From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id Se7JHcZgTmqwcCwAWB0awg (envelope-from ) for ; Wed, 08 Jul 2026 10:37:58 -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=Ijr82ssp; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 753841E098; Wed, 08 Jul 2026 10:37:58 -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 C42371E024 for ; Wed, 08 Jul 2026 10:37:57 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 950A34BA2E0D for ; Wed, 8 Jul 2026 14:37:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 950A34BA2E0D 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=Ijr82ssp Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) by sourceware.org (Postfix) with ESMTPS id 9CC474BA2E18 for ; Wed, 8 Jul 2026 14:37:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9CC474BA2E18 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 9CC474BA2E18 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=198.175.65.15 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783521451; cv=none; b=AfcG+QbB8qLz52fPB4Vu2jew8w54YtIk4FV90JykajxxzBasRvjYR0iIKWkEE+xuy31AJKO+OE/LkHxHCyhJLITGKuskHkWvqeW5NvguPRJKy97bBc51EXMEbFgRKK5+730izPtzUFN/Pvay2qPOaJQe8kvBLnWQoxxHcv/ML5A= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783521451; c=relaxed/simple; bh=EpXHKr+UUXS7SLJj8jtrbMz2EW8ab9vVoe/4yHjt+jQ=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=EvkWz8ATvoXF5HJZBf2NluFkKBtp8YAB+mK32FM8TYWUKGIY+jXnls9XZ1borpKsn5RabaKL83yQF0AC/UDmEog8TRIpXVf59mWafSwhSbNin5ESSnsUevbAjSf265OH8uptUoI/AietZVHSUzUToLBxAolccZ1i0/z5meS4T3k= 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=Ijr82ssp DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9CC474BA2E18 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1783521452; x=1815057452; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=EpXHKr+UUXS7SLJj8jtrbMz2EW8ab9vVoe/4yHjt+jQ=; b=Ijr82ssp7NPeNgGk7+lhRerpIv2hgMGgoK6yp+FMx6orkVDaqcxYyNpu Djv0gUciF5klw+7ceIaLfgPmykUWBpeOtMAy02y/+WC3xfAz2CaAJmlBK UfOP4zXayxFJLElpge7yIh1t/Dgz77hyDHclQUH5nWvoS7FCaN4hUnf23 YSW9VoAlf8EEX+r1vgQBr8xn6KsdkNMFA1+qWwYzMuhaG+kJbRMKIgkew dJbrnm72k8uxqaP5lG7vuWk9plxUpFcFwD9Bof2wh7AbjI1cooVkZuPyl H8sYni2+iZf2vHw5yvtYFcl36NFxIW4qlhUK8e/TqWpzUvhCkGJr125xw A==; X-CSE-ConnectionGUID: mMQNvDRoRfaj1gYGAoCwBQ== X-CSE-MsgGUID: iknAEjpuRZWBQkKvSzTndg== X-IronPort-AV: E=McAfee;i="6800,10657,11841"; a="87867558" X-IronPort-AV: E=Sophos;i="6.25,153,1779174000"; d="scan'208";a="87867558" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jul 2026 07:37:31 -0700 X-CSE-ConnectionGUID: zbHs0xWGSmG0UpoPDBWeHQ== X-CSE-MsgGUID: mgLVHDMATPyuN9qNmEB7pw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,153,1779174000"; d="scan'208";a="252560368" Received: from gkldtt-dev-004.igk.intel.com (HELO localhost) ([10.123.221.202]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jul 2026 07:37:30 -0700 From: Christina Schimpe To: gdb-patches@sourceware.org Cc: tom@tromey.com, thiago.bauermann@linaro.org Subject: [PATCH v4 04/13] gdb: Refactor 'stack.c:print_frame'. Date: Wed, 8 Jul 2026 14:36:30 +0000 Message-Id: <20260708143639.2214689-5-christina.schimpe@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260708143639.2214689-1-christina.schimpe@intel.com> References: <20260708143639.2214689-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