Reputation: 1501
I'm currently debugging syslinux (a boot loader) through the gdb stub of qemu.
Recently, I wrote some gdb commands that (un)load the debug symbols everytime a module is dynamically (un)loaded. In order not to disrupt the execution, I ended the commands with continue
.
break com32/lib/sys/module/elf_module.c:282 commands silent python name = gdb.parse_and_eval("module->name").string() addr = int(str(gdb.parse_and_eval("module->base_addr")), 0) gdb.execute("load-syslinux-module %s 0x%08x" % (name, addr)) end continue end
However, when stepping through the code line by line, if the next
or step
command makes the execution hit the breakpoint, the breakpoints takes precedence, the commands are executed, including the continue
. And the execution continue irrespectively of the line-by-line debugging I was doign. This also happen if I try to step over the function that has this breakpoint.
How can I keep (un)loading the debug symbols on the fly while not interfering with the debugging?
Is there an alternative to the continue
command? Maybe using breakpoints isn't the right way? I'd take any solution.
Upvotes: 1
Views: 849
Reputation: 22539
This can't be done from the gdb CLI. However, it is easy to do from Python.
In Python the simplest way is to define one's own gdb.Breakpoint
subclass, and define the stop
method on it. This method can do the work you like, then return False
to tell gdb to continue.
The stop
facility was designed to avoid the problems with cont
in commands
. See the documentation for more details.
Upvotes: 2