1 /* Native-dependent code for the i386.
3 Low level functions to implement Oeprating System specific
4 code to manipulate I386 debug registers.
6 Copyright (C) 2009-2014 Free Software Foundation, Inc.
8 This file is part of GDB.
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.
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.
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/>. */
26 #include "nat/i386-dregs.h"
28 /* Hardware-assisted breakpoints and watchpoints. */
30 /* Whether or not to print the mirrored debug registers. */
31 extern int debug_hw_points
;
33 /* Add watchpoint methods to the provided target_ops.
34 Targets using i386 family debug registers for watchpoints should call
37 extern void i386_use_watchpoints (struct target_ops
*);
39 /* Support for hardware watchpoints and breakpoints using the i386
42 Each target should provide several low-level functions
43 regrouped into i386_dr_low_type struct below. These functions
44 that will be called to insert watchpoints and hardware breakpoints
45 into the inferior, remove them, and check their status. These
48 set_control -- set the debug control (DR7)
49 register to a given value for all LWPs
51 set_addr -- put an address into one debug
54 get_addr -- return the address in a given debug
55 register of the current LWP
57 get_status -- return the value of the debug
58 status (DR6) register for current LWP
60 get_control -- return the value of the debug
61 control (DR7) register for current LWP
63 Additionally, the native file should set the debug_register_length
64 field to 4 or 8 depending on the number of bytes used for
67 struct i386_dr_low_type
69 void (*set_control
) (unsigned long);
70 void (*set_addr
) (int, CORE_ADDR
);
71 CORE_ADDR (*get_addr
) (int);
72 unsigned long (*get_status
) (void);
73 unsigned long (*get_control
) (void);
74 int debug_register_length
;
77 extern struct i386_dr_low_type i386_dr_low
;
79 /* Can we update the inferior's debug registers? */
80 #define i386_dr_low_can_set_addr() (i386_dr_low.set_addr != NULL)
82 /* Update the inferior's debug register REGNUM from STATE. */
83 #define i386_dr_low_set_addr(new_state, i) \
84 (i386_dr_low.set_addr ((i), (new_state)->dr_mirror[(i)]))
86 /* Return the inferior's debug register REGNUM. */
87 #define i386_dr_low_get_addr(i) (i386_dr_low.get_addr ((i)))
89 /* Can we update the inferior's DR7 control register? */
90 #define i386_dr_low_can_set_control() (i386_dr_low.set_control != NULL)
92 /* Update the inferior's DR7 debug control register from STATE. */
93 #define i386_dr_low_set_control(new_state) \
94 (i386_dr_low.set_control ((new_state)->dr_control_mirror))
96 /* Return the value of the inferior's DR7 debug control register. */
97 #define i386_dr_low_get_control() (i386_dr_low.get_control ())
99 /* Return the value of the inferior's DR6 debug status register. */
100 #define i386_dr_low_get_status() (i386_dr_low.get_status ())
102 /* Return the debug register size, in bytes. */
103 #define i386_get_debug_register_length() \
104 (i386_dr_low.debug_register_length)
106 /* Use this function to set i386_dr_low debug_register_length field
107 rather than setting it directly to check that the length is only
108 set once. It also enables the 'maint set/show show-debug-regs'
111 extern void i386_set_debug_register_length (int len
);
113 /* Use this function to reset the i386-nat.c debug register state. */
115 extern void i386_cleanup_dregs (void);
117 /* Return a pointer to the local mirror of the debug registers of
120 extern struct i386_debug_reg_state
*i386_debug_reg_state (pid_t pid
);
122 /* Called whenever GDB is no longer debugging process PID. It deletes
123 data structures that keep track of debug register state. */
125 extern void i386_forget_process (pid_t pid
);
127 #endif /* I386_NAT_H */