From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id MbQtFgIsc2neDhEAWB0awg (envelope-from ) for ; Fri, 23 Jan 2026 03:06:26 -0500 Authentication-Results: simark.ca; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=FVZKUkRN; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 5609A1E093; Fri, 23 Jan 2026 03:06:26 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_INVALID,DKIM_SIGNED,HTML_MESSAGE,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 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 4E6E81E093 for ; Fri, 23 Jan 2026 03:06:25 -0500 (EST) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id CA0D04BCA434 for ; Fri, 23 Jan 2026 08:06:24 +0000 (GMT) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) by sourceware.org (Postfix) with ESMTPS id C26E64BCA419 for ; Fri, 23 Jan 2026 08:06:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C26E64BCA419 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 C26E64BCA419 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=192.198.163.18 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1769155570; cv=none; b=Jz8PEOub6yhYouRUa4eW82N6iiO1xBlLxgCgh24vnnscQa4yADV7b2YDuPIf67Wz1Gs64+qb6xIxebl7LHeQWMXlaMjJNwVi3pa/37SdzUU+vmPbd1hhSsPbdDE7uFZDcpPLt1Bl7feLQURV2HW6tGDRLh44ZpIPYIJ5wHAjRDI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1769155570; c=relaxed/simple; bh=8qg4fw5u+BXpI8azK74CLMZ7ox+V8bmOhLlerorX/wM=; h=DKIM-Signature:MIME-Version:From:To:Subject:Date:Message-Id: MIME-Version; b=mduApdnDLdl8jz4p3DKr1WZIQhCl/D6rGd1/uOTSFK76w3f7NB4nCZn/QMZr38nz3VNEVzgUvznNuIbkAqvw01qJ2H0+phxCgrYhXeg+aCwjqCCaBujDaMWAsHgstRuAnlpt8Vv/iqxKLAr6rXG2/7mau3ivE8eojvqL1bMZlBA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1769155570; x=1800691570; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=8qg4fw5u+BXpI8azK74CLMZ7ox+V8bmOhLlerorX/wM=; b=FVZKUkRNZvJ5+skoUuIi0XA1yU1M2+VYcDn7rNb5mwthYqvNU9GjcZkt 8suegvU0vOBNE3pO7X/w8Xp3zc/gclTNxA3YEZN9/M5MG6gZ/xlZ+LXn8 x2/muT+Ns5B4kAQ41BhMfByUmsmSoeGz5e2meqaYkhuT8Eb8zbYOTeXyf x4IqnWBqvUErjGRVlQYwEeTXkUs6wVNu+qrk7VwgWA0VnJTee/gHu4vdh z3radqcAqdo5qN+xIxksN4TIiewLnkWunIq6w4a5uM0ovElFK/+OPEZCr 4Gw9bdKbRI8ffv1/pAD1UeLc+wBWLtnmn/aMJ1hO7r6MbrVj2Ed99EbV1 g==; X-CSE-ConnectionGUID: Us8ZXFKRS3SnTSTFMSheyA== X-CSE-MsgGUID: 9BEq1PxORseEkmZNGv8Tyg== X-IronPort-AV: E=McAfee;i="6800,10657,11679"; a="69603081" X-IronPort-AV: E=Sophos;i="6.21,248,1763452800"; d="scan'208";a="69603081" Content-Type: multipart/mixed; boundary="===============4200083393298675907==" MIME-Version: 1.0 Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2026 00:06:09 -0800 X-CSE-ConnectionGUID: LJRYdxMdTmOCqGboLzfNbQ== X-CSE-MsgGUID: hxCl+ArvQJGV0YshmX3MNA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,248,1763452800"; d="scan'208";a="206785356" Received: from gkldtt-dev-004.igk.intel.com (HELO localhost) ([10.123.221.202]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2026 00:06:08 -0800 From: Christina Schimpe To: gdb-patches@sourceware.org Cc: thiago.bauermann@linaro.org Subject: [PATCH v2 5/9] gdb: Refactor 'stack.c:print_frame_info'. Date: Fri, 23 Jan 2026 08:05:27 +0000 Message-Id: <20260123080532.878738-6-christina.schimpe@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260123080532.878738-1-christina.schimpe@intel.com> References: <20260123080532.878738-1-christina.schimpe@intel.com> MIME-Version: 1.0 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 --===============4200083393298675907== Content-Transfer-Encoding: 8bit This patch restructures the 'stack.c:print_frame_info' function by introducing two new functions in stack.c. The new functions will also be called in a later patch "gdb: Implement 'bt shadow' subcommand to print the shadow stack backtrace." Approved-By: Tom Tromey --- gdb/stack.c | 159 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 94 insertions(+), 65 deletions(-) diff --git a/gdb/stack.c b/gdb/stack.c index 805142b2f9b..0f8c52ecc93 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -1019,6 +1019,86 @@ get_user_print_what_frame_info (std::optional *what) (user_frame_print_options.print_frame_info); } +/* Return true if PRINT_WHAT is configured to print the location of a + frame. */ + +static bool +should_print_location (print_what print_what) +{ + return (print_what == LOCATION + || print_what == SRC_AND_LOC + || print_what == LOC_AND_ADDRESS + || print_what == SHORT_LOCATION); +} + +/* Print the source information for PC and SAL to UIOUT. Based on the + user-defined configuration disassemble-next-line, display disassembly + of the next source line, in addition to displaying the source line + itself. Print annotations describing source file and and line number + based on MID_STATEMENT information. If SHOW_ADDRESS is true, print the + program counter PC including, if non-empty, PC_ADDRESS_FLAGS. */ + +static void +print_source (ui_out *uiout, gdbarch *gdbarch, CORE_ADDR pc, + symtab_and_line sal, bool show_address, int mid_statement, + const std::string &pc_address_flags) +{ + if (sal.symtab == nullptr) + { + /* If disassemble-next-line is set to auto or on and doesn't have + the line debug messages for $pc, output the next instruction. */ + if (disassemble_next_line == AUTO_BOOLEAN_AUTO + || disassemble_next_line == AUTO_BOOLEAN_TRUE) + do_gdb_disassembly (gdbarch, 1, pc, pc + 1); + + /* If we do not have symtab information, we cannot print any source + line and must return here. */ + return; + } + + if (annotation_level > 0 + && annotate_source_line (sal.symtab, sal.line, mid_statement, pc)) + { + /* The call to ANNOTATE_SOURCE_LINE already printed the annotation + for this source line, so we avoid the two cases below and do not + print the actual source line. The documentation for annotations + makes it clear that the source line annotation is printed + __instead__ of printing the source line, not as well as. + + However, if we fail to print the source line, which usually means + either the source file is missing, or the requested line is out + of range of the file, then we don't print the source annotation, + and will pass through the "normal" print source line code below, + the expectation is that this code will print an appropriate + error. */ + } + else if (deprecated_print_frame_info_listing_hook) + deprecated_print_frame_info_listing_hook (sal.symtab, sal.line, + sal.line + 1, 0); + else + { + /* We used to do this earlier, but that is clearly wrong. This + function is used by many different parts of gdb, including + normal_stop in infrun.c, which uses this to print out the current + PC when we stepi/nexti into the middle of a source line. Only + the command line really wants this behavior. Other UIs probably + would like the ability to decide for themselves if it is + desired. */ + if (show_address) + { + print_pc (uiout, gdbarch, pc_address_flags, pc); + uiout->text ("\t"); + } + + print_source_lines (sal.symtab, sal.line, sal.line + 1, 0); + } + + /* If disassemble-next-line is set to on and there is line debug + messages, output assembly codes for next line. */ + if (disassemble_next_line == AUTO_BOOLEAN_TRUE) + do_gdb_disassembly (gdbarch, -1, sal.pc, sal.end); +} + /* Print information about frame FRAME. The output is format according to PRINT_LEVEL and PRINT_WHAT and PRINT_ARGS. For the meaning of PRINT_WHAT, see enum print_what comments in frame.h. @@ -1035,8 +1115,6 @@ do_print_frame_info (struct ui_out *uiout, const frame_print_options &fp_opts, int set_current_sal) { struct gdbarch *gdbarch = get_frame_arch (frame); - int source_print; - int location_print; if (!current_uiout->is_mi_like_p () && fp_opts.print_frame_info != print_frame_info_auto) @@ -1107,75 +1185,26 @@ do_print_frame_info (struct ui_out *uiout, const frame_print_options &fp_opts, to get the line containing FRAME->pc. */ symtab_and_line sal = find_frame_sal (frame); - location_print = (print_what == LOCATION - || print_what == SRC_AND_LOC - || print_what == LOC_AND_ADDRESS - || print_what == SHORT_LOCATION); - if (location_print || !sal.symtab) - print_frame (uiout, fp_opts, frame, print_level, - print_what, print_args, sal); - - source_print = (print_what == SRC_LINE || print_what == SRC_AND_LOC); + if (should_print_location (print_what) || sal.symtab == nullptr) + print_frame (uiout, fp_opts, frame, print_level, print_what, + print_args, sal); - /* If disassemble-next-line is set to auto or on and doesn't have - the line debug messages for $pc, output the next instruction. */ - if ((disassemble_next_line == AUTO_BOOLEAN_AUTO - || disassemble_next_line == AUTO_BOOLEAN_TRUE) - && source_print && !sal.symtab) - do_gdb_disassembly (get_frame_arch (frame), 1, - get_frame_pc (frame), get_frame_pc (frame) + 1); - - if (source_print && sal.symtab) + if (print_what == SRC_LINE || print_what == SRC_AND_LOC) { int mid_statement = ((print_what == SRC_LINE) && frame_show_address (frame, sal)); - if (annotation_level > 0 - && annotate_source_line (sal.symtab, sal.line, mid_statement, - get_frame_pc (frame))) - { - /* The call to ANNOTATE_SOURCE_LINE already printed the - annotation for this source line, so we avoid the two cases - below and do not print the actual source line. The - documentation for annotations makes it clear that the source - line annotation is printed __instead__ of printing the source - line, not as well as. - - However, if we fail to print the source line, which usually - means either the source file is missing, or the requested - line is out of range of the file, then we don't print the - source annotation, and will pass through the "normal" print - source line code below, the expectation is that this code - will print an appropriate error. */ - } - else if (deprecated_print_frame_info_listing_hook) - deprecated_print_frame_info_listing_hook (sal.symtab, sal.line, - sal.line + 1, 0); - else - { - struct value_print_options opts; - - get_user_print_options (&opts); - /* We used to do this earlier, but that is clearly - wrong. This function is used by many different - parts of gdb, including normal_stop in infrun.c, - which uses this to print out the current PC - when we stepi/nexti into the middle of a source - line. Only the command line really wants this - behavior. Other UIs probably would like the - ability to decide for themselves if it is desired. */ - if (opts.addressprint && mid_statement) - { - print_pc (uiout, gdbarch, frame, get_frame_pc (frame)); - uiout->text ("\t"); - } - print_source_lines (sal.symtab, sal.line, sal.line + 1, 0); - } + value_print_options opts; + get_user_print_options (&opts); + + const bool print_address = opts.addressprint && mid_statement; + + std::string pc_address_flags + = gdbarch_get_pc_address_flags (gdbarch, frame, get_frame_pc (frame)); + + print_source (uiout, gdbarch, get_frame_pc (frame), sal, + print_address, mid_statement, pc_address_flags); - /* If disassemble-next-line is set to on and there is line debug - messages, output assembly codes for next line. */ - if (disassemble_next_line == AUTO_BOOLEAN_TRUE) - do_gdb_disassembly (get_frame_arch (frame), -1, sal.pc, sal.end); } if (set_current_sal) -- 2.34.1 --===============4200083393298675907== Content-Type: multipart/alternative; boundary="===============1306402846207377981==" MIME-Version: 1.0 Content-Disposition: inline --===============1306402846207377981== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Intel Deutschland GmbH Registered Address: Dornacher Stra=C3=9Fe 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 M=C3=BCnchen HRB 186928 --===============1306402846207377981== Content-Type: text/html; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable
Intel Deutschland GmbH
Registered Address: Dornacher Stra=C3= =9Fe 1, 85622 Feldkirchen, Germany
Tel: +49 89 991 430, www.intel.deManaging Directors: Harry Demas, Jeffrey Schneiderman, Yin Chong Sorrell<= div>Chairperson of the Supervisory Board: Nicole Lau
Registered Seat: M= unich
Commercial Register: Amtsgericht M=C3=BCnchen HRB 186928 --===============1306402846207377981==-- --===============4200083393298675907==--