2013-02-04 Tristan Gingold <gingold@adacore.com>
[deliverable/binutils-gdb.git] / gdb / i386-nat.h
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-2013 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 #ifndef I386_NAT_H
24 #define I386_NAT_H 1
25
26 /* Hardware-assisted breakpoints and watchpoints. */
27
28 /* Add watchpoint methods to the provided target_ops.
29 Targets using i386 family debug registers for watchpoints should call
30 this. */
31 struct target_ops;
32 extern void i386_use_watchpoints (struct target_ops *);
33
34 /* Support for hardware watchpoints and breakpoints using the i386
35 debug registers.
36
37 This provides several functions for inserting and removing
38 hardware-assisted breakpoints and watchpoints, testing if one or
39 more of the watchpoints triggered and at what address, checking
40 whether a given region can be watched, etc.
41
42 In addition, 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
46 functions are:
47
48 set_control -- set the debug control (DR7)
49 register to a given value for all LWPs
50
51 set_addr -- put an address into one debug
52 register for all LWPs
53
54 get_addr -- return the address in a given debug
55 register of the current LWP
56
57 get_status -- return the value of the debug
58 status (DR6) register for current LWP
59
60 get_control -- return the value of the debug
61 control (DR7) register for current LWP
62
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
65 deubg registers. */
66
67 struct i386_dr_low_type
68 {
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;
75 };
76
77 extern struct i386_dr_low_type i386_dr_low;
78
79 /* Debug registers' indices. */
80 #define DR_FIRSTADDR 0
81 #define DR_LASTADDR 3
82 #define DR_NADDR 4 /* The number of debug address registers. */
83 #define DR_STATUS 6 /* Index of debug status register (DR6). */
84 #define DR_CONTROL 7 /* Index of debug control register (DR7). */
85
86 /* Global state needed to track h/w watchpoints. */
87
88 struct i386_debug_reg_state
89 {
90 /* Mirror the inferior's DRi registers. We keep the status and
91 control registers separated because they don't hold addresses.
92 Note that since we can change these mirrors while threads are
93 running, we never trust them to explain a cause of a trap.
94 For that, we need to peek directly in the inferior registers. */
95 CORE_ADDR dr_mirror[DR_NADDR];
96 unsigned dr_status_mirror, dr_control_mirror;
97
98 /* Reference counts for each debug register. */
99 int dr_ref_count[DR_NADDR];
100 };
101
102 /* Use this function to set i386_dr_low debug_register_length field
103 rather than setting it directly to check that the length is only
104 set once. It also enables the 'maint set/show show-debug-regs'
105 command. */
106
107 extern void i386_set_debug_register_length (int len);
108
109 /* Use this function to reset the i386-nat.c debug register state. */
110
111 extern void i386_cleanup_dregs (void);
112
113 /* Return a pointer to the the local mirror of the inferior's debug
114 registers. */
115
116 extern struct i386_debug_reg_state *i386_debug_reg_state (void);
117
118 #endif /* I386_NAT_H */
This page took 0.031819 seconds and 4 git commands to generate.