From 80ffe7226459e3edf840d0c23462d93cb560d2de Mon Sep 17 00:00:00 2001 From: Hannes Domani Date: Tue, 12 Dec 2023 15:57:14 +0100 Subject: Fix gdb.FinishBreakpoint when returning to an inlined function Currently, when creating a gdb.FinishBreakpoint in a function called from an inline frame, it will never be hit: ``` (gdb) py fb=gdb.FinishBreakpoint() Temporary breakpoint 1 at 0x13f1917b4: file C:/src/repos/binutils-gdb.git/gdb/testsuite/gdb.python/py-finish-breakpoint.c, line 47. (gdb) c Continuing. Thread-specific breakpoint 1 deleted - thread 1 no longer in the thread list. [Inferior 1 (process 1208) exited normally] ``` The reason is that the frame_id of a breakpoint has to be the ID of a real frame, ignoring any inline frames. With this fixed, it's working correctly: ``` (gdb) py fb=gdb.FinishBreakpoint() Temporary breakpoint 1 at 0x13f5617b4: file C:/src/repos/binutils-gdb.git/gdb/testsuite/gdb.python/py-finish-breakpoint.c, line 47. (gdb) c Continuing. Breakpoint 1, increase_inlined (a=0x40fa5c) at C:/src/repos/binutils-gdb.git/gdb/testsuite/gdb.python/py-finish-breakpoint.c:47 (gdb) py print(fb.return_value) -8 ``` Approved-By: Tom Tromey --- gdb/python/py-finishbreakpoint.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gdb/python/py-finishbreakpoint.c') diff --git a/gdb/python/py-finishbreakpoint.c b/gdb/python/py-finishbreakpoint.c index 627eb29..7f3658d 100644 --- a/gdb/python/py-finishbreakpoint.c +++ b/gdb/python/py-finishbreakpoint.c @@ -212,7 +212,8 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs) "be set on a dummy frame.")); } else - frame_id = get_frame_id (prev_frame); + /* Get the real calling frame ID, ignoring inline frames. */ + frame_id = frame_unwind_caller_id (frame); } } catch (const gdb_exception &except) -- cgit v1.1