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