36b061b8e79d1bf6b8df04e5a0ff6883f68fecfb
1 /* Native-dependent code for x86 (i386 and x86-64).
3 Low level functions to implement Operating System specific
4 code to manipulate x86 debug registers.
6 Copyright (C) 2009-2019 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 "breakpoint.h"
27 #include "nat/x86-dregs.h"
30 /* Hardware-assisted breakpoints and watchpoints. */
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'
37 extern void x86_set_debug_register_length (int len
);
39 /* Use this function to reset the x86-nat.c debug register state. */
41 extern void x86_cleanup_dregs (void);
43 /* Called whenever GDB is no longer debugging process PID. It deletes
44 data structures that keep track of debug register state. */
46 extern void x86_forget_process (pid_t pid
);
48 /* Helper functions used by x86_nat_target below. See their
51 extern int x86_can_use_hw_breakpoint (enum bptype type
, int cnt
, int othertype
);
52 extern int x86_region_ok_for_hw_watchpoint (CORE_ADDR addr
, int len
);
53 extern int x86_stopped_by_watchpoint ();
54 extern int x86_stopped_data_address (CORE_ADDR
*addr_p
);
55 extern int x86_insert_watchpoint (CORE_ADDR addr
, int len
,
56 enum target_hw_bp_type type
,
57 struct expression
*cond
);
58 extern int x86_remove_watchpoint (CORE_ADDR addr
, int len
,
59 enum target_hw_bp_type type
,
60 struct expression
*cond
);
61 extern int x86_insert_hw_breakpoint (struct gdbarch
*gdbarch
,
62 struct bp_target_info
*bp_tgt
);
63 extern int x86_remove_hw_breakpoint (struct gdbarch
*gdbarch
,
64 struct bp_target_info
*bp_tgt
);
65 extern int x86_stopped_by_hw_breakpoint ();
67 /* Convenience template mixin used to add x86 watchpoints support to a
70 template <typename BaseTarget
>
71 struct x86_nat_target
: public BaseTarget
73 /* Hook in the x86 hardware watchpoints/breakpoints support. */
75 int can_use_hw_breakpoint (enum bptype type
, int cnt
, int othertype
) override
76 { return x86_can_use_hw_breakpoint (type
, cnt
, othertype
); }
78 int region_ok_for_hw_watchpoint (CORE_ADDR addr
, int len
) override
79 { return x86_region_ok_for_hw_watchpoint (addr
, len
); }
81 int insert_watchpoint (CORE_ADDR addr
, int len
,
82 enum target_hw_bp_type type
,
83 struct expression
*cond
) override
84 { return x86_insert_watchpoint (addr
, len
, type
, cond
); }
86 int remove_watchpoint (CORE_ADDR addr
, int len
,
87 enum target_hw_bp_type type
,
88 struct expression
*cond
) override
89 { return x86_remove_watchpoint (addr
, len
, type
, cond
); }
91 int insert_hw_breakpoint (struct gdbarch
*gdbarch
,
92 struct bp_target_info
*bp_tgt
) override
93 { return x86_insert_hw_breakpoint (gdbarch
, bp_tgt
); }
95 int remove_hw_breakpoint (struct gdbarch
*gdbarch
,
96 struct bp_target_info
*bp_tgt
) override
97 { return x86_remove_hw_breakpoint (gdbarch
, bp_tgt
); }
99 bool stopped_by_watchpoint () override
100 { return x86_stopped_by_watchpoint (); }
102 bool stopped_data_address (CORE_ADDR
*addr_p
) override
103 { return x86_stopped_data_address (addr_p
); }
105 /* A target must provide an implementation of the
106 "supports_stopped_by_hw_breakpoint" target method before this
107 callback will be used. */
108 bool stopped_by_hw_breakpoint () override
109 { return x86_stopped_by_hw_breakpoint (); }
112 #endif /* X86_NAT_H */