nios2: Remove all GDB support for Nios II targets.

Intel has EOL'ed the Nios II architecture, and it's time to remove support
from all toolchain components before it gets any more bit-rotten from
lack of maintenance or regular testing.
This commit is contained in:
Sandra Loosemore
2024-11-26 19:13:07 +00:00
parent dfc65d0579
commit 7b55df8eff
24 changed files with 6 additions and 3326 deletions

View File

@@ -383,9 +383,7 @@ the native maintainer when resolving ABI issues.
ms1 Deleted
nios2 --target=nios2-elf
--target=nios2-linux-gnu
Yao Qi qiyao@sourceware.org
nios2 Deleted
ns32k Deleted

View File

@@ -857,8 +857,6 @@ ALL_TARGET_OBS = \
msp430-tdep.o \
netbsd-tdep.o \
nds32-tdep.o \
nios2-linux-tdep.o \
nios2-tdep.o \
obsd-tdep.o \
or1k-linux-tdep.o \
or1k-tdep.o \
@@ -1441,7 +1439,6 @@ HFILES_NO_SRCDIR = \
netbsd-nat.h \
netbsd-tdep.h \
nds32-tdep.h \
nios2-tdep.h \
elf-none-tdep.h \
objc-lang.h \
objfiles.h \
@@ -1806,8 +1803,6 @@ ALLDEPFILES = \
netbsd-nat.c \
netbsd-tdep.c \
nds32-tdep.c \
nios2-linux-tdep.c \
nios2-tdep.c \
obsd-nat.c \
obsd-tdep.c \
or1k-linux-nat.c \

View File

@@ -3,6 +3,9 @@
*** Changes since GDB 15
* Support for Nios II targets has been removed as this architecture
has been EOL'ed by Intel.
* GDB now supports watchpoints for tagged data pointers (see
https://en.wikipedia.org/wiki/Tagged_pointer) on amd64, such as the
one used by the Linear Address Masking (LAM) feature provided by

View File

@@ -466,17 +466,6 @@ nds32*-*-elf)
gdb_target_obs="nds32-tdep.o"
;;
nios2*-*-linux*)
# Target: Altera Nios II running Linux
gdb_target_obs="nios2-tdep.o nios2-linux-tdep.o solib-svr4.o \
symfile-mem.o glibc-tdep.o linux-tdep.o"
;;
nios2*-*-*)
# Target: Altera Nios II bare-metal
gdb_target_obs="nios2-tdep.o"
;;
or1k*-*-linux*)
# Target: OpenCores OpenRISC 1000 32-bit running Linux
gdb_target_obs="or1k-tdep.o or1k-linux-tdep.o solib-svr4.o \

View File

