Trying to get the current breakpoint’s source location, preferably as a (“file.c”, 15) tuple.
I know about the edit
command, but it won’t do as I don’t want to open a new editor window (my goal is to run a tmux command that will navigate to the breakpoint in an already open editor). It would be great if there was a way to what the edit
does but as text, or just to get the current breakpoint’s line and file in a script.
I’ve successfully set up a Python command, but can’t find documentation on how to access the current breakpoint:
import gdb
class GetSourceLocationCommand(gdb.Command):
def __init__(self):
gdb.Command.__init__(self, "foo", gdb.COMMAND_USER)
def invoke(self, arg, from_tty):
print("hw")
breakp = gdb.selected_frame().pc()
if breakp is None:
return
print(breakp)
GetSourceLocationCommand()
This seems to be really simple but I can’t find how to do it
Egor Sozonov is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.