尝试学习fmbt,在c++ test使用共享库时,共享库的源文件是从另一个文件中预处理的,如下面的make输出所示:
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
文件:
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
文件。
这里是mycountertest.cc
内容,特殊的类名是否与它有关? :
#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
}
答案 0 :(得分:1)
为什么gdb没有使用生成的mycountertest.cc文件
因为被告知不要。特别是,这一行:
Private Sub cusVal_ServerValidate(source As Object, args As ServerValidateEventArgs)
If String.IsNullOrEmpty(args.Value.Trim) Then
args.IsValid = False
Else
args.IsValid = True
End If
End Sub
告诉GCC告诉GDB,后面的代码是从#line 17 "mycountertest.cc.aal"
bool action1_guard(const std::string& name) {
的第17行生成的,这就是GDB将要显示的内容。
通常这正是人们想要生成的代码。
您可以在编译之前安全地从mycountertest.cc.aal
中删除#line
指令,然后GDB会向您显示生成的源:
mycountertest.cc