From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id Lii8H0mgS2rgwCkAWB0awg (envelope-from ) for ; Mon, 06 Jul 2026 08:32:09 -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=RScv84cb; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 723F51E070; Mon, 06 Jul 2026 08:32:09 -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 47E861E070 for ; Mon, 06 Jul 2026 08:32:08 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CA8164BA2E38 for ; Mon, 6 Jul 2026 12:32:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CA8164BA2E38 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=RScv84cb Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) by sourceware.org (Postfix) with ESMTPS id 1D0374BA2E1E for ; Mon, 6 Jul 2026 12:31:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1D0374BA2E1E 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 1D0374BA2E1E Authentication-Results: sourceware.org; arc=none smtp.remote-ip=198.175.65.17 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783341101; cv=none; b=OqCQiFU5CySv5fwMUQ+hgKQ01AL0+S9eKzBtXp4/ILfdRt2uHA9xjK8GnemSJbdbvVa/mAybMc0IgBSVhGhdYvBRhoiBi5/LSdf6R08pBBy7S3dlUMv+Bq32CfckHSZFvv8SDHIAbyxyEJltbPpWxHdI80L90rhzUim3QCJ/DzY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783341101; c=relaxed/simple; bh=HhXQOJbuq7kqX4O/FlRv138ERBj+ivOPr8gp67MkTGI=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=Zh49BC28TkTe/NtR8rV+UfnbRSdGI8YqipgxnPAwkcVmWYKofJWFlFdnxZxGbuXoJiOEKXF0R/dYqkZdioAxXWDoIf2At+o6lUMvMmYNkJdxF4hF3H5CRe3OadtB3Z4hhh/kjSYbX0N/NPiZiVDqM1t2YsL5mhfFrXcyiWqvbBw= 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=RScv84cb DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1D0374BA2E1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1783341101; x=1814877101; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=HhXQOJbuq7kqX4O/FlRv138ERBj+ivOPr8gp67MkTGI=; b=RScv84cbsJUNzWrATP2MbJ7a0iBydxwhbJe8E821/Un+l0xECGQ5yRFk TkLQU7rlVefUkyN2lklH+xFTNgWv7pzfOU3+0a3nLnpE7k2BZZmQQm600 Pu6E2S7vx5x0mmyN3yUqYk7VzmJ+hPSKJforrCEm38D208veZ1V+bsRAo DPpG7RDhfneTbsvNjlM/ZFjhfxe1JmY346uVoEMZnZOfIhF3OAkeYbjg8 2kdmUcHqYHMOod7zVZ1RALsaKqJKGKIMVpidmDQ4BuXEelu6hy0POQLGS OO+9rfaYXXsv4lHQGX1nRqQ57UmNcmfy8Vm6DhLLSaxo7sEjx1kL2YEBQ w==; X-CSE-ConnectionGUID: iL/C4MAQTGuTRWBYctb8TA== X-CSE-MsgGUID: aiSUEnfuSy6olFjGVpE/KQ== X-IronPort-AV: E=McAfee;i="6800,10657,11838"; a="84001591" X-IronPort-AV: E=Sophos;i="6.25,149,1779174000"; d="scan'208";a="84001591" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2026 05:31:40 -0700 X-CSE-ConnectionGUID: 2QuI8rf+RHm1EAWOnT3VxQ== X-CSE-MsgGUID: +FpU3XmPTl6AwMUtKWdcfw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,149,1779174000"; d="scan'208";a="257285128" Received: from gkldtt-dev-004.igk.intel.com (HELO localhost) ([10.123.221.202]) by ORVIESA003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2026 05:31:39 -0700 From: Christina Schimpe To: gdb-patches@sourceware.org Cc: tom@tromey.com, thiago.bauermann@linaro.org Subject: [PATCH v3 00/12] Add new command to print the shadow stack backtrace Date: Mon, 6 Jul 2026 12:31:21 +0000 Message-Id: <20260706123133.1990441-1-christina.schimpe@intel.com> X-Mailer: git-send-email 2.34.1 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 Hi all, this is my v3 for the series "Add new command to print the shadow stack backtrace". v2 of this series can be found here: https://sourceware.org/pipermail/gdb-patches/2026-January/224388.html It now includes - the implementation of the -past-main command line option - support for inferior calls (printing of instead of the shadow stack element) - full support for signals (printing of instead of the shadow stack element) Due to this some larger refactoring was required; I summarized it here: https://sourceware.org/pipermail/gdb-patches/2026-May/227481.html The refactoring mostly affected the following commits: "gdb: Provide gdbarch hook to distinguish shadow stack backtrace elements." "gdb: Add command option 'bt -shadow' to print the shadow stack backtrace." "gdb: Implement the hook 'is_no_return_shadow_stack_address' for amd64 linux." I did not add any Reviewed-By or Approved-By tags for the 3 commits, since they changed significantly. Furthermore, I addressed (hopefully all) the comments of Tom, Thiago and Eli: - Remove annotations - Some better code reuse (especially for the mi patch) - A new patch "aarch64: Implement gdbarch function top_addr_empty_shadow_stack." This also allows to remove some target dependent GCS code in aarch64-*.c - Various smaller issues and nits - Fixes for check-gdbarch.py And finally some smaller issues I noted myself (mostly for patch #1 "gdb: Generalize handling of the shadow stack pointer."): - Remove unused gdbarch parameter in some of the introduced hooks - Changes in gdb/aarch64-tdep.c when calling shadow_stack_push, since some code for getting the shadow stack pointer and checking the enablement state was duplicated. Opens: 1) Thiago suggested changing the frame numbering so that it always starts at #1, since for the shadow stack we don't have frame #0 printed by the normal backtrace. 2) Or, consider printing frame #0 similarly to what the normal backtrace does 3) Consider printing frame arguments (but I believe, if possible, this should better be added in a follow-up series) 4) Show the selected frame, for details see here: https://sourceware.org/pipermail/gdb-patches/2026-June/227720.html This is an example for the output of 'bt -shadow' on amd64 linux: ~~~ (gdb) bt -shadow #0 0x000055555555514a in call1 at amd64-shadow-stack.c:27 #1 0x000055555555515f in main at amd64-shadow-stack.c:38 ~~~ Note that the normal backtrace includes one additional frame, since the shadow stack backtrace relies on return addresses of the shadow stack only. But except the missing frame arguments and frame #0 of the normal backtrace, the backtrace is the same. ~~~ (gdb) bt #0 call2 () at amd64-shadow-stack.c:21 #1 0x000055555555514a in call1 () at amd64-shadow-stack.c:27 #2 0x000055555555515f in main () at amd64-shadow-stack.c:38 ~~~ I am happy about your feedback! Christina Christina Schimpe (12): gdb: Generalize handling of the shadow stack pointer. aarch64: Implement gdbarch function top_addr_empty_shadow_stack. gdb: Add get_main_func_start_pc to refactor frame.c:inside_main_func. gdb: Refactor 'stack.c:print_frame'. gdb: Introduce 'stack.c:print_pc' function without frame argument. gdb: Refactor 'find_symbol_funname' and 'info_frame_command_core' in stack.c. gdb: Refactor 'stack.c:print_frame_info'. gdb: Add command option 'bt -shadow' to print the shadow stack backtrace. gdb: Implement the hook 'is_no_return_shadow_stack_address' for amd64 linux. gdb: Enable inferior calls in the shadow stack backtrace. gdb: Enable signal trampolines in the shadow stack backtrace. gdb, mi: Add -shadow-stack-list-frames command gdb/Makefile.in | 2 + gdb/NEWS | 11 + gdb/aarch64-linux-tdep.c | 51 +- gdb/aarch64-tdep.c | 66 +- gdb/amd64-linux-tdep.c | 211 ++--- gdb/amd64-tdep.c | 22 + gdb/doc/gdb.texinfo | 94 +++ gdb/frame.c | 37 +- gdb/frame.h | 6 + gdb/gdbarch-gen.c | 190 ++++- gdb/gdbarch-gen.h | 95 ++- gdb/gdbarch.h | 1 + gdb/gdbarch_components.py | 124 ++- gdb/infcall.c | 4 +- gdb/linux-tdep.c | 9 +- gdb/mi/mi-cmd-stack.c | 100 +++ gdb/mi/mi-cmds.c | 2 + gdb/mi/mi-cmds.h | 1 + gdb/shadow-stack.c | 769 ++++++++++++++++++ gdb/shadow-stack.h | 182 +++++ gdb/stack.c | 319 +++++--- gdb/stack.h | 43 + .../amd64-shadow-stack-backtrace-signal.exp | 49 ++ .../gdb.arch/amd64-shadow-stack-cmds.exp | 71 ++ .../gdb.arch/amd64-shadow-stack-signal.c | 31 + gdb/testsuite/gdb.base/options.exp | 2 +- .../gdb.mi/mi-shadow-stack-signal.exp | 69 ++ gdb/testsuite/gdb.mi/mi-shadow-stack.exp | 93 +++ 28 files changed, 2246 insertions(+), 408 deletions(-) create mode 100644 gdb/shadow-stack.c create mode 100644 gdb/shadow-stack.h create mode 100644 gdb/testsuite/gdb.arch/amd64-shadow-stack-backtrace-signal.exp create mode 100644 gdb/testsuite/gdb.arch/amd64-shadow-stack-signal.c create mode 100644 gdb/testsuite/gdb.mi/mi-shadow-stack-signal.exp create mode 100644 gdb/testsuite/gdb.mi/mi-shadow-stack.exp -- 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