]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
[gdb/cli] Fix return from frame containing inline frame
authorTom de Vries <tdevries@suse.de>
Thu, 23 Jan 2025 13:13:16 +0000 (14:13 +0100)
committerTom de Vries <tdevries@suse.de>
Thu, 23 Jan 2025 13:13:16 +0000 (14:13 +0100)
commitb132f2344c0b58938bd11806ae2dd174b1b023e4
tree7c69531134e707e1e0fcb829af13539c17918868
parent0c1b7977c93facc6e198da457e17559c0ba7b10b
[gdb/cli] Fix return from frame containing inline frame

Consider test-case gdb.base/return-3.exp:
...
$ gdb -q outputs/gdb.base/return-3/return-3
Reading symbols from outputs/gdb.base/return-3/return-3...
(gdb)
...

Function bar is an inlined function, and consequently we cannot return from
it:
...
(gdb) b bar
Breakpoint 1 at 0x4006ac: file return-3.c, line 25.
(gdb) r
Starting program: return-3
  ...
Breakpoint 1, bar () at return-3.c:25
25        c++;
(gdb) return
Can not force return from an inlined function.
(gdb)
...

However, function foo is not an inline function, and we should be able to
return from it, but we get the same error message:
...
(gdb) up
31        bar ();
(gdb) return
Can not force return from an inlined function.
(gdb)
...

Fix this by using the selected frame rather than the current frame in
return_command, such that we get instead:
...
(gdb) up
31        bar ();
(gdb) return
40        printf ("%d\n", c);
(gdb)
...

Tested on aarch64-linux.

Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
PR cli/32479
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32479
gdb/stack.c
gdb/testsuite/gdb.base/return-3.c [new file with mode: 0644]
gdb/testsuite/gdb.base/return-3.exp [new file with mode: 0644]