From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id oHpyLL1dBWbUdhkAWB0awg (envelope-from ) for ; Thu, 28 Mar 2024 08:08:29 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=RQZfX9Ad; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id B0C361E0C0; Thu, 28 Mar 2024 08:08:29 -0400 (EDT) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 9F92C1E030 for ; Thu, 28 Mar 2024 08:08:27 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5B5633858420 for ; Thu, 28 Mar 2024 12:08:27 +0000 (GMT) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) by sourceware.org (Postfix) with ESMTPS id 50E1B3858420 for ; Thu, 28 Mar 2024 12:06:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 50E1B3858420 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 50E1B3858420 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711627602; cv=none; b=dxVcMOQ8n8QCMJwlQgeQI5QCROoPF5jbptMvM1BuuKxDYT/qfniYuhJc3MJNUb/WIDjZJewLre+Dt226RFAxcXRrpibHii7xJLWNgTu+TNDOsSN8AzgAuqgrwPvPsvhvvxBsAJa6waW70YvER7CJlxy+4+nNs9FnL4lkQELgYXY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711627602; c=relaxed/simple; bh=haA3YbJ/N6pgTzLf7pQFcsfddNVeUQ4mmlluiSHpTxE=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=fIesW60bQVTjFdGlwkrxGYVNAOHA/z8dGQqAe2/kauk9C7Sdook9TPK9FdA4kc0csZeGF9qQoBH/jeZCBybc2XMTobUfTquO5fwr225lIz9w5YgdCTtlC6zKt/DuPEmAdRcjxjI4d0m/lb7WGuNTslwUz6VbvjtJtjkpXvJU8xM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1711627598; x=1743163598; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=haA3YbJ/N6pgTzLf7pQFcsfddNVeUQ4mmlluiSHpTxE=; b=RQZfX9AdQ742eQ6zm3DRgVcPa2+64tr+Id64ueIijCWEAFZw/raRR0qQ UChLfCWHoa2vVhMH6CFY2pF3Lau2Ge6nLRJN6pqON17D1v6TsVZ6wYZ5f ixWczLkWsK2ipqUBDd20AErJMA0phvUVUI8yFhhBU28cvOwEL5U41mDI1 kem+igWNQiSbWDvKIU9Tl7km0+wrXC78a/6qzG74u0CDI2yfY+Gz6uwLE 5iQlb9tGpadayc17QaLkc/b4CKFIuC0FiYN4fIHImy2KdYtPi//gkPpxw seNmLq6hnaAkrE1CaA36y14HPxK2qS85imfTLwAFbM/hX6sWIUA7i897O A==; X-CSE-ConnectionGUID: mSAgyG2rT96uPiMBrN6Xbg== X-CSE-MsgGUID: EG2L61B5SyW17N3UAUBk6A== X-IronPort-AV: E=McAfee;i="6600,9927,11026"; a="18158639" X-IronPort-AV: E=Sophos;i="6.07,161,1708416000"; d="scan'208";a="18158639" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2024 05:06:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,161,1708416000"; d="scan'208";a="47816113" Received: from abijaz-mobl2.ger.corp.intel.com (HELO localhost) ([10.246.42.1]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2024 05:06:35 -0700 From: Abdul Basit Ijaz To: gdb-patches@sourceware.org Cc: abdul.b.ijaz@intel.com, JiniSusan.George@amd.com, tom@tromey.com, eliz@gnu.org Subject: [PATCH v6 06/10] gdb: Skip trampoline functions for the up command. Date: Thu, 28 Mar 2024 13:05:24 +0100 Message-Id: <20240328120528.30382-7-abdul.b.ijaz@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240328120528.30382-1-abdul.b.ijaz@intel.com> References: <20240328120528.30382-1-abdul.b.ijaz@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org From: "Ijaz, Abdul B" This change skips trampoline functions when the option 'skip-trampoline-functions' is set to 'on' for the up command. Before this change, GDB processes trampoline functions indicated by the compiler with DIE "DW_AT_trampoline" and stops at the trampoline function for the 'up' command. 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-up 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 'up' command output looks like: ''' (gdb) up \#1 0x0000000000405209 in second_.t74p.t75p () at test.f90:12 12 end function first ''' After this change: ''' (gdb) up \#2 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 --- gdb/doc/gdb.texinfo | 2 +- gdb/stack.c | 7 +++++++ gdb/testsuite/gdb.fortran/func-trampoline.exp | 12 ++++++++++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 5782e06b91d..222faba5da3 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -6475,7 +6475,7 @@ 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} or @code{reverse-finish}, if +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. diff --git a/gdb/stack.c b/gdb/stack.c index 6a25054673f..2071d98ffe6 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -2605,6 +2605,13 @@ find_relative_frame (frame_info_ptr frame, int *level_offset_ptr) { frame_info_ptr prev = get_prev_frame (frame); + if (skip_trampoline_functions) + { + for (int i = 0; (SAFE_TRAMPOLINE_CHAIN (i, prev) + && in_trampoline_frame (prev)); ++i) + prev = get_prev_frame (prev); + } + if (!prev) break; (*level_offset_ptr)--; diff --git a/gdb/testsuite/gdb.fortran/func-trampoline.exp b/gdb/testsuite/gdb.fortran/func-trampoline.exp index 4cb9e4f4919..e7e4c8ae7b0 100644 --- a/gdb/testsuite/gdb.fortran/func-trampoline.exp +++ b/gdb/testsuite/gdb.fortran/func-trampoline.exp @@ -13,8 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -# Test "backtrace", "backtrace -n" and "finish" commands for functions with -# trampoline calls. +# Test "backtrace", "backtrace -n", "finish" and "up" commands for +# functions with trampoline calls. require allow_fortran_tests @@ -84,3 +84,11 @@ with_test_prefix "finish" { "${fill}first \\(num1=16, num2=3\\)${fill}" \ "${fill}(\r\nValue returned is $valnum_re = 180)"] } + +with_test_prefix "up" { + init_test + + gdb_test "up" [multi_line \ + "#$decimal.* $middle_desc" \ + "${fill}first = second \\(num1 \\+ 4, num2 \\* 3\\).*${fill}"] +} -- 2.34.1 Intel Deutschland GmbH Registered Address: Am Campeon 10, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, 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