1 //===-- SBTarget.h ----------------------------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef LLDB_API_SBTARGET_H 10 #define LLDB_API_SBTARGET_H 11 12 #include "lldb/API/SBAddress.h" 13 #include "lldb/API/SBAttachInfo.h" 14 #include "lldb/API/SBBreakpoint.h" 15 #include "lldb/API/SBBroadcaster.h" 16 #include "lldb/API/SBDefines.h" 17 #include "lldb/API/SBFileSpec.h" 18 #include "lldb/API/SBFileSpecList.h" 19 #include "lldb/API/SBLaunchInfo.h" 20 #include "lldb/API/SBSymbolContextList.h" 21 #include "lldb/API/SBType.h" 22 #include "lldb/API/SBValue.h" 23 #include "lldb/API/SBWatchpoint.h" 24 #include "lldb/API/SBWatchpointOptions.h" 25 26 namespace lldb_private { 27 namespace python { 28 class SWIGBridge; 29 } 30 } // namespace lldb_private 31 32 namespace lldb { 33 34 class SBPlatform; 35 36 class LLDB_API SBTarget { 37 public: 38 // Broadcaster bits. 39 enum { 40 eBroadcastBitBreakpointChanged = (1 << 0), 41 eBroadcastBitModulesLoaded = (1 << 1), 42 eBroadcastBitModulesUnloaded = (1 << 2), 43 eBroadcastBitWatchpointChanged = (1 << 3), 44 eBroadcastBitSymbolsLoaded = (1 << 4) 45 }; 46 47 // Constructors 48 SBTarget(); 49 50 SBTarget(const lldb::SBTarget &rhs); 51 52 // Destructor 53 ~SBTarget(); 54 55 const lldb::SBTarget &operator=(const lldb::SBTarget &rhs); 56 57 explicit operator bool() const; 58 59 bool IsValid() const; 60 61 static bool EventIsTargetEvent(const lldb::SBEvent &event); 62 63 static lldb::SBTarget GetTargetFromEvent(const lldb::SBEvent &event); 64 65 static uint32_t GetNumModulesFromEvent(const lldb::SBEvent &event); 66 67 static lldb::SBModule GetModuleAtIndexFromEvent(const uint32_t idx, 68 const lldb::SBEvent &event); 69 70 static const char *GetBroadcasterClassName(); 71 72 lldb::SBProcess GetProcess(); 73 74 /// Sets whether we should collect statistics on lldb or not. 75 /// 76 /// \param[in] v 77 /// A boolean to control the collection. 78 void SetCollectingStats(bool v); 79 80 /// Returns whether statistics collection are enabled. 81 /// 82 /// \return 83 /// true if statistics are currently being collected, false 84 /// otherwise. 85 bool GetCollectingStats(); 86 87 /// Returns a dump of the collected statistics. 88 /// 89 /// \return 90 /// A SBStructuredData with the statistics collected. 91 lldb::SBStructuredData GetStatistics(); 92 93 /// Return the platform object associated with the target. 94 /// 95 /// After return, the platform object should be checked for 96 /// validity. 97 /// 98 /// \return 99 /// A platform object. 100 lldb::SBPlatform GetPlatform(); 101 102 /// Return the environment variables that would be used to launch a new 103 /// process. 104 /// 105 /// \return 106 /// An lldb::SBEnvironment object which is a copy of the target's 107 /// environment. 108 109 SBEnvironment GetEnvironment(); 110 111 /// Install any binaries that need to be installed. 112 /// 113 /// This function does nothing when debugging on the host system. 114 /// When connected to remote platforms, the target's main executable 115 /// and any modules that have their remote install path set will be 116 /// installed on the remote platform. If the main executable doesn't 117 /// have an install location set, it will be installed in the remote 118 /// platform's working directory. 119 /// 120 /// \return 121 /// An error describing anything that went wrong during 122 /// installation. 123 SBError Install(); 124 125 /// Launch a new process. 126 /// 127 /// Launch a new process by spawning a new process using the 128 /// target object's executable module's file as the file to launch. 129 /// Arguments are given in \a argv, and the environment variables 130 /// are in \a envp. Standard input and output files can be 131 /// optionally re-directed to \a stdin_path, \a stdout_path, and 132 /// \a stderr_path. 133 /// 134 /// \param[in] listener 135 /// An optional listener that will receive all process events. 136 /// If \a listener is valid then \a listener will listen to all 137 /// process events. If not valid, then this target's debugger 138 /// (SBTarget::GetDebugger()) will listen to all process events. 139 /// 140 /// \param[in] argv 141 /// The argument array. 142 /// 143 /// \param[in] envp 144 /// The environment array. If this is null, the default 145 /// environment values (provided through `settings set 146 /// target.env-vars`) will be used. 147 /// 148 /// \param[in] stdin_path 149 /// The path to use when re-directing the STDIN of the new 150 /// process. If all stdXX_path arguments are nullptr, a pseudo 151 /// terminal will be used. 152 /// 153 /// \param[in] stdout_path 154 /// The path to use when re-directing the STDOUT of the new 155 /// process. If all stdXX_path arguments are nullptr, a pseudo 156 /// terminal will be used. 157 /// 158 /// \param[in] stderr_path 159 /// The path to use when re-directing the STDERR of the new 160 /// process. If all stdXX_path arguments are nullptr, a pseudo 161 /// terminal will be used. 162 /// 163 /// \param[in] working_directory 164 /// The working directory to have the child process run in 165 /// 166 /// \param[in] launch_flags 167 /// Some launch options specified by logical OR'ing 168 /// lldb::LaunchFlags enumeration values together. 169 /// 170 /// \param[in] stop_at_entry 171 /// If false do not stop the inferior at the entry point. 172 /// 173 /// \param[out] error 174 /// An error object. Contains the reason if there is some failure. 175 /// 176 /// \return 177 /// A process object for the newly created process. 178 lldb::SBProcess Launch(SBListener &listener, char const **argv, 179 char const **envp, const char *stdin_path, 180 const char *stdout_path, const char *stderr_path, 181 const char *working_directory, 182 uint32_t launch_flags, // See LaunchFlags 183 bool stop_at_entry, lldb::SBError &error); 184 185 SBProcess LoadCore(const char *core_file); 186 SBProcess LoadCore(const char *core_file, lldb::SBError &error); 187 188 /// Launch a new process with sensible defaults. 189 /// 190 /// \param[in] argv 191 /// The argument array. 192 /// 193 /// \param[in] envp 194 /// The environment array. If this isn't provided, the default 195 /// environment values (provided through `settings set 196 /// target.env-vars`) will be used. 197 /// 198 /// \param[in] working_directory 199 /// The working directory to have the child process run in 200 /// 201 /// Default: listener 202 /// Set to the target's debugger (SBTarget::GetDebugger()) 203 /// 204 /// Default: launch_flags 205 /// Empty launch flags 206 /// 207 /// Default: stdin_path 208 /// Default: stdout_path 209 /// Default: stderr_path 210 /// A pseudo terminal will be used. 211 /// 212 /// \return 213 /// A process object for the newly created process. 214 SBProcess LaunchSimple(const char **argv, const char **envp, 215 const char *working_directory); 216 217 SBProcess Launch(SBLaunchInfo &launch_info, SBError &error); 218 219 SBProcess Attach(SBAttachInfo &attach_info, SBError &error); 220 221 /// Attach to process with pid. 222 /// 223 /// \param[in] listener 224 /// An optional listener that will receive all process events. 225 /// If \a listener is valid then \a listener will listen to all 226 /// process events. If not valid, then this target's debugger 227 /// (SBTarget::GetDebugger()) will listen to all process events. 228 /// 229 /// \param[in] pid 230 /// The process ID to attach to. 231 /// 232 /// \param[out] error 233 /// An error explaining what went wrong if attach fails. 234 /// 235 /// \return 236 /// A process object for the attached process. 237 lldb::SBProcess AttachToProcessWithID(SBListener &listener, lldb::pid_t pid, 238 lldb::SBError &error); 239 240 /// Attach to process with name. 241 /// 242 /// \param[in] listener 243 /// An optional listener that will receive all process events. 244 /// If \a listener is valid then \a listener will listen to all 245 /// process events. If not valid, then this target's debugger 246 /// (SBTarget::GetDebugger()) will listen to all process events. 247 /// 248 /// \param[in] name 249 /// Basename of process to attach to. 250 /// 251 /// \param[in] wait_for 252 /// If true wait for a new instance of 'name' to be launched. 253 /// 254 /// \param[out] error 255 /// An error explaining what went wrong if attach fails. 256 /// 257 /// \return 258 /// A process object for the attached process. 259 lldb::SBProcess AttachToProcessWithName(SBListener &listener, 260 const char *name, bool wait_for, 261 lldb::SBError &error); 262 263 /// Connect to a remote debug server with url. 264 /// 265 /// \param[in] listener 266 /// An optional listener that will receive all process events. 267 /// If \a listener is valid then \a listener will listen to all 268 /// process events. If not valid, then this target's debugger 269 /// (SBTarget::GetDebugger()) will listen to all process events. 270 /// 271 /// \param[in] url 272 /// The url to connect to, e.g., 'connect://localhost:12345'. 273 /// 274 /// \param[in] plugin_name 275 /// The plugin name to be used; can be nullptr. 276 /// 277 /// \param[out] error 278 /// An error explaining what went wrong if the connect fails. 279 /// 280 /// \return 281 /// A process object for the connected process. 282 lldb::SBProcess ConnectRemote(SBListener &listener, const char *url, 283 const char *plugin_name, SBError &error); 284 285 lldb::SBFileSpec GetExecutable(); 286 287 // Append the path mapping (from -> to) to the target's paths mapping list. 288 void AppendImageSearchPath(const char *from, const char *to, 289 lldb::SBError &error); 290 291 bool AddModule(lldb::SBModule &module); 292 293 lldb::SBModule AddModule(const char *path, const char *triple, 294 const char *uuid); 295 296 lldb::SBModule AddModule(const char *path, const char *triple, 297 const char *uuid_cstr, const char *symfile); 298 299 lldb::SBModule AddModule(const SBModuleSpec &module_spec); 300 301 uint32_t GetNumModules() const; 302 303 lldb::SBModule GetModuleAtIndex(uint32_t idx); 304 305 bool RemoveModule(lldb::SBModule module); 306 307 lldb::SBDebugger GetDebugger() const; 308 309 lldb::SBModule FindModule(const lldb::SBFileSpec &file_spec); 310 311 /// Find compile units related to *this target and passed source 312 /// file. 313 /// 314 /// \param[in] sb_file_spec 315 /// A lldb::SBFileSpec object that contains source file 316 /// specification. 317 /// 318 /// \return 319 /// A lldb::SBSymbolContextList that gets filled in with all of 320 /// the symbol contexts for all the matches. 321 lldb::SBSymbolContextList 322 FindCompileUnits(const lldb::SBFileSpec &sb_file_spec); 323 324 lldb::ByteOrder GetByteOrder(); 325 326 uint32_t GetAddressByteSize(); 327 328 const char *GetTriple(); 329 330 const char *GetABIName(); 331 332 const char *GetLabel() const; 333 334 SBError SetLabel(const char *label); 335 336 /// Architecture data byte width accessor 337 /// 338 /// \return 339 /// The size in 8-bit (host) bytes of a minimum addressable 340 /// unit from the Architecture's data bus 341 uint32_t GetDataByteSize(); 342 343 /// Architecture code byte width accessor 344 /// 345 /// \return 346 /// The size in 8-bit (host) bytes of a minimum addressable 347 /// unit from the Architecture's code bus 348 uint32_t GetCodeByteSize(); 349 350 /// Gets the target.max-children-count value 351 /// It should be used to limit the number of 352 /// children of large data structures to be displayed. 353 uint32_t GetMaximumNumberOfChildrenToDisplay() const; 354 355 /// Set the base load address for a module section. 356 /// 357 /// \param[in] section 358 /// The section whose base load address will be set within this 359 /// target. 360 /// 361 /// \param[in] section_base_addr 362 /// The base address for the section. 363 /// 364 /// \return 365 /// An error to indicate success, fail, and any reason for 366 /// failure. 367 lldb::SBError SetSectionLoadAddress(lldb::SBSection section, 368 lldb::addr_t section_base_addr); 369 370 /// Clear the base load address for a module section. 371 /// 372 /// \param[in] section 373 /// The section whose base load address will be cleared within 374 /// this target. 375 /// 376 /// \return 377 /// An error to indicate success, fail, and any reason for 378 /// failure. 379 lldb::SBError ClearSectionLoadAddress(lldb::SBSection section); 380 381 #ifndef SWIG 382 /// Slide all file addresses for all module sections so that \a module 383 /// appears to loaded at these slide addresses. 384 /// 385 /// When you need all sections within a module to be loaded at a 386 /// rigid slide from the addresses found in the module object file, 387 /// this function will allow you to easily and quickly slide all 388 /// module sections. 389 /// 390 /// \param[in] module 391 /// The module to load. 392 /// 393 /// \param[in] sections_offset 394 /// An offset that will be applied to all section file addresses 395 /// (the virtual addresses found in the object file itself). 396 /// 397 /// \return 398 /// An error to indicate success, fail, and any reason for 399 /// failure. 400 LLDB_DEPRECATED_FIXME("Use SetModuleLoadAddress(lldb::SBModule, uint64_t)", 401 "SetModuleLoadAddress(lldb::SBModule, uint64_t)") 402 lldb::SBError SetModuleLoadAddress(lldb::SBModule module, 403 int64_t sections_offset); 404 #endif 405 406 /// Slide all file addresses for all module sections so that \a module 407 /// appears to loaded at these slide addresses. 408 /// 409 /// When you need all sections within a module to be loaded at a 410 /// rigid slide from the addresses found in the module object file, 411 /// this function will allow you to easily and quickly slide all 412 /// module sections. 413 /// 414 /// \param[in] module 415 /// The module to load. 416 /// 417 /// \param[in] sections_offset 418 /// An offset that will be applied to all section file addresses 419 /// (the virtual addresses found in the object file itself). 420 /// 421 /// \return 422 /// An error to indicate success, fail, and any reason for 423 /// failure. 424 lldb::SBError SetModuleLoadAddress(lldb::SBModule module, 425 uint64_t sections_offset); 426 427 /// Clear the section base load addresses for all sections in a module. 428 /// 429 /// \param[in] module 430 /// The module to unload. 431 /// 432 /// \return 433 /// An error to indicate success, fail, and any reason for 434 /// failure. 435 lldb::SBError ClearModuleLoadAddress(lldb::SBModule module); 436 437 /// Find functions by name. 438 /// 439 /// \param[in] name 440 /// The name of the function we are looking for. 441 /// 442 /// \param[in] name_type_mask 443 /// A logical OR of one or more FunctionNameType enum bits that 444 /// indicate what kind of names should be used when doing the 445 /// lookup. Bits include fully qualified names, base names, 446 /// C++ methods, or ObjC selectors. 447 /// See FunctionNameType for more details. 448 /// 449 /// \return 450 /// A lldb::SBSymbolContextList that gets filled in with all of 451 /// the symbol contexts for all the matches. 452 lldb::SBSymbolContextList 453 FindFunctions(const char *name, 454 uint32_t name_type_mask = lldb::eFunctionNameTypeAny); 455 456 /// Find global and static variables by name. 457 /// 458 /// \param[in] name 459 /// The name of the global or static variable we are looking 460 /// for. 461 /// 462 /// \param[in] max_matches 463 /// Allow the number of matches to be limited to \a max_matches. 464 /// 465 /// \return 466 /// A list of matched variables in an SBValueList. 467 lldb::SBValueList FindGlobalVariables(const char *name, uint32_t max_matches); 468 469 /// Find the first global (or static) variable by name. 470 /// 471 /// \param[in] name 472 /// The name of the global or static variable we are looking 473 /// for. 474 /// 475 /// \return 476 /// An SBValue that gets filled in with the found variable (if any). 477 lldb::SBValue FindFirstGlobalVariable(const char *name); 478 479 /// Find global and static variables by pattern. 480 /// 481 /// \param[in] name 482 /// The pattern to search for global or static variables 483 /// 484 /// \param[in] max_matches 485 /// Allow the number of matches to be limited to \a max_matches. 486 /// 487 /// \param[in] matchtype 488 /// The match type to use. 489 /// 490 /// \return 491 /// A list of matched variables in an SBValueList. 492 lldb::SBValueList FindGlobalVariables(const char *name, uint32_t max_matches, 493 MatchType matchtype); 494 495 /// Find global functions by their name with pattern matching. 496 /// 497 /// \param[in] name 498 /// The pattern to search for global or static variables 499 /// 500 /// \param[in] max_matches 501 /// Allow the number of matches to be limited to \a max_matches. 502 /// 503 /// \param[in] matchtype 504 /// The match type to use. 505 /// 506 /// \return 507 /// A list of matched variables in an SBValueList. 508 lldb::SBSymbolContextList FindGlobalFunctions(const char *name, 509 uint32_t max_matches, 510 MatchType matchtype); 511 512 void Clear(); 513 514 /// Resolve a current file address into a section offset address. 515 /// 516 /// \param[in] file_addr 517 /// The file address to resolve. 518 /// 519 /// \return 520 /// An SBAddress which will be valid if... 521 lldb::SBAddress ResolveFileAddress(lldb::addr_t file_addr); 522 523 /// Resolve a current load address into a section offset address. 524 /// 525 /// \param[in] vm_addr 526 /// A virtual address from the current process state that is to 527 /// be translated into a section offset address. 528 /// 529 /// \return 530 /// An SBAddress which will be valid if \a vm_addr was 531 /// successfully resolved into a section offset address, or an 532 /// invalid SBAddress if \a vm_addr doesn't resolve to a section 533 /// in a module. 534 lldb::SBAddress ResolveLoadAddress(lldb::addr_t vm_addr); 535 536 /// Resolve a current load address into a section offset address 537 /// using the process stop ID to identify a time in the past. 538 /// 539 /// \param[in] stop_id 540 /// Each time a process stops, the process stop ID integer gets 541 /// incremented. These stop IDs are used to identify past times 542 /// and can be used in history objects as a cheap way to store 543 /// the time at which the sample was taken. Specifying 544 /// UINT32_MAX will always resolve the address using the 545 /// currently loaded sections. 546 /// 547 /// \param[in] vm_addr 548 /// A virtual address from the current process state that is to 549 /// be translated into a section offset address. 550 /// 551 /// \return 552 /// An SBAddress which will be valid if \a vm_addr was 553 /// successfully resolved into a section offset address, or an 554 /// invalid SBAddress if \a vm_addr doesn't resolve to a section 555 /// in a module. 556 lldb::SBAddress ResolvePastLoadAddress(uint32_t stop_id, 557 lldb::addr_t vm_addr); 558 559 SBSymbolContext ResolveSymbolContextForAddress(const SBAddress &addr, 560 uint32_t resolve_scope); 561 562 /// Read target memory. If a target process is running then memory 563 /// is read from here. Otherwise the memory is read from the object 564 /// files. For a target whose bytes are sized as a multiple of host 565 /// bytes, the data read back will preserve the target's byte order. 566 /// 567 /// \param[in] addr 568 /// A target address to read from. 569 /// 570 /// \param[out] buf 571 /// The buffer to read memory into. 572 /// 573 /// \param[in] size 574 /// The maximum number of host bytes to read in the buffer passed 575 /// into this call 576 /// 577 /// \param[out] error 578 /// Status information is written here if the memory read fails. 579 /// 580 /// \return 581 /// The amount of data read in host bytes. 582 size_t ReadMemory(const SBAddress addr, void *buf, size_t size, 583 lldb::SBError &error); 584 585 lldb::SBBreakpoint BreakpointCreateByLocation(const char *file, 586 uint32_t line); 587 588 lldb::SBBreakpoint 589 BreakpointCreateByLocation(const lldb::SBFileSpec &file_spec, uint32_t line); 590 591 lldb::SBBreakpoint 592 BreakpointCreateByLocation(const lldb::SBFileSpec &file_spec, uint32_t line, 593 lldb::addr_t offset); 594 595 lldb::SBBreakpoint 596 BreakpointCreateByLocation(const lldb::SBFileSpec &file_spec, uint32_t line, 597 lldb::addr_t offset, SBFileSpecList &module_list); 598 599 lldb::SBBreakpoint 600 BreakpointCreateByLocation(const lldb::SBFileSpec &file_spec, uint32_t line, 601 uint32_t column, lldb::addr_t offset, 602 SBFileSpecList &module_list); 603 604 lldb::SBBreakpoint 605 BreakpointCreateByLocation(const lldb::SBFileSpec &file_spec, uint32_t line, 606 uint32_t column, lldb::addr_t offset, 607 SBFileSpecList &module_list, 608 bool move_to_nearest_code); 609 610 lldb::SBBreakpoint BreakpointCreateByName(const char *symbol_name, 611 const char *module_name = nullptr); 612 613 // This version uses name_type_mask = eFunctionNameTypeAuto 614 lldb::SBBreakpoint 615 BreakpointCreateByName(const char *symbol_name, 616 const SBFileSpecList &module_list, 617 const SBFileSpecList &comp_unit_list); 618 619 lldb::SBBreakpoint BreakpointCreateByName( 620 const char *symbol_name, 621 uint32_t 622 name_type_mask, // Logical OR one or more FunctionNameType enum bits 623 const SBFileSpecList &module_list, 624 const SBFileSpecList &comp_unit_list); 625 626 lldb::SBBreakpoint BreakpointCreateByName( 627 const char *symbol_name, 628 uint32_t 629 name_type_mask, // Logical OR one or more FunctionNameType enum bits 630 lldb::LanguageType symbol_language, 631 const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list); 632 633 #ifdef SWIG 634 lldb::SBBreakpoint BreakpointCreateByNames( 635 const char **symbol_name, uint32_t num_names, 636 uint32_t 637 name_type_mask, // Logical OR one or more FunctionNameType enum bits 638 const SBFileSpecList &module_list, 639 const SBFileSpecList &comp_unit_list); 640 641 lldb::SBBreakpoint BreakpointCreateByNames( 642 const char **symbol_name, uint32_t num_names, 643 uint32_t 644 name_type_mask, // Logical OR one or more FunctionNameType enum bits 645 lldb::LanguageType symbol_language, 646 const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list); 647 648 lldb::SBBreakpoint BreakpointCreateByNames( 649 const char **symbol_name, uint32_t num_names, 650 uint32_t 651 name_type_mask, // Logical OR one or more FunctionNameType enum bits 652 lldb::LanguageType symbol_language, 653 lldb::addr_t offset, const SBFileSpecList &module_list, 654 const SBFileSpecList &comp_unit_list); 655 #else 656 lldb::SBBreakpoint BreakpointCreateByNames( 657 const char *symbol_name[], uint32_t num_names, 658 uint32_t 659 name_type_mask, // Logical OR one or more FunctionNameType enum bits 660 const SBFileSpecList &module_list, 661 const SBFileSpecList &comp_unit_list); 662 663 lldb::SBBreakpoint BreakpointCreateByNames( 664 const char *symbol_name[], uint32_t num_names, 665 uint32_t 666 name_type_mask, // Logical OR one or more FunctionNameType enum bits 667 lldb::LanguageType symbol_language, 668 const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list); 669 670 lldb::SBBreakpoint BreakpointCreateByNames( 671 const char *symbol_name[], uint32_t num_names, 672 uint32_t 673 name_type_mask, // Logical OR one or more FunctionNameType enum bits 674 lldb::LanguageType symbol_language, 675 lldb::addr_t offset, const SBFileSpecList &module_list, 676 const SBFileSpecList &comp_unit_list); 677 #endif 678 679 lldb::SBBreakpoint BreakpointCreateByRegex(const char *symbol_name_regex, 680 const char *module_name = nullptr); 681 682 lldb::SBBreakpoint 683 BreakpointCreateByRegex(const char *symbol_name_regex, 684 const SBFileSpecList &module_list, 685 const SBFileSpecList &comp_unit_list); 686 687 lldb::SBBreakpoint BreakpointCreateByRegex( 688 const char *symbol_name_regex, lldb::LanguageType symbol_language, 689 const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list); 690 691 lldb::SBBreakpoint 692 BreakpointCreateBySourceRegex(const char *source_regex, 693 const SBFileSpec &source_file, 694 const char *module_name = nullptr); 695 696 lldb::SBBreakpoint 697 BreakpointCreateBySourceRegex(const char *source_regex, 698 const SBFileSpecList &module_list, 699 const SBFileSpecList &source_file); 700 701 lldb::SBBreakpoint BreakpointCreateBySourceRegex( 702 const char *source_regex, const SBFileSpecList &module_list, 703 const SBFileSpecList &source_file, const SBStringList &func_names); 704 705 lldb::SBBreakpoint BreakpointCreateForException(lldb::LanguageType language, 706 bool catch_bp, bool throw_bp); 707 708 lldb::SBBreakpoint BreakpointCreateByAddress(addr_t address); 709 710 lldb::SBBreakpoint BreakpointCreateBySBAddress(SBAddress &address); 711 712 /// Create a breakpoint using a scripted resolver. 713 /// 714 /// \param[in] class_name 715 /// This is the name of the class that implements a scripted resolver. 716 /// 717 /// \param[in] extra_args 718 /// This is an SBStructuredData object that will get passed to the 719 /// constructor of the class in class_name. You can use this to 720 /// reuse the same class, parametrizing with entries from this 721 /// dictionary. 722 /// 723 /// \param module_list 724 /// If this is non-empty, this will be used as the module filter in the 725 /// SearchFilter created for this breakpoint. 726 /// 727 /// \param file_list 728 /// If this is non-empty, this will be used as the comp unit filter in the 729 /// SearchFilter created for this breakpoint. 730 /// 731 /// \return 732 /// An SBBreakpoint that will set locations based on the logic in the 733 /// resolver's search callback. 734 lldb::SBBreakpoint BreakpointCreateFromScript( 735 const char *class_name, 736 SBStructuredData &extra_args, 737 const SBFileSpecList &module_list, 738 const SBFileSpecList &file_list, 739 bool request_hardware = false); 740 741 /// Read breakpoints from source_file and return the newly created 742 /// breakpoints in bkpt_list. 743 /// 744 /// \param[in] source_file 745 /// The file from which to read the breakpoints. 746 /// 747 /// \param[out] new_bps 748 /// A list of the newly created breakpoints. 749 /// 750 /// \return 751 /// An SBError detailing any errors in reading in the breakpoints. 752 lldb::SBError BreakpointsCreateFromFile(SBFileSpec &source_file, 753 SBBreakpointList &new_bps); 754 755 /// Read breakpoints from source_file and return the newly created 756 /// breakpoints in bkpt_list. 757 /// 758 /// \param[in] source_file 759 /// The file from which to read the breakpoints. 760 /// 761 /// \param[in] matching_names 762 /// Only read in breakpoints whose names match one of the names in this 763 /// list. 764 /// 765 /// \param[out] new_bps 766 /// A list of the newly created breakpoints. 767 /// 768 /// \return 769 /// An SBError detailing any errors in reading in the breakpoints. 770 lldb::SBError BreakpointsCreateFromFile(SBFileSpec &source_file, 771 SBStringList &matching_names, 772 SBBreakpointList &new_bps); 773 774 /// Write breakpoints to dest_file. 775 /// 776 /// \param[in] dest_file 777 /// The file to which to write the breakpoints. 778 /// 779 /// \return 780 /// An SBError detailing any errors in writing in the breakpoints. 781 lldb::SBError BreakpointsWriteToFile(SBFileSpec &dest_file); 782 783 /// Write breakpoints listed in bkpt_list to dest_file. 784 /// 785 /// \param[in] dest_file 786 /// The file to which to write the breakpoints. 787 /// 788 /// \param[in] bkpt_list 789 /// Only write breakpoints from this list. 790 /// 791 /// \param[in] append 792 /// If \b true, append the breakpoints in bkpt_list to the others 793 /// serialized in dest_file. If dest_file doesn't exist, then a new 794 /// file will be created and the breakpoints in bkpt_list written to it. 795 /// 796 /// \return 797 /// An SBError detailing any errors in writing in the breakpoints. 798 lldb::SBError BreakpointsWriteToFile(SBFileSpec &dest_file, 799 SBBreakpointList &bkpt_list, 800 bool append = false); 801 802 uint32_t GetNumBreakpoints() const; 803 804 lldb::SBBreakpoint GetBreakpointAtIndex(uint32_t idx) const; 805 806 bool BreakpointDelete(break_id_t break_id); 807 808 lldb::SBBreakpoint FindBreakpointByID(break_id_t break_id); 809 810 // Finds all breakpoints by name, returning the list in bkpt_list. Returns 811 // false if the name is not a valid breakpoint name, true otherwise. 812 bool FindBreakpointsByName(const char *name, SBBreakpointList &bkpt_list); 813 814 void GetBreakpointNames(SBStringList &names); 815 816 void DeleteBreakpointName(const char *name); 817 818 bool EnableAllBreakpoints(); 819 820 bool DisableAllBreakpoints(); 821 822 bool DeleteAllBreakpoints(); 823 824 uint32_t GetNumWatchpoints() const; 825 826 lldb::SBWatchpoint GetWatchpointAtIndex(uint32_t idx) const; 827 828 bool DeleteWatchpoint(lldb::watch_id_t watch_id); 829 830 lldb::SBWatchpoint FindWatchpointByID(lldb::watch_id_t watch_id); 831 832 LLDB_DEPRECATED("WatchAddress deprecated, use WatchpointCreateByAddress") 833 lldb::SBWatchpoint WatchAddress(lldb::addr_t addr, size_t size, bool read, 834 bool modify, SBError &error); 835 836 lldb::SBWatchpoint 837 WatchpointCreateByAddress(lldb::addr_t addr, size_t size, 838 lldb::SBWatchpointOptions options, SBError &error); 839 840 bool EnableAllWatchpoints(); 841 842 bool DisableAllWatchpoints(); 843 844 bool DeleteAllWatchpoints(); 845 846 lldb::SBBroadcaster GetBroadcaster() const; 847 848 lldb::SBType FindFirstType(const char *type); 849 850 lldb::SBTypeList FindTypes(const char *type); 851 852 lldb::SBType GetBasicType(lldb::BasicType type); 853 854 lldb::SBValue CreateValueFromAddress(const char *name, lldb::SBAddress addr, 855 lldb::SBType type); 856 857 lldb::SBValue CreateValueFromData(const char *name, lldb::SBData data, 858 lldb::SBType type); 859 860 lldb::SBValue CreateValueFromExpression(const char *name, const char *expr); 861 862 SBSourceManager GetSourceManager(); 863 864 lldb::SBInstructionList ReadInstructions(lldb::SBAddress base_addr, 865 uint32_t count); 866 867 lldb::SBInstructionList ReadInstructions(lldb::SBAddress base_addr, 868 uint32_t count, 869 const char *flavor_string); 870 871 lldb::SBInstructionList GetInstructions(lldb::SBAddress base_addr, 872 const void *buf, size_t size); 873 874 // The "WithFlavor" is necessary to keep SWIG from getting confused about 875 // overloaded arguments when using the buf + size -> Python Object magic. 876 877 lldb::SBInstructionList GetInstructionsWithFlavor(lldb::SBAddress base_addr, 878 const char *flavor_string, 879 const void *buf, 880 size_t size); 881 882 #ifndef SWIG 883 lldb::SBInstructionList GetInstructions(lldb::addr_t base_addr, 884 const void *buf, size_t size); 885 lldb::SBInstructionList GetInstructionsWithFlavor(lldb::addr_t base_addr, 886 const char *flavor_string, 887 const void *buf, 888 size_t size); 889 #endif 890 891 lldb::SBSymbolContextList FindSymbols(const char *name, 892 lldb::SymbolType type = eSymbolTypeAny); 893 894 bool operator==(const lldb::SBTarget &rhs) const; 895 896 bool operator!=(const lldb::SBTarget &rhs) const; 897 898 bool GetDescription(lldb::SBStream &description, 899 lldb::DescriptionLevel description_level); 900 901 lldb::SBValue EvaluateExpression(const char *expr); 902 903 lldb::SBValue EvaluateExpression(const char *expr, 904 const SBExpressionOptions &options); 905 906 lldb::addr_t GetStackRedZoneSize(); 907 908 bool IsLoaded(const lldb::SBModule &module) const; 909 910 lldb::SBLaunchInfo GetLaunchInfo() const; 911 912 void SetLaunchInfo(const lldb::SBLaunchInfo &launch_info); 913 914 /// Get a \a SBTrace object the can manage the processor trace information of 915 /// this target. 916 /// 917 /// \return 918 /// The trace object. The returned SBTrace object might not be valid, so it 919 /// should be checked with a call to "bool SBTrace::IsValid()". 920 lldb::SBTrace GetTrace(); 921 922 /// Create a \a Trace object for the current target using the using the 923 /// default supported tracing technology for this process. 924 /// 925 /// \param[out] error 926 /// An error if a Trace already exists or the trace couldn't be created. 927 lldb::SBTrace CreateTrace(SBError &error); 928 929 protected: 930 friend class SBAddress; 931 friend class SBBlock; 932 friend class SBBreakpoint; 933 friend class SBBreakpointList; 934 friend class SBBreakpointNameImpl; 935 friend class SBDebugger; 936 friend class SBExecutionContext; 937 friend class SBFrame; 938 friend class SBFunction; 939 friend class SBInstruction; 940 friend class SBModule; 941 friend class SBPlatform; 942 friend class SBProcess; 943 friend class SBSection; 944 friend class SBSourceManager; 945 friend class SBSymbol; 946 friend class SBValue; 947 friend class SBVariablesOptions; 948 949 friend class lldb_private::python::SWIGBridge; 950 951 // Constructors are private, use static Target::Create function to create an 952 // instance of this class. 953 954 SBTarget(const lldb::TargetSP &target_sp); 955 956 lldb::TargetSP GetSP() const; 957 958 void SetSP(const lldb::TargetSP &target_sp); 959 960 private: 961 lldb::TargetSP m_opaque_sp; 962 }; 963 964 } // namespace lldb 965 966 #endif // LLDB_API_SBTARGET_H 967