1 /* Data structures associated with breakpoints in GDB.
2 Copyright (C) 1992-2022 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/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"
40 struct gdbpy_breakpoint_object
;
41 struct gdbscm_breakpoint_object
;
42 struct number_or_range_parser
;
46 struct linespec_result
;
50 /* Enum for exception-handling support in 'catch throw', 'catch rethrow',
51 'catch catch' and the MI equivalent. */
53 enum exception_event_kind
60 /* Why are we removing the breakpoint from the target? */
64 /* A regular remove. Remove the breakpoint and forget everything
68 /* Detach the breakpoints from a fork child. */
72 /* This is the maximum number of bytes a breakpoint instruction can
73 take. Feel free to increase it. It's just used in a few places to
74 size arrays that should be independent of the target
77 #define BREAKPOINT_MAX 16
80 /* Type of breakpoint. */
84 bp_none
= 0, /* Eventpoint has been deleted */
85 bp_breakpoint
, /* Normal breakpoint */
86 bp_hardware_breakpoint
, /* Hardware assisted breakpoint */
87 bp_single_step
, /* Software single-step */
88 bp_until
, /* used by until command */
89 bp_finish
, /* used by finish command */
90 bp_watchpoint
, /* Watchpoint */
91 bp_hardware_watchpoint
, /* Hardware assisted watchpoint */
92 bp_read_watchpoint
, /* read watchpoint, (hardware assisted) */
93 bp_access_watchpoint
, /* access watchpoint, (hardware assisted) */
94 bp_longjmp
, /* secret breakpoint to find longjmp() */
95 bp_longjmp_resume
, /* secret breakpoint to escape longjmp() */
97 /* Breakpoint placed to the same location(s) like bp_longjmp but used to
98 protect against stale DUMMY_FRAME. Multiple bp_longjmp_call_dummy and
99 one bp_call_dummy are chained together by related_breakpoint for each
101 bp_longjmp_call_dummy
,
103 /* An internal breakpoint that is installed on the unwinder's
106 /* An internal breakpoint that is set at the point where an
107 exception will land. */
110 /* Used by wait_for_inferior for stepping over subroutine calls,
111 and for skipping prologues. */
114 /* Used by wait_for_inferior for stepping over signal
118 /* Used to detect when a watchpoint expression has gone out of
119 scope. These breakpoints are usually not visible to the user.
121 This breakpoint has some interesting properties:
123 1) There's always a 1:1 mapping between watchpoints
124 on local variables and watchpoint_scope breakpoints.
126 2) It automatically deletes itself and the watchpoint it's
127 associated with when hit.
129 3) It can never be disabled. */
132 /* The breakpoint at the end of a call dummy. See bp_longjmp_call_dummy it
133 is chained with by related_breakpoint. */
136 /* A breakpoint set on std::terminate, that is used to catch
137 otherwise uncaught exceptions thrown during an inferior call. */
140 /* Some dynamic linkers (HP, maybe Solaris) can arrange for special
141 code in the inferior to run when significant events occur in the
142 dynamic linker (for example a library is loaded or unloaded).
144 By placing a breakpoint in this magic code GDB will get control
145 when these significant events occur. GDB can then re-examine
146 the dynamic linker's data structures to discover any newly loaded
147 dynamic libraries. */
150 /* Some multi-threaded systems can arrange for a location in the
151 inferior to be executed when certain thread-related events occur
152 (such as thread creation or thread death).
154 By placing a breakpoint at one of these locations, GDB will get
155 control when these events occur. GDB can then update its thread
160 /* On the same principal, an overlay manager can arrange to call a
161 magic location in the inferior whenever there is an interesting
162 change in overlay status. GDB can update its overlay tables
163 and fiddle with breakpoints in overlays when this breakpoint
168 /* Master copies of longjmp breakpoints. These are always installed
169 as soon as an objfile containing longjmp is loaded, but they are
170 always disabled. While necessary, temporary clones of bp_longjmp
171 type will be created and enabled. */
175 /* Master copies of std::terminate breakpoints. */
176 bp_std_terminate_master
,
178 /* Like bp_longjmp_master, but for exceptions. */
185 bp_static_tracepoint
,
186 /* Like bp_static_tracepoint but for static markers. */
187 bp_static_marker_tracepoint
,
189 /* A dynamic printf stops at the given location, does a formatted
190 print, then automatically continues. (Although this is sort of
191 like a macro packaging up standard breakpoint functionality,
192 GDB doesn't have a way to construct types of breakpoint from
193 elements of behavior.) */
196 /* Event for JIT compiled code generation or deletion. */
199 /* Breakpoint is placed at the STT_GNU_IFUNC resolver. When hit GDB
200 inserts new bp_gnu_ifunc_resolver_return at the caller.
201 bp_gnu_ifunc_resolver is still being kept here as a different thread
202 may still hit it before bp_gnu_ifunc_resolver_return is hit by the
204 bp_gnu_ifunc_resolver
,
206 /* On its hit GDB now know the resolved address of the target
207 STT_GNU_IFUNC function. Associated bp_gnu_ifunc_resolver can be
208 deleted now and the breakpoint moved to the target function entry
210 bp_gnu_ifunc_resolver_return
,
213 /* States of enablement of breakpoint. */
217 bp_disabled
, /* The eventpoint is inactive, and cannot
219 bp_enabled
, /* The eventpoint is active, and can
221 bp_call_disabled
, /* The eventpoint has been disabled while a
222 call into the inferior is "in flight",
223 because some eventpoints interfere with
224 the implementation of a call on some
225 targets. The eventpoint will be
226 automatically enabled and reset when the
227 call "lands" (either completes, or stops
228 at another eventpoint). */
232 /* Disposition of breakpoint. Ie: what to do after hitting it. */
236 disp_del
, /* Delete it */
237 disp_del_at_next_stop
, /* Delete at next stop,
238 whether hit or not */
239 disp_disable
, /* Disable it */
240 disp_donttouch
/* Leave it alone */
243 /* Status of breakpoint conditions used when synchronizing
244 conditions with the target. */
246 enum condition_status
248 condition_unchanged
= 0,
253 /* Information used by targets to insert and remove breakpoints. */
255 struct bp_target_info
257 /* Address space at which the breakpoint was placed. */
258 struct address_space
*placed_address_space
;
260 /* Address at which the breakpoint was placed. This is normally
261 the same as REQUESTED_ADDRESS, except when adjustment happens in
262 gdbarch_breakpoint_from_pc. The most common form of adjustment
263 is stripping an alternate ISA marker from the PC which is used
264 to determine the type of breakpoint to insert. */
265 CORE_ADDR placed_address
;
267 /* Address at which the breakpoint was requested. */
268 CORE_ADDR reqstd_address
;
270 /* If this is a ranged breakpoint, then this field contains the
271 length of the range that will be watched for execution. */
274 /* If the breakpoint lives in memory and reading that memory would
275 give back the breakpoint, instead of the original contents, then
276 the original contents are cached here. Only SHADOW_LEN bytes of
277 this buffer are valid, and only when the breakpoint is inserted. */
278 gdb_byte shadow_contents
[BREAKPOINT_MAX
];
280 /* The length of the data cached in SHADOW_CONTENTS. */
283 /* The breakpoint's kind. It is used in 'kind' parameter in Z
287 /* Conditions the target should evaluate if it supports target-side
288 breakpoint conditions. These are non-owning pointers. */
289 std::vector
<agent_expr
*> conditions
;
291 /* Commands the target should evaluate if it supports target-side
292 breakpoint commands. These are non-owning pointers. */
293 std::vector
<agent_expr
*> tcommands
;
295 /* Flag that is true if the breakpoint should be left in place even
296 when GDB is not connected. */
300 /* GDB maintains two types of information about each breakpoint (or
301 watchpoint, or other related event). The first type corresponds
302 to struct breakpoint; this is a relatively high-level structure
303 which contains the source location(s), stopping conditions, user
304 commands to execute when the breakpoint is hit, and so forth.
306 The second type of information corresponds to struct bp_location.
307 Each breakpoint has one or (eventually) more locations associated
308 with it, which represent target-specific and machine-specific
309 mechanisms for stopping the program. For instance, a watchpoint
310 expression may require multiple hardware watchpoints in order to
311 catch all changes in the value of the expression being watched. */
315 bp_loc_software_breakpoint
,
316 bp_loc_hardware_breakpoint
,
317 bp_loc_software_watchpoint
,
318 bp_loc_hardware_watchpoint
,
319 bp_loc_other
/* Miscellaneous... */
322 class bp_location
: public refcounted_object
325 bp_location () = default;
327 /* Construct a bp_location with the type inferred from OWNER's
329 explicit bp_location (breakpoint
*owner
);
331 /* Construct a bp_location with type TYPE. */
332 bp_location (breakpoint
*owner
, bp_loc_type type
);
334 virtual ~bp_location () = default;
336 /* Chain pointer to the next breakpoint location for
337 the same parent breakpoint. */
338 bp_location
*next
= NULL
;
340 /* Type of this breakpoint location. */
341 bp_loc_type loc_type
{};
343 /* Each breakpoint location must belong to exactly one higher-level
344 breakpoint. This pointer is NULL iff this bp_location is no
345 longer attached to a breakpoint. For example, when a breakpoint
346 is deleted, its locations may still be found in the
347 moribund_locations list, or if we had stopped for it, in
349 breakpoint
*owner
= NULL
;
351 /* Conditional. Break only if this expression's value is nonzero.
352 Unlike string form of condition, which is associated with
353 breakpoint, this is associated with location, since if breakpoint
354 has several locations, the evaluation of expression can be
355 different for different locations. Only valid for real
356 breakpoints; a watchpoint's conditional expression is stored in
357 the owner breakpoint object. */
360 /* Conditional expression in agent expression
361 bytecode form. This is used for stub-side breakpoint
362 condition evaluation. */
363 agent_expr_up cond_bytecode
;
365 /* Signals that the condition has changed since the last time
366 we updated the global location list. This means the condition
367 needs to be sent to the target again. This is used together
368 with target-side breakpoint conditions.
370 condition_unchanged: It means there has been no condition changes.
372 condition_modified: It means this location had its condition modified.
374 condition_updated: It means we already marked all the locations that are
375 duplicates of this location and thus we don't need to call
376 force_breakpoint_reinsertion (...) for this location. */
378 condition_status condition_changed
{};
380 agent_expr_up cmd_bytecode
;
382 /* Signals that breakpoint conditions and/or commands need to be
383 re-synced with the target. This has no use other than
384 target-side breakpoints. */
385 bool needs_update
= false;
387 /* This location's address is in an unloaded solib, and so this
388 location should not be inserted. It will be automatically
389 enabled when that solib is loaded. */
390 bool shlib_disabled
= false;
392 /* Is this particular location enabled. */
393 bool enabled
= false;
395 /* Is this particular location disabled because the condition
396 expression is invalid at this location. For a location to be
397 reported as enabled, the ENABLED field above has to be true *and*
398 the DISABLED_BY_COND field has to be false. */
399 bool disabled_by_cond
= false;
401 /* True if this breakpoint is now inserted. */
402 bool inserted
= false;
404 /* True if this is a permanent breakpoint. There is a breakpoint
405 instruction hard-wired into the target's code. Don't try to
406 write another breakpoint instruction on top of it, or restore its
407 value. Step over it using the architecture's
408 gdbarch_skip_permanent_breakpoint method. */
409 bool permanent
= false;
411 /* True if this is not the first breakpoint in the list
412 for the given address. location of tracepoint can _never_
413 be duplicated with other locations of tracepoints and other
414 kinds of breakpoints, because two locations at the same
415 address may have different actions, so both of these locations
416 should be downloaded and so that `tfind N' always works. */
417 bool duplicate
= false;
419 /* If we someday support real thread-specific breakpoints, then
420 the breakpoint location will need a thread identifier. */
422 /* Data for specific breakpoint types. These could be a union, but
423 simplicity is more important than memory usage for breakpoints. */
425 /* Architecture associated with this location's address. May be
426 different from the breakpoint architecture. */
427 struct gdbarch
*gdbarch
= NULL
;
429 /* The program space associated with this breakpoint location
430 address. Note that an address space may be represented in more
431 than one program space (e.g. each uClinux program will be given
432 its own program space, but there will only be one address space
433 for all of them), but we must not insert more than one location
434 at the same address in the same address space. */
435 program_space
*pspace
= NULL
;
437 /* Note that zero is a perfectly valid code address on some platforms
438 (for example, the mn10200 (OBSOLETE) and mn10300 simulators). NULL
439 is not a special value for this field. Valid for all types except
441 CORE_ADDR address
= 0;
443 /* For hardware watchpoints, the size of the memory region being
444 watched. For hardware ranged breakpoints, the size of the
448 /* Type of hardware watchpoint. */
449 target_hw_bp_type watchpoint_type
{};
451 /* For any breakpoint type with an address, this is the section
452 associated with the address. Used primarily for overlay
454 obj_section
*section
= NULL
;
456 /* Address at which breakpoint was requested, either by the user or
457 by GDB for internal breakpoints. This will usually be the same
458 as ``address'' (above) except for cases in which
459 ADJUST_BREAKPOINT_ADDRESS has computed a different address at
460 which to place the breakpoint in order to comply with a
461 processor's architectual constraints. */
462 CORE_ADDR requested_address
= 0;
464 /* An additional address assigned with this location. This is currently
465 only used by STT_GNU_IFUNC resolver breakpoints to hold the address
466 of the resolver function. */
467 CORE_ADDR related_address
= 0;
469 /* If the location comes from a probe point, this is the probe associated
471 bound_probe probe
{};
473 gdb::unique_xmalloc_ptr
<char> function_name
;
475 /* Details of the placed breakpoint, when inserted. */
476 bp_target_info target_info
{};
478 /* Similarly, for the breakpoint at an overlay's LMA, if necessary. */
479 bp_target_info overlay_target_info
{};
481 /* In a non-stop mode, it's possible that we delete a breakpoint,
482 but as we do that, some still running thread hits that breakpoint.
483 For that reason, we need to keep locations belonging to deleted
484 breakpoints for a bit, so that don't report unexpected SIGTRAP.
485 We can't keep such locations forever, so we use a heuristic --
486 after we process certain number of inferior events since
487 breakpoint was deleted, we retire all locations of that breakpoint.
488 This variable keeps a number of events still to go, when
489 it becomes 0 this location is retired. */
490 int events_till_retirement
= 0;
492 /* Line number which was used to place this location.
494 Breakpoint placed into a comment keeps it's user specified line number
495 despite ADDRESS resolves into a different line number. */
499 /* Symtab which was used to place this location. This is used
500 to find the corresponding source file name. */
502 struct symtab
*symtab
= NULL
;
504 /* The symbol found by the location parser, if any. This may be used to
505 ascertain when an event location was set at a different location than
506 the one originally selected by parsing, e.g., inlined symbols. */
507 const struct symbol
*symbol
= NULL
;
509 /* Similarly, the minimal symbol found by the location parser, if
510 any. This may be used to ascertain if the location was
511 originally set on a GNU ifunc symbol. */
512 const minimal_symbol
*msymbol
= NULL
;
514 /* The objfile the symbol or minimal symbol were found in. */
515 const struct objfile
*objfile
= NULL
;
518 /* A policy class for bp_location reference counting. */
519 struct bp_location_ref_policy
521 static void incref (bp_location
*loc
)
526 static void decref (bp_location
*loc
)
528 gdb_assert (loc
->refcount () > 0);
530 if (loc
->refcount () == 0)
535 /* A gdb::ref_ptr that has been specialized for bp_location. */
536 typedef gdb::ref_ptr
<bp_location
, bp_location_ref_policy
>
539 /* The possible return values for print_bpstat, print_it_normal,
540 print_it_done, print_it_noop. */
541 enum print_stop_action
543 /* We printed nothing or we need to do some more analysis. */
546 /* We printed something, and we *do* desire that something to be
547 followed by a location. */
550 /* We printed something, and we do *not* desire that something to be
551 followed by a location. */
554 /* We already printed all we needed to print, don't print anything
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
563 struct breakpoint_ops
565 /* Create SALs from location, storing the result in linespec_result.
567 For an explanation about the arguments, see the function
568 `create_sals_from_location_default'.
570 This function is called inside `create_breakpoint'. */
571 void (*create_sals_from_location
) (struct event_location
*location
,
572 struct linespec_result
*canonical
);
574 /* This method will be responsible for creating a breakpoint given its SALs.
575 Usually, it just calls `create_breakpoints_sal' (for ordinary
576 breakpoints). However, there may be some special cases where we might
577 need to do some tweaks, e.g., see
578 `strace_marker_create_breakpoints_sal'.
580 This function is called inside `create_breakpoint'. */
581 void (*create_breakpoints_sal
) (struct gdbarch
*,
582 struct linespec_result
*,
583 gdb::unique_xmalloc_ptr
<char>,
584 gdb::unique_xmalloc_ptr
<char>,
585 enum bptype
, enum bpdisp
, int, int,
586 int, int, int, int, unsigned);
589 enum watchpoint_triggered
591 /* This watchpoint definitely did not trigger. */
592 watch_triggered_no
= 0,
594 /* Some hardware watchpoint triggered, and it might have been this
595 one, but we do not know which it was. */
596 watch_triggered_unknown
,
598 /* This hardware watchpoint definitely did trigger. */
602 /* Some targets (e.g., embedded PowerPC) need two debug registers to set
603 a watchpoint over a memory region. If this flag is true, GDB will use
604 only one register per watchpoint, thus assuming that all accesses that
605 modify a memory location happen at its starting address. */
607 extern bool target_exact_watchpoints
;
609 /* bp_location linked list range. */
611 using bp_location_range
= next_range
<bp_location
>;
613 /* Note that the ->silent field is not currently used by any commands
614 (though the code is in there if it was to be, and set_raw_breakpoint
615 does set it to 0). I implemented it because I thought it would be
616 useful for a hack I had to put in; I'm going to leave it in because
617 I can see how there might be times when it would indeed be useful */
619 /* Abstract base class representing all kinds of breakpoints. */
623 breakpoint (struct gdbarch
*gdbarch_
, enum bptype bptype
,
624 bool temp
= true, const char *cond_string
= nullptr);
626 DISABLE_COPY_AND_ASSIGN (breakpoint
);
628 virtual ~breakpoint () = 0;
630 /* Allocate a location for this breakpoint. */
631 virtual struct bp_location
*allocate_location ();
633 /* Reevaluate a breakpoint. This is necessary after symbols change
634 (e.g., an executable or DSO was loaded, or the inferior just
636 virtual void re_set ()
638 /* Nothing to re-set. */
641 /* Insert the breakpoint or watchpoint or activate the catchpoint.
642 Return 0 for success, 1 if the breakpoint, watchpoint or
643 catchpoint type is not supported, -1 for failure. */
644 virtual int insert_location (struct bp_location
*);
646 /* Remove the breakpoint/catchpoint that was previously inserted
647 with the "insert" method above. Return 0 for success, 1 if the
648 breakpoint, watchpoint or catchpoint type is not supported,
650 virtual int remove_location (struct bp_location
*,
651 enum remove_bp_reason reason
);
653 /* Return true if it the target has stopped due to hitting
654 breakpoint location BL. This function does not check if we
655 should stop, only if BL explains the stop. ASPACE is the address
656 space in which the event occurred, BP_ADDR is the address at
657 which the inferior stopped, and WS is the target_waitstatus
658 describing the event. */
659 virtual int breakpoint_hit (const struct bp_location
*bl
,
660 const address_space
*aspace
,
662 const target_waitstatus
&ws
);
664 /* Check internal conditions of the breakpoint referred to by BS.
665 If we should not stop for this breakpoint, set BS->stop to 0. */
666 virtual void check_status (struct bpstat
*bs
)
671 /* Tell how many hardware resources (debug registers) are needed
672 for this breakpoint. If this function is not provided, then
673 the breakpoint or watchpoint needs one debug register. */
674 virtual int resources_needed (const struct bp_location
*);
676 /* The normal print routine for this breakpoint, called when we
678 virtual enum print_stop_action
print_it (const bpstat
*bs
) const;
680 /* Display information about this breakpoint, for "info
681 breakpoints". Returns false if this method should use the
683 virtual bool print_one (bp_location
**) const
688 /* Display extra information about this breakpoint, below the normal
689 breakpoint description in "info breakpoints".
691 In the example below, the "address range" line was printed
692 by print_one_detail_ranged_breakpoint.
694 (gdb) info breakpoints
695 Num Type Disp Enb Address What
696 2 hw breakpoint keep y in main at test-watch.c:70
697 address range: [0x10000458, 0x100004c7]
700 virtual void print_one_detail (struct ui_out
*) const
705 /* Display information about this breakpoint after setting it
706 (roughly speaking; this is called from "mention"). */
707 virtual void print_mention () const;
709 /* Print to FP the CLI command that recreates this breakpoint. */
710 virtual void print_recreate (struct ui_file
*fp
) const;
712 /* Given the location (second parameter), this method decodes it and
713 returns the SAL locations related to it. For ordinary
714 breakpoints, it calls `decode_line_full'. If SEARCH_PSPACE is
715 not NULL, symbol search is restricted to just that program space.
717 This function is called inside `location_to_sals'. */
718 virtual std::vector
<symtab_and_line
> decode_location
719 (struct event_location
*location
,
720 struct program_space
*search_pspace
);
722 /* Return true if this breakpoint explains a signal. See
723 bpstat_explains_signal. */
724 virtual bool explains_signal (enum gdb_signal
)
729 /* Called after evaluating the breakpoint's condition,
730 and only if it evaluated true. */
731 virtual void after_condition_true (struct bpstat
*bs
)
736 /* Return a range of this breakpoint's locations. */
737 bp_location_range
locations () const;
739 breakpoint
*next
= NULL
;
740 /* Type of breakpoint. */
741 bptype type
= bp_none
;
742 /* Zero means disabled; remember the info but don't break here. */
743 enum enable_state enable_state
= bp_enabled
;
744 /* What to do with this breakpoint after we hit it. */
745 bpdisp disposition
= disp_del
;
746 /* Number assigned to distinguish breakpoints. */
749 /* Location(s) associated with this high-level breakpoint. */
750 bp_location
*loc
= NULL
;
752 /* True means a silent breakpoint (don't print frame info if we stop
755 /* True means display ADDR_STRING to the user verbatim. */
756 bool display_canonical
= false;
757 /* Number of stops at this breakpoint that should be continued
758 automatically before really stopping. */
759 int ignore_count
= 0;
761 /* Number of stops at this breakpoint before it will be
763 int enable_count
= 0;
765 /* Chain of command lines to execute when this breakpoint is
767 counted_command_line commands
;
768 /* Stack depth (address of frame). If nonzero, break only if fp
770 struct frame_id frame_id
= null_frame_id
;
772 /* The program space used to set the breakpoint. This is only set
773 for breakpoints which are specific to a program space; for
774 non-thread-specific ordinary breakpoints this is NULL. */
775 program_space
*pspace
= NULL
;
777 /* Location we used to set the breakpoint. */
778 event_location_up location
;
780 /* The filter that should be passed to decode_line_full when
781 re-setting this breakpoint. This may be NULL. */
782 gdb::unique_xmalloc_ptr
<char> filter
;
784 /* For a ranged breakpoint, the location we used to find the end of
786 event_location_up location_range_end
;
788 /* Architecture we used to set the breakpoint. */
789 struct gdbarch
*gdbarch
;
790 /* Language we used to set the breakpoint. */
791 enum language language
;
792 /* Input radix we used to set the breakpoint. */
794 /* String form of the breakpoint condition (malloc'd), or NULL if
795 there is no condition. */
796 gdb::unique_xmalloc_ptr
<char> cond_string
;
798 /* String form of extra parameters, or NULL if there are none.
800 gdb::unique_xmalloc_ptr
<char> extra_string
;
802 /* Holds the address of the related watchpoint_scope breakpoint when
803 using watchpoints on local variables (might the concept of a
804 related breakpoint be useful elsewhere, if not just call it the
805 watchpoint_scope breakpoint or something like that. FIXME). */
806 breakpoint
*related_breakpoint
;
808 /* Thread number for thread-specific breakpoint, or -1 if don't
812 /* Ada task number for task-specific breakpoint, or 0 if don't
816 /* Count of the number of times this breakpoint was taken, dumped
817 with the info, but not used for anything else. Useful for seeing
818 how many times you hit a break prior to the program aborting, so
819 you can back up to just before the abort. */
822 /* Is breakpoint's condition not yet parsed because we found no
823 location initially so had no context to parse the condition
825 int condition_not_parsed
= 0;
827 /* With a Python scripting enabled GDB, store a reference to the
828 Python object that has been associated with this breakpoint.
829 This is always NULL for a GDB that is not script enabled. It can
830 sometimes be NULL for enabled GDBs as not all breakpoint types
831 are tracked by the scripting language API. */
832 gdbpy_breakpoint_object
*py_bp_object
= NULL
;
834 /* Same as py_bp_object, but for Scheme. */
835 gdbscm_breakpoint_object
*scm_bp_object
= NULL
;
839 /* Helper for breakpoint_ops->print_recreate implementations. Prints
840 the "thread" or "task" condition of B, and then a newline.
842 Necessary because most breakpoint implementations accept
843 thread/task conditions at the end of the spec line, like "break foo
844 thread 1", which needs outputting before any breakpoint-type
845 specific extra command necessary for B's recreation. */
846 void print_recreate_thread (struct ui_file
*fp
) const;
849 /* Abstract base class representing code breakpoints. User "break"
850 breakpoints, internal and momentary breakpoints, etc. IOW, any
851 kind of breakpoint whose locations are created from SALs. */
852 struct code_breakpoint
: public breakpoint
854 using breakpoint::breakpoint
;
856 /* Create a breakpoint with SALS as locations. Use LOCATION as a
857 description of the location, and COND_STRING as condition
858 expression. If LOCATION is NULL then create an "address
859 location" from the address in the SAL. */
860 code_breakpoint (struct gdbarch
*gdbarch
, bptype type
,
861 gdb::array_view
<const symtab_and_line
> sals
,
862 event_location_up
&&location
,
863 gdb::unique_xmalloc_ptr
<char> filter
,
864 gdb::unique_xmalloc_ptr
<char> cond_string
,
865 gdb::unique_xmalloc_ptr
<char> extra_string
,
866 enum bpdisp disposition
,
867 int thread
, int task
, int ignore_count
,
869 int enabled
, unsigned flags
,
870 int display_canonical
);
872 ~code_breakpoint () override
= 0;
874 /* Add a location for SAL to this breakpoint. */
875 bp_location
*add_location (const symtab_and_line
&sal
);
877 void re_set () override
;
878 int insert_location (struct bp_location
*) override
;
879 int remove_location (struct bp_location
*,
880 enum remove_bp_reason reason
) override
;
881 int breakpoint_hit (const struct bp_location
*bl
,
882 const address_space
*aspace
,
884 const target_waitstatus
&ws
) override
;
885 std::vector
<symtab_and_line
> decode_location
886 (struct event_location
*location
,
887 struct program_space
*search_pspace
) override
;
890 /* An instance of this type is used to represent a watchpoint,
891 a.k.a. a data breakpoint. */
893 struct watchpoint
: public breakpoint
895 using breakpoint::breakpoint
;
897 void re_set () override
;
898 int insert_location (struct bp_location
*) override
;
899 int remove_location (struct bp_location
*,
900 enum remove_bp_reason reason
) override
;
901 int breakpoint_hit (const struct bp_location
*bl
,
902 const address_space
*aspace
,
904 const target_waitstatus
&ws
) override
;
905 void check_status (struct bpstat
*bs
) override
;
906 int resources_needed (const struct bp_location
*) override
;
908 /* Tell whether we can downgrade from a hardware watchpoint to a software
909 one. If not, the user will not be able to enable the watchpoint when
910 there are not enough hardware resources available. */
911 virtual bool works_in_software_mode () const;
913 enum print_stop_action
print_it (const bpstat
*bs
) const override
;
914 void print_mention () const override
;
915 void print_recreate (struct ui_file
*fp
) const override
;
916 bool explains_signal (enum gdb_signal
) override
;
918 /* String form of exp to use for displaying to the user (malloc'd),
920 gdb::unique_xmalloc_ptr
<char> exp_string
;
921 /* String form to use for reparsing of EXP (malloc'd) or NULL. */
922 gdb::unique_xmalloc_ptr
<char> exp_string_reparse
;
924 /* The expression we are watching, or NULL if not a watchpoint. */
926 /* The largest block within which it is valid, or NULL if it is
927 valid anywhere (e.g. consists just of global symbols). */
928 const struct block
*exp_valid_block
;
929 /* The conditional expression if any. */
930 expression_up cond_exp
;
931 /* The largest block within which it is valid, or NULL if it is
932 valid anywhere (e.g. consists just of global symbols). */
933 const struct block
*cond_exp_valid_block
;
934 /* Value of the watchpoint the last time we checked it, or NULL when
935 we do not know the value yet or the value was not readable. VAL
939 /* True if VAL is valid. If VAL_VALID is set but VAL is NULL,
940 then an error occurred reading the value. */
943 /* When watching the location of a bitfield, contains the offset and size of
944 the bitfield. Otherwise contains 0. */
948 /* Holds the frame address which identifies the frame this
949 watchpoint should be evaluated in, or `null' if the watchpoint
950 should be evaluated on the outermost frame. */
951 struct frame_id watchpoint_frame
;
953 /* Holds the thread which identifies the frame this watchpoint
954 should be considered in scope for, or `null_ptid' if the
955 watchpoint should be evaluated in all threads. */
956 ptid_t watchpoint_thread
;
958 /* For hardware watchpoints, the triggered status according to the
960 enum watchpoint_triggered watchpoint_triggered
;
962 /* Whether this watchpoint is exact (see
963 target_exact_watchpoints). */
966 /* The mask address for a masked hardware watchpoint. */
967 CORE_ADDR hw_wp_mask
;
970 /* Return true if BPT is either a software breakpoint or a hardware
973 extern bool is_breakpoint (const struct breakpoint
*bpt
);
975 /* Return true if BPT is of any watchpoint kind, hardware or
978 extern bool is_watchpoint (const struct breakpoint
*bpt
);
980 /* Return true if BPT is a C++ exception catchpoint (catch
981 catch/throw/rethrow). */
983 extern bool is_exception_catchpoint (breakpoint
*bp
);
985 /* An instance of this type is used to represent all kinds of
988 struct tracepoint
: public code_breakpoint
990 using code_breakpoint::code_breakpoint
;
992 int breakpoint_hit (const struct bp_location
*bl
,
993 const address_space
*aspace
, CORE_ADDR bp_addr
,
994 const target_waitstatus
&ws
) override
;
995 void print_one_detail (struct ui_out
*uiout
) const override
;
996 void print_mention () const override
;
997 void print_recreate (struct ui_file
*fp
) const override
;
999 /* Number of times this tracepoint should single-step and collect
1001 long step_count
= 0;
1003 /* Number of times this tracepoint should be hit before
1004 disabling/ending. */
1007 /* The number of the tracepoint on the target. */
1008 int number_on_target
= 0;
1010 /* The total space taken by all the trace frames for this
1012 ULONGEST traceframe_usage
= 0;
1014 /* The static tracepoint marker id, if known. */
1015 std::string static_trace_marker_id
;
1017 /* LTTng/UST allow more than one marker with the same ID string,
1018 although it unadvised because it confuses tools. When setting
1019 static tracepoints by marker ID, this will record the index in
1020 the array of markers we found for the given marker ID for which
1021 this static tracepoint corresponds. When resetting breakpoints,
1022 we will use this index to try to find the same marker again. */
1023 int static_trace_marker_id_idx
= 0;
1026 /* The abstract base class for catchpoints. */
1028 struct catchpoint
: public breakpoint
1030 /* If TEMP is true, then make the breakpoint temporary. If
1031 COND_STRING is not NULL, then store it in the breakpoint. */
1032 catchpoint (struct gdbarch
*gdbarch
, bool temp
, const char *cond_string
);
1034 ~catchpoint () override
= 0;
1038 /* The following stuff is an abstract data type "bpstat" ("breakpoint
1039 status"). This provides the ability to determine whether we have
1040 stopped at a breakpoint, and what we should do about it. */
1042 /* Clears a chain of bpstat, freeing storage
1044 extern void bpstat_clear (bpstat
**);
1046 /* Return a copy of a bpstat. Like "bs1 = bs2" but all storage that
1047 is part of the bpstat is copied as well. */
1048 extern bpstat
*bpstat_copy (bpstat
*);
1050 /* Build the (raw) bpstat chain for the stop information given by ASPACE,
1051 BP_ADDR, and WS. Returns the head of the bpstat chain. */
1053 extern bpstat
*build_bpstat_chain (const address_space
*aspace
,
1055 const target_waitstatus
&ws
);
1057 /* Get a bpstat associated with having just stopped at address
1058 BP_ADDR in thread PTID. STOP_CHAIN may be supplied as a previously
1059 computed stop chain or NULL, in which case the stop chain will be
1060 computed using build_bpstat_chain.
1062 Determine whether we stopped at a breakpoint, etc, or whether we
1063 don't understand this stop. Result is a chain of bpstat's such
1066 if we don't understand the stop, the result is a null pointer.
1068 if we understand why we stopped, the result is not null.
1070 Each element of the chain refers to a particular breakpoint or
1071 watchpoint at which we have stopped. (We may have stopped for
1072 several reasons concurrently.)
1074 Each element of the chain has valid next, breakpoint_at,
1075 commands, FIXME??? fields.
1077 watchpoints_triggered must be called beforehand to set up each
1078 watchpoint's watchpoint_triggered value.
1082 extern bpstat
*bpstat_stop_status (const address_space
*aspace
,
1083 CORE_ADDR pc
, thread_info
*thread
,
1084 const target_waitstatus
&ws
,
1085 bpstat
*stop_chain
= nullptr);
1087 /* Like bpstat_stop_status, but clears all watchpoints'
1088 watchpoint_triggered flag. Unlike with bpstat_stop_status, there's
1089 no need to call watchpoint_triggered beforehand. You'll typically
1090 use this variant when handling a known-non-watchpoint event, like a
1091 fork or exec event. */
1093 extern bpstat
*bpstat_stop_status_nowatch (const address_space
*aspace
,
1095 thread_info
*thread
,
1096 const target_waitstatus
&ws
);
1100 /* This bpstat_what stuff tells wait_for_inferior what to do with a
1101 breakpoint (a challenging task).
1103 The enum values order defines priority-like order of the actions.
1104 Once you've decided that some action is appropriate, you'll never
1105 go back and decide something of a lower priority is better. Each
1106 of these actions is mutually exclusive with the others. That
1107 means, that if you find yourself adding a new action class here and
1108 wanting to tell GDB that you have two simultaneous actions to
1109 handle, something is wrong, and you probably don't actually need a
1112 Note that a step resume breakpoint overrides another breakpoint of
1113 signal handling (see comment in wait_for_inferior at where we set
1114 the step_resume breakpoint). */
1116 enum bpstat_what_main_action
1118 /* Perform various other tests; that is, this bpstat does not
1119 say to perform any action (e.g. failed watchpoint and nothing
1121 BPSTAT_WHAT_KEEP_CHECKING
,
1123 /* Remove breakpoints, single step once, then put them back in and
1124 go back to what we were doing. It's possible that this should
1125 be removed from the main_action and put into a separate field,
1126 to more cleanly handle
1127 BPSTAT_WHAT_CLEAR_LONGJMP_RESUME_SINGLE. */
1130 /* Set longjmp_resume breakpoint, remove all other breakpoints,
1131 and continue. The "remove all other breakpoints" part is
1132 required if we are also stepping over another breakpoint as
1133 well as doing the longjmp handling. */
1134 BPSTAT_WHAT_SET_LONGJMP_RESUME
,
1136 /* Clear longjmp_resume breakpoint, then handle as
1137 BPSTAT_WHAT_KEEP_CHECKING. */
1138 BPSTAT_WHAT_CLEAR_LONGJMP_RESUME
,
1140 /* Clear step resume breakpoint, and keep checking. */
1141 BPSTAT_WHAT_STEP_RESUME
,
1143 /* Rather than distinguish between noisy and silent stops here, it
1144 might be cleaner to have bpstat_print make that decision (also
1145 taking into account stop_print_frame and source_only). But the
1146 implications are a bit scary (interaction with auto-displays,
1147 etc.), so I won't try it. */
1149 /* Stop silently. */
1150 BPSTAT_WHAT_STOP_SILENT
,
1152 /* Stop and print. */
1153 BPSTAT_WHAT_STOP_NOISY
,
1155 /* Clear step resume breakpoint, and keep checking. High-priority
1156 step-resume breakpoints are used when even if there's a user
1157 breakpoint at the current PC when we set the step-resume
1158 breakpoint, we don't want to re-handle any breakpoint other
1159 than the step-resume when it's hit; instead we want to move
1160 past the breakpoint. This is used in the case of skipping
1162 BPSTAT_WHAT_HP_STEP_RESUME
,
1165 /* An enum indicating the kind of "stack dummy" stop. This is a bit
1166 of a misnomer because only one kind of truly a stack dummy. */
1167 enum stop_stack_kind
1169 /* We didn't stop at a stack dummy breakpoint. */
1172 /* Stopped at a stack dummy. */
1175 /* Stopped at std::terminate. */
1181 enum bpstat_what_main_action main_action
;
1183 /* Did we hit a call dummy breakpoint? This only goes with a
1184 main_action of BPSTAT_WHAT_STOP_SILENT or
1185 BPSTAT_WHAT_STOP_NOISY (the concept of continuing from a call
1186 dummy without popping the frame is not a useful one). */
1187 enum stop_stack_kind call_dummy
;
1189 /* Used for BPSTAT_WHAT_SET_LONGJMP_RESUME and
1190 BPSTAT_WHAT_CLEAR_LONGJMP_RESUME. True if we are handling a
1191 longjmp, false if we are handling an exception. */
1195 /* Tell what to do about this bpstat. */
1196 struct bpstat_what
bpstat_what (bpstat
*);
1198 /* Run breakpoint event callbacks associated with the breakpoints that
1200 extern void bpstat_run_callbacks (bpstat
*bs_head
);
1202 /* Find the bpstat associated with a breakpoint. NULL otherwise. */
1203 bpstat
*bpstat_find_breakpoint (bpstat
*, struct breakpoint
*);
1205 /* True if a signal that we got in target_wait() was due to
1206 circumstances explained by the bpstat; the signal is therefore not
1208 extern bool bpstat_explains_signal (bpstat
*, enum gdb_signal
);
1210 /* True if this bpstat causes a stop. */
1211 extern bool bpstat_causes_stop (bpstat
*);
1213 /* True if we should step constantly (e.g. watchpoints on machines
1214 without hardware support). This isn't related to a specific bpstat,
1215 just to things like whether watchpoints are set. */
1216 extern bool bpstat_should_step ();
1218 /* Print a message indicating what happened. Returns nonzero to
1219 say that only the source line should be printed after this (zero
1220 return means print the frame as well as the source line). */
1221 extern enum print_stop_action
bpstat_print (bpstat
*, int);
1223 /* Put in *NUM the breakpoint number of the first breakpoint we are
1224 stopped at. *BSP upon return is a bpstat which points to the
1225 remaining breakpoints stopped at (but which is not guaranteed to be
1226 good for anything but further calls to bpstat_num).
1228 Return 0 if passed a bpstat which does not indicate any breakpoints.
1229 Return -1 if stopped at a breakpoint that has been deleted since
1231 Return 1 otherwise. */
1232 extern int bpstat_num (bpstat
**, int *);
1234 /* Perform actions associated with the stopped inferior. Actually, we
1235 just use this for breakpoint commands. Perhaps other actions will
1236 go here later, but this is executed at a late time (from the
1238 extern void bpstat_do_actions (void);
1240 /* Modify all entries of STOP_BPSTAT of INFERIOR_PTID so that the actions will
1241 not be performed. */
1242 extern void bpstat_clear_actions (void);
1244 /* Implementation: */
1246 /* Values used to tell the printing routine how to behave for this
1250 /* This is used when we want to do a normal printing of the reason
1251 for stopping. The output will depend on the type of eventpoint
1252 we are dealing with. This is the default value, most commonly
1255 /* This is used when nothing should be printed for this bpstat
1258 /* This is used when everything which needs to be printed has
1259 already been printed. But we still want to print the frame. */
1266 bpstat (struct bp_location
*bl
, bpstat
***bs_link_pointer
);
1268 bpstat (const bpstat
&);
1269 bpstat
&operator= (const bpstat
&) = delete;
1271 /* Linked list because there can be more than one breakpoint at
1272 the same place, and a bpstat reflects the fact that all have
1276 /* Location that caused the stop. Locations are refcounted, so
1277 this will never be NULL. Note that this location may end up
1278 detached from a breakpoint, but that does not necessary mean
1279 that the struct breakpoint is gone. E.g., consider a
1280 watchpoint with a condition that involves an inferior function
1281 call. Watchpoint locations are recreated often (on resumes,
1282 hence on infcalls too). Between creating the bpstat and after
1283 evaluating the watchpoint condition, this location may hence
1284 end up detached from its original owner watchpoint, even though
1285 the watchpoint is still listed. If it's condition evaluates as
1286 true, we still want this location to cause a stop, and we will
1287 still need to know which watchpoint it was originally attached.
1288 What this means is that we should not (in most cases) follow
1289 the `bpstat->bp_location->owner' link, but instead use the
1290 `breakpoint_at' field below. */
1291 bp_location_ref_ptr bp_location_at
;
1293 /* Breakpoint that caused the stop. This is nullified if the
1294 breakpoint ends up being deleted. See comments on
1295 `bp_location_at' above for why do we need this field instead of
1296 following the location's owner. */
1297 struct breakpoint
*breakpoint_at
;
1299 /* The associated command list. */
1300 counted_command_line commands
;
1302 /* Old value associated with a watchpoint. */
1303 value_ref_ptr old_val
;
1305 /* Nonzero if this breakpoint tells us to print the frame. */
1308 /* Nonzero if this breakpoint tells us to stop. */
1311 /* Tell bpstat_print and print_bp_stop_message how to print stuff
1312 associated with this element of the bpstat chain. */
1313 enum bp_print_how print_it
;
1324 /* The possible return values for breakpoint_here_p.
1325 We guarantee that zero always means "no breakpoint here". */
1326 enum breakpoint_here
1328 no_breakpoint_here
= 0,
1329 ordinary_breakpoint_here
,
1330 permanent_breakpoint_here
1334 /* Prototypes for breakpoint-related functions. */
1336 extern enum breakpoint_here
breakpoint_here_p (const address_space
*,
1339 /* Return true if an enabled breakpoint exists in the range defined by
1340 ADDR and LEN, in ASPACE. */
1341 extern int breakpoint_in_range_p (const address_space
*aspace
,
1342 CORE_ADDR addr
, ULONGEST len
);
1344 extern int moribund_breakpoint_here_p (const address_space
*, CORE_ADDR
);
1346 extern int breakpoint_inserted_here_p (const address_space
*,
1349 extern int software_breakpoint_inserted_here_p (const address_space
*,
1352 /* Return non-zero iff there is a hardware breakpoint inserted at
1354 extern int hardware_breakpoint_inserted_here_p (const address_space
*,
1357 /* Check whether any location of BP is inserted at PC. */
1359 extern int breakpoint_has_location_inserted_here (struct breakpoint
*bp
,
1360 const address_space
*aspace
,
1363 extern int single_step_breakpoint_inserted_here_p (const address_space
*,
1366 /* Returns true if there's a hardware watchpoint or access watchpoint
1367 inserted in the range defined by ADDR and LEN. */
1368 extern int hardware_watchpoint_inserted_in_range (const address_space
*,
1372 /* Returns true if {ASPACE1,ADDR1} and {ASPACE2,ADDR2} represent the
1373 same breakpoint location. In most targets, this can only be true
1374 if ASPACE1 matches ASPACE2. On targets that have global
1375 breakpoints, the address space doesn't really matter. */
1377 extern int breakpoint_address_match (const address_space
*aspace1
,
1379 const address_space
*aspace2
,
1382 extern void until_break_command (const char *, int, int);
1384 /* Initialize a struct bp_location. */
1386 extern void update_breakpoint_locations
1387 (code_breakpoint
*b
,
1388 struct program_space
*filter_pspace
,
1389 gdb::array_view
<const symtab_and_line
> sals
,
1390 gdb::array_view
<const symtab_and_line
> sals_end
);
1392 extern void breakpoint_re_set (void);
1394 extern void breakpoint_re_set_thread (struct breakpoint
*);
1396 extern void delete_breakpoint (struct breakpoint
*);
1398 struct breakpoint_deleter
1400 void operator() (struct breakpoint
*b
) const
1402 delete_breakpoint (b
);
1406 typedef std::unique_ptr
<struct breakpoint
, breakpoint_deleter
> breakpoint_up
;
1408 extern breakpoint_up set_momentary_breakpoint
1409 (struct gdbarch
*, struct symtab_and_line
, struct frame_id
, enum bptype
);
1411 extern breakpoint_up set_momentary_breakpoint_at_pc
1412 (struct gdbarch
*, CORE_ADDR pc
, enum bptype type
);
1414 extern struct breakpoint
*clone_momentary_breakpoint (struct breakpoint
*bpkt
);
1416 extern void set_ignore_count (int, int, int);
1418 extern void breakpoint_init_inferior (enum inf_context
);
1420 extern void breakpoint_auto_delete (bpstat
*);
1422 /* Return the chain of command lines to execute when this breakpoint
1424 extern struct command_line
*breakpoint_commands (struct breakpoint
*b
);
1426 /* Return a string image of DISP. The string is static, and thus should
1427 NOT be deallocated after use. */
1428 const char *bpdisp_text (enum bpdisp disp
);
1430 extern void break_command (const char *, int);
1432 extern void watch_command_wrapper (const char *, int, bool);
1433 extern void awatch_command_wrapper (const char *, int, bool);
1434 extern void rwatch_command_wrapper (const char *, int, bool);
1435 extern void tbreak_command (const char *, int);
1437 extern const struct breakpoint_ops code_breakpoint_ops
;
1439 /* Arguments to pass as context to some catch command handlers. */
1440 #define CATCH_PERMANENT ((void *) (uintptr_t) 0)
1441 #define CATCH_TEMPORARY ((void *) (uintptr_t) 1)
1443 /* Like add_cmd, but add the command to both the "catch" and "tcatch"
1444 lists, and pass some additional user data to the command
1448 add_catch_command (const char *name
, const char *docstring
,
1449 cmd_func_ftype
*func
,
1450 completer_ftype
*completer
,
1451 void *user_data_catch
,
1452 void *user_data_tcatch
);
1454 /* Add breakpoint B on the breakpoint list, and notify the user, the
1455 target and breakpoint_created observers of its existence. If
1456 INTERNAL is non-zero, the breakpoint number will be allocated from
1457 the internal breakpoint count. If UPDATE_GLL is non-zero,
1458 update_global_location_list will be called. */
1460 extern void install_breakpoint (int internal
, std::unique_ptr
<breakpoint
> &&b
,
1463 /* Returns the breakpoint ops appropriate for use with with LOCATION and
1464 according to IS_TRACEPOINT. Use this to ensure, for example, that you pass
1465 the correct ops to create_breakpoint for probe locations. If LOCATION is
1466 NULL, returns code_breakpoint_ops. */
1468 extern const struct breakpoint_ops
*breakpoint_ops_for_event_location
1469 (const struct event_location
*location
, bool is_tracepoint
);
1471 /* Flags that can be passed down to create_breakpoint, etc., to affect
1472 breakpoint creation in several ways. */
1474 enum breakpoint_create_flags
1476 /* We're adding a breakpoint to our tables that is already
1477 inserted in the target. */
1478 CREATE_BREAKPOINT_FLAGS_INSERTED
= 1 << 0
1481 /* Set a breakpoint. This function is shared between CLI and MI functions
1482 for setting a breakpoint at LOCATION.
1484 This function has two major modes of operations, selected by the
1485 PARSE_EXTRA parameter.
1487 If PARSE_EXTRA is zero, LOCATION is just the breakpoint's location,
1488 with condition, thread, and extra string specified by the COND_STRING,
1489 THREAD, and EXTRA_STRING parameters.
1491 If PARSE_EXTRA is non-zero, this function will attempt to extract
1492 the condition, thread, and extra string from EXTRA_STRING, ignoring
1493 the similarly named parameters.
1495 If FORCE_CONDITION is true, the condition is accepted even when it is
1496 invalid at all of the locations. However, if PARSE_EXTRA is non-zero,
1497 the FORCE_CONDITION parameter is ignored and the corresponding argument
1498 is parsed from EXTRA_STRING.
1500 If INTERNAL is non-zero, the breakpoint number will be allocated
1501 from the internal breakpoint count.
1503 Returns true if any breakpoint was created; false otherwise. */
1505 extern int create_breakpoint (struct gdbarch
*gdbarch
,
1506 struct event_location
*location
,
1507 const char *cond_string
, int thread
,
1508 const char *extra_string
,
1509 bool force_condition
,
1511 int tempflag
, enum bptype wanted_type
,
1513 enum auto_boolean pending_break_support
,
1514 const struct breakpoint_ops
*ops
,
1517 int internal
, unsigned flags
);
1519 extern void insert_breakpoints (void);
1521 extern int remove_breakpoints (void);
1523 /* Remove breakpoints of inferior INF. */
1525 extern void remove_breakpoints_inf (inferior
*inf
);
1527 /* This function can be used to update the breakpoint package's state
1528 after an exec() system call has been executed.
1530 This function causes the following:
1532 - All eventpoints are marked "not inserted".
1533 - All eventpoints with a symbolic address are reset such that
1534 the symbolic address must be reevaluated before the eventpoints
1536 - The solib breakpoints are explicitly removed from the breakpoint
1538 - A step-resume breakpoint, if any, is explicitly removed from the
1540 - All eventpoints without a symbolic address are removed from the
1542 extern void update_breakpoints_after_exec (void);
1544 /* This function can be used to physically remove hardware breakpoints
1545 and watchpoints from the specified traced inferior process, without
1546 modifying the breakpoint package's state. This can be useful for
1547 those targets which support following the processes of a fork() or
1548 vfork() system call, when one of the resulting two processes is to
1549 be detached and allowed to run free.
1551 It is an error to use this function on the process whose id is
1553 extern int detach_breakpoints (ptid_t ptid
);
1555 /* This function is called when program space PSPACE is about to be
1556 deleted. It takes care of updating breakpoints to not reference
1557 this PSPACE anymore. */
1558 extern void breakpoint_program_space_exit (struct program_space
*pspace
);
1560 extern void set_longjmp_breakpoint (struct thread_info
*tp
,
1561 struct frame_id frame
);
1562 extern void delete_longjmp_breakpoint (int thread
);
1564 /* Mark all longjmp breakpoints from THREAD for later deletion. */
1565 extern void delete_longjmp_breakpoint_at_next_stop (int thread
);
1567 extern struct breakpoint
*set_longjmp_breakpoint_for_call_dummy (void);
1568 extern void check_longjmp_breakpoint_for_call_dummy (struct thread_info
*tp
);
1570 extern void enable_overlay_breakpoints (void);
1571 extern void disable_overlay_breakpoints (void);
1573 extern void set_std_terminate_breakpoint (void);
1574 extern void delete_std_terminate_breakpoint (void);
1576 /* These functions respectively disable or reenable all currently
1577 enabled watchpoints. When disabled, the watchpoints are marked
1578 call_disabled. When re-enabled, they are marked enabled.
1580 The intended client of these functions is call_function_by_hand.
1582 The inferior must be stopped, and all breakpoints removed, when
1583 these functions are used.
1585 The need for these functions is that on some targets (e.g., HP-UX),
1586 gdb is unable to unwind through the dummy frame that is pushed as
1587 part of the implementation of a call command. Watchpoints can
1588 cause the inferior to stop in places where this frame is visible,
1589 and that can cause execution control to become very confused.
1591 Note that if a user sets breakpoints in an interactively called
1592 function, the call_disabled watchpoints will have been re-enabled
1593 when the first such breakpoint is reached. However, on targets
1594 that are unable to unwind through the call dummy frame, watches
1595 of stack-based storage may then be deleted, because gdb will
1596 believe that their watched storage is out of scope. (Sigh.) */
1597 extern void disable_watchpoints_before_interactive_call_start (void);
1599 extern void enable_watchpoints_after_interactive_call_stop (void);
1601 /* These functions disable and re-enable all breakpoints during
1602 inferior startup. They are intended to be called from solib
1603 code where necessary. This is needed on platforms where the
1604 main executable is relocated at some point during startup
1605 processing, making breakpoint addresses invalid.
1607 If additional breakpoints are created after the routine
1608 disable_breakpoints_before_startup but before the routine
1609 enable_breakpoints_after_startup was called, they will also
1610 be marked as disabled. */
1611 extern void disable_breakpoints_before_startup (void);
1612 extern void enable_breakpoints_after_startup (void);
1614 /* For script interpreters that need to define breakpoint commands
1615 after they've already read the commands into a struct
1617 extern enum command_control_type commands_from_control_command
1618 (const char *arg
, struct command_line
*cmd
);
1620 extern void clear_breakpoint_hit_counts (void);
1622 extern struct breakpoint
*get_breakpoint (int num
);
1624 /* The following are for displays, which aren't really breakpoints,
1625 but here is as good a place as any for them. */
1627 extern void disable_current_display (void);
1629 extern void do_displays (void);
1631 extern void disable_display (int);
1633 extern void clear_displays (void);
1635 extern void disable_breakpoint (struct breakpoint
*);
1637 extern void enable_breakpoint (struct breakpoint
*);
1639 extern void breakpoint_set_commands (struct breakpoint
*b
,
1640 counted_command_line
&&commands
);
1642 extern void breakpoint_set_silent (struct breakpoint
*b
, int silent
);
1644 extern void breakpoint_set_thread (struct breakpoint
*b
, int thread
);
1646 extern void breakpoint_set_task (struct breakpoint
*b
, int task
);
1648 /* Clear the "inserted" flag in all breakpoints. */
1649 extern void mark_breakpoints_out (void);
1651 extern struct breakpoint
*create_jit_event_breakpoint (struct gdbarch
*,
1654 extern struct breakpoint
*create_solib_event_breakpoint (struct gdbarch
*,
1657 /* Create an solib event breakpoint at ADDRESS in the current program
1658 space, and immediately try to insert it. Returns a pointer to the
1659 breakpoint on success. Deletes the new breakpoint and returns NULL
1660 if inserting the breakpoint fails. */
1661 extern struct breakpoint
*create_and_insert_solib_event_breakpoint
1662 (struct gdbarch
*gdbarch
, CORE_ADDR address
);
1664 extern struct breakpoint
*create_thread_event_breakpoint (struct gdbarch
*,
1667 extern void remove_jit_event_breakpoints (void);
1669 extern void remove_solib_event_breakpoints (void);
1671 /* Mark solib event breakpoints of the current program space with
1672 delete at next stop disposition. */
1673 extern void remove_solib_event_breakpoints_at_next_stop (void);
1675 extern void disable_breakpoints_in_shlibs (void);
1677 /* This function returns true if B is a catchpoint. */
1679 extern bool is_catchpoint (struct breakpoint
*b
);
1681 /* Shared helper function (MI and CLI) for creating and installing
1682 a shared object event catchpoint. If IS_LOAD is true then
1683 the events to be caught are load events, otherwise they are
1684 unload events. If IS_TEMP is true the catchpoint is a
1685 temporary one. If ENABLED is true the catchpoint is
1686 created in an enabled state. */
1688 extern void add_solib_catchpoint (const char *arg
, bool is_load
, bool is_temp
,
1691 /* Create and insert a new software single step breakpoint for the
1692 current thread. May be called multiple times; each time will add a
1693 new location to the set of potential addresses the next instruction
1695 extern void insert_single_step_breakpoint (struct gdbarch
*,
1696 const address_space
*,
1699 /* Insert all software single step breakpoints for the current frame.
1700 Return true if any software single step breakpoints are inserted,
1701 otherwise, return false. */
1702 extern int insert_single_step_breakpoints (struct gdbarch
*);
1704 /* Check whether any hardware watchpoints have triggered or not,
1705 according to the target, and record it in each watchpoint's
1706 'watchpoint_triggered' field. */
1707 int watchpoints_triggered (const target_waitstatus
&);
1709 /* Helper for transparent breakpoint hiding for memory read and write
1712 Update one of READBUF or WRITEBUF with either the shadows
1713 (READBUF), or the breakpoint instructions (WRITEBUF) of inserted
1714 breakpoints at the memory range defined by MEMADDR and extending
1715 for LEN bytes. If writing, then WRITEBUF is a copy of WRITEBUF_ORG
1717 extern void breakpoint_xfer_memory (gdb_byte
*readbuf
, gdb_byte
*writebuf
,
1718 const gdb_byte
*writebuf_org
,
1719 ULONGEST memaddr
, LONGEST len
);
1721 /* Return true if breakpoints should be inserted now. That'll be the
1724 - the target has global breakpoints.
1726 - "breakpoint always-inserted" is on, and the target has
1729 - threads are executing.
1731 extern int breakpoints_should_be_inserted_now (void);
1733 /* Called each time new event from target is processed.
1734 Retires previously deleted breakpoint locations that
1735 in our opinion won't ever trigger. */
1736 extern void breakpoint_retire_moribund (void);
1738 /* Set break condition of breakpoint B to EXP.
1739 If FORCE, define the condition even if it is invalid in
1740 all of the breakpoint locations. */
1741 extern void set_breakpoint_condition (struct breakpoint
*b
, const char *exp
,
1742 int from_tty
, bool force
);
1744 /* Set break condition for the breakpoint with number BPNUM to EXP.
1745 Raise an error if no breakpoint with the given number is found.
1746 Also raise an error if the breakpoint already has stop conditions.
1747 If FORCE, define the condition even if it is invalid in
1748 all of the breakpoint locations. */
1749 extern void set_breakpoint_condition (int bpnum
, const char *exp
,
1750 int from_tty
, bool force
);
1752 /* Checks if we are catching syscalls or not.
1753 Returns 0 if not, greater than 0 if we are. */
1754 extern int catch_syscall_enabled (void);
1756 /* Checks if we are catching syscalls with the specific
1757 syscall_number. Used for "filtering" the catchpoints.
1758 Returns false if not, true if we are. */
1759 extern bool catching_syscall_number (int syscall_number
);
1761 /* Return a tracepoint with the given number if found. */
1762 extern struct tracepoint
*get_tracepoint (int num
);
1764 extern struct tracepoint
*get_tracepoint_by_number_on_target (int num
);
1766 /* Find a tracepoint by parsing a number in the supplied string. */
1767 extern struct tracepoint
*
1768 get_tracepoint_by_number (const char **arg
,
1769 number_or_range_parser
*parser
);
1771 /* Return true if B is of tracepoint kind. */
1773 extern bool is_tracepoint (const struct breakpoint
*b
);
1775 /* Return a vector of all static tracepoints defined at ADDR. */
1776 extern std::vector
<breakpoint
*> static_tracepoints_here (CORE_ADDR addr
);
1778 /* Create an instance of this to start registering breakpoint numbers
1779 for a later "commands" command. */
1781 class scoped_rbreak_breakpoints
1785 scoped_rbreak_breakpoints ();
1786 ~scoped_rbreak_breakpoints ();
1788 DISABLE_COPY_AND_ASSIGN (scoped_rbreak_breakpoints
);
1791 /* Breakpoint linked list iterator. */
1793 using breakpoint_iterator
= next_iterator
<breakpoint
>;
1795 /* Breakpoint linked list range. */
1797 using breakpoint_range
= iterator_range
<breakpoint_iterator
>;
1799 /* Return a range to iterate over all breakpoints. */
1801 breakpoint_range
all_breakpoints ();
1803 /* Breakpoint linked list range, safe against deletion of the current
1804 breakpoint while iterating. */
1806 using breakpoint_safe_range
= basic_safe_range
<breakpoint_range
>;
1808 /* Return a range to iterate over all breakpoints. This range is safe against
1809 deletion of the current breakpoint while iterating. */
1811 breakpoint_safe_range
all_breakpoints_safe ();
1813 /* Breakpoint filter to only keep tracepoints. */
1815 struct tracepoint_filter
1817 bool operator() (breakpoint
*b
)
1818 { return is_tracepoint (b
); }
1821 /* Breakpoint linked list iterator, filtering to only keep tracepoints. */
1823 using tracepoint_iterator
1824 = filtered_iterator
<breakpoint_iterator
, tracepoint_filter
>;
1826 /* Breakpoint linked list range, filtering to only keep tracepoints. */
1828 using tracepoint_range
= iterator_range
<tracepoint_iterator
>;
1830 /* Return a range to iterate over all tracepoints. */
1832 tracepoint_range
all_tracepoints ();
1834 /* Return a range to iterate over all breakpoint locations. */
1836 const std::vector
<bp_location
*> &all_bp_locations ();
1838 /* Nonzero if the specified PC cannot be a location where functions
1839 have been inlined. */
1841 extern int pc_at_non_inline_function (const address_space
*aspace
,
1843 const target_waitstatus
&ws
);
1845 extern int user_breakpoint_p (struct breakpoint
*);
1847 /* Return true if this breakpoint is pending, false if not. */
1848 extern int pending_breakpoint_p (struct breakpoint
*);
1850 /* Attempt to determine architecture of location identified by SAL. */
1851 extern struct gdbarch
*get_sal_arch (struct symtab_and_line sal
);
1853 extern void breakpoint_free_objfile (struct objfile
*objfile
);
1855 extern const char *ep_parse_optional_if_clause (const char **arg
);
1857 /* Print the "Thread ID hit" part of "Thread ID hit Breakpoint N" to
1858 UIOUT iff debugging multiple threads. */
1859 extern void maybe_print_thread_hit_breakpoint (struct ui_out
*uiout
);
1861 /* Print the specified breakpoint. */
1862 extern void print_breakpoint (breakpoint
*bp
);
1864 /* Command element for the 'commands' command. */
1865 extern cmd_list_element
*commands_cmd_element
;
1867 /* Whether to use the fixed output when printing information about a
1868 multi-location breakpoint (see PR 9659). */
1870 extern bool fix_multi_location_breakpoint_output_globally
;
1872 /* Deal with "catch catch", "catch throw", and "catch rethrow" commands and
1873 the MI equivalents. Sets up to catch events of type EX_EVENT. When
1874 TEMPFLAG is true only the next matching event is caught after which the
1875 catch-point is deleted. If REGEX is not NULL then only exceptions whose
1876 type name matches REGEX will trigger the event. */
1878 extern void catch_exception_event (enum exception_event_kind ex_event
,
1879 const char *regex
, bool tempflag
,
1882 /* A helper function that prints a shared library stopped event.
1883 IS_CATCHPOINT is true if the event is due to a "catch load"
1884 catchpoint, false otherwise. */
1886 extern void print_solib_event (bool is_catchpoint
);
1888 /* Print a message describing any user-breakpoints set at PC. This
1889 concerns with logical breakpoints, so we match program spaces, not
1892 extern void describe_other_breakpoints (struct gdbarch
*,
1893 struct program_space
*, CORE_ADDR
,
1894 struct obj_section
*, int);
1896 #endif /* !defined (BREAKPOINT_H) */