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