This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
gdbserver on x86_64
- From: Greg Watson <gwatson at lanl dot gov>
- To: gdb-patches at sources dot redhat dot com
- Date: Mon, 8 Aug 2005 12:23:16 -0600
- Subject: gdbserver on x86_64
- References: <1123510292.20963.ezmlm@sources.redhat.com>
Hi,
I used the following patch to enable breakpoint support in gdbserver
on x86_64.
Enjoy.
Greg
Index: linux-x86-64-low.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/linux-x86-64-low.c,v
retrieving revision 1.9
diff -c -r1.9 linux-x86-64-low.c
*** linux-x86-64-low.c 21 Oct 2004 04:10:48 -0000 1.9
--- linux-x86-64-low.c 8 Aug 2005 18:17:57 -0000
***************
*** 89,94 ****
--- 89,107 ----
return PS_ERR;
}
+ static int
+ x86_cannot_store_register (int regno)
+ {
+ return (regno >= X86_64_NUM_GREGS);
+ }
+
+ static int
+ x86_cannot_fetch_register (int regno)
+ {
+ return (regno >= X86_64_NUM_GREGS);
+ }
+
+
static void
x86_64_fill_gregset (void *buf)
{
***************
*** 129,137 ****
{ 0, 0, -1, -1, NULL, NULL }
};
struct linux_target_ops the_low_target = {
! -1,
! NULL,
! NULL,
NULL,
};
--- 142,194 ----
{ 0, 0, -1, -1, NULL, NULL }
};
+ static const unsigned char x86_breakpoint[] = { 0xCC };
+ #define x86_breakpoint_len 1
+
+ extern int debug_threads;
+
+ static CORE_ADDR
+ x86_get_pc ()
+ {
+ unsigned long pc;
+
+ collect_register_by_name ("rip", &pc);
+
+ if (debug_threads)
+ fprintf (stderr, "stop pc (before any decrement) is %08lx\n", pc);
+ return pc;
+ }
+
+ static void
+ x86_set_pc (CORE_ADDR newpc)
+ {
+ if (debug_threads)
+ fprintf (stderr, "set pc to %08lx\n", (long) newpc);
+ supply_register_by_name ("rip", &newpc);
+ }
+
+ static int
+ x86_breakpoint_at (CORE_ADDR pc)
+ {
+ unsigned char c;
+
+ read_inferior_memory (pc, &c, 1);
+ if (c == 0xCC)
+ return 1;
+
+ return 0;
+ }
+
struct linux_target_ops the_low_target = {
! X86_64_NUM_GREGS,
! x86_64_regmap,
! x86_cannot_fetch_register,
! x86_cannot_store_register,
! x86_get_pc,
! x86_set_pc,
! x86_breakpoint,
! x86_breakpoint_len,
NULL,
+ 1,
+ x86_breakpoint_at,
};