1 //===-- Target.h ------------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_Target_h_
11 #define liblldb_Target_h_
17 // Other libraries and framework includes
19 #include "lldb/lldb-public.h"
20 #include "lldb/Breakpoint/BreakpointList.h"
21 #include "lldb/Breakpoint/BreakpointLocationCollection.h"
22 #include "lldb/Breakpoint/WatchpointList.h"
23 #include "lldb/Core/ArchSpec.h"
24 #include "lldb/Core/Broadcaster.h"
25 #include "lldb/Core/Disassembler.h"
26 #include "lldb/Core/Event.h"
27 #include "lldb/Core/ModuleList.h"
28 #include "lldb/Core/UserSettingsController.h"
29 #include "lldb/Expression/ClangPersistentVariables.h"
30 #include "lldb/Interpreter/Args.h"
31 #include "lldb/Interpreter/OptionValueBoolean.h"
32 #include "lldb/Interpreter/OptionValueEnumeration.h"
33 #include "lldb/Interpreter/OptionValueFileSpec.h"
34 #include "lldb/Symbol/SymbolContext.h"
35 #include "lldb/Target/ABI.h"
36 #include "lldb/Target/ExecutionContextScope.h"
37 #include "lldb/Target/PathMappingList.h"
38 #include "lldb/Target/SectionLoadHistory.h"
40 namespace lldb_private {
42 extern OptionEnumValueElement g_dynamic_value_types[];
44 typedef enum InlineStrategy
46 eInlineBreakpointsNever = 0,
47 eInlineBreakpointsHeaders,
48 eInlineBreakpointsAlways
51 typedef enum LoadScriptFromSymFile
53 eLoadScriptFromSymFileTrue,
54 eLoadScriptFromSymFileFalse,
55 eLoadScriptFromSymFileWarn
56 } LoadScriptFromSymFile;
58 //----------------------------------------------------------------------
60 //----------------------------------------------------------------------
61 class TargetProperties : public Properties
64 TargetProperties(Target *target);
70 GetDefaultArchitecture () const;
73 SetDefaultArchitecture (const ArchSpec& arch);
75 lldb::DynamicValueType
76 GetPreferDynamicValue() const;
79 GetDisableASLR () const;
82 SetDisableASLR (bool b);
85 GetDisableSTDIO () const;
88 SetDisableSTDIO (bool b);
91 GetDisassemblyFlavor() const;
94 // SetDisassemblyFlavor(const char *flavor);
97 GetInlineStrategy () const;
103 SetArg0 (const char *arg);
106 GetRunArguments (Args &args) const;
109 SetRunArguments (const Args &args);
112 GetEnvironmentAsArgs (Args &env) const;
115 GetSkipPrologue() const;
118 GetSourcePathMap () const;
121 GetExecutableSearchPaths ();
124 GetDebugFileSearchPaths ();
127 GetEnableSyntheticValue () const;
130 GetMaximumNumberOfChildrenToDisplay() const;
133 GetMaximumSizeOfStringSummary() const;
136 GetMaximumMemReadSize () const;
139 GetStandardInputPath () const;
142 SetStandardInputPath (const char *path);
145 GetStandardOutputPath () const;
148 SetStandardOutputPath (const char *path);
151 GetStandardErrorPath () const;
154 SetStandardErrorPath (const char *path);
157 GetBreakpointsConsultPlatformAvoidList ();
160 GetExpressionPrefixContentsAsCString ();
163 GetUseHexImmediates() const;
166 GetUseFastStepping() const;
169 GetDisplayExpressionsInCrashlogs () const;
171 LoadScriptFromSymFile
172 GetLoadScriptFromSymbolFile() const;
174 Disassembler::HexImmediateStyle
175 GetHexImmediateStyle() const;
177 MemoryModuleLoadLevel
178 GetMemoryModuleLoadLevel() const;
181 GetUserSpecifiedTrapHandlerNames (Args &args) const;
184 SetUserSpecifiedTrapHandlerNames (const Args &args);
187 typedef std::shared_ptr<TargetProperties> TargetPropertiesSP;
189 class EvaluateExpressionOptions
192 static const uint32_t default_timeout = 500000;
193 EvaluateExpressionOptions() :
194 m_execution_policy(eExecutionPolicyOnlyWhenNeeded),
195 m_language (lldb::eLanguageTypeUnknown),
196 m_coerce_to_id(false),
197 m_unwind_on_error(true),
198 m_ignore_breakpoints (false),
199 m_keep_in_memory(false),
203 m_trap_exceptions(true),
204 m_use_dynamic(lldb::eNoDynamicValues),
205 m_timeout_usec(default_timeout)
209 GetExecutionPolicy () const
211 return m_execution_policy;
215 SetExecutionPolicy (ExecutionPolicy policy = eExecutionPolicyAlways)
217 m_execution_policy = policy;
227 SetLanguage(lldb::LanguageType language)
229 m_language = language;
233 DoesCoerceToId () const
235 return m_coerce_to_id;
239 SetCoerceToId (bool coerce = true)
241 m_coerce_to_id = coerce;
245 DoesUnwindOnError () const
247 return m_unwind_on_error;
251 SetUnwindOnError (bool unwind = false)
253 m_unwind_on_error = unwind;
257 DoesIgnoreBreakpoints () const
259 return m_ignore_breakpoints;
263 SetIgnoreBreakpoints (bool ignore = false)
265 m_ignore_breakpoints = ignore;
269 DoesKeepInMemory () const
271 return m_keep_in_memory;
275 SetKeepInMemory (bool keep = true)
277 m_keep_in_memory = keep;
280 lldb::DynamicValueType
281 GetUseDynamic () const
283 return m_use_dynamic;
287 SetUseDynamic (lldb::DynamicValueType dynamic = lldb::eDynamicCanRunTarget)
289 m_use_dynamic = dynamic;
293 GetTimeoutUsec () const
295 return m_timeout_usec;
299 SetTimeoutUsec (uint32_t timeout = 0)
301 m_timeout_usec = timeout;
305 GetTryAllThreads () const
311 SetTryAllThreads (bool try_others = true)
313 m_try_others = try_others;
317 GetStopOthers () const
319 return m_stop_others;
323 SetStopOthers (bool stop_others = true)
325 m_stop_others = stop_others;
341 GetTrapExceptions() const
343 return m_trap_exceptions;
347 SetTrapExceptions (bool b)
349 m_trap_exceptions = b;
353 ExecutionPolicy m_execution_policy;
354 lldb::LanguageType m_language;
356 bool m_unwind_on_error;
357 bool m_ignore_breakpoints;
358 bool m_keep_in_memory;
362 bool m_trap_exceptions;
363 lldb::DynamicValueType m_use_dynamic;
364 uint32_t m_timeout_usec;
367 //----------------------------------------------------------------------
369 //----------------------------------------------------------------------
371 public std::enable_shared_from_this<Target>,
372 public TargetProperties,
374 public ExecutionContextScope,
375 public ModuleList::Notifier
378 friend class TargetList;
380 //------------------------------------------------------------------
381 /// Broadcaster event bits definitions.
382 //------------------------------------------------------------------
385 eBroadcastBitBreakpointChanged = (1 << 0),
386 eBroadcastBitModulesLoaded = (1 << 1),
387 eBroadcastBitModulesUnloaded = (1 << 2),
388 eBroadcastBitWatchpointChanged = (1 << 3),
389 eBroadcastBitSymbolsLoaded = (1 << 4)
392 // These two functions fill out the Broadcaster interface:
394 static ConstString &GetStaticBroadcasterClass ();
396 virtual ConstString &GetBroadcasterClass() const
398 return GetStaticBroadcasterClass();
401 // This event data class is for use by the TargetList to broadcast new target notifications.
402 class TargetEventData : public EventData
406 static const ConstString &
409 virtual const ConstString &
412 TargetEventData (const lldb::TargetSP &new_target_sp);
424 Dump (Stream *s) const;
426 static const lldb::TargetSP
427 GetTargetFromEvent (const lldb::EventSP &event_sp);
429 static const TargetEventData *
430 GetEventDataFromEvent (const Event *event_sp);
433 lldb::TargetSP m_target_sp;
435 DISALLOW_COPY_AND_ASSIGN (TargetEventData);
439 SettingsInitialize ();
442 SettingsTerminate ();
444 // static lldb::UserSettingsControllerSP &
445 // GetSettingsController ();
448 GetDefaultExecutableSearchPaths ();
451 GetDefaultDebugFileSearchPaths ();
454 GetDefaultArchitecture ();
457 SetDefaultArchitecture (const ArchSpec &arch);
460 // UpdateInstanceName ();
463 GetSharedModule (const ModuleSpec &module_spec,
464 Error *error_ptr = NULL);
466 //----------------------------------------------------------------------
467 // Settings accessors
468 //----------------------------------------------------------------------
470 static const TargetPropertiesSP &
471 GetGlobalProperties();
475 //------------------------------------------------------------------
476 /// Construct with optional file and arch.
478 /// This member is private. Clients must use
479 /// TargetList::CreateTarget(const FileSpec*, const ArchSpec*)
480 /// so all targets can be tracked from the central target list.
482 /// @see TargetList::CreateTarget(const FileSpec*, const ArchSpec*)
483 //------------------------------------------------------------------
484 Target (Debugger &debugger,
485 const ArchSpec &target_arch,
486 const lldb::PlatformSP &platform_sp);
502 DeleteCurrentProcess ();
506 //------------------------------------------------------------------
507 /// Dump a description of this object to a Stream.
509 /// Dump a description of the contents of this object to the
510 /// supplied stream \a s. The dumped content will be only what has
511 /// been loaded or parsed up to this point at which this function
512 /// is called, so this is a good way to see what has been parsed
516 /// The stream to which to dump the object descripton.
517 //------------------------------------------------------------------
519 Dump (Stream *s, lldb::DescriptionLevel description_level);
521 const lldb::ProcessSP &
522 CreateProcess (Listener &listener,
523 const char *plugin_name,
524 const FileSpec *crash_file);
526 const lldb::ProcessSP &
527 GetProcessSP () const;
539 Launch (Listener &listener,
540 ProcessLaunchInfo &launch_info);
542 //------------------------------------------------------------------
543 // This part handles the breakpoints.
544 //------------------------------------------------------------------
547 GetBreakpointList(bool internal = false);
549 const BreakpointList &
550 GetBreakpointList(bool internal = false) const;
553 GetLastCreatedBreakpoint ()
555 return m_last_created_breakpoint;
559 GetBreakpointByID (lldb::break_id_t break_id);
561 // Use this to create a file and line breakpoint to a given module or all module it is NULL
563 CreateBreakpoint (const FileSpecList *containingModules,
564 const FileSpec &file,
566 LazyBool check_inlines,
567 LazyBool skip_prologue,
569 bool request_hardware);
571 // Use this to create breakpoint that matches regex against the source lines in files given in source_file_list:
573 CreateSourceRegexBreakpoint (const FileSpecList *containingModules,
574 const FileSpecList *source_file_list,
575 RegularExpression &source_regex,
577 bool request_hardware);
579 // Use this to create a breakpoint from a load address
581 CreateBreakpoint (lldb::addr_t load_addr,
583 bool request_hardware);
585 // Use this to create Address breakpoints:
587 CreateBreakpoint (Address &addr,
589 bool request_hardware);
591 // Use this to create a function breakpoint by regexp in containingModule/containingSourceFiles, or all modules if it is NULL
592 // When "skip_prologue is set to eLazyBoolCalculate, we use the current target
593 // setting, else we use the values passed in
595 CreateFuncRegexBreakpoint (const FileSpecList *containingModules,
596 const FileSpecList *containingSourceFiles,
597 RegularExpression &func_regexp,
598 LazyBool skip_prologue,
600 bool request_hardware);
602 // Use this to create a function breakpoint by name in containingModule, or all modules if it is NULL
603 // When "skip_prologue is set to eLazyBoolCalculate, we use the current target
604 // setting, else we use the values passed in
606 CreateBreakpoint (const FileSpecList *containingModules,
607 const FileSpecList *containingSourceFiles,
608 const char *func_name,
609 uint32_t func_name_type_mask,
610 LazyBool skip_prologue,
612 bool request_hardware);
615 CreateExceptionBreakpoint (enum lldb::LanguageType language, bool catch_bp, bool throw_bp, bool internal);
617 // This is the same as the func_name breakpoint except that you can specify a vector of names. This is cheaper
618 // than a regular expression breakpoint in the case where you just want to set a breakpoint on a set of names
621 CreateBreakpoint (const FileSpecList *containingModules,
622 const FileSpecList *containingSourceFiles,
623 const char *func_names[],
625 uint32_t func_name_type_mask,
626 LazyBool skip_prologue,
628 bool request_hardware);
631 CreateBreakpoint (const FileSpecList *containingModules,
632 const FileSpecList *containingSourceFiles,
633 const std::vector<std::string> &func_names,
634 uint32_t func_name_type_mask,
635 LazyBool skip_prologue,
637 bool request_hardware);
640 // Use this to create a general breakpoint:
642 CreateBreakpoint (lldb::SearchFilterSP &filter_sp,
643 lldb::BreakpointResolverSP &resolver_sp,
645 bool request_hardware,
646 bool resolve_indirect_symbols);
648 // Use this to create a watchpoint:
650 CreateWatchpoint (lldb::addr_t addr,
652 const ClangASTType *type,
657 GetLastCreatedWatchpoint ()
659 return m_last_created_watchpoint;
665 return m_watchpoint_list;
669 RemoveAllBreakpoints (bool internal_also = false);
672 DisableAllBreakpoints (bool internal_also = false);
675 EnableAllBreakpoints (bool internal_also = false);
678 DisableBreakpointByID (lldb::break_id_t break_id);
681 EnableBreakpointByID (lldb::break_id_t break_id);
684 RemoveBreakpointByID (lldb::break_id_t break_id);
686 // The flag 'end_to_end', default to true, signifies that the operation is
687 // performed end to end, for both the debugger and the debuggee.
690 RemoveAllWatchpoints (bool end_to_end = true);
693 DisableAllWatchpoints (bool end_to_end = true);
696 EnableAllWatchpoints (bool end_to_end = true);
699 ClearAllWatchpointHitCounts ();
702 IgnoreAllWatchpoints (uint32_t ignore_count);
705 DisableWatchpointByID (lldb::watch_id_t watch_id);
708 EnableWatchpointByID (lldb::watch_id_t watch_id);
711 RemoveWatchpointByID (lldb::watch_id_t watch_id);
714 IgnoreWatchpointByID (lldb::watch_id_t watch_id, uint32_t ignore_count);
716 //------------------------------------------------------------------
717 /// Get \a load_addr as a callable code load address for this target
719 /// Take \a load_addr and potentially add any address bits that are
720 /// needed to make the address callable. For ARM this can set bit
721 /// zero (if it already isn't) if \a load_addr is a thumb function.
722 /// If \a addr_class is set to eAddressClassInvalid, then the address
723 /// adjustment will always happen. If it is set to an address class
724 /// that doesn't have code in it, LLDB_INVALID_ADDRESS will be
726 //------------------------------------------------------------------
728 GetCallableLoadAddress (lldb::addr_t load_addr, lldb::AddressClass addr_class = lldb::eAddressClassInvalid) const;
730 //------------------------------------------------------------------
731 /// Get \a load_addr as an opcode for this target.
733 /// Take \a load_addr and potentially strip any address bits that are
734 /// needed to make the address point to an opcode. For ARM this can
735 /// clear bit zero (if it already isn't) if \a load_addr is a
736 /// thumb function and load_addr is in code.
737 /// If \a addr_class is set to eAddressClassInvalid, then the address
738 /// adjustment will always happen. If it is set to an address class
739 /// that doesn't have code in it, LLDB_INVALID_ADDRESS will be
741 //------------------------------------------------------------------
743 GetOpcodeLoadAddress (lldb::addr_t load_addr, lldb::AddressClass addr_class = lldb::eAddressClassInvalid) const;
746 //------------------------------------------------------------------
747 /// Implementing of ModuleList::Notifier.
748 //------------------------------------------------------------------
751 ModuleAdded (const ModuleList& module_list, const lldb::ModuleSP& module_sp);
754 ModuleRemoved (const ModuleList& module_list, const lldb::ModuleSP& module_sp);
757 ModuleUpdated (const ModuleList& module_list,
758 const lldb::ModuleSP& old_module_sp,
759 const lldb::ModuleSP& new_module_sp);
761 WillClearList (const ModuleList& module_list);
766 ModulesDidLoad (ModuleList &module_list);
769 ModulesDidUnload (ModuleList &module_list, bool delete_locations);
772 SymbolsDidLoad (ModuleList &module_list);
775 ClearModules(bool delete_locations);
777 //------------------------------------------------------------------
778 /// Called as the last function in Process::DidExec().
780 /// Process::DidExec() will clear a lot of state in the process,
781 /// then try to reload a dynamic loader plugin to discover what
782 /// binaries are currently available and then this function should
783 /// be called to allow the target to do any cleanup after everything
784 /// has been figured out. It can remove breakpoints that no longer
785 /// make sense as the exec might have changed the target
786 /// architecture, and unloaded some modules that might get deleted.
787 //------------------------------------------------------------------
791 //------------------------------------------------------------------
792 /// Gets the module for the main executable.
794 /// Each process has a notion of a main executable that is the file
795 /// that will be executed or attached to. Executable files can have
796 /// dependent modules that are discovered from the object files, or
797 /// discovered at runtime as things are dynamically loaded.
800 /// The shared pointer to the executable module which can
801 /// contains a NULL Module object if no executable has been
804 /// @see DynamicLoader
805 /// @see ObjectFile::GetDependentModules (FileSpecList&)
806 /// @see Process::SetExecutableModule(lldb::ModuleSP&)
807 //------------------------------------------------------------------
809 GetExecutableModule ();
812 GetExecutableModulePointer ();
814 //------------------------------------------------------------------
815 /// Set the main executable module.
817 /// Each process has a notion of a main executable that is the file
818 /// that will be executed or attached to. Executable files can have
819 /// dependent modules that are discovered from the object files, or
820 /// discovered at runtime as things are dynamically loaded.
822 /// Setting the executable causes any of the current dependant
823 /// image information to be cleared and replaced with the static
824 /// dependent image information found by calling
825 /// ObjectFile::GetDependentModules (FileSpecList&) on the main
826 /// executable and any modules on which it depends. Calling
827 /// Process::GetImages() will return the newly found images that
828 /// were obtained from all of the object files.
830 /// @param[in] module_sp
831 /// A shared pointer reference to the module that will become
832 /// the main executable for this process.
834 /// @param[in] get_dependent_files
835 /// If \b true then ask the object files to track down any
836 /// known dependent files.
838 /// @see ObjectFile::GetDependentModules (FileSpecList&)
839 /// @see Process::GetImages()
840 //------------------------------------------------------------------
842 SetExecutableModule (lldb::ModuleSP& module_sp, bool get_dependent_files);
845 LoadScriptingResources (std::list<Error>& errors,
846 Stream* feedback_stream = NULL,
847 bool continue_on_error = true)
849 return m_images.LoadScriptingResourcesInTarget(this,errors,feedback_stream,continue_on_error);
852 //------------------------------------------------------------------
853 /// Get accessor for the images for this process.
855 /// Each process has a notion of a main executable that is the file
856 /// that will be executed or attached to. Executable files can have
857 /// dependent modules that are discovered from the object files, or
858 /// discovered at runtime as things are dynamically loaded. After
859 /// a main executable has been set, the images will contain a list
860 /// of all the files that the executable depends upon as far as the
861 /// object files know. These images will usually contain valid file
862 /// virtual addresses only. When the process is launched or attached
863 /// to, the DynamicLoader plug-in will discover where these images
864 /// were loaded in memory and will resolve the load virtual
865 /// addresses is each image, and also in images that are loaded by
869 /// A list of Module objects in a module list.
870 //------------------------------------------------------------------
883 //------------------------------------------------------------------
884 /// Return whether this FileSpec corresponds to a module that should be considered for general searches.
886 /// This API will be consulted by the SearchFilterForNonModuleSpecificSearches
887 /// and any module that returns \b true will not be searched. Note the
888 /// SearchFilterForNonModuleSpecificSearches is the search filter that
889 /// gets used in the CreateBreakpoint calls when no modules is provided.
891 /// The target call at present just consults the Platform's call of the
894 /// @param[in] module_sp
895 /// A shared pointer reference to the module that checked.
897 /// @return \b true if the module should be excluded, \b false otherwise.
898 //------------------------------------------------------------------
900 ModuleIsExcludedForNonModuleSpecificSearches (const FileSpec &module_spec);
902 //------------------------------------------------------------------
903 /// Return whether this module should be considered for general searches.
905 /// This API will be consulted by the SearchFilterForNonModuleSpecificSearches
906 /// and any module that returns \b true will not be searched. Note the
907 /// SearchFilterForNonModuleSpecificSearches is the search filter that
908 /// gets used in the CreateBreakpoint calls when no modules is provided.
910 /// The target call at present just consults the Platform's call of the
913 /// FIXME: When we get time we should add a way for the user to set modules that they
914 /// don't want searched, in addition to or instead of the platform ones.
916 /// @param[in] module_sp
917 /// A shared pointer reference to the module that checked.
919 /// @return \b true if the module should be excluded, \b false otherwise.
920 //------------------------------------------------------------------
922 ModuleIsExcludedForNonModuleSpecificSearches (const lldb::ModuleSP &module_sp);
931 GetArchitecture () const
936 //------------------------------------------------------------------
937 /// Set the architecture for this target.
939 /// If the current target has no Images read in, then this just sets the architecture, which will
940 /// be used to select the architecture of the ExecutableModule when that is set.
941 /// If the current target has an ExecutableModule, then calling SetArchitecture with a different
942 /// architecture from the currently selected one will reset the ExecutableModule to that slice
943 /// of the file backing the ExecutableModule. If the file backing the ExecutableModule does not
944 /// contain a fork of this architecture, then this code will return false, and the architecture
945 /// won't be changed.
946 /// If the input arch_spec is the same as the already set architecture, this is a no-op.
948 /// @param[in] arch_spec
949 /// The new architecture.
952 /// \b true if the architecture was successfully set, \bfalse otherwise.
953 //------------------------------------------------------------------
955 SetArchitecture (const ArchSpec &arch_spec);
964 ReadMemoryFromFileCache (const Address& addr,
969 // Reading memory through the target allows us to skip going to the process
970 // for reading memory if possible and it allows us to try and read from
971 // any constant sections in our object files on disk. If you always want
972 // live program memory, read straight from the process. If you possibly
973 // want to read from const sections in object files, read from the target.
974 // This version of ReadMemory will try and read memory from the process
975 // if the process is alive. The order is:
976 // 1 - if (prefer_file_cache == true) then read from object file cache
977 // 2 - if there is a valid process, try and read from its memory
978 // 3 - if (prefer_file_cache == false) then read from object file cache
980 ReadMemory (const Address& addr,
981 bool prefer_file_cache,
985 lldb::addr_t *load_addr_ptr = NULL);
988 ReadCStringFromMemory (const Address& addr, std::string &out_str, Error &error);
991 ReadCStringFromMemory (const Address& addr, char *dst, size_t dst_max_len, Error &result_error);
994 ReadScalarIntegerFromMemory (const Address& addr,
995 bool prefer_file_cache,
1002 ReadUnsignedIntegerFromMemory (const Address& addr,
1003 bool prefer_file_cache,
1004 size_t integer_byte_size,
1005 uint64_t fail_value,
1009 ReadPointerFromMemory (const Address& addr,
1010 bool prefer_file_cache,
1012 Address &pointer_addr);
1015 GetSectionLoadList()
1017 return m_section_load_history.GetCurrentSectionLoadList();
1020 // const SectionLoadList&
1021 // GetSectionLoadList() const
1023 // return const_cast<SectionLoadHistory *>(&m_section_load_history)->GetCurrentSectionLoadList();
1027 GetTargetFromContexts (const ExecutionContext *exe_ctx_ptr,
1028 const SymbolContext *sc_ptr);
1030 //------------------------------------------------------------------
1031 // lldb::ExecutionContextScope pure virtual functions
1032 //------------------------------------------------------------------
1033 virtual lldb::TargetSP
1036 virtual lldb::ProcessSP
1037 CalculateProcess ();
1039 virtual lldb::ThreadSP
1042 virtual lldb::StackFrameSP
1043 CalculateStackFrame ();
1046 CalculateExecutionContext (ExecutionContext &exe_ctx);
1049 GetImageSearchPathList ();
1052 GetScratchClangASTContext(bool create_on_demand=true);
1055 GetClangASTImporter();
1057 //----------------------------------------------------------------------
1058 // Install any files through the platform that need be to installed
1059 // prior to launching or attaching.
1060 //----------------------------------------------------------------------
1062 Install(ProcessLaunchInfo *launch_info);
1066 ResolveLoadAddress (lldb::addr_t load_addr,
1068 uint32_t stop_id = SectionLoadHistory::eStopIDNow);
1071 SetSectionLoadAddress (const lldb::SectionSP §ion,
1072 lldb::addr_t load_addr,
1073 bool warn_multiple = false);
1076 SetSectionUnloaded (const lldb::SectionSP §ion_sp);
1079 SetSectionUnloaded (const lldb::SectionSP §ion_sp, lldb::addr_t load_addr);
1082 ClearAllLoadedSections ();
1084 // Since expressions results can persist beyond the lifetime of a process,
1085 // and the const expression results are available after a process is gone,
1086 // we provide a way for expressions to be evaluated from the Target itself.
1087 // If an expression is going to be run, then it should have a frame filled
1088 // in in th execution context.
1090 EvaluateExpression (const char *expression,
1092 lldb::ValueObjectSP &result_valobj_sp,
1093 const EvaluateExpressionOptions& options = EvaluateExpressionOptions());
1095 ClangPersistentVariables &
1096 GetPersistentVariables()
1098 return m_persistent_variables;
1101 //------------------------------------------------------------------
1102 // Target Stop Hooks
1103 //------------------------------------------------------------------
1104 class StopHook : public UserID
1109 StopHook (const StopHook &rhs);
1112 GetCommandPointer ()
1130 SetCommands (StringList &in_commands)
1132 m_commands = in_commands;
1135 // Set the specifier. The stop hook will own the specifier, and is responsible for deleting it when we're done.
1137 SetSpecifier (SymbolContextSpecifier *specifier)
1139 m_specifier_sp.reset (specifier);
1142 SymbolContextSpecifier *
1145 return m_specifier_sp.get();
1148 // Set the Thread Specifier. The stop hook will own the thread specifier, and is responsible for deleting it when we're done.
1150 SetThreadSpecifier (ThreadSpec *specifier);
1153 GetThreadSpecifier()
1155 return m_thread_spec_ap.get();
1165 SetIsActive (bool is_active)
1167 m_active = is_active;
1171 GetDescription (Stream *s, lldb::DescriptionLevel level) const;
1174 lldb::TargetSP m_target_sp;
1175 StringList m_commands;
1176 lldb::SymbolContextSpecifierSP m_specifier_sp;
1177 std::unique_ptr<ThreadSpec> m_thread_spec_ap;
1180 // Use CreateStopHook to make a new empty stop hook. The GetCommandPointer and fill it with commands,
1181 // and SetSpecifier to set the specifier shared pointer (can be null, that will match anything.)
1182 StopHook (lldb::TargetSP target_sp, lldb::user_id_t uid);
1183 friend class Target;
1185 typedef std::shared_ptr<StopHook> StopHookSP;
1187 // Add an empty stop hook to the Target's stop hook list, and returns a shared pointer to it in new_hook.
1188 // Returns the id of the new hook.
1199 SetSuppresStopHooks (bool suppress)
1201 bool old_value = m_suppress_stop_hooks;
1202 m_suppress_stop_hooks = suppress;
1207 GetSuppressStopHooks ()
1209 return m_suppress_stop_hooks;
1213 // GetStopHookByIndex (size_t index);
1216 RemoveStopHookByID (lldb::user_id_t uid);
1219 RemoveAllStopHooks ();
1222 GetStopHookByID (lldb::user_id_t uid);
1225 SetStopHookActiveStateByID (lldb::user_id_t uid, bool active_state);
1228 SetAllStopHooksActiveState (bool active_state);
1230 size_t GetNumStopHooks () const
1232 return m_stop_hooks.size();
1236 GetStopHookAtIndex (size_t index)
1238 if (index >= GetNumStopHooks())
1239 return StopHookSP();
1240 StopHookCollection::iterator pos = m_stop_hooks.begin();
1247 return (*pos).second;
1253 return m_platform_sp;
1257 SetPlatform (const lldb::PlatformSP &platform_sp)
1259 m_platform_sp = platform_sp;
1263 GetSourceManager ();
1265 //------------------------------------------------------------------
1267 //------------------------------------------------------------------
1268 lldb::SearchFilterSP
1269 GetSearchFilterForModule (const FileSpec *containingModule);
1271 lldb::SearchFilterSP
1272 GetSearchFilterForModuleList (const FileSpecList *containingModuleList);
1274 lldb::SearchFilterSP
1275 GetSearchFilterForModuleAndCUList (const FileSpecList *containingModules, const FileSpecList *containingSourceFiles);
1278 //------------------------------------------------------------------
1279 // Member variables.
1280 //------------------------------------------------------------------
1281 Debugger & m_debugger;
1282 lldb::PlatformSP m_platform_sp; ///< The platform for this target.
1283 Mutex m_mutex; ///< An API mutex that is used by the lldb::SB* classes make the SB interface thread safe
1285 ModuleList m_images; ///< The list of images for this process (shared libraries and anything dynamically loaded).
1286 SectionLoadHistory m_section_load_history;
1287 BreakpointList m_breakpoint_list;
1288 BreakpointList m_internal_breakpoint_list;
1289 lldb::BreakpointSP m_last_created_breakpoint;
1290 WatchpointList m_watchpoint_list;
1291 lldb::WatchpointSP m_last_created_watchpoint;
1292 // We want to tightly control the process destruction process so
1293 // we can correctly tear down everything that we need to, so the only
1294 // class that knows about the process lifespan is this target class.
1295 lldb::ProcessSP m_process_sp;
1296 lldb::SearchFilterSP m_search_filter_sp;
1297 PathMappingList m_image_search_paths;
1298 std::unique_ptr<ClangASTContext> m_scratch_ast_context_ap;
1299 std::unique_ptr<ClangASTSource> m_scratch_ast_source_ap;
1300 std::unique_ptr<ClangASTImporter> m_ast_importer_ap;
1301 ClangPersistentVariables m_persistent_variables; ///< These are the persistent variables associated with this process for the expression parser.
1303 std::unique_ptr<SourceManager> m_source_manager_ap;
1305 typedef std::map<lldb::user_id_t, StopHookSP> StopHookCollection;
1306 StopHookCollection m_stop_hooks;
1307 lldb::user_id_t m_stop_hook_next_id;
1309 bool m_suppress_stop_hooks;
1312 ImageSearchPathsChanged (const PathMappingList &path_list,
1316 DISALLOW_COPY_AND_ASSIGN (Target);
1319 } // namespace lldb_private
1321 #endif // liblldb_Target_h_