From patchwork Thu Sep 24 08:33:01 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Joos, Christina" X-Patchwork-Id: 144559 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 26D0B4BB5891 for ; Thu, 24 Sep 2026 08:36:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 26D0B4BB5891 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 X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org 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 X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, TXREP, T_SPF_TEMPERROR shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on 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 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",