GDBserver
mem-break.h
Go to the documentation of this file.
1 /* Memory breakpoint interfaces for the remote server for GDB.
2  Copyright (C) 2002-2015 Free Software Foundation, Inc.
3 
4  Contributed by MontaVista Software.
5 
6  This file is part of GDB.
7 
8  This program is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 3 of the License, or
11  (at your option) any later version.
12 
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 
21 #ifndef MEM_BREAK_H
22 #define MEM_BREAK_H
23 
24 #include "break-common.h"
25 
26 /* Breakpoints are opaque. */
27 struct breakpoint;
29 struct raw_breakpoint;
30 struct process_info;
31 
32 #define Z_PACKET_SW_BP '0'
33 #define Z_PACKET_HW_BP '1'
34 #define Z_PACKET_WRITE_WP '2'
35 #define Z_PACKET_READ_WP '3'
36 #define Z_PACKET_ACCESS_WP '4'
37 
38 /* The low level breakpoint types. */
39 
41  {
42  /* Software/memory breakpoint. */
44 
45  /* Hardware-assisted breakpoint. */
47 
48  /* Hardware-assisted write watchpoint. */
50 
51  /* Hardware-assisted read watchpoint. */
53 
54  /* Hardware-assisted access watchpoint. */
56  };
57 
58 /* Map the protocol breakpoint/watchpoint type Z_TYPE to the internal
59  raw breakpoint type. */
60 
61 enum raw_bkpt_type Z_packet_to_raw_bkpt_type (char z_type);
62 
63 /* Map a raw breakpoint type to an enum target_hw_bp_type. */
64 
66  (enum raw_bkpt_type raw_type);
67 
68 /* Create a new GDB breakpoint of type Z_TYPE at ADDR with size SIZE.
69  Returns a pointer to the newly created breakpoint on success. On
70  failure returns NULL and sets *ERR to either -1 for error, or 1 if
71  Z_TYPE breakpoints are not supported on this target. */
72 
73 struct breakpoint *set_gdb_breakpoint (char z_type, CORE_ADDR addr, int size,
74  int *err);
75 
76 /* Delete a GDB breakpoint of type Z_TYPE and size SIZE previously
77  inserted at ADDR with set_gdb_breakpoint_at. Returns 0 on success,
78  -1 on error, and 1 if Z_TYPE breakpoints are not supported on this
79  target. */
80 
81 int delete_gdb_breakpoint (char z_type, CORE_ADDR addr, int size);
82 
83 /* Returns TRUE if there's a software or hardware (code) breakpoint at
84  ADDR in our tables, inserted, or not. */
85 
86 int breakpoint_here (CORE_ADDR addr);
87 
88 /* Returns TRUE if there's any inserted software or hardware (code)
89  breakpoint set at ADDR. */
90 
92 
93 /* Returns TRUE if there's any inserted software breakpoint at
94  ADDR. */
95 
97 
98 /* Returns TRUE if there's any inserted hardware (code) breakpoint at
99  ADDR. */
100 
102 
103 /* Clear all breakpoint conditions and commands associated with a
104  breakpoint. */
105 
107 
108 /* Set target-side condition CONDITION to the breakpoint at ADDR.
109  Returns false on failure. On success, advances CONDITION pointer
110  past the condition and returns true. */
111 
112 int add_breakpoint_condition (struct breakpoint *bp, char **condition);
113 
114 /* Set target-side commands COMMANDS to the breakpoint at ADDR.
115  Returns false on failure. On success, advances COMMANDS past the
116  commands and returns true. If PERSIST, the commands should run
117  even while GDB is disconnected. */
118 
119 int add_breakpoint_commands (struct breakpoint *bp, char **commands,
120  int persist);
121 
122 int any_persistent_commands (void);
123 
124 /* Evaluation condition (if any) at breakpoint BP. Return 1 if
125  true and 0 otherwise. */
126 
128 
130 
132 
133 /* Returns TRUE if there's a GDB breakpoint (Z0 or Z1) set at
134  WHERE. */
135 
136 int gdb_breakpoint_here (CORE_ADDR where);
137 
138 /* Create a new breakpoint at WHERE, and call HANDLER when
139  it is hit. HANDLER should return 1 if the breakpoint
140  should be deleted, 0 otherwise. */
141 
142 struct breakpoint *set_breakpoint_at (CORE_ADDR where,
143  int (*handler) (CORE_ADDR));
144 
145 /* Delete a breakpoint. */
146 
147 int delete_breakpoint (struct breakpoint *bkpt);
148 
149 /* Set a reinsert breakpoint at STOP_AT. */
150 
151 void set_reinsert_breakpoint (CORE_ADDR stop_at);
152 
153 /* Delete all reinsert breakpoints. */
154 
155 void delete_reinsert_breakpoints (void);
156 
157 /* Reinsert breakpoints at WHERE (and change their status to
158  inserted). */
159 
161 
162 /* Uninsert breakpoints at WHERE (and change their status to
163  uninserted). This still leaves the breakpoints in the table. */
164 
166 
167 /* Reinsert all breakpoints of the current process (and change their
168  status to inserted). */
169 
170 void reinsert_all_breakpoints (void);
171 
172 /* Uninsert all breakpoints of the current process (and change their
173  status to uninserted). This still leaves the breakpoints in the
174  table. */
175 
176 void uninsert_all_breakpoints (void);
177 
178 /* See if any breakpoint claims ownership of STOP_PC. Call the handler for
179  the breakpoint, if found. */
180 
181 void check_breakpoints (CORE_ADDR stop_pc);
182 
183 /* See if any breakpoints shadow the target memory area from MEM_ADDR
184  to MEM_ADDR + MEM_LEN. Update the data already read from the target
185  (in BUF) if necessary. */
186 
187 void check_mem_read (CORE_ADDR mem_addr, unsigned char *buf, int mem_len);
188 
189 /* See if any breakpoints shadow the target memory area from MEM_ADDR
190  to MEM_ADDR + MEM_LEN. Update the data to be written to the target
191  (in BUF, a copy of MYADDR on entry) if necessary, as well as the
192  original data for any breakpoints. */
193 
194 void check_mem_write (CORE_ADDR mem_addr,
195  unsigned char *buf, const unsigned char *myaddr, int mem_len);
196 
197 /* Set the byte pattern to insert for memory breakpoints. This function
198  must be called before any breakpoints are set. */
199 
200 void set_breakpoint_data (const unsigned char *bp_data, int bp_len);
201 
202 /* Delete all breakpoints. */
203 
204 void delete_all_breakpoints (void);
205 
206 /* Clear the "inserted" flag in all breakpoints of PROC. */
207 
208 void mark_breakpoints_out (struct process_info *proc);
209 
210 /* Delete all breakpoints, but do not try to un-insert them from the
211  inferior. */
212 
213 void free_all_breakpoints (struct process_info *proc);
214 
215 /* Check if breakpoints still seem to be inserted in the inferior. */
216 
217 void validate_breakpoints (void);
218 
219 /* Insert a fast tracepoint jump at WHERE, using instruction INSN, of
220  LENGTH bytes. */
221 
223  unsigned char *insn,
224  ULONGEST length);
225 
226 /* Increment reference counter of JP. */
228 
229 /* Delete fast tracepoint jump TODEL from our tables, and uninsert if
230  from memory. */
231 
233 
234 /* Returns true if there's fast tracepoint jump set at WHERE. */
235 
237 
238 /* Uninsert fast tracepoint jumps at WHERE (and change their status to
239  uninserted). This still leaves the tracepoints in the table. */
240 
242 
243 /* Reinsert fast tracepoint jumps at WHERE (and change their status to
244  inserted). */
245 
247 
248 /* Insert a memory breakpoint. */
249 
251 
252 /* Remove a previously inserted memory breakpoint. */
253 
255 
256 /* Create a new breakpoint list NEW_BKPT_LIST that is a copy of SRC. */
257 
258 void clone_all_breakpoints (struct breakpoint **new_bkpt_list,
259  struct raw_breakpoint **new_raw_bkpt_list,
260  const struct breakpoint *src);
261 
262 #endif /* MEM_BREAK_H */
int hardware_breakpoint_inserted_here(CORE_ADDR addr)
Definition: mem-break.c:1649
void uninsert_breakpoints_at(CORE_ADDR where)
Definition: mem-break.c:1454
int gdb_no_commands_at_breakpoint(CORE_ADDR where)
Definition: mem-break.c:1332
void delete_reinsert_breakpoints(void)
Definition: mem-break.c:1402
int fast_tracepoint_jump_here(CORE_ADDR)
Definition: mem-break.c:492
bfd_vma CORE_ADDR
Definition: common-types.h:41
int gdb_breakpoint_here(CORE_ADDR where)
Definition: mem-break.c:1385
int delete_fast_tracepoint_jump(struct fast_tracepoint_jump *todel)
Definition: mem-break.c:500
int breakpoint_inserted_here(CORE_ADDR addr)
Definition: mem-break.c:1614
void reinsert_all_breakpoints(void)
Definition: mem-break.c:1540
void clear_breakpoint_conditions_and_commands(struct breakpoint *bp)
Definition: mem-break.c:1157
enum raw_bkpt_type Z_packet_to_raw_bkpt_type(char z_type)
Definition: mem-break.c:226
int any_persistent_commands(void)
Definition: mem-break.c:246
struct breakpoint * set_breakpoint_at(CORE_ADDR where, int(*handler)(CORE_ADDR))
Definition: mem-break.c:773
int breakpoint_here(CORE_ADDR addr)
Definition: mem-break.c:1599
int delete_breakpoint(struct breakpoint *bkpt)
Definition: mem-break.c:888
void free_all_breakpoints(struct process_info *proc)
Definition: mem-break.c:1921
raw_bkpt_type
Definition: mem-break.h:40
int delete_gdb_breakpoint(char z_type, CORE_ADDR addr, int size)
Definition: mem-break.c:1080
void reinsert_breakpoints_at(CORE_ADDR where)
Definition: mem-break.c:1512
struct fast_tracepoint_jump * set_fast_tracepoint_jump(CORE_ADDR where, unsigned char *insn, ULONGEST length)
Definition: mem-break.c:568
enum target_hw_bp_type raw_bkpt_type_to_target_hw_bp_type(enum raw_bkpt_type raw_type)
Definition: mem-break.c:195
void delete_all_breakpoints(void)
Definition: mem-break.c:1898
void set_reinsert_breakpoint(CORE_ADDR stop_at)
Definition: mem-break.c:1393
void check_mem_write(CORE_ADDR mem_addr, unsigned char *buf, const unsigned char *myaddr, int mem_len)
Definition: mem-break.c:1806
struct breakpoint * set_gdb_breakpoint(char z_type, CORE_ADDR addr, int size, int *err)
Definition: mem-break.c:1027
int gdb_condition_true_at_breakpoint(CORE_ADDR where)
Definition: mem-break.c:1254
void reinsert_fast_tracepoint_jumps_at(CORE_ADDR where)
Definition: mem-break.c:689
void check_breakpoints(CORE_ADDR stop_pc)
Definition: mem-break.c:1553
void mark_breakpoints_out(struct process_info *proc)
Definition: mem-break.c:1909
int insert_memory_breakpoint(struct raw_breakpoint *bp)
Definition: mem-break.c:299
void run_breakpoint_commands(CORE_ADDR where)
Definition: mem-break.c:1374
void check_mem_read(CORE_ADDR mem_addr, unsigned char *buf, int mem_len)
Definition: mem-break.c:1723
void clone_all_breakpoints(struct breakpoint **new_bkpt_list, struct raw_breakpoint **new_raw_bkpt_list, const struct breakpoint *src)
Definition: mem-break.c:2003
void uninsert_fast_tracepoint_jumps_at(CORE_ADDR pc)
Definition: mem-break.c:641
int add_breakpoint_commands(struct breakpoint *bp, char **commands, int persist)
Definition: mem-break.c:1282
void uninsert_all_breakpoints(void)
Definition: mem-break.c:1483
int remove_memory_breakpoint(struct raw_breakpoint *bp)
Definition: mem-break.c:348
target_hw_bp_type
Definition: break-common.h:22
void validate_breakpoints(void)
Definition: mem-break.c:1706
unsigned long long ULONGEST
Definition: common-types.h:53
void inc_ref_fast_tracepoint_jump(struct fast_tracepoint_jump *jp)
Definition: mem-break.c:562
void set_breakpoint_data(const unsigned char *bp_data, int bp_len)
Definition: mem-break.c:1592
int add_breakpoint_condition(struct breakpoint *bp, char **condition)
Definition: mem-break.c:1183
int(* handler)(CORE_ADDR)
Definition: mem-break.c:189
int software_breakpoint_inserted_here(CORE_ADDR addr)
Definition: mem-break.c:1632