1 //===-- SWIG Interface for SBTarget -----------------------------*- 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 namespace lldb { 10 11 %feature("docstring", 12 "Represents the target program running under the debugger. 13 14 SBTarget supports module, breakpoint, and watchpoint iterations. For example, :: 15 16 for m in target.module_iter(): 17 print m 18 19 produces: :: 20 21 (x86_64) /Volumes/data/lldb/svn/trunk/test/python_api/lldbutil/iter/a.out 22 (x86_64) /usr/lib/dyld 23 (x86_64) /usr/lib/libstdc++.6.dylib 24 (x86_64) /usr/lib/libSystem.B.dylib 25 (x86_64) /usr/lib/system/libmathCommon.A.dylib 26 (x86_64) /usr/lib/libSystem.B.dylib(__commpage) 27 28 and, :: 29 30 for b in target.breakpoint_iter(): 31 print b 32 33 produces: :: 34 35 SBBreakpoint: id = 1, file ='main.cpp', line = 66, locations = 1 36 SBBreakpoint: id = 2, file ='main.cpp', line = 85, locations = 1 37 38 and, :: 39 40 for wp_loc in target.watchpoint_iter(): 41 print wp_loc 42 43 produces: :: 44 45 Watchpoint 1: addr = 0x1034ca048 size = 4 state = enabled type = rw 46 declare @ '/Volumes/data/lldb/svn/trunk/test/python_api/watchpoint/main.c:12' 47 hw_index = 0 hit_count = 2 ignore_count = 0" 48 ) SBTarget; 49 class SBTarget 50 { 51 public: 52 //------------------------------------------------------------------ 53 // Broadcaster bits. 54 //------------------------------------------------------------------ 55 enum 56 { 57 eBroadcastBitBreakpointChanged = (1 << 0), 58 eBroadcastBitModulesLoaded = (1 << 1), 59 eBroadcastBitModulesUnloaded = (1 << 2), 60 eBroadcastBitWatchpointChanged = (1 << 3), 61 eBroadcastBitSymbolsLoaded = (1 << 4) 62 }; 63 64 //------------------------------------------------------------------ 65 // Constructors 66 //------------------------------------------------------------------ 67 SBTarget (); 68 69 SBTarget (const lldb::SBTarget& rhs); 70 71 //------------------------------------------------------------------ 72 // Destructor 73 //------------------------------------------------------------------ 74 ~SBTarget(); 75 76 static const char * 77 GetBroadcasterClassName (); 78 79 bool 80 IsValid() const; 81 82 explicit operator bool() const; 83 84 static bool 85 EventIsTargetEvent (const lldb::SBEvent &event); 86 87 static lldb::SBTarget 88 GetTargetFromEvent (const lldb::SBEvent &event); 89 90 static uint32_t 91 GetNumModulesFromEvent (const lldb::SBEvent &event); 92 93 static lldb::SBModule 94 GetModuleAtIndexFromEvent (const uint32_t idx, const lldb::SBEvent &event); 95 96 lldb::SBProcess 97 GetProcess (); 98 99 100 %feature("docstring", " 101 Return the platform object associated with the target. 102 103 After return, the platform object should be checked for 104 validity. 105 106 @return 107 A platform object.") GetPlatform; 108 lldb::SBPlatform 109 GetPlatform (); 110 111 %feature("docstring", " 112 Install any binaries that need to be installed. 113 114 This function does nothing when debugging on the host system. 115 When connected to remote platforms, the target's main executable 116 and any modules that have their install path set will be 117 installed on the remote platform. If the main executable doesn't 118 have an install location set, it will be installed in the remote 119 platform's working directory. 120 121 @return 122 An error describing anything that went wrong during 123 installation.") Install; 124 lldb::SBError 125 Install(); 126 127 %feature("docstring", " 128 Launch a new process. 129 130 Launch a new process by spawning a new process using the 131 target object's executable module's file as the file to launch. 132 Arguments are given in argv, and the environment variables 133 are in envp. Standard input and output files can be 134 optionally re-directed to stdin_path, stdout_path, and 135 stderr_path. 136 137 @param[in] listener 138 An optional listener that will receive all process events. 139 If listener is valid then listener will listen to all 140 process events. If not valid, then this target's debugger 141 (SBTarget::GetDebugger()) will listen to all process events. 142 143 @param[in] argv 144 The argument array. 145 146 @param[in] envp 147 The environment array. 148 149 @param[in] launch_flags 150 Flags to modify the launch (@see lldb::LaunchFlags) 151 152 @param[in] stdin_path 153 The path to use when re-directing the STDIN of the new 154 process. If all stdXX_path arguments are NULL, a pseudo 155 terminal will be used. 156 157 @param[in] stdout_path 158 The path to use when re-directing the STDOUT of the new 159 process. If all stdXX_path arguments are NULL, a pseudo 160 terminal will be used. 161 162 @param[in] stderr_path 163 The path to use when re-directing the STDERR of the new 164 process. If all stdXX_path arguments are NULL, a pseudo 165 terminal will be used. 166 167 @param[in] working_directory 168 The working directory to have the child process run in 169 170 @param[in] launch_flags 171 Some launch options specified by logical OR'ing 172 lldb::LaunchFlags enumeration values together. 173 174 @param[in] stop_at_entry 175 If false do not stop the inferior at the entry point. 176 177 @param[out] 178 An error object. Contains the reason if there is some failure. 179 180 @return 181 A process object for the newly created process. 182 183 For example, 184 185 process = target.Launch(self.dbg.GetListener(), None, None, 186 None, '/tmp/stdout.txt', None, 187 None, 0, False, error) 188 189 launches a new process by passing nothing for both the args and the envs 190 and redirect the standard output of the inferior to the /tmp/stdout.txt 191 file. It does not specify a working directory so that the debug server 192 will use its idea of what the current working directory is for the 193 inferior. Also, we ask the debugger not to stop the inferior at the 194 entry point. If no breakpoint is specified for the inferior, it should 195 run to completion if no user interaction is required.") Launch; 196 lldb::SBProcess 197 Launch (SBListener &listener, 198 char const **argv, 199 char const **envp, 200 const char *stdin_path, 201 const char *stdout_path, 202 const char *stderr_path, 203 const char *working_directory, 204 uint32_t launch_flags, // See LaunchFlags 205 bool stop_at_entry, 206 lldb::SBError& error); 207 208 %feature("docstring", " 209 Launch a new process with sensible defaults. 210 211 :param argv: The argument array. 212 :param envp: The environment array. 213 :param working_directory: The working directory to have the child process run in 214 :return: The newly created process. 215 :rtype: SBProcess 216 217 A pseudo terminal will be used as stdin/stdout/stderr. 218 No launch flags are passed and the target's debuger is used as a listener. 219 220 For example, :: 221 222 process = target.LaunchSimple(['X', 'Y', 'Z'], None, os.getcwd()) 223 224 launches a new process by passing 'X', 'Y', 'Z' as the args to the 225 executable.") LaunchSimple; 226 lldb::SBProcess 227 LaunchSimple (const char **argv, 228 const char **envp, 229 const char *working_directory); 230 231 lldb::SBProcess 232 Launch (lldb::SBLaunchInfo &launch_info, lldb::SBError& error); 233 234 %feature("docstring", " 235 Load a core file 236 237 @param[in] core_file 238 File path of the core dump. 239 240 @param[out] error 241 An error explaining what went wrong if the operation fails. 242 (Optional) 243 244 @return 245 A process object for the newly created core file. 246 247 For example, 248 249 process = target.LoadCore('./a.out.core') 250 251 loads a new core file and returns the process object.") LoadCore; 252 lldb::SBProcess 253 LoadCore(const char *core_file); 254 255 lldb::SBProcess 256 LoadCore(const char *core_file, lldb::SBError &error); 257 258 lldb::SBProcess 259 Attach(lldb::SBAttachInfo &attach_info, lldb::SBError& error); 260 261 %feature("docstring", " 262 Attach to process with pid. 263 264 @param[in] listener 265 An optional listener that will receive all process events. 266 If listener is valid then listener will listen to all 267 process events. If not valid, then this target's debugger 268 (SBTarget::GetDebugger()) will listen to all process events. 269 270 @param[in] pid 271 The process ID to attach to. 272 273 @param[out] 274 An error explaining what went wrong if attach fails. 275 276 @return 277 A process object for the attached process.") AttachToProcessWithID; 278 lldb::SBProcess 279 AttachToProcessWithID (SBListener &listener, 280 lldb::pid_t pid, 281 lldb::SBError& error); 282 283 %feature("docstring", " 284 Attach to process with name. 285 286 @param[in] listener 287 An optional listener that will receive all process events. 288 If listener is valid then listener will listen to all 289 process events. If not valid, then this target's debugger 290 (SBTarget::GetDebugger()) will listen to all process events. 291 292 @param[in] name 293 Basename of process to attach to. 294 295 @param[in] wait_for 296 If true wait for a new instance of 'name' to be launched. 297 298 @param[out] 299 An error explaining what went wrong if attach fails. 300 301 @return 302 A process object for the attached process.") AttachToProcessWithName; 303 lldb::SBProcess 304 AttachToProcessWithName (SBListener &listener, 305 const char *name, 306 bool wait_for, 307 lldb::SBError& error); 308 309 %feature("docstring", " 310 Connect to a remote debug server with url. 311 312 @param[in] listener 313 An optional listener that will receive all process events. 314 If listener is valid then listener will listen to all 315 process events. If not valid, then this target's debugger 316 (SBTarget::GetDebugger()) will listen to all process events. 317 318 @param[in] url 319 The url to connect to, e.g., 'connect://localhost:12345'. 320 321 @param[in] plugin_name 322 The plugin name to be used; can be NULL. 323 324 @param[out] 325 An error explaining what went wrong if the connect fails. 326 327 @return 328 A process object for the connected process.") ConnectRemote; 329 lldb::SBProcess 330 ConnectRemote (SBListener &listener, 331 const char *url, 332 const char *plugin_name, 333 SBError& error); 334 335 lldb::SBFileSpec 336 GetExecutable (); 337 338 %feature("docstring", " 339 Append the path mapping (from -> to) to the target's paths mapping list.") AppendImageSearchPath; 340 void 341 AppendImageSearchPath (const char *from, 342 const char *to, 343 SBError &error); 344 345 bool 346 AddModule (lldb::SBModule &module); 347 348 lldb::SBModule 349 AddModule (const char *path, 350 const char *triple, 351 const char *uuid); 352 353 lldb::SBModule 354 AddModule (const char *path, 355 const char *triple, 356 const char *uuid_cstr, 357 const char *symfile); 358 359 lldb::SBModule 360 AddModule (const SBModuleSpec &module_spec); 361 362 uint32_t 363 GetNumModules () const; 364 365 lldb::SBModule 366 GetModuleAtIndex (uint32_t idx); 367 368 bool 369 RemoveModule (lldb::SBModule module); 370 371 lldb::SBDebugger 372 GetDebugger() const; 373 374 lldb::SBModule 375 FindModule (const lldb::SBFileSpec &file_spec); 376 377 %feature("docstring", " 378 Find compile units related to this target and passed source 379 file. 380 381 :param sb_file_spec: A :py:class:`lldb::SBFileSpec` object that contains source file 382 specification. 383 :return: The symbol contexts for all the matches. 384 :rtype: SBSymbolContextList") FindCompileUnits; 385 lldb::SBSymbolContextList 386 FindCompileUnits (const lldb::SBFileSpec &sb_file_spec); 387 388 lldb::ByteOrder 389 GetByteOrder (); 390 391 uint32_t 392 GetAddressByteSize(); 393 394 const char * 395 GetTriple (); 396 397 %feature("docstring", " 398 Architecture data byte width accessor 399 400 :return: The size in 8-bit (host) bytes of a minimum addressable unit from the Architecture's data bus. 401 402 ") GetDataByteSize; 403 uint32_t 404 GetDataByteSize (); 405 406 %feature("docstring", " 407 Architecture code byte width accessor. 408 409 :return: The size in 8-bit (host) bytes of a minimum addressable unit from the Architecture's code bus. 410 411 ") GetCodeByteSize; 412 uint32_t 413 GetCodeByteSize (); 414 415 uint32_t 416 GetMaximumNumberOfChildrenToDisplay() const; 417 418 lldb::SBError 419 SetSectionLoadAddress (lldb::SBSection section, 420 lldb::addr_t section_base_addr); 421 422 lldb::SBError 423 ClearSectionLoadAddress (lldb::SBSection section); 424 425 lldb::SBError 426 SetModuleLoadAddress (lldb::SBModule module, 427 int64_t sections_offset); 428 429 lldb::SBError 430 ClearModuleLoadAddress (lldb::SBModule module); 431 432 %feature("docstring", " 433 Find functions by name. 434 435 :param name: The name of the function we are looking for. 436 437 :param name_type_mask: 438 A logical OR of one or more FunctionNameType enum bits that 439 indicate what kind of names should be used when doing the 440 lookup. Bits include fully qualified names, base names, 441 C++ methods, or ObjC selectors. 442 See FunctionNameType for more details. 443 444 :return: 445 A lldb::SBSymbolContextList that gets filled in with all of 446 the symbol contexts for all the matches.") FindFunctions; 447 lldb::SBSymbolContextList 448 FindFunctions (const char *name, 449 uint32_t name_type_mask = lldb::eFunctionNameTypeAny); 450 451 lldb::SBType 452 FindFirstType (const char* type); 453 454 lldb::SBTypeList 455 FindTypes (const char* type); 456 457 lldb::SBType 458 GetBasicType(lldb::BasicType type); 459 460 lldb::SBSourceManager 461 GetSourceManager (); 462 463 %feature("docstring", " 464 Find global and static variables by name. 465 466 @param[in] name 467 The name of the global or static variable we are looking 468 for. 469 470 @param[in] max_matches 471 Allow the number of matches to be limited to max_matches. 472 473 @return 474 A list of matched variables in an SBValueList.") FindGlobalVariables; 475 lldb::SBValueList 476 FindGlobalVariables (const char *name, 477 uint32_t max_matches); 478 479 %feature("docstring", " 480 Find the first global (or static) variable by name. 481 482 @param[in] name 483 The name of the global or static variable we are looking 484 for. 485 486 @return 487 An SBValue that gets filled in with the found variable (if any).") FindFirstGlobalVariable; 488 lldb::SBValue 489 FindFirstGlobalVariable (const char* name); 490 491 492 lldb::SBValueList 493 FindGlobalVariables(const char *name, 494 uint32_t max_matches, 495 MatchType matchtype); 496 497 lldb::SBSymbolContextList 498 FindGlobalFunctions(const char *name, 499 uint32_t max_matches, 500 MatchType matchtype); 501 502 void 503 Clear (); 504 505 %feature("docstring", " 506 Resolve a current file address into a section offset address. 507 508 @param[in] file_addr 509 510 @return 511 An SBAddress which will be valid if...") ResolveFileAddress; 512 lldb::SBAddress 513 ResolveFileAddress (lldb::addr_t file_addr); 514 515 lldb::SBAddress 516 ResolveLoadAddress (lldb::addr_t vm_addr); 517 518 lldb::SBAddress 519 ResolvePastLoadAddress (uint32_t stop_id, lldb::addr_t vm_addr); 520 521 SBSymbolContext 522 ResolveSymbolContextForAddress (const SBAddress& addr, 523 uint32_t resolve_scope); 524 525 %feature("docstring", " 526 Read target memory. If a target process is running then memory 527 is read from here. Otherwise the memory is read from the object 528 files. For a target whose bytes are sized as a multiple of host 529 bytes, the data read back will preserve the target's byte order. 530 531 @param[in] addr 532 A target address to read from. 533 534 @param[out] buf 535 The buffer to read memory into. 536 537 @param[in] size 538 The maximum number of host bytes to read in the buffer passed 539 into this call 540 541 @param[out] error 542 Error information is written here if the memory read fails. 543 544 @return 545 The amount of data read in host bytes.") ReadMemory; 546 size_t 547 ReadMemory (const SBAddress addr, void *buf, size_t size, lldb::SBError &error); 548 549 lldb::SBBreakpoint 550 BreakpointCreateByLocation (const char *file, uint32_t line); 551 552 lldb::SBBreakpoint 553 BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line); 554 555 lldb::SBBreakpoint 556 BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line, lldb::addr_t offset); 557 558 lldb::SBBreakpoint 559 BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line, 560 lldb::addr_t offset, SBFileSpecList &module_list); 561 562 lldb::SBBreakpoint 563 BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line, 564 uint32_t column, lldb::addr_t offset, 565 SBFileSpecList &module_list); 566 567 lldb::SBBreakpoint 568 BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line, 569 uint32_t column, lldb::addr_t offset, 570 SBFileSpecList &module_list, 571 bool move_to_nearest_code); 572 573 lldb::SBBreakpoint 574 BreakpointCreateByName (const char *symbol_name, const char *module_name = NULL); 575 576 lldb::SBBreakpoint 577 BreakpointCreateByName (const char *symbol_name, 578 uint32_t func_name_type, // Logical OR one or more FunctionNameType enum bits 579 const SBFileSpecList &module_list, 580 const SBFileSpecList &comp_unit_list); 581 582 lldb::SBBreakpoint 583 BreakpointCreateByName (const char *symbol_name, 584 uint32_t func_name_type, // Logical OR one or more FunctionNameType enum bits 585 lldb::LanguageType symbol_language, 586 const SBFileSpecList &module_list, 587 const SBFileSpecList &comp_unit_list); 588 589 #ifdef SWIGPYTHON 590 %typemap(in) (const char **symbol_name, uint32_t num_names) { 591 using namespace lldb_private; 592 /* Check if is a list */ 593 if (PythonList::Check($input)) { 594 PythonList list(PyRefType::Borrowed, $input); 595 $2 = list.GetSize(); 596 int i = 0; 597 $1 = (char**)malloc(($2+1)*sizeof(char*)); 598 for (i = 0; i < $2; i++) { 599 PythonString py_str = list.GetItemAtIndex(i).AsType<PythonString>(); 600 if (!py_str.IsAllocated()) { 601 PyErr_SetString(PyExc_TypeError,"list must contain strings and blubby"); 602 free($1); 603 return nullptr; 604 } 605 606 $1[i] = const_cast<char*>(py_str.GetString().data()); 607 } 608 $1[i] = 0; 609 } else if ($input == Py_None) { 610 $1 = NULL; 611 } else { 612 PyErr_SetString(PyExc_TypeError,"not a list"); 613 return NULL; 614 } 615 } 616 #endif 617 618 lldb::SBBreakpoint 619 BreakpointCreateByNames (const char **symbol_name, 620 uint32_t num_names, 621 uint32_t 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 626 BreakpointCreateByNames (const char **symbol_name, 627 uint32_t num_names, 628 uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits 629 lldb::LanguageType symbol_language, 630 const SBFileSpecList &module_list, 631 const SBFileSpecList &comp_unit_list); 632 633 lldb::SBBreakpoint 634 BreakpointCreateByNames (const char **symbol_name, 635 uint32_t num_names, 636 uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits 637 lldb::LanguageType symbol_language, 638 lldb::addr_t offset, 639 const SBFileSpecList &module_list, 640 const SBFileSpecList &comp_unit_list); 641 642 lldb::SBBreakpoint 643 BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name = NULL); 644 645 lldb::SBBreakpoint 646 BreakpointCreateByRegex (const char *symbol_name_regex, 647 lldb::LanguageType symbol_language, 648 const SBFileSpecList &module_list, 649 const SBFileSpecList &comp_unit_list); 650 651 lldb::SBBreakpoint 652 BreakpointCreateBySourceRegex (const char *source_regex, const lldb::SBFileSpec &source_file, const char *module_name = NULL); 653 654 lldb::SBBreakpoint 655 BreakpointCreateBySourceRegex (const char *source_regex, const lldb::SBFileSpecList &module_list, const lldb::SBFileSpecList &file_list); 656 657 lldb::SBBreakpoint 658 BreakpointCreateBySourceRegex (const char *source_regex, 659 const SBFileSpecList &module_list, 660 const SBFileSpecList &source_file, 661 const SBStringList &func_names); 662 663 lldb::SBBreakpoint 664 BreakpointCreateForException (lldb::LanguageType language, 665 bool catch_bp, 666 bool throw_bp); 667 668 lldb::SBBreakpoint 669 BreakpointCreateByAddress (addr_t address); 670 671 lldb::SBEnvironment 672 GetEnvironment(); 673 674 lldb::SBBreakpoint 675 BreakpointCreateBySBAddress (SBAddress &sb_address); 676 677 %feature("docstring", " 678 Create a breakpoint using a scripted resolver. 679 680 @param[in] class_name 681 This is the name of the class that implements a scripted resolver. 682 The class should have the following signature: :: 683 684 class Resolver: 685 def __init__(self, bkpt, extra_args): 686 # bkpt - the breakpoint for which this is the resolver. When 687 # the resolver finds an interesting address, call AddLocation 688 # on this breakpoint to add it. 689 # 690 # extra_args - an SBStructuredData that can be used to 691 # parametrize this instance. Same as the extra_args passed 692 # to BreakpointCreateFromScript. 693 694 def __get_depth__ (self): 695 # This is optional, but if defined, you should return the 696 # depth at which you want the callback to be called. The 697 # available options are: 698 # lldb.eSearchDepthModule 699 # lldb.eSearchDepthCompUnit 700 # The default if you don't implement this method is 701 # eSearchDepthModule. 702 703 def __callback__(self, sym_ctx): 704 # sym_ctx - an SBSymbolContext that is the cursor in the 705 # search through the program to resolve breakpoints. 706 # The sym_ctx will be filled out to the depth requested in 707 # __get_depth__. 708 # Look in this sym_ctx for new breakpoint locations, 709 # and if found use bkpt.AddLocation to add them. 710 # Note, you will only get called for modules/compile_units that 711 # pass the SearchFilter provided by the module_list & file_list 712 # passed into BreakpointCreateFromScript. 713 714 def get_short_help(self): 715 # Optional, but if implemented return a short string that will 716 # be printed at the beginning of the break list output for the 717 # breakpoint. 718 719 @param[in] extra_args 720 This is an SBStructuredData object that will get passed to the 721 constructor of the class in class_name. You can use this to 722 reuse the same class, parametrizing it with entries from this 723 dictionary. 724 725 @param module_list 726 If this is non-empty, this will be used as the module filter in the 727 SearchFilter created for this breakpoint. 728 729 @param file_list 730 If this is non-empty, this will be used as the comp unit filter in the 731 SearchFilter created for this breakpoint. 732 733 @return 734 An SBBreakpoint that will set locations based on the logic in the 735 resolver's search callback.") BreakpointCreateFromScript; 736 lldb::SBBreakpoint BreakpointCreateFromScript( 737 const char *class_name, 738 SBStructuredData &extra_args, 739 const SBFileSpecList &module_list, 740 const SBFileSpecList &file_list, 741 bool request_hardware = false); 742 743 uint32_t 744 GetNumBreakpoints () const; 745 746 lldb::SBBreakpoint 747 GetBreakpointAtIndex (uint32_t idx) const; 748 749 bool 750 BreakpointDelete (break_id_t break_id); 751 752 lldb::SBBreakpoint 753 FindBreakpointByID (break_id_t break_id); 754 755 756 bool FindBreakpointsByName(const char *name, SBBreakpointList &bkpt_list); 757 758 void DeleteBreakpointName(const char *name); 759 760 void GetBreakpointNames(SBStringList &names); 761 762 bool 763 EnableAllBreakpoints (); 764 765 bool 766 DisableAllBreakpoints (); 767 768 bool 769 DeleteAllBreakpoints (); 770 771 %feature("docstring", " 772 Read breakpoints from source_file and return the newly created 773 breakpoints in bkpt_list. 774 775 @param[in] source_file 776 The file from which to read the breakpoints 777 778 @param[out] bkpt_list 779 A list of the newly created breakpoints. 780 781 @return 782 An SBError detailing any errors in reading in the breakpoints.") BreakpointsCreateFromFile; 783 lldb::SBError 784 BreakpointsCreateFromFile(SBFileSpec &source_file, 785 SBBreakpointList &bkpt_list); 786 787 %feature("docstring", " 788 Read breakpoints from source_file and return the newly created 789 breakpoints in bkpt_list. 790 791 @param[in] source_file 792 The file from which to read the breakpoints 793 794 @param[in] matching_names 795 Only read in breakpoints whose names match one of the names in this 796 list. 797 798 @param[out] bkpt_list 799 A list of the newly created breakpoints. 800 801 @return 802 An SBError detailing any errors in reading in the breakpoints.") BreakpointsCreateFromFile; 803 lldb::SBError BreakpointsCreateFromFile(SBFileSpec &source_file, 804 SBStringList &matching_names, 805 SBBreakpointList &new_bps); 806 807 %feature("docstring", " 808 Write breakpoints to dest_file. 809 810 @param[in] dest_file 811 The file to which to write the breakpoints. 812 813 @return 814 An SBError detailing any errors in writing in the breakpoints.") BreakpointsCreateFromFile; 815 lldb::SBError 816 BreakpointsWriteToFile(SBFileSpec &dest_file); 817 818 %feature("docstring", " 819 Write breakpoints listed in bkpt_list to dest_file. 820 821 @param[in] dest_file 822 The file to which to write the breakpoints. 823 824 @param[in] bkpt_list 825 Only write breakpoints from this list. 826 827 @param[in] append 828 If true, append the breakpoints in bkpt_list to the others 829 serialized in dest_file. If dest_file doesn't exist, then a new 830 file will be created and the breakpoints in bkpt_list written to it. 831 832 @return 833 An SBError detailing any errors in writing in the breakpoints.") BreakpointsCreateFromFile; 834 lldb::SBError 835 BreakpointsWriteToFile(SBFileSpec &dest_file, 836 SBBreakpointList &bkpt_list, 837 bool append = false); 838 839 uint32_t 840 GetNumWatchpoints () const; 841 842 lldb::SBWatchpoint 843 GetWatchpointAtIndex (uint32_t idx) const; 844 845 bool 846 DeleteWatchpoint (lldb::watch_id_t watch_id); 847 848 lldb::SBWatchpoint 849 FindWatchpointByID (lldb::watch_id_t watch_id); 850 851 bool 852 EnableAllWatchpoints (); 853 854 bool 855 DisableAllWatchpoints (); 856 857 bool 858 DeleteAllWatchpoints (); 859 860 lldb::SBWatchpoint 861 WatchAddress (lldb::addr_t addr, 862 size_t size, 863 bool read, 864 bool write, 865 SBError &error); 866 867 868 lldb::SBBroadcaster 869 GetBroadcaster () const; 870 871 %feature("docstring", " 872 Create an SBValue with the given name by treating the memory starting at addr as an entity of type. 873 874 @param[in] name 875 The name of the resultant SBValue 876 877 @param[in] addr 878 The address of the start of the memory region to be used. 879 880 @param[in] type 881 The type to use to interpret the memory starting at addr. 882 883 @return 884 An SBValue of the given type, may be invalid if there was an error reading 885 the underlying memory.") CreateValueFromAddress; 886 lldb::SBValue 887 CreateValueFromAddress (const char *name, lldb::SBAddress addr, lldb::SBType type); 888 889 lldb::SBValue 890 CreateValueFromData (const char *name, lldb::SBData data, lldb::SBType type); 891 892 lldb::SBValue 893 CreateValueFromExpression (const char *name, const char* expr); 894 895 %feature("docstring", " 896 Disassemble a specified number of instructions starting at an address. 897 898 :param base_addr: the address to start disassembly from. 899 :param count: the number of instructions to disassemble. 900 :param flavor_string: may be 'intel' or 'att' on x86 targets to specify that style of disassembly. 901 :rtype: SBInstructionList 902 ") 903 ReadInstructions; 904 lldb::SBInstructionList 905 ReadInstructions (lldb::SBAddress base_addr, uint32_t count); 906 907 lldb::SBInstructionList 908 ReadInstructions (lldb::SBAddress base_addr, uint32_t count, const char *flavor_string); 909 910 %feature("docstring", " 911 Disassemble the bytes in a buffer and return them in an SBInstructionList. 912 913 :param base_addr: used for symbolicating the offsets in the byte stream when disassembling. 914 :param buf: bytes to be disassembled. 915 :param size: (C++) size of the buffer. 916 :rtype: SBInstructionList 917 ") 918 GetInstructions; 919 lldb::SBInstructionList 920 GetInstructions (lldb::SBAddress base_addr, const void *buf, size_t size); 921 922 %feature("docstring", " 923 Disassemble the bytes in a buffer and return them in an SBInstructionList, with a supplied flavor. 924 925 :param base_addr: used for symbolicating the offsets in the byte stream when disassembling. 926 :param flavor: may be 'intel' or 'att' on x86 targets to specify that style of disassembly. 927 :param buf: bytes to be disassembled. 928 :param size: (C++) size of the buffer. 929 :rtype: SBInstructionList 930 ") 931 GetInstructionsWithFlavor; 932 lldb::SBInstructionList 933 GetInstructionsWithFlavor (lldb::SBAddress base_addr, const char *flavor_string, const void *buf, size_t size); 934 935 lldb::SBSymbolContextList 936 FindSymbols (const char *name, lldb::SymbolType type = eSymbolTypeAny); 937 938 bool 939 GetDescription (lldb::SBStream &description, lldb::DescriptionLevel description_level); 940 941 lldb::addr_t 942 GetStackRedZoneSize(); 943 944 %feature("docstring", " 945 Returns true if the module has been loaded in this `SBTarget`. 946 A module can be loaded either by the dynamic loader or by being manually 947 added to the target (see `SBTarget.AddModule` and the `target module add` command). 948 949 :rtype: bool 950 ") IsLoaded; 951 bool 952 IsLoaded (const lldb::SBModule &module) const; 953 954 lldb::SBLaunchInfo 955 GetLaunchInfo () const; 956 957 void 958 SetLaunchInfo (const lldb::SBLaunchInfo &launch_info); 959 960 void SetCollectingStats(bool v); 961 962 bool GetCollectingStats(); 963 964 lldb::SBStructuredData GetStatistics(); 965 966 bool 967 operator == (const lldb::SBTarget &rhs) const; 968 969 bool 970 operator != (const lldb::SBTarget &rhs) const; 971 972 lldb::SBValue 973 EvaluateExpression (const char *expr); 974 975 lldb::SBValue 976 EvaluateExpression (const char *expr, const lldb::SBExpressionOptions &options); 977 978 STRING_EXTENSION_LEVEL(SBTarget, lldb::eDescriptionLevelBrief) 979 980 lldb::SBTrace 981 GetTrace (); 982 983 lldb::SBTrace 984 CreateTrace (lldb::SBError &error); 985 986 #ifdef SWIGPYTHON 987 %pythoncode %{ 988 class modules_access(object): 989 '''A helper object that will lazily hand out lldb.SBModule objects for a target when supplied an index, or by full or partial path.''' 990 def __init__(self, sbtarget): 991 self.sbtarget = sbtarget 992 993 def __len__(self): 994 if self.sbtarget: 995 return int(self.sbtarget.GetNumModules()) 996 return 0 997 998 def __getitem__(self, key): 999 num_modules = self.sbtarget.GetNumModules() 1000 if type(key) is int: 1001 if key < num_modules: 1002 return self.sbtarget.GetModuleAtIndex(key) 1003 elif type(key) is str: 1004 if key.find('/') == -1: 1005 for idx in range(num_modules): 1006 module = self.sbtarget.GetModuleAtIndex(idx) 1007 if module.file.basename == key: 1008 return module 1009 else: 1010 for idx in range(num_modules): 1011 module = self.sbtarget.GetModuleAtIndex(idx) 1012 if module.file.fullpath == key: 1013 return module 1014 # See if the string is a UUID 1015 try: 1016 the_uuid = uuid.UUID(key) 1017 if the_uuid: 1018 for idx in range(num_modules): 1019 module = self.sbtarget.GetModuleAtIndex(idx) 1020 if module.uuid == the_uuid: 1021 return module 1022 except: 1023 return None 1024 elif type(key) is uuid.UUID: 1025 for idx in range(num_modules): 1026 module = self.sbtarget.GetModuleAtIndex(idx) 1027 if module.uuid == key: 1028 return module 1029 elif type(key) is re.SRE_Pattern: 1030 matching_modules = [] 1031 for idx in range(num_modules): 1032 module = self.sbtarget.GetModuleAtIndex(idx) 1033 re_match = key.search(module.path.fullpath) 1034 if re_match: 1035 matching_modules.append(module) 1036 return matching_modules 1037 else: 1038 print("error: unsupported item type: %s" % type(key)) 1039 return None 1040 1041 def get_modules_access_object(self): 1042 '''An accessor function that returns a modules_access() object which allows lazy module access from a lldb.SBTarget object.''' 1043 return self.modules_access (self) 1044 1045 def get_modules_array(self): 1046 '''An accessor function that returns a list() that contains all modules in a lldb.SBTarget object.''' 1047 modules = [] 1048 for idx in range(self.GetNumModules()): 1049 modules.append(self.GetModuleAtIndex(idx)) 1050 return modules 1051 1052 def module_iter(self): 1053 '''Returns an iterator over all modules in a lldb.SBTarget 1054 object.''' 1055 return lldb_iter(self, 'GetNumModules', 'GetModuleAtIndex') 1056 1057 def breakpoint_iter(self): 1058 '''Returns an iterator over all breakpoints in a lldb.SBTarget 1059 object.''' 1060 return lldb_iter(self, 'GetNumBreakpoints', 'GetBreakpointAtIndex') 1061 1062 def watchpoint_iter(self): 1063 '''Returns an iterator over all watchpoints in a lldb.SBTarget 1064 object.''' 1065 return lldb_iter(self, 'GetNumWatchpoints', 'GetWatchpointAtIndex') 1066 1067 modules = property(get_modules_array, None, doc='''A read only property that returns a list() of lldb.SBModule objects contained in this target. This list is a list all modules that the target currently is tracking (the main executable and all dependent shared libraries).''') 1068 module = property(get_modules_access_object, None, doc=r'''A read only property that returns an object that implements python operator overloading with the square brackets().\n target.module[<int>] allows array access to any modules.\n target.module[<str>] allows access to modules by basename, full path, or uuid string value.\n target.module[uuid.UUID()] allows module access by UUID.\n target.module[re] allows module access using a regular expression that matches the module full path.''') 1069 process = property(GetProcess, None, doc='''A read only property that returns an lldb object that represents the process (lldb.SBProcess) that this target owns.''') 1070 executable = property(GetExecutable, None, doc='''A read only property that returns an lldb object that represents the main executable module (lldb.SBModule) for this target.''') 1071 debugger = property(GetDebugger, None, doc='''A read only property that returns an lldb object that represents the debugger (lldb.SBDebugger) that owns this target.''') 1072 num_breakpoints = property(GetNumBreakpoints, None, doc='''A read only property that returns the number of breakpoints that this target has as an integer.''') 1073 num_watchpoints = property(GetNumWatchpoints, None, doc='''A read only property that returns the number of watchpoints that this target has as an integer.''') 1074 broadcaster = property(GetBroadcaster, None, doc='''A read only property that an lldb object that represents the broadcaster (lldb.SBBroadcaster) for this target.''') 1075 byte_order = property(GetByteOrder, None, doc='''A read only property that returns an lldb enumeration value (lldb.eByteOrderLittle, lldb.eByteOrderBig, lldb.eByteOrderInvalid) that represents the byte order for this target.''') 1076 addr_size = property(GetAddressByteSize, None, doc='''A read only property that returns the size in bytes of an address for this target.''') 1077 triple = property(GetTriple, None, doc='''A read only property that returns the target triple (arch-vendor-os) for this target as a string.''') 1078 data_byte_size = property(GetDataByteSize, None, doc='''A read only property that returns the size in host bytes of a byte in the data address space for this target.''') 1079 code_byte_size = property(GetCodeByteSize, None, doc='''A read only property that returns the size in host bytes of a byte in the code address space for this target.''') 1080 platform = property(GetPlatform, None, doc='''A read only property that returns the platform associated with with this target.''') 1081 %} 1082 #endif 1083 }; 1084 } // namespace lldb 1085