diff options
| author | Andrew Burgess <aburgess@redhat.com> | 2026-01-23 15:12:17 +0000 |
|---|---|---|
| committer | Andrew Burgess <aburgess@redhat.com> | 2026-03-05 17:45:28 +0000 |
| commit | 99d7dc93ce3a5bbcf30ac6715edf3fb3c0e92d94 (patch) | |
| tree | 17f48aaf87e61749ee70e2b64a9fc9652aa7146b /gdb/python | |
| parent | d0c1dcb58e8d88f2c4ede55573dac7f04c3cfd55 (diff) | |
| download | binutils-99d7dc93ce3a5bbcf30ac6715edf3fb3c0e92d94.tar.gz binutils-99d7dc93ce3a5bbcf30ac6715edf3fb3c0e92d94.tar.bz2 binutils-99d7dc93ce3a5bbcf30ac6715edf3fb3c0e92d94.zip | |
gdb/python: don't allow FinishBreakpoints for inline frames
Creating a Python gdb.FinishBreakpoint for an inline frame doesn't
work.
If we look at the 'finish' command, in the finish_command
function (infcmd.c) then we see that GDB handles inline frames very
different to non-inline frames.
For non-inline frames GDB creates a temporary breakpoint and then
resumes the inferior until the breakpoint is hit.
But for inline frames, GDB steps forward until we have left the inline
frame.
When it comes to gdb.FinishBreakpoint we only have the "create a
temporary breakpoint" mechanism; that is, after all, what the
FinishBreakpoint is, it's a temporary breakpoint placed at the
return address in the caller.
Currently, when a FinishBreakpoint is created within an inline frame,
GDB ends up creating the breakpoint at the current $pc. As a result
the breakpoint will not be hit before the current function
exits (unless there's a loop going on, but that's not the point).
We could imagine what a solution to this problem would look like, GDB
would need to figure out the set of addresses for all possible exit
points from the inline function, and place a breakpoint at each of
these locations. I don't propose doing that in this commit.
Instead, I plan to update the docs to note that creating a
FinishBreakpoint within an inline frame is not allowed, and I will
catch this case within bpfinishpy_init (python/py-finishbreakpoint.c)
and throw an error.
Though the error is new, all I'm doing is raising an error for a case
that never worked.
There's a new test to cover this case.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=18339
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Tom Tromey <tom@tromey.com>
Diffstat (limited to 'gdb/python')
| -rw-r--r-- | gdb/python/py-finishbreakpoint.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/gdb/python/py-finishbreakpoint.c b/gdb/python/py-finishbreakpoint.c index 4af8ec6c75f..834f85037c0 100644 --- a/gdb/python/py-finishbreakpoint.c +++ b/gdb/python/py-finishbreakpoint.c @@ -192,10 +192,16 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs) PyErr_SetString (PyExc_ValueError, _("Invalid ID for the `frame' object.")); } + else if (get_frame_type (frame) == INLINE_FRAME) + { + PyErr_SetString + (PyExc_ValueError, + _("Unable to create FinishBreakpoint for inline frame.")); + } else { prev_frame = get_prev_frame (frame); - if (prev_frame == 0) + if (prev_frame == nullptr) { PyErr_SetString (PyExc_ValueError, _("\"FinishBreakpoint\" not " |
