From patchwork Fri May 24 15:40:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ijaz, Abdul B" X-Patchwork-Id: 90828 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C5A2A386D611 for ; Fri, 24 May 2024 15:42:44 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) by sourceware.org (Postfix) with ESMTPS id A87DA386C5A8 for ; Fri, 24 May 2024 15:42:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A87DA386C5A8 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 A87DA386C5A8 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716565332; cv=none; b=Z+uWWaqE/TRQ2L4/IkbwJJLq15b5aR8LrQ0eIZB69g612MoHmA+jd6lkKiHWkbl3hoczPVy88nTV/Nhko6NsC7YiqOx2vYgSKG+vng2yYgEenG/51V26SoKALtt/6GYFK8RO9GQEGHZ9FGuQpZhJzSzji+wcBfg9AHD5QFVwHD0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716565332; c=relaxed/simple; bh=7UIYQtcj7gNu+lBTtA3Hu9nHJ1P9L/0+njmkxpbJ5AA=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=XFrIuyKTAmUHmSYONtWDykhjMmNTVyyaJPUc2d2bUCadzixF1trDI3V+iSKH73NUOPpnPX4q1ctow+5YSSL+ltAcgE69UIT2nc8CyoKUBBm3skmgjyLUsbarETrB+cVg+FO5Fv8c9EO66ymJN51vRQxWOyRuNKoycHwoEmFgVyA= 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=1716565328; x=1748101328; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7UIYQtcj7gNu+lBTtA3Hu9nHJ1P9L/0+njmkxpbJ5AA=; b=FQ51Y+FJp/T0PPuxWYaepRgxD3lqBDqzMdumZEG/15eThAsHEGTxv230 6s4Zlk5d38PGA6bOjtapjgwc47t9M9g+d1KZWf0FLHHP5tK5vVYBED+oW 8mePJ0YXH42u3L5wFTEoKSHeiZWNxjOQEQs/b/UUl9KOydqLCHKEkk4bY e2u9lEE+c0XllkvFJOPNQRm9gHMNeix5BiNjS2nsvCXI8xmmD5iU1Ccmf vXEI/K6xWcLR6o15ehnLZirBCnnobIj98CmCyzCQAoOCWiVisesExbkjy n54J6lUxj4a9mslLHO5Oy1V4QtP8RLu5McXLPD78EiURfoUAgm3rlMigo w==; X-CSE-ConnectionGUID: WnY6Qi1vTS+peoJpN4wrpQ== X-CSE-MsgGUID: 4oi82Bz4SZiK5vnO66q20A== X-IronPort-AV: E=McAfee;i="6600,9927,11082"; a="23554324" X-IronPort-AV: E=Sophos;i="6.08,185,1712646000"; d="scan'208";a="23554324" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2024 08:42:08 -0700 X-CSE-ConnectionGUID: 0o8DBU/lTtme85/LLpRn8w== X-CSE-MsgGUID: hxiQhGKqRrWQ6vQD7whAMw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,185,1712646000"; d="scan'208";a="65279182" Received: from abijaz-mobl2.ger.corp.intel.com (HELO localhost) ([10.94.253.168]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2024 08:42:07 -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 v8 09/10] gdb, mi: Skip trampoline functions for the -stack-list-arguments command. Date: Fri, 24 May 2024 17:40:31 +0200 Message-Id: <20240524154032.12652-10-abdul.b.ijaz@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240524154032.12652-1-abdul.b.ijaz@intel.com> References: <20240524154032.12652-1-abdul.b.ijaz@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, 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+patchwork=sourceware.org@sourceware.org From: "Ijaz, Abdul B" This change skips trampoline functions for the '-stack-list-arguments' command when the option 'skip-trampoline-functions' is set to 'on'. Before this change, GDB prints the arguments of frames indicated by the compiler with DIE "DW_AT_trampoline" in the backtrace for the mi command stack-list-arguments, but for better user experience, all such frames can be 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-args 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 -stack-list-arguments' command output looks like: ''' (gdb) -stack-list-arguments 0 ^done, stack-args=[ frame={level="0",args=[name="x",name="y"]}, frame={level="1",args=[]}, frame={level="2",args=[name="num1",name="num2"]}, frame={level="3",args=[]}, frame={level="4",args=[]}] ''' After change: ''' (gdb) -stack-list-arguments 0 ^done, stack-args=[ frame={level="0",args=[name="x",name="y"]}, frame={level="1",args=[name="num1",name="num2"]}, frame={level="2",args=[]}] ''' The test gdb.mi/mi-func-treampoline is updated for testing the change. 2024-05-24 Ijaz, Abdul B Reviewed-By: Eli Zaretskii --- gdb/doc/gdb.texinfo | 3 +++ gdb/mi/mi-cmd-stack.c | 7 +++++++ gdb/testsuite/gdb.mi/mi-func-trampoline.exp | 13 ++++++++++--- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 9e273e80893..bee529735a6 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -35261,6 +35261,9 @@ variable object is updated, @value{GDBN} makes sure that the thread/frame combination the variable object is bound to still exists, and re-evaluates the variable object in context of that thread/frame. +If the option @code{skip-trampoline-functions} is set, @value{GDBN} will +not show trampoline functions in the stack. + The following is the complete set of @sc{gdb/mi} operations defined to access this functionality: diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c index 88a8af8adcf..e01c708c345 100644 --- a/gdb/mi/mi-cmd-stack.c +++ b/gdb/mi/mi-cmd-stack.c @@ -405,6 +405,13 @@ mi_cmd_stack_list_args (const char *command, const char *const *argv, int argc) i++, fi = get_prev_frame (fi)) { QUIT; + if (skip_trampoline_functions) + { + for (int j = 0; (SAFE_TRAMPOLINE_CHAIN (j, fi) + && in_trampoline_frame (fi)); ++j) + fi = get_prev_frame (fi); + } + ui_out_emit_tuple tuple_emitter (uiout, "frame"); uiout->field_signed ("level", i); list_args_or_locals (user_frame_print_options, diff --git a/gdb/testsuite/gdb.mi/mi-func-trampoline.exp b/gdb/testsuite/gdb.mi/mi-func-trampoline.exp index 34a2c464f21..44daba74cde 100644 --- a/gdb/testsuite/gdb.mi/mi-func-trampoline.exp +++ b/gdb/testsuite/gdb.mi/mi-func-trampoline.exp @@ -13,9 +13,9 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -# Test -stack-list-frames command for functions with trampoline -# calls. Also checks if trampoline frames are filtered while printing -# stack. +# Test -stack-list-frames and -stack-list-arguments command for functions +# with trampoline calls. Also checks if trampoline frames are filtered +# while printing stack. require allow_fortran_tests @@ -55,6 +55,10 @@ set frame1_regx "\{level=\"0\",addr=\"$hex\",func=\"second\",file=\".*func-tramp set frame2_regx "\{level=\"2\",addr=\"$hex\",func=\"first\",.*\}" set frame3_regx "\{level=\"4\",addr=\"$hex\",func=\"func_trampoline\",.*\}" +set arg1_regx "\{level=\"0\",args=\\\[name=\"x\",name=\"y\"\\\]\}" +set arg2_regx "\{level=\"1\",args=\\\[name=\"num1\",name=\"num2\"\\\]\}" +set arg3_regx "\{level=\"2\",args=\\\[\\\]\}" + # Set breakpoint inside the innermost function 'second'. mi_create_breakpoint "-t $srcfile:$inner_loc" \ "insert breakpoint at line $inner_loc " \ @@ -66,3 +70,6 @@ mi_expect_stop \ mi_gdb_test "100-stack-list-frames" \ "100\\^done,stack=\\\[frame=${frame1_regx},frame=${frame2_regx},frame=${frame3_regx}\\\]" + +mi_gdb_test "200-stack-list-arguments 0" \ + "200\\^done,stack-args=\\\[frame=${arg1_regx},frame=${arg2_regx},frame=${arg3_regx}\\\]"