From b16276e9da1b1c75423b2a4a38b9a7ffc77b4bd7 Mon Sep 17 00:00:00 2001 From: Dave Murphy Date: Tue, 30 Jun 2020 18:16:46 +0100 Subject: [PATCH] devkitARM: separate gdb --- dkarm-eabi/patches/gdb-8.2.1.patch | 597 ----------------------------- dkarm-eabi/scripts/build-gcc.sh | 32 -- 2 files changed, 629 deletions(-) delete mode 100644 dkarm-eabi/patches/gdb-8.2.1.patch diff --git a/dkarm-eabi/patches/gdb-8.2.1.patch b/dkarm-eabi/patches/gdb-8.2.1.patch deleted file mode 100644 index 3fc0d97..0000000 --- a/dkarm-eabi/patches/gdb-8.2.1.patch +++ /dev/null @@ -1,597 +0,0 @@ -diff --git a/gdb/Makefile.in b/gdb/Makefile.in -index 9799a7a65d..ccd3f8a626 100644 ---- a/gdb/Makefile.in -+++ b/gdb/Makefile.in -@@ -684,6 +684,7 @@ ALL_TARGET_OBS = \ - arch/arm-linux.o \ - arch/i386.o \ - arch/ppc-linux-common.o \ -+ arm-3ds-tdep.o \ - arm-bsd-tdep.o \ - arm-fbsd-tdep.o \ - arm-linux-tdep.o \ -@@ -2213,6 +2214,7 @@ ALLDEPFILES = \ - amd64-tdep.c \ - arc-tdep.c \ - arm.c \ -+ arm-3ds-tdep.c \ - arm-bsd-tdep.c \ - arm-fbsd-nat.c \ - arm-fbsd-tdep.c \ -diff --git a/gdb/arm-3ds-tdep.c b/gdb/arm-3ds-tdep.c -new file mode 100644 -index 0000000000..c41336982b ---- /dev/null -+++ b/gdb/arm-3ds-tdep.c -@@ -0,0 +1,291 @@ -+/* Target-dependent code for 3DS. */ -+ -+/* This uses code from GDB, which license is: */ -+ -+/* -+ Copyright (C) 2002-2017 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 . */ -+ -+#include "defs.h" -+#include "gdbcore.h" -+#include "target.h" -+#include "osabi.h" -+#include "xml-syscall.h" -+ -+#include "arch/arm.h" -+#include "arch/arm-get-next-pcs.h" -+#include "arm-tdep.h" -+ -+static const gdb_byte arm_3ds_arm_le_breakpoint[] = {0xff, 0x00, 0x00, 0xef}; -+static const gdb_byte arm_3ds_thumb_le_breakpoint[] = {0xff, 0xdf}; -+ -+static CORE_ADDR -+ arm_3ds_get_next_pcs_syscall_next_pc (struct arm_get_next_pcs *self); -+ -+/* Operation function pointers for get_next_pcs. */ -+static struct arm_get_next_pcs_ops arm_3ds_get_next_pcs_ops = { -+ arm_get_next_pcs_read_memory_unsigned_integer, -+ arm_3ds_get_next_pcs_syscall_next_pc, -+ arm_get_next_pcs_addr_bits_remove, -+ arm_get_next_pcs_is_thumb, -+ NULL, -+}; -+ -+/* single_step() is called just before we want to resume the inferior, -+ if we want to single-step it but there is no hardware or kernel -+ single-step support. We find the target of the coming instructions -+ and breakpoint them. */ -+ -+std::vector -+arm_3ds_software_single_step (struct regcache *regcache) -+{ -+ struct gdbarch *gdbarch = regcache->arch (); -+ struct arm_get_next_pcs next_pcs_ctx; -+ -+ arm_get_next_pcs_ctor (&next_pcs_ctx, -+ &arm_3ds_get_next_pcs_ops, -+ gdbarch_byte_order (gdbarch), -+ gdbarch_byte_order_for_code (gdbarch), -+ 0, -+ regcache); -+ -+ std::vector next_pcs = arm_get_next_pcs (&next_pcs_ctx); -+ -+ for (CORE_ADDR &pc_ref : next_pcs) -+ pc_ref = gdbarch_addr_bits_remove (gdbarch, pc_ref); -+ -+ return next_pcs; -+} -+ -+static CORE_ADDR -+arm_3ds_get_next_pcs_syscall_next_pc (struct arm_get_next_pcs *self) -+{ -+ CORE_ADDR next_pc = 0; -+ CORE_ADDR pc = regcache_read_pc (self->regcache); -+ int is_thumb = arm_is_thumb (self->regcache); -+ ULONGEST svc_number = 0; -+ -+ if (is_thumb) -+ { -+ next_pc = pc + 2; -+ } -+ else -+ { -+ next_pc = pc + 4; -+ } -+ -+ /* Addresses for calling Thumb functions have the bit 0 set. */ -+ if (is_thumb) -+ next_pc = MAKE_THUMB_ADDR (next_pc); -+ -+ return next_pc; -+} -+ -+static LONGEST -+arm_3ds_get_syscall_number (struct gdbarch *gdbarch, -+ thread_info *thread) -+{ -+ struct regcache *regs = get_thread_regcache (thread); -+ -+ ULONGEST pc; -+ ULONGEST cpsr; -+ ULONGEST t_bit = arm_psr_thumb_bit (gdbarch); -+ int is_thumb; -+ ULONGEST svc_number = -1; -+ -+ regcache_cooked_read_unsigned (regs, ARM_PC_REGNUM, &pc); -+ regcache_cooked_read_unsigned (regs, ARM_PS_REGNUM, &cpsr); -+ is_thumb = (cpsr & t_bit) != 0; -+ -+ if (is_thumb) -+ { -+ enum bfd_endian byte_order_for_code = -+ gdbarch_byte_order_for_code (gdbarch); -+ -+ /* PC gets incremented before the syscall-stop, so read the -+ previous instruction. */ -+ unsigned long this_instr = -+ read_memory_unsigned_integer (pc - 2, 2, byte_order_for_code); -+ -+ unsigned long svc_operand = (0x00ff & this_instr); -+ svc_number = svc_operand; -+ } -+ else -+ { -+ enum bfd_endian byte_order_for_code = -+ gdbarch_byte_order_for_code (gdbarch); -+ -+ /* PC gets incremented before the syscall-stop, so read the -+ previous instruction. */ -+ unsigned long this_instr = -+ read_memory_unsigned_integer (pc - 4, 4, byte_order_for_code); -+ -+ unsigned long svc_operand = (0x000000ff & this_instr); -+ svc_number = svc_operand; -+ } -+ -+ if (svc_number == 0xfe) -+ { -+ regcache_cooked_read_unsigned (regs, 12, &svc_number); -+ } -+ -+ return svc_number; -+} -+ -+/* Implement the breakpoint_kind_from_pc gdbarch method. */ -+ -+static int -+arm_3ds_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr) -+{ -+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); -+ enum bfd_endian byte_order_for_code = gdbarch_byte_order_for_code (gdbarch); -+ -+ if (arm_pc_is_thumb (gdbarch, *pcptr)) -+ { -+ *pcptr = UNMAKE_THUMB_ADDR (*pcptr); -+ -+ /* If we have a separate 32-bit breakpoint instruction for Thumb-2, -+ check whether we are replacing a 32-bit instruction. */ -+ if (tdep->thumb2_breakpoint != NULL) -+ { -+ gdb_byte buf[2]; -+ -+ if (target_read_memory (*pcptr, buf, 2) == 0) -+ { -+ unsigned short inst1; -+ -+ inst1 = extract_unsigned_integer (buf, 2, byte_order_for_code); -+ if (thumb_insn_size (inst1) == 4) -+ return ARM_BP_KIND_THUMB2; -+ } -+ } -+ -+ return ARM_BP_KIND_THUMB; -+ } -+ else -+ return ARM_BP_KIND_ARM; -+ -+} -+ -+/* Implement the sw_breakpoint_from_kind gdbarch method. */ -+ -+static const gdb_byte * -+arm_3ds_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size) -+{ -+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); -+ -+ switch (kind) -+ { -+ case ARM_BP_KIND_ARM: -+ *size = tdep->arm_breakpoint_size; -+ return tdep->arm_breakpoint; -+ case ARM_BP_KIND_THUMB: -+ *size = tdep->thumb_breakpoint_size; -+ return tdep->thumb_breakpoint; -+ case ARM_BP_KIND_THUMB2: -+ *size = tdep->thumb2_breakpoint_size; -+ return tdep->thumb2_breakpoint; -+ default: -+ gdb_assert_not_reached ("unexpected arm breakpoint kind"); -+ } -+} -+ -+/* Implement the breakpoint_kind_from_current_state gdbarch method. */ -+ -+static int -+arm_3ds_breakpoint_kind_from_current_state (struct gdbarch *gdbarch, -+ struct regcache *regcache, -+ CORE_ADDR *pcptr) -+{ -+ gdb_byte buf[4]; -+ -+ /* Check the memory pointed by PC is readable. */ -+ if (target_read_memory (regcache_read_pc (regcache), buf, 4) == 0) -+ { -+ struct arm_get_next_pcs next_pcs_ctx; -+ -+ arm_get_next_pcs_ctor (&next_pcs_ctx, -+ &arm_3ds_get_next_pcs_ops, -+ gdbarch_byte_order (gdbarch), -+ gdbarch_byte_order_for_code (gdbarch), -+ 0, -+ regcache); -+ -+ std::vector next_pcs = arm_get_next_pcs (&next_pcs_ctx); -+ -+ /* If MEMADDR is the next instruction of current pc, do the -+ software single step computation, and get the thumb mode by -+ the destination address. */ -+ for (CORE_ADDR pc : next_pcs) -+ { -+ if (UNMAKE_THUMB_ADDR (pc) == *pcptr) -+ { -+ if (IS_THUMB_ADDR (pc)) -+ { -+ *pcptr = MAKE_THUMB_ADDR (*pcptr); -+ return arm_3ds_breakpoint_kind_from_pc (gdbarch, pcptr); -+ } -+ else -+ return ARM_BP_KIND_ARM; -+ } -+ } -+ } -+ -+ return arm_3ds_breakpoint_kind_from_pc (gdbarch, pcptr); -+} -+ -+static void -+arm_3ds_init_abi (struct gdbarch_info info, -+ struct gdbarch *gdbarch) -+{ -+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); -+ -+ switch (info.byte_order) -+ { -+ case BFD_ENDIAN_LITTLE: -+ tdep->arm_breakpoint = arm_3ds_arm_le_breakpoint; -+ tdep->thumb_breakpoint = arm_3ds_thumb_le_breakpoint; -+ tdep->arm_breakpoint_size = sizeof (arm_3ds_arm_le_breakpoint); -+ tdep->thumb_breakpoint_size = sizeof (arm_3ds_thumb_le_breakpoint); -+ break; -+ -+ default: -+ internal_error (__FILE__, __LINE__, -+ _("arm_gdbarch_init: bad byte order")); -+ } -+ tdep->fp_model = ARM_FLOAT_VFP; -+ -+ /* Single stepping. */ -+ set_gdbarch_software_single_step (gdbarch, arm_3ds_software_single_step); -+ -+ /* Breakpoint manipulation. */ -+ set_gdbarch_breakpoint_kind_from_pc (gdbarch, arm_3ds_breakpoint_kind_from_pc); -+ set_gdbarch_sw_breakpoint_from_kind (gdbarch, arm_3ds_sw_breakpoint_from_kind); -+ set_gdbarch_breakpoint_kind_from_current_state (gdbarch, -+ arm_3ds_breakpoint_kind_from_current_state); -+ -+ /* `catch syscall' */ -+ set_xml_syscall_file_name (gdbarch, "syscalls/arm-3ds.xml"); -+ set_gdbarch_get_syscall_number (gdbarch, arm_3ds_get_syscall_number); -+} -+ -+void -+_initialize_arm_3ds_tdep (void) -+{ -+ gdbarch_register_osabi (bfd_arch_arm, 0, GDB_OSABI_3DS, -+ arm_3ds_init_abi); -+} -diff --git a/gdb/configure.tgt b/gdb/configure.tgt -index f197160896..e2835ddef5 100644 ---- a/gdb/configure.tgt -+++ b/gdb/configure.tgt -@@ -61,7 +61,7 @@ arc*-*-*) - ;; - - arm*-*-*) -- cpu_obs="arch/arm.o arch/arm-get-next-pcs.o arm-tdep.o";; -+ cpu_obs="arch/arm.o arch/arm-get-next-pcs.o arm-tdep.o arm-3ds-tdep.o";; - - hppa*-*-*) - # Target: HP PA-RISC -diff --git a/gdb/data-directory/Makefile.in b/gdb/data-directory/Makefile.in -index 753e0b69a3..645eb043b9 100644 ---- a/gdb/data-directory/Makefile.in -+++ b/gdb/data-directory/Makefile.in -@@ -63,7 +63,7 @@ GEN_SYSCALLS_FILES = \ - sparc-linux.xml \ - sparc64-linux.xml - --SYSCALLS_FILES = gdb-syscalls.dtd freebsd.xml $(GEN_SYSCALLS_FILES) -+SYSCALLS_FILES = gdb-syscalls.dtd freebsd.xml arm-3ds.xml $(GEN_SYSCALLS_FILES) - - PYTHON_DIR = python - PYTHON_INSTALL_DIR = $(DESTDIR)$(GDB_DATADIR)/$(PYTHON_DIR) -diff --git a/gdb/defs.h b/gdb/defs.h -index fc4217005a..a179a6d820 100644 ---- a/gdb/defs.h -+++ b/gdb/defs.h -@@ -495,6 +495,7 @@ enum gdb_osabi - GDB_OSABI_LYNXOS178, - GDB_OSABI_NEWLIB, - GDB_OSABI_SDE, -+ GDB_OSABI_3DS, - - GDB_OSABI_INVALID /* keep this last */ - }; -diff --git a/gdb/dtrace-probe.c b/gdb/dtrace-probe.c -index fa4e06e794..b6afc4cc7c 100644 ---- a/gdb/dtrace-probe.c -+++ b/gdb/dtrace-probe.c -@@ -100,7 +100,7 @@ public: - - /* DTrace static_probe_ops. */ - --const dtrace_static_probe_ops dtrace_static_probe_ops; -+const dtrace_static_probe_ops dtrace_static_probe_ops = {}; - - /* The following structure represents a dtrace probe. */ - -diff --git a/gdb/osabi.c b/gdb/osabi.c -index 7d0540b181..49d3f78331 100644 ---- a/gdb/osabi.c -+++ b/gdb/osabi.c -@@ -80,6 +80,7 @@ static const struct osabi_names gdb_osabi_names[] = - { "LynxOS178", NULL }, - { "Newlib", NULL }, - { "SDE", NULL }, -+ { "3DS", NULL }, - - { "", NULL } - }; -diff --git a/gdb/probe.c b/gdb/probe.c -index 1f3da213ef..4acbeb8704 100644 ---- a/gdb/probe.c -+++ b/gdb/probe.c -@@ -60,7 +60,7 @@ public: - - /* Static operations associated with a generic probe. */ - --const any_static_probe_ops any_static_probe_ops; -+const any_static_probe_ops any_static_probe_ops = {}; - - /* A helper for parse_probes that decodes a probe specification in - SEARCH_PSPACE. It appends matching SALs to RESULT. */ -diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c -index 09a3f6cc5c..9f90a6b436 100644 ---- a/gdb/record-btrace.c -+++ b/gdb/record-btrace.c -@@ -144,7 +144,7 @@ static record_btrace_target record_btrace_ops; - - /* Token associated with a new-thread observer enabling branch tracing - for the new thread. */ --static const gdb::observers::token record_btrace_thread_observer_token; -+static const gdb::observers::token record_btrace_thread_observer_token = {}; - - /* Memory access types used in set/show record btrace replay-memory-access. */ - static const char replay_memory_access_read_only[] = "read-only"; -diff --git a/gdb/stap-probe.c b/gdb/stap-probe.c -index ed7e1a0d3f..42fad3835f 100644 ---- a/gdb/stap-probe.c -+++ b/gdb/stap-probe.c -@@ -119,7 +119,7 @@ public: - - /* SystemTap static_probe_ops. */ - --const stap_static_probe_ops stap_static_probe_ops; -+const stap_static_probe_ops stap_static_probe_ops = {}; - - class stap_probe : public probe - { -diff --git a/gdb/syscalls/arm-3ds.xml b/gdb/syscalls/arm-3ds.xml -new file mode 100644 -index 0000000000..48780b7bd5 ---- /dev/null -+++ b/gdb/syscalls/arm-3ds.xml -@@ -0,0 +1,159 @@ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -diff --git a/gdb/tui/tui-hooks.c b/gdb/tui/tui-hooks.c -index efa02e2f08..1c341dcf47 100644 ---- a/gdb/tui/tui-hooks.c -+++ b/gdb/tui/tui-hooks.c -@@ -205,7 +205,7 @@ tui_normal_stop (struct bpstats *bs, int print_frame) - - /* Token associated with observers registered while TUI hooks are - installed. */ --static const gdb::observers::token tui_observers_token; -+static const gdb::observers::token tui_observers_token = {}; - - /* Attach or detach a single observer, according to ATTACH. */ - diff --git a/dkarm-eabi/scripts/build-gcc.sh b/dkarm-eabi/scripts/build-gcc.sh index 5cf780a..77e7793 100755 --- a/dkarm-eabi/scripts/build-gcc.sh +++ b/dkarm-eabi/scripts/build-gcc.sh @@ -152,35 +152,3 @@ fi rm -fr $prefix/$target/sys-include cd $BUILDDIR - -#--------------------------------------------------------------------------------- -# build and install the debugger -#--------------------------------------------------------------------------------- -mkdir -p $target/gdb -cd $target/gdb - -PLATFORM=`uname -s` - -if [ ! -f configured-gdb ] -then - CPPFLAGS="$cppflags $CPPFLAGS" \ - LDFLAGS="$ldflags" \ - ../../gdb-$GDB_VER/configure \ - --disable-nls --prefix=$prefix --target=$target --disable-werror \ - $CROSS_PARAMS \ - || { echo "Error configuring gdb"; exit 1; } - touch configured-gdb -fi - -if [ ! -f built-gdb ] -then - $MAKE || { echo "Error building gdb"; exit 1; } - touch built-gdb -fi - -if [ ! -f installed-gdb ] -then - $MAKE install || { echo "Error installing gdb"; exit 1; } - touch installed-gdb -fi -