diff options
author | Doug Evans <dje@google.com> | 2009-06-30 16:35:25 +0000 |
---|---|---|
committer | Doug Evans <dje@google.com> | 2009-06-30 16:35:25 +0000 |
commit | aa5ca48fad05503860c254806750c8a304ec9fc5 (patch) | |
tree | 8674f1a8f7127980b742d674010967bf1907b654 /gdb/gdbserver/win32-i386-low.c | |
parent | 2fd481e1eabba97b05cb5dbd458b2687798f872f (diff) | |
download | gdb-aa5ca48fad05503860c254806750c8a304ec9fc5.zip gdb-aa5ca48fad05503860c254806750c8a304ec9fc5.tar.gz gdb-aa5ca48fad05503860c254806750c8a304ec9fc5.tar.bz2 |
Add h/w watchpoint support to x86-linux, win32-i386.
* Makefile.in (SFILES): Add i386-low.c
(i386_low_h): Define.
(i386-low.o): Add dependencies.
(linux-x86-low.o): Add i386-low.h dependency.
(win32-i386-low.o): Ditto.
* i386-low.c: New file.
* i386-low.h: New file.
* configure.srv (i[34567]86-*-cygwin*): Add i386-low.o to srv_tgtobj.
(i[34567]86-*-linux*, i[34567]86-*-mingw*, x86_64-*-linux*): Ditto.
* linux-low.c (linux_add_process): Initialize arch_private.
(linux_remove_process): Free arch_private.
(add_lwp): Initialize arch_private.
(delete_lwp): Free arch_private.
(linux_resume_one_lwp): Call the_low_target.prepare_to_resume if
provided.
* linux-low.h (process_info_private): New member arch_private.
(lwp_info): New member arch_private.
(linux_target_ops): New members new_process, new_thread,
prepare_to_resume.
(ptid_of): New macro.
* linux-x86-low.c: Include stddef.h, i386-low.h.
(arch_process_info): New struct.
(arch_lwp_info): New struct.
(x86_linux_dr_get, x86_linux_dr_set): New functions.
(i386_dr_low_set_addr, i386_dr_low_set_control): New functions.
(i386_dr_low_get_status): New function.
(x86_insert_point, x86_remove_point): New functions.
(x86_stopped_by_watchpoint): New function.
(x86_stopped_data_address): New function.
(x86_linux_new_process, x86_linux_new_thread): New functions.
(x86_linux_prepare_to_resume): New function.
(the_low_target): Add entries for insert_point, remove_point,
stopped_by_watchpoint, stopped_data_address, new_process, new_thread,
prepare_to_resume.
* server.c (debug_hw_points): New global.
(monitor_show_help): Document set debug-hw-points.
(handle_query): Process "set debug-hw-points".
* server.h (debug_hw_points): Declare.
(paddress): Declare.
* utils.c (NUMCELLS, CELLSIZE): New macros.
(get_sell, xsnprintf, paddress): New functions.
* win32-arm-low.c (the_low_target): Add entries for insert_point,
remove_point, stopped_by_watchpoint, stopped_data_address.
* win32-i386-low.c: Include i386-low.h.
(debug_reg_state): Replaces dr.
(i386_dr_low_set_addr, i386_dr_low_set_control): New functions.
(i386_dr_low_get_status): New function.
(i386_insert_point, i386_remove_point): New functions.
(i386_stopped_by_watchpoint): New function.
(i386_stopped_data_address): New function.
(i386_initial_stuff): Update.
(get_thread_context,set_thread_context,i386_thread_added): Update.
(the_low_target): Add entries for insert_point,
remove_point, stopped_by_watchpoint, stopped_data_address.
* win32-low.c (win32_insert_watchpoint): New function.
(win32_remove_watchpoint): New function.
(win32_stopped_by_watchpoint): New function.
(win32_stopped_data_address): New function.
(win32_target_ops): Add entries for insert_watchpoint,
remove_watchpoint, stopped_by_watchpoint, stopped_data_address.
* win32-low.h (win32_target_ops): New members insert_point,
remove_point, stopped_by_watchpoint, stopped_data_address.
Diffstat (limited to 'gdb/gdbserver/win32-i386-low.c')
-rw-r--r-- | gdb/gdbserver/win32-i386-low.c | 134 |
1 files changed, 114 insertions, 20 deletions
diff --git a/gdb/gdbserver/win32-i386-low.c b/gdb/gdbserver/win32-i386-low.c index a9ede54..7e058a5 100644 --- a/gdb/gdbserver/win32-i386-low.c +++ b/gdb/gdbserver/win32-i386-low.c @@ -17,6 +17,7 @@ #include "server.h" #include "win32-low.h" +#include "i386-low.h" #define FCS_REGNUM 27 #define FOP_REGNUM 31 @@ -26,15 +27,101 @@ /* Defined in auto-generated file reg-i386.c. */ void init_registers_i386 (void); -static unsigned dr[8]; +static struct i386_debug_reg_state debug_reg_state; static int debug_registers_changed = 0; static int debug_registers_used = 0; +/* Update the inferior's debug register REGNUM from STATE. */ + +void +i386_dr_low_set_addr (const struct i386_debug_reg_state *state, int regnum) +{ + if (! (regnum >= 0 && regnum <= DR_LASTADDR - DR_FIRSTADDR)) + fatal ("Invalid debug register %d", regnum); + + /* debug_reg_state.dr_mirror is already set. + Just notify i386_set_thread_context, i386_thread_added + that the registers need to be updated. */ + debug_registers_changed = 1; + debug_registers_used = 1; +} + +/* Update the inferior's DR7 debug control register from STATE. */ + +void +i386_dr_low_set_control (const struct i386_debug_reg_state *state) +{ + /* debug_reg_state.dr_control_mirror is already set. + Just notify i386_set_thread_context, i386_thread_added + that the registers need to be updated. */ + debug_registers_changed = 1; + debug_registers_used = 1; +} + +/* Get the value of the DR6 debug status register from the inferior + and record it in STATE. */ + +void +i386_dr_low_get_status (struct i386_debug_reg_state *state) +{ + /* We don't need to do anything here, the last call to thread_rec for + current_event.dwThreadId id has already set it. */ +} + +/* Watchpoint support. */ + +static int +i386_insert_point (char type, CORE_ADDR addr, int len) +{ + switch (type) + { + case '2': + case '3': + case '4': + return i386_low_insert_watchpoint (&debug_reg_state, + type, addr, len); + default: + /* Unsupported. */ + return 1; + } +} + +static int +i386_remove_point (char type, CORE_ADDR addr, int len) +{ + switch (type) + { + case '2': + case '3': + case '4': + return i386_low_remove_watchpoint (&debug_reg_state, + type, addr, len); + default: + /* Unsupported. */ + return 1; + } +} + +static int +i386_stopped_by_watchpoint (void) +{ + return i386_low_stopped_by_watchpoint (&debug_reg_state); +} + +static CORE_ADDR +i386_stopped_data_address (void) +{ + CORE_ADDR addr; + if (i386_low_stopped_data_address (&debug_reg_state, &addr)) + return addr; + return 0; +} + static void i386_initial_stuff (void) { - memset (&dr, 0, sizeof (dr)); + i386_low_init_dregs (&debug_reg_state); debug_registers_changed = 0; debug_registers_used = 0; } @@ -55,12 +142,13 @@ i386_get_thread_context (win32_thread_info *th, DEBUG_EVENT* current_event) if (th->tid == current_event->dwThreadId) { /* Copy dr values from the current thread. */ - dr[0] = th->context.Dr0; - dr[1] = th->context.Dr1; - dr[2] = th->context.Dr2; - dr[3] = th->context.Dr3; - dr[6] = th->context.Dr6; - dr[7] = th->context.Dr7; + struct i386_debug_reg_state *dr = &debug_reg_state; + dr->dr_mirror[0] = th->context.Dr0; + dr->dr_mirror[1] = th->context.Dr1; + dr->dr_mirror[2] = th->context.Dr2; + dr->dr_mirror[3] = th->context.Dr3; + dr->dr_status_mirror = th->context.Dr6; + dr->dr_control_mirror = th->context.Dr7; } } @@ -69,13 +157,14 @@ i386_set_thread_context (win32_thread_info *th, DEBUG_EVENT* current_event) { if (debug_registers_changed) { - th->context.Dr0 = dr[0]; - th->context.Dr1 = dr[1]; - th->context.Dr2 = dr[2]; - th->context.Dr3 = dr[3]; - /* th->context.Dr6 = dr[6]; + struct i386_debug_reg_state *dr = &debug_reg_state; + th->context.Dr0 = dr->dr_mirror[0]; + th->context.Dr1 = dr->dr_mirror[1]; + th->context.Dr2 = dr->dr_mirror[2]; + th->context.Dr3 = dr->dr_mirror[3]; + /* th->context.Dr6 = dr->dr_status_mirror; FIXME: should we set dr6 also ?? */ - th->context.Dr7 = dr[7]; + th->context.Dr7 = dr->dr_control_mirror; } SetThreadContext (th->h, &th->context); @@ -87,16 +176,17 @@ i386_thread_added (win32_thread_info *th) /* Set the debug registers for the new thread if they are used. */ if (debug_registers_used) { + struct i386_debug_reg_state *dr = &debug_reg_state; th->context.ContextFlags = CONTEXT_DEBUG_REGISTERS; GetThreadContext (th->h, &th->context); - th->context.Dr0 = dr[0]; - th->context.Dr1 = dr[1]; - th->context.Dr2 = dr[2]; - th->context.Dr3 = dr[3]; - /* th->context.Dr6 = dr[6]; + th->context.Dr0 = dr->dr_mirror[0]; + th->context.Dr1 = dr->dr_mirror[1]; + th->context.Dr2 = dr->dr_mirror[2]; + th->context.Dr3 = dr->dr_mirror[3]; + /* th->context.Dr6 = dr->dr_status_mirror; FIXME: should we set dr6 also ?? */ - th->context.Dr7 = dr[7]; + th->context.Dr7 = dr->dr_control_mirror; SetThreadContext (th->h, &th->context); th->context.ContextFlags = 0; @@ -205,4 +295,8 @@ struct win32_target_ops the_low_target = { i386_single_step, NULL, /* breakpoint */ 0, /* breakpoint_len */ + i386_insert_point, + i386_remove_point, + i386_stopped_by_watchpoint, + i386_stopped_data_address }; |