danny
danny

Reputation: 1145

gdb wrong filename in shared library

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 

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() {

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

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
}

Upvotes: 1

Views: 231

Answers (1)

Employed Russian
Employed Russian

Reputation: 213375

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) {

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.

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

Upvotes: 1

Related Questions