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/WatchpointList.h"
22 #include "lldb/Core/ArchSpec.h"
23 #include "lldb/Core/Broadcaster.h"
24 #include "lldb/Core/Disassembler.h"
25 #include "lldb/Core/ModuleList.h"
26 #include "lldb/Core/UserSettingsController.h"
27 #include "lldb/Target/ExecutionContextScope.h"
28 #include "lldb/Target/PathMappingList.h"
29 #include "lldb/Target/ProcessLaunchInfo.h"
30 #include "lldb/Target/SectionLoadHistory.h"
32 namespace lldb_private {
34 extern OptionEnumValueElement g_dynamic_value_types[];
36 typedef enum InlineStrategy
38 eInlineBreakpointsNever = 0,
39 eInlineBreakpointsHeaders,
40 eInlineBreakpointsAlways
43 typedef enum LoadScriptFromSymFile
45 eLoadScriptFromSymFileTrue,
46 eLoadScriptFromSymFileFalse,
47 eLoadScriptFromSymFileWarn
48 } LoadScriptFromSymFile;
50 //----------------------------------------------------------------------
52 //----------------------------------------------------------------------
53 class TargetProperties : public Properties
56 TargetProperties(Target *target);
62 GetDefaultArchitecture () const;
65 SetDefaultArchitecture (const ArchSpec& arch);
68 GetMoveToNearestCode () const;
70 lldb::DynamicValueType
71 GetPreferDynamicValue() const;
74 SetPreferDynamicValue (lldb::DynamicValueType d);
77 GetDisableASLR () const;
80 SetDisableASLR (bool b);
83 GetDetachOnError () const;
86 SetDetachOnError (bool b);
89 GetDisableSTDIO () const;
92 SetDisableSTDIO (bool b);
95 GetDisassemblyFlavor() const;
98 // SetDisassemblyFlavor(const char *flavor);
101 GetInlineStrategy () const;
107 SetArg0 (const char *arg);
110 GetRunArguments (Args &args) const;
113 SetRunArguments (const Args &args);
116 GetEnvironmentAsArgs (Args &env) const;
119 SetEnvironmentFromArgs (const Args &env);
122 GetSkipPrologue() const;
125 GetSourcePathMap () const;
128 GetExecutableSearchPaths ();
131 GetDebugFileSearchPaths ();
134 GetClangModuleSearchPaths ();
137 GetEnableAutoImportClangModules () const;
140 GetEnableSyntheticValue () const;
143 GetMaximumNumberOfChildrenToDisplay() const;
146 GetMaximumSizeOfStringSummary() const;
149 GetMaximumMemReadSize () const;
152 GetStandardInputPath () const;
155 SetStandardInputPath (const char *path);
158 GetStandardOutputPath () const;
161 SetStandardOutputPath (const char *path);
164 GetStandardErrorPath () const;
167 SetStandardErrorPath (const char *path);
170 GetBreakpointsConsultPlatformAvoidList ();
173 GetExpressionPrefixContentsAsCString ();
176 GetUseHexImmediates() const;
179 GetUseFastStepping() const;
182 GetDisplayExpressionsInCrashlogs () const;
184 LoadScriptFromSymFile
185 GetLoadScriptFromSymbolFile() const;
187 Disassembler::HexImmediateStyle
188 GetHexImmediateStyle() const;
190 MemoryModuleLoadLevel
191 GetMemoryModuleLoadLevel() const;
194 GetUserSpecifiedTrapHandlerNames (Args &args) const;
197 SetUserSpecifiedTrapHandlerNames (const Args &args);
200 GetNonStopModeEnabled () const;
203 SetNonStopModeEnabled (bool b);
206 GetDisplayRuntimeSupportValues () const;
209 SetDisplayRuntimeSupportValues (bool b);
211 const ProcessLaunchInfo &
212 GetProcessLaunchInfo();
215 SetProcessLaunchInfo(const ProcessLaunchInfo &launch_info);
218 //------------------------------------------------------------------
219 // Callbacks for m_launch_info.
220 //------------------------------------------------------------------
221 static void Arg0ValueChangedCallback(void *target_property_ptr, OptionValue *);
222 static void RunArgsValueChangedCallback(void *target_property_ptr, OptionValue *);
223 static void EnvVarsValueChangedCallback(void *target_property_ptr, OptionValue *);
224 static void InheritEnvValueChangedCallback(void *target_property_ptr, OptionValue *);
225 static void InputPathValueChangedCallback(void *target_property_ptr, OptionValue *);
226 static void OutputPathValueChangedCallback(void *target_property_ptr, OptionValue *);
227 static void ErrorPathValueChangedCallback(void *target_property_ptr, OptionValue *);
228 static void DetachOnErrorValueChangedCallback(void *target_property_ptr, OptionValue *);
229 static void DisableASLRValueChangedCallback(void *target_property_ptr, OptionValue *);
230 static void DisableSTDIOValueChangedCallback(void *target_property_ptr, OptionValue *);
233 //------------------------------------------------------------------
235 //------------------------------------------------------------------
236 ProcessLaunchInfo m_launch_info;
239 class EvaluateExpressionOptions
242 static const uint32_t default_timeout = 500000;
243 EvaluateExpressionOptions() :
244 m_execution_policy(eExecutionPolicyOnlyWhenNeeded),
245 m_language (lldb::eLanguageTypeUnknown),
246 m_prefix (), // A prefix specific to this expression that is added after the prefix from the settings (if any)
247 m_coerce_to_id (false),
248 m_unwind_on_error (true),
249 m_ignore_breakpoints (false),
250 m_keep_in_memory (false),
252 m_stop_others (true),
254 m_trap_exceptions (true),
255 m_generate_debug_info (false),
256 m_result_is_internal (false),
257 m_use_dynamic (lldb::eNoDynamicValues),
258 m_timeout_usec (default_timeout),
259 m_one_thread_timeout_usec (0),
260 m_cancel_callback (nullptr),
261 m_cancel_callback_baton (nullptr)
266 GetExecutionPolicy () const
268 return m_execution_policy;
272 SetExecutionPolicy (ExecutionPolicy policy = eExecutionPolicyAlways)
274 m_execution_policy = policy;
284 SetLanguage(lldb::LanguageType language)
286 m_language = language;
290 DoesCoerceToId () const
292 return m_coerce_to_id;
298 if (m_prefix.empty())
300 return m_prefix.c_str();
304 SetPrefix (const char *prefix)
306 if (prefix && prefix[0])
313 SetCoerceToId (bool coerce = true)
315 m_coerce_to_id = coerce;
319 DoesUnwindOnError () const
321 return m_unwind_on_error;
325 SetUnwindOnError (bool unwind = false)
327 m_unwind_on_error = unwind;
331 DoesIgnoreBreakpoints () const
333 return m_ignore_breakpoints;
337 SetIgnoreBreakpoints (bool ignore = false)
339 m_ignore_breakpoints = ignore;
343 DoesKeepInMemory () const
345 return m_keep_in_memory;
349 SetKeepInMemory (bool keep = true)
351 m_keep_in_memory = keep;
354 lldb::DynamicValueType
355 GetUseDynamic () const
357 return m_use_dynamic;
361 SetUseDynamic (lldb::DynamicValueType dynamic = lldb::eDynamicCanRunTarget)
363 m_use_dynamic = dynamic;
367 GetTimeoutUsec () const
369 return m_timeout_usec;
373 SetTimeoutUsec (uint32_t timeout = 0)
375 m_timeout_usec = timeout;
379 GetOneThreadTimeoutUsec () const
381 return m_one_thread_timeout_usec;
385 SetOneThreadTimeoutUsec (uint32_t timeout = 0)
387 m_one_thread_timeout_usec = timeout;
391 GetTryAllThreads () const
397 SetTryAllThreads (bool try_others = true)
399 m_try_others = try_others;
403 GetStopOthers () const
405 return m_stop_others;
409 SetStopOthers (bool stop_others = true)
411 m_stop_others = stop_others;
425 m_generate_debug_info = true;
429 GetGenerateDebugInfo() const
431 return m_generate_debug_info;
435 SetGenerateDebugInfo(bool b)
437 m_generate_debug_info = b;
441 GetTrapExceptions() const
443 return m_trap_exceptions;
447 SetTrapExceptions (bool b)
449 m_trap_exceptions = b;
453 SetCancelCallback (lldb::ExpressionCancelCallback callback, void *baton)
455 m_cancel_callback_baton = baton;
456 m_cancel_callback = callback;
460 InvokeCancelCallback (lldb::ExpressionEvaluationPhase phase) const
462 if (m_cancel_callback == nullptr)
465 return m_cancel_callback (phase, m_cancel_callback_baton);
469 SetResultIsInternal (bool b)
471 m_result_is_internal = b;
475 GetResultIsInternal () const
477 return m_result_is_internal;
481 ExecutionPolicy m_execution_policy;
482 lldb::LanguageType m_language;
483 std::string m_prefix;
485 bool m_unwind_on_error;
486 bool m_ignore_breakpoints;
487 bool m_keep_in_memory;
491 bool m_trap_exceptions;
492 bool m_generate_debug_info;
493 bool m_result_is_internal;
494 lldb::DynamicValueType m_use_dynamic;
495 uint32_t m_timeout_usec;
496 uint32_t m_one_thread_timeout_usec;
497 lldb::ExpressionCancelCallback m_cancel_callback;
498 void *m_cancel_callback_baton;
501 //----------------------------------------------------------------------
503 //----------------------------------------------------------------------
505 public std::enable_shared_from_this<Target>,
506 public TargetProperties,
508 public ExecutionContextScope,
509 public ModuleList::Notifier
512 friend class TargetList;
514 //------------------------------------------------------------------
515 /// Broadcaster event bits definitions.
516 //------------------------------------------------------------------
519 eBroadcastBitBreakpointChanged = (1 << 0),
520 eBroadcastBitModulesLoaded = (1 << 1),
521 eBroadcastBitModulesUnloaded = (1 << 2),
522 eBroadcastBitWatchpointChanged = (1 << 3),
523 eBroadcastBitSymbolsLoaded = (1 << 4)
526 // These two functions fill out the Broadcaster interface:
528 static ConstString &GetStaticBroadcasterClass ();
530 virtual ConstString &GetBroadcasterClass() const
532 return GetStaticBroadcasterClass();
535 // This event data class is for use by the TargetList to broadcast new target notifications.
536 class TargetEventData : public EventData
539 TargetEventData (const lldb::TargetSP &target_sp);
541 TargetEventData (const lldb::TargetSP &target_sp, const ModuleList &module_list);
546 static const ConstString &
549 virtual const ConstString &
552 return TargetEventData::GetFlavorString ();
556 Dump (Stream *s) const;
558 static const TargetEventData *
559 GetEventDataFromEvent (const Event *event_ptr);
561 static lldb::TargetSP
562 GetTargetFromEvent (const Event *event_ptr);
565 GetModuleListFromEvent (const Event *event_ptr);
567 const lldb::TargetSP &
574 GetModuleList() const
576 return m_module_list;
580 lldb::TargetSP m_target_sp;
581 ModuleList m_module_list;
583 DISALLOW_COPY_AND_ASSIGN (TargetEventData);
587 SettingsInitialize ();
590 SettingsTerminate ();
593 GetDefaultExecutableSearchPaths ();
596 GetDefaultDebugFileSearchPaths ();
599 GetDefaultClangModuleSearchPaths ();
602 GetDefaultArchitecture ();
605 SetDefaultArchitecture (const ArchSpec &arch);
608 // UpdateInstanceName ();
611 GetSharedModule (const ModuleSpec &module_spec,
612 Error *error_ptr = NULL);
614 //----------------------------------------------------------------------
615 // Settings accessors
616 //----------------------------------------------------------------------
618 static const lldb::TargetPropertiesSP &
619 GetGlobalProperties();
623 //------------------------------------------------------------------
624 /// Construct with optional file and arch.
626 /// This member is private. Clients must use
627 /// TargetList::CreateTarget(const FileSpec*, const ArchSpec*)
628 /// so all targets can be tracked from the central target list.
630 /// @see TargetList::CreateTarget(const FileSpec*, const ArchSpec*)
631 //------------------------------------------------------------------
632 Target (Debugger &debugger,
633 const ArchSpec &target_arch,
634 const lldb::PlatformSP &platform_sp,
635 bool is_dummy_target);
641 // Copy breakpoints, stop hooks and so forth from the dummy target:
643 PrimeFromDummyTarget(Target *dummy_target);
646 AddBreakpoint(lldb::BreakpointSP breakpoint_sp, bool internal);
658 DeleteCurrentProcess ();
662 //------------------------------------------------------------------
663 /// Dump a description of this object to a Stream.
665 /// Dump a description of the contents of this object to the
666 /// supplied stream \a s. The dumped content will be only what has
667 /// been loaded or parsed up to this point at which this function
668 /// is called, so this is a good way to see what has been parsed
672 /// The stream to which to dump the object description.
673 //------------------------------------------------------------------
675 Dump (Stream *s, lldb::DescriptionLevel description_level);
677 const lldb::ProcessSP &
678 CreateProcess (Listener &listener,
679 const char *plugin_name,
680 const FileSpec *crash_file);
682 const lldb::ProcessSP &
683 GetProcessSP () const;
695 Launch (ProcessLaunchInfo &launch_info,
696 Stream *stream); // Optional stream to receive first stop info
699 Attach (ProcessAttachInfo &attach_info,
700 Stream *stream); // Optional stream to receive first stop info
702 //------------------------------------------------------------------
703 // This part handles the breakpoints.
704 //------------------------------------------------------------------
707 GetBreakpointList(bool internal = false);
709 const BreakpointList &
710 GetBreakpointList(bool internal = false) const;
713 GetLastCreatedBreakpoint ()
715 return m_last_created_breakpoint;
719 GetBreakpointByID (lldb::break_id_t break_id);
721 // Use this to create a file and line breakpoint to a given module or all module it is NULL
723 CreateBreakpoint (const FileSpecList *containingModules,
724 const FileSpec &file,
726 LazyBool check_inlines,
727 LazyBool skip_prologue,
729 bool request_hardware,
730 LazyBool move_to_nearest_code);
732 // Use this to create breakpoint that matches regex against the source lines in files given in source_file_list:
734 CreateSourceRegexBreakpoint (const FileSpecList *containingModules,
735 const FileSpecList *source_file_list,
736 RegularExpression &source_regex,
738 bool request_hardware,
739 LazyBool move_to_nearest_code);
741 // Use this to create a breakpoint from a load address
743 CreateBreakpoint (lldb::addr_t load_addr,
745 bool request_hardware);
747 // Use this to create Address breakpoints:
749 CreateBreakpoint (Address &addr,
751 bool request_hardware);
753 // Use this to create a function breakpoint by regexp in containingModule/containingSourceFiles, or all modules if it is NULL
754 // When "skip_prologue is set to eLazyBoolCalculate, we use the current target
755 // setting, else we use the values passed in
757 CreateFuncRegexBreakpoint (const FileSpecList *containingModules,
758 const FileSpecList *containingSourceFiles,
759 RegularExpression &func_regexp,
760 LazyBool skip_prologue,
762 bool request_hardware);
764 // Use this to create a function breakpoint by name in containingModule, or all modules if it is NULL
765 // When "skip_prologue is set to eLazyBoolCalculate, we use the current target
766 // setting, else we use the values passed in.
767 // func_name_type_mask is or'ed values from the FunctionNameType enum.
769 CreateBreakpoint (const FileSpecList *containingModules,
770 const FileSpecList *containingSourceFiles,
771 const char *func_name,
772 uint32_t func_name_type_mask,
773 LazyBool skip_prologue,
775 bool request_hardware);
778 CreateExceptionBreakpoint (enum lldb::LanguageType language,
782 Args *additional_args = nullptr,
783 Error *additional_args_error = nullptr);
785 // This is the same as the func_name breakpoint except that you can specify a vector of names. This is cheaper
786 // than a regular expression breakpoint in the case where you just want to set a breakpoint on a set of names
788 // func_name_type_mask is or'ed values from the FunctionNameType enum.
790 CreateBreakpoint (const FileSpecList *containingModules,
791 const FileSpecList *containingSourceFiles,
792 const char *func_names[],
794 uint32_t func_name_type_mask,
795 LazyBool skip_prologue,
797 bool request_hardware);
800 CreateBreakpoint (const FileSpecList *containingModules,
801 const FileSpecList *containingSourceFiles,
802 const std::vector<std::string> &func_names,
803 uint32_t func_name_type_mask,
804 LazyBool skip_prologue,
806 bool request_hardware);
809 // Use this to create a general breakpoint:
811 CreateBreakpoint (lldb::SearchFilterSP &filter_sp,
812 lldb::BreakpointResolverSP &resolver_sp,
814 bool request_hardware,
815 bool resolve_indirect_symbols);
817 // Use this to create a watchpoint:
819 CreateWatchpoint (lldb::addr_t addr,
821 const ClangASTType *type,
826 GetLastCreatedWatchpoint ()
828 return m_last_created_watchpoint;
834 return m_watchpoint_list;
838 RemoveAllBreakpoints (bool internal_also = false);
841 DisableAllBreakpoints (bool internal_also = false);
844 EnableAllBreakpoints (bool internal_also = false);
847 DisableBreakpointByID (lldb::break_id_t break_id);
850 EnableBreakpointByID (lldb::break_id_t break_id);
853 RemoveBreakpointByID (lldb::break_id_t break_id);
855 // The flag 'end_to_end', default to true, signifies that the operation is
856 // performed end to end, for both the debugger and the debuggee.
859 RemoveAllWatchpoints (bool end_to_end = true);
862 DisableAllWatchpoints (bool end_to_end = true);
865 EnableAllWatchpoints (bool end_to_end = true);
868 ClearAllWatchpointHitCounts ();
871 ClearAllWatchpointHistoricValues ();
874 IgnoreAllWatchpoints (uint32_t ignore_count);
877 DisableWatchpointByID (lldb::watch_id_t watch_id);
880 EnableWatchpointByID (lldb::watch_id_t watch_id);
883 RemoveWatchpointByID (lldb::watch_id_t watch_id);
886 IgnoreWatchpointByID (lldb::watch_id_t watch_id, uint32_t ignore_count);
888 //------------------------------------------------------------------
889 /// Get \a load_addr as a callable code load address for this target
891 /// Take \a load_addr and potentially add any address bits that are
892 /// needed to make the address callable. For ARM this can set bit
893 /// zero (if it already isn't) if \a load_addr is a thumb function.
894 /// If \a addr_class is set to eAddressClassInvalid, then the address
895 /// adjustment will always happen. If it is set to an address class
896 /// that doesn't have code in it, LLDB_INVALID_ADDRESS will be
898 //------------------------------------------------------------------
900 GetCallableLoadAddress (lldb::addr_t load_addr, lldb::AddressClass addr_class = lldb::eAddressClassInvalid) const;
902 //------------------------------------------------------------------
903 /// Get \a load_addr as an opcode for this target.
905 /// Take \a load_addr and potentially strip any address bits that are
906 /// needed to make the address point to an opcode. For ARM this can
907 /// clear bit zero (if it already isn't) if \a load_addr is a
908 /// thumb function and load_addr is in code.
909 /// If \a addr_class is set to eAddressClassInvalid, then the address
910 /// adjustment will always happen. If it is set to an address class
911 /// that doesn't have code in it, LLDB_INVALID_ADDRESS will be
913 //------------------------------------------------------------------
915 GetOpcodeLoadAddress (lldb::addr_t load_addr, lldb::AddressClass addr_class = lldb::eAddressClassInvalid) const;
918 //------------------------------------------------------------------
919 /// Implementing of ModuleList::Notifier.
920 //------------------------------------------------------------------
923 ModuleAdded (const ModuleList& module_list, const lldb::ModuleSP& module_sp);
926 ModuleRemoved (const ModuleList& module_list, const lldb::ModuleSP& module_sp);
929 ModuleUpdated (const ModuleList& module_list,
930 const lldb::ModuleSP& old_module_sp,
931 const lldb::ModuleSP& new_module_sp);
933 WillClearList (const ModuleList& module_list);
938 ModulesDidLoad (ModuleList &module_list);
941 ModulesDidUnload (ModuleList &module_list, bool delete_locations);
944 SymbolsDidLoad (ModuleList &module_list);
947 ClearModules(bool delete_locations);
949 //------------------------------------------------------------------
950 /// Called as the last function in Process::DidExec().
952 /// Process::DidExec() will clear a lot of state in the process,
953 /// then try to reload a dynamic loader plugin to discover what
954 /// binaries are currently available and then this function should
955 /// be called to allow the target to do any cleanup after everything
956 /// has been figured out. It can remove breakpoints that no longer
957 /// make sense as the exec might have changed the target
958 /// architecture, and unloaded some modules that might get deleted.
959 //------------------------------------------------------------------
963 //------------------------------------------------------------------
964 /// Gets the module for the main executable.
966 /// Each process has a notion of a main executable that is the file
967 /// that will be executed or attached to. Executable files can have
968 /// dependent modules that are discovered from the object files, or
969 /// discovered at runtime as things are dynamically loaded.
972 /// The shared pointer to the executable module which can
973 /// contains a NULL Module object if no executable has been
976 /// @see DynamicLoader
977 /// @see ObjectFile::GetDependentModules (FileSpecList&)
978 /// @see Process::SetExecutableModule(lldb::ModuleSP&)
979 //------------------------------------------------------------------
981 GetExecutableModule ();
984 GetExecutableModulePointer ();
986 //------------------------------------------------------------------
987 /// Set the main executable module.
989 /// Each process has a notion of a main executable that is the file
990 /// that will be executed or attached to. Executable files can have
991 /// dependent modules that are discovered from the object files, or
992 /// discovered at runtime as things are dynamically loaded.
994 /// Setting the executable causes any of the current dependant
995 /// image information to be cleared and replaced with the static
996 /// dependent image information found by calling
997 /// ObjectFile::GetDependentModules (FileSpecList&) on the main
998 /// executable and any modules on which it depends. Calling
999 /// Process::GetImages() will return the newly found images that
1000 /// were obtained from all of the object files.
1002 /// @param[in] module_sp
1003 /// A shared pointer reference to the module that will become
1004 /// the main executable for this process.
1006 /// @param[in] get_dependent_files
1007 /// If \b true then ask the object files to track down any
1008 /// known dependent files.
1010 /// @see ObjectFile::GetDependentModules (FileSpecList&)
1011 /// @see Process::GetImages()
1012 //------------------------------------------------------------------
1014 SetExecutableModule (lldb::ModuleSP& module_sp, bool get_dependent_files);
1017 LoadScriptingResources (std::list<Error>& errors,
1018 Stream* feedback_stream = NULL,
1019 bool continue_on_error = true)
1021 return m_images.LoadScriptingResourcesInTarget(this,errors,feedback_stream,continue_on_error);
1024 //------------------------------------------------------------------
1025 /// Get accessor for the images for this process.
1027 /// Each process has a notion of a main executable that is the file
1028 /// that will be executed or attached to. Executable files can have
1029 /// dependent modules that are discovered from the object files, or
1030 /// discovered at runtime as things are dynamically loaded. After
1031 /// a main executable has been set, the images will contain a list
1032 /// of all the files that the executable depends upon as far as the
1033 /// object files know. These images will usually contain valid file
1034 /// virtual addresses only. When the process is launched or attached
1035 /// to, the DynamicLoader plug-in will discover where these images
1036 /// were loaded in memory and will resolve the load virtual
1037 /// addresses is each image, and also in images that are loaded by
1041 /// A list of Module objects in a module list.
1042 //------------------------------------------------------------------
1055 //------------------------------------------------------------------
1056 /// Return whether this FileSpec corresponds to a module that should be considered for general searches.
1058 /// This API will be consulted by the SearchFilterForUnconstrainedSearches
1059 /// and any module that returns \b true will not be searched. Note the
1060 /// SearchFilterForUnconstrainedSearches is the search filter that
1061 /// gets used in the CreateBreakpoint calls when no modules is provided.
1063 /// The target call at present just consults the Platform's call of the
1066 /// @param[in] module_sp
1067 /// A shared pointer reference to the module that checked.
1069 /// @return \b true if the module should be excluded, \b false otherwise.
1070 //------------------------------------------------------------------
1072 ModuleIsExcludedForUnconstrainedSearches (const FileSpec &module_spec);
1074 //------------------------------------------------------------------
1075 /// Return whether this module should be considered for general searches.
1077 /// This API will be consulted by the SearchFilterForUnconstrainedSearches
1078 /// and any module that returns \b true will not be searched. Note the
1079 /// SearchFilterForUnconstrainedSearches is the search filter that
1080 /// gets used in the CreateBreakpoint calls when no modules is provided.
1082 /// The target call at present just consults the Platform's call of the
1085 /// FIXME: When we get time we should add a way for the user to set modules that they
1086 /// don't want searched, in addition to or instead of the platform ones.
1088 /// @param[in] module_sp
1089 /// A shared pointer reference to the module that checked.
1091 /// @return \b true if the module should be excluded, \b false otherwise.
1092 //------------------------------------------------------------------
1094 ModuleIsExcludedForUnconstrainedSearches (const lldb::ModuleSP &module_sp);
1097 GetArchitecture () const
1102 //------------------------------------------------------------------
1103 /// Set the architecture for this target.
1105 /// If the current target has no Images read in, then this just sets the architecture, which will
1106 /// be used to select the architecture of the ExecutableModule when that is set.
1107 /// If the current target has an ExecutableModule, then calling SetArchitecture with a different
1108 /// architecture from the currently selected one will reset the ExecutableModule to that slice
1109 /// of the file backing the ExecutableModule. If the file backing the ExecutableModule does not
1110 /// contain a fork of this architecture, then this code will return false, and the architecture
1111 /// won't be changed.
1112 /// If the input arch_spec is the same as the already set architecture, this is a no-op.
1114 /// @param[in] arch_spec
1115 /// The new architecture.
1118 /// \b true if the architecture was successfully set, \bfalse otherwise.
1119 //------------------------------------------------------------------
1121 SetArchitecture (const ArchSpec &arch_spec);
1124 MergeArchitecture (const ArchSpec &arch_spec);
1133 ReadMemoryFromFileCache (const Address& addr,
1138 // Reading memory through the target allows us to skip going to the process
1139 // for reading memory if possible and it allows us to try and read from
1140 // any constant sections in our object files on disk. If you always want
1141 // live program memory, read straight from the process. If you possibly
1142 // want to read from const sections in object files, read from the target.
1143 // This version of ReadMemory will try and read memory from the process
1144 // if the process is alive. The order is:
1145 // 1 - if (prefer_file_cache == true) then read from object file cache
1146 // 2 - if there is a valid process, try and read from its memory
1147 // 3 - if (prefer_file_cache == false) then read from object file cache
1149 ReadMemory (const Address& addr,
1150 bool prefer_file_cache,
1154 lldb::addr_t *load_addr_ptr = NULL);
1157 ReadCStringFromMemory (const Address& addr, std::string &out_str, Error &error);
1160 ReadCStringFromMemory (const Address& addr, char *dst, size_t dst_max_len, Error &result_error);
1163 ReadScalarIntegerFromMemory (const Address& addr,
1164 bool prefer_file_cache,
1171 ReadUnsignedIntegerFromMemory (const Address& addr,
1172 bool prefer_file_cache,
1173 size_t integer_byte_size,
1174 uint64_t fail_value,
1178 ReadPointerFromMemory (const Address& addr,
1179 bool prefer_file_cache,
1181 Address &pointer_addr);
1184 GetSectionLoadList()
1186 return m_section_load_history.GetCurrentSectionLoadList();
1189 // const SectionLoadList&
1190 // GetSectionLoadList() const
1192 // return const_cast<SectionLoadHistory *>(&m_section_load_history)->GetCurrentSectionLoadList();
1196 GetTargetFromContexts (const ExecutionContext *exe_ctx_ptr,
1197 const SymbolContext *sc_ptr);
1199 //------------------------------------------------------------------
1200 // lldb::ExecutionContextScope pure virtual functions
1201 //------------------------------------------------------------------
1202 virtual lldb::TargetSP
1205 virtual lldb::ProcessSP
1206 CalculateProcess ();
1208 virtual lldb::ThreadSP
1211 virtual lldb::StackFrameSP
1212 CalculateStackFrame ();
1215 CalculateExecutionContext (ExecutionContext &exe_ctx);
1218 GetImageSearchPathList ();
1221 GetScratchClangASTContext(bool create_on_demand=true);
1224 GetClangASTImporter();
1226 //----------------------------------------------------------------------
1227 // Install any files through the platform that need be to installed
1228 // prior to launching or attaching.
1229 //----------------------------------------------------------------------
1231 Install(ProcessLaunchInfo *launch_info);
1234 ResolveFileAddress (lldb::addr_t load_addr,
1238 ResolveLoadAddress (lldb::addr_t load_addr,
1240 uint32_t stop_id = SectionLoadHistory::eStopIDNow);
1243 SetSectionLoadAddress (const lldb::SectionSP §ion,
1244 lldb::addr_t load_addr,
1245 bool warn_multiple = false);
1248 UnloadModuleSections (const lldb::ModuleSP &module_sp);
1251 UnloadModuleSections (const ModuleList &module_list);
1254 SetSectionUnloaded (const lldb::SectionSP §ion_sp);
1257 SetSectionUnloaded (const lldb::SectionSP §ion_sp, lldb::addr_t load_addr);
1260 ClearAllLoadedSections ();
1262 // Since expressions results can persist beyond the lifetime of a process,
1263 // and the const expression results are available after a process is gone,
1264 // we provide a way for expressions to be evaluated from the Target itself.
1265 // If an expression is going to be run, then it should have a frame filled
1266 // in in th execution context.
1267 lldb::ExpressionResults
1268 EvaluateExpression (const char *expression,
1270 lldb::ValueObjectSP &result_valobj_sp,
1271 const EvaluateExpressionOptions& options = EvaluateExpressionOptions());
1273 ClangPersistentVariables &
1274 GetPersistentVariables();
1276 //------------------------------------------------------------------
1277 // Target Stop Hooks
1278 //------------------------------------------------------------------
1279 class StopHook : public UserID
1284 StopHook (const StopHook &rhs);
1287 GetCommandPointer ()
1305 SetCommands (StringList &in_commands)
1307 m_commands = in_commands;
1310 // Set the specifier. The stop hook will own the specifier, and is responsible for deleting it when we're done.
1312 SetSpecifier (SymbolContextSpecifier *specifier);
1314 SymbolContextSpecifier *
1317 return m_specifier_sp.get();
1320 // Set the Thread Specifier. The stop hook will own the thread specifier, and is responsible for deleting it when we're done.
1322 SetThreadSpecifier (ThreadSpec *specifier);
1325 GetThreadSpecifier()
1327 return m_thread_spec_ap.get();
1337 SetIsActive (bool is_active)
1339 m_active = is_active;
1343 GetDescription (Stream *s, lldb::DescriptionLevel level) const;
1346 lldb::TargetSP m_target_sp;
1347 StringList m_commands;
1348 lldb::SymbolContextSpecifierSP m_specifier_sp;
1349 std::unique_ptr<ThreadSpec> m_thread_spec_ap;
1352 // Use CreateStopHook to make a new empty stop hook. The GetCommandPointer and fill it with commands,
1353 // and SetSpecifier to set the specifier shared pointer (can be null, that will match anything.)
1354 StopHook (lldb::TargetSP target_sp, lldb::user_id_t uid);
1355 friend class Target;
1357 typedef std::shared_ptr<StopHook> StopHookSP;
1359 // Add an empty stop hook to the Target's stop hook list, and returns a shared pointer to it in new_hook.
1360 // Returns the id of the new hook.
1371 SetSuppresStopHooks (bool suppress)
1373 bool old_value = m_suppress_stop_hooks;
1374 m_suppress_stop_hooks = suppress;
1379 GetSuppressStopHooks ()
1381 return m_suppress_stop_hooks;
1385 // GetStopHookByIndex (size_t index);
1388 RemoveStopHookByID (lldb::user_id_t uid);
1391 RemoveAllStopHooks ();
1394 GetStopHookByID (lldb::user_id_t uid);
1397 SetStopHookActiveStateByID (lldb::user_id_t uid, bool active_state);
1400 SetAllStopHooksActiveState (bool active_state);
1402 size_t GetNumStopHooks () const
1404 return m_stop_hooks.size();
1408 GetStopHookAtIndex (size_t index)
1410 if (index >= GetNumStopHooks())
1411 return StopHookSP();
1412 StopHookCollection::iterator pos = m_stop_hooks.begin();
1419 return (*pos).second;
1425 return m_platform_sp;
1429 SetPlatform (const lldb::PlatformSP &platform_sp)
1431 m_platform_sp = platform_sp;
1435 GetSourceManager ();
1437 ClangModulesDeclVendor *
1438 GetClangModulesDeclVendor ();
1440 //------------------------------------------------------------------
1442 //------------------------------------------------------------------
1443 lldb::SearchFilterSP
1444 GetSearchFilterForModule (const FileSpec *containingModule);
1446 lldb::SearchFilterSP
1447 GetSearchFilterForModuleList (const FileSpecList *containingModuleList);
1449 lldb::SearchFilterSP
1450 GetSearchFilterForModuleAndCUList (const FileSpecList *containingModules, const FileSpecList *containingSourceFiles);
1453 //------------------------------------------------------------------
1454 // Member variables.
1455 //------------------------------------------------------------------
1456 Debugger & m_debugger;
1457 lldb::PlatformSP m_platform_sp; ///< The platform for this target.
1458 Mutex m_mutex; ///< An API mutex that is used by the lldb::SB* classes make the SB interface thread safe
1460 ModuleList m_images; ///< The list of images for this process (shared libraries and anything dynamically loaded).
1461 SectionLoadHistory m_section_load_history;
1462 BreakpointList m_breakpoint_list;
1463 BreakpointList m_internal_breakpoint_list;
1464 lldb::BreakpointSP m_last_created_breakpoint;
1465 WatchpointList m_watchpoint_list;
1466 lldb::WatchpointSP m_last_created_watchpoint;
1467 // We want to tightly control the process destruction process so
1468 // we can correctly tear down everything that we need to, so the only
1469 // class that knows about the process lifespan is this target class.
1470 lldb::ProcessSP m_process_sp;
1471 lldb::SearchFilterSP m_search_filter_sp;
1472 PathMappingList m_image_search_paths;
1473 lldb::ClangASTContextUP m_scratch_ast_context_ap;
1474 lldb::ClangASTSourceUP m_scratch_ast_source_ap;
1475 lldb::ClangASTImporterUP m_ast_importer_ap;
1476 lldb::ClangModulesDeclVendorUP m_clang_modules_decl_vendor_ap;
1477 lldb::ClangPersistentVariablesUP m_persistent_variables; ///< These are the persistent variables associated with this process for the expression parser.
1479 lldb::SourceManagerUP m_source_manager_ap;
1481 typedef std::map<lldb::user_id_t, StopHookSP> StopHookCollection;
1482 StopHookCollection m_stop_hooks;
1483 lldb::user_id_t m_stop_hook_next_id;
1485 bool m_suppress_stop_hooks;
1486 bool m_is_dummy_target;
1489 ImageSearchPathsChanged (const PathMappingList &path_list,
1493 DISALLOW_COPY_AND_ASSIGN (Target);
1496 } // namespace lldb_private
1498 #endif // liblldb_Target_h_