]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/gdbserver/i386-low.h
* python/python.c (gdbpy_decode_line): Move cleanup creation out
[thirdparty/binutils-gdb.git] / gdb / gdbserver / i386-low.h
1 /* Misc. low level support for i386.
2
3 Copyright (C) 2009-2012 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20 /* Support for hardware watchpoints and breakpoints using the i386
21 debug registers.
22
23 This provides several functions for inserting and removing
24 hardware-assisted breakpoints and watchpoints, testing if one or
25 more of the watchpoints triggered and at what address, checking
26 whether a given region can be watched, etc.
27
28 The functions below implement debug registers sharing by reference
29 counts, and allow to watch regions up to 16 bytes long
30 (32 bytes on 64 bit hosts). */
31
32
33 /* Debug registers' indices. */
34 #define DR_FIRSTADDR 0
35 #define DR_LASTADDR 3
36 #define DR_NADDR 4 /* The number of debug address registers. */
37 #define DR_STATUS 6
38 #define DR_CONTROL 7
39
40 /* Global state needed to track h/w watchpoints. */
41
42 struct i386_debug_reg_state
43 {
44 /* Mirror the inferior's DRi registers. We keep the status and
45 control registers separated because they don't hold addresses.
46 Note that since we can change these mirrors while threads are
47 running, we never trust them to explain a cause of a trap.
48 For that, we need to peek directly in the inferior registers. */
49 CORE_ADDR dr_mirror[DR_NADDR];
50 unsigned dr_status_mirror, dr_control_mirror;
51
52 /* Reference counts for each debug register. */
53 int dr_ref_count[DR_NADDR];
54 };
55
56 /* Initialize STATE. */
57 extern void i386_low_init_dregs (struct i386_debug_reg_state *state);
58
59 /* Insert a watchpoint to watch a memory region which starts at
60 address ADDR and whose length is LEN bytes. Watch memory accesses
61 of the type TYPE_FROM_PACKET. Return 0 on success, -1 on failure. */
62 extern int i386_low_insert_watchpoint (struct i386_debug_reg_state *state,
63 char type_from_packet, CORE_ADDR addr,
64 int len);
65
66 /* Remove a watchpoint that watched the memory region which starts at
67 address ADDR, whose length is LEN bytes, and for accesses of the
68 type TYPE_FROM_PACKET. Return 0 on success, -1 on failure. */
69 extern int i386_low_remove_watchpoint (struct i386_debug_reg_state *state,
70 char type_from_packet, CORE_ADDR addr,
71 int len);
72
73 /* Return non-zero if we can watch a memory region that starts at
74 address ADDR and whose length is LEN bytes. */
75 extern int i386_low_region_ok_for_watchpoint (struct i386_debug_reg_state *state,
76 CORE_ADDR addr, int len);
77
78 /* If the inferior has some break/watchpoint that triggered, set the
79 address associated with that break/watchpoint and return true.
80 Otherwise, return false. */
81 extern int i386_low_stopped_data_address (struct i386_debug_reg_state *state,
82 CORE_ADDR *addr_p);
83
84 /* Return true if the inferior has some watchpoint that triggered.
85 Otherwise return false. */
86 extern int i386_low_stopped_by_watchpoint (struct i386_debug_reg_state *state);
87 \f
88 /* Each target needs to provide several low-level functions
89 that will be called to insert watchpoints and hardware breakpoints
90 into the inferior, remove them, and check their status. These
91 functions are:
92
93 i386_dr_low_set_control -- set the debug control (DR7)
94 register to a given value
95
96 i386_dr_low_set_addr -- put an address into one debug register
97
98 i386_dr_low_get_status -- return the value of the debug
99 status (DR6) register.
100 */
101
102 /* Update the inferior's debug register REGNUM from STATE. */
103 extern void i386_dr_low_set_addr (const struct i386_debug_reg_state *state,
104 int regnum);
105
106 /* Return the inferior's debug register REGNUM. */
107 extern CORE_ADDR i386_dr_low_get_addr (int regnum);
108
109 /* Update the inferior's DR7 debug control register from STATE. */
110 extern void i386_dr_low_set_control (const struct i386_debug_reg_state *state);
111
112 /* Return the value of the inferior's DR7 debug control register. */
113 extern unsigned i386_dr_low_get_control (void);
114
115 /* Return the value of the inferior's DR6 debug status register. */
116 extern unsigned i386_dr_low_get_status (void);