OrenIshShalom
OrenIshShalom

Reputation: 7162

Problems with setting breakpoints in a gdb sciprt

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!

Upvotes: 0

Views: 75

Answers (1)

Employed Russian
Employed Russian

Reputation: 213897

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

Upvotes: 1

Related Questions