gdb共享库中的文件名错误 [英] gdb wrong filename in shared library

查看:60
本文介绍了gdb共享库中的文件名错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在 c ++测试中学习fmbt它正在使用共享库,共享库的源文件是从另一个文件中预处理的,如以下make输出所示:

Trying to learn fmbt ,in the c++ test it is using a shared library, the source file of the shared library is preprocessed from another file as in the following make output shows:

g++ -O0 -g -Wall -pedantic -I../../src -I/usr/include/fmbt -fPIC   -c -o mycounter.o mycounter.cc

fmbt-aalc -o mycountertest.cc mycountertest.cc.aal

g++ -O0 -g -Wall -pedantic -I../../src -I/usr/include/fmbt -fPIC   -c -o mycountertest.o mycountertest.cc

g++ -shared -o mycountertest.so mycounter.o mycountertest.o 

当我尝试调试共享库时,它总是转到 mycountertest.cc.aal 文件:

When I am trying to debug the shared the library, it always go to the mycountertest.cc.aal file:

ubuntu@i-hics5mzq:~/fMBT/examples/c++-unittest$ gdb  fmbt
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.3) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.

Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from fmbt...done.
(gdb) break awrapper.cc:149
Breakpoint 1 at 0x585e06: file awrapper.cc, line 149.
(gdb) run test.conf
Starting program: /usr/local/bin/fmbt test.conf
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
<fmbt_log>
<version>
    0.38-1

</version>
<conf_load>
    <conf_file name="test.conf"/>
    <end_time time="1501727367.947618"/>
</conf_load>
<conf_execute>
    <action_name name="iCreate"/>
    <action_name name="iDestroy"/>
    <action_name name="iIncrement"/>
    <action_name name="iReset"/>
    <action_name name="iCount"/>
    <test_engine>
        <tags enabled=""/>
        <status steps="0" coverage="0.000000" scov="0.000000e+00"/>
        <current_time time="1501727366.958535"/>
        <suggested_action type="input" name="iCreate" time="1501727366.958600"/>


Breakpoint 1, Awrapper::execute (this=0x93b6d0, action=std::vector of length 1, capacity 1 = {...}) at awrapper.cc:149
149       int tmp=ada->adapter_execute(1,"");
(gdb) s
_gen_mycountertest::adapter_execute (this=0x94ce50, action=1, param=0x65f8b0 "") at mycountertest.cc.aal:27
27              adapter() {

为什么gdb不使用生成的 mycountertest.cc 文件.

why gdb is not using the generated mycountertest.cc file.

这是 mycountertest.cc 的内容,特殊类名是否与之有关?:

here is the mycountertest.cc content, does the special class name has something to do with it ? :

#line 3 "mycountertest.cc.aal"

        #include "mycounter.h"
    #include "aal.hh"

class _gen_mycountertest:public aal {
private:

#line 6 "mycountertest.cc.aal"
//variables

        MyCounter* mycounter;
        int value;


//action1: "iCreate"

#line 17 "mycountertest.cc.aal"
bool action1_guard(const std::string& name) {
{
 return mycounter == NULL; 
}
return true;//default
}

推荐答案

为什么gdb没有使用生成的mycountertest.cc文件

why gdb is not using the generated mycountertest.cc file

因为被告知不要这样做.特别是这一行:

Because it was told not to. In particular, this line:

#line 17 "mycountertest.cc.aal"
bool action1_guard(const std::string& name) {

告诉GCC GDB,其后跟的任何代码都是从 mycountertest.cc.aal 的第17行生成的,因此GDB将显示该内容.

tells GCC to tell GDB that whatever code follows was generated from line 17 of mycountertest.cc.aal, so that's what GDB will show.

通常,这正是生成代码所要的.

Usually that's exactly what one wants for generated code.

您可以在编译之前从 mycountertest.cc 中安全地剥离 #line 指令,然后GDB将向您显示生成的源代码:

You can safely strip the #line directives from mycountertest.cc before compiling it, and then GDB will show you the generated source:

fmbt-aalc mycountertest.cc.aal | sed -e '/^#line/d' > mycountertest.cc

这篇关于gdb共享库中的文件名错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