166e63ce3Schristos /* Data structures associated with breakpoints in GDB. 2*1c468f90Schristos Copyright (C) 1992-2017 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" 2466e63ce3Schristos #include "vec.h" 2548596154Schristos #include "ax.h" 2648596154Schristos #include "command.h" 277af5a897Schristos #include "break-common.h" 2826a53354Schristos #include "probe.h" 29*1c468f90Schristos #include "location.h" 30*1c468f90Schristos #include <vector> 3166e63ce3Schristos 3266e63ce3Schristos struct value; 3366e63ce3Schristos struct block; 347af5a897Schristos struct gdbpy_breakpoint_object; 3526a53354Schristos struct gdbscm_breakpoint_object; 36*1c468f90Schristos struct number_or_range_parser; 3748596154Schristos struct thread_info; 3848596154Schristos struct bpstats; 3948596154Schristos struct bp_location; 4048596154Schristos struct linespec_result; 4148596154Schristos struct linespec_sals; 42c03b94e9Schristos 43c03b94e9Schristos /* Why are we removing the breakpoint from the target? */ 44c03b94e9Schristos 45c03b94e9Schristos enum remove_bp_reason 46c03b94e9Schristos { 47c03b94e9Schristos /* A regular remove. Remove the breakpoint and forget everything 48c03b94e9Schristos about it. */ 49c03b94e9Schristos REMOVE_BREAKPOINT, 50c03b94e9Schristos 51c03b94e9Schristos /* Detach the breakpoints from a fork child. */ 52c03b94e9Schristos DETACH_BREAKPOINT, 53c03b94e9Schristos }; 5466e63ce3Schristos 5566e63ce3Schristos /* This is the maximum number of bytes a breakpoint instruction can 5666e63ce3Schristos take. Feel free to increase it. It's just used in a few places to 5766e63ce3Schristos size arrays that should be independent of the target 5866e63ce3Schristos architecture. */ 5966e63ce3Schristos 6066e63ce3Schristos #define BREAKPOINT_MAX 16 6166e63ce3Schristos 6266e63ce3Schristos 6366e63ce3Schristos /* Type of breakpoint. */ 6466e63ce3Schristos 6566e63ce3Schristos enum bptype 6666e63ce3Schristos { 6766e63ce3Schristos bp_none = 0, /* Eventpoint has been deleted */ 6866e63ce3Schristos bp_breakpoint, /* Normal breakpoint */ 6966e63ce3Schristos bp_hardware_breakpoint, /* Hardware assisted breakpoint */ 7026a53354Schristos bp_single_step, /* Software single-step */ 7166e63ce3Schristos bp_until, /* used by until command */ 7266e63ce3Schristos bp_finish, /* used by finish command */ 7366e63ce3Schristos bp_watchpoint, /* Watchpoint */ 7466e63ce3Schristos bp_hardware_watchpoint, /* Hardware assisted watchpoint */ 7566e63ce3Schristos bp_read_watchpoint, /* read watchpoint, (hardware assisted) */ 7666e63ce3Schristos bp_access_watchpoint, /* access watchpoint, (hardware assisted) */ 7766e63ce3Schristos bp_longjmp, /* secret breakpoint to find longjmp() */ 7866e63ce3Schristos bp_longjmp_resume, /* secret breakpoint to escape longjmp() */ 7966e63ce3Schristos 8048596154Schristos /* Breakpoint placed to the same location(s) like bp_longjmp but used to 8148596154Schristos protect against stale DUMMY_FRAME. Multiple bp_longjmp_call_dummy and 8248596154Schristos one bp_call_dummy are chained together by related_breakpoint for each 8348596154Schristos DUMMY_FRAME. */ 8448596154Schristos bp_longjmp_call_dummy, 8548596154Schristos 8666e63ce3Schristos /* An internal breakpoint that is installed on the unwinder's 8766e63ce3Schristos debug hook. */ 8866e63ce3Schristos bp_exception, 8966e63ce3Schristos /* An internal breakpoint that is set at the point where an 9066e63ce3Schristos exception will land. */ 9166e63ce3Schristos bp_exception_resume, 9266e63ce3Schristos 9366e63ce3Schristos /* Used by wait_for_inferior for stepping over subroutine calls, 9448596154Schristos and for skipping prologues. */ 9566e63ce3Schristos bp_step_resume, 9666e63ce3Schristos 9748596154Schristos /* Used by wait_for_inferior for stepping over signal 9848596154Schristos handlers. */ 9948596154Schristos bp_hp_step_resume, 10048596154Schristos 10166e63ce3Schristos /* Used to detect when a watchpoint expression has gone out of 10266e63ce3Schristos scope. These breakpoints are usually not visible to the user. 10366e63ce3Schristos 10466e63ce3Schristos This breakpoint has some interesting properties: 10566e63ce3Schristos 10666e63ce3Schristos 1) There's always a 1:1 mapping between watchpoints 10766e63ce3Schristos on local variables and watchpoint_scope breakpoints. 10866e63ce3Schristos 10966e63ce3Schristos 2) It automatically deletes itself and the watchpoint it's 11066e63ce3Schristos associated with when hit. 11166e63ce3Schristos 11266e63ce3Schristos 3) It can never be disabled. */ 11366e63ce3Schristos bp_watchpoint_scope, 11466e63ce3Schristos 11548596154Schristos /* The breakpoint at the end of a call dummy. See bp_longjmp_call_dummy it 11648596154Schristos is chained with by related_breakpoint. */ 11766e63ce3Schristos bp_call_dummy, 11866e63ce3Schristos 11966e63ce3Schristos /* A breakpoint set on std::terminate, that is used to catch 12066e63ce3Schristos otherwise uncaught exceptions thrown during an inferior call. */ 12166e63ce3Schristos bp_std_terminate, 12266e63ce3Schristos 12366e63ce3Schristos /* Some dynamic linkers (HP, maybe Solaris) can arrange for special 12466e63ce3Schristos code in the inferior to run when significant events occur in the 12566e63ce3Schristos dynamic linker (for example a library is loaded or unloaded). 12666e63ce3Schristos 12766e63ce3Schristos By placing a breakpoint in this magic code GDB will get control 12866e63ce3Schristos when these significant events occur. GDB can then re-examine 12966e63ce3Schristos the dynamic linker's data structures to discover any newly loaded 13066e63ce3Schristos dynamic libraries. */ 13166e63ce3Schristos bp_shlib_event, 13266e63ce3Schristos 13366e63ce3Schristos /* Some multi-threaded systems can arrange for a location in the 13466e63ce3Schristos inferior to be executed when certain thread-related events occur 13566e63ce3Schristos (such as thread creation or thread death). 13666e63ce3Schristos 13766e63ce3Schristos By placing a breakpoint at one of these locations, GDB will get 13866e63ce3Schristos control when these events occur. GDB can then update its thread 13966e63ce3Schristos lists etc. */ 14066e63ce3Schristos 14166e63ce3Schristos bp_thread_event, 14266e63ce3Schristos 14366e63ce3Schristos /* On the same principal, an overlay manager can arrange to call a 14466e63ce3Schristos magic location in the inferior whenever there is an interesting 14566e63ce3Schristos change in overlay status. GDB can update its overlay tables 14666e63ce3Schristos and fiddle with breakpoints in overlays when this breakpoint 14766e63ce3Schristos is hit. */ 14866e63ce3Schristos 14966e63ce3Schristos bp_overlay_event, 15066e63ce3Schristos 15166e63ce3Schristos /* Master copies of longjmp breakpoints. These are always installed 15266e63ce3Schristos as soon as an objfile containing longjmp is loaded, but they are 15366e63ce3Schristos always disabled. While necessary, temporary clones of bp_longjmp 15466e63ce3Schristos type will be created and enabled. */ 15566e63ce3Schristos 15666e63ce3Schristos bp_longjmp_master, 15766e63ce3Schristos 15866e63ce3Schristos /* Master copies of std::terminate breakpoints. */ 15966e63ce3Schristos bp_std_terminate_master, 16066e63ce3Schristos 16166e63ce3Schristos /* Like bp_longjmp_master, but for exceptions. */ 16266e63ce3Schristos bp_exception_master, 16366e63ce3Schristos 16466e63ce3Schristos bp_catchpoint, 16566e63ce3Schristos 16666e63ce3Schristos bp_tracepoint, 16766e63ce3Schristos bp_fast_tracepoint, 16866e63ce3Schristos bp_static_tracepoint, 16966e63ce3Schristos 17048596154Schristos /* A dynamic printf stops at the given location, does a formatted 17148596154Schristos print, then automatically continues. (Although this is sort of 17248596154Schristos like a macro packaging up standard breakpoint functionality, 17348596154Schristos GDB doesn't have a way to construct types of breakpoint from 17448596154Schristos elements of behavior.) */ 17548596154Schristos bp_dprintf, 17648596154Schristos 17766e63ce3Schristos /* Event for JIT compiled code generation or deletion. */ 17866e63ce3Schristos bp_jit_event, 17966e63ce3Schristos 18066e63ce3Schristos /* Breakpoint is placed at the STT_GNU_IFUNC resolver. When hit GDB 18166e63ce3Schristos inserts new bp_gnu_ifunc_resolver_return at the caller. 18266e63ce3Schristos bp_gnu_ifunc_resolver is still being kept here as a different thread 18366e63ce3Schristos may still hit it before bp_gnu_ifunc_resolver_return is hit by the 18466e63ce3Schristos original thread. */ 18566e63ce3Schristos bp_gnu_ifunc_resolver, 18666e63ce3Schristos 18766e63ce3Schristos /* On its hit GDB now know the resolved address of the target 18866e63ce3Schristos STT_GNU_IFUNC function. Associated bp_gnu_ifunc_resolver can be 18966e63ce3Schristos deleted now and the breakpoint moved to the target function entry 19066e63ce3Schristos point. */ 19166e63ce3Schristos bp_gnu_ifunc_resolver_return, 19266e63ce3Schristos }; 19366e63ce3Schristos 19466e63ce3Schristos /* States of enablement of breakpoint. */ 19566e63ce3Schristos 19666e63ce3Schristos enum enable_state 19766e63ce3Schristos { 19866e63ce3Schristos bp_disabled, /* The eventpoint is inactive, and cannot 19966e63ce3Schristos trigger. */ 20066e63ce3Schristos bp_enabled, /* The eventpoint is active, and can 20166e63ce3Schristos trigger. */ 20266e63ce3Schristos bp_call_disabled, /* The eventpoint has been disabled while a 20366e63ce3Schristos call into the inferior is "in flight", 20466e63ce3Schristos because some eventpoints interfere with 20566e63ce3Schristos the implementation of a call on some 20666e63ce3Schristos targets. The eventpoint will be 20766e63ce3Schristos automatically enabled and reset when the 20866e63ce3Schristos call "lands" (either completes, or stops 20966e63ce3Schristos at another eventpoint). */ 21066e63ce3Schristos }; 21166e63ce3Schristos 21266e63ce3Schristos 21366e63ce3Schristos /* Disposition of breakpoint. Ie: what to do after hitting it. */ 21466e63ce3Schristos 21566e63ce3Schristos enum bpdisp 21666e63ce3Schristos { 21766e63ce3Schristos disp_del, /* Delete it */ 21866e63ce3Schristos disp_del_at_next_stop, /* Delete at next stop, 21966e63ce3Schristos whether hit or not */ 22066e63ce3Schristos disp_disable, /* Disable it */ 22166e63ce3Schristos disp_donttouch /* Leave it alone */ 22266e63ce3Schristos }; 22366e63ce3Schristos 22448596154Schristos /* Status of breakpoint conditions used when synchronizing 22548596154Schristos conditions with the target. */ 22648596154Schristos 22748596154Schristos enum condition_status 22848596154Schristos { 22948596154Schristos condition_unchanged = 0, 23048596154Schristos condition_modified, 23148596154Schristos condition_updated 23248596154Schristos }; 23348596154Schristos 23466e63ce3Schristos /* Information used by targets to insert and remove breakpoints. */ 23566e63ce3Schristos 23666e63ce3Schristos struct bp_target_info 23766e63ce3Schristos { 23866e63ce3Schristos /* Address space at which the breakpoint was placed. */ 23966e63ce3Schristos struct address_space *placed_address_space; 24066e63ce3Schristos 24126a53354Schristos /* Address at which the breakpoint was placed. This is normally 24226a53354Schristos the same as REQUESTED_ADDRESS, except when adjustment happens in 24326a53354Schristos gdbarch_breakpoint_from_pc. The most common form of adjustment 24426a53354Schristos is stripping an alternate ISA marker from the PC which is used 24526a53354Schristos to determine the type of breakpoint to insert. */ 24666e63ce3Schristos CORE_ADDR placed_address; 24766e63ce3Schristos 24826a53354Schristos /* Address at which the breakpoint was requested. */ 24926a53354Schristos CORE_ADDR reqstd_address; 25026a53354Schristos 25166e63ce3Schristos /* If this is a ranged breakpoint, then this field contains the 25266e63ce3Schristos length of the range that will be watched for execution. */ 25366e63ce3Schristos int length; 25466e63ce3Schristos 25566e63ce3Schristos /* If the breakpoint lives in memory and reading that memory would 25666e63ce3Schristos give back the breakpoint, instead of the original contents, then 25766e63ce3Schristos the original contents are cached here. Only SHADOW_LEN bytes of 25866e63ce3Schristos this buffer are valid, and only when the breakpoint is inserted. */ 25966e63ce3Schristos gdb_byte shadow_contents[BREAKPOINT_MAX]; 26066e63ce3Schristos 26166e63ce3Schristos /* The length of the data cached in SHADOW_CONTENTS. */ 26266e63ce3Schristos int shadow_len; 26366e63ce3Schristos 264*1c468f90Schristos /* The breakpoint's kind. It is used in 'kind' parameter in Z 265*1c468f90Schristos packets. */ 266*1c468f90Schristos int kind; 26748596154Schristos 268*1c468f90Schristos /* Conditions the target should evaluate if it supports target-side 269*1c468f90Schristos breakpoint conditions. These are non-owning pointers. */ 270*1c468f90Schristos std::vector<agent_expr *> conditions; 27148596154Schristos 272*1c468f90Schristos /* Commands the target should evaluate if it supports target-side 273*1c468f90Schristos breakpoint commands. These are non-owning pointers. */ 274*1c468f90Schristos std::vector<agent_expr *> tcommands; 27548596154Schristos 27648596154Schristos /* Flag that is true if the breakpoint should be left in place even 27748596154Schristos when GDB is not connected. */ 27848596154Schristos int persist; 27966e63ce3Schristos }; 28066e63ce3Schristos 28166e63ce3Schristos /* GDB maintains two types of information about each breakpoint (or 28266e63ce3Schristos watchpoint, or other related event). The first type corresponds 28366e63ce3Schristos to struct breakpoint; this is a relatively high-level structure 28466e63ce3Schristos which contains the source location(s), stopping conditions, user 28566e63ce3Schristos commands to execute when the breakpoint is hit, and so forth. 28666e63ce3Schristos 28766e63ce3Schristos The second type of information corresponds to struct bp_location. 28866e63ce3Schristos Each breakpoint has one or (eventually) more locations associated 28966e63ce3Schristos with it, which represent target-specific and machine-specific 29066e63ce3Schristos mechanisms for stopping the program. For instance, a watchpoint 29166e63ce3Schristos expression may require multiple hardware watchpoints in order to 29266e63ce3Schristos catch all changes in the value of the expression being watched. */ 29366e63ce3Schristos 29466e63ce3Schristos enum bp_loc_type 29566e63ce3Schristos { 29666e63ce3Schristos bp_loc_software_breakpoint, 29766e63ce3Schristos bp_loc_hardware_breakpoint, 29866e63ce3Schristos bp_loc_hardware_watchpoint, 29966e63ce3Schristos bp_loc_other /* Miscellaneous... */ 30066e63ce3Schristos }; 30166e63ce3Schristos 30248596154Schristos /* This structure is a collection of function pointers that, if 30348596154Schristos available, will be called instead of performing the default action 30448596154Schristos for this bp_loc_type. */ 30548596154Schristos 30648596154Schristos struct bp_location_ops 30748596154Schristos { 30848596154Schristos /* Destructor. Releases everything from SELF (but not SELF 30948596154Schristos itself). */ 31048596154Schristos void (*dtor) (struct bp_location *self); 31148596154Schristos }; 31248596154Schristos 31366e63ce3Schristos struct bp_location 31466e63ce3Schristos { 31566e63ce3Schristos /* Chain pointer to the next breakpoint location for 31666e63ce3Schristos the same parent breakpoint. */ 31766e63ce3Schristos struct bp_location *next; 31866e63ce3Schristos 31948596154Schristos /* Methods associated with this location. */ 32048596154Schristos const struct bp_location_ops *ops; 32148596154Schristos 32266e63ce3Schristos /* The reference count. */ 32366e63ce3Schristos int refc; 32466e63ce3Schristos 32566e63ce3Schristos /* Type of this breakpoint location. */ 32666e63ce3Schristos enum bp_loc_type loc_type; 32766e63ce3Schristos 32866e63ce3Schristos /* Each breakpoint location must belong to exactly one higher-level 32966e63ce3Schristos breakpoint. This pointer is NULL iff this bp_location is no 33066e63ce3Schristos longer attached to a breakpoint. For example, when a breakpoint 33166e63ce3Schristos is deleted, its locations may still be found in the 33266e63ce3Schristos moribund_locations list, or if we had stopped for it, in 33366e63ce3Schristos bpstats. */ 33466e63ce3Schristos struct breakpoint *owner; 33566e63ce3Schristos 33666e63ce3Schristos /* Conditional. Break only if this expression's value is nonzero. 33766e63ce3Schristos Unlike string form of condition, which is associated with 33866e63ce3Schristos breakpoint, this is associated with location, since if breakpoint 33966e63ce3Schristos has several locations, the evaluation of expression can be 34066e63ce3Schristos different for different locations. Only valid for real 34166e63ce3Schristos breakpoints; a watchpoint's conditional expression is stored in 34266e63ce3Schristos the owner breakpoint object. */ 343*1c468f90Schristos expression_up cond; 34466e63ce3Schristos 34548596154Schristos /* Conditional expression in agent expression 34648596154Schristos bytecode form. This is used for stub-side breakpoint 34748596154Schristos condition evaluation. */ 348*1c468f90Schristos agent_expr_up cond_bytecode; 34948596154Schristos 35048596154Schristos /* Signals that the condition has changed since the last time 35148596154Schristos we updated the global location list. This means the condition 35248596154Schristos needs to be sent to the target again. This is used together 35348596154Schristos with target-side breakpoint conditions. 35448596154Schristos 35548596154Schristos condition_unchanged: It means there has been no condition changes. 35648596154Schristos 35748596154Schristos condition_modified: It means this location had its condition modified. 35848596154Schristos 35948596154Schristos condition_updated: It means we already marked all the locations that are 36048596154Schristos duplicates of this location and thus we don't need to call 36148596154Schristos force_breakpoint_reinsertion (...) for this location. */ 36248596154Schristos 36348596154Schristos enum condition_status condition_changed; 36448596154Schristos 365*1c468f90Schristos agent_expr_up cmd_bytecode; 36648596154Schristos 36748596154Schristos /* Signals that breakpoint conditions and/or commands need to be 36848596154Schristos re-synched with the target. This has no use other than 36948596154Schristos target-side breakpoints. */ 37048596154Schristos char needs_update; 37148596154Schristos 37266e63ce3Schristos /* This location's address is in an unloaded solib, and so this 37366e63ce3Schristos location should not be inserted. It will be automatically 37466e63ce3Schristos enabled when that solib is loaded. */ 37566e63ce3Schristos char shlib_disabled; 37666e63ce3Schristos 37766e63ce3Schristos /* Is this particular location enabled. */ 37866e63ce3Schristos char enabled; 37966e63ce3Schristos 38066e63ce3Schristos /* Nonzero if this breakpoint is now inserted. */ 38166e63ce3Schristos char inserted; 38266e63ce3Schristos 38326a53354Schristos /* Nonzero if this is a permanent breakpoint. There is a breakpoint 38426a53354Schristos instruction hard-wired into the target's code. Don't try to 38526a53354Schristos write another breakpoint instruction on top of it, or restore its 38626a53354Schristos value. Step over it using the architecture's 38726a53354Schristos gdbarch_skip_permanent_breakpoint method. */ 38826a53354Schristos char permanent; 38926a53354Schristos 39066e63ce3Schristos /* Nonzero if this is not the first breakpoint in the list 39148596154Schristos for the given address. location of tracepoint can _never_ 39248596154Schristos be duplicated with other locations of tracepoints and other 39348596154Schristos kinds of breakpoints, because two locations at the same 39448596154Schristos address may have different actions, so both of these locations 39548596154Schristos should be downloaded and so that `tfind N' always works. */ 39666e63ce3Schristos char duplicate; 39766e63ce3Schristos 39866e63ce3Schristos /* If we someday support real thread-specific breakpoints, then 39966e63ce3Schristos the breakpoint location will need a thread identifier. */ 40066e63ce3Schristos 40166e63ce3Schristos /* Data for specific breakpoint types. These could be a union, but 40266e63ce3Schristos simplicity is more important than memory usage for breakpoints. */ 40366e63ce3Schristos 40466e63ce3Schristos /* Architecture associated with this location's address. May be 40566e63ce3Schristos different from the breakpoint architecture. */ 40666e63ce3Schristos struct gdbarch *gdbarch; 40766e63ce3Schristos 40866e63ce3Schristos /* The program space associated with this breakpoint location 40966e63ce3Schristos address. Note that an address space may be represented in more 41066e63ce3Schristos than one program space (e.g. each uClinux program will be given 41166e63ce3Schristos its own program space, but there will only be one address space 41266e63ce3Schristos for all of them), but we must not insert more than one location 41366e63ce3Schristos at the same address in the same address space. */ 41466e63ce3Schristos struct program_space *pspace; 41566e63ce3Schristos 41666e63ce3Schristos /* Note that zero is a perfectly valid code address on some platforms 41766e63ce3Schristos (for example, the mn10200 (OBSOLETE) and mn10300 simulators). NULL 41866e63ce3Schristos is not a special value for this field. Valid for all types except 41966e63ce3Schristos bp_loc_other. */ 42066e63ce3Schristos CORE_ADDR address; 42166e63ce3Schristos 42266e63ce3Schristos /* For hardware watchpoints, the size of the memory region being 42366e63ce3Schristos watched. For hardware ranged breakpoints, the size of the 42466e63ce3Schristos breakpoint range. */ 42566e63ce3Schristos int length; 42666e63ce3Schristos 42766e63ce3Schristos /* Type of hardware watchpoint. */ 42866e63ce3Schristos enum target_hw_bp_type watchpoint_type; 42966e63ce3Schristos 43066e63ce3Schristos /* For any breakpoint type with an address, this is the section 43166e63ce3Schristos associated with the address. Used primarily for overlay 43266e63ce3Schristos debugging. */ 43366e63ce3Schristos struct obj_section *section; 43466e63ce3Schristos 43566e63ce3Schristos /* Address at which breakpoint was requested, either by the user or 43666e63ce3Schristos by GDB for internal breakpoints. This will usually be the same 43766e63ce3Schristos as ``address'' (above) except for cases in which 43866e63ce3Schristos ADJUST_BREAKPOINT_ADDRESS has computed a different address at 43966e63ce3Schristos which to place the breakpoint in order to comply with a 44066e63ce3Schristos processor's architectual constraints. */ 44166e63ce3Schristos CORE_ADDR requested_address; 44266e63ce3Schristos 44348596154Schristos /* An additional address assigned with this location. This is currently 44448596154Schristos only used by STT_GNU_IFUNC resolver breakpoints to hold the address 44548596154Schristos of the resolver function. */ 44648596154Schristos CORE_ADDR related_address; 44748596154Schristos 44848596154Schristos /* If the location comes from a probe point, this is the probe associated 44948596154Schristos with it. */ 45026a53354Schristos struct bound_probe probe; 45148596154Schristos 45266e63ce3Schristos char *function_name; 45366e63ce3Schristos 45466e63ce3Schristos /* Details of the placed breakpoint, when inserted. */ 45566e63ce3Schristos struct bp_target_info target_info; 45666e63ce3Schristos 45766e63ce3Schristos /* Similarly, for the breakpoint at an overlay's LMA, if necessary. */ 45866e63ce3Schristos struct bp_target_info overlay_target_info; 45966e63ce3Schristos 46066e63ce3Schristos /* In a non-stop mode, it's possible that we delete a breakpoint, 46166e63ce3Schristos but as we do that, some still running thread hits that breakpoint. 46266e63ce3Schristos For that reason, we need to keep locations belonging to deleted 46366e63ce3Schristos breakpoints for a bit, so that don't report unexpected SIGTRAP. 46466e63ce3Schristos We can't keep such locations forever, so we use a heuristic -- 46566e63ce3Schristos after we process certain number of inferior events since 46666e63ce3Schristos breakpoint was deleted, we retire all locations of that breakpoint. 46766e63ce3Schristos This variable keeps a number of events still to go, when 46866e63ce3Schristos it becomes 0 this location is retired. */ 46966e63ce3Schristos int events_till_retirement; 47048596154Schristos 47148596154Schristos /* Line number which was used to place this location. 47248596154Schristos 47348596154Schristos Breakpoint placed into a comment keeps it's user specified line number 47448596154Schristos despite ADDRESS resolves into a different line number. */ 47548596154Schristos 47648596154Schristos int line_number; 47748596154Schristos 47848596154Schristos /* Symtab which was used to place this location. This is used 47948596154Schristos to find the corresponding source file name. */ 48048596154Schristos 48148596154Schristos struct symtab *symtab; 48248596154Schristos }; 48348596154Schristos 484ed6a76a9Schristos /* The possible return values for print_bpstat, print_it_normal, 485ed6a76a9Schristos print_it_done, print_it_noop. */ 486ed6a76a9Schristos enum print_stop_action 487ed6a76a9Schristos { 488ed6a76a9Schristos /* We printed nothing or we need to do some more analysis. */ 489ed6a76a9Schristos PRINT_UNKNOWN = -1, 490ed6a76a9Schristos 491ed6a76a9Schristos /* We printed something, and we *do* desire that something to be 492ed6a76a9Schristos followed by a location. */ 493ed6a76a9Schristos PRINT_SRC_AND_LOC, 494ed6a76a9Schristos 495ed6a76a9Schristos /* We printed something, and we do *not* desire that something to be 496ed6a76a9Schristos followed by a location. */ 497ed6a76a9Schristos PRINT_SRC_ONLY, 498ed6a76a9Schristos 499ed6a76a9Schristos /* We already printed all we needed to print, don't print anything 500ed6a76a9Schristos else. */ 501ed6a76a9Schristos PRINT_NOTHING 502ed6a76a9Schristos }; 503ed6a76a9Schristos 50466e63ce3Schristos /* This structure is a collection of function pointers that, if available, 50566e63ce3Schristos will be called instead of the performing the default action for this 50666e63ce3Schristos bptype. */ 50766e63ce3Schristos 50866e63ce3Schristos struct breakpoint_ops 50966e63ce3Schristos { 51048596154Schristos /* Destructor. Releases everything from SELF (but not SELF 51148596154Schristos itself). */ 51248596154Schristos void (*dtor) (struct breakpoint *self); 51348596154Schristos 51448596154Schristos /* Allocate a location for this breakpoint. */ 51548596154Schristos struct bp_location * (*allocate_location) (struct breakpoint *); 51648596154Schristos 51748596154Schristos /* Reevaluate a breakpoint. This is necessary after symbols change 51848596154Schristos (e.g., an executable or DSO was loaded, or the inferior just 51948596154Schristos started). */ 52048596154Schristos void (*re_set) (struct breakpoint *self); 52148596154Schristos 52266e63ce3Schristos /* Insert the breakpoint or watchpoint or activate the catchpoint. 52348596154Schristos Return 0 for success, 1 if the breakpoint, watchpoint or 52448596154Schristos catchpoint type is not supported, -1 for failure. */ 52566e63ce3Schristos int (*insert_location) (struct bp_location *); 52666e63ce3Schristos 52766e63ce3Schristos /* Remove the breakpoint/catchpoint that was previously inserted 52866e63ce3Schristos with the "insert" method above. Return 0 for success, 1 if the 52966e63ce3Schristos breakpoint, watchpoint or catchpoint type is not supported, 53066e63ce3Schristos -1 for failure. */ 531c03b94e9Schristos int (*remove_location) (struct bp_location *, enum remove_bp_reason reason); 53266e63ce3Schristos 53348596154Schristos /* Return true if it the target has stopped due to hitting 53448596154Schristos breakpoint location BL. This function does not check if we 53548596154Schristos should stop, only if BL explains the stop. ASPACE is the address 53648596154Schristos space in which the event occurred, BP_ADDR is the address at 53748596154Schristos which the inferior stopped, and WS is the target_waitstatus 53848596154Schristos describing the event. */ 53948596154Schristos int (*breakpoint_hit) (const struct bp_location *bl, 54048596154Schristos struct address_space *aspace, 54148596154Schristos CORE_ADDR bp_addr, 54248596154Schristos const struct target_waitstatus *ws); 54348596154Schristos 54448596154Schristos /* Check internal conditions of the breakpoint referred to by BS. 54548596154Schristos If we should not stop for this breakpoint, set BS->stop to 0. */ 54648596154Schristos void (*check_status) (struct bpstats *bs); 54766e63ce3Schristos 54866e63ce3Schristos /* Tell how many hardware resources (debug registers) are needed 54966e63ce3Schristos for this breakpoint. If this function is not provided, then 55066e63ce3Schristos the breakpoint or watchpoint needs one debug register. */ 55166e63ce3Schristos int (*resources_needed) (const struct bp_location *); 55266e63ce3Schristos 55348596154Schristos /* Tell whether we can downgrade from a hardware watchpoint to a software 55448596154Schristos one. If not, the user will not be able to enable the watchpoint when 55548596154Schristos there are not enough hardware resources available. */ 55648596154Schristos int (*works_in_software_mode) (const struct breakpoint *); 55748596154Schristos 55866e63ce3Schristos /* The normal print routine for this breakpoint, called when we 55966e63ce3Schristos hit it. */ 56048596154Schristos enum print_stop_action (*print_it) (struct bpstats *bs); 56166e63ce3Schristos 56266e63ce3Schristos /* Display information about this breakpoint, for "info 56366e63ce3Schristos breakpoints". */ 56466e63ce3Schristos void (*print_one) (struct breakpoint *, struct bp_location **); 56566e63ce3Schristos 56666e63ce3Schristos /* Display extra information about this breakpoint, below the normal 56766e63ce3Schristos breakpoint description in "info breakpoints". 56866e63ce3Schristos 56966e63ce3Schristos In the example below, the "address range" line was printed 57066e63ce3Schristos by print_one_detail_ranged_breakpoint. 57166e63ce3Schristos 57266e63ce3Schristos (gdb) info breakpoints 57366e63ce3Schristos Num Type Disp Enb Address What 57466e63ce3Schristos 2 hw breakpoint keep y in main at test-watch.c:70 57566e63ce3Schristos address range: [0x10000458, 0x100004c7] 57666e63ce3Schristos 57766e63ce3Schristos */ 57866e63ce3Schristos void (*print_one_detail) (const struct breakpoint *, struct ui_out *); 57966e63ce3Schristos 58066e63ce3Schristos /* Display information about this breakpoint after setting it 58166e63ce3Schristos (roughly speaking; this is called from "mention"). */ 58266e63ce3Schristos void (*print_mention) (struct breakpoint *); 58366e63ce3Schristos 58466e63ce3Schristos /* Print to FP the CLI command that recreates this breakpoint. */ 58566e63ce3Schristos void (*print_recreate) (struct breakpoint *, struct ui_file *fp); 58648596154Schristos 587c03b94e9Schristos /* Create SALs from location, storing the result in linespec_result. 58848596154Schristos 58948596154Schristos For an explanation about the arguments, see the function 590c03b94e9Schristos `create_sals_from_location_default'. 59148596154Schristos 59248596154Schristos This function is called inside `create_breakpoint'. */ 593c03b94e9Schristos void (*create_sals_from_location) (const struct event_location *location, 594c03b94e9Schristos struct linespec_result *canonical, 595c03b94e9Schristos enum bptype type_wanted); 59648596154Schristos 59748596154Schristos /* This method will be responsible for creating a breakpoint given its SALs. 59848596154Schristos Usually, it just calls `create_breakpoints_sal' (for ordinary 59948596154Schristos breakpoints). However, there may be some special cases where we might 60048596154Schristos need to do some tweaks, e.g., see 60148596154Schristos `strace_marker_create_breakpoints_sal'. 60248596154Schristos 60348596154Schristos This function is called inside `create_breakpoint'. */ 60448596154Schristos void (*create_breakpoints_sal) (struct gdbarch *, 60548596154Schristos struct linespec_result *, 6067af5a897Schristos char *, char *, 60748596154Schristos enum bptype, enum bpdisp, int, int, 60848596154Schristos int, const struct breakpoint_ops *, 60948596154Schristos int, int, int, unsigned); 61048596154Schristos 611c03b94e9Schristos /* Given the location (second parameter), this method decodes it and 612c03b94e9Schristos provides the SAL locations related to it. For ordinary 613c03b94e9Schristos breakpoints, it calls `decode_line_full'. If SEARCH_PSPACE is 614c03b94e9Schristos not NULL, symbol search is restricted to just that program space. 61548596154Schristos 616c03b94e9Schristos This function is called inside `location_to_sals'. */ 617c03b94e9Schristos void (*decode_location) (struct breakpoint *b, 618c03b94e9Schristos const struct event_location *location, 619c03b94e9Schristos struct program_space *search_pspace, 620c03b94e9Schristos struct symtabs_and_lines *sals); 62148596154Schristos 6227af5a897Schristos /* Return true if this breakpoint explains a signal. See 62348596154Schristos bpstat_explains_signal. */ 6247af5a897Schristos int (*explains_signal) (struct breakpoint *, enum gdb_signal); 62548596154Schristos 62648596154Schristos /* Called after evaluating the breakpoint's condition, 62748596154Schristos and only if it evaluated true. */ 62848596154Schristos void (*after_condition_true) (struct bpstats *bs); 62966e63ce3Schristos }; 63066e63ce3Schristos 63148596154Schristos /* Helper for breakpoint_ops->print_recreate implementations. Prints 63248596154Schristos the "thread" or "task" condition of B, and then a newline. 63348596154Schristos 63448596154Schristos Necessary because most breakpoint implementations accept 63548596154Schristos thread/task conditions at the end of the spec line, like "break foo 63648596154Schristos thread 1", which needs outputting before any breakpoint-type 63748596154Schristos specific extra command necessary for B's recreation. */ 63848596154Schristos extern void print_recreate_thread (struct breakpoint *b, struct ui_file *fp); 63948596154Schristos 64066e63ce3Schristos enum watchpoint_triggered 64166e63ce3Schristos { 64266e63ce3Schristos /* This watchpoint definitely did not trigger. */ 64366e63ce3Schristos watch_triggered_no = 0, 64466e63ce3Schristos 64566e63ce3Schristos /* Some hardware watchpoint triggered, and it might have been this 64666e63ce3Schristos one, but we do not know which it was. */ 64766e63ce3Schristos watch_triggered_unknown, 64866e63ce3Schristos 64966e63ce3Schristos /* This hardware watchpoint definitely did trigger. */ 65066e63ce3Schristos watch_triggered_yes 65166e63ce3Schristos }; 65266e63ce3Schristos 65366e63ce3Schristos typedef struct bp_location *bp_location_p; 65466e63ce3Schristos DEF_VEC_P(bp_location_p); 65566e63ce3Schristos 65666e63ce3Schristos /* A reference-counted struct command_line. This lets multiple 65766e63ce3Schristos breakpoints share a single command list. This is an implementation 65866e63ce3Schristos detail to the breakpoints module. */ 65966e63ce3Schristos struct counted_command_line; 66066e63ce3Schristos 66166e63ce3Schristos /* Some targets (e.g., embedded PowerPC) need two debug registers to set 66266e63ce3Schristos a watchpoint over a memory region. If this flag is true, GDB will use 66366e63ce3Schristos only one register per watchpoint, thus assuming that all acesses that 66466e63ce3Schristos modify a memory location happen at its starting address. */ 66566e63ce3Schristos 66666e63ce3Schristos extern int target_exact_watchpoints; 66766e63ce3Schristos 66866e63ce3Schristos /* Note that the ->silent field is not currently used by any commands 66966e63ce3Schristos (though the code is in there if it was to be, and set_raw_breakpoint 67066e63ce3Schristos does set it to 0). I implemented it because I thought it would be 67166e63ce3Schristos useful for a hack I had to put in; I'm going to leave it in because 67266e63ce3Schristos I can see how there might be times when it would indeed be useful */ 67366e63ce3Schristos 67448596154Schristos /* This is for all kinds of breakpoints. */ 67566e63ce3Schristos 67666e63ce3Schristos struct breakpoint 67766e63ce3Schristos { 67848596154Schristos /* Methods associated with this breakpoint. */ 67948596154Schristos const struct breakpoint_ops *ops; 68048596154Schristos 68166e63ce3Schristos struct breakpoint *next; 68266e63ce3Schristos /* Type of breakpoint. */ 68366e63ce3Schristos enum bptype type; 68466e63ce3Schristos /* Zero means disabled; remember the info but don't break here. */ 68566e63ce3Schristos enum enable_state enable_state; 68666e63ce3Schristos /* What to do with this breakpoint after we hit it. */ 68766e63ce3Schristos enum bpdisp disposition; 68866e63ce3Schristos /* Number assigned to distinguish breakpoints. */ 68966e63ce3Schristos int number; 69066e63ce3Schristos 69166e63ce3Schristos /* Location(s) associated with this high-level breakpoint. */ 69266e63ce3Schristos struct bp_location *loc; 69366e63ce3Schristos 694*1c468f90Schristos /* Non-zero means a silent breakpoint (don't print frame info if we 695*1c468f90Schristos stop here). */ 69666e63ce3Schristos unsigned char silent; 69766e63ce3Schristos /* Non-zero means display ADDR_STRING to the user verbatim. */ 69866e63ce3Schristos unsigned char display_canonical; 699*1c468f90Schristos /* Number of stops at this breakpoint that should be continued 700*1c468f90Schristos automatically before really stopping. */ 70166e63ce3Schristos int ignore_count; 70248596154Schristos 70348596154Schristos /* Number of stops at this breakpoint before it will be 70448596154Schristos disabled. */ 70548596154Schristos int enable_count; 70648596154Schristos 70766e63ce3Schristos /* Chain of command lines to execute when this breakpoint is 70866e63ce3Schristos hit. */ 70966e63ce3Schristos struct counted_command_line *commands; 71066e63ce3Schristos /* Stack depth (address of frame). If nonzero, break only if fp 71166e63ce3Schristos equals this. */ 71266e63ce3Schristos struct frame_id frame_id; 71366e63ce3Schristos 71448596154Schristos /* The program space used to set the breakpoint. This is only set 71548596154Schristos for breakpoints which are specific to a program space; for 71648596154Schristos non-thread-specific ordinary breakpoints this is NULL. */ 71766e63ce3Schristos struct program_space *pspace; 71866e63ce3Schristos 719*1c468f90Schristos /* Location we used to set the breakpoint. */ 720*1c468f90Schristos event_location_up location; 72166e63ce3Schristos 72248596154Schristos /* The filter that should be passed to decode_line_full when 72348596154Schristos re-setting this breakpoint. This may be NULL, but otherwise is 72448596154Schristos allocated with xmalloc. */ 72548596154Schristos char *filter; 72648596154Schristos 727*1c468f90Schristos /* For a ranged breakpoint, the location we used to find the end of 728*1c468f90Schristos the range. */ 729*1c468f90Schristos event_location_up location_range_end; 73066e63ce3Schristos 73166e63ce3Schristos /* Architecture we used to set the breakpoint. */ 73266e63ce3Schristos struct gdbarch *gdbarch; 73366e63ce3Schristos /* Language we used to set the breakpoint. */ 73466e63ce3Schristos enum language language; 73566e63ce3Schristos /* Input radix we used to set the breakpoint. */ 73666e63ce3Schristos int input_radix; 73766e63ce3Schristos /* String form of the breakpoint condition (malloc'd), or NULL if 73866e63ce3Schristos there is no condition. */ 73966e63ce3Schristos char *cond_string; 74066e63ce3Schristos 7417af5a897Schristos /* String form of extra parameters, or NULL if there are none. 7427af5a897Schristos Malloc'd. */ 74348596154Schristos char *extra_string; 74466e63ce3Schristos 745*1c468f90Schristos /* Holds the address of the related watchpoint_scope breakpoint when 746*1c468f90Schristos using watchpoints on local variables (might the concept of a 747*1c468f90Schristos related breakpoint be useful elsewhere, if not just call it the 748*1c468f90Schristos watchpoint_scope breakpoint or something like that. FIXME). */ 74966e63ce3Schristos struct breakpoint *related_breakpoint; 75066e63ce3Schristos 751*1c468f90Schristos /* Thread number for thread-specific breakpoint, or -1 if don't 752*1c468f90Schristos care. */ 75366e63ce3Schristos int thread; 75466e63ce3Schristos 755*1c468f90Schristos /* Ada task number for task-specific breakpoint, or 0 if don't 756*1c468f90Schristos care. */ 75766e63ce3Schristos int task; 75866e63ce3Schristos 75966e63ce3Schristos /* Count of the number of times this breakpoint was taken, dumped 760*1c468f90Schristos with the info, but not used for anything else. Useful for seeing 761*1c468f90Schristos how many times you hit a break prior to the program aborting, so 762*1c468f90Schristos you can back up to just before the abort. */ 76366e63ce3Schristos int hit_count; 76466e63ce3Schristos 765*1c468f90Schristos /* Is breakpoint's condition not yet parsed because we found no 766*1c468f90Schristos location initially so had no context to parse the condition 767*1c468f90Schristos in. */ 76866e63ce3Schristos int condition_not_parsed; 76966e63ce3Schristos 77048596154Schristos /* With a Python scripting enabled GDB, store a reference to the 77148596154Schristos Python object that has been associated with this breakpoint. 772*1c468f90Schristos This is always NULL for a GDB that is not script enabled. It can 773*1c468f90Schristos sometimes be NULL for enabled GDBs as not all breakpoint types 774*1c468f90Schristos are tracked by the scripting language API. */ 7757af5a897Schristos struct gdbpy_breakpoint_object *py_bp_object; 77626a53354Schristos 77726a53354Schristos /* Same as py_bp_object, but for Scheme. */ 77826a53354Schristos struct gdbscm_breakpoint_object *scm_bp_object; 77948596154Schristos }; 78048596154Schristos 78148596154Schristos /* An instance of this type is used to represent a watchpoint. It 78248596154Schristos includes a "struct breakpoint" as a kind of base class; users 78348596154Schristos downcast to "struct breakpoint *" when needed. */ 78448596154Schristos 78548596154Schristos struct watchpoint 78648596154Schristos { 78748596154Schristos /* The base class. */ 78848596154Schristos struct breakpoint base; 78948596154Schristos 79048596154Schristos /* String form of exp to use for displaying to the user (malloc'd), 79148596154Schristos or NULL if none. */ 79248596154Schristos char *exp_string; 79348596154Schristos /* String form to use for reparsing of EXP (malloc'd) or NULL. */ 79448596154Schristos char *exp_string_reparse; 79548596154Schristos 79648596154Schristos /* The expression we are watching, or NULL if not a watchpoint. */ 797*1c468f90Schristos expression_up exp; 79848596154Schristos /* The largest block within which it is valid, or NULL if it is 79948596154Schristos valid anywhere (e.g. consists just of global symbols). */ 80048596154Schristos const struct block *exp_valid_block; 80148596154Schristos /* The conditional expression if any. */ 802*1c468f90Schristos expression_up cond_exp; 80348596154Schristos /* The largest block within which it is valid, or NULL if it is 80448596154Schristos valid anywhere (e.g. consists just of global symbols). */ 80548596154Schristos const struct block *cond_exp_valid_block; 80648596154Schristos /* Value of the watchpoint the last time we checked it, or NULL when 80748596154Schristos we do not know the value yet or the value was not readable. VAL 80848596154Schristos is never lazy. */ 80948596154Schristos struct value *val; 81048596154Schristos /* Nonzero if VAL is valid. If VAL_VALID is set but VAL is NULL, 81148596154Schristos then an error occurred reading the value. */ 81248596154Schristos int val_valid; 81348596154Schristos 81426a53354Schristos /* When watching the location of a bitfield, contains the offset and size of 81526a53354Schristos the bitfield. Otherwise contains 0. */ 81626a53354Schristos int val_bitpos; 81726a53354Schristos int val_bitsize; 81826a53354Schristos 81948596154Schristos /* Holds the frame address which identifies the frame this 82048596154Schristos watchpoint should be evaluated in, or `null' if the watchpoint 82148596154Schristos should be evaluated on the outermost frame. */ 82248596154Schristos struct frame_id watchpoint_frame; 82348596154Schristos 82448596154Schristos /* Holds the thread which identifies the frame this watchpoint 82548596154Schristos should be considered in scope for, or `null_ptid' if the 82648596154Schristos watchpoint should be evaluated in all threads. */ 82748596154Schristos ptid_t watchpoint_thread; 82848596154Schristos 82948596154Schristos /* For hardware watchpoints, the triggered status according to the 83048596154Schristos hardware. */ 83148596154Schristos enum watchpoint_triggered watchpoint_triggered; 83248596154Schristos 83348596154Schristos /* Whether this watchpoint is exact (see 83448596154Schristos target_exact_watchpoints). */ 83548596154Schristos int exact; 83648596154Schristos 83748596154Schristos /* The mask address for a masked hardware watchpoint. */ 83848596154Schristos CORE_ADDR hw_wp_mask; 83948596154Schristos }; 84048596154Schristos 841ed6a76a9Schristos /* Given a function FUNC (struct breakpoint *B, void *DATA) and 842ed6a76a9Schristos USER_DATA, call FUNC for every known breakpoint passing USER_DATA 843ed6a76a9Schristos as argument. 844ed6a76a9Schristos 845ed6a76a9Schristos If FUNC returns 1, the loop stops and the current 846ed6a76a9Schristos 'struct breakpoint' being processed is returned. If FUNC returns 847ed6a76a9Schristos zero, the loop continues. 848ed6a76a9Schristos 849ed6a76a9Schristos This function returns either a 'struct breakpoint' pointer or NULL. 850ed6a76a9Schristos It was based on BFD's bfd_sections_find_if function. */ 851ed6a76a9Schristos 852ed6a76a9Schristos extern struct breakpoint *breakpoint_find_if 853ed6a76a9Schristos (int (*func) (struct breakpoint *b, void *d), void *user_data); 854ed6a76a9Schristos 85548596154Schristos /* Return true if BPT is either a software breakpoint or a hardware 85648596154Schristos breakpoint. */ 85748596154Schristos 85848596154Schristos extern int is_breakpoint (const struct breakpoint *bpt); 85948596154Schristos 86048596154Schristos /* Returns true if BPT is really a watchpoint. */ 86148596154Schristos 86248596154Schristos extern int is_watchpoint (const struct breakpoint *bpt); 86348596154Schristos 86448596154Schristos /* An instance of this type is used to represent all kinds of 86548596154Schristos tracepoints. It includes a "struct breakpoint" as a kind of base 86648596154Schristos class; users downcast to "struct breakpoint *" when needed. */ 86748596154Schristos 86848596154Schristos struct tracepoint 86948596154Schristos { 87048596154Schristos /* The base class. */ 87148596154Schristos struct breakpoint base; 87248596154Schristos 87348596154Schristos /* Number of times this tracepoint should single-step and collect 87448596154Schristos additional data. */ 87566e63ce3Schristos long step_count; 87666e63ce3Schristos 87766e63ce3Schristos /* Number of times this tracepoint should be hit before 87866e63ce3Schristos disabling/ending. */ 87966e63ce3Schristos int pass_count; 88066e63ce3Schristos 88166e63ce3Schristos /* The number of the tracepoint on the target. */ 88266e63ce3Schristos int number_on_target; 88366e63ce3Schristos 88448596154Schristos /* The total space taken by all the trace frames for this 88548596154Schristos tracepoint. */ 88648596154Schristos ULONGEST traceframe_usage; 88748596154Schristos 88866e63ce3Schristos /* The static tracepoint marker id, if known. */ 88966e63ce3Schristos char *static_trace_marker_id; 89066e63ce3Schristos 89166e63ce3Schristos /* LTTng/UST allow more than one marker with the same ID string, 89266e63ce3Schristos although it unadvised because it confuses tools. When setting 89366e63ce3Schristos static tracepoints by marker ID, this will record the index in 89466e63ce3Schristos the array of markers we found for the given marker ID for which 89548596154Schristos this static tracepoint corresponds. When resetting breakpoints, 89648596154Schristos we will use this index to try to find the same marker again. */ 89766e63ce3Schristos int static_trace_marker_id_idx; 89866e63ce3Schristos }; 89966e63ce3Schristos 90066e63ce3Schristos typedef struct breakpoint *breakpoint_p; 90166e63ce3Schristos DEF_VEC_P(breakpoint_p); 90266e63ce3Schristos 90366e63ce3Schristos /* The following stuff is an abstract data type "bpstat" ("breakpoint 90466e63ce3Schristos status"). This provides the ability to determine whether we have 90566e63ce3Schristos stopped at a breakpoint, and what we should do about it. */ 90666e63ce3Schristos 90766e63ce3Schristos typedef struct bpstats *bpstat; 90866e63ce3Schristos 90966e63ce3Schristos /* Clears a chain of bpstat, freeing storage 91066e63ce3Schristos of each. */ 91166e63ce3Schristos extern void bpstat_clear (bpstat *); 91266e63ce3Schristos 91366e63ce3Schristos /* Return a copy of a bpstat. Like "bs1 = bs2" but all storage that 91466e63ce3Schristos is part of the bpstat is copied as well. */ 91566e63ce3Schristos extern bpstat bpstat_copy (bpstat); 91666e63ce3Schristos 91766e63ce3Schristos extern bpstat bpstat_stop_status (struct address_space *aspace, 91848596154Schristos CORE_ADDR pc, ptid_t ptid, 91948596154Schristos const struct target_waitstatus *ws); 92066e63ce3Schristos 92166e63ce3Schristos /* This bpstat_what stuff tells wait_for_inferior what to do with a 92266e63ce3Schristos breakpoint (a challenging task). 92366e63ce3Schristos 92466e63ce3Schristos The enum values order defines priority-like order of the actions. 92566e63ce3Schristos Once you've decided that some action is appropriate, you'll never 92666e63ce3Schristos go back and decide something of a lower priority is better. Each 92766e63ce3Schristos of these actions is mutually exclusive with the others. That 92866e63ce3Schristos means, that if you find yourself adding a new action class here and 92966e63ce3Schristos wanting to tell GDB that you have two simultaneous actions to 93066e63ce3Schristos handle, something is wrong, and you probably don't actually need a 93166e63ce3Schristos new action type. 93266e63ce3Schristos 93366e63ce3Schristos Note that a step resume breakpoint overrides another breakpoint of 93466e63ce3Schristos signal handling (see comment in wait_for_inferior at where we set 93566e63ce3Schristos the step_resume breakpoint). */ 93666e63ce3Schristos 93766e63ce3Schristos enum bpstat_what_main_action 93866e63ce3Schristos { 93966e63ce3Schristos /* Perform various other tests; that is, this bpstat does not 94066e63ce3Schristos say to perform any action (e.g. failed watchpoint and nothing 94166e63ce3Schristos else). */ 94266e63ce3Schristos BPSTAT_WHAT_KEEP_CHECKING, 94366e63ce3Schristos 94466e63ce3Schristos /* Remove breakpoints, single step once, then put them back in and 94566e63ce3Schristos go back to what we were doing. It's possible that this should 94666e63ce3Schristos be removed from the main_action and put into a separate field, 94766e63ce3Schristos to more cleanly handle 94866e63ce3Schristos BPSTAT_WHAT_CLEAR_LONGJMP_RESUME_SINGLE. */ 94966e63ce3Schristos BPSTAT_WHAT_SINGLE, 95066e63ce3Schristos 95166e63ce3Schristos /* Set longjmp_resume breakpoint, remove all other breakpoints, 95266e63ce3Schristos and continue. The "remove all other breakpoints" part is 95366e63ce3Schristos required if we are also stepping over another breakpoint as 95466e63ce3Schristos well as doing the longjmp handling. */ 95566e63ce3Schristos BPSTAT_WHAT_SET_LONGJMP_RESUME, 95666e63ce3Schristos 95766e63ce3Schristos /* Clear longjmp_resume breakpoint, then handle as 95866e63ce3Schristos BPSTAT_WHAT_KEEP_CHECKING. */ 95966e63ce3Schristos BPSTAT_WHAT_CLEAR_LONGJMP_RESUME, 96066e63ce3Schristos 96148596154Schristos /* Clear step resume breakpoint, and keep checking. */ 96248596154Schristos BPSTAT_WHAT_STEP_RESUME, 96348596154Schristos 96466e63ce3Schristos /* Rather than distinguish between noisy and silent stops here, it 96566e63ce3Schristos might be cleaner to have bpstat_print make that decision (also 96666e63ce3Schristos taking into account stop_print_frame and source_only). But the 96766e63ce3Schristos implications are a bit scary (interaction with auto-displays, 96866e63ce3Schristos etc.), so I won't try it. */ 96966e63ce3Schristos 97066e63ce3Schristos /* Stop silently. */ 97166e63ce3Schristos BPSTAT_WHAT_STOP_SILENT, 97266e63ce3Schristos 97366e63ce3Schristos /* Stop and print. */ 97466e63ce3Schristos BPSTAT_WHAT_STOP_NOISY, 97566e63ce3Schristos 97648596154Schristos /* Clear step resume breakpoint, and keep checking. High-priority 97748596154Schristos step-resume breakpoints are used when even if there's a user 97848596154Schristos breakpoint at the current PC when we set the step-resume 97948596154Schristos breakpoint, we don't want to re-handle any breakpoint other 98048596154Schristos than the step-resume when it's hit; instead we want to move 98148596154Schristos past the breakpoint. This is used in the case of skipping 98248596154Schristos signal handlers. */ 98348596154Schristos BPSTAT_WHAT_HP_STEP_RESUME, 98466e63ce3Schristos }; 98566e63ce3Schristos 98666e63ce3Schristos /* An enum indicating the kind of "stack dummy" stop. This is a bit 98766e63ce3Schristos of a misnomer because only one kind of truly a stack dummy. */ 98866e63ce3Schristos enum stop_stack_kind 98966e63ce3Schristos { 99066e63ce3Schristos /* We didn't stop at a stack dummy breakpoint. */ 99166e63ce3Schristos STOP_NONE = 0, 99266e63ce3Schristos 99366e63ce3Schristos /* Stopped at a stack dummy. */ 99466e63ce3Schristos STOP_STACK_DUMMY, 99566e63ce3Schristos 99666e63ce3Schristos /* Stopped at std::terminate. */ 99766e63ce3Schristos STOP_STD_TERMINATE 99866e63ce3Schristos }; 99966e63ce3Schristos 100066e63ce3Schristos struct bpstat_what 100166e63ce3Schristos { 100266e63ce3Schristos enum bpstat_what_main_action main_action; 100366e63ce3Schristos 100466e63ce3Schristos /* Did we hit a call dummy breakpoint? This only goes with a 100566e63ce3Schristos main_action of BPSTAT_WHAT_STOP_SILENT or 100666e63ce3Schristos BPSTAT_WHAT_STOP_NOISY (the concept of continuing from a call 100766e63ce3Schristos dummy without popping the frame is not a useful one). */ 100866e63ce3Schristos enum stop_stack_kind call_dummy; 100966e63ce3Schristos 101066e63ce3Schristos /* Used for BPSTAT_WHAT_SET_LONGJMP_RESUME and 101166e63ce3Schristos BPSTAT_WHAT_CLEAR_LONGJMP_RESUME. True if we are handling a 101266e63ce3Schristos longjmp, false if we are handling an exception. */ 101366e63ce3Schristos int is_longjmp; 101466e63ce3Schristos }; 101566e63ce3Schristos 101666e63ce3Schristos /* Tell what to do about this bpstat. */ 101766e63ce3Schristos struct bpstat_what bpstat_what (bpstat); 1018c03b94e9Schristos 1019c03b94e9Schristos /* Run breakpoint event callbacks associated with the breakpoints that 1020c03b94e9Schristos triggered. */ 1021c03b94e9Schristos extern void bpstat_run_callbacks (bpstat bs_head); 1022c03b94e9Schristos 102366e63ce3Schristos /* Find the bpstat associated with a breakpoint. NULL otherwise. */ 102466e63ce3Schristos bpstat bpstat_find_breakpoint (bpstat, struct breakpoint *); 102566e63ce3Schristos 10267af5a897Schristos /* Nonzero if a signal that we got in target_wait() was due to 10277af5a897Schristos circumstances explained by the bpstat; the signal is therefore not 10287af5a897Schristos random. */ 10297af5a897Schristos extern int bpstat_explains_signal (bpstat, enum gdb_signal); 103066e63ce3Schristos 103166e63ce3Schristos /* Nonzero is this bpstat causes a stop. */ 103266e63ce3Schristos extern int bpstat_causes_stop (bpstat); 103366e63ce3Schristos 103466e63ce3Schristos /* Nonzero if we should step constantly (e.g. watchpoints on machines 103566e63ce3Schristos without hardware support). This isn't related to a specific bpstat, 103666e63ce3Schristos just to things like whether watchpoints are set. */ 103766e63ce3Schristos extern int bpstat_should_step (void); 103866e63ce3Schristos 103966e63ce3Schristos /* Print a message indicating what happened. Returns nonzero to 104066e63ce3Schristos say that only the source line should be printed after this (zero 104166e63ce3Schristos return means print the frame as well as the source line). */ 104248596154Schristos extern enum print_stop_action bpstat_print (bpstat, int); 104366e63ce3Schristos 104466e63ce3Schristos /* Put in *NUM the breakpoint number of the first breakpoint we are 104566e63ce3Schristos stopped at. *BSP upon return is a bpstat which points to the 104666e63ce3Schristos remaining breakpoints stopped at (but which is not guaranteed to be 104766e63ce3Schristos good for anything but further calls to bpstat_num). 104866e63ce3Schristos 104966e63ce3Schristos Return 0 if passed a bpstat which does not indicate any breakpoints. 105066e63ce3Schristos Return -1 if stopped at a breakpoint that has been deleted since 105166e63ce3Schristos we set it. 105266e63ce3Schristos Return 1 otherwise. */ 105366e63ce3Schristos extern int bpstat_num (bpstat *, int *); 105466e63ce3Schristos 105566e63ce3Schristos /* Perform actions associated with the stopped inferior. Actually, we 105666e63ce3Schristos just use this for breakpoint commands. Perhaps other actions will 105766e63ce3Schristos go here later, but this is executed at a late time (from the 105866e63ce3Schristos command loop). */ 105966e63ce3Schristos extern void bpstat_do_actions (void); 106066e63ce3Schristos 106148596154Schristos /* Modify all entries of STOP_BPSTAT of INFERIOR_PTID so that the actions will 106248596154Schristos not be performed. */ 106348596154Schristos extern void bpstat_clear_actions (void); 106466e63ce3Schristos 106566e63ce3Schristos /* Implementation: */ 106666e63ce3Schristos 106766e63ce3Schristos /* Values used to tell the printing routine how to behave for this 106866e63ce3Schristos bpstat. */ 106966e63ce3Schristos enum bp_print_how 107066e63ce3Schristos { 107166e63ce3Schristos /* This is used when we want to do a normal printing of the reason 107266e63ce3Schristos for stopping. The output will depend on the type of eventpoint 107366e63ce3Schristos we are dealing with. This is the default value, most commonly 107466e63ce3Schristos used. */ 107566e63ce3Schristos print_it_normal, 107666e63ce3Schristos /* This is used when nothing should be printed for this bpstat 107766e63ce3Schristos entry. */ 107866e63ce3Schristos print_it_noop, 107966e63ce3Schristos /* This is used when everything which needs to be printed has 108066e63ce3Schristos already been printed. But we still want to print the frame. */ 108166e63ce3Schristos print_it_done 108266e63ce3Schristos }; 108366e63ce3Schristos 108466e63ce3Schristos struct bpstats 108566e63ce3Schristos { 108666e63ce3Schristos /* Linked list because there can be more than one breakpoint at 108766e63ce3Schristos the same place, and a bpstat reflects the fact that all have 108866e63ce3Schristos been hit. */ 108966e63ce3Schristos bpstat next; 109066e63ce3Schristos 109166e63ce3Schristos /* Location that caused the stop. Locations are refcounted, so 109266e63ce3Schristos this will never be NULL. Note that this location may end up 109366e63ce3Schristos detached from a breakpoint, but that does not necessary mean 109466e63ce3Schristos that the struct breakpoint is gone. E.g., consider a 109566e63ce3Schristos watchpoint with a condition that involves an inferior function 109666e63ce3Schristos call. Watchpoint locations are recreated often (on resumes, 109766e63ce3Schristos hence on infcalls too). Between creating the bpstat and after 109866e63ce3Schristos evaluating the watchpoint condition, this location may hence 109966e63ce3Schristos end up detached from its original owner watchpoint, even though 110066e63ce3Schristos the watchpoint is still listed. If it's condition evaluates as 110166e63ce3Schristos true, we still want this location to cause a stop, and we will 110266e63ce3Schristos still need to know which watchpoint it was originally attached. 110366e63ce3Schristos What this means is that we should not (in most cases) follow 110466e63ce3Schristos the `bpstat->bp_location->owner' link, but instead use the 110566e63ce3Schristos `breakpoint_at' field below. */ 110666e63ce3Schristos struct bp_location *bp_location_at; 110766e63ce3Schristos 110866e63ce3Schristos /* Breakpoint that caused the stop. This is nullified if the 110966e63ce3Schristos breakpoint ends up being deleted. See comments on 111066e63ce3Schristos `bp_location_at' above for why do we need this field instead of 111166e63ce3Schristos following the location's owner. */ 111266e63ce3Schristos struct breakpoint *breakpoint_at; 111366e63ce3Schristos 111466e63ce3Schristos /* The associated command list. */ 111566e63ce3Schristos struct counted_command_line *commands; 111666e63ce3Schristos 111766e63ce3Schristos /* Old value associated with a watchpoint. */ 111866e63ce3Schristos struct value *old_val; 111966e63ce3Schristos 112066e63ce3Schristos /* Nonzero if this breakpoint tells us to print the frame. */ 112166e63ce3Schristos char print; 112266e63ce3Schristos 112366e63ce3Schristos /* Nonzero if this breakpoint tells us to stop. */ 112466e63ce3Schristos char stop; 112566e63ce3Schristos 112666e63ce3Schristos /* Tell bpstat_print and print_bp_stop_message how to print stuff 112766e63ce3Schristos associated with this element of the bpstat chain. */ 112866e63ce3Schristos enum bp_print_how print_it; 112966e63ce3Schristos }; 113066e63ce3Schristos 113166e63ce3Schristos enum inf_context 113266e63ce3Schristos { 113366e63ce3Schristos inf_starting, 113466e63ce3Schristos inf_running, 113566e63ce3Schristos inf_exited, 113666e63ce3Schristos inf_execd 113766e63ce3Schristos }; 113866e63ce3Schristos 113966e63ce3Schristos /* The possible return values for breakpoint_here_p. 114066e63ce3Schristos We guarantee that zero always means "no breakpoint here". */ 114166e63ce3Schristos enum breakpoint_here 114266e63ce3Schristos { 114366e63ce3Schristos no_breakpoint_here = 0, 114466e63ce3Schristos ordinary_breakpoint_here, 114566e63ce3Schristos permanent_breakpoint_here 114666e63ce3Schristos }; 114766e63ce3Schristos 114866e63ce3Schristos 114966e63ce3Schristos /* Prototypes for breakpoint-related functions. */ 115066e63ce3Schristos 1151ed6a76a9Schristos /* Return 1 if there's a program/permanent breakpoint planted in 1152ed6a76a9Schristos memory at ADDRESS, return 0 otherwise. */ 1153ed6a76a9Schristos 1154ed6a76a9Schristos extern int program_breakpoint_here_p (struct gdbarch *gdbarch, CORE_ADDR address); 1155ed6a76a9Schristos 115666e63ce3Schristos extern enum breakpoint_here breakpoint_here_p (struct address_space *, 115766e63ce3Schristos CORE_ADDR); 115866e63ce3Schristos 1159c03b94e9Schristos /* Return true if an enabled breakpoint exists in the range defined by 1160c03b94e9Schristos ADDR and LEN, in ASPACE. */ 1161c03b94e9Schristos extern int breakpoint_in_range_p (struct address_space *aspace, 1162c03b94e9Schristos CORE_ADDR addr, ULONGEST len); 1163c03b94e9Schristos 116466e63ce3Schristos extern int moribund_breakpoint_here_p (struct address_space *, CORE_ADDR); 116566e63ce3Schristos 116666e63ce3Schristos extern int breakpoint_inserted_here_p (struct address_space *, CORE_ADDR); 116766e63ce3Schristos 116866e63ce3Schristos extern int regular_breakpoint_inserted_here_p (struct address_space *, 116966e63ce3Schristos CORE_ADDR); 117066e63ce3Schristos 117166e63ce3Schristos extern int software_breakpoint_inserted_here_p (struct address_space *, 117266e63ce3Schristos CORE_ADDR); 117366e63ce3Schristos 117426a53354Schristos /* Return non-zero iff there is a hardware breakpoint inserted at 117526a53354Schristos PC. */ 117626a53354Schristos extern int hardware_breakpoint_inserted_here_p (struct address_space *, 117726a53354Schristos CORE_ADDR); 117826a53354Schristos 117926a53354Schristos /* Check whether any location of BP is inserted at PC. */ 118026a53354Schristos 118126a53354Schristos extern int breakpoint_has_location_inserted_here (struct breakpoint *bp, 118226a53354Schristos struct address_space *aspace, 118326a53354Schristos CORE_ADDR pc); 118426a53354Schristos 118526a53354Schristos extern int single_step_breakpoint_inserted_here_p (struct address_space *, 118626a53354Schristos CORE_ADDR); 118726a53354Schristos 118866e63ce3Schristos /* Returns true if there's a hardware watchpoint or access watchpoint 118966e63ce3Schristos inserted in the range defined by ADDR and LEN. */ 119066e63ce3Schristos extern int hardware_watchpoint_inserted_in_range (struct address_space *, 119166e63ce3Schristos CORE_ADDR addr, 119266e63ce3Schristos ULONGEST len); 119366e63ce3Schristos 119426a53354Schristos /* Returns true if {ASPACE1,ADDR1} and {ASPACE2,ADDR2} represent the 119526a53354Schristos same breakpoint location. In most targets, this can only be true 119626a53354Schristos if ASPACE1 matches ASPACE2. On targets that have global 119726a53354Schristos breakpoints, the address space doesn't really matter. */ 119826a53354Schristos 119926a53354Schristos extern int breakpoint_address_match (struct address_space *aspace1, 120026a53354Schristos CORE_ADDR addr1, 120126a53354Schristos struct address_space *aspace2, 120226a53354Schristos CORE_ADDR addr2); 120366e63ce3Schristos 120466e63ce3Schristos extern void until_break_command (char *, int, int); 120566e63ce3Schristos 120648596154Schristos /* Initialize a struct bp_location. */ 120748596154Schristos 120848596154Schristos extern void init_bp_location (struct bp_location *loc, 120948596154Schristos const struct bp_location_ops *ops, 121048596154Schristos struct breakpoint *owner); 121148596154Schristos 121266e63ce3Schristos extern void update_breakpoint_locations (struct breakpoint *b, 1213c03b94e9Schristos struct program_space *filter_pspace, 121466e63ce3Schristos struct symtabs_and_lines sals, 121566e63ce3Schristos struct symtabs_and_lines sals_end); 121666e63ce3Schristos 121766e63ce3Schristos extern void breakpoint_re_set (void); 121866e63ce3Schristos 121966e63ce3Schristos extern void breakpoint_re_set_thread (struct breakpoint *); 122066e63ce3Schristos 122166e63ce3Schristos extern struct breakpoint *set_momentary_breakpoint 122266e63ce3Schristos (struct gdbarch *, struct symtab_and_line, struct frame_id, enum bptype); 122366e63ce3Schristos 122466e63ce3Schristos extern struct breakpoint *set_momentary_breakpoint_at_pc 122566e63ce3Schristos (struct gdbarch *, CORE_ADDR pc, enum bptype type); 122666e63ce3Schristos 122766e63ce3Schristos extern struct breakpoint *clone_momentary_breakpoint (struct breakpoint *bpkt); 122866e63ce3Schristos 122966e63ce3Schristos extern void set_ignore_count (int, int, int); 123066e63ce3Schristos 123166e63ce3Schristos extern void breakpoint_init_inferior (enum inf_context); 123266e63ce3Schristos 123366e63ce3Schristos extern struct cleanup *make_cleanup_delete_breakpoint (struct breakpoint *); 123466e63ce3Schristos 123566e63ce3Schristos extern void delete_breakpoint (struct breakpoint *); 123666e63ce3Schristos 123766e63ce3Schristos extern void breakpoint_auto_delete (bpstat); 123866e63ce3Schristos 123948596154Schristos typedef void (*walk_bp_location_callback) (struct bp_location *, void *); 124048596154Schristos 124148596154Schristos extern void iterate_over_bp_locations (walk_bp_location_callback); 124248596154Schristos 124366e63ce3Schristos /* Return the chain of command lines to execute when this breakpoint 124466e63ce3Schristos is hit. */ 124566e63ce3Schristos extern struct command_line *breakpoint_commands (struct breakpoint *b); 124666e63ce3Schristos 124766e63ce3Schristos /* Return a string image of DISP. The string is static, and thus should 124866e63ce3Schristos NOT be deallocated after use. */ 124966e63ce3Schristos const char *bpdisp_text (enum bpdisp disp); 125066e63ce3Schristos 125166e63ce3Schristos extern void break_command (char *, int); 125266e63ce3Schristos 125366e63ce3Schristos extern void hbreak_command_wrapper (char *, int); 125466e63ce3Schristos extern void thbreak_command_wrapper (char *, int); 125566e63ce3Schristos extern void rbreak_command_wrapper (char *, int); 125666e63ce3Schristos extern void watch_command_wrapper (char *, int, int); 125766e63ce3Schristos extern void awatch_command_wrapper (char *, int, int); 125866e63ce3Schristos extern void rwatch_command_wrapper (char *, int, int); 125966e63ce3Schristos extern void tbreak_command (char *, int); 126066e63ce3Schristos 126148596154Schristos extern struct breakpoint_ops base_breakpoint_ops; 126248596154Schristos extern struct breakpoint_ops bkpt_breakpoint_ops; 126348596154Schristos extern struct breakpoint_ops tracepoint_breakpoint_ops; 12647af5a897Schristos extern struct breakpoint_ops dprintf_breakpoint_ops; 126548596154Schristos 126648596154Schristos extern void initialize_breakpoint_ops (void); 126748596154Schristos 126848596154Schristos /* Arguments to pass as context to some catch command handlers. */ 126948596154Schristos #define CATCH_PERMANENT ((void *) (uintptr_t) 0) 127048596154Schristos #define CATCH_TEMPORARY ((void *) (uintptr_t) 1) 127148596154Schristos 127248596154Schristos /* Like add_cmd, but add the command to both the "catch" and "tcatch" 127348596154Schristos lists, and pass some additional user data to the command 127448596154Schristos function. */ 127548596154Schristos 127648596154Schristos extern void 1277*1c468f90Schristos add_catch_command (const char *name, const char *docstring, 127826a53354Schristos cmd_sfunc_ftype *sfunc, 127948596154Schristos completer_ftype *completer, 128048596154Schristos void *user_data_catch, 128148596154Schristos void *user_data_tcatch); 128248596154Schristos 128348596154Schristos /* Initialize a breakpoint struct for Ada exception catchpoints. */ 128448596154Schristos 128548596154Schristos extern void 128648596154Schristos init_ada_exception_breakpoint (struct breakpoint *b, 128748596154Schristos struct gdbarch *gdbarch, 128848596154Schristos struct symtab_and_line sal, 128948596154Schristos char *addr_string, 129048596154Schristos const struct breakpoint_ops *ops, 129148596154Schristos int tempflag, 12927af5a897Schristos int enabled, 129348596154Schristos int from_tty); 129448596154Schristos 129548596154Schristos extern void init_catchpoint (struct breakpoint *b, 129648596154Schristos struct gdbarch *gdbarch, int tempflag, 1297*1c468f90Schristos const char *cond_string, 129848596154Schristos const struct breakpoint_ops *ops); 129948596154Schristos 130048596154Schristos /* Add breakpoint B on the breakpoint list, and notify the user, the 130148596154Schristos target and breakpoint_created observers of its existence. If 130248596154Schristos INTERNAL is non-zero, the breakpoint number will be allocated from 130348596154Schristos the internal breakpoint count. If UPDATE_GLL is non-zero, 130448596154Schristos update_global_location_list will be called. */ 130548596154Schristos 130648596154Schristos extern void install_breakpoint (int internal, struct breakpoint *b, 130748596154Schristos int update_gll); 130848596154Schristos 130948596154Schristos /* Flags that can be passed down to create_breakpoint, etc., to affect 131048596154Schristos breakpoint creation in several ways. */ 131148596154Schristos 131248596154Schristos enum breakpoint_create_flags 131348596154Schristos { 131448596154Schristos /* We're adding a breakpoint to our tables that is already 131548596154Schristos inserted in the target. */ 131648596154Schristos CREATE_BREAKPOINT_FLAGS_INSERTED = 1 << 0 131748596154Schristos }; 131848596154Schristos 1319c03b94e9Schristos /* Set a breakpoint. This function is shared between CLI and MI functions 1320c03b94e9Schristos for setting a breakpoint at LOCATION. 1321c03b94e9Schristos 1322c03b94e9Schristos This function has two major modes of operations, selected by the 1323c03b94e9Schristos PARSE_EXTRA parameter. 1324c03b94e9Schristos 1325c03b94e9Schristos If PARSE_EXTRA is zero, LOCATION is just the breakpoint's location, 1326c03b94e9Schristos with condition, thread, and extra string specified by the COND_STRING, 1327c03b94e9Schristos THREAD, and EXTRA_STRING parameters. 1328c03b94e9Schristos 1329c03b94e9Schristos If PARSE_EXTRA is non-zero, this function will attempt to extract 1330c03b94e9Schristos the condition, thread, and extra string from EXTRA_STRING, ignoring 1331c03b94e9Schristos the similarly named parameters. 1332c03b94e9Schristos 1333c03b94e9Schristos If INTERNAL is non-zero, the breakpoint number will be allocated 1334c03b94e9Schristos from the internal breakpoint count. 1335c03b94e9Schristos 1336c03b94e9Schristos Returns true if any breakpoint was created; false otherwise. */ 1337c03b94e9Schristos 1338c03b94e9Schristos extern int create_breakpoint (struct gdbarch *gdbarch, 1339c03b94e9Schristos const struct event_location *location, 134066e63ce3Schristos char *cond_string, int thread, 134148596154Schristos char *extra_string, 1342c03b94e9Schristos int parse_extra, 134366e63ce3Schristos int tempflag, enum bptype wanted_type, 134466e63ce3Schristos int ignore_count, 134566e63ce3Schristos enum auto_boolean pending_break_support, 134648596154Schristos const struct breakpoint_ops *ops, 134766e63ce3Schristos int from_tty, 134866e63ce3Schristos int enabled, 134948596154Schristos int internal, unsigned flags); 135066e63ce3Schristos 135166e63ce3Schristos extern void insert_breakpoints (void); 135266e63ce3Schristos 135366e63ce3Schristos extern int remove_breakpoints (void); 135466e63ce3Schristos 135566e63ce3Schristos extern int remove_breakpoints_pid (int pid); 135666e63ce3Schristos 135766e63ce3Schristos /* This function can be used to physically insert eventpoints from the 135866e63ce3Schristos specified traced inferior process, without modifying the breakpoint 135966e63ce3Schristos package's state. This can be useful for those targets which 136066e63ce3Schristos support following the processes of a fork() or vfork() system call, 136166e63ce3Schristos when both of the resulting two processes are to be followed. */ 136266e63ce3Schristos extern int reattach_breakpoints (int); 136366e63ce3Schristos 136466e63ce3Schristos /* This function can be used to update the breakpoint package's state 136566e63ce3Schristos after an exec() system call has been executed. 136666e63ce3Schristos 136766e63ce3Schristos This function causes the following: 136866e63ce3Schristos 136966e63ce3Schristos - All eventpoints are marked "not inserted". 137066e63ce3Schristos - All eventpoints with a symbolic address are reset such that 137166e63ce3Schristos the symbolic address must be reevaluated before the eventpoints 137266e63ce3Schristos can be reinserted. 137366e63ce3Schristos - The solib breakpoints are explicitly removed from the breakpoint 137466e63ce3Schristos list. 137566e63ce3Schristos - A step-resume breakpoint, if any, is explicitly removed from the 137666e63ce3Schristos breakpoint list. 137766e63ce3Schristos - All eventpoints without a symbolic address are removed from the 137866e63ce3Schristos breakpoint list. */ 137966e63ce3Schristos extern void update_breakpoints_after_exec (void); 138066e63ce3Schristos 138166e63ce3Schristos /* This function can be used to physically remove hardware breakpoints 138266e63ce3Schristos and watchpoints from the specified traced inferior process, without 138366e63ce3Schristos modifying the breakpoint package's state. This can be useful for 138466e63ce3Schristos those targets which support following the processes of a fork() or 138566e63ce3Schristos vfork() system call, when one of the resulting two processes is to 138666e63ce3Schristos be detached and allowed to run free. 138766e63ce3Schristos 138866e63ce3Schristos It is an error to use this function on the process whose id is 138966e63ce3Schristos inferior_ptid. */ 139048596154Schristos extern int detach_breakpoints (ptid_t ptid); 139166e63ce3Schristos 139266e63ce3Schristos /* This function is called when program space PSPACE is about to be 139366e63ce3Schristos deleted. It takes care of updating breakpoints to not reference 139466e63ce3Schristos this PSPACE anymore. */ 139566e63ce3Schristos extern void breakpoint_program_space_exit (struct program_space *pspace); 139666e63ce3Schristos 139766e63ce3Schristos extern void set_longjmp_breakpoint (struct thread_info *tp, 139866e63ce3Schristos struct frame_id frame); 139966e63ce3Schristos extern void delete_longjmp_breakpoint (int thread); 140066e63ce3Schristos 140148596154Schristos /* Mark all longjmp breakpoints from THREAD for later deletion. */ 140248596154Schristos extern void delete_longjmp_breakpoint_at_next_stop (int thread); 140348596154Schristos 140448596154Schristos extern struct breakpoint *set_longjmp_breakpoint_for_call_dummy (void); 140526a53354Schristos extern void check_longjmp_breakpoint_for_call_dummy (struct thread_info *tp); 140648596154Schristos 140766e63ce3Schristos extern void enable_overlay_breakpoints (void); 140866e63ce3Schristos extern void disable_overlay_breakpoints (void); 140966e63ce3Schristos 141066e63ce3Schristos extern void set_std_terminate_breakpoint (void); 141166e63ce3Schristos extern void delete_std_terminate_breakpoint (void); 141266e63ce3Schristos 141366e63ce3Schristos /* These functions respectively disable or reenable all currently 141466e63ce3Schristos enabled watchpoints. When disabled, the watchpoints are marked 141548596154Schristos call_disabled. When re-enabled, they are marked enabled. 141666e63ce3Schristos 141766e63ce3Schristos The intended client of these functions is call_function_by_hand. 141866e63ce3Schristos 141966e63ce3Schristos The inferior must be stopped, and all breakpoints removed, when 142066e63ce3Schristos these functions are used. 142166e63ce3Schristos 142266e63ce3Schristos The need for these functions is that on some targets (e.g., HP-UX), 142366e63ce3Schristos gdb is unable to unwind through the dummy frame that is pushed as 142466e63ce3Schristos part of the implementation of a call command. Watchpoints can 142566e63ce3Schristos cause the inferior to stop in places where this frame is visible, 142666e63ce3Schristos and that can cause execution control to become very confused. 142766e63ce3Schristos 142866e63ce3Schristos Note that if a user sets breakpoints in an interactively called 142948596154Schristos function, the call_disabled watchpoints will have been re-enabled 143066e63ce3Schristos when the first such breakpoint is reached. However, on targets 143166e63ce3Schristos that are unable to unwind through the call dummy frame, watches 143266e63ce3Schristos of stack-based storage may then be deleted, because gdb will 143366e63ce3Schristos believe that their watched storage is out of scope. (Sigh.) */ 143466e63ce3Schristos extern void disable_watchpoints_before_interactive_call_start (void); 143566e63ce3Schristos 143666e63ce3Schristos extern void enable_watchpoints_after_interactive_call_stop (void); 143766e63ce3Schristos 143866e63ce3Schristos /* These functions disable and re-enable all breakpoints during 143966e63ce3Schristos inferior startup. They are intended to be called from solib 144066e63ce3Schristos code where necessary. This is needed on platforms where the 144166e63ce3Schristos main executable is relocated at some point during startup 144266e63ce3Schristos processing, making breakpoint addresses invalid. 144366e63ce3Schristos 144466e63ce3Schristos If additional breakpoints are created after the routine 144566e63ce3Schristos disable_breakpoints_before_startup but before the routine 144666e63ce3Schristos enable_breakpoints_after_startup was called, they will also 144766e63ce3Schristos be marked as disabled. */ 144866e63ce3Schristos extern void disable_breakpoints_before_startup (void); 144966e63ce3Schristos extern void enable_breakpoints_after_startup (void); 145066e63ce3Schristos 145166e63ce3Schristos /* For script interpreters that need to define breakpoint commands 145266e63ce3Schristos after they've already read the commands into a struct 145366e63ce3Schristos command_line. */ 145466e63ce3Schristos extern enum command_control_type commands_from_control_command 1455*1c468f90Schristos (const char *arg, struct command_line *cmd); 145666e63ce3Schristos 145766e63ce3Schristos extern void clear_breakpoint_hit_counts (void); 145866e63ce3Schristos 145966e63ce3Schristos extern struct breakpoint *get_breakpoint (int num); 146066e63ce3Schristos 146166e63ce3Schristos /* The following are for displays, which aren't really breakpoints, 146266e63ce3Schristos but here is as good a place as any for them. */ 146366e63ce3Schristos 146466e63ce3Schristos extern void disable_current_display (void); 146566e63ce3Schristos 146666e63ce3Schristos extern void do_displays (void); 146766e63ce3Schristos 146866e63ce3Schristos extern void disable_display (int); 146966e63ce3Schristos 147066e63ce3Schristos extern void clear_displays (void); 147166e63ce3Schristos 147266e63ce3Schristos extern void disable_breakpoint (struct breakpoint *); 147366e63ce3Schristos 147466e63ce3Schristos extern void enable_breakpoint (struct breakpoint *); 147566e63ce3Schristos 147666e63ce3Schristos extern void breakpoint_set_commands (struct breakpoint *b, 1477*1c468f90Schristos command_line_up &&commands); 147866e63ce3Schristos 147966e63ce3Schristos extern void breakpoint_set_silent (struct breakpoint *b, int silent); 148066e63ce3Schristos 148166e63ce3Schristos extern void breakpoint_set_thread (struct breakpoint *b, int thread); 148266e63ce3Schristos 148366e63ce3Schristos extern void breakpoint_set_task (struct breakpoint *b, int task); 148466e63ce3Schristos 148566e63ce3Schristos /* Clear the "inserted" flag in all breakpoints. */ 148666e63ce3Schristos extern void mark_breakpoints_out (void); 148766e63ce3Schristos 148866e63ce3Schristos extern struct breakpoint *create_jit_event_breakpoint (struct gdbarch *, 148966e63ce3Schristos CORE_ADDR); 149066e63ce3Schristos 149166e63ce3Schristos extern struct breakpoint *create_solib_event_breakpoint (struct gdbarch *, 149266e63ce3Schristos CORE_ADDR); 149366e63ce3Schristos 149426a53354Schristos /* Create an solib event breakpoint at ADDRESS in the current program 149526a53354Schristos space, and immediately try to insert it. Returns a pointer to the 149626a53354Schristos breakpoint on success. Deletes the new breakpoint and returns NULL 149726a53354Schristos if inserting the breakpoint fails. */ 149826a53354Schristos extern struct breakpoint *create_and_insert_solib_event_breakpoint 149926a53354Schristos (struct gdbarch *gdbarch, CORE_ADDR address); 150026a53354Schristos 150166e63ce3Schristos extern struct breakpoint *create_thread_event_breakpoint (struct gdbarch *, 150266e63ce3Schristos CORE_ADDR); 150366e63ce3Schristos 150466e63ce3Schristos extern void remove_jit_event_breakpoints (void); 150566e63ce3Schristos 150666e63ce3Schristos extern void remove_solib_event_breakpoints (void); 150766e63ce3Schristos 150826a53354Schristos /* Mark solib event breakpoints of the current program space with 150926a53354Schristos delete at next stop disposition. */ 151026a53354Schristos extern void remove_solib_event_breakpoints_at_next_stop (void); 151126a53354Schristos 151266e63ce3Schristos extern void disable_breakpoints_in_shlibs (void); 151366e63ce3Schristos 151466e63ce3Schristos /* This function returns TRUE if ep is a catchpoint. */ 151548596154Schristos extern int is_catchpoint (struct breakpoint *); 151648596154Schristos 151748596154Schristos /* Shared helper function (MI and CLI) for creating and installing 151848596154Schristos a shared object event catchpoint. */ 1519*1c468f90Schristos extern void add_solib_catchpoint (const char *arg, int is_load, int is_temp, 152048596154Schristos int enabled); 152166e63ce3Schristos 152266e63ce3Schristos /* Enable breakpoints and delete when hit. Called with ARG == NULL 152366e63ce3Schristos deletes all breakpoints. */ 152466e63ce3Schristos extern void delete_command (char *arg, int from_tty); 152566e63ce3Schristos 152626a53354Schristos /* Create and insert a new software single step breakpoint for the 152726a53354Schristos current thread. May be called multiple times; each time will add a 152826a53354Schristos new location to the set of potential addresses the next instruction 152926a53354Schristos is at. */ 153066e63ce3Schristos extern void insert_single_step_breakpoint (struct gdbarch *, 153166e63ce3Schristos struct address_space *, 153266e63ce3Schristos CORE_ADDR); 1533*1c468f90Schristos 1534*1c468f90Schristos /* Insert all software single step breakpoints for the current frame. 1535*1c468f90Schristos Return true if any software single step breakpoints are inserted, 1536*1c468f90Schristos otherwise, return false. */ 1537*1c468f90Schristos extern int insert_single_step_breakpoints (struct gdbarch *); 1538*1c468f90Schristos 153966e63ce3Schristos /* Check if any hardware watchpoints have triggered, according to the 154066e63ce3Schristos target. */ 154166e63ce3Schristos int watchpoints_triggered (struct target_waitstatus *); 154266e63ce3Schristos 154348596154Schristos /* Helper for transparent breakpoint hiding for memory read and write 154448596154Schristos routines. 154548596154Schristos 154648596154Schristos Update one of READBUF or WRITEBUF with either the shadows 154748596154Schristos (READBUF), or the breakpoint instructions (WRITEBUF) of inserted 154848596154Schristos breakpoints at the memory range defined by MEMADDR and extending 154948596154Schristos for LEN bytes. If writing, then WRITEBUF is a copy of WRITEBUF_ORG 155048596154Schristos on entry.*/ 155148596154Schristos extern void breakpoint_xfer_memory (gdb_byte *readbuf, gdb_byte *writebuf, 155248596154Schristos const gdb_byte *writebuf_org, 155348596154Schristos ULONGEST memaddr, LONGEST len); 155466e63ce3Schristos 155526a53354Schristos /* Return true if breakpoints should be inserted now. That'll be the 155626a53354Schristos case if either: 155726a53354Schristos 155826a53354Schristos - the target has global breakpoints. 155926a53354Schristos 156026a53354Schristos - "breakpoint always-inserted" is on, and the target has 156126a53354Schristos execution. 156226a53354Schristos 156326a53354Schristos - threads are executing. 156426a53354Schristos */ 156526a53354Schristos extern int breakpoints_should_be_inserted_now (void); 156666e63ce3Schristos 156766e63ce3Schristos /* Called each time new event from target is processed. 156866e63ce3Schristos Retires previously deleted breakpoint locations that 156966e63ce3Schristos in our opinion won't ever trigger. */ 157066e63ce3Schristos extern void breakpoint_retire_moribund (void); 157166e63ce3Schristos 157266e63ce3Schristos /* Set break condition of breakpoint B to EXP. */ 1573ed6a76a9Schristos extern void set_breakpoint_condition (struct breakpoint *b, const char *exp, 157466e63ce3Schristos int from_tty); 157566e63ce3Schristos 157666e63ce3Schristos /* Checks if we are catching syscalls or not. 157766e63ce3Schristos Returns 0 if not, greater than 0 if we are. */ 157866e63ce3Schristos extern int catch_syscall_enabled (void); 157966e63ce3Schristos 158066e63ce3Schristos /* Checks if we are catching syscalls with the specific 158166e63ce3Schristos syscall_number. Used for "filtering" the catchpoints. 158266e63ce3Schristos Returns 0 if not, greater than 0 if we are. */ 158366e63ce3Schristos extern int catching_syscall_number (int syscall_number); 158466e63ce3Schristos 158566e63ce3Schristos /* Return a tracepoint with the given number if found. */ 158648596154Schristos extern struct tracepoint *get_tracepoint (int num); 158766e63ce3Schristos 158848596154Schristos extern struct tracepoint *get_tracepoint_by_number_on_target (int num); 158966e63ce3Schristos 159066e63ce3Schristos /* Find a tracepoint by parsing a number in the supplied string. */ 159148596154Schristos extern struct tracepoint * 159266e63ce3Schristos get_tracepoint_by_number (char **arg, 1593*1c468f90Schristos number_or_range_parser *parser); 159466e63ce3Schristos 159566e63ce3Schristos /* Return a vector of all tracepoints currently defined. The vector 159666e63ce3Schristos is newly allocated; the caller should free when done with it. */ 159766e63ce3Schristos extern VEC(breakpoint_p) *all_tracepoints (void); 159866e63ce3Schristos 159966e63ce3Schristos extern int is_tracepoint (const struct breakpoint *b); 160066e63ce3Schristos 160166e63ce3Schristos /* Return a vector of all static tracepoints defined at ADDR. The 160266e63ce3Schristos vector is newly allocated; the caller should free when done with 160366e63ce3Schristos it. */ 160466e63ce3Schristos extern VEC(breakpoint_p) *static_tracepoints_here (CORE_ADDR addr); 160566e63ce3Schristos 160666e63ce3Schristos /* Function that can be passed to read_command_line to validate 160766e63ce3Schristos that each command is suitable for tracepoint command list. */ 160866e63ce3Schristos extern void check_tracepoint_command (char *line, void *closure); 160966e63ce3Schristos 161066e63ce3Schristos /* Call at the start and end of an "rbreak" command to register 161166e63ce3Schristos breakpoint numbers for a later "commands" command. */ 161266e63ce3Schristos extern void start_rbreak_breakpoints (void); 161366e63ce3Schristos extern void end_rbreak_breakpoints (void); 161466e63ce3Schristos 161566e63ce3Schristos /* Breakpoint iterator function. 161666e63ce3Schristos 161766e63ce3Schristos Calls a callback function once for each breakpoint, so long as the 161866e63ce3Schristos callback function returns false. If the callback function returns 161966e63ce3Schristos true, the iteration will end and the current breakpoint will be 162066e63ce3Schristos returned. This can be useful for implementing a search for a 162166e63ce3Schristos breakpoint with arbitrary attributes, or for applying an operation 162266e63ce3Schristos to every breakpoint. */ 162366e63ce3Schristos extern struct breakpoint *iterate_over_breakpoints (int (*) (struct breakpoint *, 162466e63ce3Schristos void *), void *); 162566e63ce3Schristos 162648596154Schristos /* Nonzero if the specified PC cannot be a location where functions 162748596154Schristos have been inlined. */ 162848596154Schristos 162948596154Schristos extern int pc_at_non_inline_function (struct address_space *aspace, 163048596154Schristos CORE_ADDR pc, 163148596154Schristos const struct target_waitstatus *ws); 163248596154Schristos 163366e63ce3Schristos extern int user_breakpoint_p (struct breakpoint *); 163466e63ce3Schristos 1635c03b94e9Schristos /* Return true if this breakpoint is pending, false if not. */ 1636c03b94e9Schristos extern int pending_breakpoint_p (struct breakpoint *); 1637c03b94e9Schristos 163848596154Schristos /* Attempt to determine architecture of location identified by SAL. */ 163948596154Schristos extern struct gdbarch *get_sal_arch (struct symtab_and_line sal); 164048596154Schristos 164148596154Schristos extern void breakpoint_free_objfile (struct objfile *objfile); 164248596154Schristos 1643*1c468f90Schristos extern const char *ep_parse_optional_if_clause (const char **arg); 16447af5a897Schristos 1645c03b94e9Schristos /* Print the "Thread ID hit" part of "Thread ID hit Breakpoint N" to 1646c03b94e9Schristos UIOUT iff debugging multiple threads. */ 1647c03b94e9Schristos extern void maybe_print_thread_hit_breakpoint (struct ui_out *uiout); 1648c03b94e9Schristos 164966e63ce3Schristos #endif /* !defined (BREAKPOINT_H) */ 1650