GDB (xrefs)
Loading...
Searching...
No Matches
x86-nat.h
Go to the documentation of this file.
1/* Native-dependent code for x86 (i386 and x86-64).
2
3 Low level functions to implement Operating System specific
4 code to manipulate x86 debug registers.
5
6 Copyright (C) 2009-2023 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 X86_NAT_H
24#define X86_NAT_H 1
25
26#include "breakpoint.h"
27#include "nat/x86-dregs.h"
28#include "target.h"
29
30/* Hardware-assisted breakpoints and watchpoints. */
31
32/* Use this function to set x86_dr_low debug_register_length field
33 rather than setting it directly to check that the length is only
34 set once. It also enables the 'maint set/show show-debug-regs'
35 command. */
36
37extern void x86_set_debug_register_length (int len);
38
39/* Use this function to reset the x86-nat.c debug register state. */
40
41extern void x86_cleanup_dregs (void);
42
43/* Return the debug register state for process PID. If no existing
44 state is found for this process, return nullptr. */
45
47
48/* Called whenever GDB is no longer debugging process PID. It deletes
49 data structures that keep track of debug register state. */
50
51extern void x86_forget_process (pid_t pid);
52
53/* Helper functions used by x86_nat_target below. See their
54 definitions. */
55
56extern int x86_can_use_hw_breakpoint (enum bptype type, int cnt, int othertype);
57extern int x86_region_ok_for_hw_watchpoint (CORE_ADDR addr, int len);
58extern int x86_stopped_by_watchpoint ();
59extern int x86_stopped_data_address (CORE_ADDR *addr_p);
60extern int x86_insert_watchpoint (CORE_ADDR addr, int len,
61 enum target_hw_bp_type type,
62 struct expression *cond);
63extern int x86_remove_watchpoint (CORE_ADDR addr, int len,
64 enum target_hw_bp_type type,
65 struct expression *cond);
66extern int x86_insert_hw_breakpoint (struct gdbarch *gdbarch,
67 struct bp_target_info *bp_tgt);
68extern int x86_remove_hw_breakpoint (struct gdbarch *gdbarch,
69 struct bp_target_info *bp_tgt);
71
72/* Convenience template mixin used to add x86 watchpoints support to a
73 target. */
74
75template <typename BaseTarget>
76struct x86_nat_target : public BaseTarget
77{
78 /* Hook in the x86 hardware watchpoints/breakpoints support. */
79
80 int can_use_hw_breakpoint (enum bptype type, int cnt, int othertype) override
81 { return x86_can_use_hw_breakpoint (type, cnt, othertype); }
82
83 int region_ok_for_hw_watchpoint (CORE_ADDR addr, int len) override
84 { return x86_region_ok_for_hw_watchpoint (addr, len); }
85
86 int insert_watchpoint (CORE_ADDR addr, int len,
87 enum target_hw_bp_type type,
88 struct expression *cond) override
89 { return x86_insert_watchpoint (addr, len, type, cond); }
90
91 int remove_watchpoint (CORE_ADDR addr, int len,
92 enum target_hw_bp_type type,
93 struct expression *cond) override
94 { return x86_remove_watchpoint (addr, len, type, cond); }
95
97 struct bp_target_info *bp_tgt) override
98 { return x86_insert_hw_breakpoint (gdbarch, bp_tgt); }
99
101 struct bp_target_info *bp_tgt) override
102 { return x86_remove_hw_breakpoint (gdbarch, bp_tgt); }
103
104 bool stopped_by_watchpoint () override
105 { return x86_stopped_by_watchpoint (); }
106
107 bool stopped_data_address (CORE_ADDR *addr_p) override
108 { return x86_stopped_data_address (addr_p); }
109
110 /* A target must provide an implementation of the
111 "supports_stopped_by_hw_breakpoint" target method before this
112 callback will be used. */
114 { return x86_stopped_by_hw_breakpoint (); }
115};
116
117#endif /* X86_NAT_H */
bptype
Definition breakpoint.h:84
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int int rusage_t pid_t pid
Definition gnu-nat.c:1791
int insert_hw_breakpoint(struct gdbarch *gdbarch, struct bp_target_info *bp_tgt) override
Definition x86-nat.h:96
int can_use_hw_breakpoint(enum bptype type, int cnt, int othertype) override
Definition x86-nat.h:80
int insert_watchpoint(CORE_ADDR addr, int len, enum target_hw_bp_type type, struct expression *cond) override
Definition x86-nat.h:86
bool stopped_data_address(CORE_ADDR *addr_p) override
Definition x86-nat.h:107
int region_ok_for_hw_watchpoint(CORE_ADDR addr, int len) override
Definition x86-nat.h:83
int remove_watchpoint(CORE_ADDR addr, int len, enum target_hw_bp_type type, struct expression *cond) override
Definition x86-nat.h:91
bool stopped_by_hw_breakpoint() override
Definition x86-nat.h:113
bool stopped_by_watchpoint() override
Definition x86-nat.h:104
int remove_hw_breakpoint(struct gdbarch *gdbarch, struct bp_target_info *bp_tgt) override
Definition x86-nat.h:100
int x86_stopped_by_hw_breakpoint()
Definition x86-nat.c:206
int x86_insert_watchpoint(CORE_ADDR addr, int len, enum target_hw_bp_type type, struct expression *cond)
Definition x86-nat.c:92
int x86_stopped_data_address(CORE_ADDR *addr_p)
Definition x86-nat.c:131
int x86_remove_hw_breakpoint(struct gdbarch *gdbarch, struct bp_target_info *bp_tgt)
Definition x86-nat.c:169
void x86_cleanup_dregs(void)
Definition x86-nat.c:81
void x86_forget_process(pid_t pid)
Definition x86-nat.c:72
int x86_stopped_by_watchpoint()
Definition x86-nat.c:143
int x86_insert_hw_breakpoint(struct gdbarch *gdbarch, struct bp_target_info *bp_tgt)
Definition x86-nat.c:155
int x86_can_use_hw_breakpoint(enum bptype type, int cnt, int othertype)
Definition x86-nat.c:197
int x86_region_ok_for_hw_watchpoint(CORE_ADDR addr, int len)
Definition x86-nat.c:118
void x86_set_debug_register_length(int len)
Definition x86-nat.c:236
struct x86_debug_reg_state * x86_lookup_debug_reg_state(pid_t pid)
Definition x86-nat.c:52
int x86_remove_watchpoint(CORE_ADDR addr, int len, enum target_hw_bp_type type, struct expression *cond)
Definition x86-nat.c:105