From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id ARGPACDhtGqL3zsAWB0awg (envelope-from ) for ; Thu, 24 Sep 2026 04:36:48 -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=iQ0lwBqt; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id F254A1E033; Thu, 24 Sep 2026 04:36:47 -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 [IPv6:2620:52:6:3111::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 2BA611E033 for ; Thu, 24 Sep 2026 04:36:47 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5D1FD4BB5889 for ; Thu, 24 Sep 2026 08:36:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5D1FD4BB5889 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=iQ0lwBqt Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) by sourceware.org (Postfix) with ESMTPS id 9A1B04BB3BF5 for ; Thu, 24 Sep 2026 08:34:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9A1B04BB3BF5 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 9A1B04BB3BF5 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=192.198.163.18 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790238864; cv=none; b=N4pyzl8pthkzHy8OPMUdGvUFh6BJMzevUzCBgDoMsoXnRHGRLqIV38+yKQWsgiJpu0hAu/IL+wHE0us+Kjh6QkbqCpiE9aXQfsSjxYJTId0mXAWt3JU4f7PxQCviMHmR6gde3POGwVB8f7k0g1iSzEMMvhdld85igDQzvg0vUXU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790238864; c=relaxed/simple; bh=rOFOT20Cir/8rmlxAp83qBiwPUNS3JSrRXvXEsI15to=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=XbjkKZn3ljJERLgw1rs9eMF+jAN/z0ep3iU4+/Ts13Dsn5/1B8tbsIOL1e4Ha/HFiiAQiMXM2wazMkxwsXwxvZ3k8xjLrDahhcQdZk1ZxCacpUWzLeiZpMeR7CgxumHofdDPFdWjvYAQKXd0rowSkwuKMClTBT9V5Z0EWaoeWr4= 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=iQ0lwBqt DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9A1B04BB3BF5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1790238864; x=1821774864; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rOFOT20Cir/8rmlxAp83qBiwPUNS3JSrRXvXEsI15to=; b=iQ0lwBqt0aznrnCf0EK0wr/uuZXfJegudHUOWdEfnuJyhA0uZV0vpKVe vceM0Nyy03R2s/WOVed3zP8hnMNZC31YfqS/bPOu4WCkCZKd5DU3c//cX WbKXVlFiTqBRkwk58TDvObPEZ7NNIBv8LP16WEgDUWCZimWr2zo4GlfYp /WP83zFGLRpqq4f8Wh4YFHVoE/eX7w5phdpymAYh4zkS4gFZ4JkW9QSk/ Iv6Ko8EdSR3WDDU6uFZzaB1q1WhLtUxLLSn400IIR0Tbydi58iSluZp/q MGAyAJZggGCctHKQ6RhJJumBVBb329oa0QvPHqbG4CB+6k5L2eMiOdnE3 Q==; X-CSE-ConnectionGUID: 9u8enz+ESZCLObZh5XVt2Q== X-CSE-MsgGUID: Fq1oubDnRpi+eYlj/HDm/w== X-IronPort-AV: E=McAfee;i="6800,10657,11914"; a="90123848" X-IronPort-AV: E=Sophos;i="6.27,120,1787036400"; d="scan'208";a="90123848" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Sep 2026 01:34:23 -0700 X-CSE-ConnectionGUID: Vq4tkPdTREetz1yvsxTQaA== X-CSE-MsgGUID: 44JgXIgmQQ+ZnkxUNxl1Bg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,120,1787036400"; d="scan'208";a="277709335" Received: from gkldtt-dev-004.igk.intel.com (HELO localhost) ([10.123.221.202]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Sep 2026 01:34:21 -0700 From: Christina Joos To: gdb-patches@sourceware.org Cc: thiago.bauermann@linaro.org, tom@tromey.com, luis.machado.foss@gmail.com Subject: [PATCH v5 04/13] gdb: Refactor 'stack.c:print_frame'. Date: Thu, 24 Sep 2026 10:33:01 +0200 Message-ID: <20260924083311.1961530-5-christina.joos@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260924083311.1961530-1-christina.joos@intel.com> References: <20260924083311.1961530-1-christina.joos@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 7fe05bb52a8..cfbb22ee193 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -1295,6 +1295,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, @@ -1339,12 +1393,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 (" ("); @@ -1374,28 +1424,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)) @@ -1405,12 +1434,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.53.0 ________________________________________ Intel Deutschland GmbH Registered Address: Dornacher Strasse 1, 85622 Feldkirchen, Germany Tel: +49 (89) 99143-0 www.intel.de Managing Directors: Candice Moore, Jeffrey Schneiderman, Ramachandran Sitaraman Chairperson of the Supervisory Board: Sonja Pierer Registered Seat: Munich Commercial Register B: Amtsgericht Munich HRB 186928 This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.