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