From: Abdul Basit Ijaz <abdul.b.ijaz@intel.com>
To: gdb-patches@sourceware.org
Cc: abdul.b.ijaz@intel.com, JiniSusan.George@amd.com, tom@tromey.com,
eliz@gnu.org
Subject: [PATCH v6 07/10] gdb: Skip trampoline functions for the return command.
Date: Thu, 28 Mar 2024 13:05:25 +0100 [thread overview]
Message-ID: <20240328120528.30382-8-abdul.b.ijaz@intel.com> (raw)
In-Reply-To: <20240328120528.30382-1-abdul.b.ijaz@intel.com>
From: "Ijaz, Abdul B" <abdul.b.ijaz@intel.com>
This change skips trampoline functions for the return command
when the option 'skip-trampoline-functions' is set to 'on'. Before this
change, GDB processes trampoline functions indicated by the compiler with
DIE "DW_AT_trampoline" for the return command and stops at the trampoline
functions. For better user experience, all such frames can
be skipped and hidden from the user.
In this example the IFX compiler emits "DW_AT_trampoline" tag for the 'first'
and 'second' trampoline functions like following:
function second (x, y) result(z)
integer, intent(in) :: x, y
integer :: z
z = x * y ! breakpt-return
end function second
function first (num1, num2) result(total)
integer, intent(in) :: num1, num2
integer :: total
total = second (num1 + 4, num2 * 3) ! first-breakpt
total = total + 30
end function first
Related Dwarf:
0x0000013f: DW_TAG_subprogram
DW_AT_low_pc (0x0000000000404350)
DW_AT_high_pc (0x000000000040435f)
DW_AT_frame_base (DW_OP_reg6 RBP)
DW_AT_linkage_name ("second_.t74p.t75p")
DW_AT_name ("second_.t74p.t75p")
DW_AT_trampoline ("second_")
0x0000015a: DW_TAG_subprogram
DW_AT_low_pc (0x00000000004044a0)
DW_AT_high_pc (0x00000000004044af)
DW_AT_frame_base (DW_OP_reg6 RBP)
DW_AT_linkage_name ("first_.t104p.t105p")
DW_AT_name ("first_.t104p.t105p")
DW_AT_trampoline ("first_")
Before this change, the return command output looks like:
'''
(gdb) return
Make second return now? (y or n) y
\#0 0x0000000000405209 in second_.t74p.t75p () at test.f90:12
12 end function first
'''
After this change:
'''
(gdb) return
Make second return now? (y or n) y
\#0 0x00000000004051e3 in first (num1=16, num2=3) at test.f90:10
10 total = second (num1 + 4, num2 * 3) ! first-breakpt
'''
The test gdb.fortran/func-trampoline.exp is updated for testing this change.
2024-03-28 Ijaz, Abdul B <abdul.b.ijaz@intel.com>
---
gdb/doc/gdb.texinfo | 6 +++---
gdb/stack.c | 11 +++++++++++
gdb/testsuite/gdb.fortran/func-trampoline.exp | 10 +++++++++-
3 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 222faba5da3..a6f74373dfe 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -6475,9 +6475,9 @@ DWARF trampolines marked via DW_AT_trampoline are supported by this.
When issuing a @code{backtrace}, if @code{skip-trampoline-functions} is set,
@value{GDBN} will skip trampoline frames while printing the stack.
-When issuing a @code{finish}, @code{reverse-finish} or @code{up}, if
-@code{skip-trampoline-functions} is set, @value{GDBN} will skip trampoline
-frames while returning from the target function.
+When issuing a @code{finish}, @code{reverse-finish}, @code{up} or
+@code{return}, if @code{skip-trampoline-functions} is set, @value{GDBN} will
+skip trampoline frames while returning from the target function.
Currently, only DWARF trampolines marked via DW_AT_trampoline are supported by
this.
diff --git a/gdb/stack.c b/gdb/stack.c
index 2071d98ffe6..85deedce682 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -2836,6 +2836,17 @@ return_command (const char *retval_exp, int from_tty)
if (get_frame_type (get_current_frame ()) == DUMMY_FRAME)
frame_pop (get_current_frame ());
+ if (skip_trampoline_functions)
+ {
+ frame_info_ptr ret_frame = get_current_frame ();
+ for (int i = 0; (SAFE_TRAMPOLINE_CHAIN (i, ret_frame)
+ && in_trampoline_frame (ret_frame)); ++i)
+ {
+ frame_pop (ret_frame);
+ ret_frame = get_current_frame ();
+ }
+ }
+
select_frame (get_current_frame ());
/* If interactive, print the frame that is now current. */
if (from_tty)
diff --git a/gdb/testsuite/gdb.fortran/func-trampoline.exp b/gdb/testsuite/gdb.fortran/func-trampoline.exp
index e7e4c8ae7b0..dd26e5ab035 100644
--- a/gdb/testsuite/gdb.fortran/func-trampoline.exp
+++ b/gdb/testsuite/gdb.fortran/func-trampoline.exp
@@ -13,7 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/> .
-# Test "backtrace", "backtrace -n", "finish" and "up" commands for
+# Test "backtrace", "backtrace -n", "finish", "up" and "return" commands for
# functions with trampoline calls.
require allow_fortran_tests
@@ -92,3 +92,11 @@ with_test_prefix "up" {
"#$decimal.* $middle_desc" \
"${fill}first = second \\(num1 \\+ 4, num2 \\* 3\\).*${fill}"]
}
+
+with_test_prefix "return" {
+ init_test
+
+ gdb_test "return" \
+ ".*first = second \\(num1 \\+ 4, num2 \\* 3\\) \\! first-breakpt" \
+ "" "Make second return now.*y or n. $" "y"
+}
--
2.34.1
Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
next prev parent reply other threads:[~2024-03-28 12:08 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-28 12:05 [PATCH v6 00/10] GDB support for DW_AT_trampoline Abdul Basit Ijaz
2024-03-28 12:05 ` [PATCH v6 01/10] gdb, dwarf: add support for DW_AT_trampoline in DWARF reader Abdul Basit Ijaz
2024-03-28 12:05 ` [PATCH v6 02/10] gdb/symtab: add lookup for trampoline functions Abdul Basit Ijaz
2024-03-28 12:05 ` [PATCH v6 03/10] gdb: handle stepping through functions with DW_AT_trampoline Abdul Basit Ijaz
2024-03-28 13:58 ` Eli Zaretskii
2024-03-28 14:31 ` Ijaz, Abdul B
2024-03-28 12:05 ` [PATCH v6 04/10] gdb: Skip trampoline frames for the backtrace command Abdul Basit Ijaz
2024-03-28 12:05 ` [PATCH v6 05/10] gdb: Skip trampoline functions for the finish and reverse-finish commands Abdul Basit Ijaz
2024-03-28 13:59 ` Eli Zaretskii
2024-03-28 12:05 ` [PATCH v6 06/10] gdb: Skip trampoline functions for the up command Abdul Basit Ijaz
2024-03-28 14:01 ` Eli Zaretskii
2024-03-28 12:05 ` Abdul Basit Ijaz [this message]
2024-03-28 14:01 ` [PATCH v6 07/10] gdb: Skip trampoline functions for the return command Eli Zaretskii
2024-03-28 12:05 ` [PATCH v6 08/10] gdb, mi: Skip trampoline functions for the -stack-list-frames command Abdul Basit Ijaz
2024-03-28 14:02 ` Eli Zaretskii
2024-03-28 12:05 ` [PATCH v6 09/10] gdb, mi: Skip trampoline functions for the -stack-list-arguments command Abdul Basit Ijaz
2024-03-28 14:03 ` Eli Zaretskii
2024-03-28 12:05 ` [PATCH v6 10/10] gdb: Filter trampoline frames in backtrace when using Python frame-filters Abdul Basit Ijaz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240328120528.30382-8-abdul.b.ijaz@intel.com \
--to=abdul.b.ijaz@intel.com \
--cc=JiniSusan.George@amd.com \
--cc=eliz@gnu.org \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox