This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gdbserver on x86_64


On Mon, Aug 08, 2005 at 12:23:16PM -0600, Greg Watson wrote:
> Hi,
> 
> I used the following patch to enable breakpoint support in gdbserver  
> on x86_64.

Sorry, I never got back to you about this patch.

For x86_64 thread debugging you need these changes, plus a bit in
configure.srv.  Minus some unnecessary bits of the patch.  I've
committed this, based on the i386 support.  I've tested LinuxThreads;
there's a decent chance NPTL will work too.

-- 
Daniel Jacobowitz
CodeSourcery, LLC

2005-11-02  Daniel Jacobowitz  <dan@codesourcery.com>

	* configure.srv (x86_64-*-linux*): Turn on thread_db support.
	* linux-x86-64-low.c (x86_64_breakpoint, x86_64_breakpoint_len)
	(x86_64_get_pc, x86_64_set_pc, x86_64_breakpoint_at): New.
	(the_low_target): Update.

Index: configure.srv
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/configure.srv,v
retrieving revision 1.12
diff -u -p -r1.12 configure.srv
--- configure.srv	13 Jul 2005 15:21:02 -0000	1.12
+++ configure.srv	2 Nov 2005 19:50:46 -0000
@@ -87,6 +87,7 @@ case "${target}" in
   x86_64-*-linux*)	srv_regobj=reg-x86-64.o
 			srv_tgtobj="linux-low.o linux-x86-64-low.o i387-fp.o"
 			srv_linux_regsets=yes
+			srv_linux_thread_db=yes
 			;;
   xscale*-*-linux*)	srv_regobj=reg-arm.o
 			srv_tgtobj="linux-low.o linux-arm-low.o"
Index: linux-x86-64-low.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/linux-x86-64-low.c,v
retrieving revision 1.9
diff -u -p -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	2 Nov 2005 19:50:46 -0000
@@ -1,6 +1,6 @@
 /* GNU/Linux/x86-64 specific low level interface, for the remote server
    for GDB.
-   Copyright 2002, 2004
+   Copyright 2002, 2004, 2005
    Free Software Foundation, Inc.
 
    This file is part of GDB.
@@ -129,9 +129,53 @@ struct regset_info target_regsets[] = {
   { 0, 0, -1, -1, NULL, NULL }
 };
 
+static const unsigned char x86_64_breakpoint[] = { 0xCC };
+#define x86_64_breakpoint_len 1
+                
+extern int debug_threads;
+
+static CORE_ADDR
+x86_64_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_64_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_64_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 = {
   -1,
   NULL,
   NULL,
   NULL,
+  x86_64_get_pc,
+  x86_64_set_pc,
+  x86_64_breakpoint,  
+  x86_64_breakpoint_len,
+  NULL,                                 
+  1,
+  x86_64_breakpoint_at,
 };


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]