Re: [PATCH v2 1/9] gdb: Generalize handling of the shadow stack pointer.

Thiago Jung Bauermann
2026-03-06T03:16:24Z

Hello Christina,

Thank you for addressing my review comments! Just a couple of comments:

Christina Schimpe <christina.schimpe@intel.com> writes:

> +static bool
> +amd64_linux_top_addr_empty_shadow_stack
> + (gdbarch *gdbarch, const CORE_ADDR addr,
> + const std::pair<CORE_ADDR, CORE_ADDR> range)
> {
> - if (regnum == gdbarch_pc_regnum (gdbarch))
> - reg->how = DWARF2_FRAME_REG_RA;
> - else if (regnum == gdbarch_sp_regnum (gdbarch))
> - reg->how = DWARF2_FRAME_REG_CFA;
> - else if (regnum == AMD64_PL3_SSP_REGNUM)
> - {
> - reg->how = DWARF2_FRAME_REG_FN;
> - reg->loc.fn = amd64_linux_dwarf2_prev_ssp;
> - }
> + return addr == range.second;
> }

Next week I'll provide the AArch64 implementation of this hook,
if you can squash it into your patch.

> diff --git a/gdb/shadow-stack.c b/gdb/shadow-stack.c
> new file mode 100644
> index 00000000000..77d7c07d970
> --- /dev/null
> +++ b/gdb/shadow-stack.c
> @@ -0,0 +1,166 @@
> +/* Manage a shadow stack pointer for GDB, the GNU debugger.
> +
> + Copyright (C) 2024-2026 Free Software Foundation, Inc.
> + This file is part of GDB.
> +
> + This program is free software; you can redistribute it and/or modify
> + it under the terms of the GNU General Public License as published by
> + the Free Software Foundation; either version 3 of the License, or
> + (at your option) any later version.
> +
> + This program is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + GNU General Public License for more details.
> +
> + You should have received a copy of the GNU General Public License
> + along with this program. If not, see <http://www.gnu.org/licenses/>. */
> +
> +#include "defs.h"
> +#include "arch-utils.h"
> +#include "gdbcore.h"
> +#include "extract-store-integer.h"
> +#include "frame.h"
> +#include "frame-unwind.h"
> +#include "shadow-stack.h"
> +
> +class regcache;

This forward declaration should be in shadow-stack.h, since the
shadow_stack_push prototype declared there uses it.

--
Thiago