From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id oasUIkmD0mimLA8AWB0awg (envelope-from ) for ; Tue, 23 Sep 2025 07:23:53 -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=UTmP+OGW; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 86D5E1E047; Tue, 23 Sep 2025 07:23:53 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.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,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 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 CD7AB1E047 for ; Tue, 23 Sep 2025 07:23:52 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6A6143858406 for ; Tue, 23 Sep 2025 11:23:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6A6143858406 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=UTmP+OGW Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) by sourceware.org (Postfix) with ESMTPS id 773713858C2D for ; Tue, 23 Sep 2025 11:19:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 773713858C2D 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 773713858C2D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1758626352; cv=none; b=B8lJ5/z5chy3vNiUUXbY17oD0lo9yPQEu2JR3FZX0wc8KevkFKqFFlH3NWPLvpYNM6oPumU5Q+Q/vC8qnLViodqYJ5jrtHfWXzKHadUCBJ7kaMWXhj+n5V2zBM4QlZFQJ6pmTV5DjGn9wGfWZHOjttcZCCbPaNZ/4L6jrCj4wGU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1758626352; c=relaxed/simple; bh=11cr0nCpTMGLzQghwc3HmXwMATcDoWOkwMo7hY4oAI4=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=HsRRMXmrJUAhGGptK2TUCLJqQUDBO3MMIrzXkhOavDSzUf1zylhnIjLgscjZR+RjhF7V0jRrbyXuJLg4493yFtZigdbF3ip1xwT47UlLgShToEtRCCbqed8NMkikkmCMGaBWuSN45C1NG/16mWDtQpThuCjYIKvfJR6YLOoztPo= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 773713858C2D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1758626353; x=1790162353; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=11cr0nCpTMGLzQghwc3HmXwMATcDoWOkwMo7hY4oAI4=; b=UTmP+OGWoHUWZwpVbsmORsdaimu0H9r2f0ssG7unh8LT1ZJBLmnYFGxE /8+GoCurFs3aJu04pH7684JIt1wTFV0bchKt78klGqoWtfNl4vZ1vOgmS S5J2YhEmtkwUzbtcn8172QJTD05aF8ZpcwCmeQvEugYnhn0KXULj+zEzX Sty7AsKQev4Ysn3aU/M8vWYbXRVdHADqs1dbzdjuCFhB4xtgEPlp10Ico DsG5L+EJlet0bSKEk8/1TwuBLTuOC5hQvSrwbozGp5Jwou0e8/+bWYuPx WJjZM+6St5zYBPSC3zVXgHyD0UWMRumP7j/6y7Z5lUkWBQhKwShDosWKc A==; X-CSE-ConnectionGUID: ngfHfJCmRW6m8trB8fynHw== X-CSE-MsgGUID: WzC9rTpTRk29RgbkS9F1FA== X-IronPort-AV: E=McAfee;i="6800,10657,11561"; a="60827518" X-IronPort-AV: E=Sophos;i="6.18,287,1751266800"; d="scan'208";a="60827518" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Sep 2025 04:19:12 -0700 X-CSE-ConnectionGUID: iP29UF72SJiXOPkP3g0Q/w== X-CSE-MsgGUID: no7Qem1+Q2SqwkHEpQMCEg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.18,287,1751266800"; d="scan'208";a="177118659" Received: from gkldtt-dev-004.igk.intel.com (HELO localhost) ([10.123.221.202]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Sep 2025 04:19:11 -0700 From: Christina Schimpe To: gdb-patches@sourceware.org Subject: [PATCH 2/9] gdb: Refactor 'stack.c:print_frame'. Date: Tue, 23 Sep 2025 11:18:35 +0000 Message-Id: <20250923111842.4091694-3-christina.schimpe@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250923111842.4091694-1-christina.schimpe@intel.com> References: <20250923111842.4091694-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." --- gdb/stack.c | 90 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 57 insertions(+), 33 deletions(-) diff --git a/gdb/stack.c b/gdb/stack.c index add1c547b55..3efb4ebdbc2 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -1314,6 +1314,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, @@ -1359,12 +1413,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 (" ("); @@ -1397,28 +1447,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)) @@ -1428,12 +1457,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: Am Campeon 10, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de Managing Directors: Sean Fennelly, Jeffrey Schneiderman, Tiffany Doon Silva Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928