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