Problems with setting breakpoints in a gdb sciprt

余生颓废 提交于 2019-12-12 05:39:46

问题


I am using this gdb script with 5 breakpoints:

set pagination off
break rewriter_def.h:679
break asserted_formulas.cpp:149
break Z3Solver.cpp:221
break api_solver.cpp:247
break smt_context.cpp:2950
run

When gdb runs, it stops in the third breakpoint, but not in the other breakpoints:

Breakpoint 1, klee::Z3SolverImpl::internalRunSolver ( ... ) at 
Z3Solver.cpp:221
221    int dave=0;

I make sure the other breakpoints weren't really set, by trying to manually clear them from the gdb console:

(gdb) clear api_solver.cpp:247
No breakpoint at api_solver.cpp:247.

If I manually copy and paste the other break commands from the script file to the gdb console, everything works fine:

(gdb) break api_solver.cpp:247
Breakpoint 2 at 0x7ffff5afbb31: file ../src/api/api_solver.cpp, line 
247.
(gdb) cont
Continuing.

Breakpoint 2, Z3_solver_assert ( ... ) at ../src/api/api_solver.cpp:247
247    to_solver_ref(s)->assert_expr(to_expr(a));

The breakpoint that is being set by the script originates from one source tree (KLEE), and the other four breakpoints that are not being set originate from another source tree (Z3). Could this be some kind of a PATH problem?? Any help is very much appreciated, thanks!


回答1:


If I manually copy and paste the other break commands from the script file to the gdb console, everything works fine:

The most probable cause: the other breakpoints "belong" to a shared library which has not been loaded yet.

Try cut/pasting the same commands after you load the binary into GDB, but beofre you run it. Chances are, GDB will say something like

No source file named rewriter_def.h.

You can work around this by adding start to your script before setting breakpoints: if the shared library in question is directly linked, it will be loaded by the time your program reaches main (which is what start command does).



来源:https://stackoverflow.com/questions/47388639/problems-with-setting-breakpoints-in-a-gdb-sciprt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!