[PATCH 17/20] Multi-process + multiarch: GDBserver: Windows ports

Pedro Alves palves@redhat.com
Tue Apr 10 23:50:00 GMT 2012


This adjusts the Windows ports to new interfaces.

Cross built for i386 mingw32, and smoke tested under Wine.
(yep, GDBserver does work under Wine these days.)

2012-04-10  Pedro Alves  <palves@redhat.com>

	* win32-arm-low.c (tdesc_arm): Declare.
	(arm_arch_setup): New function.
	(the_low_target): Install arm_arch_setup instead of
	init_registers_arm.
	* win32-i386-low.c (tdesc_i386, tdesc_amd64): Declare.
	(init_windows_x86): Rename to ...
	(i386_arch_setup): ... this.  Set `win32_tdesc'.
	(the_low_target): Adjust.
	* win32-low.c (win32_tdesc): New global.
	(child_add_thread): Don't create the thread cache here.
	(do_initial_child_stuff): Set the new process'es tdesc.
	* win32-low.h (struct target_desc): Forward declare.
	(win32_tdesc): Declare.
---
 gdb/gdbserver/win32-arm-low.c  |   11 +++++++++--
 gdb/gdbserver/win32-i386-low.c |    8 ++++++--
 gdb/gdbserver/win32-low.c      |   10 ++++++----
 gdb/gdbserver/win32-low.h      |    6 ++++++
 4 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/gdb/gdbserver/win32-arm-low.c b/gdb/gdbserver/win32-arm-low.c
index b668f6f..88e06dd 100644
--- a/gdb/gdbserver/win32-arm-low.c
+++ b/gdb/gdbserver/win32-arm-low.c
@@ -24,7 +24,7 @@
 
 /* Defined in auto-generated file reg-arm.c.  */
 void init_registers_arm (void);
-
+extern struct target_desc *tdesc_arm;
 
 static void
 arm_get_thread_context (win32_thread_info *th, DEBUG_EVENT* current_event)
@@ -108,12 +108,19 @@ arm_store_inferior_register (struct regcache *regcache,
   collect_register (regcache, r, regptr (&th->context, r));
 }
 
+static void
+arm_arch_setup (void)
+{
+  init_registers_arm ();
+  win32_tdesc = tdesc_arm;
+}
+
 /* Correct in either endianness.  We do not support Thumb yet.  */
 static const unsigned long arm_wince_breakpoint = 0xe6000010;
 #define arm_wince_breakpoint_len 4
 
 struct win32_target_ops the_low_target = {
-  init_registers_arm,
+  arm_arch_setup,
   sizeof (mappings) / sizeof (mappings[0]),
   NULL, /* initial_stuff */
   arm_get_thread_context,
diff --git a/gdb/gdbserver/win32-i386-low.c b/gdb/gdbserver/win32-i386-low.c
index 59b4f1b..1f17990 100644
--- a/gdb/gdbserver/win32-i386-low.c
+++ b/gdb/gdbserver/win32-i386-low.c
@@ -31,9 +31,11 @@
 #ifdef __x86_64__
 /* Defined in auto-generated file reg-amd64.c.  */
 void init_registers_amd64 (void);
+extern struct target_desc *tdesc_amd64;
 #else
 /* Defined in auto-generated file reg-i386.c.  */
 void init_registers_i386 (void);
+extern struct target_desc *tdesc_i386;
 #endif
 
 static struct i386_debug_reg_state debug_reg_state;
@@ -399,17 +401,19 @@ static const unsigned char i386_win32_breakpoint = 0xcc;
 #define i386_win32_breakpoint_len 1
 
 static void
-init_windows_x86 (void)
+i386_arch_setup (void)
 {
 #ifdef __x86_64__
   init_registers_amd64 ();
+  win32_tdesc = tdesc_amd64;
 #else
   init_registers_i386 ();
+  win32_tdesc = tdesc_i386;
 #endif
 }
 
 struct win32_target_ops the_low_target = {
-  init_windows_x86,
+  i386_arch_setup,
   sizeof (mappings) / sizeof (mappings[0]),
   i386_initial_stuff,
   i386_get_thread_context,
diff --git a/gdb/gdbserver/win32-low.c b/gdb/gdbserver/win32-low.c
index 3e10490..956c4eb 100644
--- a/gdb/gdbserver/win32-low.c
+++ b/gdb/gdbserver/win32-low.c
@@ -86,6 +86,8 @@ static int soft_interrupt_requested = 0;
    by suspending all the threads.  */
 static int faked_breakpoint = 0;
 
+struct target_desc *win32_tdesc;
+
 #define NUM_REGS (the_low_target.num_regs)
 
 typedef BOOL WINAPI (*winapi_DebugActiveProcessStop) (DWORD dwProcessId);
@@ -192,9 +194,6 @@ child_add_thread (DWORD pid, DWORD tid, HANDLE h, void *tlb)
   th->thread_local_base = (CORE_ADDR) (uintptr_t) tlb;
 
   add_thread (ptid, th);
-  set_inferior_regcache_data ((struct thread_info *)
-			      find_inferior_id (&all_threads, ptid),
-			      new_register_cache ());
 
   if (the_low_target.thread_added != NULL)
     (*the_low_target.thread_added) (th);
@@ -307,6 +306,8 @@ child_init_thread_list (void)
 static void
 do_initial_child_stuff (HANDLE proch, DWORD pid, int attached)
 {
+  struct process_info *proc;
+
   last_sig = TARGET_SIGNAL_0;
 
   current_process_handle = proch;
@@ -318,7 +319,8 @@ do_initial_child_stuff (HANDLE proch, DWORD pid, int attached)
 
   memset (&current_event, 0, sizeof (current_event));
 
-  add_process (pid, attached);
+  proc = add_process (pid, attached);
+  proc->tdesc = win32_tdesc;
   child_init_thread_list ();
 
   if (the_low_target.initial_stuff != NULL)
diff --git a/gdb/gdbserver/win32-low.h b/gdb/gdbserver/win32-low.h
index 7696d7d..0c6e10a 100644
--- a/gdb/gdbserver/win32-low.h
+++ b/gdb/gdbserver/win32-low.h
@@ -18,6 +18,12 @@
 
 #include <windows.h>
 
+struct target_desc;
+
+/* The inferior's target description.  A global, since the Windows
+   ports don't support multi-arch/multi-process.  */
+extern struct target_desc *win32_tdesc;
+
 /* Thread information structure used to track extra information about
    each thread.  */
 typedef struct win32_thread_info



More information about the Gdb-patches mailing list