]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/breakpoint.h
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / breakpoint.h
CommitLineData
c906108c 1/* Data structures associated with breakpoints in GDB.
213516ef 2 Copyright (C) 1992-2023 Free Software Foundation, Inc.
c906108c 3
c5aa993b 4 This file is part of GDB.
c906108c 5
c5aa993b
JM
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
a9762ec7 8 the Free Software Foundation; either version 3 of the License, or
c5aa993b 9 (at your option) any later version.
c906108c 10
c5aa993b
JM
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
c906108c 15
c5aa993b 16 You should have received a copy of the GNU General Public License
a9762ec7 17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
c906108c
SS
18
19#if !defined (BREAKPOINT_H)
20#define BREAKPOINT_H 1
21
4de283e4
TT
22#include "frame.h"
23#include "value.h"
b775012e 24#include "ax.h"
625e8578 25#include "command.h"
268a13a5 26#include "gdbsupport/break-common.h"
d55e5aa6 27#include "probe.h"
4de283e4
TT
28#include "location.h"
29#include <vector>
268a13a5 30#include "gdbsupport/array-view.h"
f6d17b2b 31#include "gdbsupport/filtered-iterator.h"
95da600f 32#include "gdbsupport/function-view.h"
9be25986
SM
33#include "gdbsupport/next-iterator.h"
34#include "gdbsupport/iterator-range.h"
b6433ede 35#include "gdbsupport/refcounted-object.h"
240edef6 36#include "gdbsupport/safe-iterator.h"
4de283e4 37#include "cli/cli-script.h"
403c71fd 38#include "target/waitstatus.h"
c906108c 39
fe898f56 40struct block;
4cb0213d 41struct gdbpy_breakpoint_object;
ed3ef339 42struct gdbscm_breakpoint_object;
bfd28288 43struct number_or_range_parser;
619cebe8 44struct thread_info;
313f3b21 45struct bpstat;
28010a5d 46struct bp_location;
983af33b
SDJ
47struct linespec_result;
48struct linespec_sals;
00431a78 49struct inferior;
278cd55f 50
30056ea0
AB
51/* Enum for exception-handling support in 'catch throw', 'catch rethrow',
52 'catch catch' and the MI equivalent. */
53
54enum exception_event_kind
55{
56 EX_EVENT_THROW,
57 EX_EVENT_RETHROW,
58 EX_EVENT_CATCH
59};
60
73971819
PA
61/* Why are we removing the breakpoint from the target? */
62
63enum remove_bp_reason
64{
65 /* A regular remove. Remove the breakpoint and forget everything
66 about it. */
67 REMOVE_BREAKPOINT,
68
69 /* Detach the breakpoints from a fork child. */
70 DETACH_BREAKPOINT,
71};
72
0e2de366
MS
73/* This is the maximum number of bytes a breakpoint instruction can
74 take. Feel free to increase it. It's just used in a few places to
75 size arrays that should be independent of the target
76 architecture. */
c906108c
SS
77
78#define BREAKPOINT_MAX 16
79\f
a96d9b2e
SDJ
80
81/* Type of breakpoint. */
c5aa993b
JM
82
83enum bptype
84 {
0e2de366 85 bp_none = 0, /* Eventpoint has been deleted */
c5aa993b
JM
86 bp_breakpoint, /* Normal breakpoint */
87 bp_hardware_breakpoint, /* Hardware assisted breakpoint */
7c16b83e 88 bp_single_step, /* Software single-step */
c5aa993b
JM
89 bp_until, /* used by until command */
90 bp_finish, /* used by finish command */
91 bp_watchpoint, /* Watchpoint */
92 bp_hardware_watchpoint, /* Hardware assisted watchpoint */
93 bp_read_watchpoint, /* read watchpoint, (hardware assisted) */
94 bp_access_watchpoint, /* access watchpoint, (hardware assisted) */
95 bp_longjmp, /* secret breakpoint to find longjmp() */
96 bp_longjmp_resume, /* secret breakpoint to escape longjmp() */
97
e2e4d78b
JK
98 /* Breakpoint placed to the same location(s) like bp_longjmp but used to
99 protect against stale DUMMY_FRAME. Multiple bp_longjmp_call_dummy and
100 one bp_call_dummy are chained together by related_breakpoint for each
101 DUMMY_FRAME. */
102 bp_longjmp_call_dummy,
103
186c406b
TT
104 /* An internal breakpoint that is installed on the unwinder's
105 debug hook. */
106 bp_exception,
107 /* An internal breakpoint that is set at the point where an
108 exception will land. */
109 bp_exception_resume,
110
0e2de366 111 /* Used by wait_for_inferior for stepping over subroutine calls,
2c03e5be 112 and for skipping prologues. */
c5aa993b
JM
113 bp_step_resume,
114
2c03e5be
PA
115 /* Used by wait_for_inferior for stepping over signal
116 handlers. */
117 bp_hp_step_resume,
118
c5aa993b
JM
119 /* Used to detect when a watchpoint expression has gone out of
120 scope. These breakpoints are usually not visible to the user.
121
122 This breakpoint has some interesting properties:
c906108c
SS
123
124 1) There's always a 1:1 mapping between watchpoints
125 on local variables and watchpoint_scope breakpoints.
126
127 2) It automatically deletes itself and the watchpoint it's
128 associated with when hit.
129
130 3) It can never be disabled. */
c5aa993b
JM
131 bp_watchpoint_scope,
132
e2e4d78b
JK
133 /* The breakpoint at the end of a call dummy. See bp_longjmp_call_dummy it
134 is chained with by related_breakpoint. */
c5aa993b
JM
135 bp_call_dummy,
136
aa7d318d
TT
137 /* A breakpoint set on std::terminate, that is used to catch
138 otherwise uncaught exceptions thrown during an inferior call. */
139 bp_std_terminate,
140
c5aa993b
JM
141 /* Some dynamic linkers (HP, maybe Solaris) can arrange for special
142 code in the inferior to run when significant events occur in the
143 dynamic linker (for example a library is loaded or unloaded).
144
145 By placing a breakpoint in this magic code GDB will get control
146 when these significant events occur. GDB can then re-examine
147 the dynamic linker's data structures to discover any newly loaded
148 dynamic libraries. */
149 bp_shlib_event,
150
c4093a6a
JM
151 /* Some multi-threaded systems can arrange for a location in the
152 inferior to be executed when certain thread-related events occur
153 (such as thread creation or thread death).
154
155 By placing a breakpoint at one of these locations, GDB will get
156 control when these events occur. GDB can then update its thread
157 lists etc. */
158
159 bp_thread_event,
160
1900040c
MS
161 /* On the same principal, an overlay manager can arrange to call a
162 magic location in the inferior whenever there is an interesting
163 change in overlay status. GDB can update its overlay tables
164 and fiddle with breakpoints in overlays when this breakpoint
165 is hit. */
166
167 bp_overlay_event,
168
0fd8e87f
UW
169 /* Master copies of longjmp breakpoints. These are always installed
170 as soon as an objfile containing longjmp is loaded, but they are
171 always disabled. While necessary, temporary clones of bp_longjmp
172 type will be created and enabled. */
173
174 bp_longjmp_master,
175
aa7d318d
TT
176 /* Master copies of std::terminate breakpoints. */
177 bp_std_terminate_master,
178
186c406b
TT
179 /* Like bp_longjmp_master, but for exceptions. */
180 bp_exception_master,
181
ce78b96d 182 bp_catchpoint,
1042e4c0
SS
183
184 bp_tracepoint,
7a697b8d 185 bp_fast_tracepoint,
0fb4aa4b 186 bp_static_tracepoint,
7b572efb
TT
187 /* Like bp_static_tracepoint but for static markers. */
188 bp_static_marker_tracepoint,
4efc6507 189
e7e0cddf
SS
190 /* A dynamic printf stops at the given location, does a formatted
191 print, then automatically continues. (Although this is sort of
192 like a macro packaging up standard breakpoint functionality,
193 GDB doesn't have a way to construct types of breakpoint from
194 elements of behavior.) */
195 bp_dprintf,
196
4efc6507
DE
197 /* Event for JIT compiled code generation or deletion. */
198 bp_jit_event,
0e30163f
JK
199
200 /* Breakpoint is placed at the STT_GNU_IFUNC resolver. When hit GDB
201 inserts new bp_gnu_ifunc_resolver_return at the caller.
202 bp_gnu_ifunc_resolver is still being kept here as a different thread
203 may still hit it before bp_gnu_ifunc_resolver_return is hit by the
204 original thread. */
205 bp_gnu_ifunc_resolver,
206
207 /* On its hit GDB now know the resolved address of the target
208 STT_GNU_IFUNC function. Associated bp_gnu_ifunc_resolver can be
209 deleted now and the breakpoint moved to the target function entry
210 point. */
211 bp_gnu_ifunc_resolver_return,
c5aa993b 212 };
c906108c 213
0e2de366 214/* States of enablement of breakpoint. */
c906108c 215
b5de0fa7 216enum enable_state
c5aa993b 217 {
0e2de366
MS
218 bp_disabled, /* The eventpoint is inactive, and cannot
219 trigger. */
220 bp_enabled, /* The eventpoint is active, and can
221 trigger. */
222 bp_call_disabled, /* The eventpoint has been disabled while a
223 call into the inferior is "in flight",
224 because some eventpoints interfere with
225 the implementation of a call on some
226 targets. The eventpoint will be
227 automatically enabled and reset when the
228 call "lands" (either completes, or stops
229 at another eventpoint). */
c5aa993b 230 };
c906108c
SS
231
232
0e2de366 233/* Disposition of breakpoint. Ie: what to do after hitting it. */
c906108c 234
c5aa993b
JM
235enum bpdisp
236 {
b5de0fa7 237 disp_del, /* Delete it */
0e2de366
MS
238 disp_del_at_next_stop, /* Delete at next stop,
239 whether hit or not */
b5de0fa7
EZ
240 disp_disable, /* Disable it */
241 disp_donttouch /* Leave it alone */
c5aa993b 242 };
c906108c 243
b775012e
LM
244/* Status of breakpoint conditions used when synchronizing
245 conditions with the target. */
246
247enum condition_status
248 {
249 condition_unchanged = 0,
250 condition_modified,
251 condition_updated
252 };
253
8181d85f
DJ
254/* Information used by targets to insert and remove breakpoints. */
255
256struct bp_target_info
257{
6c95b8df
PA
258 /* Address space at which the breakpoint was placed. */
259 struct address_space *placed_address_space;
260
0d5ed153
MR
261 /* Address at which the breakpoint was placed. This is normally
262 the same as REQUESTED_ADDRESS, except when adjustment happens in
263 gdbarch_breakpoint_from_pc. The most common form of adjustment
264 is stripping an alternate ISA marker from the PC which is used
265 to determine the type of breakpoint to insert. */
8181d85f
DJ
266 CORE_ADDR placed_address;
267
0d5ed153
MR
268 /* Address at which the breakpoint was requested. */
269 CORE_ADDR reqstd_address;
270
f1310107
TJB
271 /* If this is a ranged breakpoint, then this field contains the
272 length of the range that will be watched for execution. */
273 int length;
274
8181d85f
DJ
275 /* If the breakpoint lives in memory and reading that memory would
276 give back the breakpoint, instead of the original contents, then
277 the original contents are cached here. Only SHADOW_LEN bytes of
278 this buffer are valid, and only when the breakpoint is inserted. */
279 gdb_byte shadow_contents[BREAKPOINT_MAX];
280
281 /* The length of the data cached in SHADOW_CONTENTS. */
282 int shadow_len;
283
579c6ad9
YQ
284 /* The breakpoint's kind. It is used in 'kind' parameter in Z
285 packets. */
286 int kind;
b775012e 287
3cde5c42
PA
288 /* Conditions the target should evaluate if it supports target-side
289 breakpoint conditions. These are non-owning pointers. */
290 std::vector<agent_expr *> conditions;
d3ce09f5 291
3cde5c42
PA
292 /* Commands the target should evaluate if it supports target-side
293 breakpoint commands. These are non-owning pointers. */
294 std::vector<agent_expr *> tcommands;
d3ce09f5
SS
295
296 /* Flag that is true if the breakpoint should be left in place even
297 when GDB is not connected. */
298 int persist;
8181d85f
DJ
299};
300
5cab636d
DJ
301/* GDB maintains two types of information about each breakpoint (or
302 watchpoint, or other related event). The first type corresponds
303 to struct breakpoint; this is a relatively high-level structure
304 which contains the source location(s), stopping conditions, user
305 commands to execute when the breakpoint is hit, and so forth.
306
307 The second type of information corresponds to struct bp_location.
308 Each breakpoint has one or (eventually) more locations associated
309 with it, which represent target-specific and machine-specific
310 mechanisms for stopping the program. For instance, a watchpoint
311 expression may require multiple hardware watchpoints in order to
312 catch all changes in the value of the expression being watched. */
313
314enum bp_loc_type
315{
316 bp_loc_software_breakpoint,
317 bp_loc_hardware_breakpoint,
6e14e441 318 bp_loc_software_watchpoint,
5cab636d
DJ
319 bp_loc_hardware_watchpoint,
320 bp_loc_other /* Miscellaneous... */
321};
322
b6433ede 323class bp_location : public refcounted_object
5cab636d 324{
5625a286
PA
325public:
326 bp_location () = default;
327
cb1e4e32
PA
328 /* Construct a bp_location with the type inferred from OWNER's
329 type. */
330 explicit bp_location (breakpoint *owner);
331
332 /* Construct a bp_location with type TYPE. */
333 bp_location (breakpoint *owner, bp_loc_type type);
5f486660 334
23d6ee64 335 virtual ~bp_location () = default;
5625a286 336
0d381245
VP
337 /* Chain pointer to the next breakpoint location for
338 the same parent breakpoint. */
5625a286 339 bp_location *next = NULL;
7cc221ef 340
5cab636d 341 /* Type of this breakpoint location. */
5625a286 342 bp_loc_type loc_type {};
5cab636d
DJ
343
344 /* Each breakpoint location must belong to exactly one higher-level
f431efe5
PA
345 breakpoint. This pointer is NULL iff this bp_location is no
346 longer attached to a breakpoint. For example, when a breakpoint
347 is deleted, its locations may still be found in the
348 moribund_locations list, or if we had stopped for it, in
349 bpstats. */
5625a286 350 breakpoint *owner = NULL;
5cab636d 351
60e1c644
PA
352 /* Conditional. Break only if this expression's value is nonzero.
353 Unlike string form of condition, which is associated with
354 breakpoint, this is associated with location, since if breakpoint
355 has several locations, the evaluation of expression can be
356 different for different locations. Only valid for real
357 breakpoints; a watchpoint's conditional expression is stored in
358 the owner breakpoint object. */
4d01a485 359 expression_up cond;
0d381245 360
b775012e
LM
361 /* Conditional expression in agent expression
362 bytecode form. This is used for stub-side breakpoint
363 condition evaluation. */
833177a4 364 agent_expr_up cond_bytecode;
b775012e
LM
365
366 /* Signals that the condition has changed since the last time
367 we updated the global location list. This means the condition
368 needs to be sent to the target again. This is used together
369 with target-side breakpoint conditions.
370
371 condition_unchanged: It means there has been no condition changes.
372
373 condition_modified: It means this location had its condition modified.
374
375 condition_updated: It means we already marked all the locations that are
376 duplicates of this location and thus we don't need to call
377 force_breakpoint_reinsertion (...) for this location. */
378
5625a286 379 condition_status condition_changed {};
b775012e 380
833177a4 381 agent_expr_up cmd_bytecode;
d3ce09f5
SS
382
383 /* Signals that breakpoint conditions and/or commands need to be
30baf67b 384 re-synced with the target. This has no use other than
d3ce09f5 385 target-side breakpoints. */
5625a286 386 bool needs_update = false;
b775012e 387
0d381245
VP
388 /* This location's address is in an unloaded solib, and so this
389 location should not be inserted. It will be automatically
390 enabled when that solib is loaded. */
5625a286 391 bool shlib_disabled = false;
0d381245
VP
392
393 /* Is this particular location enabled. */
5625a286 394 bool enabled = false;
511a6cd4 395
b5fa468f
TBA
396 /* Is this particular location disabled because the condition
397 expression is invalid at this location. For a location to be
398 reported as enabled, the ENABLED field above has to be true *and*
399 the DISABLED_BY_COND field has to be false. */
400 bool disabled_by_cond = false;
401
9252448b 402 /* True if this breakpoint is now inserted. */
5625a286 403 bool inserted = false;
5cab636d 404
9252448b 405 /* True if this is a permanent breakpoint. There is a breakpoint
1a853c52
PA
406 instruction hard-wired into the target's code. Don't try to
407 write another breakpoint instruction on top of it, or restore its
408 value. Step over it using the architecture's
409 gdbarch_skip_permanent_breakpoint method. */
5625a286 410 bool permanent = false;
1a853c52 411
9252448b 412 /* True if this is not the first breakpoint in the list
1e4d1764
YQ
413 for the given address. location of tracepoint can _never_
414 be duplicated with other locations of tracepoints and other
415 kinds of breakpoints, because two locations at the same
416 address may have different actions, so both of these locations
417 should be downloaded and so that `tfind N' always works. */
5625a286 418 bool duplicate = false;
5cab636d
DJ
419
420 /* If we someday support real thread-specific breakpoints, then
421 the breakpoint location will need a thread identifier. */
422
423 /* Data for specific breakpoint types. These could be a union, but
424 simplicity is more important than memory usage for breakpoints. */
425
a6d9a66e
UW
426 /* Architecture associated with this location's address. May be
427 different from the breakpoint architecture. */
5625a286 428 struct gdbarch *gdbarch = NULL;
a6d9a66e 429
6c95b8df
PA
430 /* The program space associated with this breakpoint location
431 address. Note that an address space may be represented in more
432 than one program space (e.g. each uClinux program will be given
433 its own program space, but there will only be one address space
434 for all of them), but we must not insert more than one location
435 at the same address in the same address space. */
5625a286 436 program_space *pspace = NULL;
6c95b8df 437
5cab636d
DJ
438 /* Note that zero is a perfectly valid code address on some platforms
439 (for example, the mn10200 (OBSOLETE) and mn10300 simulators). NULL
440 is not a special value for this field. Valid for all types except
441 bp_loc_other. */
5625a286 442 CORE_ADDR address = 0;
5cab636d 443
a3be7890 444 /* For hardware watchpoints, the size of the memory region being
f1310107
TJB
445 watched. For hardware ranged breakpoints, the size of the
446 breakpoint range. */
5625a286 447 int length = 0;
a5606eee 448
0e2de366 449 /* Type of hardware watchpoint. */
5625a286 450 target_hw_bp_type watchpoint_type {};
a5606eee 451
714835d5 452 /* For any breakpoint type with an address, this is the section
0e2de366
MS
453 associated with the address. Used primarily for overlay
454 debugging. */
5625a286 455 obj_section *section = NULL;
cf3a9e5b 456
5cab636d
DJ
457 /* Address at which breakpoint was requested, either by the user or
458 by GDB for internal breakpoints. This will usually be the same
459 as ``address'' (above) except for cases in which
460 ADJUST_BREAKPOINT_ADDRESS has computed a different address at
461 which to place the breakpoint in order to comply with a
462 processor's architectual constraints. */
5625a286 463 CORE_ADDR requested_address = 0;
8181d85f 464
6a3a010b
MR
465 /* An additional address assigned with this location. This is currently
466 only used by STT_GNU_IFUNC resolver breakpoints to hold the address
467 of the resolver function. */
5625a286 468 CORE_ADDR related_address = 0;
6a3a010b 469
55aa24fb
SDJ
470 /* If the location comes from a probe point, this is the probe associated
471 with it. */
5625a286 472 bound_probe probe {};
55aa24fb 473
23d6ee64 474 gdb::unique_xmalloc_ptr<char> function_name;
0d381245 475
8181d85f 476 /* Details of the placed breakpoint, when inserted. */
5625a286 477 bp_target_info target_info {};
8181d85f
DJ
478
479 /* Similarly, for the breakpoint at an overlay's LMA, if necessary. */
5625a286 480 bp_target_info overlay_target_info {};
20874c92
VP
481
482 /* In a non-stop mode, it's possible that we delete a breakpoint,
483 but as we do that, some still running thread hits that breakpoint.
484 For that reason, we need to keep locations belonging to deleted
485 breakpoints for a bit, so that don't report unexpected SIGTRAP.
486 We can't keep such locations forever, so we use a heuristic --
487 after we process certain number of inferior events since
488 breakpoint was deleted, we retire all locations of that breakpoint.
489 This variable keeps a number of events still to go, when
490 it becomes 0 this location is retired. */
5625a286 491 int events_till_retirement = 0;
f8eba3c6 492
2f202fde
JK
493 /* Line number which was used to place this location.
494
495 Breakpoint placed into a comment keeps it's user specified line number
496 despite ADDRESS resolves into a different line number. */
f8eba3c6 497
5625a286 498 int line_number = 0;
f8eba3c6 499
2f202fde
JK
500 /* Symtab which was used to place this location. This is used
501 to find the corresponding source file name. */
f8eba3c6 502
5625a286 503 struct symtab *symtab = NULL;
4a27f119
KS
504
505 /* The symbol found by the location parser, if any. This may be used to
264f9890 506 ascertain when a location spec was set at a different location than
4a27f119
KS
507 the one originally selected by parsing, e.g., inlined symbols. */
508 const struct symbol *symbol = NULL;
3467ec66
PA
509
510 /* Similarly, the minimal symbol found by the location parser, if
511 any. This may be used to ascertain if the location was
512 originally set on a GNU ifunc symbol. */
513 const minimal_symbol *msymbol = NULL;
514
515 /* The objfile the symbol or minimal symbol were found in. */
516 const struct objfile *objfile = NULL;
5cab636d
DJ
517};
518
b6433ede
TT
519/* A policy class for bp_location reference counting. */
520struct bp_location_ref_policy
521{
522 static void incref (bp_location *loc)
523 {
524 loc->incref ();
525 }
526
527 static void decref (bp_location *loc)
528 {
529 gdb_assert (loc->refcount () > 0);
530 loc->decref ();
531 if (loc->refcount () == 0)
532 delete loc;
533 }
534};
535
536/* A gdb::ref_ptr that has been specialized for bp_location. */
537typedef gdb::ref_ptr<bp_location, bp_location_ref_policy>
538 bp_location_ref_ptr;
539
64166036
PA
540/* The possible return values for print_bpstat, print_it_normal,
541 print_it_done, print_it_noop. */
542enum print_stop_action
543{
544 /* We printed nothing or we need to do some more analysis. */
545 PRINT_UNKNOWN = -1,
546
547 /* We printed something, and we *do* desire that something to be
548 followed by a location. */
549 PRINT_SRC_AND_LOC,
550
551 /* We printed something, and we do *not* desire that something to be
552 followed by a location. */
553 PRINT_SRC_ONLY,
554
555 /* We already printed all we needed to print, don't print anything
556 else. */
557 PRINT_NOTHING
558};
559
3086aeae
DJ
560/* This structure is a collection of function pointers that, if available,
561 will be called instead of the performing the default action for this
562 bptype. */
563
77b06cd7 564struct breakpoint_ops
3086aeae 565{
264f9890
PA
566 /* Create SALs from location spec, storing the result in
567 linespec_result.
983af33b
SDJ
568
569 For an explanation about the arguments, see the function
264f9890 570 `create_sals_from_location_spec_default'.
983af33b
SDJ
571
572 This function is called inside `create_breakpoint'. */
264f9890
PA
573 void (*create_sals_from_location_spec) (location_spec *locspec,
574 struct linespec_result *canonical);
983af33b
SDJ
575
576 /* This method will be responsible for creating a breakpoint given its SALs.
577 Usually, it just calls `create_breakpoints_sal' (for ordinary
578 breakpoints). However, there may be some special cases where we might
579 need to do some tweaks, e.g., see
580 `strace_marker_create_breakpoints_sal'.
581
582 This function is called inside `create_breakpoint'. */
583 void (*create_breakpoints_sal) (struct gdbarch *,
584 struct linespec_result *,
e1e01040
PA
585 gdb::unique_xmalloc_ptr<char>,
586 gdb::unique_xmalloc_ptr<char>,
983af33b 587 enum bptype, enum bpdisp, int, int,
ef4848c7 588 int, int, int, int, unsigned);
3086aeae
DJ
589};
590
d983da9c
DJ
591enum watchpoint_triggered
592{
593 /* This watchpoint definitely did not trigger. */
594 watch_triggered_no = 0,
595
596 /* Some hardware watchpoint triggered, and it might have been this
597 one, but we do not know which it was. */
598 watch_triggered_unknown,
599
600 /* This hardware watchpoint definitely did trigger. */
601 watch_triggered_yes
602};
603
e09342b5
TJB
604/* Some targets (e.g., embedded PowerPC) need two debug registers to set
605 a watchpoint over a memory region. If this flag is true, GDB will use
30baf67b 606 only one register per watchpoint, thus assuming that all accesses that
e09342b5
TJB
607 modify a memory location happen at its starting address. */
608
491144b5 609extern bool target_exact_watchpoints;
e09342b5 610
40cb8ca5
SM
611/* bp_location linked list range. */
612
9be25986 613using bp_location_range = next_range<bp_location>;
40cb8ca5 614
c906108c
SS
615/* Note that the ->silent field is not currently used by any commands
616 (though the code is in there if it was to be, and set_raw_breakpoint
617 does set it to 0). I implemented it because I thought it would be
618 useful for a hack I had to put in; I'm going to leave it in because
619 I can see how there might be times when it would indeed be useful */
620
9a71ed14 621/* Abstract base class representing all kinds of breakpoints. */
c906108c
SS
622
623struct breakpoint
bfb8cf90 624{
92bb0228
PA
625 breakpoint (struct gdbarch *gdbarch_, enum bptype bptype,
626 bool temp = true, const char *cond_string = nullptr);
73063f51 627
3101e4a1
TT
628 DISABLE_COPY_AND_ASSIGN (breakpoint);
629
1c2cbcf1 630 virtual ~breakpoint () = 0;
c1fc2657 631
4c6a92b1
TT
632 /* Allocate a location for this breakpoint. */
633 virtual struct bp_location *allocate_location ();
634
635 /* Reevaluate a breakpoint. This is necessary after symbols change
636 (e.g., an executable or DSO was loaded, or the inferior just
637 started). */
638 virtual void re_set ()
639 {
640 /* Nothing to re-set. */
641 }
642
643 /* Insert the breakpoint or watchpoint or activate the catchpoint.
644 Return 0 for success, 1 if the breakpoint, watchpoint or
645 catchpoint type is not supported, -1 for failure. */
646 virtual int insert_location (struct bp_location *);
647
648 /* Remove the breakpoint/catchpoint that was previously inserted
649 with the "insert" method above. Return 0 for success, 1 if the
650 breakpoint, watchpoint or catchpoint type is not supported,
651 -1 for failure. */
652 virtual int remove_location (struct bp_location *,
653 enum remove_bp_reason reason);
654
655 /* Return true if it the target has stopped due to hitting
656 breakpoint location BL. This function does not check if we
657 should stop, only if BL explains the stop. ASPACE is the address
658 space in which the event occurred, BP_ADDR is the address at
659 which the inferior stopped, and WS is the target_waitstatus
660 describing the event. */
661 virtual int breakpoint_hit (const struct bp_location *bl,
662 const address_space *aspace,
663 CORE_ADDR bp_addr,
664 const target_waitstatus &ws);
665
666 /* Check internal conditions of the breakpoint referred to by BS.
4ec2227a
TT
667 If we should not stop for this breakpoint, set BS->stop to
668 false. */
4c6a92b1
TT
669 virtual void check_status (struct bpstat *bs)
670 {
671 /* Always stop. */
672 }
673
674 /* Tell how many hardware resources (debug registers) are needed
675 for this breakpoint. If this function is not provided, then
676 the breakpoint or watchpoint needs one debug register. */
677 virtual int resources_needed (const struct bp_location *);
678
4c6a92b1
TT
679 /* The normal print routine for this breakpoint, called when we
680 hit it. */
7bd86313 681 virtual enum print_stop_action print_it (const bpstat *bs) const;
4c6a92b1
TT
682
683 /* Display information about this breakpoint, for "info
684 breakpoints". Returns false if this method should use the
685 default behavior. */
a67bcaba 686 virtual bool print_one (bp_location **) const
4c6a92b1
TT
687 {
688 return false;
689 }
690
691 /* Display extra information about this breakpoint, below the normal
692 breakpoint description in "info breakpoints".
693
694 In the example below, the "address range" line was printed
f7968895 695 by ranged_breakpoint::print_one_detail.
4c6a92b1
TT
696
697 (gdb) info breakpoints
698 Num Type Disp Enb Address What
699 2 hw breakpoint keep y in main at test-watch.c:70
700 address range: [0x10000458, 0x100004c7]
701
702 */
703 virtual void print_one_detail (struct ui_out *) const
704 {
705 /* Nothing. */
706 }
707
708 /* Display information about this breakpoint after setting it
709 (roughly speaking; this is called from "mention"). */
b713485d 710 virtual void print_mention () const;
4c6a92b1
TT
711
712 /* Print to FP the CLI command that recreates this breakpoint. */
4d1ae558 713 virtual void print_recreate (struct ui_file *fp) const;
4c6a92b1 714
4c6a92b1
TT
715 /* Return true if this breakpoint explains a signal. See
716 bpstat_explains_signal. */
a6860f3a 717 virtual bool explains_signal (enum gdb_signal)
4c6a92b1 718 {
a6860f3a 719 return true;
4c6a92b1
TT
720 }
721
722 /* Called after evaluating the breakpoint's condition,
723 and only if it evaluated true. */
724 virtual void after_condition_true (struct bpstat *bs)
725 {
726 /* Nothing to do. */
727 }
728
40cb8ca5 729 /* Return a range of this breakpoint's locations. */
a67bcaba 730 bp_location_range locations () const;
40cb8ca5 731
16c4d54a 732 breakpoint *next = NULL;
bfb8cf90 733 /* Type of breakpoint. */
16c4d54a 734 bptype type = bp_none;
bfb8cf90 735 /* Zero means disabled; remember the info but don't break here. */
16c4d54a 736 enum enable_state enable_state = bp_enabled;
bfb8cf90 737 /* What to do with this breakpoint after we hit it. */
16c4d54a 738 bpdisp disposition = disp_del;
bfb8cf90 739 /* Number assigned to distinguish breakpoints. */
16c4d54a 740 int number = 0;
bfb8cf90
PA
741
742 /* Location(s) associated with this high-level breakpoint. */
16c4d54a 743 bp_location *loc = NULL;
bfb8cf90 744
16c4d54a
PA
745 /* True means a silent breakpoint (don't print frame info if we stop
746 here). */
747 bool silent = false;
748 /* True means display ADDR_STRING to the user verbatim. */
749 bool display_canonical = false;
bfb8cf90
PA
750 /* Number of stops at this breakpoint that should be continued
751 automatically before really stopping. */
16c4d54a 752 int ignore_count = 0;
bfb8cf90
PA
753
754 /* Number of stops at this breakpoint before it will be
755 disabled. */
16c4d54a 756 int enable_count = 0;
bfb8cf90
PA
757
758 /* Chain of command lines to execute when this breakpoint is
759 hit. */
d1b0a7bf 760 counted_command_line commands;
bfb8cf90
PA
761 /* Stack depth (address of frame). If nonzero, break only if fp
762 equals this. */
16c4d54a 763 struct frame_id frame_id = null_frame_id;
bfb8cf90
PA
764
765 /* The program space used to set the breakpoint. This is only set
766 for breakpoints which are specific to a program space; for
767 non-thread-specific ordinary breakpoints this is NULL. */
16c4d54a 768 program_space *pspace = NULL;
bfb8cf90 769
264f9890
PA
770 /* The location specification we used to set the breakpoint. */
771 location_spec_up locspec;
bfb8cf90
PA
772
773 /* The filter that should be passed to decode_line_full when
c0e8dcd8
TT
774 re-setting this breakpoint. This may be NULL. */
775 gdb::unique_xmalloc_ptr<char> filter;
bfb8cf90 776
264f9890
PA
777 /* For a ranged breakpoint, the location specification we used to
778 find the end of the range. */
779 location_spec_up locspec_range_end;
bfb8cf90
PA
780
781 /* Architecture we used to set the breakpoint. */
73063f51 782 struct gdbarch *gdbarch;
bfb8cf90 783 /* Language we used to set the breakpoint. */
73063f51 784 enum language language;
bfb8cf90 785 /* Input radix we used to set the breakpoint. */
73063f51 786 int input_radix;
bfb8cf90
PA
787 /* String form of the breakpoint condition (malloc'd), or NULL if
788 there is no condition. */
6f781ee3 789 gdb::unique_xmalloc_ptr<char> cond_string;
bfb8cf90
PA
790
791 /* String form of extra parameters, or NULL if there are none.
fb81d016 792 Malloc'd. */
6f781ee3 793 gdb::unique_xmalloc_ptr<char> extra_string;
bfb8cf90
PA
794
795 /* Holds the address of the related watchpoint_scope breakpoint when
796 using watchpoints on local variables (might the concept of a
797 related breakpoint be useful elsewhere, if not just call it the
798 watchpoint_scope breakpoint or something like that. FIXME). */
73063f51 799 breakpoint *related_breakpoint;
bfb8cf90
PA
800
801 /* Thread number for thread-specific breakpoint, or -1 if don't
802 care. */
16c4d54a 803 int thread = -1;
bfb8cf90
PA
804
805 /* Ada task number for task-specific breakpoint, or 0 if don't
806 care. */
16c4d54a 807 int task = 0;
bfb8cf90
PA
808
809 /* Count of the number of times this breakpoint was taken, dumped
810 with the info, but not used for anything else. Useful for seeing
811 how many times you hit a break prior to the program aborting, so
812 you can back up to just before the abort. */
16c4d54a 813 int hit_count = 0;
bfb8cf90
PA
814
815 /* Is breakpoint's condition not yet parsed because we found no
816 location initially so had no context to parse the condition
817 in. */
16c4d54a 818 int condition_not_parsed = 0;
bfb8cf90
PA
819
820 /* With a Python scripting enabled GDB, store a reference to the
821 Python object that has been associated with this breakpoint.
822 This is always NULL for a GDB that is not script enabled. It can
823 sometimes be NULL for enabled GDBs as not all breakpoint types
824 are tracked by the scripting language API. */
16c4d54a 825 gdbpy_breakpoint_object *py_bp_object = NULL;
bfb8cf90
PA
826
827 /* Same as py_bp_object, but for Scheme. */
16c4d54a 828 gdbscm_breakpoint_object *scm_bp_object = NULL;
04d0163c
TT
829
830protected:
831
832 /* Helper for breakpoint_ops->print_recreate implementations. Prints
833 the "thread" or "task" condition of B, and then a newline.
834
835 Necessary because most breakpoint implementations accept
836 thread/task conditions at the end of the spec line, like "break foo
837 thread 1", which needs outputting before any breakpoint-type
838 specific extra command necessary for B's recreation. */
839 void print_recreate_thread (struct ui_file *fp) const;
bfb8cf90 840};
e09342b5 841
9a71ed14
PA
842/* Abstract base class representing code breakpoints. User "break"
843 breakpoints, internal and momentary breakpoints, etc. IOW, any
844 kind of breakpoint whose locations are created from SALs. */
74421c0b 845struct code_breakpoint : public breakpoint
098f1272 846{
73063f51
TT
847 using breakpoint::breakpoint;
848
3b003a61
PA
849 /* Create a breakpoint with SALS as locations. Use LOCATION as a
850 description of the location, and COND_STRING as condition
851 expression. If LOCATION is NULL then create an "address
852 location" from the address in the SAL. */
74421c0b 853 code_breakpoint (struct gdbarch *gdbarch, bptype type,
3b003a61 854 gdb::array_view<const symtab_and_line> sals,
264f9890 855 location_spec_up &&locspec,
3b003a61
PA
856 gdb::unique_xmalloc_ptr<char> filter,
857 gdb::unique_xmalloc_ptr<char> cond_string,
858 gdb::unique_xmalloc_ptr<char> extra_string,
859 enum bpdisp disposition,
860 int thread, int task, int ignore_count,
861 int from_tty,
862 int enabled, unsigned flags,
863 int display_canonical);
864
74421c0b 865 ~code_breakpoint () override = 0;
1c2cbcf1 866
960bc2bd
PA
867 /* Add a location for SAL to this breakpoint. */
868 bp_location *add_location (const symtab_and_line &sal);
869
2b5ab5b8
TT
870 void re_set () override;
871 int insert_location (struct bp_location *) override;
872 int remove_location (struct bp_location *,
873 enum remove_bp_reason reason) override;
874 int breakpoint_hit (const struct bp_location *bl,
875 const address_space *aspace,
876 CORE_ADDR bp_addr,
877 const target_waitstatus &ws) override;
b3d5660a
TT
878
879protected:
880
aef4b7a5
TT
881 /* Given the location spec, this method decodes it and returns the
882 SAL locations related to it. For ordinary breakpoints, it calls
883 `decode_line_full'. If SEARCH_PSPACE is not NULL, symbol search
884 is restricted to just that program space.
885
886 This function is called inside `location_spec_to_sals'. */
887 virtual std::vector<symtab_and_line> decode_location_spec
888 (location_spec *locspec,
889 struct program_space *search_pspace);
890
b3d5660a
TT
891 /* Helper method that does the basic work of re_set. */
892 void re_set_default ();
2c9a6d72
TT
893
894 /* Find the SaL locations corresponding to the given LOCATION.
895 On return, FOUND will be 1 if any SaL was found, zero otherwise. */
896
897 std::vector<symtab_and_line> location_spec_to_sals
898 (location_spec *locspec,
899 struct program_space *search_pspace,
900 int *found);
098f1272
TT
901};
902
9a71ed14
PA
903/* An instance of this type is used to represent a watchpoint,
904 a.k.a. a data breakpoint. */
9c06b0b4 905
c1fc2657 906struct watchpoint : public breakpoint
3a5c3e22 907{
73063f51
TT
908 using breakpoint::breakpoint;
909
3a292923
TT
910 void re_set () override;
911 int insert_location (struct bp_location *) override;
912 int remove_location (struct bp_location *,
913 enum remove_bp_reason reason) override;
914 int breakpoint_hit (const struct bp_location *bl,
915 const address_space *aspace,
916 CORE_ADDR bp_addr,
917 const target_waitstatus &ws) override;
918 void check_status (struct bpstat *bs) override;
919 int resources_needed (const struct bp_location *) override;
5a61e176
TT
920
921 /* Tell whether we can downgrade from a hardware watchpoint to a software
922 one. If not, the user will not be able to enable the watchpoint when
923 there are not enough hardware resources available. */
924 virtual bool works_in_software_mode () const;
925
7bd86313 926 enum print_stop_action print_it (const bpstat *bs) const override;
b713485d 927 void print_mention () const override;
4d1ae558 928 void print_recreate (struct ui_file *fp) const override;
a6860f3a 929 bool explains_signal (enum gdb_signal) override;
3a292923 930
3a5c3e22
PA
931 /* String form of exp to use for displaying to the user (malloc'd),
932 or NULL if none. */
a4c50be3 933 gdb::unique_xmalloc_ptr<char> exp_string;
3a5c3e22 934 /* String form to use for reparsing of EXP (malloc'd) or NULL. */
a4c50be3 935 gdb::unique_xmalloc_ptr<char> exp_string_reparse;
3a5c3e22
PA
936
937 /* The expression we are watching, or NULL if not a watchpoint. */
4d01a485 938 expression_up exp;
3a5c3e22
PA
939 /* The largest block within which it is valid, or NULL if it is
940 valid anywhere (e.g. consists just of global symbols). */
270140bd 941 const struct block *exp_valid_block;
3a5c3e22 942 /* The conditional expression if any. */
4d01a485 943 expression_up cond_exp;
3a5c3e22
PA
944 /* The largest block within which it is valid, or NULL if it is
945 valid anywhere (e.g. consists just of global symbols). */
270140bd 946 const struct block *cond_exp_valid_block;
3a5c3e22
PA
947 /* Value of the watchpoint the last time we checked it, or NULL when
948 we do not know the value yet or the value was not readable. VAL
949 is never lazy. */
850645cf 950 value_ref_ptr val;
4c1d86d9
SM
951
952 /* True if VAL is valid. If VAL_VALID is set but VAL is NULL,
3a5c3e22 953 then an error occurred reading the value. */
4c1d86d9 954 bool val_valid;
3a5c3e22 955
bb9d5f81
PP
956 /* When watching the location of a bitfield, contains the offset and size of
957 the bitfield. Otherwise contains 0. */
958 int val_bitpos;
959 int val_bitsize;
960
3a5c3e22
PA
961 /* Holds the frame address which identifies the frame this
962 watchpoint should be evaluated in, or `null' if the watchpoint
963 should be evaluated on the outermost frame. */
964 struct frame_id watchpoint_frame;
965
966 /* Holds the thread which identifies the frame this watchpoint
967 should be considered in scope for, or `null_ptid' if the
968 watchpoint should be evaluated in all threads. */
969 ptid_t watchpoint_thread;
970
971 /* For hardware watchpoints, the triggered status according to the
972 hardware. */
973 enum watchpoint_triggered watchpoint_triggered;
974
975 /* Whether this watchpoint is exact (see
976 target_exact_watchpoints). */
977 int exact;
978
979 /* The mask address for a masked hardware watchpoint. */
980 CORE_ADDR hw_wp_mask;
981};
982
b775012e
LM
983/* Return true if BPT is either a software breakpoint or a hardware
984 breakpoint. */
985
f2478a7e 986extern bool is_breakpoint (const struct breakpoint *bpt);
b775012e 987
f2478a7e
SM
988/* Return true if BPT is of any watchpoint kind, hardware or
989 software. */
3a5c3e22 990
f2478a7e 991extern bool is_watchpoint (const struct breakpoint *bpt);
d6e956e5 992
a38118e5
PA
993/* Return true if BPT is a C++ exception catchpoint (catch
994 catch/throw/rethrow). */
995
996extern bool is_exception_catchpoint (breakpoint *bp);
997
d9b3f62e 998/* An instance of this type is used to represent all kinds of
c1fc2657 999 tracepoints. */
d9b3f62e 1000
74421c0b 1001struct tracepoint : public code_breakpoint
d9b3f62e 1002{
74421c0b 1003 using code_breakpoint::code_breakpoint;
73063f51 1004
779dcceb
TT
1005 int breakpoint_hit (const struct bp_location *bl,
1006 const address_space *aspace, CORE_ADDR bp_addr,
1007 const target_waitstatus &ws) override;
1008 void print_one_detail (struct ui_out *uiout) const override;
b713485d 1009 void print_mention () const override;
4d1ae558 1010 void print_recreate (struct ui_file *fp) const override;
779dcceb 1011
d9b3f62e
PA
1012 /* Number of times this tracepoint should single-step and collect
1013 additional data. */
b68f26de 1014 long step_count = 0;
d9b3f62e
PA
1015
1016 /* Number of times this tracepoint should be hit before
1017 disabling/ending. */
b68f26de 1018 int pass_count = 0;
d9b3f62e
PA
1019
1020 /* The number of the tracepoint on the target. */
b68f26de 1021 int number_on_target = 0;
d9b3f62e 1022
f196051f
SS
1023 /* The total space taken by all the trace frames for this
1024 tracepoint. */
b68f26de 1025 ULONGEST traceframe_usage = 0;
f196051f 1026
d9b3f62e 1027 /* The static tracepoint marker id, if known. */
5d9310c4 1028 std::string static_trace_marker_id;
d9b3f62e
PA
1029
1030 /* LTTng/UST allow more than one marker with the same ID string,
1031 although it unadvised because it confuses tools. When setting
1032 static tracepoints by marker ID, this will record the index in
1033 the array of markers we found for the given marker ID for which
1034 this static tracepoint corresponds. When resetting breakpoints,
1035 we will use this index to try to find the same marker again. */
b68f26de 1036 int static_trace_marker_id_idx = 0;
d9b3f62e
PA
1037};
1038
9a71ed14 1039/* The abstract base class for catchpoints. */
fed1c982 1040
acd0955b 1041struct catchpoint : public breakpoint
fed1c982
TT
1042{
1043 /* If TEMP is true, then make the breakpoint temporary. If
1044 COND_STRING is not NULL, then store it in the breakpoint. */
1045 catchpoint (struct gdbarch *gdbarch, bool temp, const char *cond_string);
1046
1c2cbcf1 1047 ~catchpoint () override = 0;
fed1c982
TT
1048};
1049
c906108c 1050\f
53a5351d
JM
1051/* The following stuff is an abstract data type "bpstat" ("breakpoint
1052 status"). This provides the ability to determine whether we have
1053 stopped at a breakpoint, and what we should do about it. */
c906108c 1054
198757a8
VP
1055/* Clears a chain of bpstat, freeing storage
1056 of each. */
313f3b21 1057extern void bpstat_clear (bpstat **);
c906108c
SS
1058
1059/* Return a copy of a bpstat. Like "bs1 = bs2" but all storage that
1060 is part of the bpstat is copied as well. */
313f3b21 1061extern bpstat *bpstat_copy (bpstat *);
c906108c 1062
ddfe970e
KS
1063/* Build the (raw) bpstat chain for the stop information given by ASPACE,
1064 BP_ADDR, and WS. Returns the head of the bpstat chain. */
1065
313f3b21 1066extern bpstat *build_bpstat_chain (const address_space *aspace,
ddfe970e 1067 CORE_ADDR bp_addr,
c272a98c 1068 const target_waitstatus &ws);
ddfe970e
KS
1069
1070/* Get a bpstat associated with having just stopped at address
1071 BP_ADDR in thread PTID. STOP_CHAIN may be supplied as a previously
1072 computed stop chain or NULL, in which case the stop chain will be
1073 computed using build_bpstat_chain.
1074
1075 Determine whether we stopped at a breakpoint, etc, or whether we
1076 don't understand this stop. Result is a chain of bpstat's such
1077 that:
1078
1079 if we don't understand the stop, the result is a null pointer.
1080
1081 if we understand why we stopped, the result is not null.
1082
1083 Each element of the chain refers to a particular breakpoint or
1084 watchpoint at which we have stopped. (We may have stopped for
1085 several reasons concurrently.)
1086
1087 Each element of the chain has valid next, breakpoint_at,
d37e0847
PA
1088 commands, FIXME??? fields.
1089
1090 watchpoints_triggered must be called beforehand to set up each
1091 watchpoint's watchpoint_triggered value.
1092
1093*/
ddfe970e 1094
313f3b21 1095extern bpstat *bpstat_stop_status (const address_space *aspace,
00431a78 1096 CORE_ADDR pc, thread_info *thread,
c272a98c 1097 const target_waitstatus &ws,
313f3b21 1098 bpstat *stop_chain = nullptr);
d37e0847
PA
1099
1100/* Like bpstat_stop_status, but clears all watchpoints'
1101 watchpoint_triggered flag. Unlike with bpstat_stop_status, there's
1102 no need to call watchpoint_triggered beforehand. You'll typically
1103 use this variant when handling a known-non-watchpoint event, like a
1104 fork or exec event. */
1105
1106extern bpstat *bpstat_stop_status_nowatch (const address_space *aspace,
1107 CORE_ADDR bp_addr,
1108 thread_info *thread,
1109 const target_waitstatus &ws);
c906108c 1110\f
d37e0847
PA
1111
1112
c906108c 1113/* This bpstat_what stuff tells wait_for_inferior what to do with a
628fe4e4
JK
1114 breakpoint (a challenging task).
1115
1116 The enum values order defines priority-like order of the actions.
1117 Once you've decided that some action is appropriate, you'll never
1118 go back and decide something of a lower priority is better. Each
1119 of these actions is mutually exclusive with the others. That
1120 means, that if you find yourself adding a new action class here and
1121 wanting to tell GDB that you have two simultaneous actions to
1122 handle, something is wrong, and you probably don't actually need a
1123 new action type.
1124
1125 Note that a step resume breakpoint overrides another breakpoint of
1126 signal handling (see comment in wait_for_inferior at where we set
1127 the step_resume breakpoint). */
c906108c 1128
c5aa993b
JM
1129enum bpstat_what_main_action
1130 {
1131 /* Perform various other tests; that is, this bpstat does not
1132 say to perform any action (e.g. failed watchpoint and nothing
1133 else). */
1134 BPSTAT_WHAT_KEEP_CHECKING,
1135
c5aa993b 1136 /* Remove breakpoints, single step once, then put them back in and
0e2de366
MS
1137 go back to what we were doing. It's possible that this should
1138 be removed from the main_action and put into a separate field,
1139 to more cleanly handle
1140 BPSTAT_WHAT_CLEAR_LONGJMP_RESUME_SINGLE. */
c5aa993b
JM
1141 BPSTAT_WHAT_SINGLE,
1142
1143 /* Set longjmp_resume breakpoint, remove all other breakpoints,
0e2de366
MS
1144 and continue. The "remove all other breakpoints" part is
1145 required if we are also stepping over another breakpoint as
1146 well as doing the longjmp handling. */
c5aa993b
JM
1147 BPSTAT_WHAT_SET_LONGJMP_RESUME,
1148
1149 /* Clear longjmp_resume breakpoint, then handle as
1150 BPSTAT_WHAT_KEEP_CHECKING. */
1151 BPSTAT_WHAT_CLEAR_LONGJMP_RESUME,
1152
2c03e5be
PA
1153 /* Clear step resume breakpoint, and keep checking. */
1154 BPSTAT_WHAT_STEP_RESUME,
1155
628fe4e4
JK
1156 /* Rather than distinguish between noisy and silent stops here, it
1157 might be cleaner to have bpstat_print make that decision (also
1158 taking into account stop_print_frame and source_only). But the
0e2de366
MS
1159 implications are a bit scary (interaction with auto-displays,
1160 etc.), so I won't try it. */
c5aa993b 1161
628fe4e4
JK
1162 /* Stop silently. */
1163 BPSTAT_WHAT_STOP_SILENT,
c5aa993b 1164
628fe4e4
JK
1165 /* Stop and print. */
1166 BPSTAT_WHAT_STOP_NOISY,
4efc6507 1167
2c03e5be
PA
1168 /* Clear step resume breakpoint, and keep checking. High-priority
1169 step-resume breakpoints are used when even if there's a user
1170 breakpoint at the current PC when we set the step-resume
1171 breakpoint, we don't want to re-handle any breakpoint other
1172 than the step-resume when it's hit; instead we want to move
1173 past the breakpoint. This is used in the case of skipping
1174 signal handlers. */
1175 BPSTAT_WHAT_HP_STEP_RESUME,
c5aa993b
JM
1176 };
1177
aa7d318d
TT
1178/* An enum indicating the kind of "stack dummy" stop. This is a bit
1179 of a misnomer because only one kind of truly a stack dummy. */
1180enum stop_stack_kind
1181 {
1182 /* We didn't stop at a stack dummy breakpoint. */
1183 STOP_NONE = 0,
1184
1185 /* Stopped at a stack dummy. */
1186 STOP_STACK_DUMMY,
1187
1188 /* Stopped at std::terminate. */
1189 STOP_STD_TERMINATE
1190 };
1191
c5aa993b
JM
1192struct bpstat_what
1193 {
1194 enum bpstat_what_main_action main_action;
1195
0e2de366
MS
1196 /* Did we hit a call dummy breakpoint? This only goes with a
1197 main_action of BPSTAT_WHAT_STOP_SILENT or
1198 BPSTAT_WHAT_STOP_NOISY (the concept of continuing from a call
1199 dummy without popping the frame is not a useful one). */
aa7d318d 1200 enum stop_stack_kind call_dummy;
186c406b
TT
1201
1202 /* Used for BPSTAT_WHAT_SET_LONGJMP_RESUME and
1203 BPSTAT_WHAT_CLEAR_LONGJMP_RESUME. True if we are handling a
1204 longjmp, false if we are handling an exception. */
e2d0f980 1205 bool is_longjmp;
c5aa993b 1206 };
c906108c
SS
1207
1208/* Tell what to do about this bpstat. */
313f3b21 1209struct bpstat_what bpstat_what (bpstat *);
243a9253
PA
1210
1211/* Run breakpoint event callbacks associated with the breakpoints that
1212 triggered. */
313f3b21 1213extern void bpstat_run_callbacks (bpstat *bs_head);
243a9253 1214
0e2de366 1215/* Find the bpstat associated with a breakpoint. NULL otherwise. */
313f3b21 1216bpstat *bpstat_find_breakpoint (bpstat *, struct breakpoint *);
c906108c 1217
4c462cb0 1218/* True if a signal that we got in target_wait() was due to
47591c29
PA
1219 circumstances explained by the bpstat; the signal is therefore not
1220 random. */
313f3b21 1221extern bool bpstat_explains_signal (bpstat *, enum gdb_signal);
c906108c 1222
4c462cb0 1223/* True if this bpstat causes a stop. */
313f3b21 1224extern bool bpstat_causes_stop (bpstat *);
67822962 1225
4c462cb0 1226/* True if we should step constantly (e.g. watchpoints on machines
c906108c
SS
1227 without hardware support). This isn't related to a specific bpstat,
1228 just to things like whether watchpoints are set. */
4c462cb0 1229extern bool bpstat_should_step ();
c906108c 1230
403c71fd
SM
1231/* Print a message indicating what happened. */
1232extern enum print_stop_action bpstat_print (bpstat *bs, target_waitkind kind);
c906108c 1233
0e2de366
MS
1234/* Put in *NUM the breakpoint number of the first breakpoint we are
1235 stopped at. *BSP upon return is a bpstat which points to the
1236 remaining breakpoints stopped at (but which is not guaranteed to be
1237 good for anything but further calls to bpstat_num).
1238
8671a17b
PA
1239 Return 0 if passed a bpstat which does not indicate any breakpoints.
1240 Return -1 if stopped at a breakpoint that has been deleted since
1241 we set it.
1242 Return 1 otherwise. */
313f3b21 1243extern int bpstat_num (bpstat **, int *);
c906108c 1244
78805ff8
PW
1245/* If BS indicates a breakpoint and this breakpoint has several code locations,
1246 return the location number of BS, otherwise return 0. */
1247
1248extern int bpstat_locno (const bpstat *bs);
1249
1250/* Print BS breakpoint number optionally followed by a . and breakpoint locno.
1251
1252 For a breakpoint with only one code location, outputs the signed field
1253 "bkptno" breakpoint number of BS (as returned by bpstat_num).
1254 If BS has several code locations, outputs a '.' character followed by
1255 the signed field "locno" (as returned by bpstat_locno). */
1256
1257extern void print_num_locno (const bpstat *bs, struct ui_out *);
1258
347bddb7
PA
1259/* Perform actions associated with the stopped inferior. Actually, we
1260 just use this for breakpoint commands. Perhaps other actions will
1261 go here later, but this is executed at a late time (from the
1262 command loop). */
1263extern void bpstat_do_actions (void);
c906108c 1264
e93ca019
JK
1265/* Modify all entries of STOP_BPSTAT of INFERIOR_PTID so that the actions will
1266 not be performed. */
1267extern void bpstat_clear_actions (void);
c906108c 1268
c906108c 1269/* Implementation: */
e514a9d6 1270
0e2de366
MS
1271/* Values used to tell the printing routine how to behave for this
1272 bpstat. */
e514a9d6
JM
1273enum bp_print_how
1274 {
1275 /* This is used when we want to do a normal printing of the reason
0e2de366
MS
1276 for stopping. The output will depend on the type of eventpoint
1277 we are dealing with. This is the default value, most commonly
1278 used. */
e514a9d6 1279 print_it_normal,
0e2de366
MS
1280 /* This is used when nothing should be printed for this bpstat
1281 entry. */
e514a9d6
JM
1282 print_it_noop,
1283 /* This is used when everything which needs to be printed has
1284 already been printed. But we still want to print the frame. */
1285 print_it_done
1286 };
1287
313f3b21 1288struct bpstat
c5aa993b 1289 {
313f3b21
SM
1290 bpstat ();
1291 bpstat (struct bp_location *bl, bpstat ***bs_link_pointer);
04afa70c 1292
313f3b21
SM
1293 bpstat (const bpstat &);
1294 bpstat &operator= (const bpstat &) = delete;
04afa70c 1295
f431efe5
PA
1296 /* Linked list because there can be more than one breakpoint at
1297 the same place, and a bpstat reflects the fact that all have
1298 been hit. */
313f3b21 1299 bpstat *next;
f431efe5
PA
1300
1301 /* Location that caused the stop. Locations are refcounted, so
1302 this will never be NULL. Note that this location may end up
1303 detached from a breakpoint, but that does not necessary mean
1304 that the struct breakpoint is gone. E.g., consider a
1305 watchpoint with a condition that involves an inferior function
1306 call. Watchpoint locations are recreated often (on resumes,
1307 hence on infcalls too). Between creating the bpstat and after
1308 evaluating the watchpoint condition, this location may hence
1309 end up detached from its original owner watchpoint, even though
1310 the watchpoint is still listed. If it's condition evaluates as
1311 true, we still want this location to cause a stop, and we will
1312 still need to know which watchpoint it was originally attached.
1313 What this means is that we should not (in most cases) follow
1314 the `bpstat->bp_location->owner' link, but instead use the
1315 `breakpoint_at' field below. */
b6433ede 1316 bp_location_ref_ptr bp_location_at;
f431efe5
PA
1317
1318 /* Breakpoint that caused the stop. This is nullified if the
1319 breakpoint ends up being deleted. See comments on
1320 `bp_location_at' above for why do we need this field instead of
1321 following the location's owner. */
1322 struct breakpoint *breakpoint_at;
1323
9add0f1b 1324 /* The associated command list. */
d1b0a7bf 1325 counted_command_line commands;
f431efe5 1326
c5aa993b 1327 /* Old value associated with a watchpoint. */
850645cf 1328 value_ref_ptr old_val;
c5aa993b 1329
4ec2227a
TT
1330 /* True if this breakpoint tells us to print the frame. */
1331 bool print;
c5aa993b 1332
4ec2227a
TT
1333 /* True if this breakpoint tells us to stop. */
1334 bool stop;
c5aa993b 1335
e514a9d6
JM
1336 /* Tell bpstat_print and print_bp_stop_message how to print stuff
1337 associated with this element of the bpstat chain. */
1338 enum bp_print_how print_it;
c5aa993b 1339 };
c906108c
SS
1340
1341enum inf_context
c5aa993b
JM
1342 {
1343 inf_starting,
1344 inf_running,
6ca15a4b
PA
1345 inf_exited,
1346 inf_execd
c5aa993b 1347 };
c2c6d25f
JM
1348
1349/* The possible return values for breakpoint_here_p.
1350 We guarantee that zero always means "no breakpoint here". */
1351enum breakpoint_here
1352 {
1353 no_breakpoint_here = 0,
1354 ordinary_breakpoint_here,
1355 permanent_breakpoint_here
1356 };
c906108c 1357\f
c5aa993b 1358
c906108c
SS
1359/* Prototypes for breakpoint-related functions. */
1360
accd0bcd 1361extern enum breakpoint_here breakpoint_here_p (const address_space *,
0e2de366 1362 CORE_ADDR);
c906108c 1363
d35ae833
PA
1364/* Return true if an enabled breakpoint exists in the range defined by
1365 ADDR and LEN, in ASPACE. */
accd0bcd 1366extern int breakpoint_in_range_p (const address_space *aspace,
d35ae833
PA
1367 CORE_ADDR addr, ULONGEST len);
1368
accd0bcd 1369extern int moribund_breakpoint_here_p (const address_space *, CORE_ADDR);
1c5cfe86 1370
accd0bcd
YQ
1371extern int breakpoint_inserted_here_p (const address_space *,
1372 CORE_ADDR);
c906108c 1373
accd0bcd 1374extern int software_breakpoint_inserted_here_p (const address_space *,
0e2de366 1375 CORE_ADDR);
4fa8626c 1376
9c02b525
PA
1377/* Return non-zero iff there is a hardware breakpoint inserted at
1378 PC. */
accd0bcd 1379extern int hardware_breakpoint_inserted_here_p (const address_space *,
9c02b525
PA
1380 CORE_ADDR);
1381
34b7e8a6
PA
1382/* Check whether any location of BP is inserted at PC. */
1383
1384extern int breakpoint_has_location_inserted_here (struct breakpoint *bp,
accd0bcd 1385 const address_space *aspace,
34b7e8a6
PA
1386 CORE_ADDR pc);
1387
accd0bcd 1388extern int single_step_breakpoint_inserted_here_p (const address_space *,
2adfaa28
PA
1389 CORE_ADDR);
1390
9093389c
PA
1391/* Returns true if there's a hardware watchpoint or access watchpoint
1392 inserted in the range defined by ADDR and LEN. */
accd0bcd 1393extern int hardware_watchpoint_inserted_in_range (const address_space *,
9093389c
PA
1394 CORE_ADDR addr,
1395 ULONGEST len);
1396
31e77af2
PA
1397/* Returns true if {ASPACE1,ADDR1} and {ASPACE2,ADDR2} represent the
1398 same breakpoint location. In most targets, this can only be true
1399 if ASPACE1 matches ASPACE2. On targets that have global
1400 breakpoints, the address space doesn't really matter. */
1401
accd0bcd 1402extern int breakpoint_address_match (const address_space *aspace1,
31e77af2 1403 CORE_ADDR addr1,
accd0bcd 1404 const address_space *aspace2,
31e77af2
PA
1405 CORE_ADDR addr2);
1406
f2fc3015 1407extern void until_break_command (const char *, int, int);
c906108c 1408
28010a5d
PA
1409/* Initialize a struct bp_location. */
1410
6c5b2ebe 1411extern void update_breakpoint_locations
74421c0b 1412 (code_breakpoint *b,
6c5b2ebe
PA
1413 struct program_space *filter_pspace,
1414 gdb::array_view<const symtab_and_line> sals,
1415 gdb::array_view<const symtab_and_line> sals_end);
0e30163f 1416
a14ed312 1417extern void breakpoint_re_set (void);
69de3c6a 1418
a14ed312 1419extern void breakpoint_re_set_thread (struct breakpoint *);
c906108c 1420
454dafbd
TT
1421extern void delete_breakpoint (struct breakpoint *);
1422
1423struct breakpoint_deleter
1424{
1425 void operator() (struct breakpoint *b) const
1426 {
1427 delete_breakpoint (b);
1428 }
1429};
1430
1431typedef std::unique_ptr<struct breakpoint, breakpoint_deleter> breakpoint_up;
1432
1433extern breakpoint_up set_momentary_breakpoint
a6d9a66e 1434 (struct gdbarch *, struct symtab_and_line, struct frame_id, enum bptype);
c906108c 1435
454dafbd 1436extern breakpoint_up set_momentary_breakpoint_at_pc
a6d9a66e 1437 (struct gdbarch *, CORE_ADDR pc, enum bptype type);
611c83ae 1438
e58b0e63
PA
1439extern struct breakpoint *clone_momentary_breakpoint (struct breakpoint *bpkt);
1440
a14ed312 1441extern void set_ignore_count (int, int, int);
c906108c 1442
a14ed312 1443extern void breakpoint_init_inferior (enum inf_context);
c906108c 1444
313f3b21 1445extern void breakpoint_auto_delete (bpstat *);
c906108c 1446
5cea2a26
PA
1447/* Return the chain of command lines to execute when this breakpoint
1448 is hit. */
1449extern struct command_line *breakpoint_commands (struct breakpoint *b);
1450
956a9fb9
JB
1451/* Return a string image of DISP. The string is static, and thus should
1452 NOT be deallocated after use. */
1453const char *bpdisp_text (enum bpdisp disp);
1454
0b39b52e 1455extern void break_command (const char *, int);
c906108c 1456
2e362716
AB
1457extern void watch_command_wrapper (const char *, int, bool);
1458extern void awatch_command_wrapper (const char *, int, bool);
1459extern void rwatch_command_wrapper (const char *, int, bool);
0b39b52e 1460extern void tbreak_command (const char *, int);
c906108c 1461
74421c0b 1462extern const struct breakpoint_ops code_breakpoint_ops;
348d480f 1463
9ac4176b
PA
1464/* Arguments to pass as context to some catch command handlers. */
1465#define CATCH_PERMANENT ((void *) (uintptr_t) 0)
1466#define CATCH_TEMPORARY ((void *) (uintptr_t) 1)
1467
1468/* Like add_cmd, but add the command to both the "catch" and "tcatch"
1469 lists, and pass some additional user data to the command
1470 function. */
1471
1472extern void
a121b7c1 1473 add_catch_command (const char *name, const char *docstring,
5538b03c 1474 cmd_func_ftype *func,
625e8578 1475 completer_ftype *completer,
9ac4176b
PA
1476 void *user_data_catch,
1477 void *user_data_tcatch);
1478
28010a5d 1479/* Add breakpoint B on the breakpoint list, and notify the user, the
3a5c3e22
PA
1480 target and breakpoint_created observers of its existence. If
1481 INTERNAL is non-zero, the breakpoint number will be allocated from
3ea46bff
YQ
1482 the internal breakpoint count. If UPDATE_GLL is non-zero,
1483 update_global_location_list will be called. */
28010a5d 1484
b270e6f9 1485extern void install_breakpoint (int internal, std::unique_ptr<breakpoint> &&b,
3ea46bff 1486 int update_gll);
9ac4176b 1487
264f9890
PA
1488/* Returns the breakpoint ops appropriate for use with with LOCSPEC
1489 and according to IS_TRACEPOINT. Use this to ensure, for example,
1490 that you pass the correct ops to create_breakpoint for probe
1491 location specs. If LOCSPEC is NULL, returns
1492 code_breakpoint_ops. */
bac7c5cf 1493
264f9890
PA
1494extern const struct breakpoint_ops *breakpoint_ops_for_location_spec
1495 (const location_spec *locspec, bool is_tracepoint);
bac7c5cf 1496
44f238bb
PA
1497/* Flags that can be passed down to create_breakpoint, etc., to affect
1498 breakpoint creation in several ways. */
1499
1500enum breakpoint_create_flags
1501 {
1502 /* We're adding a breakpoint to our tables that is already
1503 inserted in the target. */
1504 CREATE_BREAKPOINT_FLAGS_INSERTED = 1 << 0
1505 };
1506
264f9890
PA
1507/* Set a breakpoint. This function is shared between CLI and MI
1508 functions for setting a breakpoint at LOCSPEC.
f00aae0f
KS
1509
1510 This function has two major modes of operations, selected by the
1511 PARSE_EXTRA parameter.
1512
264f9890
PA
1513 If PARSE_EXTRA is zero, LOCSPEC is just the breakpoint's location
1514 spec, with condition, thread, and extra string specified by the
1515 COND_STRING, THREAD, and EXTRA_STRING parameters.
f00aae0f
KS
1516
1517 If PARSE_EXTRA is non-zero, this function will attempt to extract
1518 the condition, thread, and extra string from EXTRA_STRING, ignoring
1519 the similarly named parameters.
1520
10a636cc
TBA
1521 If FORCE_CONDITION is true, the condition is accepted even when it is
1522 invalid at all of the locations. However, if PARSE_EXTRA is non-zero,
1523 the FORCE_CONDITION parameter is ignored and the corresponding argument
1524 is parsed from EXTRA_STRING.
1525
f00aae0f
KS
1526 If INTERNAL is non-zero, the breakpoint number will be allocated
1527 from the internal breakpoint count.
1528
1529 Returns true if any breakpoint was created; false otherwise. */
1530
1531extern int create_breakpoint (struct gdbarch *gdbarch,
264f9890 1532 struct location_spec *locspec,
e1e01040
PA
1533 const char *cond_string, int thread,
1534 const char *extra_string,
10a636cc 1535 bool force_condition,
f00aae0f 1536 int parse_extra,
0fb4aa4b 1537 int tempflag, enum bptype wanted_type,
8cdf0e15
VP
1538 int ignore_count,
1539 enum auto_boolean pending_break_support,
c0a91b2b 1540 const struct breakpoint_ops *ops,
8cdf0e15 1541 int from_tty,
84f4c1fe 1542 int enabled,
44f238bb 1543 int internal, unsigned flags);
98deb0da 1544
e236ba44 1545extern void insert_breakpoints (void);
c906108c 1546
a14ed312 1547extern int remove_breakpoints (void);
c906108c 1548
f3869b1a
SM
1549/* Remove breakpoints of inferior INF. */
1550
1551extern void remove_breakpoints_inf (inferior *inf);
6c95b8df 1552
c906108c
SS
1553/* This function can be used to update the breakpoint package's state
1554 after an exec() system call has been executed.
1555
1556 This function causes the following:
1557
c5aa993b
JM
1558 - All eventpoints are marked "not inserted".
1559 - All eventpoints with a symbolic address are reset such that
1560 the symbolic address must be reevaluated before the eventpoints
1561 can be reinserted.
1562 - The solib breakpoints are explicitly removed from the breakpoint
1563 list.
1564 - A step-resume breakpoint, if any, is explicitly removed from the
1565 breakpoint list.
1566 - All eventpoints without a symbolic address are removed from the
0e2de366 1567 breakpoint list. */
a14ed312 1568extern void update_breakpoints_after_exec (void);
c906108c
SS
1569
1570/* This function can be used to physically remove hardware breakpoints
1571 and watchpoints from the specified traced inferior process, without
1572 modifying the breakpoint package's state. This can be useful for
1573 those targets which support following the processes of a fork() or
1574 vfork() system call, when one of the resulting two processes is to
1575 be detached and allowed to run free.
c5aa993b 1576
c906108c 1577 It is an error to use this function on the process whose id is
39f77062 1578 inferior_ptid. */
d80ee84f 1579extern int detach_breakpoints (ptid_t ptid);
c5aa993b 1580
6c95b8df
PA
1581/* This function is called when program space PSPACE is about to be
1582 deleted. It takes care of updating breakpoints to not reference
1583 this PSPACE anymore. */
1584extern void breakpoint_program_space_exit (struct program_space *pspace);
1585
186c406b
TT
1586extern void set_longjmp_breakpoint (struct thread_info *tp,
1587 struct frame_id frame);
611c83ae
PA
1588extern void delete_longjmp_breakpoint (int thread);
1589
f59f708a
PA
1590/* Mark all longjmp breakpoints from THREAD for later deletion. */
1591extern void delete_longjmp_breakpoint_at_next_stop (int thread);
1592
e2e4d78b 1593extern struct breakpoint *set_longjmp_breakpoint_for_call_dummy (void);
b67a2c6f 1594extern void check_longjmp_breakpoint_for_call_dummy (struct thread_info *tp);
e2e4d78b 1595
1900040c
MS
1596extern void enable_overlay_breakpoints (void);
1597extern void disable_overlay_breakpoints (void);
c906108c 1598
aa7d318d
TT
1599extern void set_std_terminate_breakpoint (void);
1600extern void delete_std_terminate_breakpoint (void);
1601
c906108c
SS
1602/* These functions respectively disable or reenable all currently
1603 enabled watchpoints. When disabled, the watchpoints are marked
64b9b334 1604 call_disabled. When re-enabled, they are marked enabled.
c906108c 1605
04714b91 1606 The intended client of these functions is call_function_by_hand.
c906108c
SS
1607
1608 The inferior must be stopped, and all breakpoints removed, when
1609 these functions are used.
1610
1611 The need for these functions is that on some targets (e.g., HP-UX),
1612 gdb is unable to unwind through the dummy frame that is pushed as
1613 part of the implementation of a call command. Watchpoints can
1614 cause the inferior to stop in places where this frame is visible,
1615 and that can cause execution control to become very confused.
1616
7e73cedf 1617 Note that if a user sets breakpoints in an interactively called
64b9b334 1618 function, the call_disabled watchpoints will have been re-enabled
c906108c
SS
1619 when the first such breakpoint is reached. However, on targets
1620 that are unable to unwind through the call dummy frame, watches
1621 of stack-based storage may then be deleted, because gdb will
1622 believe that their watched storage is out of scope. (Sigh.) */
a14ed312 1623extern void disable_watchpoints_before_interactive_call_start (void);
c906108c 1624
a14ed312 1625extern void enable_watchpoints_after_interactive_call_stop (void);
c906108c 1626
8bea4e01
UW
1627/* These functions disable and re-enable all breakpoints during
1628 inferior startup. They are intended to be called from solib
1629 code where necessary. This is needed on platforms where the
1630 main executable is relocated at some point during startup
1631 processing, making breakpoint addresses invalid.
1632
1633 If additional breakpoints are created after the routine
1634 disable_breakpoints_before_startup but before the routine
1635 enable_breakpoints_after_startup was called, they will also
1636 be marked as disabled. */
1637extern void disable_breakpoints_before_startup (void);
1638extern void enable_breakpoints_after_startup (void);
1639
40c03ae8 1640/* For script interpreters that need to define breakpoint commands
0e2de366
MS
1641 after they've already read the commands into a struct
1642 command_line. */
40c03ae8 1643extern enum command_control_type commands_from_control_command
896b6bda 1644 (const char *arg, struct command_line *cmd);
c5aa993b 1645
a14ed312 1646extern void clear_breakpoint_hit_counts (void);
c906108c 1647
48cb2d85
VP
1648extern struct breakpoint *get_breakpoint (int num);
1649
0e2de366
MS
1650/* The following are for displays, which aren't really breakpoints,
1651 but here is as good a place as any for them. */
c906108c 1652
a14ed312 1653extern void disable_current_display (void);
c906108c 1654
a14ed312 1655extern void do_displays (void);
c906108c 1656
a14ed312 1657extern void disable_display (int);
c906108c 1658
a14ed312 1659extern void clear_displays (void);
c906108c 1660
a14ed312 1661extern void disable_breakpoint (struct breakpoint *);
c906108c 1662
a14ed312 1663extern void enable_breakpoint (struct breakpoint *);
c906108c 1664
48cb2d85 1665extern void breakpoint_set_commands (struct breakpoint *b,
12973681 1666 counted_command_line &&commands);
48cb2d85 1667
45a43567
TT
1668extern void breakpoint_set_silent (struct breakpoint *b, int silent);
1669
1670extern void breakpoint_set_thread (struct breakpoint *b, int thread);
1671
1672extern void breakpoint_set_task (struct breakpoint *b, int task);
1673
25b22b0a
PA
1674/* Clear the "inserted" flag in all breakpoints. */
1675extern void mark_breakpoints_out (void);
1676
4efc6507 1677extern struct breakpoint *create_jit_event_breakpoint (struct gdbarch *,
dda83cd7 1678 CORE_ADDR);
4efc6507 1679
a6d9a66e
UW
1680extern struct breakpoint *create_solib_event_breakpoint (struct gdbarch *,
1681 CORE_ADDR);
c906108c 1682
f37f681c
PA
1683/* Create an solib event breakpoint at ADDRESS in the current program
1684 space, and immediately try to insert it. Returns a pointer to the
1685 breakpoint on success. Deletes the new breakpoint and returns NULL
1686 if inserting the breakpoint fails. */
1687extern struct breakpoint *create_and_insert_solib_event_breakpoint
1688 (struct gdbarch *gdbarch, CORE_ADDR address);
1689
a6d9a66e
UW
1690extern struct breakpoint *create_thread_event_breakpoint (struct gdbarch *,
1691 CORE_ADDR);
c4093a6a 1692
03673fc7
PP
1693extern void remove_jit_event_breakpoints (void);
1694
a14ed312 1695extern void remove_solib_event_breakpoints (void);
c906108c 1696
f37f681c
PA
1697/* Mark solib event breakpoints of the current program space with
1698 delete at next stop disposition. */
1699extern void remove_solib_event_breakpoints_at_next_stop (void);
1700
cb851954 1701extern void disable_breakpoints_in_shlibs (void);
c906108c 1702
f2478a7e
SM
1703/* This function returns true if B is a catchpoint. */
1704
1705extern bool is_catchpoint (struct breakpoint *b);
c5aa993b 1706
91985142 1707/* Shared helper function (MI and CLI) for creating and installing
b650a282
SM
1708 a shared object event catchpoint. If IS_LOAD is true then
1709 the events to be caught are load events, otherwise they are
1710 unload events. If IS_TEMP is true the catchpoint is a
1711 temporary one. If ENABLED is true the catchpoint is
1712 created in an enabled state. */
1713
1714extern void add_solib_catchpoint (const char *arg, bool is_load, bool is_temp,
1715 bool enabled);
91985142 1716
7c16b83e
PA
1717/* Create and insert a new software single step breakpoint for the
1718 current thread. May be called multiple times; each time will add a
1719 new location to the set of potential addresses the next instruction
1720 is at. */
6c95b8df 1721extern void insert_single_step_breakpoint (struct gdbarch *,
accd0bcd 1722 const address_space *,
0e2de366 1723 CORE_ADDR);
93f9a11f
YQ
1724
1725/* Insert all software single step breakpoints for the current frame.
1726 Return true if any software single step breakpoints are inserted,
1727 otherwise, return false. */
1728extern int insert_single_step_breakpoints (struct gdbarch *);
1729
d37e0847
PA
1730/* Check whether any hardware watchpoints have triggered or not,
1731 according to the target, and record it in each watchpoint's
1732 'watchpoint_triggered' field. */
c272a98c 1733int watchpoints_triggered (const target_waitstatus &);
d983da9c 1734
f0ba3972
PA
1735/* Helper for transparent breakpoint hiding for memory read and write
1736 routines.
1737
1738 Update one of READBUF or WRITEBUF with either the shadows
1739 (READBUF), or the breakpoint instructions (WRITEBUF) of inserted
1740 breakpoints at the memory range defined by MEMADDR and extending
1741 for LEN bytes. If writing, then WRITEBUF is a copy of WRITEBUF_ORG
1742 on entry.*/
1743extern void breakpoint_xfer_memory (gdb_byte *readbuf, gdb_byte *writebuf,
1744 const gdb_byte *writebuf_org,
1745 ULONGEST memaddr, LONGEST len);
8defab1a 1746
b57bacec
PA
1747/* Return true if breakpoints should be inserted now. That'll be the
1748 case if either:
1749
1750 - the target has global breakpoints.
1751
1752 - "breakpoint always-inserted" is on, and the target has
1753 execution.
1754
1755 - threads are executing.
1756*/
a25a5a45 1757extern int breakpoints_should_be_inserted_now (void);
74960c60 1758
20874c92
VP
1759/* Called each time new event from target is processed.
1760 Retires previously deleted breakpoint locations that
1761 in our opinion won't ever trigger. */
1762extern void breakpoint_retire_moribund (void);
1763
733d554a
TBA
1764/* Set break condition of breakpoint B to EXP.
1765 If FORCE, define the condition even if it is invalid in
1766 all of the breakpoint locations. */
7a26bd4d 1767extern void set_breakpoint_condition (struct breakpoint *b, const char *exp,
733d554a 1768 int from_tty, bool force);
adc36818 1769
79aabb73
TBA
1770/* Set break condition for the breakpoint with number BPNUM to EXP.
1771 Raise an error if no breakpoint with the given number is found.
1772 Also raise an error if the breakpoint already has stop conditions.
1773 If FORCE, define the condition even if it is invalid in
1774 all of the breakpoint locations. */
1775extern void set_breakpoint_condition (int bpnum, const char *exp,
1776 int from_tty, bool force);
1777
a96d9b2e
SDJ
1778/* Checks if we are catching syscalls or not.
1779 Returns 0 if not, greater than 0 if we are. */
1780extern int catch_syscall_enabled (void);
1781
1782/* Checks if we are catching syscalls with the specific
1783 syscall_number. Used for "filtering" the catchpoints.
9fe3819e
SM
1784 Returns false if not, true if we are. */
1785extern bool catching_syscall_number (int syscall_number);
a96d9b2e 1786
1042e4c0 1787/* Return a tracepoint with the given number if found. */
d9b3f62e 1788extern struct tracepoint *get_tracepoint (int num);
1042e4c0 1789
d9b3f62e 1790extern struct tracepoint *get_tracepoint_by_number_on_target (int num);
d5551862 1791
1042e4c0 1792/* Find a tracepoint by parsing a number in the supplied string. */
d9b3f62e 1793extern struct tracepoint *
0b39b52e 1794 get_tracepoint_by_number (const char **arg,
bfd28288 1795 number_or_range_parser *parser);
1042e4c0 1796
f2478a7e
SM
1797/* Return true if B is of tracepoint kind. */
1798
1799extern bool is_tracepoint (const struct breakpoint *b);
a7bdde9e 1800
f51e0e20
TT
1801/* Return a vector of all static tracepoints defined at ADDR. */
1802extern std::vector<breakpoint *> static_tracepoints_here (CORE_ADDR addr);
0fb4aa4b 1803
c80049d3
TT
1804/* Create an instance of this to start registering breakpoint numbers
1805 for a later "commands" command. */
1806
1807class scoped_rbreak_breakpoints
1808{
1809public:
1810
1811 scoped_rbreak_breakpoints ();
1812 ~scoped_rbreak_breakpoints ();
1813
1814 DISABLE_COPY_AND_ASSIGN (scoped_rbreak_breakpoints);
1815};
95a42b64 1816
f6d17b2b
SM
1817/* Breakpoint linked list iterator. */
1818
1819using breakpoint_iterator = next_iterator<breakpoint>;
1820
240edef6
SM
1821/* Breakpoint linked list range. */
1822
9be25986 1823using breakpoint_range = iterator_range<breakpoint_iterator>;
240edef6
SM
1824
1825/* Return a range to iterate over all breakpoints. */
1826
1827breakpoint_range all_breakpoints ();
1828
1829/* Breakpoint linked list range, safe against deletion of the current
1830 breakpoint while iterating. */
1831
1832using breakpoint_safe_range = basic_safe_range<breakpoint_range>;
1833
1834/* Return a range to iterate over all breakpoints. This range is safe against
1835 deletion of the current breakpoint while iterating. */
1836
1837breakpoint_safe_range all_breakpoints_safe ();
1838
f6d17b2b
SM
1839/* Breakpoint filter to only keep tracepoints. */
1840
1841struct tracepoint_filter
1842{
1843 bool operator() (breakpoint *b)
1844 { return is_tracepoint (b); }
1845};
1846
1847/* Breakpoint linked list iterator, filtering to only keep tracepoints. */
1848
1849using tracepoint_iterator
1850 = filtered_iterator<breakpoint_iterator, tracepoint_filter>;
1851
1852/* Breakpoint linked list range, filtering to only keep tracepoints. */
1853
9be25986 1854using tracepoint_range = iterator_range<tracepoint_iterator>;
f6d17b2b
SM
1855
1856/* Return a range to iterate over all tracepoints. */
1857
1858tracepoint_range all_tracepoints ();
1859
055c879f
SM
1860/* Return a range to iterate over all breakpoint locations. */
1861
1862const std::vector<bp_location *> &all_bp_locations ();
1863
0574c78f
GB
1864/* Nonzero if the specified PC cannot be a location where functions
1865 have been inlined. */
1866
accd0bcd 1867extern int pc_at_non_inline_function (const address_space *aspace,
09ac7c10 1868 CORE_ADDR pc,
c272a98c 1869 const target_waitstatus &ws);
0574c78f 1870
09d682a4
TT
1871extern int user_breakpoint_p (struct breakpoint *);
1872
93daf339
TT
1873/* Return true if this breakpoint is pending, false if not. */
1874extern int pending_breakpoint_p (struct breakpoint *);
1875
1bfeeb0f
JL
1876/* Attempt to determine architecture of location identified by SAL. */
1877extern struct gdbarch *get_sal_arch (struct symtab_and_line sal);
1878
2f202fde
JK
1879extern void breakpoint_free_objfile (struct objfile *objfile);
1880
63160a43 1881extern const char *ep_parse_optional_if_clause (const char **arg);
916703c0 1882
f303dbd6
PA
1883/* Print the "Thread ID hit" part of "Thread ID hit Breakpoint N" to
1884 UIOUT iff debugging multiple threads. */
1885extern void maybe_print_thread_hit_breakpoint (struct ui_out *uiout);
1886
65630365
PA
1887/* Print the specified breakpoint. */
1888extern void print_breakpoint (breakpoint *bp);
1889
8588b356
SM
1890/* Command element for the 'commands' command. */
1891extern cmd_list_element *commands_cmd_element;
1892
13674803
SM
1893/* Whether to use the fixed output when printing information about a
1894 multi-location breakpoint (see PR 9659). */
1895
1896extern bool fix_multi_location_breakpoint_output_globally;
1897
9db0d853
SM
1898/* Whether to use the fixed output when printing information about
1899 commands attached to a breakpoint. */
1900
1901extern bool fix_breakpoint_script_output_globally;
1902
30056ea0
AB
1903/* Deal with "catch catch", "catch throw", and "catch rethrow" commands and
1904 the MI equivalents. Sets up to catch events of type EX_EVENT. When
1905 TEMPFLAG is true only the next matching event is caught after which the
1906 catch-point is deleted. If REGEX is not NULL then only exceptions whose
1907 type name matches REGEX will trigger the event. */
1908
1909extern void catch_exception_event (enum exception_event_kind ex_event,
1910 const char *regex, bool tempflag,
1911 int from_tty);
1912
2f9ee862
TT
1913/* A helper function that prints a shared library stopped event.
1914 IS_CATCHPOINT is true if the event is due to a "catch load"
1915 catchpoint, false otherwise. */
1916
4e9e993a 1917extern void print_solib_event (bool is_catchpoint);
2f9ee862 1918
bd21b6c9
PA
1919/* Print a message describing any user-breakpoints set at PC. This
1920 concerns with logical breakpoints, so we match program spaces, not
1921 address spaces. */
1922
1923extern void describe_other_breakpoints (struct gdbarch *,
1924 struct program_space *, CORE_ADDR,
1925 struct obj_section *, int);
1926
e5213e2c
SF
1927/* Enable or disable a breakpoint location LOC. ENABLE
1928 specifies whether to enable or disable. */
1929
1930extern void enable_disable_bp_location (bp_location *loc, bool enable);
1931
c906108c 1932#endif /* !defined (BREAKPOINT_H) */