xref: /netbsd/external/gpl3/gdb/dist/gdb/breakpoint.h (revision 1424dfb3)
166e63ce3Schristos /* Data structures associated with breakpoints in GDB.
2*1424dfb3Schristos    Copyright (C) 1992-2020 Free Software Foundation, Inc.
366e63ce3Schristos 
466e63ce3Schristos    This file is part of GDB.
566e63ce3Schristos 
666e63ce3Schristos    This program is free software; you can redistribute it and/or modify
766e63ce3Schristos    it under the terms of the GNU General Public License as published by
866e63ce3Schristos    the Free Software Foundation; either version 3 of the License, or
966e63ce3Schristos    (at your option) any later version.
1066e63ce3Schristos 
1166e63ce3Schristos    This program is distributed in the hope that it will be useful,
1266e63ce3Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
1366e63ce3Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1466e63ce3Schristos    GNU General Public License for more details.
1566e63ce3Schristos 
1666e63ce3Schristos    You should have received a copy of the GNU General Public License
1766e63ce3Schristos    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
1866e63ce3Schristos 
1966e63ce3Schristos #if !defined (BREAKPOINT_H)
2066e63ce3Schristos #define BREAKPOINT_H 1
2166e63ce3Schristos 
2266e63ce3Schristos #include "frame.h"
2366e63ce3Schristos #include "value.h"
2448596154Schristos #include "ax.h"
2548596154Schristos #include "command.h"
26*1424dfb3Schristos #include "gdbsupport/break-common.h"
2726a53354Schristos #include "probe.h"
281c468f90Schristos #include "location.h"
291c468f90Schristos #include <vector>
30*1424dfb3Schristos #include "gdbsupport/array-view.h"
31*1424dfb3Schristos #include "gdbsupport/function-view.h"
3207163879Schristos #include "cli/cli-script.h"
3366e63ce3Schristos 
3466e63ce3Schristos struct block;
357af5a897Schristos struct gdbpy_breakpoint_object;
3626a53354Schristos struct gdbscm_breakpoint_object;
371c468f90Schristos struct number_or_range_parser;
3848596154Schristos struct thread_info;
3948596154Schristos struct bpstats;
4048596154Schristos struct bp_location;
4148596154Schristos struct linespec_result;
4248596154Schristos struct linespec_sals;
4307163879Schristos struct inferior;
44c03b94e9Schristos 
45*1424dfb3Schristos /* Enum for exception-handling support in 'catch throw', 'catch rethrow',
46*1424dfb3Schristos    'catch catch' and the MI equivalent.  */
47*1424dfb3Schristos 
48*1424dfb3Schristos enum exception_event_kind
49*1424dfb3Schristos {
50*1424dfb3Schristos   EX_EVENT_THROW,
51*1424dfb3Schristos   EX_EVENT_RETHROW,
52*1424dfb3Schristos   EX_EVENT_CATCH
53*1424dfb3Schristos };
54*1424dfb3Schristos 
55c03b94e9Schristos /* Why are we removing the breakpoint from the target?  */
56c03b94e9Schristos 
57c03b94e9Schristos enum remove_bp_reason
58c03b94e9Schristos {
59c03b94e9Schristos   /* A regular remove.  Remove the breakpoint and forget everything
60c03b94e9Schristos      about it.  */
61c03b94e9Schristos   REMOVE_BREAKPOINT,
62c03b94e9Schristos 
63c03b94e9Schristos   /* Detach the breakpoints from a fork child.  */
64c03b94e9Schristos   DETACH_BREAKPOINT,
65c03b94e9Schristos };
6666e63ce3Schristos 
6766e63ce3Schristos /* This is the maximum number of bytes a breakpoint instruction can
6866e63ce3Schristos    take.  Feel free to increase it.  It's just used in a few places to
6966e63ce3Schristos    size arrays that should be independent of the target
7066e63ce3Schristos    architecture.  */
7166e63ce3Schristos 
7266e63ce3Schristos #define	BREAKPOINT_MAX	16
7366e63ce3Schristos 
7466e63ce3Schristos 
7566e63ce3Schristos /* Type of breakpoint.  */
7666e63ce3Schristos 
7766e63ce3Schristos enum bptype
7866e63ce3Schristos   {
7966e63ce3Schristos     bp_none = 0,		/* Eventpoint has been deleted */
8066e63ce3Schristos     bp_breakpoint,		/* Normal breakpoint */
8166e63ce3Schristos     bp_hardware_breakpoint,	/* Hardware assisted breakpoint */
8226a53354Schristos     bp_single_step,		/* Software single-step */
8366e63ce3Schristos     bp_until,			/* used by until command */
8466e63ce3Schristos     bp_finish,			/* used by finish command */
8566e63ce3Schristos     bp_watchpoint,		/* Watchpoint */
8666e63ce3Schristos     bp_hardware_watchpoint,	/* Hardware assisted watchpoint */
8766e63ce3Schristos     bp_read_watchpoint,		/* read watchpoint, (hardware assisted) */
8866e63ce3Schristos     bp_access_watchpoint,	/* access watchpoint, (hardware assisted) */
8966e63ce3Schristos     bp_longjmp,			/* secret breakpoint to find longjmp() */
9066e63ce3Schristos     bp_longjmp_resume,		/* secret breakpoint to escape longjmp() */
9166e63ce3Schristos 
9248596154Schristos     /* Breakpoint placed to the same location(s) like bp_longjmp but used to
9348596154Schristos        protect against stale DUMMY_FRAME.  Multiple bp_longjmp_call_dummy and
9448596154Schristos        one bp_call_dummy are chained together by related_breakpoint for each
9548596154Schristos        DUMMY_FRAME.  */
9648596154Schristos     bp_longjmp_call_dummy,
9748596154Schristos 
9866e63ce3Schristos     /* An internal breakpoint that is installed on the unwinder's
9966e63ce3Schristos        debug hook.  */
10066e63ce3Schristos     bp_exception,
10166e63ce3Schristos     /* An internal breakpoint that is set at the point where an
10266e63ce3Schristos        exception will land.  */
10366e63ce3Schristos     bp_exception_resume,
10466e63ce3Schristos 
10566e63ce3Schristos     /* Used by wait_for_inferior for stepping over subroutine calls,
10648596154Schristos        and for skipping prologues.  */
10766e63ce3Schristos     bp_step_resume,
10866e63ce3Schristos 
10948596154Schristos     /* Used by wait_for_inferior for stepping over signal
11048596154Schristos        handlers.  */
11148596154Schristos     bp_hp_step_resume,
11248596154Schristos 
11366e63ce3Schristos     /* Used to detect when a watchpoint expression has gone out of
11466e63ce3Schristos        scope.  These breakpoints are usually not visible to the user.
11566e63ce3Schristos 
11666e63ce3Schristos        This breakpoint has some interesting properties:
11766e63ce3Schristos 
11866e63ce3Schristos        1) There's always a 1:1 mapping between watchpoints
11966e63ce3Schristos        on local variables and watchpoint_scope breakpoints.
12066e63ce3Schristos 
12166e63ce3Schristos        2) It automatically deletes itself and the watchpoint it's
12266e63ce3Schristos        associated with when hit.
12366e63ce3Schristos 
12466e63ce3Schristos        3) It can never be disabled.  */
12566e63ce3Schristos     bp_watchpoint_scope,
12666e63ce3Schristos 
12748596154Schristos     /* The breakpoint at the end of a call dummy.  See bp_longjmp_call_dummy it
12848596154Schristos        is chained with by related_breakpoint.  */
12966e63ce3Schristos     bp_call_dummy,
13066e63ce3Schristos 
13166e63ce3Schristos     /* A breakpoint set on std::terminate, that is used to catch
13266e63ce3Schristos        otherwise uncaught exceptions thrown during an inferior call.  */
13366e63ce3Schristos     bp_std_terminate,
13466e63ce3Schristos 
13566e63ce3Schristos     /* Some dynamic linkers (HP, maybe Solaris) can arrange for special
13666e63ce3Schristos        code in the inferior to run when significant events occur in the
13766e63ce3Schristos        dynamic linker (for example a library is loaded or unloaded).
13866e63ce3Schristos 
13966e63ce3Schristos        By placing a breakpoint in this magic code GDB will get control
14066e63ce3Schristos        when these significant events occur.  GDB can then re-examine
14166e63ce3Schristos        the dynamic linker's data structures to discover any newly loaded
14266e63ce3Schristos        dynamic libraries.  */
14366e63ce3Schristos     bp_shlib_event,
14466e63ce3Schristos 
14566e63ce3Schristos     /* Some multi-threaded systems can arrange for a location in the
14666e63ce3Schristos        inferior to be executed when certain thread-related events occur
14766e63ce3Schristos        (such as thread creation or thread death).
14866e63ce3Schristos 
14966e63ce3Schristos        By placing a breakpoint at one of these locations, GDB will get
15066e63ce3Schristos        control when these events occur.  GDB can then update its thread
15166e63ce3Schristos        lists etc.  */
15266e63ce3Schristos 
15366e63ce3Schristos     bp_thread_event,
15466e63ce3Schristos 
15566e63ce3Schristos     /* On the same principal, an overlay manager can arrange to call a
15666e63ce3Schristos        magic location in the inferior whenever there is an interesting
15766e63ce3Schristos        change in overlay status.  GDB can update its overlay tables
15866e63ce3Schristos        and fiddle with breakpoints in overlays when this breakpoint
15966e63ce3Schristos        is hit.  */
16066e63ce3Schristos 
16166e63ce3Schristos     bp_overlay_event,
16266e63ce3Schristos 
16366e63ce3Schristos     /* Master copies of longjmp breakpoints.  These are always installed
16466e63ce3Schristos        as soon as an objfile containing longjmp is loaded, but they are
16566e63ce3Schristos        always disabled.  While necessary, temporary clones of bp_longjmp
16666e63ce3Schristos        type will be created and enabled.  */
16766e63ce3Schristos 
16866e63ce3Schristos     bp_longjmp_master,
16966e63ce3Schristos 
17066e63ce3Schristos     /* Master copies of std::terminate breakpoints.  */
17166e63ce3Schristos     bp_std_terminate_master,
17266e63ce3Schristos 
17366e63ce3Schristos     /* Like bp_longjmp_master, but for exceptions.  */
17466e63ce3Schristos     bp_exception_master,
17566e63ce3Schristos 
17666e63ce3Schristos     bp_catchpoint,
17766e63ce3Schristos 
17866e63ce3Schristos     bp_tracepoint,
17966e63ce3Schristos     bp_fast_tracepoint,
18066e63ce3Schristos     bp_static_tracepoint,
18166e63ce3Schristos 
18248596154Schristos     /* A dynamic printf stops at the given location, does a formatted
18348596154Schristos        print, then automatically continues.  (Although this is sort of
18448596154Schristos        like a macro packaging up standard breakpoint functionality,
18548596154Schristos        GDB doesn't have a way to construct types of breakpoint from
18648596154Schristos        elements of behavior.)  */
18748596154Schristos     bp_dprintf,
18848596154Schristos 
18966e63ce3Schristos     /* Event for JIT compiled code generation or deletion.  */
19066e63ce3Schristos     bp_jit_event,
19166e63ce3Schristos 
19266e63ce3Schristos     /* Breakpoint is placed at the STT_GNU_IFUNC resolver.  When hit GDB
19366e63ce3Schristos        inserts new bp_gnu_ifunc_resolver_return at the caller.
19466e63ce3Schristos        bp_gnu_ifunc_resolver is still being kept here as a different thread
19566e63ce3Schristos        may still hit it before bp_gnu_ifunc_resolver_return is hit by the
19666e63ce3Schristos        original thread.  */
19766e63ce3Schristos     bp_gnu_ifunc_resolver,
19866e63ce3Schristos 
19966e63ce3Schristos     /* On its hit GDB now know the resolved address of the target
20066e63ce3Schristos        STT_GNU_IFUNC function.  Associated bp_gnu_ifunc_resolver can be
20166e63ce3Schristos        deleted now and the breakpoint moved to the target function entry
20266e63ce3Schristos        point.  */
20366e63ce3Schristos     bp_gnu_ifunc_resolver_return,
20466e63ce3Schristos   };
20566e63ce3Schristos 
20666e63ce3Schristos /* States of enablement of breakpoint.  */
20766e63ce3Schristos 
20866e63ce3Schristos enum enable_state
20966e63ce3Schristos   {
21066e63ce3Schristos     bp_disabled,	 /* The eventpoint is inactive, and cannot
21166e63ce3Schristos 			    trigger.  */
21266e63ce3Schristos     bp_enabled,		 /* The eventpoint is active, and can
21366e63ce3Schristos 			    trigger.  */
21466e63ce3Schristos     bp_call_disabled,	 /* The eventpoint has been disabled while a
21566e63ce3Schristos 			    call into the inferior is "in flight",
21666e63ce3Schristos 			    because some eventpoints interfere with
21766e63ce3Schristos 			    the implementation of a call on some
21866e63ce3Schristos 			    targets.  The eventpoint will be
21966e63ce3Schristos 			    automatically enabled and reset when the
22066e63ce3Schristos 			    call "lands" (either completes, or stops
22166e63ce3Schristos 			    at another eventpoint).  */
22266e63ce3Schristos   };
22366e63ce3Schristos 
22466e63ce3Schristos 
22566e63ce3Schristos /* Disposition of breakpoint.  Ie: what to do after hitting it.  */
22666e63ce3Schristos 
22766e63ce3Schristos enum bpdisp
22866e63ce3Schristos   {
22966e63ce3Schristos     disp_del,			/* Delete it */
23066e63ce3Schristos     disp_del_at_next_stop,	/* Delete at next stop,
23166e63ce3Schristos 				   whether hit or not */
23266e63ce3Schristos     disp_disable,		/* Disable it */
23366e63ce3Schristos     disp_donttouch		/* Leave it alone */
23466e63ce3Schristos   };
23566e63ce3Schristos 
23648596154Schristos /* Status of breakpoint conditions used when synchronizing
23748596154Schristos    conditions with the target.  */
23848596154Schristos 
23948596154Schristos enum condition_status
24048596154Schristos   {
24148596154Schristos     condition_unchanged = 0,
24248596154Schristos     condition_modified,
24348596154Schristos     condition_updated
24448596154Schristos   };
24548596154Schristos 
24666e63ce3Schristos /* Information used by targets to insert and remove breakpoints.  */
24766e63ce3Schristos 
24866e63ce3Schristos struct bp_target_info
24966e63ce3Schristos {
25066e63ce3Schristos   /* Address space at which the breakpoint was placed.  */
25166e63ce3Schristos   struct address_space *placed_address_space;
25266e63ce3Schristos 
25326a53354Schristos   /* Address at which the breakpoint was placed.  This is normally
25426a53354Schristos      the same as REQUESTED_ADDRESS, except when adjustment happens in
25526a53354Schristos      gdbarch_breakpoint_from_pc.  The most common form of adjustment
25626a53354Schristos      is stripping an alternate ISA marker from the PC which is used
25726a53354Schristos      to determine the type of breakpoint to insert.  */
25866e63ce3Schristos   CORE_ADDR placed_address;
25966e63ce3Schristos 
26026a53354Schristos   /* Address at which the breakpoint was requested.  */
26126a53354Schristos   CORE_ADDR reqstd_address;
26226a53354Schristos 
26366e63ce3Schristos   /* If this is a ranged breakpoint, then this field contains the
26466e63ce3Schristos      length of the range that will be watched for execution.  */
26566e63ce3Schristos   int length;
26666e63ce3Schristos 
26766e63ce3Schristos   /* If the breakpoint lives in memory and reading that memory would
26866e63ce3Schristos      give back the breakpoint, instead of the original contents, then
26966e63ce3Schristos      the original contents are cached here.  Only SHADOW_LEN bytes of
27066e63ce3Schristos      this buffer are valid, and only when the breakpoint is inserted.  */
27166e63ce3Schristos   gdb_byte shadow_contents[BREAKPOINT_MAX];
27266e63ce3Schristos 
27366e63ce3Schristos   /* The length of the data cached in SHADOW_CONTENTS.  */
27466e63ce3Schristos   int shadow_len;
27566e63ce3Schristos 
2761c468f90Schristos   /* The breakpoint's kind.  It is used in 'kind' parameter in Z
2771c468f90Schristos      packets.  */
2781c468f90Schristos   int kind;
27948596154Schristos 
2801c468f90Schristos   /* Conditions the target should evaluate if it supports target-side
2811c468f90Schristos      breakpoint conditions.  These are non-owning pointers.  */
2821c468f90Schristos   std::vector<agent_expr *> conditions;
28348596154Schristos 
2841c468f90Schristos   /* Commands the target should evaluate if it supports target-side
2851c468f90Schristos      breakpoint commands.  These are non-owning pointers.  */
2861c468f90Schristos   std::vector<agent_expr *> tcommands;
28748596154Schristos 
28848596154Schristos   /* Flag that is true if the breakpoint should be left in place even
28948596154Schristos      when GDB is not connected.  */
29048596154Schristos   int persist;
29166e63ce3Schristos };
29266e63ce3Schristos 
29366e63ce3Schristos /* GDB maintains two types of information about each breakpoint (or
29466e63ce3Schristos    watchpoint, or other related event).  The first type corresponds
29566e63ce3Schristos    to struct breakpoint; this is a relatively high-level structure
29666e63ce3Schristos    which contains the source location(s), stopping conditions, user
29766e63ce3Schristos    commands to execute when the breakpoint is hit, and so forth.
29866e63ce3Schristos 
29966e63ce3Schristos    The second type of information corresponds to struct bp_location.
30066e63ce3Schristos    Each breakpoint has one or (eventually) more locations associated
30166e63ce3Schristos    with it, which represent target-specific and machine-specific
30266e63ce3Schristos    mechanisms for stopping the program.  For instance, a watchpoint
30366e63ce3Schristos    expression may require multiple hardware watchpoints in order to
30466e63ce3Schristos    catch all changes in the value of the expression being watched.  */
30566e63ce3Schristos 
30666e63ce3Schristos enum bp_loc_type
30766e63ce3Schristos {
30866e63ce3Schristos   bp_loc_software_breakpoint,
30966e63ce3Schristos   bp_loc_hardware_breakpoint,
31066e63ce3Schristos   bp_loc_hardware_watchpoint,
31166e63ce3Schristos   bp_loc_other			/* Miscellaneous...  */
31266e63ce3Schristos };
31366e63ce3Schristos 
31407163879Schristos class bp_location
31548596154Schristos {
31607163879Schristos public:
31707163879Schristos   bp_location () = default;
31848596154Schristos 
319*1424dfb3Schristos   /* Construct a bp_location with the type inferred from OWNER's
320*1424dfb3Schristos      type.  */
321*1424dfb3Schristos   explicit bp_location (breakpoint *owner);
322*1424dfb3Schristos 
323*1424dfb3Schristos   /* Construct a bp_location with type TYPE.  */
324*1424dfb3Schristos   bp_location (breakpoint *owner, bp_loc_type type);
32507163879Schristos 
32607163879Schristos   virtual ~bp_location ();
32707163879Schristos 
32866e63ce3Schristos   /* Chain pointer to the next breakpoint location for
32966e63ce3Schristos      the same parent breakpoint.  */
33007163879Schristos   bp_location *next = NULL;
33148596154Schristos 
33266e63ce3Schristos   /* The reference count.  */
33307163879Schristos   int refc = 0;
33466e63ce3Schristos 
33566e63ce3Schristos   /* Type of this breakpoint location.  */
33607163879Schristos   bp_loc_type loc_type {};
33766e63ce3Schristos 
33866e63ce3Schristos   /* Each breakpoint location must belong to exactly one higher-level
33966e63ce3Schristos      breakpoint.  This pointer is NULL iff this bp_location is no
34066e63ce3Schristos      longer attached to a breakpoint.  For example, when a breakpoint
34166e63ce3Schristos      is deleted, its locations may still be found in the
34266e63ce3Schristos      moribund_locations list, or if we had stopped for it, in
34366e63ce3Schristos      bpstats.  */
34407163879Schristos   breakpoint *owner = NULL;
34566e63ce3Schristos 
34666e63ce3Schristos   /* Conditional.  Break only if this expression's value is nonzero.
34766e63ce3Schristos      Unlike string form of condition, which is associated with
34866e63ce3Schristos      breakpoint, this is associated with location, since if breakpoint
34966e63ce3Schristos      has several locations, the evaluation of expression can be
35066e63ce3Schristos      different for different locations.  Only valid for real
35166e63ce3Schristos      breakpoints; a watchpoint's conditional expression is stored in
35266e63ce3Schristos      the owner breakpoint object.  */
3531c468f90Schristos   expression_up cond;
35466e63ce3Schristos 
35548596154Schristos   /* Conditional expression in agent expression
35648596154Schristos      bytecode form.  This is used for stub-side breakpoint
35748596154Schristos      condition evaluation.  */
3581c468f90Schristos   agent_expr_up cond_bytecode;
35948596154Schristos 
36048596154Schristos   /* Signals that the condition has changed since the last time
36148596154Schristos      we updated the global location list.  This means the condition
36248596154Schristos      needs to be sent to the target again.  This is used together
36348596154Schristos      with target-side breakpoint conditions.
36448596154Schristos 
36548596154Schristos      condition_unchanged: It means there has been no condition changes.
36648596154Schristos 
36748596154Schristos      condition_modified: It means this location had its condition modified.
36848596154Schristos 
36948596154Schristos      condition_updated: It means we already marked all the locations that are
37048596154Schristos      duplicates of this location and thus we don't need to call
37148596154Schristos      force_breakpoint_reinsertion (...) for this location.  */
37248596154Schristos 
37307163879Schristos   condition_status condition_changed {};
37448596154Schristos 
3751c468f90Schristos   agent_expr_up cmd_bytecode;
37648596154Schristos 
37748596154Schristos   /* Signals that breakpoint conditions and/or commands need to be
378*1424dfb3Schristos      re-synced with the target.  This has no use other than
37948596154Schristos      target-side breakpoints.  */
38007163879Schristos   bool needs_update = false;
38148596154Schristos 
38266e63ce3Schristos   /* This location's address is in an unloaded solib, and so this
38366e63ce3Schristos      location should not be inserted.  It will be automatically
38466e63ce3Schristos      enabled when that solib is loaded.  */
38507163879Schristos   bool shlib_disabled = false;
38666e63ce3Schristos 
38766e63ce3Schristos   /* Is this particular location enabled.  */
38807163879Schristos   bool enabled = false;
38966e63ce3Schristos 
390*1424dfb3Schristos   /* True if this breakpoint is now inserted.  */
39107163879Schristos   bool inserted = false;
39266e63ce3Schristos 
393*1424dfb3Schristos   /* True if this is a permanent breakpoint.  There is a breakpoint
39426a53354Schristos      instruction hard-wired into the target's code.  Don't try to
39526a53354Schristos      write another breakpoint instruction on top of it, or restore its
39626a53354Schristos      value.  Step over it using the architecture's
39726a53354Schristos      gdbarch_skip_permanent_breakpoint method.  */
39807163879Schristos   bool permanent = false;
39926a53354Schristos 
400*1424dfb3Schristos   /* True if this is not the first breakpoint in the list
40148596154Schristos      for the given address.  location of tracepoint can _never_
40248596154Schristos      be duplicated with other locations of tracepoints and other
40348596154Schristos      kinds of breakpoints, because two locations at the same
40448596154Schristos      address may have different actions, so both of these locations
40548596154Schristos      should be downloaded and so that `tfind N' always works.  */
40607163879Schristos   bool duplicate = false;
40766e63ce3Schristos 
40866e63ce3Schristos   /* If we someday support real thread-specific breakpoints, then
40966e63ce3Schristos      the breakpoint location will need a thread identifier.  */
41066e63ce3Schristos 
41166e63ce3Schristos   /* Data for specific breakpoint types.  These could be a union, but
41266e63ce3Schristos      simplicity is more important than memory usage for breakpoints.  */
41366e63ce3Schristos 
41466e63ce3Schristos   /* Architecture associated with this location's address.  May be
41566e63ce3Schristos      different from the breakpoint architecture.  */
41607163879Schristos   struct gdbarch *gdbarch = NULL;
41766e63ce3Schristos 
41866e63ce3Schristos   /* The program space associated with this breakpoint location
41966e63ce3Schristos      address.  Note that an address space may be represented in more
42066e63ce3Schristos      than one program space (e.g. each uClinux program will be given
42166e63ce3Schristos      its own program space, but there will only be one address space
42266e63ce3Schristos      for all of them), but we must not insert more than one location
42366e63ce3Schristos      at the same address in the same address space.  */
42407163879Schristos   program_space *pspace = NULL;
42566e63ce3Schristos 
42666e63ce3Schristos   /* Note that zero is a perfectly valid code address on some platforms
42766e63ce3Schristos      (for example, the mn10200 (OBSOLETE) and mn10300 simulators).  NULL
42866e63ce3Schristos      is not a special value for this field.  Valid for all types except
42966e63ce3Schristos      bp_loc_other.  */
43007163879Schristos   CORE_ADDR address = 0;
43166e63ce3Schristos 
43266e63ce3Schristos   /* For hardware watchpoints, the size of the memory region being
43366e63ce3Schristos      watched.  For hardware ranged breakpoints, the size of the
43466e63ce3Schristos      breakpoint range.  */
43507163879Schristos   int length = 0;
43666e63ce3Schristos 
43766e63ce3Schristos   /* Type of hardware watchpoint.  */
43807163879Schristos   target_hw_bp_type watchpoint_type {};
43966e63ce3Schristos 
44066e63ce3Schristos   /* For any breakpoint type with an address, this is the section
44166e63ce3Schristos      associated with the address.  Used primarily for overlay
44266e63ce3Schristos      debugging.  */
44307163879Schristos   obj_section *section = NULL;
44466e63ce3Schristos 
44566e63ce3Schristos   /* Address at which breakpoint was requested, either by the user or
44666e63ce3Schristos      by GDB for internal breakpoints.  This will usually be the same
44766e63ce3Schristos      as ``address'' (above) except for cases in which
44866e63ce3Schristos      ADJUST_BREAKPOINT_ADDRESS has computed a different address at
44966e63ce3Schristos      which to place the breakpoint in order to comply with a
45066e63ce3Schristos      processor's architectual constraints.  */
45107163879Schristos   CORE_ADDR requested_address = 0;
45266e63ce3Schristos 
45348596154Schristos   /* An additional address assigned with this location.  This is currently
45448596154Schristos      only used by STT_GNU_IFUNC resolver breakpoints to hold the address
45548596154Schristos      of the resolver function.  */
45607163879Schristos   CORE_ADDR related_address = 0;
45748596154Schristos 
45848596154Schristos   /* If the location comes from a probe point, this is the probe associated
45948596154Schristos      with it.  */
46007163879Schristos   bound_probe probe {};
46148596154Schristos 
46207163879Schristos   char *function_name = NULL;
46366e63ce3Schristos 
46466e63ce3Schristos   /* Details of the placed breakpoint, when inserted.  */
46507163879Schristos   bp_target_info target_info {};
46666e63ce3Schristos 
46766e63ce3Schristos   /* Similarly, for the breakpoint at an overlay's LMA, if necessary.  */
46807163879Schristos   bp_target_info overlay_target_info {};
46966e63ce3Schristos 
47066e63ce3Schristos   /* In a non-stop mode, it's possible that we delete a breakpoint,
47166e63ce3Schristos      but as we do that, some still running thread hits that breakpoint.
47266e63ce3Schristos      For that reason, we need to keep locations belonging to deleted
47366e63ce3Schristos      breakpoints for a bit, so that don't report unexpected SIGTRAP.
47466e63ce3Schristos      We can't keep such locations forever, so we use a heuristic --
47566e63ce3Schristos      after we process certain number of inferior events since
47666e63ce3Schristos      breakpoint was deleted, we retire all locations of that breakpoint.
47766e63ce3Schristos      This variable keeps a number of events still to go, when
47866e63ce3Schristos      it becomes 0 this location is retired.  */
47907163879Schristos   int events_till_retirement = 0;
48048596154Schristos 
48148596154Schristos   /* Line number which was used to place this location.
48248596154Schristos 
48348596154Schristos      Breakpoint placed into a comment keeps it's user specified line number
48448596154Schristos      despite ADDRESS resolves into a different line number.  */
48548596154Schristos 
48607163879Schristos   int line_number = 0;
48748596154Schristos 
48848596154Schristos   /* Symtab which was used to place this location.  This is used
48948596154Schristos      to find the corresponding source file name.  */
49048596154Schristos 
49107163879Schristos   struct symtab *symtab = NULL;
49207163879Schristos 
49307163879Schristos   /* The symbol found by the location parser, if any.  This may be used to
49407163879Schristos      ascertain when an event location was set at a different location than
49507163879Schristos      the one originally selected by parsing, e.g., inlined symbols.  */
49607163879Schristos   const struct symbol *symbol = NULL;
49707163879Schristos 
49807163879Schristos   /* Similarly, the minimal symbol found by the location parser, if
49907163879Schristos      any.  This may be used to ascertain if the location was
50007163879Schristos      originally set on a GNU ifunc symbol.  */
50107163879Schristos   const minimal_symbol *msymbol = NULL;
50207163879Schristos 
50307163879Schristos   /* The objfile the symbol or minimal symbol were found in.  */
50407163879Schristos   const struct objfile *objfile = NULL;
50548596154Schristos };
50648596154Schristos 
507ed6a76a9Schristos /* The possible return values for print_bpstat, print_it_normal,
508ed6a76a9Schristos    print_it_done, print_it_noop.  */
509ed6a76a9Schristos enum print_stop_action
510ed6a76a9Schristos {
511ed6a76a9Schristos   /* We printed nothing or we need to do some more analysis.  */
512ed6a76a9Schristos   PRINT_UNKNOWN = -1,
513ed6a76a9Schristos 
514ed6a76a9Schristos   /* We printed something, and we *do* desire that something to be
515ed6a76a9Schristos      followed by a location.  */
516ed6a76a9Schristos   PRINT_SRC_AND_LOC,
517ed6a76a9Schristos 
518ed6a76a9Schristos   /* We printed something, and we do *not* desire that something to be
519ed6a76a9Schristos      followed by a location.  */
520ed6a76a9Schristos   PRINT_SRC_ONLY,
521ed6a76a9Schristos 
522ed6a76a9Schristos   /* We already printed all we needed to print, don't print anything
523ed6a76a9Schristos      else.  */
524ed6a76a9Schristos   PRINT_NOTHING
525ed6a76a9Schristos };
526ed6a76a9Schristos 
52766e63ce3Schristos /* This structure is a collection of function pointers that, if available,
52866e63ce3Schristos    will be called instead of the performing the default action for this
52966e63ce3Schristos    bptype.  */
53066e63ce3Schristos 
53166e63ce3Schristos struct breakpoint_ops
53266e63ce3Schristos {
53348596154Schristos   /* Allocate a location for this breakpoint.  */
53448596154Schristos   struct bp_location * (*allocate_location) (struct breakpoint *);
53548596154Schristos 
53648596154Schristos   /* Reevaluate a breakpoint.  This is necessary after symbols change
53748596154Schristos      (e.g., an executable or DSO was loaded, or the inferior just
53848596154Schristos      started).  */
53948596154Schristos   void (*re_set) (struct breakpoint *self);
54048596154Schristos 
54166e63ce3Schristos   /* Insert the breakpoint or watchpoint or activate the catchpoint.
54248596154Schristos      Return 0 for success, 1 if the breakpoint, watchpoint or
54348596154Schristos      catchpoint type is not supported, -1 for failure.  */
54466e63ce3Schristos   int (*insert_location) (struct bp_location *);
54566e63ce3Schristos 
54666e63ce3Schristos   /* Remove the breakpoint/catchpoint that was previously inserted
54766e63ce3Schristos      with the "insert" method above.  Return 0 for success, 1 if the
54866e63ce3Schristos      breakpoint, watchpoint or catchpoint type is not supported,
54966e63ce3Schristos      -1 for failure.  */
550c03b94e9Schristos   int (*remove_location) (struct bp_location *, enum remove_bp_reason reason);
55166e63ce3Schristos 
55248596154Schristos   /* Return true if it the target has stopped due to hitting
55348596154Schristos      breakpoint location BL.  This function does not check if we
55448596154Schristos      should stop, only if BL explains the stop.  ASPACE is the address
55548596154Schristos      space in which the event occurred, BP_ADDR is the address at
55648596154Schristos      which the inferior stopped, and WS is the target_waitstatus
55748596154Schristos      describing the event.  */
55848596154Schristos   int (*breakpoint_hit) (const struct bp_location *bl,
55907163879Schristos 			 const address_space *aspace,
56048596154Schristos 			 CORE_ADDR bp_addr,
56148596154Schristos 			 const struct target_waitstatus *ws);
56248596154Schristos 
56348596154Schristos   /* Check internal conditions of the breakpoint referred to by BS.
56448596154Schristos      If we should not stop for this breakpoint, set BS->stop to 0.  */
56548596154Schristos   void (*check_status) (struct bpstats *bs);
56666e63ce3Schristos 
56766e63ce3Schristos   /* Tell how many hardware resources (debug registers) are needed
56866e63ce3Schristos      for this breakpoint.  If this function is not provided, then
56966e63ce3Schristos      the breakpoint or watchpoint needs one debug register.  */
57066e63ce3Schristos   int (*resources_needed) (const struct bp_location *);
57166e63ce3Schristos 
57248596154Schristos   /* Tell whether we can downgrade from a hardware watchpoint to a software
57348596154Schristos      one.  If not, the user will not be able to enable the watchpoint when
57448596154Schristos      there are not enough hardware resources available.  */
57548596154Schristos   int (*works_in_software_mode) (const struct breakpoint *);
57648596154Schristos 
57766e63ce3Schristos   /* The normal print routine for this breakpoint, called when we
57866e63ce3Schristos      hit it.  */
57948596154Schristos   enum print_stop_action (*print_it) (struct bpstats *bs);
58066e63ce3Schristos 
58166e63ce3Schristos   /* Display information about this breakpoint, for "info
58266e63ce3Schristos      breakpoints".  */
58366e63ce3Schristos   void (*print_one) (struct breakpoint *, struct bp_location **);
58466e63ce3Schristos 
58566e63ce3Schristos   /* Display extra information about this breakpoint, below the normal
58666e63ce3Schristos      breakpoint description in "info breakpoints".
58766e63ce3Schristos 
58866e63ce3Schristos      In the example below, the "address range" line was printed
58966e63ce3Schristos      by print_one_detail_ranged_breakpoint.
59066e63ce3Schristos 
59166e63ce3Schristos      (gdb) info breakpoints
59266e63ce3Schristos      Num     Type           Disp Enb Address    What
59366e63ce3Schristos      2       hw breakpoint  keep y              in main at test-watch.c:70
59466e63ce3Schristos 	     address range: [0x10000458, 0x100004c7]
59566e63ce3Schristos 
59666e63ce3Schristos    */
59766e63ce3Schristos   void (*print_one_detail) (const struct breakpoint *, struct ui_out *);
59866e63ce3Schristos 
59966e63ce3Schristos   /* Display information about this breakpoint after setting it
60066e63ce3Schristos      (roughly speaking; this is called from "mention").  */
60166e63ce3Schristos   void (*print_mention) (struct breakpoint *);
60266e63ce3Schristos 
60366e63ce3Schristos   /* Print to FP the CLI command that recreates this breakpoint.  */
60466e63ce3Schristos   void (*print_recreate) (struct breakpoint *, struct ui_file *fp);
60548596154Schristos 
606c03b94e9Schristos   /* Create SALs from location, storing the result in linespec_result.
60748596154Schristos 
60848596154Schristos      For an explanation about the arguments, see the function
609c03b94e9Schristos      `create_sals_from_location_default'.
61048596154Schristos 
61148596154Schristos      This function is called inside `create_breakpoint'.  */
612*1424dfb3Schristos   void (*create_sals_from_location) (struct event_location *location,
613c03b94e9Schristos 				     struct linespec_result *canonical,
614c03b94e9Schristos 				     enum bptype type_wanted);
61548596154Schristos 
61648596154Schristos   /* This method will be responsible for creating a breakpoint given its SALs.
61748596154Schristos      Usually, it just calls `create_breakpoints_sal' (for ordinary
61848596154Schristos      breakpoints).  However, there may be some special cases where we might
61948596154Schristos      need to do some tweaks, e.g., see
62048596154Schristos      `strace_marker_create_breakpoints_sal'.
62148596154Schristos 
62248596154Schristos      This function is called inside `create_breakpoint'.  */
62348596154Schristos   void (*create_breakpoints_sal) (struct gdbarch *,
62448596154Schristos 				  struct linespec_result *,
62507163879Schristos 				  gdb::unique_xmalloc_ptr<char>,
62607163879Schristos 				  gdb::unique_xmalloc_ptr<char>,
62748596154Schristos 				  enum bptype, enum bpdisp, int, int,
62848596154Schristos 				  int, const struct breakpoint_ops *,
62948596154Schristos 				  int, int, int, unsigned);
63048596154Schristos 
631c03b94e9Schristos   /* Given the location (second parameter), this method decodes it and
63207163879Schristos      returns the SAL locations related to it.  For ordinary
633c03b94e9Schristos      breakpoints, it calls `decode_line_full'.  If SEARCH_PSPACE is
634c03b94e9Schristos      not NULL, symbol search is restricted to just that program space.
63548596154Schristos 
636c03b94e9Schristos      This function is called inside `location_to_sals'.  */
63707163879Schristos   std::vector<symtab_and_line> (*decode_location)
63807163879Schristos     (struct breakpoint *b,
639*1424dfb3Schristos      struct event_location *location,
64007163879Schristos      struct program_space *search_pspace);
64148596154Schristos 
6427af5a897Schristos   /* Return true if this breakpoint explains a signal.  See
64348596154Schristos      bpstat_explains_signal.  */
6447af5a897Schristos   int (*explains_signal) (struct breakpoint *, enum gdb_signal);
64548596154Schristos 
64648596154Schristos   /* Called after evaluating the breakpoint's condition,
64748596154Schristos      and only if it evaluated true.  */
64848596154Schristos   void (*after_condition_true) (struct bpstats *bs);
64966e63ce3Schristos };
65066e63ce3Schristos 
65148596154Schristos /* Helper for breakpoint_ops->print_recreate implementations.  Prints
65248596154Schristos    the "thread" or "task" condition of B, and then a newline.
65348596154Schristos 
65448596154Schristos    Necessary because most breakpoint implementations accept
65548596154Schristos    thread/task conditions at the end of the spec line, like "break foo
65648596154Schristos    thread 1", which needs outputting before any breakpoint-type
65748596154Schristos    specific extra command necessary for B's recreation.  */
65848596154Schristos extern void print_recreate_thread (struct breakpoint *b, struct ui_file *fp);
65948596154Schristos 
66066e63ce3Schristos enum watchpoint_triggered
66166e63ce3Schristos {
66266e63ce3Schristos   /* This watchpoint definitely did not trigger.  */
66366e63ce3Schristos   watch_triggered_no = 0,
66466e63ce3Schristos 
66566e63ce3Schristos   /* Some hardware watchpoint triggered, and it might have been this
66666e63ce3Schristos      one, but we do not know which it was.  */
66766e63ce3Schristos   watch_triggered_unknown,
66866e63ce3Schristos 
66966e63ce3Schristos   /* This hardware watchpoint definitely did trigger.  */
67066e63ce3Schristos   watch_triggered_yes
67166e63ce3Schristos };
67266e63ce3Schristos 
67366e63ce3Schristos /* Some targets (e.g., embedded PowerPC) need two debug registers to set
67466e63ce3Schristos    a watchpoint over a memory region.  If this flag is true, GDB will use
675*1424dfb3Schristos    only one register per watchpoint, thus assuming that all accesses that
67666e63ce3Schristos    modify a memory location happen at its starting address. */
67766e63ce3Schristos 
678*1424dfb3Schristos extern bool target_exact_watchpoints;
67966e63ce3Schristos 
68066e63ce3Schristos /* Note that the ->silent field is not currently used by any commands
68166e63ce3Schristos    (though the code is in there if it was to be, and set_raw_breakpoint
68266e63ce3Schristos    does set it to 0).  I implemented it because I thought it would be
68366e63ce3Schristos    useful for a hack I had to put in; I'm going to leave it in because
68466e63ce3Schristos    I can see how there might be times when it would indeed be useful */
68566e63ce3Schristos 
68648596154Schristos /* This is for all kinds of breakpoints.  */
68766e63ce3Schristos 
68866e63ce3Schristos struct breakpoint
68966e63ce3Schristos {
69007163879Schristos   virtual ~breakpoint ();
69148596154Schristos 
69207163879Schristos   /* Methods associated with this breakpoint.  */
69307163879Schristos   const breakpoint_ops *ops = NULL;
69407163879Schristos 
69507163879Schristos   breakpoint *next = NULL;
69666e63ce3Schristos   /* Type of breakpoint.  */
69707163879Schristos   bptype type = bp_none;
69866e63ce3Schristos   /* Zero means disabled; remember the info but don't break here.  */
69907163879Schristos   enum enable_state enable_state = bp_enabled;
70066e63ce3Schristos   /* What to do with this breakpoint after we hit it.  */
70107163879Schristos   bpdisp disposition = disp_del;
70266e63ce3Schristos   /* Number assigned to distinguish breakpoints.  */
70307163879Schristos   int number = 0;
70466e63ce3Schristos 
70566e63ce3Schristos   /* Location(s) associated with this high-level breakpoint.  */
70607163879Schristos   bp_location *loc = NULL;
70766e63ce3Schristos 
70807163879Schristos   /* True means a silent breakpoint (don't print frame info if we stop
70907163879Schristos      here).  */
71007163879Schristos   bool silent = false;
71107163879Schristos   /* True means display ADDR_STRING to the user verbatim.  */
71207163879Schristos   bool display_canonical = false;
7131c468f90Schristos   /* Number of stops at this breakpoint that should be continued
7141c468f90Schristos      automatically before really stopping.  */
71507163879Schristos   int ignore_count = 0;
71648596154Schristos 
71748596154Schristos   /* Number of stops at this breakpoint before it will be
71848596154Schristos      disabled.  */
71907163879Schristos   int enable_count = 0;
72048596154Schristos 
72166e63ce3Schristos   /* Chain of command lines to execute when this breakpoint is
72266e63ce3Schristos      hit.  */
72307163879Schristos   counted_command_line commands;
72466e63ce3Schristos   /* Stack depth (address of frame).  If nonzero, break only if fp
72566e63ce3Schristos      equals this.  */
72607163879Schristos   struct frame_id frame_id = null_frame_id;
72766e63ce3Schristos 
72848596154Schristos   /* The program space used to set the breakpoint.  This is only set
72948596154Schristos      for breakpoints which are specific to a program space; for
73048596154Schristos      non-thread-specific ordinary breakpoints this is NULL.  */
73107163879Schristos   program_space *pspace = NULL;
73266e63ce3Schristos 
7331c468f90Schristos   /* Location we used to set the breakpoint.  */
7341c468f90Schristos   event_location_up location;
73566e63ce3Schristos 
73648596154Schristos   /* The filter that should be passed to decode_line_full when
737*1424dfb3Schristos      re-setting this breakpoint.  This may be NULL.  */
738*1424dfb3Schristos   gdb::unique_xmalloc_ptr<char> filter;
73948596154Schristos 
7401c468f90Schristos   /* For a ranged breakpoint, the location we used to find the end of
7411c468f90Schristos      the range.  */
7421c468f90Schristos   event_location_up location_range_end;
74366e63ce3Schristos 
74466e63ce3Schristos   /* Architecture we used to set the breakpoint.  */
74507163879Schristos   struct gdbarch *gdbarch = NULL;
74666e63ce3Schristos   /* Language we used to set the breakpoint.  */
74707163879Schristos   enum language language = language_unknown;
74866e63ce3Schristos   /* Input radix we used to set the breakpoint.  */
74907163879Schristos   int input_radix = 0;
75066e63ce3Schristos   /* String form of the breakpoint condition (malloc'd), or NULL if
75166e63ce3Schristos      there is no condition.  */
75207163879Schristos   char *cond_string = NULL;
75366e63ce3Schristos 
7547af5a897Schristos   /* String form of extra parameters, or NULL if there are none.
7557af5a897Schristos      Malloc'd.  */
75607163879Schristos   char *extra_string = NULL;
75766e63ce3Schristos 
7581c468f90Schristos   /* Holds the address of the related watchpoint_scope breakpoint when
7591c468f90Schristos      using watchpoints on local variables (might the concept of a
7601c468f90Schristos      related breakpoint be useful elsewhere, if not just call it the
7611c468f90Schristos      watchpoint_scope breakpoint or something like that.  FIXME).  */
76207163879Schristos   breakpoint *related_breakpoint = NULL;
76366e63ce3Schristos 
7641c468f90Schristos   /* Thread number for thread-specific breakpoint, or -1 if don't
7651c468f90Schristos      care.  */
76607163879Schristos   int thread = -1;
76766e63ce3Schristos 
7681c468f90Schristos   /* Ada task number for task-specific breakpoint, or 0 if don't
7691c468f90Schristos      care.  */
77007163879Schristos   int task = 0;
77166e63ce3Schristos 
77266e63ce3Schristos   /* Count of the number of times this breakpoint was taken, dumped
7731c468f90Schristos      with the info, but not used for anything else.  Useful for seeing
7741c468f90Schristos      how many times you hit a break prior to the program aborting, so
7751c468f90Schristos      you can back up to just before the abort.  */
77607163879Schristos   int hit_count = 0;
77766e63ce3Schristos 
7781c468f90Schristos   /* Is breakpoint's condition not yet parsed because we found no
7791c468f90Schristos      location initially so had no context to parse the condition
7801c468f90Schristos      in.  */
78107163879Schristos   int condition_not_parsed = 0;
78266e63ce3Schristos 
78348596154Schristos   /* With a Python scripting enabled GDB, store a reference to the
78448596154Schristos      Python object that has been associated with this breakpoint.
7851c468f90Schristos      This is always NULL for a GDB that is not script enabled.  It can
7861c468f90Schristos      sometimes be NULL for enabled GDBs as not all breakpoint types
7871c468f90Schristos      are tracked by the scripting language API.  */
78807163879Schristos   gdbpy_breakpoint_object *py_bp_object = NULL;
78926a53354Schristos 
79026a53354Schristos   /* Same as py_bp_object, but for Scheme.  */
79107163879Schristos   gdbscm_breakpoint_object *scm_bp_object = NULL;
79248596154Schristos };
79348596154Schristos 
79407163879Schristos /* An instance of this type is used to represent a watchpoint.  */
79548596154Schristos 
79607163879Schristos struct watchpoint : public breakpoint
79748596154Schristos {
79807163879Schristos   ~watchpoint () override;
79948596154Schristos 
80048596154Schristos   /* String form of exp to use for displaying to the user (malloc'd),
80148596154Schristos      or NULL if none.  */
80248596154Schristos   char *exp_string;
80348596154Schristos   /* String form to use for reparsing of EXP (malloc'd) or NULL.  */
80448596154Schristos   char *exp_string_reparse;
80548596154Schristos 
80648596154Schristos   /* The expression we are watching, or NULL if not a watchpoint.  */
8071c468f90Schristos   expression_up exp;
80848596154Schristos   /* The largest block within which it is valid, or NULL if it is
80948596154Schristos      valid anywhere (e.g. consists just of global symbols).  */
81048596154Schristos   const struct block *exp_valid_block;
81148596154Schristos   /* The conditional expression if any.  */
8121c468f90Schristos   expression_up cond_exp;
81348596154Schristos   /* The largest block within which it is valid, or NULL if it is
81448596154Schristos      valid anywhere (e.g. consists just of global symbols).  */
81548596154Schristos   const struct block *cond_exp_valid_block;
81648596154Schristos   /* Value of the watchpoint the last time we checked it, or NULL when
81748596154Schristos      we do not know the value yet or the value was not readable.  VAL
81848596154Schristos      is never lazy.  */
81907163879Schristos   value_ref_ptr val;
820*1424dfb3Schristos 
821*1424dfb3Schristos   /* True if VAL is valid.  If VAL_VALID is set but VAL is NULL,
82248596154Schristos      then an error occurred reading the value.  */
823*1424dfb3Schristos   bool val_valid;
82448596154Schristos 
82526a53354Schristos   /* When watching the location of a bitfield, contains the offset and size of
82626a53354Schristos      the bitfield.  Otherwise contains 0.  */
82726a53354Schristos   int val_bitpos;
82826a53354Schristos   int val_bitsize;
82926a53354Schristos 
83048596154Schristos   /* Holds the frame address which identifies the frame this
83148596154Schristos      watchpoint should be evaluated in, or `null' if the watchpoint
83248596154Schristos      should be evaluated on the outermost frame.  */
83348596154Schristos   struct frame_id watchpoint_frame;
83448596154Schristos 
83548596154Schristos   /* Holds the thread which identifies the frame this watchpoint
83648596154Schristos      should be considered in scope for, or `null_ptid' if the
83748596154Schristos      watchpoint should be evaluated in all threads.  */
83848596154Schristos   ptid_t watchpoint_thread;
83948596154Schristos 
84048596154Schristos   /* For hardware watchpoints, the triggered status according to the
84148596154Schristos      hardware.  */
84248596154Schristos   enum watchpoint_triggered watchpoint_triggered;
84348596154Schristos 
84448596154Schristos   /* Whether this watchpoint is exact (see
84548596154Schristos      target_exact_watchpoints).  */
84648596154Schristos   int exact;
84748596154Schristos 
84848596154Schristos   /* The mask address for a masked hardware watchpoint.  */
84948596154Schristos   CORE_ADDR hw_wp_mask;
85048596154Schristos };
85148596154Schristos 
852ed6a76a9Schristos /* Given a function FUNC (struct breakpoint *B, void *DATA) and
853ed6a76a9Schristos    USER_DATA, call FUNC for every known breakpoint passing USER_DATA
854ed6a76a9Schristos    as argument.
855ed6a76a9Schristos 
856ed6a76a9Schristos    If FUNC returns 1, the loop stops and the current
857ed6a76a9Schristos    'struct breakpoint' being processed is returned.  If FUNC returns
858ed6a76a9Schristos    zero, the loop continues.
859ed6a76a9Schristos 
860ed6a76a9Schristos    This function returns either a 'struct breakpoint' pointer or NULL.
861ed6a76a9Schristos    It was based on BFD's bfd_sections_find_if function.  */
862ed6a76a9Schristos 
863ed6a76a9Schristos extern struct breakpoint *breakpoint_find_if
864ed6a76a9Schristos   (int (*func) (struct breakpoint *b, void *d), void *user_data);
865ed6a76a9Schristos 
86648596154Schristos /* Return true if BPT is either a software breakpoint or a hardware
86748596154Schristos    breakpoint.  */
86848596154Schristos 
869*1424dfb3Schristos extern bool is_breakpoint (const struct breakpoint *bpt);
87048596154Schristos 
871*1424dfb3Schristos /* Return true if BPT is of any watchpoint kind, hardware or
872*1424dfb3Schristos    software.  */
87348596154Schristos 
874*1424dfb3Schristos extern bool is_watchpoint (const struct breakpoint *bpt);
875*1424dfb3Schristos 
876*1424dfb3Schristos /* Return true if BPT is a C++ exception catchpoint (catch
877*1424dfb3Schristos    catch/throw/rethrow).  */
878*1424dfb3Schristos 
879*1424dfb3Schristos extern bool is_exception_catchpoint (breakpoint *bp);
88048596154Schristos 
88148596154Schristos /* An instance of this type is used to represent all kinds of
88207163879Schristos    tracepoints.  */
88348596154Schristos 
88407163879Schristos struct tracepoint : public breakpoint
88548596154Schristos {
88648596154Schristos   /* Number of times this tracepoint should single-step and collect
88748596154Schristos      additional data.  */
88866e63ce3Schristos   long step_count;
88966e63ce3Schristos 
89066e63ce3Schristos   /* Number of times this tracepoint should be hit before
89166e63ce3Schristos      disabling/ending.  */
89266e63ce3Schristos   int pass_count;
89366e63ce3Schristos 
89466e63ce3Schristos   /* The number of the tracepoint on the target.  */
89566e63ce3Schristos   int number_on_target;
89666e63ce3Schristos 
89748596154Schristos   /* The total space taken by all the trace frames for this
89848596154Schristos      tracepoint.  */
89948596154Schristos   ULONGEST traceframe_usage;
90048596154Schristos 
90166e63ce3Schristos   /* The static tracepoint marker id, if known.  */
90207163879Schristos   std::string static_trace_marker_id;
90366e63ce3Schristos 
90466e63ce3Schristos   /* LTTng/UST allow more than one marker with the same ID string,
90566e63ce3Schristos      although it unadvised because it confuses tools.  When setting
90666e63ce3Schristos      static tracepoints by marker ID, this will record the index in
90766e63ce3Schristos      the array of markers we found for the given marker ID for which
90848596154Schristos      this static tracepoint corresponds.  When resetting breakpoints,
90948596154Schristos      we will use this index to try to find the same marker again.  */
91066e63ce3Schristos   int static_trace_marker_id_idx;
91166e63ce3Schristos };
91266e63ce3Schristos 
91366e63ce3Schristos 
91466e63ce3Schristos /* The following stuff is an abstract data type "bpstat" ("breakpoint
91566e63ce3Schristos    status").  This provides the ability to determine whether we have
91666e63ce3Schristos    stopped at a breakpoint, and what we should do about it.  */
91766e63ce3Schristos 
91866e63ce3Schristos typedef struct bpstats *bpstat;
91966e63ce3Schristos 
92066e63ce3Schristos /* Clears a chain of bpstat, freeing storage
92166e63ce3Schristos    of each.  */
92266e63ce3Schristos extern void bpstat_clear (bpstat *);
92366e63ce3Schristos 
92466e63ce3Schristos /* Return a copy of a bpstat.  Like "bs1 = bs2" but all storage that
92566e63ce3Schristos    is part of the bpstat is copied as well.  */
92666e63ce3Schristos extern bpstat bpstat_copy (bpstat);
92766e63ce3Schristos 
92807163879Schristos /* Build the (raw) bpstat chain for the stop information given by ASPACE,
92907163879Schristos    BP_ADDR, and WS.  Returns the head of the bpstat chain.  */
93007163879Schristos 
93107163879Schristos extern bpstat build_bpstat_chain (const address_space *aspace,
93207163879Schristos 				  CORE_ADDR bp_addr,
93348596154Schristos 				  const struct target_waitstatus *ws);
93407163879Schristos 
93507163879Schristos /* Get a bpstat associated with having just stopped at address
93607163879Schristos    BP_ADDR in thread PTID.  STOP_CHAIN may be supplied as a previously
93707163879Schristos    computed stop chain or NULL, in which case the stop chain will be
93807163879Schristos    computed using build_bpstat_chain.
93907163879Schristos 
94007163879Schristos    Determine whether we stopped at a breakpoint, etc, or whether we
94107163879Schristos    don't understand this stop.  Result is a chain of bpstat's such
94207163879Schristos    that:
94307163879Schristos 
94407163879Schristos    if we don't understand the stop, the result is a null pointer.
94507163879Schristos 
94607163879Schristos    if we understand why we stopped, the result is not null.
94707163879Schristos 
94807163879Schristos    Each element of the chain refers to a particular breakpoint or
94907163879Schristos    watchpoint at which we have stopped.  (We may have stopped for
95007163879Schristos    several reasons concurrently.)
95107163879Schristos 
95207163879Schristos    Each element of the chain has valid next, breakpoint_at,
95307163879Schristos    commands, FIXME??? fields.  */
95407163879Schristos 
95507163879Schristos extern bpstat bpstat_stop_status (const address_space *aspace,
95607163879Schristos 				  CORE_ADDR pc, thread_info *thread,
95707163879Schristos 				  const struct target_waitstatus *ws,
95807163879Schristos 				  bpstat stop_chain = NULL);
95966e63ce3Schristos 
96066e63ce3Schristos /* This bpstat_what stuff tells wait_for_inferior what to do with a
96166e63ce3Schristos    breakpoint (a challenging task).
96266e63ce3Schristos 
96366e63ce3Schristos    The enum values order defines priority-like order of the actions.
96466e63ce3Schristos    Once you've decided that some action is appropriate, you'll never
96566e63ce3Schristos    go back and decide something of a lower priority is better.  Each
96666e63ce3Schristos    of these actions is mutually exclusive with the others.  That
96766e63ce3Schristos    means, that if you find yourself adding a new action class here and
96866e63ce3Schristos    wanting to tell GDB that you have two simultaneous actions to
96966e63ce3Schristos    handle, something is wrong, and you probably don't actually need a
97066e63ce3Schristos    new action type.
97166e63ce3Schristos 
97266e63ce3Schristos    Note that a step resume breakpoint overrides another breakpoint of
97366e63ce3Schristos    signal handling (see comment in wait_for_inferior at where we set
97466e63ce3Schristos    the step_resume breakpoint).  */
97566e63ce3Schristos 
97666e63ce3Schristos enum bpstat_what_main_action
97766e63ce3Schristos   {
97866e63ce3Schristos     /* Perform various other tests; that is, this bpstat does not
97966e63ce3Schristos        say to perform any action (e.g. failed watchpoint and nothing
98066e63ce3Schristos        else).  */
98166e63ce3Schristos     BPSTAT_WHAT_KEEP_CHECKING,
98266e63ce3Schristos 
98366e63ce3Schristos     /* Remove breakpoints, single step once, then put them back in and
98466e63ce3Schristos        go back to what we were doing.  It's possible that this should
98566e63ce3Schristos        be removed from the main_action and put into a separate field,
98666e63ce3Schristos        to more cleanly handle
98766e63ce3Schristos        BPSTAT_WHAT_CLEAR_LONGJMP_RESUME_SINGLE.  */
98866e63ce3Schristos     BPSTAT_WHAT_SINGLE,
98966e63ce3Schristos 
99066e63ce3Schristos     /* Set longjmp_resume breakpoint, remove all other breakpoints,
99166e63ce3Schristos        and continue.  The "remove all other breakpoints" part is
99266e63ce3Schristos        required if we are also stepping over another breakpoint as
99366e63ce3Schristos        well as doing the longjmp handling.  */
99466e63ce3Schristos     BPSTAT_WHAT_SET_LONGJMP_RESUME,
99566e63ce3Schristos 
99666e63ce3Schristos     /* Clear longjmp_resume breakpoint, then handle as
99766e63ce3Schristos        BPSTAT_WHAT_KEEP_CHECKING.  */
99866e63ce3Schristos     BPSTAT_WHAT_CLEAR_LONGJMP_RESUME,
99966e63ce3Schristos 
100048596154Schristos     /* Clear step resume breakpoint, and keep checking.  */
100148596154Schristos     BPSTAT_WHAT_STEP_RESUME,
100248596154Schristos 
100366e63ce3Schristos     /* Rather than distinguish between noisy and silent stops here, it
100466e63ce3Schristos        might be cleaner to have bpstat_print make that decision (also
100566e63ce3Schristos        taking into account stop_print_frame and source_only).  But the
100666e63ce3Schristos        implications are a bit scary (interaction with auto-displays,
100766e63ce3Schristos        etc.), so I won't try it.  */
100866e63ce3Schristos 
100966e63ce3Schristos     /* Stop silently.  */
101066e63ce3Schristos     BPSTAT_WHAT_STOP_SILENT,
101166e63ce3Schristos 
101266e63ce3Schristos     /* Stop and print.  */
101366e63ce3Schristos     BPSTAT_WHAT_STOP_NOISY,
101466e63ce3Schristos 
101548596154Schristos     /* Clear step resume breakpoint, and keep checking.  High-priority
101648596154Schristos        step-resume breakpoints are used when even if there's a user
101748596154Schristos        breakpoint at the current PC when we set the step-resume
101848596154Schristos        breakpoint, we don't want to re-handle any breakpoint other
101948596154Schristos        than the step-resume when it's hit; instead we want to move
102048596154Schristos        past the breakpoint.  This is used in the case of skipping
102148596154Schristos        signal handlers.  */
102248596154Schristos     BPSTAT_WHAT_HP_STEP_RESUME,
102366e63ce3Schristos   };
102466e63ce3Schristos 
102566e63ce3Schristos /* An enum indicating the kind of "stack dummy" stop.  This is a bit
102666e63ce3Schristos    of a misnomer because only one kind of truly a stack dummy.  */
102766e63ce3Schristos enum stop_stack_kind
102866e63ce3Schristos   {
102966e63ce3Schristos     /* We didn't stop at a stack dummy breakpoint.  */
103066e63ce3Schristos     STOP_NONE = 0,
103166e63ce3Schristos 
103266e63ce3Schristos     /* Stopped at a stack dummy.  */
103366e63ce3Schristos     STOP_STACK_DUMMY,
103466e63ce3Schristos 
103566e63ce3Schristos     /* Stopped at std::terminate.  */
103666e63ce3Schristos     STOP_STD_TERMINATE
103766e63ce3Schristos   };
103866e63ce3Schristos 
103966e63ce3Schristos struct bpstat_what
104066e63ce3Schristos   {
104166e63ce3Schristos     enum bpstat_what_main_action main_action;
104266e63ce3Schristos 
104366e63ce3Schristos     /* Did we hit a call dummy breakpoint?  This only goes with a
104466e63ce3Schristos        main_action of BPSTAT_WHAT_STOP_SILENT or
104566e63ce3Schristos        BPSTAT_WHAT_STOP_NOISY (the concept of continuing from a call
104666e63ce3Schristos        dummy without popping the frame is not a useful one).  */
104766e63ce3Schristos     enum stop_stack_kind call_dummy;
104866e63ce3Schristos 
104966e63ce3Schristos     /* Used for BPSTAT_WHAT_SET_LONGJMP_RESUME and
105066e63ce3Schristos        BPSTAT_WHAT_CLEAR_LONGJMP_RESUME.  True if we are handling a
105166e63ce3Schristos        longjmp, false if we are handling an exception.  */
1052*1424dfb3Schristos     bool is_longjmp;
105366e63ce3Schristos   };
105466e63ce3Schristos 
105566e63ce3Schristos /* Tell what to do about this bpstat.  */
105666e63ce3Schristos struct bpstat_what bpstat_what (bpstat);
1057c03b94e9Schristos 
1058c03b94e9Schristos /* Run breakpoint event callbacks associated with the breakpoints that
1059c03b94e9Schristos    triggered.  */
1060c03b94e9Schristos extern void bpstat_run_callbacks (bpstat bs_head);
1061c03b94e9Schristos 
106266e63ce3Schristos /* Find the bpstat associated with a breakpoint.  NULL otherwise.  */
106366e63ce3Schristos bpstat bpstat_find_breakpoint (bpstat, struct breakpoint *);
106466e63ce3Schristos 
1065*1424dfb3Schristos /* True if a signal that we got in target_wait() was due to
10667af5a897Schristos    circumstances explained by the bpstat; the signal is therefore not
10677af5a897Schristos    random.  */
1068*1424dfb3Schristos extern bool bpstat_explains_signal (bpstat, enum gdb_signal);
106966e63ce3Schristos 
1070*1424dfb3Schristos /* True if this bpstat causes a stop.  */
1071*1424dfb3Schristos extern bool bpstat_causes_stop (bpstat);
107266e63ce3Schristos 
1073*1424dfb3Schristos /* True if we should step constantly (e.g. watchpoints on machines
107466e63ce3Schristos    without hardware support).  This isn't related to a specific bpstat,
107566e63ce3Schristos    just to things like whether watchpoints are set.  */
1076*1424dfb3Schristos extern bool bpstat_should_step ();
107766e63ce3Schristos 
107866e63ce3Schristos /* Print a message indicating what happened.  Returns nonzero to
107966e63ce3Schristos    say that only the source line should be printed after this (zero
108066e63ce3Schristos    return means print the frame as well as the source line).  */
108148596154Schristos extern enum print_stop_action bpstat_print (bpstat, int);
108266e63ce3Schristos 
108366e63ce3Schristos /* Put in *NUM the breakpoint number of the first breakpoint we are
108466e63ce3Schristos    stopped at.  *BSP upon return is a bpstat which points to the
108566e63ce3Schristos    remaining breakpoints stopped at (but which is not guaranteed to be
108666e63ce3Schristos    good for anything but further calls to bpstat_num).
108766e63ce3Schristos 
108866e63ce3Schristos    Return 0 if passed a bpstat which does not indicate any breakpoints.
108966e63ce3Schristos    Return -1 if stopped at a breakpoint that has been deleted since
109066e63ce3Schristos    we set it.
109166e63ce3Schristos    Return 1 otherwise.  */
109266e63ce3Schristos extern int bpstat_num (bpstat *, int *);
109366e63ce3Schristos 
109466e63ce3Schristos /* Perform actions associated with the stopped inferior.  Actually, we
109566e63ce3Schristos    just use this for breakpoint commands.  Perhaps other actions will
109666e63ce3Schristos    go here later, but this is executed at a late time (from the
109766e63ce3Schristos    command loop).  */
109866e63ce3Schristos extern void bpstat_do_actions (void);
109966e63ce3Schristos 
110048596154Schristos /* Modify all entries of STOP_BPSTAT of INFERIOR_PTID so that the actions will
110148596154Schristos    not be performed.  */
110248596154Schristos extern void bpstat_clear_actions (void);
110366e63ce3Schristos 
110466e63ce3Schristos /* Implementation:  */
110566e63ce3Schristos 
110666e63ce3Schristos /* Values used to tell the printing routine how to behave for this
110766e63ce3Schristos    bpstat.  */
110866e63ce3Schristos enum bp_print_how
110966e63ce3Schristos   {
111066e63ce3Schristos     /* This is used when we want to do a normal printing of the reason
111166e63ce3Schristos        for stopping.  The output will depend on the type of eventpoint
111266e63ce3Schristos        we are dealing with.  This is the default value, most commonly
111366e63ce3Schristos        used.  */
111466e63ce3Schristos     print_it_normal,
111566e63ce3Schristos     /* This is used when nothing should be printed for this bpstat
111666e63ce3Schristos        entry.  */
111766e63ce3Schristos     print_it_noop,
111866e63ce3Schristos     /* This is used when everything which needs to be printed has
111966e63ce3Schristos        already been printed.  But we still want to print the frame.  */
112066e63ce3Schristos     print_it_done
112166e63ce3Schristos   };
112266e63ce3Schristos 
112366e63ce3Schristos struct bpstats
112466e63ce3Schristos   {
112507163879Schristos     bpstats ();
112607163879Schristos     bpstats (struct bp_location *bl, bpstat **bs_link_pointer);
112707163879Schristos     ~bpstats ();
112807163879Schristos 
112907163879Schristos     bpstats (const bpstats &);
113007163879Schristos     bpstats &operator= (const bpstats &) = delete;
113107163879Schristos 
113266e63ce3Schristos     /* Linked list because there can be more than one breakpoint at
113366e63ce3Schristos        the same place, and a bpstat reflects the fact that all have
113466e63ce3Schristos        been hit.  */
113566e63ce3Schristos     bpstat next;
113666e63ce3Schristos 
113766e63ce3Schristos     /* Location that caused the stop.  Locations are refcounted, so
113866e63ce3Schristos        this will never be NULL.  Note that this location may end up
113966e63ce3Schristos        detached from a breakpoint, but that does not necessary mean
114066e63ce3Schristos        that the struct breakpoint is gone.  E.g., consider a
114166e63ce3Schristos        watchpoint with a condition that involves an inferior function
114266e63ce3Schristos        call.  Watchpoint locations are recreated often (on resumes,
114366e63ce3Schristos        hence on infcalls too).  Between creating the bpstat and after
114466e63ce3Schristos        evaluating the watchpoint condition, this location may hence
114566e63ce3Schristos        end up detached from its original owner watchpoint, even though
114666e63ce3Schristos        the watchpoint is still listed.  If it's condition evaluates as
114766e63ce3Schristos        true, we still want this location to cause a stop, and we will
114866e63ce3Schristos        still need to know which watchpoint it was originally attached.
114966e63ce3Schristos        What this means is that we should not (in most cases) follow
115066e63ce3Schristos        the `bpstat->bp_location->owner' link, but instead use the
115166e63ce3Schristos        `breakpoint_at' field below.  */
115266e63ce3Schristos     struct bp_location *bp_location_at;
115366e63ce3Schristos 
115466e63ce3Schristos     /* Breakpoint that caused the stop.  This is nullified if the
115566e63ce3Schristos        breakpoint ends up being deleted.  See comments on
115666e63ce3Schristos        `bp_location_at' above for why do we need this field instead of
115766e63ce3Schristos        following the location's owner.  */
115866e63ce3Schristos     struct breakpoint *breakpoint_at;
115966e63ce3Schristos 
116066e63ce3Schristos     /* The associated command list.  */
116107163879Schristos     counted_command_line commands;
116266e63ce3Schristos 
116366e63ce3Schristos     /* Old value associated with a watchpoint.  */
116407163879Schristos     value_ref_ptr old_val;
116566e63ce3Schristos 
116666e63ce3Schristos     /* Nonzero if this breakpoint tells us to print the frame.  */
116766e63ce3Schristos     char print;
116866e63ce3Schristos 
116966e63ce3Schristos     /* Nonzero if this breakpoint tells us to stop.  */
117066e63ce3Schristos     char stop;
117166e63ce3Schristos 
117266e63ce3Schristos     /* Tell bpstat_print and print_bp_stop_message how to print stuff
117366e63ce3Schristos        associated with this element of the bpstat chain.  */
117466e63ce3Schristos     enum bp_print_how print_it;
117566e63ce3Schristos   };
117666e63ce3Schristos 
117766e63ce3Schristos enum inf_context
117866e63ce3Schristos   {
117966e63ce3Schristos     inf_starting,
118066e63ce3Schristos     inf_running,
118166e63ce3Schristos     inf_exited,
118266e63ce3Schristos     inf_execd
118366e63ce3Schristos   };
118466e63ce3Schristos 
118566e63ce3Schristos /* The possible return values for breakpoint_here_p.
118666e63ce3Schristos    We guarantee that zero always means "no breakpoint here".  */
118766e63ce3Schristos enum breakpoint_here
118866e63ce3Schristos   {
118966e63ce3Schristos     no_breakpoint_here = 0,
119066e63ce3Schristos     ordinary_breakpoint_here,
119166e63ce3Schristos     permanent_breakpoint_here
119266e63ce3Schristos   };
119366e63ce3Schristos 
119466e63ce3Schristos 
119566e63ce3Schristos /* Prototypes for breakpoint-related functions.  */
119666e63ce3Schristos 
119707163879Schristos extern enum breakpoint_here breakpoint_here_p (const address_space *,
119866e63ce3Schristos 					       CORE_ADDR);
119966e63ce3Schristos 
1200c03b94e9Schristos /* Return true if an enabled breakpoint exists in the range defined by
1201c03b94e9Schristos    ADDR and LEN, in ASPACE.  */
120207163879Schristos extern int breakpoint_in_range_p (const address_space *aspace,
1203c03b94e9Schristos 				  CORE_ADDR addr, ULONGEST len);
1204c03b94e9Schristos 
120507163879Schristos extern int moribund_breakpoint_here_p (const address_space *, CORE_ADDR);
120666e63ce3Schristos 
120707163879Schristos extern int breakpoint_inserted_here_p (const address_space *,
120866e63ce3Schristos 				       CORE_ADDR);
120966e63ce3Schristos 
121007163879Schristos extern int software_breakpoint_inserted_here_p (const address_space *,
121166e63ce3Schristos 						CORE_ADDR);
121266e63ce3Schristos 
121326a53354Schristos /* Return non-zero iff there is a hardware breakpoint inserted at
121426a53354Schristos    PC.  */
121507163879Schristos extern int hardware_breakpoint_inserted_here_p (const address_space *,
121626a53354Schristos 						CORE_ADDR);
121726a53354Schristos 
121826a53354Schristos /* Check whether any location of BP is inserted at PC.  */
121926a53354Schristos 
122026a53354Schristos extern int breakpoint_has_location_inserted_here (struct breakpoint *bp,
122107163879Schristos 						  const address_space *aspace,
122226a53354Schristos 						  CORE_ADDR pc);
122326a53354Schristos 
122407163879Schristos extern int single_step_breakpoint_inserted_here_p (const address_space *,
122526a53354Schristos 						   CORE_ADDR);
122626a53354Schristos 
122766e63ce3Schristos /* Returns true if there's a hardware watchpoint or access watchpoint
122866e63ce3Schristos    inserted in the range defined by ADDR and LEN.  */
122907163879Schristos extern int hardware_watchpoint_inserted_in_range (const address_space *,
123066e63ce3Schristos 						  CORE_ADDR addr,
123166e63ce3Schristos 						  ULONGEST len);
123266e63ce3Schristos 
123326a53354Schristos /* Returns true if {ASPACE1,ADDR1} and {ASPACE2,ADDR2} represent the
123426a53354Schristos    same breakpoint location.  In most targets, this can only be true
123526a53354Schristos    if ASPACE1 matches ASPACE2.  On targets that have global
123626a53354Schristos    breakpoints, the address space doesn't really matter.  */
123726a53354Schristos 
123807163879Schristos extern int breakpoint_address_match (const address_space *aspace1,
123926a53354Schristos 				     CORE_ADDR addr1,
124007163879Schristos 				     const address_space *aspace2,
124126a53354Schristos 				     CORE_ADDR addr2);
124266e63ce3Schristos 
124307163879Schristos extern void until_break_command (const char *, int, int);
124466e63ce3Schristos 
124548596154Schristos /* Initialize a struct bp_location.  */
124648596154Schristos 
124707163879Schristos extern void update_breakpoint_locations
124807163879Schristos   (struct breakpoint *b,
1249c03b94e9Schristos    struct program_space *filter_pspace,
125007163879Schristos    gdb::array_view<const symtab_and_line> sals,
125107163879Schristos    gdb::array_view<const symtab_and_line> sals_end);
125266e63ce3Schristos 
125366e63ce3Schristos extern void breakpoint_re_set (void);
125466e63ce3Schristos 
125566e63ce3Schristos extern void breakpoint_re_set_thread (struct breakpoint *);
125666e63ce3Schristos 
125707163879Schristos extern void delete_breakpoint (struct breakpoint *);
125807163879Schristos 
125907163879Schristos struct breakpoint_deleter
126007163879Schristos {
operatorbreakpoint_deleter126107163879Schristos   void operator() (struct breakpoint *b) const
126207163879Schristos   {
126307163879Schristos     delete_breakpoint (b);
126407163879Schristos   }
126507163879Schristos };
126607163879Schristos 
126707163879Schristos typedef std::unique_ptr<struct breakpoint, breakpoint_deleter> breakpoint_up;
126807163879Schristos 
126907163879Schristos extern breakpoint_up set_momentary_breakpoint
127066e63ce3Schristos   (struct gdbarch *, struct symtab_and_line, struct frame_id, enum bptype);
127166e63ce3Schristos 
127207163879Schristos extern breakpoint_up set_momentary_breakpoint_at_pc
127366e63ce3Schristos   (struct gdbarch *, CORE_ADDR pc, enum bptype type);
127466e63ce3Schristos 
127566e63ce3Schristos extern struct breakpoint *clone_momentary_breakpoint (struct breakpoint *bpkt);
127666e63ce3Schristos 
127766e63ce3Schristos extern void set_ignore_count (int, int, int);
127866e63ce3Schristos 
127966e63ce3Schristos extern void breakpoint_init_inferior (enum inf_context);
128066e63ce3Schristos 
128166e63ce3Schristos extern void breakpoint_auto_delete (bpstat);
128266e63ce3Schristos 
128348596154Schristos typedef void (*walk_bp_location_callback) (struct bp_location *, void *);
128448596154Schristos 
128548596154Schristos extern void iterate_over_bp_locations (walk_bp_location_callback);
128648596154Schristos 
128766e63ce3Schristos /* Return the chain of command lines to execute when this breakpoint
128866e63ce3Schristos    is hit.  */
128966e63ce3Schristos extern struct command_line *breakpoint_commands (struct breakpoint *b);
129066e63ce3Schristos 
129166e63ce3Schristos /* Return a string image of DISP.  The string is static, and thus should
129266e63ce3Schristos    NOT be deallocated after use.  */
129366e63ce3Schristos const char *bpdisp_text (enum bpdisp disp);
129466e63ce3Schristos 
129507163879Schristos extern void break_command (const char *, int);
129666e63ce3Schristos 
129707163879Schristos extern void watch_command_wrapper (const char *, int, int);
129807163879Schristos extern void awatch_command_wrapper (const char *, int, int);
129907163879Schristos extern void rwatch_command_wrapper (const char *, int, int);
130007163879Schristos extern void tbreak_command (const char *, int);
130166e63ce3Schristos 
130248596154Schristos extern struct breakpoint_ops base_breakpoint_ops;
130348596154Schristos extern struct breakpoint_ops bkpt_breakpoint_ops;
130448596154Schristos extern struct breakpoint_ops tracepoint_breakpoint_ops;
13057af5a897Schristos extern struct breakpoint_ops dprintf_breakpoint_ops;
130648596154Schristos 
130748596154Schristos extern void initialize_breakpoint_ops (void);
130848596154Schristos 
130948596154Schristos /* Arguments to pass as context to some catch command handlers.  */
131048596154Schristos #define CATCH_PERMANENT ((void *) (uintptr_t) 0)
131148596154Schristos #define CATCH_TEMPORARY ((void *) (uintptr_t) 1)
131248596154Schristos 
131348596154Schristos /* Like add_cmd, but add the command to both the "catch" and "tcatch"
131448596154Schristos    lists, and pass some additional user data to the command
131548596154Schristos    function.  */
131648596154Schristos 
131748596154Schristos extern void
13181c468f90Schristos   add_catch_command (const char *name, const char *docstring,
131907163879Schristos 		     cmd_const_sfunc_ftype *sfunc,
132048596154Schristos 		     completer_ftype *completer,
132148596154Schristos 		     void *user_data_catch,
132248596154Schristos 		     void *user_data_tcatch);
132348596154Schristos 
132448596154Schristos /* Initialize a breakpoint struct for Ada exception catchpoints.  */
132548596154Schristos 
132648596154Schristos extern void
132748596154Schristos   init_ada_exception_breakpoint (struct breakpoint *b,
132848596154Schristos 				 struct gdbarch *gdbarch,
132948596154Schristos 				 struct symtab_and_line sal,
133007163879Schristos 				 const char *addr_string,
133148596154Schristos 				 const struct breakpoint_ops *ops,
133248596154Schristos 				 int tempflag,
13337af5a897Schristos 				 int enabled,
133448596154Schristos 				 int from_tty);
133548596154Schristos 
133648596154Schristos extern void init_catchpoint (struct breakpoint *b,
133748596154Schristos 			     struct gdbarch *gdbarch, int tempflag,
13381c468f90Schristos 			     const char *cond_string,
133948596154Schristos 			     const struct breakpoint_ops *ops);
134048596154Schristos 
134148596154Schristos /* Add breakpoint B on the breakpoint list, and notify the user, the
134248596154Schristos    target and breakpoint_created observers of its existence.  If
134348596154Schristos    INTERNAL is non-zero, the breakpoint number will be allocated from
134448596154Schristos    the internal breakpoint count.  If UPDATE_GLL is non-zero,
134548596154Schristos    update_global_location_list will be called.  */
134648596154Schristos 
134707163879Schristos extern void install_breakpoint (int internal, std::unique_ptr<breakpoint> &&b,
134848596154Schristos 				int update_gll);
134948596154Schristos 
1350*1424dfb3Schristos /* Returns the breakpoint ops appropriate for use with with LOCATION and
1351*1424dfb3Schristos    according to IS_TRACEPOINT.  Use this to ensure, for example, that you pass
1352*1424dfb3Schristos    the correct ops to create_breakpoint for probe locations.  If LOCATION is
1353*1424dfb3Schristos    NULL, returns bkpt_breakpoint_ops (or tracepoint_breakpoint_ops, if
1354*1424dfb3Schristos    IS_TRACEPOINT is true).  */
1355*1424dfb3Schristos 
1356*1424dfb3Schristos extern const struct breakpoint_ops *breakpoint_ops_for_event_location
1357*1424dfb3Schristos   (const struct event_location *location, bool is_tracepoint);
1358*1424dfb3Schristos 
135948596154Schristos /* Flags that can be passed down to create_breakpoint, etc., to affect
136048596154Schristos    breakpoint creation in several ways.  */
136148596154Schristos 
136248596154Schristos enum breakpoint_create_flags
136348596154Schristos   {
136448596154Schristos     /* We're adding a breakpoint to our tables that is already
136548596154Schristos        inserted in the target.  */
136648596154Schristos     CREATE_BREAKPOINT_FLAGS_INSERTED = 1 << 0
136748596154Schristos   };
136848596154Schristos 
1369c03b94e9Schristos /* Set a breakpoint.  This function is shared between CLI and MI functions
1370c03b94e9Schristos    for setting a breakpoint at LOCATION.
1371c03b94e9Schristos 
1372c03b94e9Schristos    This function has two major modes of operations, selected by the
1373c03b94e9Schristos    PARSE_EXTRA parameter.
1374c03b94e9Schristos 
1375c03b94e9Schristos    If PARSE_EXTRA is zero, LOCATION is just the breakpoint's location,
1376c03b94e9Schristos    with condition, thread, and extra string specified by the COND_STRING,
1377c03b94e9Schristos    THREAD, and EXTRA_STRING parameters.
1378c03b94e9Schristos 
1379c03b94e9Schristos    If PARSE_EXTRA is non-zero, this function will attempt to extract
1380c03b94e9Schristos    the condition, thread, and extra string from EXTRA_STRING, ignoring
1381c03b94e9Schristos    the similarly named parameters.
1382c03b94e9Schristos 
1383c03b94e9Schristos    If INTERNAL is non-zero, the breakpoint number will be allocated
1384c03b94e9Schristos    from the internal breakpoint count.
1385c03b94e9Schristos 
1386c03b94e9Schristos    Returns true if any breakpoint was created; false otherwise.  */
1387c03b94e9Schristos 
1388c03b94e9Schristos extern int create_breakpoint (struct gdbarch *gdbarch,
1389*1424dfb3Schristos 			      struct event_location *location,
139007163879Schristos 			      const char *cond_string, int thread,
139107163879Schristos 			      const char *extra_string,
1392c03b94e9Schristos 			      int parse_extra,
139366e63ce3Schristos 			      int tempflag, enum bptype wanted_type,
139466e63ce3Schristos 			      int ignore_count,
139566e63ce3Schristos 			      enum auto_boolean pending_break_support,
139648596154Schristos 			      const struct breakpoint_ops *ops,
139766e63ce3Schristos 			      int from_tty,
139866e63ce3Schristos 			      int enabled,
139948596154Schristos 			      int internal, unsigned flags);
140066e63ce3Schristos 
140166e63ce3Schristos extern void insert_breakpoints (void);
140266e63ce3Schristos 
140366e63ce3Schristos extern int remove_breakpoints (void);
140466e63ce3Schristos 
1405*1424dfb3Schristos /* Remove breakpoints of inferior INF.  */
1406*1424dfb3Schristos 
1407*1424dfb3Schristos extern void remove_breakpoints_inf (inferior *inf);
140866e63ce3Schristos 
140966e63ce3Schristos /* This function can be used to update the breakpoint package's state
141066e63ce3Schristos    after an exec() system call has been executed.
141166e63ce3Schristos 
141266e63ce3Schristos    This function causes the following:
141366e63ce3Schristos 
141466e63ce3Schristos    - All eventpoints are marked "not inserted".
141566e63ce3Schristos    - All eventpoints with a symbolic address are reset such that
141666e63ce3Schristos    the symbolic address must be reevaluated before the eventpoints
141766e63ce3Schristos    can be reinserted.
141866e63ce3Schristos    - The solib breakpoints are explicitly removed from the breakpoint
141966e63ce3Schristos    list.
142066e63ce3Schristos    - A step-resume breakpoint, if any, is explicitly removed from the
142166e63ce3Schristos    breakpoint list.
142266e63ce3Schristos    - All eventpoints without a symbolic address are removed from the
142366e63ce3Schristos    breakpoint list.  */
142466e63ce3Schristos extern void update_breakpoints_after_exec (void);
142566e63ce3Schristos 
142666e63ce3Schristos /* This function can be used to physically remove hardware breakpoints
142766e63ce3Schristos    and watchpoints from the specified traced inferior process, without
142866e63ce3Schristos    modifying the breakpoint package's state.  This can be useful for
142966e63ce3Schristos    those targets which support following the processes of a fork() or
143066e63ce3Schristos    vfork() system call, when one of the resulting two processes is to
143166e63ce3Schristos    be detached and allowed to run free.
143266e63ce3Schristos 
143366e63ce3Schristos    It is an error to use this function on the process whose id is
143466e63ce3Schristos    inferior_ptid.  */
143548596154Schristos extern int detach_breakpoints (ptid_t ptid);
143666e63ce3Schristos 
143766e63ce3Schristos /* This function is called when program space PSPACE is about to be
143866e63ce3Schristos    deleted.  It takes care of updating breakpoints to not reference
143966e63ce3Schristos    this PSPACE anymore.  */
144066e63ce3Schristos extern void breakpoint_program_space_exit (struct program_space *pspace);
144166e63ce3Schristos 
144266e63ce3Schristos extern void set_longjmp_breakpoint (struct thread_info *tp,
144366e63ce3Schristos 				    struct frame_id frame);
144466e63ce3Schristos extern void delete_longjmp_breakpoint (int thread);
144566e63ce3Schristos 
144648596154Schristos /* Mark all longjmp breakpoints from THREAD for later deletion.  */
144748596154Schristos extern void delete_longjmp_breakpoint_at_next_stop (int thread);
144848596154Schristos 
144948596154Schristos extern struct breakpoint *set_longjmp_breakpoint_for_call_dummy (void);
145026a53354Schristos extern void check_longjmp_breakpoint_for_call_dummy (struct thread_info *tp);
145148596154Schristos 
145266e63ce3Schristos extern void enable_overlay_breakpoints (void);
145366e63ce3Schristos extern void disable_overlay_breakpoints (void);
145466e63ce3Schristos 
145566e63ce3Schristos extern void set_std_terminate_breakpoint (void);
145666e63ce3Schristos extern void delete_std_terminate_breakpoint (void);
145766e63ce3Schristos 
145866e63ce3Schristos /* These functions respectively disable or reenable all currently
145966e63ce3Schristos    enabled watchpoints.  When disabled, the watchpoints are marked
146048596154Schristos    call_disabled.  When re-enabled, they are marked enabled.
146166e63ce3Schristos 
146266e63ce3Schristos    The intended client of these functions is call_function_by_hand.
146366e63ce3Schristos 
146466e63ce3Schristos    The inferior must be stopped, and all breakpoints removed, when
146566e63ce3Schristos    these functions are used.
146666e63ce3Schristos 
146766e63ce3Schristos    The need for these functions is that on some targets (e.g., HP-UX),
146866e63ce3Schristos    gdb is unable to unwind through the dummy frame that is pushed as
146966e63ce3Schristos    part of the implementation of a call command.  Watchpoints can
147066e63ce3Schristos    cause the inferior to stop in places where this frame is visible,
147166e63ce3Schristos    and that can cause execution control to become very confused.
147266e63ce3Schristos 
147366e63ce3Schristos    Note that if a user sets breakpoints in an interactively called
147448596154Schristos    function, the call_disabled watchpoints will have been re-enabled
147566e63ce3Schristos    when the first such breakpoint is reached.  However, on targets
147666e63ce3Schristos    that are unable to unwind through the call dummy frame, watches
147766e63ce3Schristos    of stack-based storage may then be deleted, because gdb will
147866e63ce3Schristos    believe that their watched storage is out of scope.  (Sigh.) */
147966e63ce3Schristos extern void disable_watchpoints_before_interactive_call_start (void);
148066e63ce3Schristos 
148166e63ce3Schristos extern void enable_watchpoints_after_interactive_call_stop (void);
148266e63ce3Schristos 
148366e63ce3Schristos /* These functions disable and re-enable all breakpoints during
148466e63ce3Schristos    inferior startup.  They are intended to be called from solib
148566e63ce3Schristos    code where necessary.  This is needed on platforms where the
148666e63ce3Schristos    main executable is relocated at some point during startup
148766e63ce3Schristos    processing, making breakpoint addresses invalid.
148866e63ce3Schristos 
148966e63ce3Schristos    If additional breakpoints are created after the routine
149066e63ce3Schristos    disable_breakpoints_before_startup but before the routine
149166e63ce3Schristos    enable_breakpoints_after_startup was called, they will also
149266e63ce3Schristos    be marked as disabled.  */
149366e63ce3Schristos extern void disable_breakpoints_before_startup (void);
149466e63ce3Schristos extern void enable_breakpoints_after_startup (void);
149566e63ce3Schristos 
149666e63ce3Schristos /* For script interpreters that need to define breakpoint commands
149766e63ce3Schristos    after they've already read the commands into a struct
149866e63ce3Schristos    command_line.  */
149966e63ce3Schristos extern enum command_control_type commands_from_control_command
15001c468f90Schristos   (const char *arg, struct command_line *cmd);
150166e63ce3Schristos 
150266e63ce3Schristos extern void clear_breakpoint_hit_counts (void);
150366e63ce3Schristos 
150466e63ce3Schristos extern struct breakpoint *get_breakpoint (int num);
150566e63ce3Schristos 
150666e63ce3Schristos /* The following are for displays, which aren't really breakpoints,
150766e63ce3Schristos    but here is as good a place as any for them.  */
150866e63ce3Schristos 
150966e63ce3Schristos extern void disable_current_display (void);
151066e63ce3Schristos 
151166e63ce3Schristos extern void do_displays (void);
151266e63ce3Schristos 
151366e63ce3Schristos extern void disable_display (int);
151466e63ce3Schristos 
151566e63ce3Schristos extern void clear_displays (void);
151666e63ce3Schristos 
151766e63ce3Schristos extern void disable_breakpoint (struct breakpoint *);
151866e63ce3Schristos 
151966e63ce3Schristos extern void enable_breakpoint (struct breakpoint *);
152066e63ce3Schristos 
152166e63ce3Schristos extern void breakpoint_set_commands (struct breakpoint *b,
152207163879Schristos 				     counted_command_line &&commands);
152366e63ce3Schristos 
152466e63ce3Schristos extern void breakpoint_set_silent (struct breakpoint *b, int silent);
152566e63ce3Schristos 
152666e63ce3Schristos extern void breakpoint_set_thread (struct breakpoint *b, int thread);
152766e63ce3Schristos 
152866e63ce3Schristos extern void breakpoint_set_task (struct breakpoint *b, int task);
152966e63ce3Schristos 
153066e63ce3Schristos /* Clear the "inserted" flag in all breakpoints.  */
153166e63ce3Schristos extern void mark_breakpoints_out (void);
153266e63ce3Schristos 
153366e63ce3Schristos extern struct breakpoint *create_jit_event_breakpoint (struct gdbarch *,
153466e63ce3Schristos                                                        CORE_ADDR);
153566e63ce3Schristos 
153666e63ce3Schristos extern struct breakpoint *create_solib_event_breakpoint (struct gdbarch *,
153766e63ce3Schristos 							 CORE_ADDR);
153866e63ce3Schristos 
153926a53354Schristos /* Create an solib event breakpoint at ADDRESS in the current program
154026a53354Schristos    space, and immediately try to insert it.  Returns a pointer to the
154126a53354Schristos    breakpoint on success.  Deletes the new breakpoint and returns NULL
154226a53354Schristos    if inserting the breakpoint fails.  */
154326a53354Schristos extern struct breakpoint *create_and_insert_solib_event_breakpoint
154426a53354Schristos   (struct gdbarch *gdbarch, CORE_ADDR address);
154526a53354Schristos 
154666e63ce3Schristos extern struct breakpoint *create_thread_event_breakpoint (struct gdbarch *,
154766e63ce3Schristos 							  CORE_ADDR);
154866e63ce3Schristos 
154966e63ce3Schristos extern void remove_jit_event_breakpoints (void);
155066e63ce3Schristos 
155166e63ce3Schristos extern void remove_solib_event_breakpoints (void);
155266e63ce3Schristos 
155326a53354Schristos /* Mark solib event breakpoints of the current program space with
155426a53354Schristos    delete at next stop disposition.  */
155526a53354Schristos extern void remove_solib_event_breakpoints_at_next_stop (void);
155626a53354Schristos 
155766e63ce3Schristos extern void disable_breakpoints_in_shlibs (void);
155866e63ce3Schristos 
1559*1424dfb3Schristos /* This function returns true if B is a catchpoint.  */
1560*1424dfb3Schristos 
1561*1424dfb3Schristos extern bool is_catchpoint (struct breakpoint *b);
156248596154Schristos 
156348596154Schristos /* Shared helper function (MI and CLI) for creating and installing
156448596154Schristos    a shared object event catchpoint.  */
15651c468f90Schristos extern void add_solib_catchpoint (const char *arg, int is_load, int is_temp,
156648596154Schristos                                   int enabled);
156766e63ce3Schristos 
156826a53354Schristos /* Create and insert a new software single step breakpoint for the
156926a53354Schristos    current thread.  May be called multiple times; each time will add a
157026a53354Schristos    new location to the set of potential addresses the next instruction
157126a53354Schristos    is at.  */
157266e63ce3Schristos extern void insert_single_step_breakpoint (struct gdbarch *,
157307163879Schristos 					   const address_space *,
157466e63ce3Schristos 					   CORE_ADDR);
15751c468f90Schristos 
15761c468f90Schristos /* Insert all software single step breakpoints for the current frame.
15771c468f90Schristos    Return true if any software single step breakpoints are inserted,
15781c468f90Schristos    otherwise, return false.  */
15791c468f90Schristos extern int insert_single_step_breakpoints (struct gdbarch *);
15801c468f90Schristos 
158166e63ce3Schristos /* Check if any hardware watchpoints have triggered, according to the
158266e63ce3Schristos    target.  */
158366e63ce3Schristos int watchpoints_triggered (struct target_waitstatus *);
158466e63ce3Schristos 
158548596154Schristos /* Helper for transparent breakpoint hiding for memory read and write
158648596154Schristos    routines.
158748596154Schristos 
158848596154Schristos    Update one of READBUF or WRITEBUF with either the shadows
158948596154Schristos    (READBUF), or the breakpoint instructions (WRITEBUF) of inserted
159048596154Schristos    breakpoints at the memory range defined by MEMADDR and extending
159148596154Schristos    for LEN bytes.  If writing, then WRITEBUF is a copy of WRITEBUF_ORG
159248596154Schristos    on entry.*/
159348596154Schristos extern void breakpoint_xfer_memory (gdb_byte *readbuf, gdb_byte *writebuf,
159448596154Schristos 				    const gdb_byte *writebuf_org,
159548596154Schristos 				    ULONGEST memaddr, LONGEST len);
159666e63ce3Schristos 
159726a53354Schristos /* Return true if breakpoints should be inserted now.  That'll be the
159826a53354Schristos    case if either:
159926a53354Schristos 
160026a53354Schristos     - the target has global breakpoints.
160126a53354Schristos 
160226a53354Schristos     - "breakpoint always-inserted" is on, and the target has
160326a53354Schristos       execution.
160426a53354Schristos 
160526a53354Schristos     - threads are executing.
160626a53354Schristos */
160726a53354Schristos extern int breakpoints_should_be_inserted_now (void);
160866e63ce3Schristos 
160966e63ce3Schristos /* Called each time new event from target is processed.
161066e63ce3Schristos    Retires previously deleted breakpoint locations that
161166e63ce3Schristos    in our opinion won't ever trigger.  */
161266e63ce3Schristos extern void breakpoint_retire_moribund (void);
161366e63ce3Schristos 
161466e63ce3Schristos /* Set break condition of breakpoint B to EXP.  */
1615ed6a76a9Schristos extern void set_breakpoint_condition (struct breakpoint *b, const char *exp,
161666e63ce3Schristos 				      int from_tty);
161766e63ce3Schristos 
161866e63ce3Schristos /* Checks if we are catching syscalls or not.
161966e63ce3Schristos    Returns 0 if not, greater than 0 if we are.  */
162066e63ce3Schristos extern int catch_syscall_enabled (void);
162166e63ce3Schristos 
162266e63ce3Schristos /* Checks if we are catching syscalls with the specific
162366e63ce3Schristos    syscall_number.  Used for "filtering" the catchpoints.
162466e63ce3Schristos    Returns 0 if not, greater than 0 if we are.  */
162566e63ce3Schristos extern int catching_syscall_number (int syscall_number);
162666e63ce3Schristos 
162766e63ce3Schristos /* Return a tracepoint with the given number if found.  */
162848596154Schristos extern struct tracepoint *get_tracepoint (int num);
162966e63ce3Schristos 
163048596154Schristos extern struct tracepoint *get_tracepoint_by_number_on_target (int num);
163166e63ce3Schristos 
163266e63ce3Schristos /* Find a tracepoint by parsing a number in the supplied string.  */
163348596154Schristos extern struct tracepoint *
163407163879Schristos   get_tracepoint_by_number (const char **arg,
16351c468f90Schristos 			    number_or_range_parser *parser);
163666e63ce3Schristos 
163707163879Schristos /* Return a vector of all tracepoints currently defined.  */
163807163879Schristos extern std::vector<breakpoint *> all_tracepoints (void);
163966e63ce3Schristos 
1640*1424dfb3Schristos /* Return true if B is of tracepoint kind.  */
1641*1424dfb3Schristos 
1642*1424dfb3Schristos extern bool is_tracepoint (const struct breakpoint *b);
164366e63ce3Schristos 
164407163879Schristos /* Return a vector of all static tracepoints defined at ADDR.  */
164507163879Schristos extern std::vector<breakpoint *> static_tracepoints_here (CORE_ADDR addr);
164666e63ce3Schristos 
164707163879Schristos /* Create an instance of this to start registering breakpoint numbers
164807163879Schristos    for a later "commands" command.  */
164966e63ce3Schristos 
165007163879Schristos class scoped_rbreak_breakpoints
165107163879Schristos {
165207163879Schristos public:
165307163879Schristos 
165407163879Schristos   scoped_rbreak_breakpoints ();
165507163879Schristos   ~scoped_rbreak_breakpoints ();
165607163879Schristos 
165707163879Schristos   DISABLE_COPY_AND_ASSIGN (scoped_rbreak_breakpoints);
165807163879Schristos };
165966e63ce3Schristos 
166066e63ce3Schristos /* Breakpoint iterator function.
166166e63ce3Schristos 
166266e63ce3Schristos    Calls a callback function once for each breakpoint, so long as the
166366e63ce3Schristos    callback function returns false.  If the callback function returns
166466e63ce3Schristos    true, the iteration will end and the current breakpoint will be
166566e63ce3Schristos    returned.  This can be useful for implementing a search for a
166666e63ce3Schristos    breakpoint with arbitrary attributes, or for applying an operation
166766e63ce3Schristos    to every breakpoint.  */
1668*1424dfb3Schristos extern struct breakpoint *iterate_over_breakpoints
1669*1424dfb3Schristos   (gdb::function_view<bool (breakpoint *)>);
167066e63ce3Schristos 
167148596154Schristos /* Nonzero if the specified PC cannot be a location where functions
167248596154Schristos    have been inlined.  */
167348596154Schristos 
167407163879Schristos extern int pc_at_non_inline_function (const address_space *aspace,
167548596154Schristos 				      CORE_ADDR pc,
167648596154Schristos 				      const struct target_waitstatus *ws);
167748596154Schristos 
167866e63ce3Schristos extern int user_breakpoint_p (struct breakpoint *);
167966e63ce3Schristos 
1680c03b94e9Schristos /* Return true if this breakpoint is pending, false if not.  */
1681c03b94e9Schristos extern int pending_breakpoint_p (struct breakpoint *);
1682c03b94e9Schristos 
168348596154Schristos /* Attempt to determine architecture of location identified by SAL.  */
168448596154Schristos extern struct gdbarch *get_sal_arch (struct symtab_and_line sal);
168548596154Schristos 
168648596154Schristos extern void breakpoint_free_objfile (struct objfile *objfile);
168748596154Schristos 
16881c468f90Schristos extern const char *ep_parse_optional_if_clause (const char **arg);
16897af5a897Schristos 
1690c03b94e9Schristos /* Print the "Thread ID hit" part of "Thread ID hit Breakpoint N" to
1691c03b94e9Schristos    UIOUT iff debugging multiple threads.  */
1692c03b94e9Schristos extern void maybe_print_thread_hit_breakpoint (struct ui_out *uiout);
1693c03b94e9Schristos 
169407163879Schristos /* Print the specified breakpoint.  */
169507163879Schristos extern void print_breakpoint (breakpoint *bp);
169607163879Schristos 
169707163879Schristos /* Command element for the 'commands' command.  */
169807163879Schristos extern cmd_list_element *commands_cmd_element;
169907163879Schristos 
1700*1424dfb3Schristos /* Whether to use the fixed output when printing information about a
1701*1424dfb3Schristos    multi-location breakpoint (see PR 9659).  */
1702*1424dfb3Schristos 
1703*1424dfb3Schristos extern bool fix_multi_location_breakpoint_output_globally;
1704*1424dfb3Schristos 
1705*1424dfb3Schristos /* Deal with "catch catch", "catch throw", and "catch rethrow" commands and
1706*1424dfb3Schristos    the MI equivalents.  Sets up to catch events of type EX_EVENT.  When
1707*1424dfb3Schristos    TEMPFLAG is true only the next matching event is caught after which the
1708*1424dfb3Schristos    catch-point is deleted.  If REGEX is not NULL then only exceptions whose
1709*1424dfb3Schristos    type name matches REGEX will trigger the event.  */
1710*1424dfb3Schristos 
1711*1424dfb3Schristos extern void catch_exception_event (enum exception_event_kind ex_event,
1712*1424dfb3Schristos 				   const char *regex, bool tempflag,
1713*1424dfb3Schristos 				   int from_tty);
1714*1424dfb3Schristos 
171566e63ce3Schristos #endif /* !defined (BREAKPOINT_H) */
1716