From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id AbLsLq6gS2pOwSkAWB0awg (envelope-from ) for ; Mon, 06 Jul 2026 08:33:50 -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=ILPfREpc; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id BC0B51E098; Mon, 06 Jul 2026 08:33:50 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (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 146501E070 for ; Mon, 06 Jul 2026 08:33:50 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B345C4BA2E3B for ; Mon, 6 Jul 2026 12:33:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B345C4BA2E3B Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=ILPfREpc Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) by sourceware.org (Postfix) with ESMTPS id D7CE84BA23C7 for ; Mon, 6 Jul 2026 12:32:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D7CE84BA23C7 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 D7CE84BA23C7 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=198.175.65.17 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783341125; cv=none; b=bbmsBaK9BMlTItdpXdLaRd6oWgcvL27BUFSPfIaP3Z1pmIbAa9B4TnJUlCRUy+bO/96OV0cEQSVz2Bvmh7cFYBFXf3cGQTgEHMhp4TJKsuMBL0s9cte4+Ze40T8WexV2T3G3J1OALEDE9rPVeb/e88EDqXKABkLBVakPtiYGkR4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783341125; c=relaxed/simple; bh=EpXHKr+UUXS7SLJj8jtrbMz2EW8ab9vVoe/4yHjt+jQ=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=drGTrTMKDg9GoSikF5YJMQtA83nUhygKam/9cCi/p4Xp6CT0BtUHS2tDo5ivXVFL6PUqx/4hCopFwrJSyFyHBAXh0E2U+1qVQGnStq9ZxE7PLM2CKIIwkgFFkl8r0AOxyW1EgmWW1tx8w4rf9lp+kx0tw6VCGyjGsJ76Qp4fh0Q= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=ILPfREpc DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D7CE84BA23C7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1783341125; x=1814877125; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=EpXHKr+UUXS7SLJj8jtrbMz2EW8ab9vVoe/4yHjt+jQ=; b=ILPfREpch900FfAldN5O/4xZKCp7QH9pVCytfIuo9Rbw6nC/0IsXzu7p +eeBZM/9ikl93vQQ4VMgSOTA4S3Oj21BuABHMBT80HX4QEc39WGR+pROt csspvQl+V4uSU553J7vW99jcOCgkshlccNchkIJtmsAWVjql5fmr8Sb5a x2nV/nJRA2NBBmOS43xeQePS+kWYQnqFLhpQhkyWKvM4rOe9lyHIzi0uC 68bCt+D9lJ3/OQhY5/VZhWesBX1mDQiGDEJnZymDl52KbGPT1GFuNZ6Vb 1QuEahGOIfkjo4J7kjwV9RmobApR6kUJ2yAlE2O67cNhPSsb834FUd1On A==; X-CSE-ConnectionGUID: 2HmVVXWHSbS1gJhlBxkYMA== X-CSE-MsgGUID: 0vhxeD0YSDKz2IkU79IqTA== X-IronPort-AV: E=McAfee;i="6800,10657,11838"; a="84001669" X-IronPort-AV: E=Sophos;i="6.25,149,1779174000"; d="scan'208";a="84001669" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2026 05:32:05 -0700 X-CSE-ConnectionGUID: wcODZseCSA6650CIfKXwqA== X-CSE-MsgGUID: cL2MvEGrRSCrdi/6N49aZg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,149,1779174000"; d="scan'208";a="257285216" Received: from gkldtt-dev-004.igk.intel.com (HELO localhost) ([10.123.221.202]) by ORVIESA003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2026 05:32:04 -0700 From: Christina Schimpe To: gdb-patches@sourceware.org Cc: tom@tromey.com, thiago.bauermann@linaro.org Subject: [PATCH v3 04/12] gdb: Refactor 'stack.c:print_frame'. Date: Mon, 6 Jul 2026 12:31:25 +0000 Message-Id: <20260706123133.1990441-5-christina.schimpe@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260706123133.1990441-1-christina.schimpe@intel.com> References: <20260706123133.1990441-1-christina.schimpe@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 Refactor the function 'stack.c:print_frame' by introducing several small functions. The functions will also be used in a later patch "gdb: Implement 'bt shadow' to print the shadow stack backtrace." Approved-By: Tom Tromey --- gdb/stack.c | 90 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 57 insertions(+), 33 deletions(-) diff --git a/gdb/stack.c b/gdb/stack.c index e084976eabf..25527618a4d 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -1258,6 +1258,60 @@ find_frame_funname (const frame_info_ptr &frame, enum language *funlang, return funname; } +/* Print the library LIB to UIOUT for the printing of frame + information. */ + +static void +print_lib (ui_out *uiout, const char *lib) +{ + annotate_frame_where (); + uiout->wrap_hint (2); + uiout->text (" from "); + uiout->field_string ("from", lib, file_name_style.style ()); +} + +/* Print the filenname of SAL to UIOUT for the printing of frame + information. */ + +static void +print_filename (ui_out *uiout, symtab_and_line sal) +{ + annotate_frame_source_begin (); + const char *filename_display; + + filename_display = symtab_to_filename_for_display (sal.symtab); + uiout->wrap_hint (3); + uiout->text (" at "); + annotate_frame_source_file (); + uiout->field_string ("file", filename_display, file_name_style.style ()); + + if (uiout->is_mi_like_p ()) + { + const char *fullname = symtab_to_fullname (sal.symtab); + uiout->field_string ("fullname", fullname); + } + + annotate_frame_source_file_end (); + uiout->text (":"); + annotate_frame_source_line (); + uiout->field_signed ("line", sal.line, line_number_style.style ()); + annotate_frame_source_end (); +} + +/* If available, print FUNNAME to UIOUT for the printing of frame + information. */ + +static void +print_funname (ui_out *uiout, + gdb::unique_xmalloc_ptr const &funname) +{ + annotate_frame_function_name (); + string_file stb; + gdb_puts (funname ? funname.get () : "??", &stb); + uiout->field_stream ("func", stb, function_name_style.style ()); + uiout->wrap_hint (3); +} + static void print_frame (struct ui_out *uiout, const frame_print_options &fp_opts, @@ -1303,12 +1357,8 @@ print_frame (struct ui_out *uiout, annotate_frame_address_end (); uiout->text (" in "); } - annotate_frame_function_name (); + print_funname (uiout, funname); - string_file stb; - gdb_puts (funname ? funname.get () : "??", &stb); - uiout->field_stream ("func", stb, function_name_style.style ()); - uiout->wrap_hint (3); annotate_frame_args (); uiout->text (" ("); @@ -1338,28 +1388,7 @@ print_frame (struct ui_out *uiout, } uiout->text (")"); if (print_what != SHORT_LOCATION && sal.symtab) - { - const char *filename_display; - - filename_display = symtab_to_filename_for_display (sal.symtab); - annotate_frame_source_begin (); - uiout->wrap_hint (3); - uiout->text (" at "); - annotate_frame_source_file (); - uiout->field_string ("file", filename_display, - file_name_style.style ()); - if (uiout->is_mi_like_p ()) - { - const char *fullname = symtab_to_fullname (sal.symtab); - - uiout->field_string ("fullname", fullname); - } - annotate_frame_source_file_end (); - uiout->text (":"); - annotate_frame_source_line (); - uiout->field_signed ("line", sal.line, line_number_style.style ()); - annotate_frame_source_end (); - } + print_filename (uiout, sal); if (print_what != SHORT_LOCATION && pc.has_value () && (funname == NULL || sal.symtab == NULL)) @@ -1369,12 +1398,7 @@ print_frame (struct ui_out *uiout, get_frame_address_in_block (frame)); if (lib) - { - annotate_frame_where (); - uiout->wrap_hint (2); - uiout->text (" from "); - uiout->field_string ("from", lib, file_name_style.style ()); - } + print_lib (uiout, lib); } if (uiout->is_mi_like_p ()) uiout->field_string ("arch", -- 2.34.1 Intel Deutschland GmbH Registered Address: Dornacher Strasse 1, 85622 Feldkirchen, Germany Tel: +49 89 991 430, www.intel.de Managing Directors: Harry Demas, Jeffrey Schneiderman, Yin Chong Sorrell Chairperson of the Supervisory Board: Nicole Lau Registered Seat: Munich Commercial Register: Amtsgericht Muenchen HRB 186928