From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id KbufB8KBJmkLmDAAWB0awg (envelope-from ) for ; Tue, 25 Nov 2025 23:27:46 -0500 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=jrQ3SdNI; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 03B8A1E0B3; Tue, 25 Nov 2025 23:27:46 -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.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,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 server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (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 4D4BA1E048 for ; Tue, 25 Nov 2025 23:27:45 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 75B183858CD9 for ; Wed, 26 Nov 2025 04:27:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 75B183858CD9 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=jrQ3SdNI Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by sourceware.org (Postfix) with ESMTPS id 7849F3858D20 for ; Wed, 26 Nov 2025 04:26:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7849F3858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 7849F3858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::42a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1764131207; cv=none; b=NkbeffIneRkpYtyg4z4PfCCtpnJWGeUhUjuEPWqn7obGI/E/psJI8m7TeabdETO9m772GT528IatRFkstmZfJTFcEk3W2w71dSAJHJdzk7UrBwWAgPcX6KOCth+8eF7cbTv3su0sJB4h/kDaZR7JvjiZokz0HKyx9Yshl5GORrY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1764131207; c=relaxed/simple; bh=0limRi6DO0OIjQwXGQxnDHNA/XYUisQyK0VxJyBigVQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=IjXDoMcEp3RL2R72mVu5jZKKPCPhWvk5B9ui8YRPG09j9GYgAC1CxGEBFGm9tUuu3aoc+83hOpKapDhJIoz00qSWtGFcyqfoNM67DhMbi7jfTxn05BCIzmKTF30Qq3onfSDjDyT0CuLsgFUBOfsr8D4jtE3l253NrF1ibQnVH+M= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7849F3858D20 Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-7b80fed1505so7138652b3a.3 for ; Tue, 25 Nov 2025 20:26:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764131206; x=1764736006; darn=sourceware.org; h=mime-version:message-id:date:user-agent:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=Lt8eOl/TC54aL4Hc3ZmOLPRqQZNuQXTZP1PktnQFg+Y=; b=jrQ3SdNI1KB1f8+LHd+EYprKF/TH+DnOq/Br+NAyIMMcxQs5bM5NZuPwi6r/TAEv8F n4rZY5GWiATQXtmTHJG0toeBHXKWNOhbCpVT/jH3AHNdbXsZzYHYOHDzkvxv9ya45kZt ljjFiq5FkeUT1QmG48xA1QDGqMIUlWINhK3+6+LFGF8KzOU3iU/tIqezVCWIGGO3RF3V PwlllNdkoiKAYrufOnW2zvgeOR50ZbNGPSEVHY7fDH4MdTJ2yS+PKCn0cwDh9iTa2KMa R6GSlxQLt5TyFLrb8BEw4422iXI6Afs7gywF3RyKp6if4JZWxULMM64mdwNSjA+uxMrP Q30w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764131206; x=1764736006; h=mime-version:message-id:date:user-agent:references:in-reply-to :subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=Lt8eOl/TC54aL4Hc3ZmOLPRqQZNuQXTZP1PktnQFg+Y=; b=n2xvlb/fR6rxwmj2yWBsUBTLlVkIbVj/oKQqb8nemD4h9WyPlTkV0d8woD5q4LCCnK 0uVgCvNG6IdeycRgdcj87Ok8kMjq8K+Tyf+9T/txS7XHx5TgX7Xe9McCS22kVmCg+q1+ mqK8yk4edYhroYx+63o7EU4Cj/tTfz51Yzpfi8AizPmLCcTq0EeINjR1wdV+oPWPFwjW tmyEV9r36YN4d7VWWcpjViqLktuOWWGsD2jJjJhg2F2HxD3vmfZ7JRhTUm2klRTnbnzX Vlg1ZnV23Qxv5okUtDtwjIFf7+hVobwIkr7ayFfoDkMPKMEi7N/sVBnmDXvI1Jblww2B q+RQ== X-Gm-Message-State: AOJu0YzbYObkfyCJfJp1KUUk/8spcSG6CBcoA3pUkd1IN/qELDDPLdZB hTgwuUTaFPOWXSneXVNVruI2aTIp30E/ni2ntawMtvnzxbMX1OefevzvIDAcmWL2sO8jeYMAsuo T6QW0fa0= X-Gm-Gg: ASbGncuJQnAsHR2D6PgmHUJbnacIHmytQN6cO71Rh+iT1LkaEOWn1tVYgBejIUZS5jb q8iAeSSDHg0BAKnNQ5NoV6UwPGhrxXU9i/RBOxT6m9WyzOIbPTe3eNjxw9otsCB7B7fe1Z7RmOx RhiPjpf8ykd1i/L99xKij/nz3eu+a6gOPkIrNHrCV8EeJtKrGsTpn/oLN88JGOlVWPRvVGc+1KB u4ipsD2bmS2DioDRt27ULibSvdu83V8KXDkYImnnIkX8rRoaVwsIDQZ/nl0vJvbFbcuLL7yMzIz hJvX+CHBqpPWHxVO+xjXjxlJluWvrzhNNDO4J4fL0sFNoSN+ZG1cIXb7kE56eluLxyb6TvOYwaS KdViAScB0QcfaIGF79EDhdBvOluJmpQem2mgXi8Y1E8uEa7nz31zWTqzPcMIEZ1MZpxWkH/3MTV gAYJ+aT9gonyrTLYJvgYO1 X-Google-Smtp-Source: AGHT+IHoF1mwj27zP7tLUYer28FTh9IjsqIUDMnSjS3nyFWDdxPCOIAaxBhY/zYvjeZ3qRj9NotcVw== X-Received: by 2002:a05:7022:3898:b0:119:e56b:957b with SMTP id a92af1059eb24-11c9d550f9emr15273133c88.0.1764131205683; Tue, 25 Nov 2025 20:26:45 -0800 (PST) Received: from localhost ([2804:14d:7e39:8083:2b62:e85c:5936:d298]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-11c93de82c1sm64432464c88.3.2025.11.25.20.26.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Nov 2025 20:26:44 -0800 (PST) From: Thiago Jung Bauermann To: Christina Schimpe Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 9/9] gdb, mi: Add -shadow-stack-list-frames command In-Reply-To: <20250923111842.4091694-10-christina.schimpe@intel.com> (Christina Schimpe's message of "Tue, 23 Sep 2025 11:18:42 +0000") References: <20250923111842.4091694-1-christina.schimpe@intel.com> <20250923111842.4091694-10-christina.schimpe@intel.com> User-Agent: mu4e 1.12.13; emacs 30.2 Date: Wed, 26 Nov 2025 01:26:43 -0300 Message-ID: <87a509pgfw.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain 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 Christina Schimpe writes: > +/* Parse arguments of -shadow-stack-list-frames command and set FRAME_LOW > + and FRAME_HIGH accordingly. Throw an error in case the arguments are > + invalid. */ > +static void > +mi_cmd_shadow_stack_list_frames_parse_args (const char *const *argv, > + int argc, int &frame_low, > + int &frame_high) > +{ > + /* There should either be low - high range, or no arguments. */ > + if ((argc != 0) && (argc != 2)) > + error (_("-shadow-stack-list-frames: Usage: [FRAME_LOW FRAME_HIGH]")); > + > + /* If there is a range, set it. */ > + if (argc == 2) > + { > + frame_low = atoi (argv[0]); > + frame_high = atoi (argv[1]); > + std::string err_str; > + if (frame_low < 0) > + { > + err_str = "``" + std::to_string (frame_low) + "''"; > + if (frame_high < 0) > + err_str += " and ``" + std::to_string (frame_high) + "''"; > + } > + else if (frame_high < 0) > + err_str = "``" + std::to_string (frame_high) + "''"; > + > + if (!err_str.empty ()) > + { > + err_str = "-shadow-stack-list-frames: Invalid option " + err_str; > + error (_("%s."), err_str.c_str ()); The call to _() here isn't very useful, because it puts the string "%s." in the message file for translation: #: gnu-nat.c:3090 mi/mi-cmd-stack.c:810 #, possible-c-format msgid "%s." msgstr "" And we see from the comment that gnu-nat.c has the same problem. :) Messages constructed piece by piece aren't translatable and so should be avoided if possible. > + } > + } > + else > + { > + /* No arguments, print the whole shadow stack backtrace. */ > + frame_low = -1; > + frame_high = -1; > + } > +} > + > +/* Print a list of the shadow stack frames. Args can be none, in which > + case we want to print the whole shadow stack backtrace, or a pair of > + numbers specifying the frame numbers at which to start and stop the > + display. If the two numbers are equal, a single frame will be > + displayed. */ > + > +void > +mi_cmd_shadow_stack_list_frames (const char *command, > + const char *const *argv, > + int argc) > +{ > + int frame_low; > + int frame_high; > + > + mi_cmd_shadow_stack_list_frames_parse_args (argv, argc, frame_low, > + frame_high); > + > + if (!target_has_stack ()) > + error (_("-shadow-stack-list-frames: No shadow stack.")); > + > + gdbarch *gdbarch = get_current_arch (); > + if (!gdbarch_address_in_shadow_stack_memory_range_p (gdbarch)) > + error (_("-shadow-stack-list-frames: Printing of shadow stack \ > + backtrace is not supported for the current target.")); The string above contains all the whitespace used for indentation. It should be: error (_("-shadow-stack-list-frames: Printing of shadow stack " "backtrace is not supported for the current target.")); Same for the other multi-line messages in this patch. > + regcache *regcache = get_thread_regcache (inferior_thread ()); > + bool shadow_stack_enabled = false; > + > + std::optional start_ssp > + = gdbarch_get_shadow_stack_pointer (gdbarch, regcache, > + shadow_stack_enabled); > + if (!start_ssp.has_value () || !shadow_stack_enabled) > + error (_("-shadow-stack-list-frames: Shadow stack is not enabled for \ > + the current target.")); My comment on patch 6 about a similar message also applies here: At least for AArch64, GCS can be enabled or disabled per-thread so I would say "not enabled for the current thread" here. > diff --git a/gdb/shadow-stack.c b/gdb/shadow-stack.c > index 42032f51781..ef8e31c730e 100644 > --- a/gdb/shadow-stack.c > +++ b/gdb/shadow-stack.c > @@ -270,6 +270,12 @@ do_print_shadow_stack_frame_info > uiout->field_string > ("addr", hex_string_custom (frame.value, element_size * 2), > address_style.style ()); > + > + if (uiout->is_mi_like_p ()) > + { > + uiout->field_string > + ("arch", (gdbarch_bfd_arch_info (gdbarch))->printable_name); Extraneous parentheses around gdbarch_bfd_arch_info (gdbarch). > + } > uiout->text ("\n"); > gdb_flush (gdb_stdout); > return; > @@ -333,6 +339,12 @@ do_print_shadow_stack_frame_info > if (lib != nullptr) > print_lib (uiout, lib, true); > } > + > + if (uiout->is_mi_like_p ()) > + { > + uiout->field_string > + ("arch", (gdbarch_bfd_arch_info (gdbarch))->printable_name); Extraneous parentheses around gdbarch_bfd_arch_info (gdbarch). > + } > } /* Extra scope to print frame tuple. */ > > uiout->text ("\n"); > diff --git a/gdb/testsuite/gdb.mi/mi-shadow-stack-signal.exp b/gdb/testsuite/gdb.mi/mi-shadow-stack-signal.exp > new file mode 100644 > index 00000000000..219f1b8ad78 > --- /dev/null > +++ b/gdb/testsuite/gdb.mi/mi-shadow-stack-signal.exp My only suggestion for this testcase is to add "amd64" to the filename, since it can only run on x86. Perhaps mi-amd64-shadow-stack-signal.exp? > diff --git a/gdb/testsuite/gdb.mi/mi-shadow-stack.exp b/gdb/testsuite/gdb.mi/mi-shadow-stack.exp > new file mode 100644 > index 00000000000..bbbc7ec5460 > --- /dev/null > +++ b/gdb/testsuite/gdb.mi/mi-shadow-stack.exp Samme suggestion here, about adding "amd64" to the filename. -- Thiago