1 /* Native-dependent code for the i386. 2 3 Low level functions to implement Oeprating System specific 4 code to manipulate I386 debug registers. 5 6 Copyright (C) 2009-2012 Free Software Foundation, Inc. 7 8 This file is part of GDB. 9 10 This program is free software; you can redistribute it and/or modify 11 it under the terms of the GNU General Public License as published by 12 the Free Software Foundation; either version 3 of the License, or 13 (at your option) any later version. 14 15 This program is distributed in the hope that it will be useful, 16 but WITHOUT ANY WARRANTY; without even the implied warranty of 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 GNU General Public License for more details. 19 20 You should have received a copy of the GNU General Public License 21 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 22 23 #include "defs.h" 24 25 #ifndef I386_NAT_H 26 #define I386_NAT_H 1 27 28 /* Hardware-assisted breakpoints and watchpoints. */ 29 30 /* Add watchpoint methods to the provided target_ops. 31 Targets using i386 family debug registers for watchpoints should call 32 this. */ 33 struct target_ops; 34 extern void i386_use_watchpoints (struct target_ops *); 35 36 /* Support for hardware watchpoints and breakpoints using the i386 37 debug registers. 38 39 This provides several functions for inserting and removing 40 hardware-assisted breakpoints and watchpoints, testing if one or 41 more of the watchpoints triggered and at what address, checking 42 whether a given region can be watched, etc. 43 44 In addition, each target should provide several low-level functions 45 regrouped into i386_dr_low_type struct below. These functions 46 that will be called to insert watchpoints and hardware breakpoints 47 into the inferior, remove them, and check their status. These 48 functions are: 49 50 set_control -- set the debug control (DR7) 51 register to a given value for all LWPs 52 53 set_addr -- put an address into one debug 54 register for all LWPs 55 56 reset_addr -- reset the address stored in 57 one debug register for all LWPs 58 59 get_status -- return the value of the debug 60 status (DR6) register for current LWP 61 62 unset_status -- unset the specified bits of the debug 63 status (DR6) register for all LWPs 64 65 Additionally, the native file should set the debug_register_length 66 field to 4 or 8 depending on the number of bytes used for 67 deubg registers. */ 68 69 struct i386_dr_low_type 70 { 71 void (*set_control) (unsigned long); 72 void (*set_addr) (int, CORE_ADDR); 73 void (*reset_addr) (int); 74 unsigned long (*get_status) (void); 75 void (*unset_status) (unsigned long); 76 int debug_register_length; 77 }; 78 79 extern struct i386_dr_low_type i386_dr_low; 80 81 /* Use this function to set i386_dr_low debug_register_length field 82 rather than setting it directly to check that the length is only 83 set once. It also enables the 'maint set/show show-debug-regs' 84 command. */ 85 86 extern void i386_set_debug_register_length (int len); 87 88 /* Use this function to reset the i386-nat.c debug register state. */ 89 90 extern void i386_cleanup_dregs (void); 91 92 #endif /* I386_NAT_H */ 93