@@ -92,10 +92,9 @@ get_test_insn (struct gdbarch *gdbarch, size_t *len)
insn = xstormy16_insn;
*len = sizeof (xstormy16_insn);
break;
case bfd_arch_nios2:
case bfd_arch_score:
case bfd_arch_riscv:
/* nios2, riscv, and score need to know the current instruction
/* riscv and score need to know the current instruction
to select breakpoint instruction. Give the breakpoint
instruction kind explicitly. */
{

View File

@@ -26426,7 +26426,6 @@ all uses of @value{GDBN} with the architecture, both native and cross.
* MIPS::
* HPPA:: HP PA architecture
* PowerPC::
* Nios II::
* Sparc64::
* S12Z::
* AMD GPU:: @acronym{AMD GPU} architectures
@@ -27015,25 +27014,6 @@ by joining the even/odd register pairs @code{f0} and @code{f1} for @code{$dl0},
For POWER7 processors, @value{GDBN} provides a set of pseudo-registers, the 64-bit
wide Extended Floating Point Registers (@samp{f32} through @samp{f63}).
@node Nios II
@subsection Nios II
@cindex Nios II architecture
When @value{GDBN} is debugging the Nios II architecture,
it provides the following special commands:
@table @code
@item set debug nios2
@kindex set debug nios2
This command turns on and off debugging messages for the Nios II
target code in @value{GDBN}.
@item show debug nios2
@kindex show debug nios2
Show the current setting of Nios II debugging messages.
@end table
@node Sparc64
@subsection Sparc64
@cindex Sparc64 support
@@ -49008,7 +48988,6 @@ registers using the capitalization used in the description.
* MIPS Features::
* M68K Features::
* NDS32 Features::
* Nios II Features::
* OpenRISC 1000 Features::
* PowerPC Features::
* RISC-V Features::
@@ -49841,16 +49820,6 @@ overlapping 64-bit double-precision registers. Listing 32-bit
single-precision registers explicitly is deprecated, and the
support to it could be totally removed some day.
@node Nios II Features
@subsection Nios II Features
@cindex target descriptions, Nios II features
The @samp{org.gnu.gdb.nios2.cpu} feature is required for Nios II
targets. It should contain the 32 core registers (@samp{zero},
@samp{at}, @samp{r2} through @samp{r23}, @samp{et} through @samp{ra}),
@samp{pc}, and the 16 control registers (@samp{status} through
@samp{mpuacc}).
@node OpenRISC 1000 Features
@subsection Openrisc 1000 Features
@cindex target descriptions, OpenRISC 1000 features

View File

@@ -46,7 +46,6 @@
# List of .dat files to create in ../regformats/
WHICH = mips-linux mips-dsp-linux \
mips64-linux mips64-dsp-linux \
nios2-linux \
or1k-linux \
rs6000/powerpc-32 \
rs6000/powerpc-32l rs6000/powerpc-altivec32l rs6000/powerpc-e500l \
@@ -73,7 +72,6 @@ mips-expedite = r29,pc
mips-dsp-expedite = r29,pc
mips64-expedite = r29,pc
mips64-dsp-expedite = r29,pc
nios2-linux-expedite = sp,pc
or1k-expedite = r1,npc
powerpc-expedite = r1,pc
s390-linux32-expedite = r14,r15,pswa
@@ -107,7 +105,6 @@ XMLTOC = \
mips64-dsp-linux.xml \
mips64-linux.xml \
nds32.xml \
nios2.xml \
or1k.xml \
or1k-linux.xml \
rs6000/powerpc-32.xml \

View File

@@ -1,59 +0,0 @@
<?xml version="1.0"?>
<!-- Copyright (C) 2012-2024 Free Software Foundation, Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved. -->
<!DOCTYPE feature SYSTEM "gdb-target.dtd">
<feature name="org.gnu.gdb.nios2.cpu">
<reg name="zero" bitsize="32" type="uint32"/>
<reg name="at" bitsize="32" type="uint32"/>
<reg name="r2" bitsize="32" type="uint32"/>
<reg name="r3" bitsize="32" type="uint32"/>
<reg name="r4" bitsize="32" type="uint32"/>
<reg name="r5" bitsize="32" type="uint32"/>
<reg name="r6" bitsize="32" type="uint32"/>
<reg name="r7" bitsize="32" type="uint32"/>
<reg name="r8" bitsize="32" type="uint32"/>
<reg name="r9" bitsize="32" type="uint32"/>
<reg name="r10" bitsize="32" type="uint32"/>
<reg name="r11" bitsize="32" type="uint32"/>
<reg name="r12" bitsize="32" type="uint32"/>
<reg name="r13" bitsize="32" type="uint32"/>
<reg name="r14" bitsize="32" type="uint32"/>
<reg name="r15" bitsize="32" type="uint32"/>
<reg name="r16" bitsize="32" type="uint32"/>
<reg name="r17" bitsize="32" type="uint32"/>
<reg name="r18" bitsize="32" type="uint32"/>
<reg name="r19" bitsize="32" type="uint32"/>
<reg name="r20" bitsize="32" type="uint32"/>
<reg name="r21" bitsize="32" type="uint32"/>
<reg name="r22" bitsize="32" type="uint32"/>
<reg name="r23" bitsize="32" type="uint32"/>
<reg name="et" bitsize="32" type="uint32"/>
<reg name="bt" bitsize="32" type="uint32"/>
<reg name="gp" bitsize="32" type="data_ptr"/>
<reg name="sp" bitsize="32" type="data_ptr"/>
<reg name="fp" bitsize="32" type="data_ptr"/>
<reg name="ea" bitsize="32" type="code_ptr"/>
<reg name="sstatus" bitsize="32" type="uint32"/>
<reg name="ra" bitsize="32" type="code_ptr"/>
<reg name="pc" bitsize="32" type="code_ptr"/>
<reg name="status" bitsize="32" type="uint32"/>
<reg name="estatus" bitsize="32" type="uint32"/>
<reg name="bstatus" bitsize="32" type="uint32"/>
<reg name="ienable" bitsize="32" type="uint32"/>
<reg name="ipending" bitsize="32" type="uint32"/>
<reg name="cpuid" bitsize="32" type="uint32"/>
<reg name="ctl6" bitsize="32" type="uint32"/>
<reg name="exception" bitsize="32" type="uint32"/>
<reg name="pteaddr" bitsize="32" type="uint32"/>
<reg name="tlbacc" bitsize="32" type="uint32"/>
<reg name="tlbmisc" bitsize="32" type="uint32"/>
<reg name="eccinj" bitsize="32" type="uint32"/>
<reg name="badaddr" bitsize="32" type="uint32"/>
<reg name="config" bitsize="32" type="uint32"/>
<reg name="mpubase" bitsize="32" type="uint32"/>
<reg name="mpuacc" bitsize="32" type="uint32"/>
</feature>

View File

@@ -1,13 +0,0 @@
<?xml version="1.0"?>
<!-- Copyright (C) 2012-2024 Free Software Foundation, Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved. -->
<!DOCTYPE target SYSTEM "gdb-target.dtd">
<target>
<architecture>nios2</architecture>
<osabi>GNU/Linux</osabi>
<xi:include href="nios2-cpu.xml"/>
</target>

View File

@@ -1,68 +0,0 @@
/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro:
Original: nios2.xml */
#include "osabi.h"
#include "target-descriptions.h"
const struct target_desc *tdesc_nios2;
static void
initialize_tdesc_nios2 (void)
{
target_desc_up result = allocate_target_description ();
set_tdesc_architecture (result.get (), bfd_scan_arch ("nios2"));
struct tdesc_feature *feature;
feature = tdesc_create_feature (result.get (), "org.gnu.gdb.nios2.cpu");
tdesc_create_reg (feature, "zero", 0, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "at", 1, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r2", 2, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r3", 3, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r4", 4, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r5", 5, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r6", 6, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r7", 7, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r8", 8, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r9", 9, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r10", 10, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r11", 11, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r12", 12, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r13", 13, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r14", 14, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r15", 15, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r16", 16, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r17", 17, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r18", 18, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r19", 19, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r20", 20, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r21", 21, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r22", 22, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r23", 23, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "et", 24, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "bt", 25, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "gp", 26, 1, NULL, 32, "data_ptr");
tdesc_create_reg (feature, "sp", 27, 1, NULL, 32, "data_ptr");
tdesc_create_reg (feature, "fp", 28, 1, NULL, 32, "data_ptr");
tdesc_create_reg (feature, "ea", 29, 1, NULL, 32, "code_ptr");
tdesc_create_reg (feature, "sstatus", 30, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "ra", 31, 1, NULL, 32, "code_ptr");
tdesc_create_reg (feature, "pc", 32, 1, NULL, 32, "code_ptr");
tdesc_create_reg (feature, "status", 33, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "estatus", 34, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "bstatus", 35, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "ienable", 36, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "ipending", 37, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "cpuid", 38, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "ctl6", 39, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "exception", 40, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "pteaddr", 41, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "tlbacc", 42, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "tlbmisc", 43, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "eccinj", 44, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "badaddr", 45, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "config", 46, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "mpubase", 47, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "mpuacc", 48, 1, NULL, 32, "uint32");
tdesc_nios2 = result.release ();
}

View File

@@ -1,12 +0,0 @@
<?xml version="1.0"?>
<!-- Copyright (C) 2013-2024 Free Software Foundation, Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved. -->
<!DOCTYPE target SYSTEM "gdb-target.dtd">
<target>
<architecture>nios2</architecture>
<xi:include href="nios2-cpu.xml"/>
</target>

View File

@@ -1,261 +0,0 @@
/* Target-dependent code for GNU/Linux on Nios II.
Copyright (C) 2012-2024 Free Software Foundation, Inc.
Contributed by Mentor Graphics, 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 "frame.h"
#include "osabi.h"
#include "solib-svr4.h"
#include "trad-frame.h"
#include "tramp-frame.h"
#include "symtab.h"
#include "regset.h"
#include "regcache.h"
#include "linux-tdep.h"
#include "glibc-tdep.h"
#include "nios2-tdep.h"
#include "gdbarch.h"
/* Core file and register set support. */
/* Map from the normal register enumeration order to the order that
registers appear in core files, which corresponds to the order
of the register slots in the kernel's struct pt_regs. */
static const int reg_offsets[NIOS2_NUM_REGS] =
{
-1, 8, 9, 10, 11, 12, 13, 14, /* r0 - r7 */
0, 1, 2, 3, 4, 5, 6, 7, /* r8 - r15 */
23, 24, 25, 26, 27, 28, 29, 30, /* r16 - r23 */
-1, -1, 19, 18, 17, 21, -1, 16, /* et bt gp sp fp ea sstatus ra */
21, /* pc */
-1, 20, -1, -1, -1, -1, -1, -1, /* status estatus ... */
-1, -1, -1, -1, -1, -1, -1, -1
};
/* General register set size. Should match sizeof (struct pt_regs) +
sizeof (struct switch_stack) from the NIOS2 Linux kernel patch. */
#define NIOS2_GREGS_SIZE (4 * 34)
/* Implement the supply_regset hook for core files. */
static void
nios2_supply_gregset (const struct regset *regset,
struct regcache *regcache,
int regnum, const void *gregs_buf, size_t len)
{
const gdb_byte *gregs = (const gdb_byte *) gregs_buf;
int regno;
for (regno = NIOS2_Z_REGNUM; regno <= NIOS2_MPUACC_REGNUM; regno++)
if (regnum == -1 || regnum == regno)
{
if (reg_offsets[regno] != -1)
regcache->raw_supply (regno, gregs + 4 * reg_offsets[regno]);
else
regcache->raw_supply_zeroed (regno);
}
}
/* Implement the collect_regset hook for core files. */
static void
nios2_collect_gregset (const struct regset *regset,
const struct regcache *regcache,
int regnum, void *gregs_buf, size_t len)
{
gdb_byte *gregs = (gdb_byte *) gregs_buf;
int regno;
for (regno = NIOS2_Z_REGNUM; regno <= NIOS2_MPUACC_REGNUM; regno++)
if (regnum == -1 || regnum == regno)
{
if (reg_offsets[regno] != -1)
regcache->raw_collect (regno, gregs + 4 * reg_offsets[regno]);
}
}
static const struct regset nios2_core_regset =
{
NULL,
nios2_supply_gregset,
nios2_collect_gregset
};
/* Iterate over core file register note sections. */
static void
nios2_iterate_over_regset_sections (struct gdbarch *gdbarch,
iterate_over_regset_sections_cb *cb,
void *cb_data,
const struct regcache *regcache)
{
cb (".reg", NIOS2_GREGS_SIZE, NIOS2_GREGS_SIZE, &nios2_core_regset, NULL,
cb_data);
}
/* Initialize a trad-frame cache corresponding to the tramp-frame.
FUNC is the address of the instruction TRAMP[0] in memory.
This ABI is not documented. It corresponds to rt_setup_ucontext in
the kernel arch/nios2/kernel/signal.c file.
The key points are:
- The kernel creates a trampoline at the hard-wired address 0x1044.
- The stack pointer points to an object of type struct rt_sigframe.
The definition of this structure is not exported from the kernel.
The register save area is located at offset 152 bytes (as determined
by inspection of the stack contents in the debugger), and the
registers are saved as r1-r23, ra, fp, gp, ea, sp.
This interface was implemented with kernel version 3.19 (the first
official mainline kernel). Older unofficial kernel versions used
incompatible conventions; we do not support those here. */
#define NIOS2_SIGRETURN_TRAMP_ADDR 0x1044
#define NIOS2_SIGRETURN_REGSAVE_OFFSET 152
static void
nios2_linux_rt_sigreturn_init (const struct tramp_frame *self,
const frame_info_ptr &next_frame,
struct trad_frame_cache *this_cache,
CORE_ADDR func)
{
CORE_ADDR sp = get_frame_register_unsigned (next_frame, NIOS2_SP_REGNUM);
CORE_ADDR base = sp + NIOS2_SIGRETURN_REGSAVE_OFFSET;
int i;
for (i = 0; i < 23; i++)
trad_frame_set_reg_addr (this_cache, i + 1, base + i * 4);
trad_frame_set_reg_addr (this_cache, NIOS2_RA_REGNUM, base + 23 * 4);
trad_frame_set_reg_addr (this_cache, NIOS2_FP_REGNUM, base + 24 * 4);
trad_frame_set_reg_addr (this_cache, NIOS2_GP_REGNUM, base + 25 * 4);
trad_frame_set_reg_addr (this_cache, NIOS2_PC_REGNUM, base + 27 * 4);
trad_frame_set_reg_addr (this_cache, NIOS2_SP_REGNUM, base + 28 * 4);
/* Save a frame ID. */
trad_frame_set_id (this_cache, frame_id_build (base, func));
}
/* Trampoline for sigreturn. This has the form
movi r2, __NR_rt_sigreturn
trap 0
appropriately encoded for R1 or R2. */
static struct tramp_frame nios2_r1_linux_rt_sigreturn_tramp_frame =
{
SIGTRAMP_FRAME,
4,
{
{ MATCH_R1_MOVI | SET_IW_I_B (2) | SET_IW_I_IMM16 (139), ULONGEST_MAX },
{ MATCH_R1_TRAP | SET_IW_R_IMM5 (0), ULONGEST_MAX},
{ TRAMP_SENTINEL_INSN }
},
nios2_linux_rt_sigreturn_init
};
static struct tramp_frame nios2_r2_linux_rt_sigreturn_tramp_frame =
{
SIGTRAMP_FRAME,
4,
{
{ MATCH_R2_MOVI | SET_IW_F2I16_B (2) | SET_IW_F2I16_IMM16 (139), ULONGEST_MAX },
{ MATCH_R2_TRAP | SET_IW_X2L5_IMM5 (0), ULONGEST_MAX},
{ TRAMP_SENTINEL_INSN }
},
nios2_linux_rt_sigreturn_init
};
/* When FRAME is at a syscall instruction, return the PC of the next
instruction to be executed. */
static CORE_ADDR
nios2_linux_syscall_next_pc (const frame_info_ptr &frame,
const struct nios2_opcode *op)
{
CORE_ADDR pc = get_frame_pc (frame);
ULONGEST syscall_nr = get_frame_register_unsigned (frame, NIOS2_R2_REGNUM);
/* If we are about to make a sigreturn syscall, use the unwinder to
decode the signal frame. */
if (syscall_nr == 139 /* rt_sigreturn */)
return frame_unwind_caller_pc (frame);
return pc + op->size;
}
/* Return true if PC is a kernel helper, a function mapped by the kernel
into user space on an unwritable page. Currently the only such function
is __kuser_cmpxchg at 0x1004. See arch/nios2/kernel/entry.S in the Linux
kernel sources and sysdeps/unix/sysv/linux/nios2/atomic-machine.h in
GLIBC. */
static bool
nios2_linux_is_kernel_helper (CORE_ADDR pc)
{
return pc == 0x1004;
}
/* Hook function for gdbarch_register_osabi. */
static void
nios2_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
{
nios2_gdbarch_tdep *tdep = gdbarch_tdep<nios2_gdbarch_tdep> (gdbarch);
linux_init_abi (info, gdbarch, 0);
/* Shared library handling. */
set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
set_gdbarch_skip_solib_resolver (gdbarch, glibc_skip_solib_resolver);
set_solib_svr4_fetch_link_map_offsets (gdbarch,
linux_ilp32_fetch_link_map_offsets);
/* Enable TLS support. */
set_gdbarch_fetch_tls_load_module_address (gdbarch,
svr4_fetch_objfile_link_map);
/* Core file support. */
set_gdbarch_iterate_over_regset_sections
(gdbarch, nios2_iterate_over_regset_sections);
/* Linux signal frame unwinders. */
if (gdbarch_bfd_arch_info (gdbarch)->mach == bfd_mach_nios2r2)
tramp_frame_prepend_unwinder (gdbarch,
&nios2_r2_linux_rt_sigreturn_tramp_frame);
else
tramp_frame_prepend_unwinder (gdbarch,
&nios2_r1_linux_rt_sigreturn_tramp_frame);
tdep->syscall_next_pc = nios2_linux_syscall_next_pc;
tdep->is_kernel_helper = nios2_linux_is_kernel_helper;
/* Index of target address word in glibc jmp_buf. */
tdep->jb_pc = 10;
}
void _initialize_nios2_linux_tdep ();
void
_initialize_nios2_linux_tdep ()
{
const struct bfd_arch_info *arch_info;
for (arch_info = bfd_lookup_arch (bfd_arch_nios2, 0);
arch_info != NULL;
arch_info = arch_info->next)
gdbarch_register_osabi (bfd_arch_nios2, arch_info->mach,
GDB_OSABI_LINUX, nios2_linux_init_abi);
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,90 +0,0 @@
/* Target-dependent header for the Nios II architecture, for GDB.
Copyright (C) 2012-2024 Free Software Foundation, Inc.
Contributed by Mentor Graphics, 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/>. */
#ifndef NIOS2_TDEP_H
#define NIOS2_TDEP_H
#include "gdbarch.h"
/* Nios II ISA specific encodings and macros. */
#include "opcode/nios2.h"
/* Registers. */
#define NIOS2_Z_REGNUM 0 /* Zero */
#define NIOS2_R2_REGNUM 2 /* used for return value */
#define NIOS2_R3_REGNUM 3 /* used for return value */
/* Used for hidden zero argument to store ptr to struct return value. */
#define NIOS2_R4_REGNUM 4
#define NIOS2_R7_REGNUM 7
#define NIOS2_GP_REGNUM 26 /* Global Pointer */
#define NIOS2_SP_REGNUM 27 /* Stack Pointer */
#define NIOS2_FP_REGNUM 28 /* Frame Pointer */
#define NIOS2_EA_REGNUM 29 /* Exception address */
#define NIOS2_BA_REGNUM 30 /* Breakpoint return address */
#define NIOS2_RA_REGNUM 31 /* Return address */
#define NIOS2_PC_REGNUM 32
/* Control registers. */
#define NIOS2_STATUS_REGNUM 33
#define NIOS2_ESTATUS_REGNUM 34
#define NIOS2_BSTATUS_REGNUM 35
#define NIOS2_IENABLE_REGNUM 36
#define NIOS2_IPENDING_REGNUM 37
#define NIOS2_CPUID_REGNUM 38
#define NIOS2_EXCEPTION_REGNUM 40
#define NIOS2_PTEADDR_REGNUM 41
#define NIOS2_TLBACC_REGNUM 42
#define NIOS2_TLBMISC_REGNUM 43
#define NIOS2_ECCINJ_REGNUM 44
#define NIOS2_BADADDR_REGNUM 45
#define NIOS2_CONFIG_REGNUM 46
#define NIOS2_MPUBASE_REGNUM 47
#define NIOS2_MPUACC_REGNUM 48
/* R4-R7 are used for argument passing. */
#define NIOS2_FIRST_ARGREG NIOS2_R4_REGNUM
#define NIOS2_LAST_ARGREG NIOS2_R7_REGNUM
/* Number of all registers. */
#define NIOS2_NUM_REGS 49
/* Size of an instruction, in bytes. */
#define NIOS2_OPCODE_SIZE 4
#define NIOS2_CDX_OPCODE_SIZE 2
/* Target-dependent structure in gdbarch. */
struct nios2_gdbarch_tdep : gdbarch_tdep_base
{
/* Assumes FRAME is stopped at a syscall (trap) instruction; returns
the expected next PC. */
CORE_ADDR (*syscall_next_pc) (const frame_info_ptr &frame,
const struct nios2_opcode *op) = nullptr;
/* Returns true if PC points to a kernel helper function. */
bool (*is_kernel_helper) (CORE_ADDR pc) = nullptr;
/* Offset to PC value in jump buffer.
If this is negative, longjmp support will be disabled. */
int jb_pc = 0;
};
extern const struct target_desc *tdesc_nios2_linux;
extern const struct target_desc *tdesc_nios2;
#endif /* NIOS2_TDEP_H */

View File

@@ -1,55 +0,0 @@
# THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi :set ro:
# Generated from: nios2-linux.xml
name:nios2_linux
xmltarget:nios2-linux.xml
expedite:sp,pc
osabi:GNU/Linux
32:zero
32:at
32:r2
32:r3
32:r4
32:r5
32:r6
32:r7
32:r8
32:r9
32:r10
32:r11
32:r12
32:r13
32:r14
32:r15
32:r16
32:r17
32:r18
32:r19
32:r20
32:r21
32:r22
32:r23
32:et
32:bt
32:gp
32:sp
32:fp
32:ea
32:sstatus
32:ra
32:pc
32:status
32:estatus
32:bstatus
32:ienable
32:ipending
32:cpuid
32:ctl6
32:exception
32:pteaddr
32:tlbacc
32:tlbmisc
32:eccinj
32:badaddr
32:config
32:mpubase
32:mpuacc

View File

@@ -73,7 +73,6 @@ proc finish_test { pattern msg } {
# don't gracefully fall back to single-stepping.
setup_kfail gdb/8841 "i?86-*-linux*"
setup_kfail gdb/8841 "*-*-openbsd*"
setup_kfail gdb/8841 "nios2-*-linux*"
fail "$msg (could not set breakpoint)"
}
-re "$pattern.*${gdb_prompt} $" {

View File

@@ -158,7 +158,6 @@ proc stepi_out { name args } {
fail "$test (could not insert single-step breakpoint)"
}
-re "Cannot insert breakpoint.*Cannot access memory.*$gdb_prompt $" {
setup_kfail gdb/8841 "nios2*-*-linux*"
fail "$test (could not insert single-step breakpoint)"
}
-re "keeper.*$gdb_prompt $" {

View File

@@ -61,7 +61,6 @@ gdb_test_multiple "step" "${test}" {
fail "$test (could not insert single-step breakpoint)"
}
-re "Cannot insert breakpoint.*Cannot access memory.*$gdb_prompt $" {
setup_kfail gdb/8841 "nios2*-*-linux*"
fail "$test (could not insert single-step breakpoint)"
}
-re "done = 1;.*${gdb_prompt} $" {

View File

@@ -117,7 +117,6 @@ proc advance { enter_cmd in_handler_prefix in_handler exit_cmd } {
fail "$test (could not insert single-step breakpoint)"
}
-re "Cannot insert breakpoint.*Cannot access memory.*$gdb_prompt $" {
setup_kfail gdb/8841 "nios2*-*-linux*"
fail "$test (could not insert single-step breakpoint)"
}
-re "done = 1;.*${gdb_prompt} $" {
@@ -214,7 +213,6 @@ proc advancei { cmd } {
# don't gracefully fall back to single-stepping.
setup_kfail gdb/8841 "i?86-*-linux*"
setup_kfail gdb/8841 "*-*-openbsd*"
setup_kfail gdb/8841 "nios2-*-linux*"
fail "$test (could not set breakpoint)"
return
}

View File

@@ -45,9 +45,6 @@ switch -glob -- [istarget] {
"nds32*-*-*" {
set core-regs {nds32-core.xml}
}
"nios2-*-*" {
set core-regs {nios2-cpu.xml}
}
"or1k-*-*" {
set core-regs {or1k-core.xml}
}

View File

@@ -3671,7 +3671,7 @@ proc can_hardware_single_step {} {
if { [istarget "arm*-*-*"] || [istarget "mips*-*-*"]
|| [istarget "tic6x-*-*"] || [istarget "sparc*-*-linux*"]
|| [istarget "nios2-*-*"] || [istarget "riscv*-*-linux*"] } {
|| [istarget "riscv*-*-linux*"] } {
return 0
}

View File

@@ -199,7 +199,6 @@ SFILES = \
$(srcdir)/linux-low.cc \
$(srcdir)/linux-m68k-low.cc \
$(srcdir)/linux-mips-low.cc \
$(srcdir)/linux-nios2-low.cc \
$(srcdir)/linux-or1k-low.cc \
$(srcdir)/linux-ppc-low.cc \
$(srcdir)/linux-riscv-low.cc \

View File

@@ -188,14 +188,6 @@ case "${gdbserver_host}" in
srv_linux_usrregs=yes
srv_linux_thread_db=yes
;;
nios2*-*-linux*) srv_regobj="nios2-linux.o"
srv_tgtobj="$srv_linux_obj linux-nios2-low.o"
srv_xmlfiles="nios2-linux.xml"
srv_xmlfiles="${srv_xmlfiles} nios2-cpu.xml"
srv_linux_regsets=yes
srv_linux_usrregs=yes
srv_linux_thread_db=yes
;;
or1k*-*-linux*) srv_regobj="or1k-linux.o"
srv_tgtobj="$srv_linux_obj linux-or1k-low.o"
srv_xmlfiles="or1k-linux.xml"

View File

@@ -1,289 +0,0 @@
/* GNU/Linux/Nios II specific low level interface, for the remote server for
GDB.
Copyright (C) 2008-2024 Free Software Foundation, Inc.
Contributed by Mentor Graphics, 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-low.h"
#include "elf/common.h"
#include "nat/gdb_ptrace.h"
#include <endian.h>
#include "gdb_proc_service.h"
#include <asm/ptrace.h>
#ifndef PTRACE_GET_THREAD_AREA
#define PTRACE_GET_THREAD_AREA 25
#endif
/* Linux target op definitions for the NIOS II architecture. */
class nios2_target : public linux_process_target
{
public:
const regs_info *get_regs_info () override;
const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
protected:
void low_arch_setup () override;
bool low_cannot_fetch_register (int regno) override;
bool low_cannot_store_register (int regno) override;
bool low_supports_breakpoints () override;
CORE_ADDR low_get_pc (regcache *regcache) override;
void low_set_pc (regcache *regcache, CORE_ADDR newpc) override;
bool low_breakpoint_at (CORE_ADDR pc) override;
};
/* The singleton target ops object. */
static nios2_target the_nios2_target;
bool
nios2_target::low_supports_breakpoints ()
{
return true;
}
CORE_ADDR
nios2_target::low_get_pc (regcache *regcache)
{
return linux_get_pc_32bit (regcache);
}
void
nios2_target::low_set_pc (regcache *regcache, CORE_ADDR pc)
{
linux_set_pc_32bit (regcache, pc);
}
/* The following definition must agree with the number of registers
defined in "struct user_regs" in GLIBC
(sysdeps/unix/sysv/linux/nios2/sys/user.h), and also with
NIOS2_NUM_REGS in GDB proper. */
#define nios2_num_regs 49
/* Defined in auto-generated file nios2-linux.c. */
void init_registers_nios2_linux (void);
extern const struct target_desc *tdesc_nios2_linux;
/* This union is used to convert between int and byte buffer
representations of register contents. */
union nios2_register
{
unsigned char buf[4];
int reg32;
};
/* Return the ptrace ``address'' of register REGNO. */
static int nios2_regmap[] = {
-1, 1, 2, 3, 4, 5, 6, 7,
8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23,
24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39,
40, 41, 42, 43, 44, 45, 46, 47,
48,
0
};
/* Implement the low_arch_setup linux target ops method. */
void
nios2_target::low_arch_setup ()
{
current_process ()->tdesc = tdesc_nios2_linux;
}
/* Implement the low_cannot_fetch_register linux target ops method. */
bool
nios2_target::low_cannot_fetch_register (int regno)
{
return (nios2_regmap[regno] == -1);
}
/* Implement the low_cannot_store_register linux target ops method. */
bool
nios2_target::low_cannot_store_register (int regno)
{
return (nios2_regmap[regno] == -1);
}
/* Breakpoint support. Also see comments on nios2_breakpoint_from_pc
in nios2-tdep.c. */
#if defined(__nios2_arch__) && __nios2_arch__ == 2
#define NIOS2_BREAKPOINT 0xb7fd0020
#define CDX_BREAKPOINT 0xd7c9
#else
#define NIOS2_BREAKPOINT 0x003b6ffa
#endif
/* We only register the 4-byte breakpoint, even on R2 targets which also
support 2-byte breakpoints. Since there is no supports_z_point_type
function provided, gdbserver never inserts software breakpoints itself
and instead relies on GDB to insert the breakpoint of the correct length
via a memory write. */
static const unsigned int nios2_breakpoint = NIOS2_BREAKPOINT;
#define nios2_breakpoint_len 4
/* Implementation of target ops method "sw_breakpoint_from_kind". */
const gdb_byte *
nios2_target::sw_breakpoint_from_kind (int kind, int *size)
{
*size = nios2_breakpoint_len;
return (const gdb_byte *) &nios2_breakpoint;
}
/* Implement the low_breakpoint_at linux target ops method. */
bool
nios2_target::low_breakpoint_at (CORE_ADDR where)
{
unsigned int insn;
/* For R2, first check for the 2-byte CDX trap.n breakpoint encoding. */
#if defined(__nios2_arch__) && __nios2_arch__ == 2
read_memory (where, (unsigned char *) &insn, 2);
if (insn == CDX_BREAKPOINT)
return true;
#endif
read_memory (where, (unsigned char *) &insn, 4);
if (insn == nios2_breakpoint)
return true;
return false;
}
/* Fetch the thread-local storage pointer for libthread_db. */
ps_err_e
ps_get_thread_area (struct ps_prochandle *ph,
lwpid_t lwpid, int idx, void **base)
{
if (ptrace (PTRACE_GET_THREAD_AREA, lwpid, NULL, base) != 0)
return PS_ERR;
/* IDX is the bias from the thread pointer to the beginning of the
thread descriptor. It has to be subtracted due to implementation
quirks in libthread_db. */
*base = (void *) ((char *) *base - idx);
return PS_OK;
}
/* Helper functions to collect/supply a single register REGNO. */
static void
nios2_collect_register (struct regcache *regcache, int regno,
union nios2_register *reg)
{
union nios2_register tmp_reg;
collect_register (regcache, regno, &tmp_reg.reg32);
reg->reg32 = tmp_reg.reg32;
}
static void
nios2_supply_register (struct regcache *regcache, int regno,
const union nios2_register *reg)
{
supply_register (regcache, regno, reg->buf);
}
/* We have only a single register set on Nios II. */
static void
nios2_fill_gregset (struct regcache *regcache, void *buf)
{
union nios2_register *regset = (union nios2_register *) buf;
int i;
for (i = 1; i < nios2_num_regs; i++)
nios2_collect_register (regcache, i, regset + i);
}
static void
nios2_store_gregset (struct regcache *regcache, const void *buf)
{
const union nios2_register *regset = (union nios2_register *) buf;
int i;
for (i = 0; i < nios2_num_regs; i++)
nios2_supply_register (regcache, i, regset + i);
}
static struct regset_info nios2_regsets[] =
{
{ PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PRSTATUS,
nios2_num_regs * 4, GENERAL_REGS,
nios2_fill_gregset, nios2_store_gregset },
NULL_REGSET
};
static struct regsets_info nios2_regsets_info =
{
nios2_regsets, /* regsets */
0, /* num_regsets */
NULL, /* disabled_regsets */
};
static struct usrregs_info nios2_usrregs_info =
{
nios2_num_regs,
nios2_regmap,
};
static struct regs_info myregs_info =
{
NULL, /* regset_bitmap */
&nios2_usrregs_info,
&nios2_regsets_info
};
const regs_info *
nios2_target::get_regs_info ()
{
return &myregs_info;
}
/* The linux target ops object. */
linux_process_target *the_linux_target = &the_nios2_target;
void
initialize_low_arch (void)
{
init_registers_nios2_linux ();
initialize_regsets_info (&nios2_regsets_info);
}