mirror of
https://github.com/genodelabs/genode.git
synced 2025-02-12 05:55:37 +00:00
GDB monitor: x86_64 support
General support for the x86_64 architecture. Fixes #1970
This commit is contained in:
parent
5842b2065e
commit
ff76e69542
@ -26,6 +26,12 @@ i386.c:
|
|||||||
i386-avx.c:
|
i386-avx.c:
|
||||||
$(VERBOSE) cd $(dir $@) && $(SHELL) $(REGFORMATS_DIR)/regdat.sh $(REGFORMATS_DIR)/i386/i386-avx.dat $(notdir $@)
|
$(VERBOSE) cd $(dir $@) && $(SHELL) $(REGFORMATS_DIR)/regdat.sh $(REGFORMATS_DIR)/i386/i386-avx.dat $(notdir $@)
|
||||||
|
|
||||||
|
amd64.c:
|
||||||
|
$(VERBOSE) cd $(dir $@) && $(SHELL) $(REGFORMATS_DIR)/regdat.sh $(REGFORMATS_DIR)/i386/amd64.dat $(notdir $@)
|
||||||
|
|
||||||
|
amd64-avx.c:
|
||||||
|
$(VERBOSE) cd $(dir $@) && $(SHELL) $(REGFORMATS_DIR)/regdat.sh $(REGFORMATS_DIR)/i386/amd64-avx.dat $(notdir $@)
|
||||||
|
|
||||||
vpath %.cc $(REP_DIR)/src/lib/gdbserver_platform
|
vpath %.cc $(REP_DIR)/src/lib/gdbserver_platform
|
||||||
vpath %.c $(GDB_CONTRIB_DIR)/gdb/gdbserver
|
vpath %.c $(GDB_CONTRIB_DIR)/gdb/gdbserver
|
||||||
|
|
||||||
|
9
repos/ports/lib/mk/spec/x86_64/gdbserver_platform.inc
Normal file
9
repos/ports/lib/mk/spec/x86_64/gdbserver_platform.inc
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
SRC_C = i386.c \
|
||||||
|
i386-avx.c \
|
||||||
|
amd64.c \
|
||||||
|
amd64-avx.c \
|
||||||
|
linux-x86-low.c
|
||||||
|
|
||||||
|
CC_OPT_linux-x86-low += -Wno-unused-function
|
||||||
|
|
||||||
|
include $(REP_DIR)/lib/mk/gdbserver_platform.inc
|
@ -1 +1 @@
|
|||||||
408b65147b4253d1ffa3d9ebd7b197df2a666261
|
4d172e5273a79dd9b3da41eff846f945719e4ee3
|
||||||
|
@ -13,6 +13,7 @@ PATCHES_DIR := $(GENODE_DIR)/tool/patches/gdb-$(VERSION)
|
|||||||
PATCHES := $(addprefix $(PATCHES_DIR)/,$(shell cat $(PATCHES_DIR)/series)) \
|
PATCHES := $(addprefix $(PATCHES_DIR)/,$(shell cat $(PATCHES_DIR)/series)) \
|
||||||
$(REP_DIR)/src/app/gdb_monitor/siginfo.patch \
|
$(REP_DIR)/src/app/gdb_monitor/siginfo.patch \
|
||||||
$(REP_DIR)/src/app/gdb_monitor/gdbserver_genode.patch \
|
$(REP_DIR)/src/app/gdb_monitor/gdbserver_genode.patch \
|
||||||
$(REP_DIR)/src/noux-pkg/gdb/build.patch
|
$(REP_DIR)/src/noux-pkg/gdb/build.patch \
|
||||||
PATCH_OPT := -p1 -d ${DIR(gdb)}
|
$(REP_DIR)/src/app/gdb_monitor/gdbserver_x86_64.patch
|
||||||
|
|
||||||
|
PATCH_OPT := -p1 -d ${DIR(gdb)}
|
||||||
|
@ -221,6 +221,8 @@ append_platform_drv_boot_modules
|
|||||||
|
|
||||||
build_boot_image $boot_modules
|
build_boot_image $boot_modules
|
||||||
|
|
||||||
|
append qemu_args " -m 256 "
|
||||||
|
|
||||||
run_genode_until forever
|
run_genode_until forever
|
||||||
|
|
||||||
exec rm bin/gdb.tar
|
exec rm bin/gdb.tar
|
||||||
|
169
repos/ports/src/app/gdb_monitor/gdbserver_x86_64.patch
Normal file
169
repos/ports/src/app/gdb_monitor/gdbserver_x86_64.patch
Normal file
@ -0,0 +1,169 @@
|
|||||||
|
gdbserver_x86_64.patch
|
||||||
|
|
||||||
|
From: Christian Prochaska <christian.prochaska@genode-labs.com>
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
gdb/gdbserver/linux-x86-low.c | 54 ++++++++++++++++++++++++++++++++++++++---
|
||||||
|
1 file changed, 50 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c
|
||||||
|
index e98e3bd..0ece728 100644
|
||||||
|
--- a/gdb/gdbserver/linux-x86-low.c
|
||||||
|
+++ b/gdb/gdbserver/linux-x86-low.c
|
||||||
|
@@ -33,6 +33,12 @@
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __GENODE__
|
||||||
|
+#ifdef __x86_64__
|
||||||
|
+void init_registers_amd64 (void);
|
||||||
|
+static inline void init_registers_amd64_linux(void) { init_registers_amd64(); }
|
||||||
|
+void init_registers_amd64_avx (void);
|
||||||
|
+static inline void init_registers_amd64_avx_linux(void) { init_registers_amd64_avx(); }
|
||||||
|
+#endif /* __x64_64__ */
|
||||||
|
/* Defined in auto-generated file i386.c. */
|
||||||
|
void init_registers_i386 (void);
|
||||||
|
static inline void init_registers_i386_linux(void) { init_registers_i386(); }
|
||||||
|
@@ -83,7 +89,9 @@ static const char *xmltarget_amd64_linux_no_xml = "@<target>\
|
||||||
|
#endif /* __GENODE__ */
|
||||||
|
|
||||||
|
#ifdef __GENODE__
|
||||||
|
-#ifndef __x86_64__
|
||||||
|
+#ifdef __x86_64__
|
||||||
|
+#include "amd64.h"
|
||||||
|
+#else
|
||||||
|
#include "i386.h"
|
||||||
|
#endif /* __x86_64__ */
|
||||||
|
#else
|
||||||
|
@@ -153,7 +161,11 @@ static /*const*/ int i386_regmap[] =
|
||||||
|
/* So code below doesn't have to care, i386 or amd64. */
|
||||||
|
#define ORIG_EAX ORIG_RAX
|
||||||
|
|
||||||
|
-static const int x86_64_regmap[] =
|
||||||
|
+static
|
||||||
|
+#ifndef __GENODE__
|
||||||
|
+const
|
||||||
|
+#endif
|
||||||
|
+int x86_64_regmap[] =
|
||||||
|
{
|
||||||
|
RAX * 8, RBX * 8, RCX * 8, RDX * 8,
|
||||||
|
RSI * 8, RDI * 8, RBP * 8, RSP * 8,
|
||||||
|
@@ -165,7 +177,9 @@ static const int x86_64_regmap[] =
|
||||||
|
-1, -1, -1, -1, -1, -1, -1, -1,
|
||||||
|
-1, -1, -1, -1, -1, -1, -1, -1,
|
||||||
|
-1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||||
|
+#ifndef __GENODE__
|
||||||
|
ORIG_RAX * 8
|
||||||
|
+#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
#define X86_64_NUM_REGS (sizeof (x86_64_regmap) / sizeof (x86_64_regmap[0]))
|
||||||
|
@@ -188,6 +202,7 @@ static /*const*/ int i386_regmap[] =
|
||||||
|
|
||||||
|
/* Called by libthread_db. */
|
||||||
|
|
||||||
|
+#ifndef __GENODE__
|
||||||
|
ps_err_e
|
||||||
|
ps_get_thread_area (const struct ps_prochandle *ph,
|
||||||
|
lwpid_t lwpid, int idx, void **base)
|
||||||
|
@@ -225,6 +240,7 @@ ps_get_thread_area (const struct ps_prochandle *ph,
|
||||||
|
return PS_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+#endif
|
||||||
|
|
||||||
|
/* Get the thread area address. This is used to recognize which
|
||||||
|
thread is which when tracing with the in-process agent library. We
|
||||||
|
@@ -286,6 +302,20 @@ i386_cannot_fetch_register (int regno)
|
||||||
|
return regno >= I386_NUM_REGS;
|
||||||
|
}
|
||||||
|
|
||||||
|
+#ifdef __x86_64__
|
||||||
|
+static int
|
||||||
|
+x86_64_cannot_store_register (int regno)
|
||||||
|
+{
|
||||||
|
+ return regno >= X86_64_NUM_REGS;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static int
|
||||||
|
+x86_64_cannot_fetch_register (int regno)
|
||||||
|
+{
|
||||||
|
+ return regno >= X86_64_NUM_REGS;
|
||||||
|
+}
|
||||||
|
+#endif /* __x86_64__ */
|
||||||
|
+
|
||||||
|
static void
|
||||||
|
x86_fill_gregset (struct regcache *regcache, void *buf)
|
||||||
|
{
|
||||||
|
@@ -728,6 +758,7 @@ x86_linux_prepare_to_resume (struct lwp_info *lwp)
|
||||||
|
compatible with the siginfo type exported by the 32-bit userspace
|
||||||
|
support. */
|
||||||
|
|
||||||
|
+#ifndef __GENODE__
|
||||||
|
#ifdef __x86_64__
|
||||||
|
|
||||||
|
typedef int compat_int_t;
|
||||||
|
@@ -969,6 +1000,7 @@ x86_siginfo_fixup (siginfo_t *native, void *inf, int direction)
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
+#endif
|
||||||
|
|
||||||
|
static int use_xml;
|
||||||
|
|
||||||
|
@@ -1138,11 +1170,15 @@ static void
|
||||||
|
x86_arch_setup (void)
|
||||||
|
{
|
||||||
|
#ifdef __x86_64__
|
||||||
|
+#ifdef __GENODE__
|
||||||
|
+ int use_64bit = 1;
|
||||||
|
+#else
|
||||||
|
int pid = pid_of (get_thread_lwp (current_inferior));
|
||||||
|
char *file = linux_child_pid_to_exec_file (pid);
|
||||||
|
int use_64bit = elf_64_file_p (file);
|
||||||
|
|
||||||
|
free (file);
|
||||||
|
+#endif
|
||||||
|
|
||||||
|
if (use_64bit < 0)
|
||||||
|
{
|
||||||
|
@@ -1152,19 +1188,25 @@ x86_arch_setup (void)
|
||||||
|
}
|
||||||
|
else if (use_64bit)
|
||||||
|
{
|
||||||
|
+#ifdef __GENODE__
|
||||||
|
+ the_low_target.num_regs = X86_64_NUM_REGS;
|
||||||
|
+ the_low_target.regmap = x86_64_regmap;
|
||||||
|
+ the_low_target.cannot_fetch_register = x86_64_cannot_fetch_register;
|
||||||
|
+ the_low_target.cannot_store_register = x86_64_cannot_store_register;
|
||||||
|
+#else
|
||||||
|
/* Amd64 doesn't have HAVE_LINUX_USRREGS. */
|
||||||
|
the_low_target.num_regs = -1;
|
||||||
|
the_low_target.regmap = NULL;
|
||||||
|
the_low_target.cannot_fetch_register = NULL;
|
||||||
|
the_low_target.cannot_store_register = NULL;
|
||||||
|
-
|
||||||
|
+#endif
|
||||||
|
/* Amd64 has 16 xmm regs. */
|
||||||
|
num_xmm_registers = 16;
|
||||||
|
|
||||||
|
x86_linux_update_xmltarget ();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
-#endif
|
||||||
|
+#endif /* __x86_64__ */
|
||||||
|
|
||||||
|
/* Ok we have a 32-bit inferior. */
|
||||||
|
|
||||||
|
@@ -2620,7 +2662,11 @@ struct linux_target_ops the_low_target =
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
/* need to fix up i386 siginfo if host is amd64 */
|
||||||
|
+#ifdef __GENODE__
|
||||||
|
+ NULL,
|
||||||
|
+#else
|
||||||
|
x86_siginfo_fixup,
|
||||||
|
+#endif
|
||||||
|
x86_linux_new_process,
|
||||||
|
x86_linux_new_thread,
|
||||||
|
#ifndef __GENODE__
|
78
repos/ports/src/lib/gdbserver_platform/amd64.h
Normal file
78
repos/ports/src/lib/gdbserver_platform/amd64.h
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
/*
|
||||||
|
* \brief Genode backend for GDB server (x86_64-specific code)
|
||||||
|
* \author Christian Prochaska
|
||||||
|
* \date 2014-01-30
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2014-2016 Genode Labs GmbH
|
||||||
|
*
|
||||||
|
* This file is part of the Genode OS framework, which is distributed
|
||||||
|
* under the terms of the GNU General Public License version 2.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef AMD64_H
|
||||||
|
#define AMD64_H
|
||||||
|
|
||||||
|
/* indices from 'regs_amd64' array in amd64.c */
|
||||||
|
enum reg_index {
|
||||||
|
RAX = 0,
|
||||||
|
RBX = 1,
|
||||||
|
RCX = 2,
|
||||||
|
RDX = 3,
|
||||||
|
RSI = 4,
|
||||||
|
RDI = 5,
|
||||||
|
RBP = 6,
|
||||||
|
RSP = 7,
|
||||||
|
R8 = 8,
|
||||||
|
R9 = 9,
|
||||||
|
R10 = 10,
|
||||||
|
R11 = 11,
|
||||||
|
R12 = 12,
|
||||||
|
R13 = 13,
|
||||||
|
R14 = 14,
|
||||||
|
R15 = 15,
|
||||||
|
RIP = 16,
|
||||||
|
EFLAGS = 17,
|
||||||
|
CS = 18,
|
||||||
|
SS = 19,
|
||||||
|
DS = 20,
|
||||||
|
ES = 21,
|
||||||
|
FS = 22,
|
||||||
|
GS = 23,
|
||||||
|
ST0 = 24,
|
||||||
|
ST1 = 25,
|
||||||
|
ST2 = 26,
|
||||||
|
ST3 = 27,
|
||||||
|
ST4 = 28,
|
||||||
|
ST5 = 29,
|
||||||
|
ST6 = 30,
|
||||||
|
ST7 = 31,
|
||||||
|
FCTRL = 32,
|
||||||
|
FSTAT = 33,
|
||||||
|
FTAG = 34,
|
||||||
|
FISEG = 35,
|
||||||
|
FIOFF = 36,
|
||||||
|
FOSEG = 37,
|
||||||
|
FOOFF = 38,
|
||||||
|
FOP = 39,
|
||||||
|
XMM0 = 40,
|
||||||
|
XMM1 = 41,
|
||||||
|
XMM2 = 42,
|
||||||
|
XMM3 = 43,
|
||||||
|
XMM4 = 44,
|
||||||
|
XMM5 = 45,
|
||||||
|
XMM6 = 46,
|
||||||
|
XMM7 = 47,
|
||||||
|
XMM8 = 48,
|
||||||
|
XMM9 = 49,
|
||||||
|
XMM10 = 50,
|
||||||
|
XMM11 = 51,
|
||||||
|
XMM12 = 52,
|
||||||
|
XMM13 = 53,
|
||||||
|
XMM14 = 54,
|
||||||
|
XMM15 = 55,
|
||||||
|
MXCSR = 56,
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* AMD64_H */
|
Loading…
x
Reference in New Issue
Block a user