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/ClangModulesDeclVendor.h"
30 #include "lldb/Expression/ClangPersistentVariables.h"
31 #include "lldb/Interpreter/Args.h"
32 #include "lldb/Interpreter/OptionValueBoolean.h"
33 #include "lldb/Interpreter/OptionValueEnumeration.h"
34 #include "lldb/Interpreter/OptionValueFileSpec.h"
35 #include "lldb/Symbol/SymbolContext.h"
36 #include "lldb/Target/ABI.h"
37 #include "lldb/Target/ExecutionContextScope.h"
38 #include "lldb/Target/PathMappingList.h"
39 #include "lldb/Target/SectionLoadHistory.h"
41 namespace lldb_private {
43 extern OptionEnumValueElement g_dynamic_value_types[];
45 typedef enum InlineStrategy
47 eInlineBreakpointsNever = 0,
48 eInlineBreakpointsHeaders,
49 eInlineBreakpointsAlways
52 typedef enum LoadScriptFromSymFile
54 eLoadScriptFromSymFileTrue,
55 eLoadScriptFromSymFileFalse,
56 eLoadScriptFromSymFileWarn
57 } LoadScriptFromSymFile;
59 //----------------------------------------------------------------------
61 //----------------------------------------------------------------------
62 class TargetProperties : public Properties
65 TargetProperties(Target *target);
71 GetDefaultArchitecture () const;
74 SetDefaultArchitecture (const ArchSpec& arch);
76 lldb::DynamicValueType
77 GetPreferDynamicValue() const;
80 GetDisableASLR () const;
83 SetDisableASLR (bool b);
86 GetDetachOnError () const;
89 SetDetachOnError (bool b);
92 GetDisableSTDIO () const;
95 SetDisableSTDIO (bool b);
98 GetDisassemblyFlavor() const;
101 // SetDisassemblyFlavor(const char *flavor);
104 GetInlineStrategy () const;
110 SetArg0 (const char *arg);
113 GetRunArguments (Args &args) const;
116 SetRunArguments (const Args &args);
119 GetEnvironmentAsArgs (Args &env) const;
122 GetSkipPrologue() const;
125 GetSourcePathMap () const;
128 GetExecutableSearchPaths ();
131 GetDebugFileSearchPaths ();
134 GetEnableSyntheticValue () const;
137 GetMaximumNumberOfChildrenToDisplay() const;
140 GetMaximumSizeOfStringSummary() const;
143 GetMaximumMemReadSize () const;
146 GetStandardInputPath () const;
149 SetStandardInputPath (const char *path);
152 GetStandardOutputPath () const;
155 SetStandardOutputPath (const char *path);
158 GetStandardErrorPath () const;
161 SetStandardErrorPath (const char *path);
164 GetBreakpointsConsultPlatformAvoidList ();
167 GetExpressionPrefixContentsAsCString ();
170 GetUseHexImmediates() const;
173 GetUseFastStepping() const;
176 GetDisplayExpressionsInCrashlogs () const;
178 LoadScriptFromSymFile
179 GetLoadScriptFromSymbolFile() const;
181 Disassembler::HexImmediateStyle
182 GetHexImmediateStyle() const;
184 MemoryModuleLoadLevel
185 GetMemoryModuleLoadLevel() const;
188 GetUserSpecifiedTrapHandlerNames (Args &args) const;
191 SetUserSpecifiedTrapHandlerNames (const Args &args);
194 typedef std::shared_ptr<TargetProperties> TargetPropertiesSP;
196 class EvaluateExpressionOptions
199 static const uint32_t default_timeout = 500000;
200 EvaluateExpressionOptions() :
201 m_execution_policy(eExecutionPolicyOnlyWhenNeeded),
202 m_language (lldb::eLanguageTypeUnknown),
203 m_coerce_to_id(false),
204 m_unwind_on_error(true),
205 m_ignore_breakpoints (false),
206 m_keep_in_memory(false),
210 m_trap_exceptions(true),
211 m_generate_debug_info(false),
212 m_result_is_internal(false),
213 m_use_dynamic(lldb::eNoDynamicValues),
214 m_timeout_usec(default_timeout),
215 m_one_thread_timeout_usec(0),
216 m_cancel_callback (nullptr),
217 m_cancel_callback_baton (nullptr)
222 GetExecutionPolicy () const
224 return m_execution_policy;
228 SetExecutionPolicy (ExecutionPolicy policy = eExecutionPolicyAlways)
230 m_execution_policy = policy;
240 SetLanguage(lldb::LanguageType language)
242 m_language = language;
246 DoesCoerceToId () const
248 return m_coerce_to_id;
252 SetCoerceToId (bool coerce = true)
254 m_coerce_to_id = coerce;
258 DoesUnwindOnError () const
260 return m_unwind_on_error;
264 SetUnwindOnError (bool unwind = false)
266 m_unwind_on_error = unwind;
270 DoesIgnoreBreakpoints () const
272 return m_ignore_breakpoints;
276 SetIgnoreBreakpoints (bool ignore = false)
278 m_ignore_breakpoints = ignore;
282 DoesKeepInMemory () const
284 return m_keep_in_memory;
288 SetKeepInMemory (bool keep = true)
290 m_keep_in_memory = keep;
293 lldb::DynamicValueType
294 GetUseDynamic () const
296 return m_use_dynamic;
300 SetUseDynamic (lldb::DynamicValueType dynamic = lldb::eDynamicCanRunTarget)
302 m_use_dynamic = dynamic;
306 GetTimeoutUsec () const
308 return m_timeout_usec;
312 SetTimeoutUsec (uint32_t timeout = 0)
314 m_timeout_usec = timeout;
318 GetOneThreadTimeoutUsec () const
320 return m_one_thread_timeout_usec;
324 SetOneThreadTimeoutUsec (uint32_t timeout = 0)
326 m_one_thread_timeout_usec = timeout;
330 GetTryAllThreads () const
336 SetTryAllThreads (bool try_others = true)
338 m_try_others = try_others;
342 GetStopOthers () const
344 return m_stop_others;
348 SetStopOthers (bool stop_others = true)
350 m_stop_others = stop_others;
364 m_generate_debug_info = true;
368 GetGenerateDebugInfo() const
370 return m_generate_debug_info;
374 SetGenerateDebugInfo(bool b)
376 m_generate_debug_info = b;
380 GetTrapExceptions() const
382 return m_trap_exceptions;
386 SetTrapExceptions (bool b)
388 m_trap_exceptions = b;
392 SetCancelCallback (lldb::ExpressionCancelCallback callback, void *baton)
394 m_cancel_callback_baton = baton;
395 m_cancel_callback = callback;
399 InvokeCancelCallback (lldb::ExpressionEvaluationPhase phase) const
401 if (m_cancel_callback == nullptr)
404 return m_cancel_callback (phase, m_cancel_callback_baton);
408 SetResultIsInternal (bool b)
410 m_result_is_internal = b;
414 GetResultIsInternal () const
416 return m_result_is_internal;
420 ExecutionPolicy m_execution_policy;
421 lldb::LanguageType m_language;
423 bool m_unwind_on_error;
424 bool m_ignore_breakpoints;
425 bool m_keep_in_memory;
429 bool m_trap_exceptions;
430 bool m_generate_debug_info;
431 bool m_result_is_internal;
432 lldb::DynamicValueType m_use_dynamic;
433 uint32_t m_timeout_usec;
434 uint32_t m_one_thread_timeout_usec;
435 lldb::ExpressionCancelCallback m_cancel_callback;
436 void *m_cancel_callback_baton;
439 //----------------------------------------------------------------------
441 //----------------------------------------------------------------------
443 public std::enable_shared_from_this<Target>,
444 public TargetProperties,
446 public ExecutionContextScope,
447 public ModuleList::Notifier
450 friend class TargetList;
452 //------------------------------------------------------------------
453 /// Broadcaster event bits definitions.
454 //------------------------------------------------------------------
457 eBroadcastBitBreakpointChanged = (1 << 0),
458 eBroadcastBitModulesLoaded = (1 << 1),
459 eBroadcastBitModulesUnloaded = (1 << 2),
460 eBroadcastBitWatchpointChanged = (1 << 3),
461 eBroadcastBitSymbolsLoaded = (1 << 4)
464 // These two functions fill out the Broadcaster interface:
466 static ConstString &GetStaticBroadcasterClass ();
468 virtual ConstString &GetBroadcasterClass() const
470 return GetStaticBroadcasterClass();
473 // This event data class is for use by the TargetList to broadcast new target notifications.
474 class TargetEventData : public EventData
478 static const ConstString &
481 virtual const ConstString &
484 TargetEventData (const lldb::TargetSP &new_target_sp);
496 Dump (Stream *s) const;
498 static const lldb::TargetSP
499 GetTargetFromEvent (const lldb::EventSP &event_sp);
501 static const TargetEventData *
502 GetEventDataFromEvent (const Event *event_sp);
505 lldb::TargetSP m_target_sp;
507 DISALLOW_COPY_AND_ASSIGN (TargetEventData);
511 SettingsInitialize ();
514 SettingsTerminate ();
516 // static lldb::UserSettingsControllerSP &
517 // GetSettingsController ();
520 GetDefaultExecutableSearchPaths ();
523 GetDefaultDebugFileSearchPaths ();
526 GetDefaultArchitecture ();
529 SetDefaultArchitecture (const ArchSpec &arch);
532 // UpdateInstanceName ();
535 GetSharedModule (const ModuleSpec &module_spec,
536 Error *error_ptr = NULL);
538 //----------------------------------------------------------------------
539 // Settings accessors
540 //----------------------------------------------------------------------
542 static const TargetPropertiesSP &
543 GetGlobalProperties();
547 //------------------------------------------------------------------
548 /// Construct with optional file and arch.
550 /// This member is private. Clients must use
551 /// TargetList::CreateTarget(const FileSpec*, const ArchSpec*)
552 /// so all targets can be tracked from the central target list.
554 /// @see TargetList::CreateTarget(const FileSpec*, const ArchSpec*)
555 //------------------------------------------------------------------
556 Target (Debugger &debugger,
557 const ArchSpec &target_arch,
558 const lldb::PlatformSP &platform_sp,
559 bool is_dummy_target);
565 // Copy breakpoints, stop hooks and so forth from the dummy target:
567 PrimeFromDummyTarget(Target *dummy_target);
570 AddBreakpoint(lldb::BreakpointSP breakpoint_sp, bool internal);
582 DeleteCurrentProcess ();
586 //------------------------------------------------------------------
587 /// Dump a description of this object to a Stream.
589 /// Dump a description of the contents of this object to the
590 /// supplied stream \a s. The dumped content will be only what has
591 /// been loaded or parsed up to this point at which this function
592 /// is called, so this is a good way to see what has been parsed
596 /// The stream to which to dump the object description.
597 //------------------------------------------------------------------
599 Dump (Stream *s, lldb::DescriptionLevel description_level);
601 const lldb::ProcessSP &
602 CreateProcess (Listener &listener,
603 const char *plugin_name,
604 const FileSpec *crash_file);
606 const lldb::ProcessSP &
607 GetProcessSP () const;
619 Launch (ProcessLaunchInfo &launch_info,
620 Stream *stream); // Optional stream to receive first stop info
622 //------------------------------------------------------------------
623 // This part handles the breakpoints.
624 //------------------------------------------------------------------
627 GetBreakpointList(bool internal = false);
629 const BreakpointList &
630 GetBreakpointList(bool internal = false) const;
633 GetLastCreatedBreakpoint ()
635 return m_last_created_breakpoint;
639 GetBreakpointByID (lldb::break_id_t break_id);
641 // Use this to create a file and line breakpoint to a given module or all module it is NULL
643 CreateBreakpoint (const FileSpecList *containingModules,
644 const FileSpec &file,
646 LazyBool check_inlines,
647 LazyBool skip_prologue,
649 bool request_hardware);
651 // Use this to create breakpoint that matches regex against the source lines in files given in source_file_list:
653 CreateSourceRegexBreakpoint (const FileSpecList *containingModules,
654 const FileSpecList *source_file_list,
655 RegularExpression &source_regex,
657 bool request_hardware);
659 // Use this to create a breakpoint from a load address
661 CreateBreakpoint (lldb::addr_t load_addr,
663 bool request_hardware);
665 // Use this to create Address breakpoints:
667 CreateBreakpoint (Address &addr,
669 bool request_hardware);
671 // Use this to create a function breakpoint by regexp in containingModule/containingSourceFiles, or all modules if it is NULL
672 // When "skip_prologue is set to eLazyBoolCalculate, we use the current target
673 // setting, else we use the values passed in
675 CreateFuncRegexBreakpoint (const FileSpecList *containingModules,
676 const FileSpecList *containingSourceFiles,
677 RegularExpression &func_regexp,
678 LazyBool skip_prologue,
680 bool request_hardware);
682 // Use this to create a function breakpoint by name in containingModule, or all modules if it is NULL
683 // When "skip_prologue is set to eLazyBoolCalculate, we use the current target
684 // setting, else we use the values passed in
686 CreateBreakpoint (const FileSpecList *containingModules,
687 const FileSpecList *containingSourceFiles,
688 const char *func_name,
689 uint32_t func_name_type_mask,
690 LazyBool skip_prologue,
692 bool request_hardware);
695 CreateExceptionBreakpoint (enum lldb::LanguageType language, bool catch_bp, bool throw_bp, bool internal);
697 // This is the same as the func_name breakpoint except that you can specify a vector of names. This is cheaper
698 // than a regular expression breakpoint in the case where you just want to set a breakpoint on a set of names
701 CreateBreakpoint (const FileSpecList *containingModules,
702 const FileSpecList *containingSourceFiles,
703 const char *func_names[],
705 uint32_t func_name_type_mask,
706 LazyBool skip_prologue,
708 bool request_hardware);
711 CreateBreakpoint (const FileSpecList *containingModules,
712 const FileSpecList *containingSourceFiles,
713 const std::vector<std::string> &func_names,
714 uint32_t func_name_type_mask,
715 LazyBool skip_prologue,
717 bool request_hardware);
720 // Use this to create a general breakpoint:
722 CreateBreakpoint (lldb::SearchFilterSP &filter_sp,
723 lldb::BreakpointResolverSP &resolver_sp,
725 bool request_hardware,
726 bool resolve_indirect_symbols);
728 // Use this to create a watchpoint:
730 CreateWatchpoint (lldb::addr_t addr,
732 const ClangASTType *type,
737 GetLastCreatedWatchpoint ()
739 return m_last_created_watchpoint;
745 return m_watchpoint_list;
749 RemoveAllBreakpoints (bool internal_also = false);
752 DisableAllBreakpoints (bool internal_also = false);
755 EnableAllBreakpoints (bool internal_also = false);
758 DisableBreakpointByID (lldb::break_id_t break_id);
761 EnableBreakpointByID (lldb::break_id_t break_id);
764 RemoveBreakpointByID (lldb::break_id_t break_id);
766 // The flag 'end_to_end', default to true, signifies that the operation is
767 // performed end to end, for both the debugger and the debuggee.
770 RemoveAllWatchpoints (bool end_to_end = true);
773 DisableAllWatchpoints (bool end_to_end = true);
776 EnableAllWatchpoints (bool end_to_end = true);
779 ClearAllWatchpointHitCounts ();
782 IgnoreAllWatchpoints (uint32_t ignore_count);
785 DisableWatchpointByID (lldb::watch_id_t watch_id);
788 EnableWatchpointByID (lldb::watch_id_t watch_id);
791 RemoveWatchpointByID (lldb::watch_id_t watch_id);
794 IgnoreWatchpointByID (lldb::watch_id_t watch_id, uint32_t ignore_count);
796 //------------------------------------------------------------------
797 /// Get \a load_addr as a callable code load address for this target
799 /// Take \a load_addr and potentially add any address bits that are
800 /// needed to make the address callable. For ARM this can set bit
801 /// zero (if it already isn't) if \a load_addr is a thumb function.
802 /// If \a addr_class is set to eAddressClassInvalid, then the address
803 /// adjustment will always happen. If it is set to an address class
804 /// that doesn't have code in it, LLDB_INVALID_ADDRESS will be
806 //------------------------------------------------------------------
808 GetCallableLoadAddress (lldb::addr_t load_addr, lldb::AddressClass addr_class = lldb::eAddressClassInvalid) const;
810 //------------------------------------------------------------------
811 /// Get \a load_addr as an opcode for this target.
813 /// Take \a load_addr and potentially strip any address bits that are
814 /// needed to make the address point to an opcode. For ARM this can
815 /// clear bit zero (if it already isn't) if \a load_addr is a
816 /// thumb function and load_addr is in code.
817 /// If \a addr_class is set to eAddressClassInvalid, then the address
818 /// adjustment will always happen. If it is set to an address class
819 /// that doesn't have code in it, LLDB_INVALID_ADDRESS will be
821 //------------------------------------------------------------------
823 GetOpcodeLoadAddress (lldb::addr_t load_addr, lldb::AddressClass addr_class = lldb::eAddressClassInvalid) const;
826 //------------------------------------------------------------------
827 /// Implementing of ModuleList::Notifier.
828 //------------------------------------------------------------------
831 ModuleAdded (const ModuleList& module_list, const lldb::ModuleSP& module_sp);
834 ModuleRemoved (const ModuleList& module_list, const lldb::ModuleSP& module_sp);
837 ModuleUpdated (const ModuleList& module_list,
838 const lldb::ModuleSP& old_module_sp,
839 const lldb::ModuleSP& new_module_sp);
841 WillClearList (const ModuleList& module_list);
846 ModulesDidLoad (ModuleList &module_list);
849 ModulesDidUnload (ModuleList &module_list, bool delete_locations);
852 SymbolsDidLoad (ModuleList &module_list);
855 ClearModules(bool delete_locations);
857 //------------------------------------------------------------------
858 /// Called as the last function in Process::DidExec().
860 /// Process::DidExec() will clear a lot of state in the process,
861 /// then try to reload a dynamic loader plugin to discover what
862 /// binaries are currently available and then this function should
863 /// be called to allow the target to do any cleanup after everything
864 /// has been figured out. It can remove breakpoints that no longer
865 /// make sense as the exec might have changed the target
866 /// architecture, and unloaded some modules that might get deleted.
867 //------------------------------------------------------------------
871 //------------------------------------------------------------------
872 /// Gets the module for the main executable.
874 /// Each process has a notion of a main executable that is the file
875 /// that will be executed or attached to. Executable files can have
876 /// dependent modules that are discovered from the object files, or
877 /// discovered at runtime as things are dynamically loaded.
880 /// The shared pointer to the executable module which can
881 /// contains a NULL Module object if no executable has been
884 /// @see DynamicLoader
885 /// @see ObjectFile::GetDependentModules (FileSpecList&)
886 /// @see Process::SetExecutableModule(lldb::ModuleSP&)
887 //------------------------------------------------------------------
889 GetExecutableModule ();
892 GetExecutableModulePointer ();
894 //------------------------------------------------------------------
895 /// Set the main executable module.
897 /// Each process has a notion of a main executable that is the file
898 /// that will be executed or attached to. Executable files can have
899 /// dependent modules that are discovered from the object files, or
900 /// discovered at runtime as things are dynamically loaded.
902 /// Setting the executable causes any of the current dependant
903 /// image information to be cleared and replaced with the static
904 /// dependent image information found by calling
905 /// ObjectFile::GetDependentModules (FileSpecList&) on the main
906 /// executable and any modules on which it depends. Calling
907 /// Process::GetImages() will return the newly found images that
908 /// were obtained from all of the object files.
910 /// @param[in] module_sp
911 /// A shared pointer reference to the module that will become
912 /// the main executable for this process.
914 /// @param[in] get_dependent_files
915 /// If \b true then ask the object files to track down any
916 /// known dependent files.
918 /// @see ObjectFile::GetDependentModules (FileSpecList&)
919 /// @see Process::GetImages()
920 //------------------------------------------------------------------
922 SetExecutableModule (lldb::ModuleSP& module_sp, bool get_dependent_files);
925 LoadScriptingResources (std::list<Error>& errors,
926 Stream* feedback_stream = NULL,
927 bool continue_on_error = true)
929 return m_images.LoadScriptingResourcesInTarget(this,errors,feedback_stream,continue_on_error);
932 //------------------------------------------------------------------
933 /// Get accessor for the images for this process.
935 /// Each process has a notion of a main executable that is the file
936 /// that will be executed or attached to. Executable files can have
937 /// dependent modules that are discovered from the object files, or
938 /// discovered at runtime as things are dynamically loaded. After
939 /// a main executable has been set, the images will contain a list
940 /// of all the files that the executable depends upon as far as the
941 /// object files know. These images will usually contain valid file
942 /// virtual addresses only. When the process is launched or attached
943 /// to, the DynamicLoader plug-in will discover where these images
944 /// were loaded in memory and will resolve the load virtual
945 /// addresses is each image, and also in images that are loaded by
949 /// A list of Module objects in a module list.
950 //------------------------------------------------------------------
963 //------------------------------------------------------------------
964 /// Return whether this FileSpec corresponds to a module that should be considered for general searches.
966 /// This API will be consulted by the SearchFilterForUnconstrainedSearches
967 /// and any module that returns \b true will not be searched. Note the
968 /// SearchFilterForUnconstrainedSearches is the search filter that
969 /// gets used in the CreateBreakpoint calls when no modules is provided.
971 /// The target call at present just consults the Platform's call of the
974 /// @param[in] module_sp
975 /// A shared pointer reference to the module that checked.
977 /// @return \b true if the module should be excluded, \b false otherwise.
978 //------------------------------------------------------------------
980 ModuleIsExcludedForUnconstrainedSearches (const FileSpec &module_spec);
982 //------------------------------------------------------------------
983 /// Return whether this module should be considered for general searches.
985 /// This API will be consulted by the SearchFilterForUnconstrainedSearches
986 /// and any module that returns \b true will not be searched. Note the
987 /// SearchFilterForUnconstrainedSearches is the search filter that
988 /// gets used in the CreateBreakpoint calls when no modules is provided.
990 /// The target call at present just consults the Platform's call of the
993 /// FIXME: When we get time we should add a way for the user to set modules that they
994 /// don't want searched, in addition to or instead of the platform ones.
996 /// @param[in] module_sp
997 /// A shared pointer reference to the module that checked.
999 /// @return \b true if the module should be excluded, \b false otherwise.
1000 //------------------------------------------------------------------
1002 ModuleIsExcludedForUnconstrainedSearches (const lldb::ModuleSP &module_sp);
1011 GetArchitecture () const
1016 //------------------------------------------------------------------
1017 /// Set the architecture for this target.
1019 /// If the current target has no Images read in, then this just sets the architecture, which will
1020 /// be used to select the architecture of the ExecutableModule when that is set.
1021 /// If the current target has an ExecutableModule, then calling SetArchitecture with a different
1022 /// architecture from the currently selected one will reset the ExecutableModule to that slice
1023 /// of the file backing the ExecutableModule. If the file backing the ExecutableModule does not
1024 /// contain a fork of this architecture, then this code will return false, and the architecture
1025 /// won't be changed.
1026 /// If the input arch_spec is the same as the already set architecture, this is a no-op.
1028 /// @param[in] arch_spec
1029 /// The new architecture.
1032 /// \b true if the architecture was successfully set, \bfalse otherwise.
1033 //------------------------------------------------------------------
1035 SetArchitecture (const ArchSpec &arch_spec);
1044 ReadMemoryFromFileCache (const Address& addr,
1049 // Reading memory through the target allows us to skip going to the process
1050 // for reading memory if possible and it allows us to try and read from
1051 // any constant sections in our object files on disk. If you always want
1052 // live program memory, read straight from the process. If you possibly
1053 // want to read from const sections in object files, read from the target.
1054 // This version of ReadMemory will try and read memory from the process
1055 // if the process is alive. The order is:
1056 // 1 - if (prefer_file_cache == true) then read from object file cache
1057 // 2 - if there is a valid process, try and read from its memory
1058 // 3 - if (prefer_file_cache == false) then read from object file cache
1060 ReadMemory (const Address& addr,
1061 bool prefer_file_cache,
1065 lldb::addr_t *load_addr_ptr = NULL);
1068 ReadCStringFromMemory (const Address& addr, std::string &out_str, Error &error);
1071 ReadCStringFromMemory (const Address& addr, char *dst, size_t dst_max_len, Error &result_error);
1074 ReadScalarIntegerFromMemory (const Address& addr,
1075 bool prefer_file_cache,
1082 ReadUnsignedIntegerFromMemory (const Address& addr,
1083 bool prefer_file_cache,
1084 size_t integer_byte_size,
1085 uint64_t fail_value,
1089 ReadPointerFromMemory (const Address& addr,
1090 bool prefer_file_cache,
1092 Address &pointer_addr);
1095 GetSectionLoadList()
1097 return m_section_load_history.GetCurrentSectionLoadList();
1100 // const SectionLoadList&
1101 // GetSectionLoadList() const
1103 // return const_cast<SectionLoadHistory *>(&m_section_load_history)->GetCurrentSectionLoadList();
1107 GetTargetFromContexts (const ExecutionContext *exe_ctx_ptr,
1108 const SymbolContext *sc_ptr);
1110 //------------------------------------------------------------------
1111 // lldb::ExecutionContextScope pure virtual functions
1112 //------------------------------------------------------------------
1113 virtual lldb::TargetSP
1116 virtual lldb::ProcessSP
1117 CalculateProcess ();
1119 virtual lldb::ThreadSP
1122 virtual lldb::StackFrameSP
1123 CalculateStackFrame ();
1126 CalculateExecutionContext (ExecutionContext &exe_ctx);
1129 GetImageSearchPathList ();
1132 GetScratchClangASTContext(bool create_on_demand=true);
1135 GetClangASTImporter();
1137 //----------------------------------------------------------------------
1138 // Install any files through the platform that need be to installed
1139 // prior to launching or attaching.
1140 //----------------------------------------------------------------------
1142 Install(ProcessLaunchInfo *launch_info);
1145 ResolveFileAddress (lldb::addr_t load_addr,
1149 ResolveLoadAddress (lldb::addr_t load_addr,
1151 uint32_t stop_id = SectionLoadHistory::eStopIDNow);
1154 SetSectionLoadAddress (const lldb::SectionSP §ion,
1155 lldb::addr_t load_addr,
1156 bool warn_multiple = false);
1159 UnloadModuleSections (const lldb::ModuleSP &module_sp);
1162 UnloadModuleSections (const ModuleList &module_list);
1165 SetSectionUnloaded (const lldb::SectionSP §ion_sp);
1168 SetSectionUnloaded (const lldb::SectionSP §ion_sp, lldb::addr_t load_addr);
1171 ClearAllLoadedSections ();
1173 // Since expressions results can persist beyond the lifetime of a process,
1174 // and the const expression results are available after a process is gone,
1175 // we provide a way for expressions to be evaluated from the Target itself.
1176 // If an expression is going to be run, then it should have a frame filled
1177 // in in th execution context.
1178 lldb::ExpressionResults
1179 EvaluateExpression (const char *expression,
1181 lldb::ValueObjectSP &result_valobj_sp,
1182 const EvaluateExpressionOptions& options = EvaluateExpressionOptions());
1184 ClangPersistentVariables &
1185 GetPersistentVariables()
1187 return m_persistent_variables;
1190 //------------------------------------------------------------------
1191 // Target Stop Hooks
1192 //------------------------------------------------------------------
1193 class StopHook : public UserID
1198 StopHook (const StopHook &rhs);
1201 GetCommandPointer ()
1219 SetCommands (StringList &in_commands)
1221 m_commands = in_commands;
1224 // Set the specifier. The stop hook will own the specifier, and is responsible for deleting it when we're done.
1226 SetSpecifier (SymbolContextSpecifier *specifier)
1228 m_specifier_sp.reset (specifier);
1231 SymbolContextSpecifier *
1234 return m_specifier_sp.get();
1237 // Set the Thread Specifier. The stop hook will own the thread specifier, and is responsible for deleting it when we're done.
1239 SetThreadSpecifier (ThreadSpec *specifier);
1242 GetThreadSpecifier()
1244 return m_thread_spec_ap.get();
1254 SetIsActive (bool is_active)
1256 m_active = is_active;
1260 GetDescription (Stream *s, lldb::DescriptionLevel level) const;
1263 lldb::TargetSP m_target_sp;
1264 StringList m_commands;
1265 lldb::SymbolContextSpecifierSP m_specifier_sp;
1266 std::unique_ptr<ThreadSpec> m_thread_spec_ap;
1269 // Use CreateStopHook to make a new empty stop hook. The GetCommandPointer and fill it with commands,
1270 // and SetSpecifier to set the specifier shared pointer (can be null, that will match anything.)
1271 StopHook (lldb::TargetSP target_sp, lldb::user_id_t uid);
1272 friend class Target;
1274 typedef std::shared_ptr<StopHook> StopHookSP;
1276 // Add an empty stop hook to the Target's stop hook list, and returns a shared pointer to it in new_hook.
1277 // Returns the id of the new hook.
1288 SetSuppresStopHooks (bool suppress)
1290 bool old_value = m_suppress_stop_hooks;
1291 m_suppress_stop_hooks = suppress;
1296 GetSuppressStopHooks ()
1298 return m_suppress_stop_hooks;
1302 // GetStopHookByIndex (size_t index);
1305 RemoveStopHookByID (lldb::user_id_t uid);
1308 RemoveAllStopHooks ();
1311 GetStopHookByID (lldb::user_id_t uid);
1314 SetStopHookActiveStateByID (lldb::user_id_t uid, bool active_state);
1317 SetAllStopHooksActiveState (bool active_state);
1319 size_t GetNumStopHooks () const
1321 return m_stop_hooks.size();
1325 GetStopHookAtIndex (size_t index)
1327 if (index >= GetNumStopHooks())
1328 return StopHookSP();
1329 StopHookCollection::iterator pos = m_stop_hooks.begin();
1336 return (*pos).second;
1342 return m_platform_sp;
1346 SetPlatform (const lldb::PlatformSP &platform_sp)
1348 m_platform_sp = platform_sp;
1352 GetSourceManager ();
1354 ClangModulesDeclVendor *
1355 GetClangModulesDeclVendor ();
1357 //------------------------------------------------------------------
1359 //------------------------------------------------------------------
1360 lldb::SearchFilterSP
1361 GetSearchFilterForModule (const FileSpec *containingModule);
1363 lldb::SearchFilterSP
1364 GetSearchFilterForModuleList (const FileSpecList *containingModuleList);
1366 lldb::SearchFilterSP
1367 GetSearchFilterForModuleAndCUList (const FileSpecList *containingModules, const FileSpecList *containingSourceFiles);
1370 //------------------------------------------------------------------
1371 // Member variables.
1372 //------------------------------------------------------------------
1373 Debugger & m_debugger;
1374 lldb::PlatformSP m_platform_sp; ///< The platform for this target.
1375 Mutex m_mutex; ///< An API mutex that is used by the lldb::SB* classes make the SB interface thread safe
1377 ModuleList m_images; ///< The list of images for this process (shared libraries and anything dynamically loaded).
1378 SectionLoadHistory m_section_load_history;
1379 BreakpointList m_breakpoint_list;
1380 BreakpointList m_internal_breakpoint_list;
1381 lldb::BreakpointSP m_last_created_breakpoint;
1382 WatchpointList m_watchpoint_list;
1383 lldb::WatchpointSP m_last_created_watchpoint;
1384 // We want to tightly control the process destruction process so
1385 // we can correctly tear down everything that we need to, so the only
1386 // class that knows about the process lifespan is this target class.
1387 lldb::ProcessSP m_process_sp;
1388 lldb::SearchFilterSP m_search_filter_sp;
1389 PathMappingList m_image_search_paths;
1390 std::unique_ptr<ClangASTContext> m_scratch_ast_context_ap;
1391 std::unique_ptr<ClangASTSource> m_scratch_ast_source_ap;
1392 std::unique_ptr<ClangASTImporter> m_ast_importer_ap;
1393 std::unique_ptr<ClangModulesDeclVendor> m_clang_modules_decl_vendor_ap;
1394 ClangPersistentVariables m_persistent_variables; ///< These are the persistent variables associated with this process for the expression parser.
1396 std::unique_ptr<SourceManager> m_source_manager_ap;
1398 typedef std::map<lldb::user_id_t, StopHookSP> StopHookCollection;
1399 StopHookCollection m_stop_hooks;
1400 lldb::user_id_t m_stop_hook_next_id;
1402 bool m_suppress_stop_hooks;
1403 bool m_is_dummy_target;
1406 ImageSearchPathsChanged (const PathMappingList &path_list,
1410 DISALLOW_COPY_AND_ASSIGN (Target);
1413 } // namespace lldb_private
1415 #endif // liblldb_Target_h_