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