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