Commit | Line | Data |
---|---|---|
9bb9e8ad PM |
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 | ||
ecd75fc8 | 6 | Copyright (C) 2009-2014 Free Software Foundation, Inc. |
9bb9e8ad PM |
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 | ||
9bb9e8ad PM |
23 | #ifndef I386_NAT_H |
24 | #define I386_NAT_H 1 | |
25 | ||
b9228891 GB |
26 | #include "nat/i386-dregs.h" |
27 | ||
9bb9e8ad PM |
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 | ||
b9228891 | 39 | Each target should provide several low-level functions |
1777feb0 | 40 | regrouped into i386_dr_low_type struct below. These functions |
9bb9e8ad PM |
41 | that will be called to insert watchpoints and hardware breakpoints |
42 | into the inferior, remove them, and check their status. These | |
43 | functions are: | |
44 | ||
45 | set_control -- set the debug control (DR7) | |
a79d3c27 | 46 | register to a given value for all LWPs |
9bb9e8ad PM |
47 | |
48 | set_addr -- put an address into one debug | |
a79d3c27 | 49 | register for all LWPs |
9bb9e8ad | 50 | |
7b50312a PA |
51 | get_addr -- return the address in a given debug |
52 | register of the current LWP | |
9bb9e8ad PM |
53 | |
54 | get_status -- return the value of the debug | |
a79d3c27 JK |
55 | status (DR6) register for current LWP |
56 | ||
7b50312a PA |
57 | get_control -- return the value of the debug |
58 | control (DR7) register for current LWP | |
9bb9e8ad PM |
59 | |
60 | Additionally, the native file should set the debug_register_length | |
61 | field to 4 or 8 depending on the number of bytes used for | |
62 | deubg registers. */ | |
63 | ||
7b50312a | 64 | struct i386_dr_low_type |
9bb9e8ad PM |
65 | { |
66 | void (*set_control) (unsigned long); | |
67 | void (*set_addr) (int, CORE_ADDR); | |
7b50312a | 68 | CORE_ADDR (*get_addr) (int); |
9bb9e8ad | 69 | unsigned long (*get_status) (void); |
7b50312a | 70 | unsigned long (*get_control) (void); |
9bb9e8ad PM |
71 | int debug_register_length; |
72 | }; | |
73 | ||
74 | extern struct i386_dr_low_type i386_dr_low; | |
75 | ||
5171def3 GB |
76 | /* Can we update the inferior's debug registers? */ |
77 | #define i386_dr_low_can_set_addr() (i386_dr_low.set_addr != NULL) | |
78 | ||
79 | /* Update the inferior's debug register REGNUM from STATE. */ | |
80 | #define i386_dr_low_set_addr(new_state, i) \ | |
81 | (i386_dr_low.set_addr ((i), (new_state)->dr_mirror[(i)])) | |
82 | ||
83 | /* Return the inferior's debug register REGNUM. */ | |
84 | #define i386_dr_low_get_addr(i) (i386_dr_low.get_addr ((i))) | |
85 | ||
86 | /* Can we update the inferior's DR7 control register? */ | |
87 | #define i386_dr_low_can_set_control() (i386_dr_low.set_control != NULL) | |
88 | ||
89 | /* Update the inferior's DR7 debug control register from STATE. */ | |
90 | #define i386_dr_low_set_control(new_state) \ | |
91 | (i386_dr_low.set_control ((new_state)->dr_control_mirror)) | |
92 | ||
93 | /* Return the value of the inferior's DR7 debug control register. */ | |
94 | #define i386_dr_low_get_control() (i386_dr_low.get_control ()) | |
95 | ||
96 | /* Return the value of the inferior's DR6 debug status register. */ | |
97 | #define i386_dr_low_get_status() (i386_dr_low.get_status ()) | |
98 | ||
99 | /* Return the debug register size, in bytes. */ | |
100 | #define i386_get_debug_register_length() \ | |
101 | (i386_dr_low.debug_register_length) | |
102 | ||
9bb9e8ad PM |
103 | /* Use this function to set i386_dr_low debug_register_length field |
104 | rather than setting it directly to check that the length is only | |
105 | set once. It also enables the 'maint set/show show-debug-regs' | |
106 | command. */ | |
107 | ||
108 | extern void i386_set_debug_register_length (int len); | |
109 | ||
110 | /* Use this function to reset the i386-nat.c debug register state. */ | |
111 | ||
112 | extern void i386_cleanup_dregs (void); | |
113 | ||
26cb8b7c PA |
114 | /* Return a pointer to the local mirror of the debug registers of |
115 | process PID. */ | |
7b50312a | 116 | |
26cb8b7c PA |
117 | extern struct i386_debug_reg_state *i386_debug_reg_state (pid_t pid); |
118 | ||
119 | /* Called whenever GDB is no longer debugging process PID. It deletes | |
120 | data structures that keep track of debug register state. */ | |
121 | ||
122 | extern void i386_forget_process (pid_t pid); | |
7b50312a | 123 | |
9bb9e8ad | 124 | #endif /* I386_NAT_H */ |