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[in] argv 212 The argument array. 213 214 @param[in] envp 215 The environment array. 216 217 @param[in] working_directory 218 The working directory to have the child process run in 219 220 Default: listener 221 Set to the target's debugger (SBTarget::GetDebugger()) 222 223 Default: launch_flags 224 Empty launch flags 225 226 Default: stdin_path 227 Default: stdout_path 228 Default: stderr_path 229 A pseudo terminal will be used. 230 231 @return 232 A process object for the newly created process. 233 234 For example, 235 236 process = target.LaunchSimple(['X', 'Y', 'Z'], None, os.getcwd()) 237 238 launches a new process by passing 'X', 'Y', 'Z' as the args to the 239 executable.") LaunchSimple; 240 lldb::SBProcess 241 LaunchSimple (const char **argv, 242 const char **envp, 243 const char *working_directory); 244 245 lldb::SBProcess 246 Launch (lldb::SBLaunchInfo &launch_info, lldb::SBError& error); 247 248 %feature("docstring", " 249 Load a core file 250 251 @param[in] core_file 252 File path of the core dump. 253 254 @param[out] error 255 An error explaining what went wrong if the operation fails. 256 (Optional) 257 258 @return 259 A process object for the newly created core file. 260 261 For example, 262 263 process = target.LoadCore('./a.out.core') 264 265 loads a new core file and returns the process object.") LoadCore; 266 lldb::SBProcess 267 LoadCore(const char *core_file); 268 269 lldb::SBProcess 270 LoadCore(const char *core_file, lldb::SBError &error); 271 272 lldb::SBProcess 273 Attach(lldb::SBAttachInfo &attach_info, lldb::SBError& error); 274 275 %feature("docstring", " 276 Attach to process with pid. 277 278 @param[in] listener 279 An optional listener that will receive all process events. 280 If listener is valid then listener will listen to all 281 process events. If not valid, then this target's debugger 282 (SBTarget::GetDebugger()) will listen to all process events. 283 284 @param[in] pid 285 The process ID to attach to. 286 287 @param[out] 288 An error explaining what went wrong if attach fails. 289 290 @return 291 A process object for the attached process.") AttachToProcessWithID; 292 lldb::SBProcess 293 AttachToProcessWithID (SBListener &listener, 294 lldb::pid_t pid, 295 lldb::SBError& error); 296 297 %feature("docstring", " 298 Attach to process with name. 299 300 @param[in] listener 301 An optional listener that will receive all process events. 302 If listener is valid then listener will listen to all 303 process events. If not valid, then this target's debugger 304 (SBTarget::GetDebugger()) will listen to all process events. 305 306 @param[in] name 307 Basename of process to attach to. 308 309 @param[in] wait_for 310 If true wait for a new instance of 'name' to be launched. 311 312 @param[out] 313 An error explaining what went wrong if attach fails. 314 315 @return 316 A process object for the attached process.") AttachToProcessWithName; 317 lldb::SBProcess 318 AttachToProcessWithName (SBListener &listener, 319 const char *name, 320 bool wait_for, 321 lldb::SBError& error); 322 323 %feature("docstring", " 324 Connect to a remote debug server with url. 325 326 @param[in] listener 327 An optional listener that will receive all process events. 328 If listener is valid then listener will listen to all 329 process events. If not valid, then this target's debugger 330 (SBTarget::GetDebugger()) will listen to all process events. 331 332 @param[in] url 333 The url to connect to, e.g., 'connect://localhost:12345'. 334 335 @param[in] plugin_name 336 The plugin name to be used; can be NULL. 337 338 @param[out] 339 An error explaining what went wrong if the connect fails. 340 341 @return 342 A process object for the connected process.") ConnectRemote; 343 lldb::SBProcess 344 ConnectRemote (SBListener &listener, 345 const char *url, 346 const char *plugin_name, 347 SBError& error); 348 349 lldb::SBFileSpec 350 GetExecutable (); 351 352 %feature("docstring", " 353 Append the path mapping (from -> to) to the target's paths mapping list.") AppendImageSearchPath; 354 void 355 AppendImageSearchPath (const char *from, 356 const char *to, 357 SBError &error); 358 359 bool 360 AddModule (lldb::SBModule &module); 361 362 lldb::SBModule 363 AddModule (const char *path, 364 const char *triple, 365 const char *uuid); 366 367 lldb::SBModule 368 AddModule (const char *path, 369 const char *triple, 370 const char *uuid_cstr, 371 const char *symfile); 372 373 lldb::SBModule 374 AddModule (const SBModuleSpec &module_spec); 375 376 uint32_t 377 GetNumModules () const; 378 379 lldb::SBModule 380 GetModuleAtIndex (uint32_t idx); 381 382 bool 383 RemoveModule (lldb::SBModule module); 384 385 lldb::SBDebugger 386 GetDebugger() const; 387 388 lldb::SBModule 389 FindModule (const lldb::SBFileSpec &file_spec); 390 391 %feature("docstring", " 392 Find compile units related to *this target and passed source 393 file. 394 395 @param[in] sb_file_spec 396 A lldb::SBFileSpec object that contains source file 397 specification. 398 399 @return 400 A lldb::SBSymbolContextList that gets filled in with all of 401 the symbol contexts for all the matches.") FindCompileUnits; 402 lldb::SBSymbolContextList 403 FindCompileUnits (const lldb::SBFileSpec &sb_file_spec); 404 405 lldb::ByteOrder 406 GetByteOrder (); 407 408 uint32_t 409 GetAddressByteSize(); 410 411 const char * 412 GetTriple (); 413 414 %feature("docstring", " 415 Architecture data byte width accessor 416 417 @return 418 The size in 8-bit (host) bytes of a minimum addressable 419 unit from the Architecture's data bus") GetDataByteSize; 420 uint32_t 421 GetDataByteSize (); 422 423 %feature("docstring", " 424 Architecture code byte width accessor 425 426 @return 427 The size in 8-bit (host) bytes of a minimum addressable 428 unit from the Architecture's code bus") GetCodeByteSize; 429 uint32_t 430 GetCodeByteSize (); 431 432 lldb::SBError 433 SetSectionLoadAddress (lldb::SBSection section, 434 lldb::addr_t section_base_addr); 435 436 lldb::SBError 437 ClearSectionLoadAddress (lldb::SBSection section); 438 439 lldb::SBError 440 SetModuleLoadAddress (lldb::SBModule module, 441 int64_t sections_offset); 442 443 lldb::SBError 444 ClearModuleLoadAddress (lldb::SBModule module); 445 446 %feature("docstring", " 447 Find functions by name. 448 449 @param[in] name 450 The name of the function we are looking for. 451 452 @param[in] name_type_mask 453 A logical OR of one or more FunctionNameType enum bits that 454 indicate what kind of names should be used when doing the 455 lookup. Bits include fully qualified names, base names, 456 C++ methods, or ObjC selectors. 457 See FunctionNameType for more details. 458 459 @return 460 A lldb::SBSymbolContextList that gets filled in with all of 461 the symbol contexts for all the matches.") FindFunctions; 462 lldb::SBSymbolContextList 463 FindFunctions (const char *name, 464 uint32_t name_type_mask = lldb::eFunctionNameTypeAny); 465 466 lldb::SBType 467 FindFirstType (const char* type); 468 469 lldb::SBTypeList 470 FindTypes (const char* type); 471 472 lldb::SBType 473 GetBasicType(lldb::BasicType type); 474 475 lldb::SBSourceManager 476 GetSourceManager (); 477 478 %feature("docstring", " 479 Find global and static variables by name. 480 481 @param[in] name 482 The name of the global or static variable we are looking 483 for. 484 485 @param[in] max_matches 486 Allow the number of matches to be limited to max_matches. 487 488 @return 489 A list of matched variables in an SBValueList.") FindGlobalVariables; 490 lldb::SBValueList 491 FindGlobalVariables (const char *name, 492 uint32_t max_matches); 493 494 %feature("docstring", " 495 Find the first global (or static) variable by name. 496 497 @param[in] name 498 The name of the global or static variable we are looking 499 for. 500 501 @return 502 An SBValue that gets filled in with the found variable (if any).") FindFirstGlobalVariable; 503 lldb::SBValue 504 FindFirstGlobalVariable (const char* name); 505 506 507 lldb::SBValueList 508 FindGlobalVariables(const char *name, 509 uint32_t max_matches, 510 MatchType matchtype); 511 512 lldb::SBSymbolContextList 513 FindGlobalFunctions(const char *name, 514 uint32_t max_matches, 515 MatchType matchtype); 516 517 void 518 Clear (); 519 520 %feature("docstring", " 521 Resolve a current file address into a section offset address. 522 523 @param[in] file_addr 524 525 @return 526 An SBAddress which will be valid if...") ResolveFileAddress; 527 lldb::SBAddress 528 ResolveFileAddress (lldb::addr_t file_addr); 529 530 lldb::SBAddress 531 ResolveLoadAddress (lldb::addr_t vm_addr); 532 533 lldb::SBAddress 534 ResolvePastLoadAddress (uint32_t stop_id, lldb::addr_t vm_addr); 535 536 SBSymbolContext 537 ResolveSymbolContextForAddress (const SBAddress& addr, 538 uint32_t resolve_scope); 539 540 %feature("docstring", " 541 Read target memory. If a target process is running then memory 542 is read from here. Otherwise the memory is read from the object 543 files. For a target whose bytes are sized as a multiple of host 544 bytes, the data read back will preserve the target's byte order. 545 546 @param[in] addr 547 A target address to read from. 548 549 @param[out] buf 550 The buffer to read memory into. 551 552 @param[in] size 553 The maximum number of host bytes to read in the buffer passed 554 into this call 555 556 @param[out] error 557 Error information is written here if the memory read fails. 558 559 @return 560 The amount of data read in host bytes.") ReadMemory; 561 size_t 562 ReadMemory (const SBAddress addr, void *buf, size_t size, lldb::SBError &error); 563 564 lldb::SBBreakpoint 565 BreakpointCreateByLocation (const char *file, uint32_t line); 566 567 lldb::SBBreakpoint 568 BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line); 569 570 lldb::SBBreakpoint 571 BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line, lldb::addr_t offset); 572 573 lldb::SBBreakpoint 574 BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line, 575 lldb::addr_t offset, SBFileSpecList &module_list); 576 577 lldb::SBBreakpoint 578 BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line, 579 uint32_t column, lldb::addr_t offset, 580 SBFileSpecList &module_list); 581 582 lldb::SBBreakpoint 583 BreakpointCreateByName (const char *symbol_name, const char *module_name = NULL); 584 585 lldb::SBBreakpoint 586 BreakpointCreateByName (const char *symbol_name, 587 uint32_t func_name_type, // Logical OR one or more FunctionNameType enum bits 588 const SBFileSpecList &module_list, 589 const SBFileSpecList &comp_unit_list); 590 591 lldb::SBBreakpoint 592 BreakpointCreateByName (const char *symbol_name, 593 uint32_t func_name_type, // Logical OR one or more FunctionNameType enum bits 594 lldb::LanguageType symbol_language, 595 const SBFileSpecList &module_list, 596 const SBFileSpecList &comp_unit_list); 597 598 #ifdef SWIGPYTHON 599 %typemap(in) (const char **symbol_name, uint32_t num_names) { 600 using namespace lldb_private; 601 /* Check if is a list */ 602 if (PythonList::Check($input)) { 603 PythonList list(PyRefType::Borrowed, $input); 604 $2 = list.GetSize(); 605 int i = 0; 606 $1 = (char**)malloc(($2+1)*sizeof(char*)); 607 for (i = 0; i < $2; i++) { 608 PythonString py_str = list.GetItemAtIndex(i).AsType<PythonString>(); 609 if (!py_str.IsAllocated()) { 610 PyErr_SetString(PyExc_TypeError,"list must contain strings and blubby"); 611 free($1); 612 return nullptr; 613 } 614 615 $1[i] = const_cast<char*>(py_str.GetString().data()); 616 } 617 $1[i] = 0; 618 } else if ($input == Py_None) { 619 $1 = NULL; 620 } else { 621 PyErr_SetString(PyExc_TypeError,"not a list"); 622 return NULL; 623 } 624 } 625 #endif 626 627 lldb::SBBreakpoint 628 BreakpointCreateByNames (const char **symbol_name, 629 uint32_t num_names, 630 uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits 631 const SBFileSpecList &module_list, 632 const SBFileSpecList &comp_unit_list); 633 634 lldb::SBBreakpoint 635 BreakpointCreateByNames (const char **symbol_name, 636 uint32_t num_names, 637 uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits 638 lldb::LanguageType symbol_language, 639 const SBFileSpecList &module_list, 640 const SBFileSpecList &comp_unit_list); 641 642 lldb::SBBreakpoint 643 BreakpointCreateByNames (const char **symbol_name, 644 uint32_t num_names, 645 uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits 646 lldb::LanguageType symbol_language, 647 lldb::addr_t offset, 648 const SBFileSpecList &module_list, 649 const SBFileSpecList &comp_unit_list); 650 651 lldb::SBBreakpoint 652 BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name = NULL); 653 654 lldb::SBBreakpoint 655 BreakpointCreateByRegex (const char *symbol_name_regex, 656 lldb::LanguageType symbol_language, 657 const SBFileSpecList &module_list, 658 const SBFileSpecList &comp_unit_list); 659 660 lldb::SBBreakpoint 661 BreakpointCreateBySourceRegex (const char *source_regex, const lldb::SBFileSpec &source_file, const char *module_name = NULL); 662 663 lldb::SBBreakpoint 664 BreakpointCreateBySourceRegex (const char *source_regex, const lldb::SBFileSpecList &module_list, const lldb::SBFileSpecList &file_list); 665 666 lldb::SBBreakpoint 667 BreakpointCreateBySourceRegex (const char *source_regex, 668 const SBFileSpecList &module_list, 669 const SBFileSpecList &source_file, 670 const SBStringList &func_names); 671 672 lldb::SBBreakpoint 673 BreakpointCreateForException (lldb::LanguageType language, 674 bool catch_bp, 675 bool throw_bp); 676 677 lldb::SBBreakpoint 678 BreakpointCreateByAddress (addr_t address); 679 680 lldb::SBBreakpoint 681 BreakpointCreateBySBAddress (SBAddress &sb_address); 682 683 %feature("docstring", " 684 Create a breakpoint using a scripted resolver. 685 686 @param[in] class_name 687 This is the name of the class that implements a scripted resolver. 688 The class should have the following signature: 689 class Resolver: 690 def __init__(self, bkpt, extra_args): 691 # bkpt - the breakpoint for which this is the resolver. When 692 # the resolver finds an interesting address, call AddLocation 693 # on this breakpoint to add it. 694 # 695 # extra_args - an SBStructuredData that can be used to 696 # parametrize this instance. Same as the extra_args passed 697 # to BreakpointCreateFromScript. 698 699 def __get_depth__ (self): 700 # This is optional, but if defined, you should return the 701 # depth at which you want the callback to be called. The 702 # available options are: 703 # lldb.eSearchDepthModule 704 # lldb.eSearchDepthCompUnit 705 # The default if you don't implement this method is 706 # eSearchDepthModule. 707 708 def __callback__(self, sym_ctx): 709 # sym_ctx - an SBSymbolContext that is the cursor in the 710 # search through the program to resolve breakpoints. 711 # The sym_ctx will be filled out to the depth requested in 712 # __get_depth__. 713 # Look in this sym_ctx for new breakpoint locations, 714 # and if found use bkpt.AddLocation to add them. 715 # Note, you will only get called for modules/compile_units that 716 # pass the SearchFilter provided by the module_list & file_list 717 # passed into BreakpointCreateFromScript. 718 719 def get_short_help(self): 720 # Optional, but if implemented return a short string that will 721 # be printed at the beginning of the break list output for the 722 # breakpoint. 723 724 @param[in] extra_args 725 This is an SBStructuredData object that will get passed to the 726 constructor of the class in class_name. You can use this to 727 reuse the same class, parametrizing it with entries from this 728 dictionary. 729 730 @param module_list 731 If this is non-empty, this will be used as the module filter in the 732 SearchFilter created for this breakpoint. 733 734 @param file_list 735 If this is non-empty, this will be used as the comp unit filter in the 736 SearchFilter created for this breakpoint. 737 738 @return 739 An SBBreakpoint that will set locations based on the logic in the 740 resolver's search callback.") BreakpointCreateFromScript; 741 lldb::SBBreakpoint BreakpointCreateFromScript( 742 const char *class_name, 743 SBStructuredData &extra_args, 744 const SBFileSpecList &module_list, 745 const SBFileSpecList &file_list, 746 bool request_hardware = false); 747 748 uint32_t 749 GetNumBreakpoints () const; 750 751 lldb::SBBreakpoint 752 GetBreakpointAtIndex (uint32_t idx) const; 753 754 bool 755 BreakpointDelete (break_id_t break_id); 756 757 lldb::SBBreakpoint 758 FindBreakpointByID (break_id_t break_id); 759 760 761 bool FindBreakpointsByName(const char *name, SBBreakpointList &bkpt_list); 762 763 void DeleteBreakpointName(const char *name); 764 765 void GetBreakpointNames(SBStringList &names); 766 767 bool 768 EnableAllBreakpoints (); 769 770 bool 771 DisableAllBreakpoints (); 772 773 bool 774 DeleteAllBreakpoints (); 775 776 %feature("docstring", " 777 Read breakpoints from source_file and return the newly created 778 breakpoints in bkpt_list. 779 780 @param[in] source_file 781 The file from which to read the breakpoints 782 783 @param[out] bkpt_list 784 A list of the newly created breakpoints. 785 786 @return 787 An SBError detailing any errors in reading in the breakpoints.") BreakpointsCreateFromFile; 788 lldb::SBError 789 BreakpointsCreateFromFile(SBFileSpec &source_file, 790 SBBreakpointList &bkpt_list); 791 792 %feature("docstring", " 793 Read breakpoints from source_file and return the newly created 794 breakpoints in bkpt_list. 795 796 @param[in] source_file 797 The file from which to read the breakpoints 798 799 @param[in] matching_names 800 Only read in breakpoints whose names match one of the names in this 801 list. 802 803 @param[out] bkpt_list 804 A list of the newly created breakpoints. 805 806 @return 807 An SBError detailing any errors in reading in the breakpoints.") BreakpointsCreateFromFile; 808 lldb::SBError BreakpointsCreateFromFile(SBFileSpec &source_file, 809 SBStringList &matching_names, 810 SBBreakpointList &new_bps); 811 812 %feature("docstring", " 813 Write breakpoints to dest_file. 814 815 @param[in] dest_file 816 The file to which to write the breakpoints. 817 818 @return 819 An SBError detailing any errors in writing in the breakpoints.") BreakpointsCreateFromFile; 820 lldb::SBError 821 BreakpointsWriteToFile(SBFileSpec &dest_file); 822 823 %feature("docstring", " 824 Write breakpoints listed in bkpt_list to dest_file. 825 826 @param[in] dest_file 827 The file to which to write the breakpoints. 828 829 @param[in] bkpt_list 830 Only write breakpoints from this list. 831 832 @param[in] append 833 If true, append the breakpoints in bkpt_list to the others 834 serialized in dest_file. If dest_file doesn't exist, then a new 835 file will be created and the breakpoints in bkpt_list written to it. 836 837 @return 838 An SBError detailing any errors in writing in the breakpoints.") BreakpointsCreateFromFile; 839 lldb::SBError 840 BreakpointsWriteToFile(SBFileSpec &dest_file, 841 SBBreakpointList &bkpt_list, 842 bool append = false); 843 844 uint32_t 845 GetNumWatchpoints () const; 846 847 lldb::SBWatchpoint 848 GetWatchpointAtIndex (uint32_t idx) const; 849 850 bool 851 DeleteWatchpoint (lldb::watch_id_t watch_id); 852 853 lldb::SBWatchpoint 854 FindWatchpointByID (lldb::watch_id_t watch_id); 855 856 bool 857 EnableAllWatchpoints (); 858 859 bool 860 DisableAllWatchpoints (); 861 862 bool 863 DeleteAllWatchpoints (); 864 865 lldb::SBWatchpoint 866 WatchAddress (lldb::addr_t addr, 867 size_t size, 868 bool read, 869 bool write, 870 SBError &error); 871 872 873 lldb::SBBroadcaster 874 GetBroadcaster () const; 875 876 %feature("docstring", " 877 Create an SBValue with the given name by treating the memory starting at addr as an entity of type. 878 879 @param[in] name 880 The name of the resultant SBValue 881 882 @param[in] addr 883 The address of the start of the memory region to be used. 884 885 @param[in] type 886 The type to use to interpret the memory starting at addr. 887 888 @return 889 An SBValue of the given type, may be invalid if there was an error reading 890 the underlying memory.") CreateValueFromAddress; 891 lldb::SBValue 892 CreateValueFromAddress (const char *name, lldb::SBAddress addr, lldb::SBType type); 893 894 lldb::SBValue 895 CreateValueFromData (const char *name, lldb::SBData data, lldb::SBType type); 896 897 lldb::SBValue 898 CreateValueFromExpression (const char *name, const char* expr); 899 900 %feature("docstring", " 901 Disassemble a specified number of instructions starting at an address. 902 Parameters: 903 base_addr -- the address to start disassembly from 904 count -- the number of instructions to disassemble 905 flavor_string -- may be 'intel' or 'att' on x86 targets to specify that style of disassembly 906 Returns an SBInstructionList.") 907 ReadInstructions; 908 lldb::SBInstructionList 909 ReadInstructions (lldb::SBAddress base_addr, uint32_t count); 910 911 lldb::SBInstructionList 912 ReadInstructions (lldb::SBAddress base_addr, uint32_t count, const char *flavor_string); 913 914 %feature("docstring", " 915 Disassemble the bytes in a buffer and return them in an SBInstructionList. 916 Parameters: 917 base_addr -- used for symbolicating the offsets in the byte stream when disassembling 918 buf -- bytes to be disassembled 919 size -- (C++) size of the buffer 920 Returns an SBInstructionList.") 921 GetInstructions; 922 lldb::SBInstructionList 923 GetInstructions (lldb::SBAddress base_addr, const void *buf, size_t size); 924 925 %feature("docstring", " 926 Disassemble the bytes in a buffer and return them in an SBInstructionList, with a supplied flavor. 927 Parameters: 928 base_addr -- used for symbolicating the offsets in the byte stream when disassembling 929 flavor -- may be 'intel' or 'att' on x86 targets to specify that style of disassembly 930 buf -- bytes to be disassembled 931 size -- (C++) size of the buffer 932 Returns an SBInstructionList.") 933 GetInstructionsWithFlavor; 934 lldb::SBInstructionList 935 GetInstructionsWithFlavor (lldb::SBAddress base_addr, const char *flavor_string, const void *buf, size_t size); 936 937 lldb::SBSymbolContextList 938 FindSymbols (const char *name, lldb::SymbolType type = eSymbolTypeAny); 939 940 bool 941 GetDescription (lldb::SBStream &description, lldb::DescriptionLevel description_level); 942 943 lldb::addr_t 944 GetStackRedZoneSize(); 945 946 lldb::SBLaunchInfo 947 GetLaunchInfo () const; 948 949 void 950 SetLaunchInfo (const lldb::SBLaunchInfo &launch_info); 951 952 void SetCollectingStats(bool v); 953 954 bool GetCollectingStats(); 955 956 lldb::SBStructuredData GetStatistics(); 957 958 bool 959 operator == (const lldb::SBTarget &rhs) const; 960 961 bool 962 operator != (const lldb::SBTarget &rhs) const; 963 964 lldb::SBValue 965 EvaluateExpression (const char *expr); 966 967 lldb::SBValue 968 EvaluateExpression (const char *expr, const lldb::SBExpressionOptions &options); 969 970 STRING_EXTENSION_LEVEL(SBTarget, lldb::eDescriptionLevelBrief) 971 972 #ifdef SWIGPYTHON 973 %pythoncode %{ 974 class modules_access(object): 975 '''A helper object that will lazily hand out lldb.SBModule objects for a target when supplied an index, or by full or partial path.''' 976 def __init__(self, sbtarget): 977 self.sbtarget = sbtarget 978 979 def __len__(self): 980 if self.sbtarget: 981 return int(self.sbtarget.GetNumModules()) 982 return 0 983 984 def __getitem__(self, key): 985 num_modules = self.sbtarget.GetNumModules() 986 if type(key) is int: 987 if key < num_modules: 988 return self.sbtarget.GetModuleAtIndex(key) 989 elif type(key) is str: 990 if key.find('/') == -1: 991 for idx in range(num_modules): 992 module = self.sbtarget.GetModuleAtIndex(idx) 993 if module.file.basename == key: 994 return module 995 else: 996 for idx in range(num_modules): 997 module = self.sbtarget.GetModuleAtIndex(idx) 998 if module.file.fullpath == key: 999 return module 1000 # See if the string is a UUID 1001 try: 1002 the_uuid = uuid.UUID(key) 1003 if the_uuid: 1004 for idx in range(num_modules): 1005 module = self.sbtarget.GetModuleAtIndex(idx) 1006 if module.uuid == the_uuid: 1007 return module 1008 except: 1009 return None 1010 elif type(key) is uuid.UUID: 1011 for idx in range(num_modules): 1012 module = self.sbtarget.GetModuleAtIndex(idx) 1013 if module.uuid == key: 1014 return module 1015 elif type(key) is re.SRE_Pattern: 1016 matching_modules = [] 1017 for idx in range(num_modules): 1018 module = self.sbtarget.GetModuleAtIndex(idx) 1019 re_match = key.search(module.path.fullpath) 1020 if re_match: 1021 matching_modules.append(module) 1022 return matching_modules 1023 else: 1024 print("error: unsupported item type: %s" % type(key)) 1025 return None 1026 1027 def get_modules_access_object(self): 1028 '''An accessor function that returns a modules_access() object which allows lazy module access from a lldb.SBTarget object.''' 1029 return self.modules_access (self) 1030 1031 def get_modules_array(self): 1032 '''An accessor function that returns a list() that contains all modules in a lldb.SBTarget object.''' 1033 modules = [] 1034 for idx in range(self.GetNumModules()): 1035 modules.append(self.GetModuleAtIndex(idx)) 1036 return modules 1037 1038 def module_iter(self): 1039 '''Returns an iterator over all modules in a lldb.SBTarget 1040 object.''' 1041 return lldb_iter(self, 'GetNumModules', 'GetModuleAtIndex') 1042 1043 def breakpoint_iter(self): 1044 '''Returns an iterator over all breakpoints in a lldb.SBTarget 1045 object.''' 1046 return lldb_iter(self, 'GetNumBreakpoints', 'GetBreakpointAtIndex') 1047 1048 def watchpoint_iter(self): 1049 '''Returns an iterator over all watchpoints in a lldb.SBTarget 1050 object.''' 1051 return lldb_iter(self, 'GetNumWatchpoints', 'GetWatchpointAtIndex') 1052 1053 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).''') 1054 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.''') 1055 process = property(GetProcess, None, doc='''A read only property that returns an lldb object that represents the process (lldb.SBProcess) that this target owns.''') 1056 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.''') 1057 debugger = property(GetDebugger, None, doc='''A read only property that returns an lldb object that represents the debugger (lldb.SBDebugger) that owns this target.''') 1058 num_breakpoints = property(GetNumBreakpoints, None, doc='''A read only property that returns the number of breakpoints that this target has as an integer.''') 1059 num_watchpoints = property(GetNumWatchpoints, None, doc='''A read only property that returns the number of watchpoints that this target has as an integer.''') 1060 broadcaster = property(GetBroadcaster, None, doc='''A read only property that an lldb object that represents the broadcaster (lldb.SBBroadcaster) for this target.''') 1061 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.''') 1062 addr_size = property(GetAddressByteSize, None, doc='''A read only property that returns the size in bytes of an address for this target.''') 1063 triple = property(GetTriple, None, doc='''A read only property that returns the target triple (arch-vendor-os) for this target as a string.''') 1064 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.''') 1065 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.''') 1066 platform = property(GetPlatform, None, doc='''A read only property that returns the platform associated with with this target.''') 1067 %} 1068 #endif 1069 }; 1070 } // namespace lldb 1071