You can see my answer to
Does GDB have a “step-to-next-call” instruction?
: there is no native GDB command for that (as far as I know, they may have worked on that), but it's easy to do in Python:
import gdb
class StepNoLibrary (gdb.Command):
def __init__ (self):
super (StepNoLibrary, self).__init__ ("step-no-library",
gdb.COMMAND_OBSCURE)
def invoke (self, arg, from_tty):
step_msg = gdb.execute("step", to_string=True)
fname = gdb.newest_frame().function().symtab.objfile.filename
if fname.startswith("/usr"):
# inside a library
SILENT=False
gdb.execute("finish", to_string=SILENT)
else:
# inside the application
print(step_msg[:-1])
StepNoLibrary()
just put that in a file, source it with GDB (or in your .gdbinit) and that will provide you the new command step-no-library
.
It's easy to read what it does, it goes one step
forward, and if the step ends up in a file stored in /usr/*
, it finish
es it to come back to the application.
Of course that's a naive implementation, if you requirements are different from that just edit the function code!