Target.h revision 49ce8969d3154e1560106cfe530444c09410f217
1//===-- Target.h ------------------------------------------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10#ifndef liblldb_Target_h_ 11#define liblldb_Target_h_ 12 13// C Includes 14// C++ Includes 15 16// Other libraries and framework includes 17// Project includes 18#include "lldb/lldb-public.h" 19#include "lldb/Breakpoint/BreakpointList.h" 20#include "lldb/Breakpoint/BreakpointLocationCollection.h" 21#include "lldb/Breakpoint/WatchpointList.h" 22#include "lldb/Core/ArchSpec.h" 23#include "lldb/Core/Broadcaster.h" 24#include "lldb/Core/Event.h" 25#include "lldb/Core/ModuleList.h" 26#include "lldb/Core/UserSettingsController.h" 27#include "lldb/Core/SourceManager.h" 28#include "lldb/Expression/ClangPersistentVariables.h" 29#include "lldb/Interpreter/Args.h" 30#include "lldb/Interpreter/OptionValueBoolean.h" 31#include "lldb/Interpreter/OptionValueEnumeration.h" 32#include "lldb/Interpreter/OptionValueFileSpec.h" 33#include "lldb/Symbol/SymbolContext.h" 34#include "lldb/Target/ABI.h" 35#include "lldb/Target/ExecutionContextScope.h" 36#include "lldb/Target/PathMappingList.h" 37#include "lldb/Target/SectionLoadList.h" 38 39namespace lldb_private { 40 41extern OptionEnumValueElement g_dynamic_value_types[]; 42 43typedef enum InlineStrategy 44{ 45 eInlineBreakpointsNever = 0, 46 eInlineBreakpointsHeaders, 47 eInlineBreakpointsAlways 48} InlineStrategy; 49 50 51//---------------------------------------------------------------------- 52// TargetProperties 53//---------------------------------------------------------------------- 54class TargetProperties : public Properties 55{ 56public: 57 TargetProperties(Target *target); 58 59 virtual 60 ~TargetProperties(); 61 62 ArchSpec 63 GetDefaultArchitecture () const; 64 65 void 66 SetDefaultArchitecture (const ArchSpec& arch); 67 68 lldb::DynamicValueType 69 GetPreferDynamicValue() const; 70 71 bool 72 GetDisableASLR () const; 73 74 void 75 SetDisableASLR (bool b); 76 77 bool 78 GetDisableSTDIO () const; 79 80 void 81 SetDisableSTDIO (bool b); 82 83 InlineStrategy 84 GetInlineStrategy () const; 85 86 bool 87 GetRunArguments (Args &args) const; 88 89 void 90 SetRunArguments (const Args &args); 91 92 size_t 93 GetEnvironmentAsArgs (Args &env) const; 94 95 bool 96 GetSkipPrologue() const; 97 98 PathMappingList & 99 GetSourcePathMap () const; 100 101 FileSpecList & 102 GetExecutableSearchPaths (); 103 104 bool 105 GetEnableSyntheticValue () const; 106 107 uint32_t 108 GetMaximumNumberOfChildrenToDisplay() const; 109 110 uint32_t 111 GetMaximumSizeOfStringSummary() const; 112 113 FileSpec 114 GetStandardInputPath () const; 115 116 void 117 SetStandardInputPath (const char *path); 118 119 FileSpec 120 GetStandardOutputPath () const; 121 122 void 123 SetStandardOutputPath (const char *path); 124 125 FileSpec 126 GetStandardErrorPath () const; 127 128 void 129 SetStandardErrorPath (const char *path); 130 131 bool 132 GetBreakpointsConsultPlatformAvoidList (); 133 134 const char * 135 GetExpressionPrefixContentsAsCString (); 136}; 137 138typedef STD_SHARED_PTR(TargetProperties) TargetPropertiesSP; 139 140//---------------------------------------------------------------------- 141// Target 142//---------------------------------------------------------------------- 143class Target : 144 public STD_ENABLE_SHARED_FROM_THIS(Target), 145 public TargetProperties, 146 public Broadcaster, 147 public ExecutionContextScope 148{ 149public: 150 friend class TargetList; 151 152 //------------------------------------------------------------------ 153 /// Broadcaster event bits definitions. 154 //------------------------------------------------------------------ 155 enum 156 { 157 eBroadcastBitBreakpointChanged = (1 << 0), 158 eBroadcastBitModulesLoaded = (1 << 1), 159 eBroadcastBitModulesUnloaded = (1 << 2) 160 }; 161 162 // These two functions fill out the Broadcaster interface: 163 164 static ConstString &GetStaticBroadcasterClass (); 165 166 virtual ConstString &GetBroadcasterClass() const 167 { 168 return GetStaticBroadcasterClass(); 169 } 170 171 // This event data class is for use by the TargetList to broadcast new target notifications. 172 class TargetEventData : public EventData 173 { 174 public: 175 176 static const ConstString & 177 GetFlavorString (); 178 179 virtual const ConstString & 180 GetFlavor () const; 181 182 TargetEventData (const lldb::TargetSP &new_target_sp); 183 184 lldb::TargetSP & 185 GetTarget() 186 { 187 return m_target_sp; 188 } 189 190 virtual 191 ~TargetEventData(); 192 193 virtual void 194 Dump (Stream *s) const; 195 196 static const lldb::TargetSP 197 GetTargetFromEvent (const lldb::EventSP &event_sp); 198 199 static const TargetEventData * 200 GetEventDataFromEvent (const Event *event_sp); 201 202 private: 203 lldb::TargetSP m_target_sp; 204 205 DISALLOW_COPY_AND_ASSIGN (TargetEventData); 206 }; 207 208 static void 209 SettingsInitialize (); 210 211 static void 212 SettingsTerminate (); 213 214// static lldb::UserSettingsControllerSP & 215// GetSettingsController (); 216 217 static FileSpecList 218 GetDefaultExecutableSearchPaths (); 219 220 static ArchSpec 221 GetDefaultArchitecture (); 222 223 static void 224 SetDefaultArchitecture (const ArchSpec &arch); 225 226// void 227// UpdateInstanceName (); 228 229 lldb::ModuleSP 230 GetSharedModule (const ModuleSpec &module_spec, 231 Error *error_ptr = NULL); 232 233 //---------------------------------------------------------------------- 234 // Settings accessors 235 //---------------------------------------------------------------------- 236 237 static const TargetPropertiesSP & 238 GetGlobalProperties(); 239 240 241private: 242 //------------------------------------------------------------------ 243 /// Construct with optional file and arch. 244 /// 245 /// This member is private. Clients must use 246 /// TargetList::CreateTarget(const FileSpec*, const ArchSpec*) 247 /// so all targets can be tracked from the central target list. 248 /// 249 /// @see TargetList::CreateTarget(const FileSpec*, const ArchSpec*) 250 //------------------------------------------------------------------ 251 Target (Debugger &debugger, 252 const ArchSpec &target_arch, 253 const lldb::PlatformSP &platform_sp); 254 255 // Helper function. 256 bool 257 ProcessIsValid (); 258 259public: 260 ~Target(); 261 262 Mutex & 263 GetAPIMutex () 264 { 265 return m_mutex; 266 } 267 268 void 269 DeleteCurrentProcess (); 270 271 //------------------------------------------------------------------ 272 /// Dump a description of this object to a Stream. 273 /// 274 /// Dump a description of the contents of this object to the 275 /// supplied stream \a s. The dumped content will be only what has 276 /// been loaded or parsed up to this point at which this function 277 /// is called, so this is a good way to see what has been parsed 278 /// in a target. 279 /// 280 /// @param[in] s 281 /// The stream to which to dump the object descripton. 282 //------------------------------------------------------------------ 283 void 284 Dump (Stream *s, lldb::DescriptionLevel description_level); 285 286 const lldb::ProcessSP & 287 CreateProcess (Listener &listener, 288 const char *plugin_name, 289 const FileSpec *crash_file); 290 291 const lldb::ProcessSP & 292 GetProcessSP () const; 293 294 bool 295 IsValid() 296 { 297 return m_valid; 298 } 299 300 void 301 Destroy(); 302 303 //------------------------------------------------------------------ 304 // This part handles the breakpoints. 305 //------------------------------------------------------------------ 306 307 BreakpointList & 308 GetBreakpointList(bool internal = false); 309 310 const BreakpointList & 311 GetBreakpointList(bool internal = false) const; 312 313 lldb::BreakpointSP 314 GetLastCreatedBreakpoint () 315 { 316 return m_last_created_breakpoint; 317 } 318 319 lldb::BreakpointSP 320 GetBreakpointByID (lldb::break_id_t break_id); 321 322 // Use this to create a file and line breakpoint to a given module or all module it is NULL 323 lldb::BreakpointSP 324 CreateBreakpoint (const FileSpecList *containingModules, 325 const FileSpec &file, 326 uint32_t line_no, 327 LazyBool check_inlines = eLazyBoolCalculate, 328 LazyBool skip_prologue = eLazyBoolCalculate, 329 bool internal = false); 330 331 // Use this to create breakpoint that matches regex against the source lines in files given in source_file_list: 332 lldb::BreakpointSP 333 CreateSourceRegexBreakpoint (const FileSpecList *containingModules, 334 const FileSpecList *source_file_list, 335 RegularExpression &source_regex, 336 bool internal = false); 337 338 // Use this to create a breakpoint from a load address 339 lldb::BreakpointSP 340 CreateBreakpoint (lldb::addr_t load_addr, 341 bool internal = false); 342 343 // Use this to create Address breakpoints: 344 lldb::BreakpointSP 345 CreateBreakpoint (Address &addr, 346 bool internal = false); 347 348 // Use this to create a function breakpoint by regexp in containingModule/containingSourceFiles, or all modules if it is NULL 349 // When "skip_prologue is set to eLazyBoolCalculate, we use the current target 350 // setting, else we use the values passed in 351 lldb::BreakpointSP 352 CreateFuncRegexBreakpoint (const FileSpecList *containingModules, 353 const FileSpecList *containingSourceFiles, 354 RegularExpression &func_regexp, 355 LazyBool skip_prologue = eLazyBoolCalculate, 356 bool internal = false); 357 358 // Use this to create a function breakpoint by name in containingModule, or all modules if it is NULL 359 // When "skip_prologue is set to eLazyBoolCalculate, we use the current target 360 // setting, else we use the values passed in 361 lldb::BreakpointSP 362 CreateBreakpoint (const FileSpecList *containingModules, 363 const FileSpecList *containingSourceFiles, 364 const char *func_name, 365 uint32_t func_name_type_mask, 366 LazyBool skip_prologue = eLazyBoolCalculate, 367 bool internal = false); 368 369 lldb::BreakpointSP 370 CreateExceptionBreakpoint (enum lldb::LanguageType language, bool catch_bp, bool throw_bp, bool internal = false); 371 372 // This is the same as the func_name breakpoint except that you can specify a vector of names. This is cheaper 373 // than a regular expression breakpoint in the case where you just want to set a breakpoint on a set of names 374 // you already know. 375 lldb::BreakpointSP 376 CreateBreakpoint (const FileSpecList *containingModules, 377 const FileSpecList *containingSourceFiles, 378 const char *func_names[], 379 size_t num_names, 380 uint32_t func_name_type_mask, 381 LazyBool skip_prologue = eLazyBoolCalculate, 382 bool internal = false); 383 384 lldb::BreakpointSP 385 CreateBreakpoint (const FileSpecList *containingModules, 386 const FileSpecList *containingSourceFiles, 387 const std::vector<std::string> &func_names, 388 uint32_t func_name_type_mask, 389 LazyBool skip_prologue = eLazyBoolCalculate, 390 bool internal = false); 391 392 393 // Use this to create a general breakpoint: 394 lldb::BreakpointSP 395 CreateBreakpoint (lldb::SearchFilterSP &filter_sp, 396 lldb::BreakpointResolverSP &resolver_sp, 397 bool internal = false); 398 399 // Use this to create a watchpoint: 400 lldb::WatchpointSP 401 CreateWatchpoint (lldb::addr_t addr, 402 size_t size, 403 uint32_t type, 404 Error &error); 405 406 lldb::WatchpointSP 407 GetLastCreatedWatchpoint () 408 { 409 return m_last_created_watchpoint; 410 } 411 412 WatchpointList & 413 GetWatchpointList() 414 { 415 return m_watchpoint_list; 416 } 417 418 void 419 RemoveAllBreakpoints (bool internal_also = false); 420 421 void 422 DisableAllBreakpoints (bool internal_also = false); 423 424 void 425 EnableAllBreakpoints (bool internal_also = false); 426 427 bool 428 DisableBreakpointByID (lldb::break_id_t break_id); 429 430 bool 431 EnableBreakpointByID (lldb::break_id_t break_id); 432 433 bool 434 RemoveBreakpointByID (lldb::break_id_t break_id); 435 436 // The flag 'end_to_end', default to true, signifies that the operation is 437 // performed end to end, for both the debugger and the debuggee. 438 439 bool 440 RemoveAllWatchpoints (bool end_to_end = true); 441 442 bool 443 DisableAllWatchpoints (bool end_to_end = true); 444 445 bool 446 EnableAllWatchpoints (bool end_to_end = true); 447 448 bool 449 ClearAllWatchpointHitCounts (); 450 451 bool 452 IgnoreAllWatchpoints (uint32_t ignore_count); 453 454 bool 455 DisableWatchpointByID (lldb::watch_id_t watch_id); 456 457 bool 458 EnableWatchpointByID (lldb::watch_id_t watch_id); 459 460 bool 461 RemoveWatchpointByID (lldb::watch_id_t watch_id); 462 463 bool 464 IgnoreWatchpointByID (lldb::watch_id_t watch_id, uint32_t ignore_count); 465 466 void 467 ModulesDidLoad (ModuleList &module_list); 468 469 void 470 ModulesDidUnload (ModuleList &module_list); 471 472 473 //------------------------------------------------------------------ 474 /// Get \a load_addr as a callable code load address for this target 475 /// 476 /// Take \a load_addr and potentially add any address bits that are 477 /// needed to make the address callable. For ARM this can set bit 478 /// zero (if it already isn't) if \a load_addr is a thumb function. 479 /// If \a addr_class is set to eAddressClassInvalid, then the address 480 /// adjustment will always happen. If it is set to an address class 481 /// that doesn't have code in it, LLDB_INVALID_ADDRESS will be 482 /// returned. 483 //------------------------------------------------------------------ 484 lldb::addr_t 485 GetCallableLoadAddress (lldb::addr_t load_addr, lldb::AddressClass addr_class = lldb::eAddressClassInvalid) const; 486 487 //------------------------------------------------------------------ 488 /// Get \a load_addr as an opcode for this target. 489 /// 490 /// Take \a load_addr and potentially strip any address bits that are 491 /// needed to make the address point to an opcode. For ARM this can 492 /// clear bit zero (if it already isn't) if \a load_addr is a 493 /// thumb function and load_addr is in code. 494 /// If \a addr_class is set to eAddressClassInvalid, then the address 495 /// adjustment will always happen. If it is set to an address class 496 /// that doesn't have code in it, LLDB_INVALID_ADDRESS will be 497 /// returned. 498 //------------------------------------------------------------------ 499 lldb::addr_t 500 GetOpcodeLoadAddress (lldb::addr_t load_addr, lldb::AddressClass addr_class = lldb::eAddressClassInvalid) const; 501 502protected: 503 void 504 ModuleAdded (lldb::ModuleSP &module_sp); 505 506 void 507 ModuleUpdated (lldb::ModuleSP &old_module_sp, lldb::ModuleSP &new_module_sp); 508 509public: 510 //------------------------------------------------------------------ 511 /// Gets the module for the main executable. 512 /// 513 /// Each process has a notion of a main executable that is the file 514 /// that will be executed or attached to. Executable files can have 515 /// dependent modules that are discovered from the object files, or 516 /// discovered at runtime as things are dynamically loaded. 517 /// 518 /// @return 519 /// The shared pointer to the executable module which can 520 /// contains a NULL Module object if no executable has been 521 /// set. 522 /// 523 /// @see DynamicLoader 524 /// @see ObjectFile::GetDependentModules (FileSpecList&) 525 /// @see Process::SetExecutableModule(lldb::ModuleSP&) 526 //------------------------------------------------------------------ 527 lldb::ModuleSP 528 GetExecutableModule (); 529 530 Module* 531 GetExecutableModulePointer (); 532 533 //------------------------------------------------------------------ 534 /// Set the main executable module. 535 /// 536 /// Each process has a notion of a main executable that is the file 537 /// that will be executed or attached to. Executable files can have 538 /// dependent modules that are discovered from the object files, or 539 /// discovered at runtime as things are dynamically loaded. 540 /// 541 /// Setting the executable causes any of the current dependant 542 /// image information to be cleared and replaced with the static 543 /// dependent image information found by calling 544 /// ObjectFile::GetDependentModules (FileSpecList&) on the main 545 /// executable and any modules on which it depends. Calling 546 /// Process::GetImages() will return the newly found images that 547 /// were obtained from all of the object files. 548 /// 549 /// @param[in] module_sp 550 /// A shared pointer reference to the module that will become 551 /// the main executable for this process. 552 /// 553 /// @param[in] get_dependent_files 554 /// If \b true then ask the object files to track down any 555 /// known dependent files. 556 /// 557 /// @see ObjectFile::GetDependentModules (FileSpecList&) 558 /// @see Process::GetImages() 559 //------------------------------------------------------------------ 560 void 561 SetExecutableModule (lldb::ModuleSP& module_sp, bool get_dependent_files); 562 563 //------------------------------------------------------------------ 564 /// Get accessor for the images for this process. 565 /// 566 /// Each process has a notion of a main executable that is the file 567 /// that will be executed or attached to. Executable files can have 568 /// dependent modules that are discovered from the object files, or 569 /// discovered at runtime as things are dynamically loaded. After 570 /// a main executable has been set, the images will contain a list 571 /// of all the files that the executable depends upon as far as the 572 /// object files know. These images will usually contain valid file 573 /// virtual addresses only. When the process is launched or attached 574 /// to, the DynamicLoader plug-in will discover where these images 575 /// were loaded in memory and will resolve the load virtual 576 /// addresses is each image, and also in images that are loaded by 577 /// code. 578 /// 579 /// @return 580 /// A list of Module objects in a module list. 581 //------------------------------------------------------------------ 582 ModuleList& 583 GetImages () 584 { 585 return m_images; 586 } 587 588 const ModuleList& 589 GetImages () const 590 { 591 return m_images; 592 } 593 594 595 //------------------------------------------------------------------ 596 /// Return whether this FileSpec corresponds to a module that should be considered for general searches. 597 /// 598 /// This API will be consulted by the SearchFilterForNonModuleSpecificSearches 599 /// and any module that returns \b true will not be searched. Note the 600 /// SearchFilterForNonModuleSpecificSearches is the search filter that 601 /// gets used in the CreateBreakpoint calls when no modules is provided. 602 /// 603 /// The target call at present just consults the Platform's call of the 604 /// same name. 605 /// 606 /// @param[in] module_sp 607 /// A shared pointer reference to the module that checked. 608 /// 609 /// @return \b true if the module should be excluded, \b false otherwise. 610 //------------------------------------------------------------------ 611 bool 612 ModuleIsExcludedForNonModuleSpecificSearches (const FileSpec &module_spec); 613 614 //------------------------------------------------------------------ 615 /// Return whether this module should be considered for general searches. 616 /// 617 /// This API will be consulted by the SearchFilterForNonModuleSpecificSearches 618 /// and any module that returns \b true will not be searched. Note the 619 /// SearchFilterForNonModuleSpecificSearches is the search filter that 620 /// gets used in the CreateBreakpoint calls when no modules is provided. 621 /// 622 /// The target call at present just consults the Platform's call of the 623 /// same name. 624 /// 625 /// FIXME: When we get time we should add a way for the user to set modules that they 626 /// don't want searched, in addition to or instead of the platform ones. 627 /// 628 /// @param[in] module_sp 629 /// A shared pointer reference to the module that checked. 630 /// 631 /// @return \b true if the module should be excluded, \b false otherwise. 632 //------------------------------------------------------------------ 633 bool 634 ModuleIsExcludedForNonModuleSpecificSearches (const lldb::ModuleSP &module_sp); 635 636 ArchSpec & 637 GetArchitecture () 638 { 639 return m_arch; 640 } 641 642 const ArchSpec & 643 GetArchitecture () const 644 { 645 return m_arch; 646 } 647 648 //------------------------------------------------------------------ 649 /// Set the architecture for this target. 650 /// 651 /// If the current target has no Images read in, then this just sets the architecture, which will 652 /// be used to select the architecture of the ExecutableModule when that is set. 653 /// If the current target has an ExecutableModule, then calling SetArchitecture with a different 654 /// architecture from the currently selected one will reset the ExecutableModule to that slice 655 /// of the file backing the ExecutableModule. If the file backing the ExecutableModule does not 656 /// contain a fork of this architecture, then this code will return false, and the architecture 657 /// won't be changed. 658 /// If the input arch_spec is the same as the already set architecture, this is a no-op. 659 /// 660 /// @param[in] arch_spec 661 /// The new architecture. 662 /// 663 /// @return 664 /// \b true if the architecture was successfully set, \bfalse otherwise. 665 //------------------------------------------------------------------ 666 bool 667 SetArchitecture (const ArchSpec &arch_spec); 668 669 Debugger & 670 GetDebugger () 671 { 672 return m_debugger; 673 } 674 675 size_t 676 ReadMemoryFromFileCache (const Address& addr, 677 void *dst, 678 size_t dst_len, 679 Error &error); 680 681 // Reading memory through the target allows us to skip going to the process 682 // for reading memory if possible and it allows us to try and read from 683 // any constant sections in our object files on disk. If you always want 684 // live program memory, read straight from the process. If you possibly 685 // want to read from const sections in object files, read from the target. 686 // This version of ReadMemory will try and read memory from the process 687 // if the process is alive. The order is: 688 // 1 - if (prefer_file_cache == true) then read from object file cache 689 // 2 - if there is a valid process, try and read from its memory 690 // 3 - if (prefer_file_cache == false) then read from object file cache 691 size_t 692 ReadMemory (const Address& addr, 693 bool prefer_file_cache, 694 void *dst, 695 size_t dst_len, 696 Error &error, 697 lldb::addr_t *load_addr_ptr = NULL); 698 699 size_t 700 ReadScalarIntegerFromMemory (const Address& addr, 701 bool prefer_file_cache, 702 uint32_t byte_size, 703 bool is_signed, 704 Scalar &scalar, 705 Error &error); 706 707 uint64_t 708 ReadUnsignedIntegerFromMemory (const Address& addr, 709 bool prefer_file_cache, 710 size_t integer_byte_size, 711 uint64_t fail_value, 712 Error &error); 713 714 bool 715 ReadPointerFromMemory (const Address& addr, 716 bool prefer_file_cache, 717 Error &error, 718 Address &pointer_addr); 719 720 SectionLoadList& 721 GetSectionLoadList() 722 { 723 return m_section_load_list; 724 } 725 726 const SectionLoadList& 727 GetSectionLoadList() const 728 { 729 return m_section_load_list; 730 } 731 732 static Target * 733 GetTargetFromContexts (const ExecutionContext *exe_ctx_ptr, 734 const SymbolContext *sc_ptr); 735 736 //------------------------------------------------------------------ 737 // lldb::ExecutionContextScope pure virtual functions 738 //------------------------------------------------------------------ 739 virtual lldb::TargetSP 740 CalculateTarget (); 741 742 virtual lldb::ProcessSP 743 CalculateProcess (); 744 745 virtual lldb::ThreadSP 746 CalculateThread (); 747 748 virtual lldb::StackFrameSP 749 CalculateStackFrame (); 750 751 virtual void 752 CalculateExecutionContext (ExecutionContext &exe_ctx); 753 754 PathMappingList & 755 GetImageSearchPathList (); 756 757 ClangASTContext * 758 GetScratchClangASTContext(bool create_on_demand=true); 759 760 ClangASTImporter * 761 GetClangASTImporter(); 762 763 // Since expressions results can persist beyond the lifetime of a process, 764 // and the const expression results are available after a process is gone, 765 // we provide a way for expressions to be evaluated from the Target itself. 766 // If an expression is going to be run, then it should have a frame filled 767 // in in th execution context. 768 ExecutionResults 769 EvaluateExpression (const char *expression, 770 StackFrame *frame, 771 lldb_private::ExecutionPolicy execution_policy, 772 bool coerce_to_id, 773 bool unwind_on_error, 774 bool keep_in_memory, 775 lldb::DynamicValueType use_dynamic, 776 lldb::ValueObjectSP &result_valobj_sp, 777 uint32_t single_thread_timeout_usec = 500000); 778 779 ClangPersistentVariables & 780 GetPersistentVariables() 781 { 782 return m_persistent_variables; 783 } 784 785 //------------------------------------------------------------------ 786 // Target Stop Hooks 787 //------------------------------------------------------------------ 788 class StopHook : public UserID 789 { 790 public: 791 ~StopHook (); 792 793 StopHook (const StopHook &rhs); 794 795 StringList * 796 GetCommandPointer () 797 { 798 return &m_commands; 799 } 800 801 const StringList & 802 GetCommands() 803 { 804 return m_commands; 805 } 806 807 lldb::TargetSP & 808 GetTarget() 809 { 810 return m_target_sp; 811 } 812 813 void 814 SetCommands (StringList &in_commands) 815 { 816 m_commands = in_commands; 817 } 818 819 // Set the specifier. The stop hook will own the specifier, and is responsible for deleting it when we're done. 820 void 821 SetSpecifier (SymbolContextSpecifier *specifier) 822 { 823 m_specifier_sp.reset (specifier); 824 } 825 826 SymbolContextSpecifier * 827 GetSpecifier () 828 { 829 return m_specifier_sp.get(); 830 } 831 832 // Set the Thread Specifier. The stop hook will own the thread specifier, and is responsible for deleting it when we're done. 833 void 834 SetThreadSpecifier (ThreadSpec *specifier); 835 836 ThreadSpec * 837 GetThreadSpecifier() 838 { 839 return m_thread_spec_ap.get(); 840 } 841 842 bool 843 IsActive() 844 { 845 return m_active; 846 } 847 848 void 849 SetIsActive (bool is_active) 850 { 851 m_active = is_active; 852 } 853 854 void 855 GetDescription (Stream *s, lldb::DescriptionLevel level) const; 856 857 private: 858 lldb::TargetSP m_target_sp; 859 StringList m_commands; 860 lldb::SymbolContextSpecifierSP m_specifier_sp; 861 std::auto_ptr<ThreadSpec> m_thread_spec_ap; 862 bool m_active; 863 864 // Use AddStopHook to make a new empty stop hook. The GetCommandPointer and fill it with commands, 865 // and SetSpecifier to set the specifier shared pointer (can be null, that will match anything.) 866 StopHook (lldb::TargetSP target_sp, lldb::user_id_t uid); 867 friend class Target; 868 }; 869 typedef STD_SHARED_PTR(StopHook) StopHookSP; 870 871 // Add an empty stop hook to the Target's stop hook list, and returns a shared pointer to it in new_hook. 872 // Returns the id of the new hook. 873 lldb::user_id_t 874 AddStopHook (StopHookSP &new_hook); 875 876 void 877 RunStopHooks (); 878 879 size_t 880 GetStopHookSize(); 881 882 bool 883 SetSuppresStopHooks (bool suppress) 884 { 885 bool old_value = m_suppress_stop_hooks; 886 m_suppress_stop_hooks = suppress; 887 return old_value; 888 } 889 890 bool 891 GetSuppressStopHooks () 892 { 893 return m_suppress_stop_hooks; 894 } 895 896 bool 897 SetSuppressSyntheticValue (bool suppress) 898 { 899 bool old_value = m_suppress_synthetic_value; 900 m_suppress_synthetic_value = suppress; 901 return old_value; 902 } 903 904 bool 905 GetSuppressSyntheticValue () 906 { 907 return m_suppress_synthetic_value; 908 } 909 910// StopHookSP & 911// GetStopHookByIndex (size_t index); 912// 913 bool 914 RemoveStopHookByID (lldb::user_id_t uid); 915 916 void 917 RemoveAllStopHooks (); 918 919 StopHookSP 920 GetStopHookByID (lldb::user_id_t uid); 921 922 bool 923 SetStopHookActiveStateByID (lldb::user_id_t uid, bool active_state); 924 925 void 926 SetAllStopHooksActiveState (bool active_state); 927 928 size_t GetNumStopHooks () const 929 { 930 return m_stop_hooks.size(); 931 } 932 933 StopHookSP 934 GetStopHookAtIndex (size_t index) 935 { 936 if (index >= GetNumStopHooks()) 937 return StopHookSP(); 938 StopHookCollection::iterator pos = m_stop_hooks.begin(); 939 940 while (index > 0) 941 { 942 pos++; 943 index--; 944 } 945 return (*pos).second; 946 } 947 948 lldb::PlatformSP 949 GetPlatform () 950 { 951 return m_platform_sp; 952 } 953 954 void 955 SetPlatform (const lldb::PlatformSP &platform_sp) 956 { 957 m_platform_sp = platform_sp; 958 } 959 960 SourceManager & 961 GetSourceManager () 962 { 963 return m_source_manager; 964 } 965 966 //------------------------------------------------------------------ 967 // Methods. 968 //------------------------------------------------------------------ 969 lldb::SearchFilterSP 970 GetSearchFilterForModule (const FileSpec *containingModule); 971 972 lldb::SearchFilterSP 973 GetSearchFilterForModuleList (const FileSpecList *containingModuleList); 974 975 lldb::SearchFilterSP 976 GetSearchFilterForModuleAndCUList (const FileSpecList *containingModules, const FileSpecList *containingSourceFiles); 977 978protected: 979 //------------------------------------------------------------------ 980 // Member variables. 981 //------------------------------------------------------------------ 982 Debugger & m_debugger; 983 lldb::PlatformSP m_platform_sp; ///< The platform for this target. 984 Mutex m_mutex; ///< An API mutex that is used by the lldb::SB* classes make the SB interface thread safe 985 ArchSpec m_arch; 986 ModuleList m_images; ///< The list of images for this process (shared libraries and anything dynamically loaded). 987 SectionLoadList m_section_load_list; 988 BreakpointList m_breakpoint_list; 989 BreakpointList m_internal_breakpoint_list; 990 lldb::BreakpointSP m_last_created_breakpoint; 991 WatchpointList m_watchpoint_list; 992 lldb::WatchpointSP m_last_created_watchpoint; 993 // We want to tightly control the process destruction process so 994 // we can correctly tear down everything that we need to, so the only 995 // class that knows about the process lifespan is this target class. 996 lldb::ProcessSP m_process_sp; 997 bool m_valid; 998 lldb::SearchFilterSP m_search_filter_sp; 999 PathMappingList m_image_search_paths; 1000 std::auto_ptr<ClangASTContext> m_scratch_ast_context_ap; 1001 std::auto_ptr<ClangASTSource> m_scratch_ast_source_ap; 1002 std::auto_ptr<ClangASTImporter> m_ast_importer_ap; 1003 ClangPersistentVariables m_persistent_variables; ///< These are the persistent variables associated with this process for the expression parser. 1004 1005 SourceManager m_source_manager; 1006 1007 typedef std::map<lldb::user_id_t, StopHookSP> StopHookCollection; 1008 StopHookCollection m_stop_hooks; 1009 lldb::user_id_t m_stop_hook_next_id; 1010 bool m_suppress_stop_hooks; 1011 bool m_suppress_synthetic_value; 1012 1013 static void 1014 ImageSearchPathsChanged (const PathMappingList &path_list, 1015 void *baton); 1016 1017private: 1018 DISALLOW_COPY_AND_ASSIGN (Target); 1019}; 1020 1021} // namespace lldb_private 1022 1023#endif // liblldb_Target_h_ 1024