1 /* Data structures associated with breakpoints in GDB.
2 Copyright (C) 1992-2024 Free Software Foundation, Inc.
4 This file is part of GDB.
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.
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.
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/>. */
19 #if !defined (BREAKPOINT_H)
20 #define BREAKPOINT_H 1
26 #include "gdbsupport/break-common.h"
30 #include "gdbsupport/array-view.h"
31 #include "gdbsupport/filtered-iterator.h"
32 #include "gdbsupport/iterator-range.h"
33 #include "gdbsupport/refcounted-object.h"
34 #include "gdbsupport/safe-iterator.h"
35 #include "cli/cli-script.h"
36 #include "target/waitstatus.h"
39 struct gdbpy_breakpoint_object
;
40 struct gdbscm_breakpoint_object
;
41 struct number_or_range_parser
;
45 struct linespec_result
;
49 /* Enum for exception-handling support in 'catch throw', 'catch rethrow',
50 'catch catch' and the MI equivalent. */
52 enum exception_event_kind
59 /* Why are we removing the breakpoint from the target? */
63 /* A regular remove. Remove the breakpoint and forget everything
67 /* Detach the breakpoints from a fork child. */
71 /* This is the maximum number of bytes a breakpoint instruction can
72 take. Feel free to increase it. It's just used in a few places to
73 size arrays that should be independent of the target
76 #define BREAKPOINT_MAX 16
79 /* Type of breakpoint. */
83 bp_none
= 0, /* Eventpoint has been deleted */
84 bp_breakpoint
, /* Normal breakpoint */
85 bp_hardware_breakpoint
, /* Hardware assisted breakpoint */
86 bp_single_step
, /* Software single-step */
87 bp_until
, /* used by until command */
88 bp_finish
, /* used by finish command */
89 bp_watchpoint
, /* Watchpoint */
90 bp_hardware_watchpoint
, /* Hardware assisted watchpoint */
91 bp_read_watchpoint
, /* read watchpoint, (hardware assisted) */
92 bp_access_watchpoint
, /* access watchpoint, (hardware assisted) */
93 bp_longjmp
, /* secret breakpoint to find longjmp() */
94 bp_longjmp_resume
, /* secret breakpoint to escape longjmp() */
96 /* Breakpoint placed to the same location(s) like bp_longjmp but used to
97 protect against stale DUMMY_FRAME. Multiple bp_longjmp_call_dummy and
98 one bp_call_dummy are chained together by related_breakpoint for each
100 bp_longjmp_call_dummy
,
102 /* An internal breakpoint that is installed on the unwinder's
105 /* An internal breakpoint that is set at the point where an
106 exception will land. */
109 /* Used by wait_for_inferior for stepping over subroutine calls,
110 and for skipping prologues. */
113 /* Used by wait_for_inferior for stepping over signal
117 /* Used to detect when a watchpoint expression has gone out of
118 scope. These breakpoints are usually not visible to the user.
120 This breakpoint has some interesting properties:
122 1) There's always a 1:1 mapping between watchpoints
123 on local variables and watchpoint_scope breakpoints.
125 2) It automatically deletes itself and the watchpoint it's
126 associated with when hit.
128 3) It can never be disabled. */
131 /* The breakpoint at the end of a call dummy. See bp_longjmp_call_dummy it
132 is chained with by related_breakpoint. */
135 /* A breakpoint set on std::terminate, that is used to catch
136 otherwise uncaught exceptions thrown during an inferior call. */
139 /* Some dynamic linkers (HP, maybe Solaris) can arrange for special
140 code in the inferior to run when significant events occur in the
141 dynamic linker (for example a library is loaded or unloaded).
143 By placing a breakpoint in this magic code GDB will get control
144 when these significant events occur. GDB can then re-examine
145 the dynamic linker's data structures to discover any newly loaded
146 dynamic libraries. */
149 /* Some multi-threaded systems can arrange for a location in the
150 inferior to be executed when certain thread-related events occur
151 (such as thread creation or thread death).
153 By placing a breakpoint at one of these locations, GDB will get
154 control when these events occur. GDB can then update its thread
159 /* On the same principal, an overlay manager can arrange to call a
160 magic location in the inferior whenever there is an interesting
161 change in overlay status. GDB can update its overlay tables
162 and fiddle with breakpoints in overlays when this breakpoint
167 /* Master copies of longjmp breakpoints. These are always installed
168 as soon as an objfile containing longjmp is loaded, but they are
169 always disabled. While necessary, temporary clones of bp_longjmp
170 type will be created and enabled. */
174 /* Master copies of std::terminate breakpoints. */
175 bp_std_terminate_master
,
177 /* Like bp_longjmp_master, but for exceptions. */
184 bp_static_tracepoint
,
185 /* Like bp_static_tracepoint but for static markers. */
186 bp_static_marker_tracepoint
,
188 /* A dynamic printf stops at the given location, does a formatted
189 print, then automatically continues. (Although this is sort of
190 like a macro packaging up standard breakpoint functionality,
191 GDB doesn't have a way to construct types of breakpoint from
192 elements of behavior.) */
195 /* Event for JIT compiled code generation or deletion. */
198 /* Breakpoint is placed at the STT_GNU_IFUNC resolver. When hit GDB
199 inserts new bp_gnu_ifunc_resolver_return at the caller.
200 bp_gnu_ifunc_resolver is still being kept here as a different thread
201 may still hit it before bp_gnu_ifunc_resolver_return is hit by the
203 bp_gnu_ifunc_resolver
,
205 /* On its hit GDB now know the resolved address of the target
206 STT_GNU_IFUNC function. Associated bp_gnu_ifunc_resolver can be
207 deleted now and the breakpoint moved to the target function entry
209 bp_gnu_ifunc_resolver_return
,
212 /* States of enablement of breakpoint. */
216 bp_disabled
, /* The eventpoint is inactive, and cannot
218 bp_enabled
, /* The eventpoint is active, and can
220 bp_call_disabled
, /* The eventpoint has been disabled while a
221 call into the inferior is "in flight",
222 because some eventpoints interfere with
223 the implementation of a call on some
224 targets. The eventpoint will be
225 automatically enabled and reset when the
226 call "lands" (either completes, or stops
227 at another eventpoint). */
231 /* Disposition of breakpoint. Ie: what to do after hitting it. */
235 disp_del
, /* Delete it */
236 disp_del_at_next_stop
, /* Delete at next stop,
237 whether hit or not */
238 disp_disable
, /* Disable it */
239 disp_donttouch
/* Leave it alone */
242 /* Status of breakpoint conditions used when synchronizing
243 conditions with the target. */
245 enum condition_status
247 condition_unchanged
= 0,
252 /* Information used by targets to insert and remove breakpoints. */
254 struct bp_target_info
256 /* Address space at which the breakpoint was placed. */
257 struct address_space
*placed_address_space
;
259 /* Address at which the breakpoint was placed. This is normally
260 the same as REQUESTED_ADDRESS, except when adjustment happens in
261 gdbarch_breakpoint_from_pc. The most common form of adjustment
262 is stripping an alternate ISA marker from the PC which is used
263 to determine the type of breakpoint to insert. */
264 CORE_ADDR placed_address
;
266 /* Address at which the breakpoint was requested. */
267 CORE_ADDR reqstd_address
;
269 /* If this is a ranged breakpoint, then this field contains the
270 length of the range that will be watched for execution. */
273 /* If the breakpoint lives in memory and reading that memory would
274 give back the breakpoint, instead of the original contents, then
275 the original contents are cached here. Only SHADOW_LEN bytes of
276 this buffer are valid, and only when the breakpoint is inserted. */
277 gdb_byte shadow_contents
[BREAKPOINT_MAX
];
279 /* The length of the data cached in SHADOW_CONTENTS. */
282 /* The breakpoint's kind. It is used in 'kind' parameter in Z
286 /* Conditions the target should evaluate if it supports target-side
287 breakpoint conditions. These are non-owning pointers. */
288 std::vector
<agent_expr
*> conditions
;
290 /* Commands the target should evaluate if it supports target-side
291 breakpoint commands. These are non-owning pointers. */
292 std::vector
<agent_expr
*> tcommands
;
294 /* Flag that is true if the breakpoint should be left in place even
295 when GDB is not connected. */
299 /* GDB maintains two types of information about each breakpoint (or
300 watchpoint, or other related event). The first type corresponds
301 to struct breakpoint; this is a relatively high-level structure
302 which contains the source location(s), stopping conditions, user
303 commands to execute when the breakpoint is hit, and so forth.
305 The second type of information corresponds to struct bp_location.
306 Each breakpoint has one or (eventually) more locations associated
307 with it, which represent target-specific and machine-specific
308 mechanisms for stopping the program. For instance, a watchpoint
309 expression may require multiple hardware watchpoints in order to
310 catch all changes in the value of the expression being watched. */
314 bp_loc_software_breakpoint
,
315 bp_loc_hardware_breakpoint
,
316 bp_loc_software_watchpoint
,
317 bp_loc_hardware_watchpoint
,
319 bp_loc_other
/* Miscellaneous... */
322 class bp_location
: public refcounted_object
, public intrusive_list_node
<bp_location
>
325 /* Construct a bp_location with the type inferred from OWNER's
327 explicit bp_location (breakpoint
*owner
);
329 /* Construct a bp_location with type TYPE. */
330 bp_location (breakpoint
*owner
, bp_loc_type type
);
332 virtual ~bp_location () = default;
334 /* Type of this breakpoint location. */
335 bp_loc_type loc_type
{};
337 /* Each breakpoint location must belong to exactly one higher-level
338 breakpoint. This pointer is NULL iff this bp_location is no
339 longer attached to a breakpoint. For example, when a breakpoint
340 is deleted, its locations may still be found in the
341 moribund_locations list, or if we had stopped for it, in
343 breakpoint
*owner
= NULL
;
345 /* Conditional. Break only if this expression's value is nonzero.
346 Unlike string form of condition, which is associated with
347 breakpoint, this is associated with location, since if breakpoint
348 has several locations, the evaluation of expression can be
349 different for different locations. Only valid for real
350 breakpoints; a watchpoint's conditional expression is stored in
351 the owner breakpoint object. */
354 /* Conditional expression in agent expression
355 bytecode form. This is used for stub-side breakpoint
356 condition evaluation. */
357 agent_expr_up cond_bytecode
;
359 /* Signals that the condition has changed since the last time
360 we updated the global location list. This means the condition
361 needs to be sent to the target again. This is used together
362 with target-side breakpoint conditions.
364 condition_unchanged: It means there has been no condition changes.
366 condition_modified: It means this location had its condition modified.
368 condition_updated: It means we already marked all the locations that are
369 duplicates of this location and thus we don't need to call
370 force_breakpoint_reinsertion (...) for this location. */
372 condition_status condition_changed
{};
374 agent_expr_up cmd_bytecode
;
376 /* Signals that breakpoint conditions and/or commands need to be
377 re-synced with the target. This has no use other than
378 target-side breakpoints. */
379 bool needs_update
= false;
381 /* This location's address is in an unloaded solib, and so this
382 location should not be inserted. It will be automatically
383 enabled when that solib is loaded. */
384 bool shlib_disabled
= false;
386 /* Is this particular location enabled. */
387 bool enabled
= false;
389 /* Is this particular location disabled because the condition
390 expression is invalid at this location. For a location to be
391 reported as enabled, the ENABLED field above has to be true *and*
392 the DISABLED_BY_COND field has to be false. */
393 bool disabled_by_cond
= false;
395 /* True if this breakpoint is now inserted. */
396 bool inserted
= false;
398 /* True if this is a permanent breakpoint. There is a breakpoint
399 instruction hard-wired into the target's code. Don't try to
400 write another breakpoint instruction on top of it, or restore its
401 value. Step over it using the architecture's
402 gdbarch_skip_permanent_breakpoint method. */
403 bool permanent
= false;
405 /* True if this is not the first breakpoint in the list
406 for the given address. location of tracepoint can _never_
407 be duplicated with other locations of tracepoints and other
408 kinds of breakpoints, because two locations at the same
409 address may have different actions, so both of these locations
410 should be downloaded and so that `tfind N' always works. */
411 bool duplicate
= false;
413 /* If we someday support real thread-specific breakpoints, then
414 the breakpoint location will need a thread identifier. */
416 /* Data for specific breakpoint types. These could be a union, but
417 simplicity is more important than memory usage for breakpoints. */
419 /* Architecture associated with this location's address. May be
420 different from the breakpoint architecture. */
421 struct gdbarch
*gdbarch
= NULL
;
423 /* The program space associated with this breakpoint location
424 address. Note that an address space may be represented in more
425 than one program space (e.g. each uClinux program will be given
426 its own program space, but there will only be one address space
427 for all of them), but we must not insert more than one location
428 at the same address in the same address space. */
429 program_space
*pspace
= NULL
;
431 /* Note that zero is a perfectly valid code address on some platforms
432 (for example, the mn10200 (OBSOLETE) and mn10300 simulators). NULL
433 is not a special value for this field. Valid for all types except
435 CORE_ADDR address
= 0;
437 /* For hardware watchpoints, the size of the memory region being
438 watched. For hardware ranged breakpoints, the size of the
442 /* Type of hardware watchpoint. */
443 target_hw_bp_type watchpoint_type
{};
445 /* For any breakpoint type with an address, this is the section
446 associated with the address. Used primarily for overlay
448 obj_section
*section
= NULL
;
450 /* Address at which breakpoint was requested, either by the user or
451 by GDB for internal breakpoints. This will usually be the same
452 as ``address'' (above) except for cases in which
453 ADJUST_BREAKPOINT_ADDRESS has computed a different address at
454 which to place the breakpoint in order to comply with a
455 processor's architectual constraints. */
456 CORE_ADDR requested_address
= 0;
458 /* An additional address assigned with this location. This is currently
459 only used by STT_GNU_IFUNC resolver breakpoints to hold the address
460 of the resolver function. */
461 CORE_ADDR related_address
= 0;
463 /* If the location comes from a probe point, this is the probe associated
465 bound_probe probe
{};
467 gdb::unique_xmalloc_ptr
<char> function_name
;
469 /* Details of the placed breakpoint, when inserted. */
470 bp_target_info target_info
{};
472 /* Similarly, for the breakpoint at an overlay's LMA, if necessary. */
473 bp_target_info overlay_target_info
{};
475 /* In a non-stop mode, it's possible that we delete a breakpoint,
476 but as we do that, some still running thread hits that breakpoint.
477 For that reason, we need to keep locations belonging to deleted
478 breakpoints for a bit, so that don't report unexpected SIGTRAP.
479 We can't keep such locations forever, so we use a heuristic --
480 after we process certain number of inferior events since
481 breakpoint was deleted, we retire all locations of that breakpoint.
482 This variable keeps a number of events still to go, when
483 it becomes 0 this location is retired. */
484 int events_till_retirement
= 0;
486 /* Line number which was used to place this location.
488 Breakpoint placed into a comment keeps it's user specified line number
489 despite ADDRESS resolves into a different line number. */
493 /* Symtab which was used to place this location. This is used
494 to find the corresponding source file name. */
496 struct symtab
*symtab
= NULL
;
498 /* The symbol found by the location parser, if any. This may be used to
499 ascertain when a location spec was set at a different location than
500 the one originally selected by parsing, e.g., inlined symbols. */
501 const struct symbol
*symbol
= NULL
;
503 /* Similarly, the minimal symbol found by the location parser, if
504 any. This may be used to ascertain if the location was
505 originally set on a GNU ifunc symbol. */
506 const minimal_symbol
*msymbol
= NULL
;
508 /* The objfile the symbol or minimal symbol were found in. */
509 const struct objfile
*objfile
= NULL
;
511 /* Return a string representation of the bp_location.
512 This is only meant to be used in debug messages. */
513 std::string
to_string () const;
516 /* A policy class for bp_location reference counting. */
517 struct bp_location_ref_policy
519 static void incref (bp_location
*loc
)
524 static void decref (bp_location
*loc
)
526 gdb_assert (loc
->refcount () > 0);
528 if (loc
->refcount () == 0)
533 /* A gdb::ref_ptr that has been specialized for bp_location. */
534 typedef gdb::ref_ptr
<bp_location
, bp_location_ref_policy
>
537 /* The possible return values for print_bpstat, print_it_normal,
538 print_it_done, print_it_noop. */
539 enum print_stop_action
541 /* We printed nothing or we need to do some more analysis. */
544 /* We printed something, and we *do* desire that something to be
545 followed by a location. */
548 /* We printed something, and we do *not* desire that something to be
549 followed by a location. */
552 /* We already printed all we needed to print, don't print anything
557 /* This structure is a collection of function pointers that, if available,
558 will be called instead of the performing the default action for this
561 struct breakpoint_ops
563 /* Create SALs from location spec, storing the result in
566 For an explanation about the arguments, see the function
567 `create_sals_from_location_spec_default'.
569 This function is called inside `create_breakpoint'. */
570 void (*create_sals_from_location_spec
) (location_spec
*locspec
,
571 struct linespec_result
*canonical
);
573 /* This method will be responsible for creating a breakpoint given its SALs.
574 Usually, it just calls `create_breakpoints_sal' (for ordinary
575 breakpoints). However, there may be some special cases where we might
576 need to do some tweaks, e.g., see
577 `strace_marker_create_breakpoints_sal'.
579 This function is called inside `create_breakpoint'. */
580 void (*create_breakpoints_sal
) (struct gdbarch
*,
581 struct linespec_result
*,
582 gdb::unique_xmalloc_ptr
<char>,
583 gdb::unique_xmalloc_ptr
<char>,
584 enum bptype
, enum bpdisp
, int, int, int,
585 int, int, int, int, unsigned);
588 enum watchpoint_triggered
590 /* This watchpoint definitely did not trigger. */
591 watch_triggered_no
= 0,
593 /* Some hardware watchpoint triggered, and it might have been this
594 one, but we do not know which it was. */
595 watch_triggered_unknown
,
597 /* This hardware watchpoint definitely did trigger. */
601 /* Some targets (e.g., embedded PowerPC) need two debug registers to set
602 a watchpoint over a memory region. If this flag is true, GDB will use
603 only one register per watchpoint, thus assuming that all accesses that
604 modify a memory location happen at its starting address. */
606 extern bool target_exact_watchpoints
;
608 using bp_location_list
= intrusive_list
<bp_location
>;
609 using bp_location_iterator
= bp_location_list::iterator
;
610 using bp_location_range
= iterator_range
<bp_location_iterator
>;
612 /* Note that the ->silent field is not currently used by any commands
613 (though the code is in there if it was to be, and set_raw_breakpoint
614 does set it to 0). I implemented it because I thought it would be
615 useful for a hack I had to put in; I'm going to leave it in because
616 I can see how there might be times when it would indeed be useful */
618 /* Abstract base class representing all kinds of breakpoints. */
620 struct breakpoint
: public intrusive_list_node
<breakpoint
>
622 breakpoint (struct gdbarch
*gdbarch_
, enum bptype bptype
,
623 bool temp
= true, const char *cond_string
= nullptr);
625 DISABLE_COPY_AND_ASSIGN (breakpoint
);
627 virtual ~breakpoint () = 0;
629 /* Allocate a location for this breakpoint. */
630 virtual struct bp_location
*allocate_location ();
632 /* Return a range of this breakpoint's locations. */
633 bp_location_range
locations () const;
635 /* Add LOC to the location list of this breakpoint, sorted by address
638 LOC must have this breakpoint as its owner. LOC must not already be linked
639 in a location list. */
640 void add_location (bp_location
&loc
);
642 /* Remove LOC from this breakpoint's location list. The name is a bit funny
643 because remove_location is already taken, and means something else.
645 LOC must be have this breakpoints as its owner. LOC must be linked in this
646 breakpoint's location list. */
647 void unadd_location (bp_location
&loc
);
649 /* Clear the location list of this breakpoint. */
650 void clear_locations ()
651 { m_locations
.clear (); }
653 /* Split all locations of this breakpoint that are bound to PSPACE out of its
654 location list to a separate list and return that list. If
655 PSPACE is nullptr, hoist out all locations. */
656 bp_location_list
steal_locations (program_space
*pspace
);
658 /* Return true if this breakpoint has a least one location. */
659 bool has_locations () const
660 { return !m_locations
.empty (); }
662 /* Return true if this breakpoint has a single location. */
663 bool has_single_location () const
665 if (!this->has_locations ())
668 return std::next (m_locations
.begin ()) == m_locations
.end ();
671 /* Return true if this breakpoint has multiple locations. */
672 bool has_multiple_locations () const
674 if (!this->has_locations ())
677 return std::next (m_locations
.begin ()) != m_locations
.end ();
680 /* Return a reference to the first location of this breakpoint. */
681 bp_location
&first_loc ()
683 gdb_assert (this->has_locations ());
684 return m_locations
.front ();
687 /* Return a reference to the first location of this breakpoint. */
688 const bp_location
&first_loc () const
690 gdb_assert (this->has_locations ());
691 return m_locations
.front ();
694 /* Return a reference to the last location of this breakpoint. */
695 const bp_location
&last_loc () const
697 gdb_assert (this->has_locations ());
698 return m_locations
.back ();
701 /* Reevaluate a breakpoint. This is necessary after symbols change
702 (e.g., an executable or DSO was loaded, or the inferior just
704 virtual void re_set ()
706 /* Nothing to re-set. */
709 /* Insert the breakpoint or watchpoint or activate the catchpoint.
710 Return 0 for success, 1 if the breakpoint, watchpoint or
711 catchpoint type is not supported, -1 for failure. */
712 virtual int insert_location (struct bp_location
*);
714 /* Remove the breakpoint/catchpoint that was previously inserted
715 with the "insert" method above. Return 0 for success, 1 if the
716 breakpoint, watchpoint or catchpoint type is not supported,
718 virtual int remove_location (struct bp_location
*,
719 enum remove_bp_reason reason
);
721 /* Return true if it the target has stopped due to hitting
722 breakpoint location BL. This function does not check if we
723 should stop, only if BL explains the stop. ASPACE is the address
724 space in which the event occurred, BP_ADDR is the address at
725 which the inferior stopped, and WS is the target_waitstatus
726 describing the event. */
727 virtual int breakpoint_hit (const struct bp_location
*bl
,
728 const address_space
*aspace
,
730 const target_waitstatus
&ws
);
732 /* Check internal conditions of the breakpoint referred to by BS.
733 If we should not stop for this breakpoint, set BS->stop to
735 virtual void check_status (struct bpstat
*bs
)
740 /* Tell how many hardware resources (debug registers) are needed
741 for this breakpoint. If this function is not provided, then
742 the breakpoint or watchpoint needs one debug register. */
743 virtual int resources_needed (const struct bp_location
*);
745 /* The normal print routine for this breakpoint, called when we
747 virtual enum print_stop_action
print_it (const bpstat
*bs
) const;
749 /* Display information about this breakpoint, for "info
750 breakpoints". Returns false if this method should use the
752 virtual bool print_one (const bp_location
**) const
757 /* Display extra information about this breakpoint, below the normal
758 breakpoint description in "info breakpoints".
760 In the example below, the "address range" line was printed
761 by ranged_breakpoint::print_one_detail.
763 (gdb) info breakpoints
764 Num Type Disp Enb Address What
765 2 hw breakpoint keep y in main at test-watch.c:70
766 address range: [0x10000458, 0x100004c7]
769 virtual void print_one_detail (struct ui_out
*) const
774 /* Display information about this breakpoint after setting it
775 (roughly speaking; this is called from "mention"). */
776 virtual void print_mention () const;
778 /* Print to FP the CLI command that recreates this breakpoint. */
779 virtual void print_recreate (struct ui_file
*fp
) const;
781 /* Return true if this breakpoint explains a signal. See
782 bpstat_explains_signal. */
783 virtual bool explains_signal (enum gdb_signal
)
788 /* Called after evaluating the breakpoint's condition,
789 and only if it evaluated true. */
790 virtual void after_condition_true (struct bpstat
*bs
)
795 /* Type of breakpoint. */
796 bptype type
= bp_none
;
797 /* Zero means disabled; remember the info but don't break here. */
798 enum enable_state enable_state
= bp_enabled
;
799 /* What to do with this breakpoint after we hit it. */
800 bpdisp disposition
= disp_del
;
801 /* Number assigned to distinguish breakpoints. */
804 /* True means a silent breakpoint (don't print frame info if we stop
807 /* True means display ADDR_STRING to the user verbatim. */
808 bool display_canonical
= false;
809 /* Number of stops at this breakpoint that should be continued
810 automatically before really stopping. */
811 int ignore_count
= 0;
813 /* Number of stops at this breakpoint before it will be
815 int enable_count
= 0;
817 /* Chain of command lines to execute when this breakpoint is
819 counted_command_line commands
;
820 /* Stack depth (address of frame). If nonzero, break only if fp
822 struct frame_id frame_id
= null_frame_id
;
824 /* The program space used to set the breakpoint. This is only set
825 for breakpoints which are specific to a program space; for
826 non-thread-specific ordinary breakpoints this is NULL. */
827 program_space
*pspace
= NULL
;
829 /* The location specification we used to set the breakpoint. */
830 location_spec_up locspec
;
832 /* The filter that should be passed to decode_line_full when
833 re-setting this breakpoint. This may be NULL. */
834 gdb::unique_xmalloc_ptr
<char> filter
;
836 /* For a ranged breakpoint, the location specification we used to
837 find the end of the range. */
838 location_spec_up locspec_range_end
;
840 /* Architecture we used to set the breakpoint. */
841 struct gdbarch
*gdbarch
;
842 /* Language we used to set the breakpoint. */
843 enum language language
;
844 /* Input radix we used to set the breakpoint. */
846 /* String form of the breakpoint condition (malloc'd), or NULL if
847 there is no condition. */
848 gdb::unique_xmalloc_ptr
<char> cond_string
;
850 /* String form of extra parameters, or NULL if there are none.
852 gdb::unique_xmalloc_ptr
<char> extra_string
;
854 /* Holds the address of the related watchpoint_scope breakpoint when
855 using watchpoints on local variables (might the concept of a
856 related breakpoint be useful elsewhere, if not just call it the
857 watchpoint_scope breakpoint or something like that. FIXME). */
858 breakpoint
*related_breakpoint
;
860 /* Thread number for thread-specific breakpoint, or -1 if don't
864 /* Inferior number for inferior-specific breakpoint, or -1 if this
865 breakpoint is for all inferiors. */
868 /* Ada task number for task-specific breakpoint, or -1 if don't
872 /* Count of the number of times this breakpoint was taken, dumped
873 with the info, but not used for anything else. Useful for seeing
874 how many times you hit a break prior to the program aborting, so
875 you can back up to just before the abort. */
878 /* Is breakpoint's condition not yet parsed because we found no
879 location initially so had no context to parse the condition
881 int condition_not_parsed
= 0;
883 /* With a Python scripting enabled GDB, store a reference to the
884 Python object that has been associated with this breakpoint.
885 This is always NULL for a GDB that is not script enabled. It can
886 sometimes be NULL for enabled GDBs as not all breakpoint types
887 are tracked by the scripting language API. */
888 gdbpy_breakpoint_object
*py_bp_object
= NULL
;
890 /* Same as py_bp_object, but for Scheme. */
891 gdbscm_breakpoint_object
*scm_bp_object
= NULL
;
895 /* Helper for breakpoint_ops->print_recreate implementations. Prints
896 the "thread" or "task" condition of B, and then a newline.
898 Necessary because most breakpoint implementations accept
899 thread/task conditions at the end of the spec line, like "break foo
900 thread 1", which needs outputting before any breakpoint-type
901 specific extra command necessary for B's recreation. */
902 void print_recreate_thread (struct ui_file
*fp
) const;
904 /* Location(s) associated with this high-level breakpoint. */
905 bp_location_list m_locations
;
908 /* Abstract base class representing code breakpoints. User "break"
909 breakpoints, internal and momentary breakpoints, etc. IOW, any
910 kind of breakpoint whose locations are created from SALs. */
911 struct code_breakpoint
: public breakpoint
913 using breakpoint::breakpoint
;
915 /* Create a breakpoint with SALS as locations. Use LOCATION as a
916 description of the location, and COND_STRING as condition
917 expression. If LOCATION is NULL then create an "address
918 location" from the address in the SAL. */
919 code_breakpoint (struct gdbarch
*gdbarch
, bptype type
,
920 gdb::array_view
<const symtab_and_line
> sals
,
921 location_spec_up
&&locspec
,
922 gdb::unique_xmalloc_ptr
<char> filter
,
923 gdb::unique_xmalloc_ptr
<char> cond_string
,
924 gdb::unique_xmalloc_ptr
<char> extra_string
,
925 enum bpdisp disposition
,
926 int thread
, int task
, int inferior
, int ignore_count
,
928 int enabled
, unsigned flags
,
929 int display_canonical
);
931 ~code_breakpoint () override
= 0;
933 /* Add a location for SAL to this breakpoint. */
934 bp_location
*add_location (const symtab_and_line
&sal
);
936 void re_set () override
;
937 int insert_location (struct bp_location
*) override
;
938 int remove_location (struct bp_location
*,
939 enum remove_bp_reason reason
) override
;
940 int breakpoint_hit (const struct bp_location
*bl
,
941 const address_space
*aspace
,
943 const target_waitstatus
&ws
) override
;
947 /* Given the location spec, this method decodes it and returns the
948 SAL locations related to it. For ordinary breakpoints, it calls
949 `decode_line_full'. If SEARCH_PSPACE is not NULL, symbol search
950 is restricted to just that program space.
952 This function is called inside `location_spec_to_sals'. */
953 virtual std::vector
<symtab_and_line
> decode_location_spec
954 (location_spec
*locspec
,
955 struct program_space
*search_pspace
);
957 /* Helper method that does the basic work of re_set. */
958 void re_set_default ();
960 /* Find the SaL locations corresponding to the given LOCATION.
961 On return, FOUND will be 1 if any SaL was found, zero otherwise. */
963 std::vector
<symtab_and_line
> location_spec_to_sals
964 (location_spec
*locspec
,
965 struct program_space
*search_pspace
,
968 /* Helper for breakpoint and tracepoint breakpoint->mention
970 void say_where () const;
973 /* An instance of this type is used to represent a watchpoint,
974 a.k.a. a data breakpoint. */
976 struct watchpoint
: public breakpoint
978 using breakpoint::breakpoint
;
980 void re_set () override
;
981 int insert_location (struct bp_location
*) override
;
982 int remove_location (struct bp_location
*,
983 enum remove_bp_reason reason
) override
;
984 int breakpoint_hit (const struct bp_location
*bl
,
985 const address_space
*aspace
,
987 const target_waitstatus
&ws
) override
;
988 void check_status (struct bpstat
*bs
) override
;
989 int resources_needed (const struct bp_location
*) override
;
991 /* Tell whether we can downgrade from a hardware watchpoint to a software
992 one. If not, the user will not be able to enable the watchpoint when
993 there are not enough hardware resources available. */
994 virtual bool works_in_software_mode () const;
996 enum print_stop_action
print_it (const bpstat
*bs
) const override
;
997 void print_mention () const override
;
998 void print_recreate (struct ui_file
*fp
) const override
;
999 bool explains_signal (enum gdb_signal
) override
;
1001 /* Destructor for WATCHPOINT. */
1004 /* String form of exp to use for displaying to the user (malloc'd),
1006 gdb::unique_xmalloc_ptr
<char> exp_string
;
1007 /* String form to use for reparsing of EXP (malloc'd) or NULL. */
1008 gdb::unique_xmalloc_ptr
<char> exp_string_reparse
;
1010 /* The expression we are watching, or NULL if not a watchpoint. */
1012 /* The largest block within which it is valid, or NULL if it is
1013 valid anywhere (e.g. consists just of global symbols). */
1014 const struct block
*exp_valid_block
;
1015 /* The conditional expression if any. */
1016 expression_up cond_exp
;
1017 /* The largest block within which it is valid, or NULL if it is
1018 valid anywhere (e.g. consists just of global symbols). */
1019 const struct block
*cond_exp_valid_block
;
1020 /* Value of the watchpoint the last time we checked it, or NULL when
1021 we do not know the value yet or the value was not readable. VAL
1025 /* True if VAL is valid. If VAL_VALID is set but VAL is NULL,
1026 then an error occurred reading the value. */
1029 /* When watching the location of a bitfield, contains the offset and size of
1030 the bitfield. Otherwise contains 0. */
1034 /* Holds the frame address which identifies the frame this
1035 watchpoint should be evaluated in, or `null' if the watchpoint
1036 should be evaluated on the outermost frame. */
1037 struct frame_id watchpoint_frame
;
1039 /* Holds the thread which identifies the frame this watchpoint
1040 should be considered in scope for, or `null_ptid' if the
1041 watchpoint should be evaluated in all threads. */
1042 ptid_t watchpoint_thread
;
1044 /* For hardware watchpoints, the triggered status according to the
1046 enum watchpoint_triggered watchpoint_triggered
;
1048 /* Whether this watchpoint is exact (see
1049 target_exact_watchpoints). */
1052 /* The mask address for a masked hardware watchpoint. */
1053 CORE_ADDR hw_wp_mask
;
1056 /* Return true if BPT is either a software breakpoint or a hardware
1059 extern bool is_breakpoint (const struct breakpoint
*bpt
);
1061 /* Return true if BPT is of any watchpoint kind, hardware or
1064 extern bool is_watchpoint (const struct breakpoint
*bpt
);
1066 /* Return true if BPT is a C++ exception catchpoint (catch
1067 catch/throw/rethrow). */
1069 extern bool is_exception_catchpoint (breakpoint
*bp
);
1071 /* An instance of this type is used to represent all kinds of
1074 struct tracepoint
: public code_breakpoint
1076 using code_breakpoint::code_breakpoint
;
1078 int breakpoint_hit (const struct bp_location
*bl
,
1079 const address_space
*aspace
, CORE_ADDR bp_addr
,
1080 const target_waitstatus
&ws
) override
;
1081 void print_one_detail (struct ui_out
*uiout
) const override
;
1082 void print_mention () const override
;
1083 void print_recreate (struct ui_file
*fp
) const override
;
1085 /* Number of times this tracepoint should single-step and collect
1087 long step_count
= 0;
1089 /* Number of times this tracepoint should be hit before
1090 disabling/ending. */
1093 /* The number of the tracepoint on the target. */
1094 int number_on_target
= 0;
1096 /* The total space taken by all the trace frames for this
1098 ULONGEST traceframe_usage
= 0;
1100 /* The static tracepoint marker id, if known. */
1101 std::string static_trace_marker_id
;
1103 /* LTTng/UST allow more than one marker with the same ID string,
1104 although it unadvised because it confuses tools. When setting
1105 static tracepoints by marker ID, this will record the index in
1106 the array of markers we found for the given marker ID for which
1107 this static tracepoint corresponds. When resetting breakpoints,
1108 we will use this index to try to find the same marker again. */
1109 int static_trace_marker_id_idx
= 0;
1112 /* The abstract base class for catchpoints. */
1114 struct catchpoint
: public breakpoint
1116 /* If TEMP is true, then make the breakpoint temporary. If
1117 COND_STRING is not NULL, then store it in the breakpoint. */
1118 catchpoint (struct gdbarch
*gdbarch
, bool temp
, const char *cond_string
);
1120 ~catchpoint () override
= 0;
1124 /* The following stuff is an abstract data type "bpstat" ("breakpoint
1125 status"). This provides the ability to determine whether we have
1126 stopped at a breakpoint, and what we should do about it. */
1128 /* Clears a chain of bpstat, freeing storage
1130 extern void bpstat_clear (bpstat
**);
1132 /* Return a copy of a bpstat. Like "bs1 = bs2" but all storage that
1133 is part of the bpstat is copied as well. */
1134 extern bpstat
*bpstat_copy (bpstat
*);
1136 /* Build the (raw) bpstat chain for the stop information given by ASPACE,
1137 BP_ADDR, and WS. Returns the head of the bpstat chain. */
1139 extern bpstat
*build_bpstat_chain (const address_space
*aspace
,
1141 const target_waitstatus
&ws
);
1143 /* Get a bpstat associated with having just stopped at address
1144 BP_ADDR in thread PTID. STOP_CHAIN may be supplied as a previously
1145 computed stop chain or NULL, in which case the stop chain will be
1146 computed using build_bpstat_chain.
1148 Determine whether we stopped at a breakpoint, etc, or whether we
1149 don't understand this stop. Result is a chain of bpstat's such
1152 if we don't understand the stop, the result is a null pointer.
1154 if we understand why we stopped, the result is not null.
1156 Each element of the chain refers to a particular breakpoint or
1157 watchpoint at which we have stopped. (We may have stopped for
1158 several reasons concurrently.)
1160 Each element of the chain has valid next, breakpoint_at,
1161 commands, FIXME??? fields.
1163 watchpoints_triggered must be called beforehand to set up each
1164 watchpoint's watchpoint_triggered value.
1168 extern bpstat
*bpstat_stop_status (const address_space
*aspace
,
1169 CORE_ADDR pc
, thread_info
*thread
,
1170 const target_waitstatus
&ws
,
1171 bpstat
*stop_chain
= nullptr);
1173 /* Like bpstat_stop_status, but clears all watchpoints'
1174 watchpoint_triggered flag. Unlike with bpstat_stop_status, there's
1175 no need to call watchpoint_triggered beforehand. You'll typically
1176 use this variant when handling a known-non-watchpoint event, like a
1177 fork or exec event. */
1179 extern bpstat
*bpstat_stop_status_nowatch (const address_space
*aspace
,
1181 thread_info
*thread
,
1182 const target_waitstatus
&ws
);
1186 /* This bpstat_what stuff tells wait_for_inferior what to do with a
1187 breakpoint (a challenging task).
1189 The enum values order defines priority-like order of the actions.
1190 Once you've decided that some action is appropriate, you'll never
1191 go back and decide something of a lower priority is better. Each
1192 of these actions is mutually exclusive with the others. That
1193 means, that if you find yourself adding a new action class here and
1194 wanting to tell GDB that you have two simultaneous actions to
1195 handle, something is wrong, and you probably don't actually need a
1198 Note that a step resume breakpoint overrides another breakpoint of
1199 signal handling (see comment in wait_for_inferior at where we set
1200 the step_resume breakpoint). */
1202 enum bpstat_what_main_action
1204 /* Perform various other tests; that is, this bpstat does not
1205 say to perform any action (e.g. failed watchpoint and nothing
1207 BPSTAT_WHAT_KEEP_CHECKING
,
1209 /* Remove breakpoints, single step once, then put them back in and
1210 go back to what we were doing. It's possible that this should
1211 be removed from the main_action and put into a separate field,
1212 to more cleanly handle
1213 BPSTAT_WHAT_CLEAR_LONGJMP_RESUME_SINGLE. */
1216 /* Set longjmp_resume breakpoint, remove all other breakpoints,
1217 and continue. The "remove all other breakpoints" part is
1218 required if we are also stepping over another breakpoint as
1219 well as doing the longjmp handling. */
1220 BPSTAT_WHAT_SET_LONGJMP_RESUME
,
1222 /* Clear longjmp_resume breakpoint, then handle as
1223 BPSTAT_WHAT_KEEP_CHECKING. */
1224 BPSTAT_WHAT_CLEAR_LONGJMP_RESUME
,
1226 /* Clear step resume breakpoint, and keep checking. */
1227 BPSTAT_WHAT_STEP_RESUME
,
1229 /* Rather than distinguish between noisy and silent stops here, it
1230 might be cleaner to have bpstat_print make that decision (also
1231 taking into account stop_print_frame and source_only). But the
1232 implications are a bit scary (interaction with auto-displays,
1233 etc.), so I won't try it. */
1235 /* Stop silently. */
1236 BPSTAT_WHAT_STOP_SILENT
,
1238 /* Stop and print. */
1239 BPSTAT_WHAT_STOP_NOISY
,
1241 /* Clear step resume breakpoint, and keep checking. High-priority
1242 step-resume breakpoints are used when even if there's a user
1243 breakpoint at the current PC when we set the step-resume
1244 breakpoint, we don't want to re-handle any breakpoint other
1245 than the step-resume when it's hit; instead we want to move
1246 past the breakpoint. This is used in the case of skipping
1248 BPSTAT_WHAT_HP_STEP_RESUME
,
1251 /* An enum indicating the kind of "stack dummy" stop. This is a bit
1252 of a misnomer because only one kind of truly a stack dummy. */
1253 enum stop_stack_kind
1255 /* We didn't stop at a stack dummy breakpoint. */
1258 /* Stopped at a stack dummy. */
1261 /* Stopped at std::terminate. */
1267 enum bpstat_what_main_action main_action
;
1269 /* Did we hit a call dummy breakpoint? This only goes with a
1270 main_action of BPSTAT_WHAT_STOP_SILENT or
1271 BPSTAT_WHAT_STOP_NOISY (the concept of continuing from a call
1272 dummy without popping the frame is not a useful one). */
1273 enum stop_stack_kind call_dummy
;
1275 /* Used for BPSTAT_WHAT_SET_LONGJMP_RESUME and
1276 BPSTAT_WHAT_CLEAR_LONGJMP_RESUME. True if we are handling a
1277 longjmp, false if we are handling an exception. */
1281 /* Tell what to do about this bpstat. */
1282 struct bpstat_what
bpstat_what (bpstat
*);
1284 /* Run breakpoint event callbacks associated with the breakpoints that
1286 extern void bpstat_run_callbacks (bpstat
*bs_head
);
1288 /* Find the bpstat associated with a breakpoint. NULL otherwise. */
1289 bpstat
*bpstat_find_breakpoint (bpstat
*, struct breakpoint
*);
1291 /* True if a signal that we got in target_wait() was due to
1292 circumstances explained by the bpstat; the signal is therefore not
1294 extern bool bpstat_explains_signal (bpstat
*, enum gdb_signal
);
1296 /* True if this bpstat causes a stop. */
1297 extern bool bpstat_causes_stop (bpstat
*);
1299 /* True if we should step constantly (e.g. watchpoints on machines
1300 without hardware support). This isn't related to a specific bpstat,
1301 just to things like whether watchpoints are set. */
1302 extern bool bpstat_should_step ();
1304 /* Print a message indicating what happened. */
1305 extern enum print_stop_action
bpstat_print (bpstat
*bs
, target_waitkind kind
);
1307 /* Put in *NUM the breakpoint number of the first breakpoint we are
1308 stopped at. *BSP upon return is a bpstat which points to the
1309 remaining breakpoints stopped at (but which is not guaranteed to be
1310 good for anything but further calls to bpstat_num).
1312 Return 0 if passed a bpstat which does not indicate any breakpoints.
1313 Return -1 if stopped at a breakpoint that has been deleted since
1315 Return 1 otherwise. */
1316 extern int bpstat_num (bpstat
**, int *);
1318 /* If BS indicates a breakpoint and this breakpoint has several code locations,
1319 return the location number of BS, otherwise return 0. */
1321 extern int bpstat_locno (const bpstat
*bs
);
1323 /* Print BS breakpoint number optionally followed by a . and breakpoint locno.
1325 For a breakpoint with only one code location, outputs the signed field
1326 "bkptno" breakpoint number of BS (as returned by bpstat_num).
1327 If BS has several code locations, outputs a '.' character followed by
1328 the signed field "locno" (as returned by bpstat_locno). */
1330 extern void print_num_locno (const bpstat
*bs
, struct ui_out
*);
1332 /* Perform actions associated with the stopped inferior. Actually, we
1333 just use this for breakpoint commands. Perhaps other actions will
1334 go here later, but this is executed at a late time (from the
1336 extern void bpstat_do_actions (void);
1338 /* Modify all entries of STOP_BPSTAT of INFERIOR_PTID so that the actions will
1339 not be performed. */
1340 extern void bpstat_clear_actions (void);
1342 /* Implementation: */
1344 /* Values used to tell the printing routine how to behave for this
1348 /* This is used when we want to do a normal printing of the reason
1349 for stopping. The output will depend on the type of eventpoint
1350 we are dealing with. This is the default value, most commonly
1353 /* This is used when nothing should be printed for this bpstat
1356 /* This is used when everything which needs to be printed has
1357 already been printed. But we still want to print the frame. */
1364 bpstat (struct bp_location
*bl
, bpstat
***bs_link_pointer
);
1366 bpstat (const bpstat
&);
1367 bpstat
&operator= (const bpstat
&) = delete;
1369 /* Linked list because there can be more than one breakpoint at
1370 the same place, and a bpstat reflects the fact that all have
1374 /* Location that caused the stop. Locations are refcounted, so
1375 this will never be NULL. Note that this location may end up
1376 detached from a breakpoint, but that does not necessary mean
1377 that the struct breakpoint is gone. E.g., consider a
1378 watchpoint with a condition that involves an inferior function
1379 call. Watchpoint locations are recreated often (on resumes,
1380 hence on infcalls too). Between creating the bpstat and after
1381 evaluating the watchpoint condition, this location may hence
1382 end up detached from its original owner watchpoint, even though
1383 the watchpoint is still listed. If it's condition evaluates as
1384 true, we still want this location to cause a stop, and we will
1385 still need to know which watchpoint it was originally attached.
1386 What this means is that we should not (in most cases) follow
1387 the `bpstat->bp_location->owner' link, but instead use the
1388 `breakpoint_at' field below. */
1389 bp_location_ref_ptr bp_location_at
;
1391 /* Breakpoint that caused the stop. This is nullified if the
1392 breakpoint ends up being deleted. See comments on
1393 `bp_location_at' above for why do we need this field instead of
1394 following the location's owner. */
1395 struct breakpoint
*breakpoint_at
;
1397 /* The associated command list. */
1398 counted_command_line commands
;
1400 /* Old value associated with a watchpoint. */
1401 value_ref_ptr old_val
;
1403 /* True if this breakpoint tells us to print the frame. */
1406 /* True if this breakpoint tells us to stop. */
1409 /* Tell bpstat_print and print_bp_stop_message how to print stuff
1410 associated with this element of the bpstat chain. */
1411 enum bp_print_how print_it
;
1422 /* The possible return values for breakpoint_here_p.
1423 We guarantee that zero always means "no breakpoint here". */
1424 enum breakpoint_here
1426 no_breakpoint_here
= 0,
1427 ordinary_breakpoint_here
,
1428 permanent_breakpoint_here
1432 /* Prototypes for breakpoint-related functions. */
1434 extern enum breakpoint_here
breakpoint_here_p (const address_space
*,
1437 /* Return true if an enabled breakpoint exists in the range defined by
1438 ADDR and LEN, in ASPACE. */
1439 extern int breakpoint_in_range_p (const address_space
*aspace
,
1440 CORE_ADDR addr
, ULONGEST len
);
1442 extern int moribund_breakpoint_here_p (const address_space
*, CORE_ADDR
);
1444 extern int breakpoint_inserted_here_p (const address_space
*,
1447 extern int software_breakpoint_inserted_here_p (const address_space
*,
1450 /* Return non-zero iff there is a hardware breakpoint inserted at
1452 extern int hardware_breakpoint_inserted_here_p (const address_space
*,
1455 /* Check whether any location of BP is inserted at PC. */
1457 extern int breakpoint_has_location_inserted_here (struct breakpoint
*bp
,
1458 const address_space
*aspace
,
1461 extern int single_step_breakpoint_inserted_here_p (const address_space
*,
1464 /* Returns true if there's a hardware watchpoint or access watchpoint
1465 inserted in the range defined by ADDR and LEN. */
1466 extern int hardware_watchpoint_inserted_in_range (const address_space
*,
1470 /* Returns true if {ASPACE1,ADDR1} and {ASPACE2,ADDR2} represent the
1471 same breakpoint location. In most targets, this can only be true
1472 if ASPACE1 matches ASPACE2. On targets that have global
1473 breakpoints, the address space doesn't really matter. */
1475 extern int breakpoint_address_match (const address_space
*aspace1
,
1477 const address_space
*aspace2
,
1480 extern void until_break_command (const char *, int, int);
1482 /* Initialize a struct bp_location. */
1484 extern void update_breakpoint_locations
1485 (code_breakpoint
*b
,
1486 struct program_space
*filter_pspace
,
1487 gdb::array_view
<const symtab_and_line
> sals
,
1488 gdb::array_view
<const symtab_and_line
> sals_end
);
1490 extern void breakpoint_re_set (void);
1492 extern void breakpoint_re_set_thread (struct breakpoint
*);
1494 extern void delete_breakpoint (struct breakpoint
*);
1496 struct breakpoint_deleter
1498 void operator() (struct breakpoint
*b
) const
1500 delete_breakpoint (b
);
1504 typedef std::unique_ptr
<struct breakpoint
, breakpoint_deleter
> breakpoint_up
;
1506 extern breakpoint_up set_momentary_breakpoint
1507 (struct gdbarch
*, struct symtab_and_line
, struct frame_id
, enum bptype
);
1509 extern breakpoint_up set_momentary_breakpoint_at_pc
1510 (struct gdbarch
*, CORE_ADDR pc
, enum bptype type
);
1512 extern struct breakpoint
*clone_momentary_breakpoint (struct breakpoint
*bpkt
);
1514 extern void set_ignore_count (int, int, int);
1516 /* Clear the "inserted" flag in all breakpoint locations of INF's program space
1517 and delete any breakpoints which should go away between runs of the program.
1519 Plus other such housekeeping that has to be done for breakpoints
1522 Note: this function gets called at the end of a run (by
1523 generic_mourn_inferior) and when a run begins (by
1524 init_wait_for_inferior). */
1526 extern void breakpoint_init_inferior (inferior
*inf
, inf_context context
);
1528 extern void breakpoint_auto_delete (bpstat
*);
1530 /* Return the chain of command lines to execute when this breakpoint
1532 extern struct command_line
*breakpoint_commands (struct breakpoint
*b
);
1534 /* Return a string image of DISP. The string is static, and thus should
1535 NOT be deallocated after use. */
1536 const char *bpdisp_text (enum bpdisp disp
);
1538 extern void break_command (const char *, int);
1540 extern void watch_command_wrapper (const char *, int, bool);
1541 extern void awatch_command_wrapper (const char *, int, bool);
1542 extern void rwatch_command_wrapper (const char *, int, bool);
1543 extern void tbreak_command (const char *, int);
1545 extern const struct breakpoint_ops code_breakpoint_ops
;
1547 /* Arguments to pass as context to some catch command handlers. */
1548 #define CATCH_PERMANENT ((void *) (uintptr_t) 0)
1549 #define CATCH_TEMPORARY ((void *) (uintptr_t) 1)
1551 /* Like add_cmd, but add the command to both the "catch" and "tcatch"
1552 lists, and pass some additional user data to the command
1556 add_catch_command (const char *name
, const char *docstring
,
1557 cmd_func_ftype
*func
,
1558 completer_ftype
*completer
,
1559 void *user_data_catch
,
1560 void *user_data_tcatch
);
1562 /* Add breakpoint B on the breakpoint list, and notify the user, the
1563 target and breakpoint_created observers of its existence. If
1564 INTERNAL is non-zero, the breakpoint number will be allocated from
1565 the internal breakpoint count. If UPDATE_GLL is non-zero,
1566 update_global_location_list will be called.
1568 Takes ownership of B, and returns a non-owning reference to it. */
1570 extern breakpoint
*install_breakpoint
1571 (int internal
, std::unique_ptr
<breakpoint
> &&b
, int update_gll
);
1573 /* Returns the breakpoint ops appropriate for use with with LOCSPEC
1574 and according to IS_TRACEPOINT. Use this to ensure, for example,
1575 that you pass the correct ops to create_breakpoint for probe
1576 location specs. If LOCSPEC is NULL, returns
1577 code_breakpoint_ops. */
1579 extern const struct breakpoint_ops
*breakpoint_ops_for_location_spec
1580 (const location_spec
*locspec
, bool is_tracepoint
);
1582 /* Flags that can be passed down to create_breakpoint, etc., to affect
1583 breakpoint creation in several ways. */
1585 enum breakpoint_create_flags
1587 /* We're adding a breakpoint to our tables that is already
1588 inserted in the target. */
1589 CREATE_BREAKPOINT_FLAGS_INSERTED
= 1 << 0
1592 /* Set a breakpoint. This function is shared between CLI and MI
1593 functions for setting a breakpoint at LOCSPEC.
1595 This function has two major modes of operations, selected by the
1596 PARSE_EXTRA and WANTED_TYPE parameters.
1598 When WANTED_TYPE is not bp_dprintf the following rules apply:
1600 If PARSE_EXTRA is zero, LOCSPEC is just the breakpoint's location
1601 spec, with condition, thread, and extra string specified by the
1602 COND_STRING, THREAD, and EXTRA_STRING parameters.
1604 If PARSE_EXTRA is non-zero, this function will attempt to extract the
1605 condition, thread, and extra string from EXTRA_STRING, ignoring the
1606 similarly named parameters.
1608 When WANTED_TYPE is bp_dprintf the following rules apply:
1610 PARSE_EXTRA must always be zero, LOCSPEC is just the breakpoint's
1611 location spec, with condition, thread, and extra string (which
1612 contains the dprintf format and arguments) specified by the
1613 COND_STRING, THREAD, and EXTRA_STRING parameters.
1615 If FORCE_CONDITION is true, the condition (in COND_STRING) is accepted
1616 even when it is invalid at all of the locations. However, if
1617 PARSE_EXTRA is non-zero and WANTED_TYPE is not bp_dprintf, the
1618 FORCE_CONDITION parameter is ignored and the corresponding argument is
1619 parsed from EXTRA_STRING.
1621 The THREAD should be a global thread number, the created breakpoint will
1622 only apply for that thread. If the breakpoint should apply for all
1623 threads then pass -1. However, if PARSE_EXTRA is non-zero and
1624 WANTED_TYPE is not bp_dprintf, then the THREAD parameter is ignored and
1625 an optional thread number will be parsed from EXTRA_STRING.
1627 The INFERIOR should be a global inferior number, the created breakpoint
1628 will only apply for that inferior. If the breakpoint should apply for
1629 all inferiors then pass -1. However, if PARSE_EXTRA is non-zero and
1630 WANTED_TYPE is not bp_dprintf, then the INFERIOR parameter is ignored
1631 and an optional inferior number will be parsed from EXTRA_STRING.
1633 At most one of THREAD and INFERIOR should be set to a value other than
1634 -1; breakpoints can be thread specific, or inferior specific, but not
1637 If INTERNAL is non-zero, the breakpoint number will be allocated
1638 from the internal breakpoint count.
1640 Returns true if any breakpoint was created; false otherwise. */
1642 extern int create_breakpoint (struct gdbarch
*gdbarch
,
1643 struct location_spec
*locspec
,
1644 const char *cond_string
, int thread
,
1646 const char *extra_string
,
1647 bool force_condition
,
1649 int tempflag
, enum bptype wanted_type
,
1651 enum auto_boolean pending_break_support
,
1652 const struct breakpoint_ops
*ops
,
1655 int internal
, unsigned flags
);
1657 extern void insert_breakpoints (void);
1659 extern int remove_breakpoints (void);
1661 /* Remove breakpoints of inferior INF. */
1663 extern void remove_breakpoints_inf (inferior
*inf
);
1665 /* This function can be used to update the breakpoint package's state
1666 after an exec() system call has been executed.
1668 This function causes the following:
1670 - All eventpoints are marked "not inserted".
1671 - All eventpoints with a symbolic address are reset such that
1672 the symbolic address must be reevaluated before the eventpoints
1674 - The solib breakpoints are explicitly removed from the breakpoint
1676 - A step-resume breakpoint, if any, is explicitly removed from the
1678 - All eventpoints without a symbolic address are removed from the
1680 extern void update_breakpoints_after_exec (void);
1682 /* This function can be used to physically remove hardware breakpoints
1683 and watchpoints from the specified traced inferior process, without
1684 modifying the breakpoint package's state. This can be useful for
1685 those targets which support following the processes of a fork() or
1686 vfork() system call, when one of the resulting two processes is to
1687 be detached and allowed to run free.
1689 It is an error to use this function on the process whose id is
1691 extern int detach_breakpoints (ptid_t ptid
);
1693 /* This function is called when program space PSPACE is about to be
1694 deleted. It takes care of updating breakpoints to not reference
1695 this PSPACE anymore. */
1696 extern void breakpoint_program_space_exit (struct program_space
*pspace
);
1698 extern void set_longjmp_breakpoint (struct thread_info
*tp
,
1699 struct frame_id frame
);
1700 extern void delete_longjmp_breakpoint (int thread
);
1702 /* Mark all longjmp breakpoints from THREAD for later deletion. */
1703 extern void delete_longjmp_breakpoint_at_next_stop (int thread
);
1705 extern struct breakpoint
*set_longjmp_breakpoint_for_call_dummy (void);
1706 extern void check_longjmp_breakpoint_for_call_dummy (struct thread_info
*tp
);
1708 extern void enable_overlay_breakpoints (void);
1709 extern void disable_overlay_breakpoints (void);
1711 extern void set_std_terminate_breakpoint (void);
1712 extern void delete_std_terminate_breakpoint (void);
1714 /* These functions respectively disable or reenable all currently
1715 enabled watchpoints. When disabled, the watchpoints are marked
1716 call_disabled. When re-enabled, they are marked enabled.
1718 The intended client of these functions is call_function_by_hand.
1720 The inferior must be stopped, and all breakpoints removed, when
1721 these functions are used.
1723 The need for these functions is that on some targets (e.g., HP-UX),
1724 gdb is unable to unwind through the dummy frame that is pushed as
1725 part of the implementation of a call command. Watchpoints can
1726 cause the inferior to stop in places where this frame is visible,
1727 and that can cause execution control to become very confused.
1729 Note that if a user sets breakpoints in an interactively called
1730 function, the call_disabled watchpoints will have been re-enabled
1731 when the first such breakpoint is reached. However, on targets
1732 that are unable to unwind through the call dummy frame, watches
1733 of stack-based storage may then be deleted, because gdb will
1734 believe that their watched storage is out of scope. (Sigh.) */
1735 extern void disable_watchpoints_before_interactive_call_start (void);
1737 extern void enable_watchpoints_after_interactive_call_stop (void);
1739 /* These functions disable and re-enable all breakpoints during
1740 inferior startup. They are intended to be called from solib
1741 code where necessary. This is needed on platforms where the
1742 main executable is relocated at some point during startup
1743 processing, making breakpoint addresses invalid.
1745 If additional breakpoints are created after the routine
1746 disable_breakpoints_before_startup but before the routine
1747 enable_breakpoints_after_startup was called, they will also
1748 be marked as disabled. */
1749 extern void disable_breakpoints_before_startup (void);
1750 extern void enable_breakpoints_after_startup (void);
1752 /* For script interpreters that need to define breakpoint commands
1753 after they've already read the commands into a struct
1755 extern enum command_control_type commands_from_control_command
1756 (const char *arg
, struct command_line
*cmd
);
1758 extern void clear_breakpoint_hit_counts (void);
1760 extern struct breakpoint
*get_breakpoint (int num
);
1762 /* The following are for displays, which aren't really breakpoints,
1763 but here is as good a place as any for them. */
1765 extern void disable_current_display (void);
1767 extern void do_displays (void);
1769 extern void disable_display (int);
1771 extern void clear_displays (void);
1773 extern void disable_breakpoint (struct breakpoint
*);
1775 extern void enable_breakpoint (struct breakpoint
*);
1777 extern void breakpoint_set_commands (struct breakpoint
*b
,
1778 counted_command_line
&&commands
);
1780 extern void breakpoint_set_silent (struct breakpoint
*b
, int silent
);
1782 /* Set the thread for this breakpoint. If THREAD is -1, make the
1783 breakpoint work for any thread. Passing a value other than -1 for
1784 THREAD should only be done if b->task is 0; it is not valid to try and
1785 set both a thread and task restriction on a breakpoint. */
1787 extern void breakpoint_set_thread (struct breakpoint
*b
, int thread
);
1789 /* Set the inferior for breakpoint B to INFERIOR. If INFERIOR is -1, make
1790 the breakpoint work for any inferior. */
1792 extern void breakpoint_set_inferior (struct breakpoint
*b
, int inferior
);
1794 /* Set the task for this breakpoint. If TASK is -1, make the breakpoint
1795 work for any task. Passing a value other than -1 for TASK should only
1796 be done if b->thread is -1; it is not valid to try and set both a thread
1797 and task restriction on a breakpoint. */
1799 extern void breakpoint_set_task (struct breakpoint
*b
, int task
);
1801 /* Clear the "inserted" flag in all breakpoints locations in PSPACE. */
1803 extern void mark_breakpoints_out (program_space
*pspace
);
1805 extern struct breakpoint
*create_jit_event_breakpoint (struct gdbarch
*,
1808 extern struct breakpoint
*create_solib_event_breakpoint (struct gdbarch
*,
1811 /* Create an solib event breakpoint at ADDRESS in the current program
1812 space, and immediately try to insert it. Returns a pointer to the
1813 breakpoint on success. Deletes the new breakpoint and returns NULL
1814 if inserting the breakpoint fails. */
1815 extern struct breakpoint
*create_and_insert_solib_event_breakpoint
1816 (struct gdbarch
*gdbarch
, CORE_ADDR address
);
1818 extern struct breakpoint
*create_thread_event_breakpoint (struct gdbarch
*,
1821 extern void remove_jit_event_breakpoints (void);
1823 extern void remove_solib_event_breakpoints (void);
1825 /* Mark solib event breakpoints of the current program space with
1826 delete at next stop disposition. */
1827 extern void remove_solib_event_breakpoints_at_next_stop (void);
1829 /* Disable any breakpoints that are on code in shared libraries in PSPACE.
1830 Only apply to enabled breakpoints, disabled ones can just stay disabled. */
1832 extern void disable_breakpoints_in_shlibs (program_space
*pspace
);
1834 /* This function returns true if B is a catchpoint. */
1836 extern bool is_catchpoint (struct breakpoint
*b
);
1838 /* Shared helper function (MI and CLI) for creating and installing
1839 a shared object event catchpoint. If IS_LOAD is true then
1840 the events to be caught are load events, otherwise they are
1841 unload events. If IS_TEMP is true the catchpoint is a
1842 temporary one. If ENABLED is true the catchpoint is
1843 created in an enabled state. */
1845 extern void add_solib_catchpoint (const char *arg
, bool is_load
, bool is_temp
,
1848 /* Create and insert a new software single step breakpoint for the
1849 current thread. May be called multiple times; each time will add a
1850 new location to the set of potential addresses the next instruction
1852 extern void insert_single_step_breakpoint (struct gdbarch
*,
1853 const address_space
*,
1856 /* Insert all software single step breakpoints for the current frame.
1857 Return true if any software single step breakpoints are inserted,
1858 otherwise, return false. */
1859 extern int insert_single_step_breakpoints (struct gdbarch
*);
1861 /* Check whether any hardware watchpoints have triggered or not,
1862 according to the target, and record it in each watchpoint's
1863 'watchpoint_triggered' field. */
1864 int watchpoints_triggered (const target_waitstatus
&);
1866 /* Helper for transparent breakpoint hiding for memory read and write
1869 Update one of READBUF or WRITEBUF with either the shadows
1870 (READBUF), or the breakpoint instructions (WRITEBUF) of inserted
1871 breakpoints at the memory range defined by MEMADDR and extending
1872 for LEN bytes. If writing, then WRITEBUF is a copy of WRITEBUF_ORG
1874 extern void breakpoint_xfer_memory (gdb_byte
*readbuf
, gdb_byte
*writebuf
,
1875 const gdb_byte
*writebuf_org
,
1876 ULONGEST memaddr
, LONGEST len
);
1878 /* Return true if breakpoints should be inserted now. That'll be the
1881 - the target has global breakpoints.
1883 - "breakpoint always-inserted" is on, and the target has
1886 - threads are executing.
1888 extern int breakpoints_should_be_inserted_now (void);
1890 /* Called each time new event from target is processed.
1891 Retires previously deleted breakpoint locations that
1892 in our opinion won't ever trigger. */
1893 extern void breakpoint_retire_moribund (void);
1895 /* Set break condition of breakpoint B to EXP.
1896 If FORCE, define the condition even if it is invalid in
1897 all of the breakpoint locations. */
1898 extern void set_breakpoint_condition (struct breakpoint
*b
, const char *exp
,
1899 int from_tty
, bool force
);
1901 /* Set break condition for the breakpoint with number BPNUM to EXP.
1902 Raise an error if no breakpoint with the given number is found.
1903 Also raise an error if the breakpoint already has stop conditions.
1904 If FORCE, define the condition even if it is invalid in
1905 all of the breakpoint locations. */
1906 extern void set_breakpoint_condition (int bpnum
, const char *exp
,
1907 int from_tty
, bool force
);
1909 /* Checks if we are catching syscalls or not. */
1910 extern bool catch_syscall_enabled ();
1912 /* Checks if we are catching syscalls with the specific
1913 syscall_number. Used for "filtering" the catchpoints.
1914 Returns false if not, true if we are. */
1915 extern bool catching_syscall_number (int syscall_number
);
1917 /* Return a tracepoint with the given number if found. */
1918 extern struct tracepoint
*get_tracepoint (int num
);
1920 extern struct tracepoint
*get_tracepoint_by_number_on_target (int num
);
1922 /* Find a tracepoint by parsing a number in the supplied string. */
1923 extern struct tracepoint
*
1924 get_tracepoint_by_number (const char **arg
,
1925 number_or_range_parser
*parser
);
1927 /* Return true if B is of tracepoint kind. */
1929 extern bool is_tracepoint (const struct breakpoint
*b
);
1931 /* Return a vector of all static tracepoints defined at ADDR. */
1932 extern std::vector
<breakpoint
*> static_tracepoints_here (CORE_ADDR addr
);
1934 /* Create an instance of this to start registering breakpoint numbers
1935 for a later "commands" command. */
1937 class scoped_rbreak_breakpoints
1941 scoped_rbreak_breakpoints ();
1942 ~scoped_rbreak_breakpoints ();
1944 DISABLE_COPY_AND_ASSIGN (scoped_rbreak_breakpoints
);
1947 /* Breakpoint linked list iterator. */
1949 using breakpoint_list
= intrusive_list
<breakpoint
>;
1951 using breakpoint_iterator
= breakpoint_list::iterator
;
1953 /* Breakpoint linked list range. */
1955 using breakpoint_range
= iterator_range
<breakpoint_iterator
>;
1957 /* Return a range to iterate over all breakpoints. */
1959 breakpoint_range
all_breakpoints ();
1961 /* Breakpoint linked list range, safe against deletion of the current
1962 breakpoint while iterating. */
1964 using breakpoint_safe_range
= basic_safe_range
<breakpoint_range
>;
1966 /* Return a range to iterate over all breakpoints. This range is safe against
1967 deletion of the current breakpoint while iterating. */
1969 breakpoint_safe_range
all_breakpoints_safe ();
1971 /* Breakpoint filter to only keep tracepoints. */
1973 struct tracepoint_filter
1975 bool operator() (breakpoint
&b
)
1976 { return is_tracepoint (&b
); }
1979 /* Breakpoint linked list iterator, filtering to only keep tracepoints. */
1981 using tracepoint_iterator
1982 = filtered_iterator
<breakpoint_iterator
, tracepoint_filter
>;
1984 /* Breakpoint linked list range, filtering to only keep tracepoints. */
1986 using tracepoint_range
= iterator_range
<tracepoint_iterator
>;
1988 /* Return a range to iterate over all tracepoints. */
1990 tracepoint_range
all_tracepoints ();
1992 /* Return a range to iterate over all breakpoint locations. */
1994 const std::vector
<bp_location
*> &all_bp_locations ();
1996 /* Nonzero if the specified PC cannot be a location where functions
1997 have been inlined. */
1999 extern int pc_at_non_inline_function (const address_space
*aspace
,
2001 const target_waitstatus
&ws
);
2003 extern int user_breakpoint_p (struct breakpoint
*);
2005 /* Return true if this breakpoint is pending, false if not. */
2006 extern int pending_breakpoint_p (struct breakpoint
*);
2008 /* Attempt to determine architecture of location identified by SAL. */
2009 extern struct gdbarch
*get_sal_arch (struct symtab_and_line sal
);
2011 extern void breakpoint_free_objfile (struct objfile
*objfile
);
2013 extern const char *ep_parse_optional_if_clause (const char **arg
);
2015 /* Print the "Thread ID hit" part of "Thread ID hit Breakpoint N" to
2016 UIOUT iff debugging multiple threads. */
2017 extern void maybe_print_thread_hit_breakpoint (struct ui_out
*uiout
);
2019 /* Print the specified breakpoint. */
2020 extern void print_breakpoint (breakpoint
*bp
);
2022 /* Command element for the 'commands' command. */
2023 extern cmd_list_element
*commands_cmd_element
;
2025 /* Whether to use the fixed output when printing information about a
2026 multi-location breakpoint (see PR 9659). */
2028 extern bool fix_multi_location_breakpoint_output_globally
;
2030 /* Whether to use the fixed output when printing information about
2031 commands attached to a breakpoint. */
2033 extern bool fix_breakpoint_script_output_globally
;
2035 /* Deal with "catch catch", "catch throw", and "catch rethrow" commands and
2036 the MI equivalents. Sets up to catch events of type EX_EVENT. When
2037 TEMPFLAG is true only the next matching event is caught after which the
2038 catch-point is deleted. If REGEX is not NULL then only exceptions whose
2039 type name matches REGEX will trigger the event. */
2041 extern void catch_exception_event (enum exception_event_kind ex_event
,
2042 const char *regex
, bool tempflag
,
2045 /* A helper function that prints a shared library stopped event.
2046 IS_CATCHPOINT is true if the event is due to a "catch load"
2047 catchpoint, false otherwise. */
2049 extern void print_solib_event (bool is_catchpoint
);
2051 /* Print a message describing any user-breakpoints set at PC. This
2052 concerns with logical breakpoints, so we match program spaces, not
2055 extern void describe_other_breakpoints (struct gdbarch
*,
2056 struct program_space
*, CORE_ADDR
,
2057 struct obj_section
*, int);
2059 /* Enable or disable a breakpoint location LOC. ENABLE
2060 specifies whether to enable or disable. */
2062 extern void enable_disable_bp_location (bp_location
*loc
, bool enable
);
2065 /* Notify interpreters and observers that breakpoint B was modified. */
2067 extern void notify_breakpoint_modified (breakpoint
*b
);
2069 #endif /* !defined (BREAKPOINT_H) */