binutils-gdb/gdbserver/linux-aarch32-tdesc.cc

50 lines
1.4 KiB
C++
Raw Normal View History

/* Copyright (C) 2019-2024 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 "linux-aarch32-tdesc.h"
#include "tdesc.h"
#include "arch/aarch32.h"
#include <inttypes.h>
static struct target_desc *tdesc_aarch32;
/* See linux-aarch32-tdesc.h. */
const target_desc *
aarch32_linux_read_description ()
{
if (tdesc_aarch32 == nullptr)
{
gdb/arm: Remove tpidruro register from non-FreeBSD target descriptions Commit 92d48a1e4eac ("Add an arm-tls feature which includes the tpidruro register from CP15.") introduced the org.gnu.gdb.arm.tls feature, which adds the tpidruro register, and unconditionally enabled it in aarch32_create_target_description. In Linux, the tpidruro register isn't available via ptrace in the 32-bit kernel but it is available for an aarch32 program running under an arm64 kernel via the ptrace compat interface. This isn't currently implemented however, which causes GDB on arm-linux with 64-bit kernel to list the register but show it as unavailable, as reported by Tom de Vries: $ gdb -q -batch a.out -ex start -ex 'p $tpidruro' Temporary breakpoint 1 at 0x512 Temporary breakpoint 1, 0xaaaaa512 in main () $1 = <unavailable> Simon Marchi then clarified: > The only time we should be seeing some "unavailable" registers or memory > is in the context of tracepoints, for things that are not collected. > Seeing an unavailable register here is a sign that something is not > right. Therefore, disable the TLS feature in aarch32 target descriptions for Linux and NetBSD targets (the latter also doesn't seem to support accessing tpidruro either, based on a quick look at arm-netbsd-nat.c). This patch fixes the following tests: Running gdb.base/inline-frame-cycle-unwind.exp ... FAIL: gdb.base/inline-frame-cycle-unwind.exp: cycle at level 3: backtrace when the unwind is broken at frame 3 FAIL: gdb.base/inline-frame-cycle-unwind.exp: cycle at level 5: backtrace when the unwind is broken at frame 5 FAIL: gdb.base/inline-frame-cycle-unwind.exp: cycle at level 1: backtrace when the unwind is broken at frame 1 Tested with Ubuntu 22.04.3 on armv8l-linux-gnueabihf in native, native-gdbserver and native-extended-gdbserver targets with no regressions. PR tdep/31418 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31418 Approved-By: John Baldwin <jhb@FreeBSD.org>
2024-02-27 06:11:45 +08:00
tdesc_aarch32 = aarch32_create_target_description (false);
static const char *expedite_regs[] = { "r11", "sp", "pc", 0 };
init_target_desc (tdesc_aarch32, expedite_regs);
}
return tdesc_aarch32;
}
/* See linux-aarch32-tdesc.h. */
bool
is_aarch32_linux_description (const target_desc *tdesc)
{
gdb_assert (tdesc != nullptr);
return tdesc == tdesc_aarch32;
}