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