]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm-project/lldb/include/lldb/Target/Target.h
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm-project / lldb / include / lldb / Target / Target.h
1 //===-- Target.h ------------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 #ifndef liblldb_Target_h_
10 #define liblldb_Target_h_
11
12 #include <list>
13 #include <map>
14 #include <memory>
15 #include <string>
16 #include <vector>
17
18 #include "lldb/Breakpoint/BreakpointList.h"
19 #include "lldb/Breakpoint/BreakpointName.h"
20 #include "lldb/Breakpoint/WatchpointList.h"
21 #include "lldb/Core/Architecture.h"
22 #include "lldb/Core/Disassembler.h"
23 #include "lldb/Core/ModuleList.h"
24 #include "lldb/Core/UserSettingsController.h"
25 #include "lldb/Expression/Expression.h"
26 #include "lldb/Host/ProcessLaunchInfo.h"
27 #include "lldb/Symbol/TypeSystem.h"
28 #include "lldb/Target/ExecutionContextScope.h"
29 #include "lldb/Target/PathMappingList.h"
30 #include "lldb/Target/SectionLoadHistory.h"
31 #include "lldb/Utility/ArchSpec.h"
32 #include "lldb/Utility/Broadcaster.h"
33 #include "lldb/Utility/LLDBAssert.h"
34 #include "lldb/Utility/Timeout.h"
35 #include "lldb/lldb-public.h"
36
37 namespace lldb_private {
38
39 OptionEnumValues GetDynamicValueTypes();
40
41 enum InlineStrategy {
42   eInlineBreakpointsNever = 0,
43   eInlineBreakpointsHeaders,
44   eInlineBreakpointsAlways
45 };
46
47 enum LoadScriptFromSymFile {
48   eLoadScriptFromSymFileTrue,
49   eLoadScriptFromSymFileFalse,
50   eLoadScriptFromSymFileWarn
51 };
52
53 enum LoadCWDlldbinitFile {
54   eLoadCWDlldbinitTrue,
55   eLoadCWDlldbinitFalse,
56   eLoadCWDlldbinitWarn
57 };
58
59 enum LoadDependentFiles {
60   eLoadDependentsDefault,
61   eLoadDependentsYes,
62   eLoadDependentsNo,
63 };
64
65 // TargetProperties
66 class TargetExperimentalProperties : public Properties {
67 public:
68   TargetExperimentalProperties();
69 };
70
71 class TargetProperties : public Properties {
72 public:
73   TargetProperties(Target *target);
74
75   ~TargetProperties() override;
76
77   ArchSpec GetDefaultArchitecture() const;
78
79   void SetDefaultArchitecture(const ArchSpec &arch);
80
81   bool GetMoveToNearestCode() const;
82
83   lldb::DynamicValueType GetPreferDynamicValue() const;
84
85   bool SetPreferDynamicValue(lldb::DynamicValueType d);
86
87   bool GetPreloadSymbols() const;
88
89   void SetPreloadSymbols(bool b);
90
91   bool GetDisableASLR() const;
92
93   void SetDisableASLR(bool b);
94
95   bool GetDetachOnError() const;
96
97   void SetDetachOnError(bool b);
98
99   bool GetDisableSTDIO() const;
100
101   void SetDisableSTDIO(bool b);
102
103   const char *GetDisassemblyFlavor() const;
104
105   InlineStrategy GetInlineStrategy() const;
106
107   llvm::StringRef GetArg0() const;
108
109   void SetArg0(llvm::StringRef arg);
110
111   bool GetRunArguments(Args &args) const;
112
113   void SetRunArguments(const Args &args);
114
115   Environment GetEnvironment() const;
116   void SetEnvironment(Environment env);
117
118   bool GetSkipPrologue() const;
119
120   PathMappingList &GetSourcePathMap() const;
121
122   FileSpecList GetExecutableSearchPaths();
123
124   void AppendExecutableSearchPaths(const FileSpec&);
125
126   FileSpecList GetDebugFileSearchPaths();
127
128   FileSpecList GetClangModuleSearchPaths();
129
130   bool GetEnableAutoImportClangModules() const;
131
132   bool GetEnableImportStdModule() const;
133
134   bool GetEnableAutoApplyFixIts() const;
135
136   bool GetEnableNotifyAboutFixIts() const;
137
138   bool GetEnableSaveObjects() const;
139
140   bool GetEnableSyntheticValue() const;
141
142   uint32_t GetMaximumNumberOfChildrenToDisplay() const;
143
144   uint32_t GetMaximumSizeOfStringSummary() const;
145
146   uint32_t GetMaximumMemReadSize() const;
147
148   FileSpec GetStandardInputPath() const;
149   FileSpec GetStandardErrorPath() const;
150   FileSpec GetStandardOutputPath() const;
151
152   void SetStandardInputPath(llvm::StringRef path);
153   void SetStandardOutputPath(llvm::StringRef path);
154   void SetStandardErrorPath(llvm::StringRef path);
155
156   void SetStandardInputPath(const char *path) = delete;
157   void SetStandardOutputPath(const char *path) = delete;
158   void SetStandardErrorPath(const char *path) = delete;
159
160   bool GetBreakpointsConsultPlatformAvoidList();
161
162   lldb::LanguageType GetLanguage() const;
163
164   llvm::StringRef GetExpressionPrefixContents();
165
166   bool GetUseHexImmediates() const;
167
168   bool GetUseFastStepping() const;
169
170   bool GetDisplayExpressionsInCrashlogs() const;
171
172   LoadScriptFromSymFile GetLoadScriptFromSymbolFile() const;
173
174   LoadCWDlldbinitFile GetLoadCWDlldbinitFile() const;
175
176   Disassembler::HexImmediateStyle GetHexImmediateStyle() const;
177
178   MemoryModuleLoadLevel GetMemoryModuleLoadLevel() const;
179
180   bool GetUserSpecifiedTrapHandlerNames(Args &args) const;
181
182   void SetUserSpecifiedTrapHandlerNames(const Args &args);
183
184   bool GetNonStopModeEnabled() const;
185
186   void SetNonStopModeEnabled(bool b);
187
188   bool GetDisplayRuntimeSupportValues() const;
189
190   void SetDisplayRuntimeSupportValues(bool b);
191
192   bool GetDisplayRecognizedArguments() const;
193
194   void SetDisplayRecognizedArguments(bool b);
195
196   const ProcessLaunchInfo &GetProcessLaunchInfo();
197
198   void SetProcessLaunchInfo(const ProcessLaunchInfo &launch_info);
199
200   bool GetInjectLocalVariables(ExecutionContext *exe_ctx) const;
201
202   void SetInjectLocalVariables(ExecutionContext *exe_ctx, bool b);
203
204   bool GetUseModernTypeLookup() const;
205
206   void SetRequireHardwareBreakpoints(bool b);
207
208   bool GetRequireHardwareBreakpoints() const;
209
210 private:
211   // Callbacks for m_launch_info.
212   static void Arg0ValueChangedCallback(void *target_property_ptr,
213                                        OptionValue *);
214   static void RunArgsValueChangedCallback(void *target_property_ptr,
215                                           OptionValue *);
216   static void EnvVarsValueChangedCallback(void *target_property_ptr,
217                                           OptionValue *);
218   static void InheritEnvValueChangedCallback(void *target_property_ptr,
219                                              OptionValue *);
220   static void InputPathValueChangedCallback(void *target_property_ptr,
221                                             OptionValue *);
222   static void OutputPathValueChangedCallback(void *target_property_ptr,
223                                              OptionValue *);
224   static void ErrorPathValueChangedCallback(void *target_property_ptr,
225                                             OptionValue *);
226   static void DetachOnErrorValueChangedCallback(void *target_property_ptr,
227                                                 OptionValue *);
228   static void DisableASLRValueChangedCallback(void *target_property_ptr,
229                                               OptionValue *);
230   static void DisableSTDIOValueChangedCallback(void *target_property_ptr,
231                                                OptionValue *);
232
233   // Member variables.
234   ProcessLaunchInfo m_launch_info;
235   std::unique_ptr<TargetExperimentalProperties> m_experimental_properties_up;
236 };
237
238 class EvaluateExpressionOptions {
239 public:
240 // MSVC has a bug here that reports C4268: 'const' static/global data
241 // initialized with compiler generated default constructor fills the object
242 // with zeros. Confirmed that MSVC is *not* zero-initializing, it's just a
243 // bogus warning.
244 #if defined(_MSC_VER)
245 #pragma warning(push)
246 #pragma warning(disable : 4268)
247 #endif
248   static constexpr std::chrono::milliseconds default_timeout{500};
249 #if defined(_MSC_VER)
250 #pragma warning(pop)
251 #endif
252
253   static constexpr ExecutionPolicy default_execution_policy =
254       eExecutionPolicyOnlyWhenNeeded;
255
256   EvaluateExpressionOptions() = default;
257
258   ExecutionPolicy GetExecutionPolicy() const { return m_execution_policy; }
259
260   void SetExecutionPolicy(ExecutionPolicy policy = eExecutionPolicyAlways) {
261     m_execution_policy = policy;
262   }
263
264   lldb::LanguageType GetLanguage() const { return m_language; }
265
266   void SetLanguage(lldb::LanguageType language) { m_language = language; }
267
268   bool DoesCoerceToId() const { return m_coerce_to_id; }
269
270   const char *GetPrefix() const {
271     return (m_prefix.empty() ? nullptr : m_prefix.c_str());
272   }
273
274   void SetPrefix(const char *prefix) {
275     if (prefix && prefix[0])
276       m_prefix = prefix;
277     else
278       m_prefix.clear();
279   }
280
281   void SetCoerceToId(bool coerce = true) { m_coerce_to_id = coerce; }
282
283   bool DoesUnwindOnError() const { return m_unwind_on_error; }
284
285   void SetUnwindOnError(bool unwind = false) { m_unwind_on_error = unwind; }
286
287   bool DoesIgnoreBreakpoints() const { return m_ignore_breakpoints; }
288
289   void SetIgnoreBreakpoints(bool ignore = false) {
290     m_ignore_breakpoints = ignore;
291   }
292
293   bool DoesKeepInMemory() const { return m_keep_in_memory; }
294
295   void SetKeepInMemory(bool keep = true) { m_keep_in_memory = keep; }
296
297   lldb::DynamicValueType GetUseDynamic() const { return m_use_dynamic; }
298
299   void
300   SetUseDynamic(lldb::DynamicValueType dynamic = lldb::eDynamicCanRunTarget) {
301     m_use_dynamic = dynamic;
302   }
303
304   const Timeout<std::micro> &GetTimeout() const { return m_timeout; }
305
306   void SetTimeout(const Timeout<std::micro> &timeout) { m_timeout = timeout; }
307
308   const Timeout<std::micro> &GetOneThreadTimeout() const {
309     return m_one_thread_timeout;
310   }
311
312   void SetOneThreadTimeout(const Timeout<std::micro> &timeout) {
313     m_one_thread_timeout = timeout;
314   }
315
316   bool GetTryAllThreads() const { return m_try_others; }
317
318   void SetTryAllThreads(bool try_others = true) { m_try_others = try_others; }
319
320   bool GetStopOthers() const { return m_stop_others; }
321
322   void SetStopOthers(bool stop_others = true) { m_stop_others = stop_others; }
323
324   bool GetDebug() const { return m_debug; }
325
326   void SetDebug(bool b) {
327     m_debug = b;
328     if (m_debug)
329       m_generate_debug_info = true;
330   }
331
332   bool GetGenerateDebugInfo() const { return m_generate_debug_info; }
333
334   void SetGenerateDebugInfo(bool b) { m_generate_debug_info = b; }
335
336   bool GetColorizeErrors() const { return m_ansi_color_errors; }
337
338   void SetColorizeErrors(bool b) { m_ansi_color_errors = b; }
339
340   bool GetTrapExceptions() const { return m_trap_exceptions; }
341
342   void SetTrapExceptions(bool b) { m_trap_exceptions = b; }
343
344   bool GetREPLEnabled() const { return m_repl; }
345
346   void SetREPLEnabled(bool b) { m_repl = b; }
347
348   void SetCancelCallback(lldb::ExpressionCancelCallback callback, void *baton) {
349     m_cancel_callback_baton = baton;
350     m_cancel_callback = callback;
351   }
352
353   bool InvokeCancelCallback(lldb::ExpressionEvaluationPhase phase) const {
354     return ((m_cancel_callback != nullptr)
355                 ? m_cancel_callback(phase, m_cancel_callback_baton)
356                 : false);
357   }
358
359   // Allows the expression contents to be remapped to point to the specified
360   // file and line using #line directives.
361   void SetPoundLine(const char *path, uint32_t line) const {
362     if (path && path[0]) {
363       m_pound_line_file = path;
364       m_pound_line_line = line;
365     } else {
366       m_pound_line_file.clear();
367       m_pound_line_line = 0;
368     }
369   }
370
371   const char *GetPoundLineFilePath() const {
372     return (m_pound_line_file.empty() ? nullptr : m_pound_line_file.c_str());
373   }
374
375   uint32_t GetPoundLineLine() const { return m_pound_line_line; }
376
377   void SetResultIsInternal(bool b) { m_result_is_internal = b; }
378
379   bool GetResultIsInternal() const { return m_result_is_internal; }
380
381   void SetAutoApplyFixIts(bool b) { m_auto_apply_fixits = b; }
382
383   bool GetAutoApplyFixIts() const { return m_auto_apply_fixits; }
384
385   bool IsForUtilityExpr() const { return m_running_utility_expression; }
386
387   void SetIsForUtilityExpr(bool b) { m_running_utility_expression = b; }
388
389 private:
390   ExecutionPolicy m_execution_policy = default_execution_policy;
391   lldb::LanguageType m_language = lldb::eLanguageTypeUnknown;
392   std::string m_prefix;
393   bool m_coerce_to_id = false;
394   bool m_unwind_on_error = true;
395   bool m_ignore_breakpoints = false;
396   bool m_keep_in_memory = false;
397   bool m_try_others = true;
398   bool m_stop_others = true;
399   bool m_debug = false;
400   bool m_trap_exceptions = true;
401   bool m_repl = false;
402   bool m_generate_debug_info = false;
403   bool m_ansi_color_errors = false;
404   bool m_result_is_internal = false;
405   bool m_auto_apply_fixits = true;
406   /// True if the executed code should be treated as utility code that is only
407   /// used by LLDB internally.
408   bool m_running_utility_expression = false;
409
410   lldb::DynamicValueType m_use_dynamic = lldb::eNoDynamicValues;
411   Timeout<std::micro> m_timeout = default_timeout;
412   Timeout<std::micro> m_one_thread_timeout = llvm::None;
413   lldb::ExpressionCancelCallback m_cancel_callback = nullptr;
414   void *m_cancel_callback_baton = nullptr;
415   // If m_pound_line_file is not empty and m_pound_line_line is non-zero, use
416   // #line %u "%s" before the expression content to remap where the source
417   // originates
418   mutable std::string m_pound_line_file;
419   mutable uint32_t m_pound_line_line;
420 };
421
422 // Target
423 class Target : public std::enable_shared_from_this<Target>,
424                public TargetProperties,
425                public Broadcaster,
426                public ExecutionContextScope,
427                public ModuleList::Notifier {
428 public:
429   friend class TargetList;
430
431   /// Broadcaster event bits definitions.
432   enum {
433     eBroadcastBitBreakpointChanged = (1 << 0),
434     eBroadcastBitModulesLoaded = (1 << 1),
435     eBroadcastBitModulesUnloaded = (1 << 2),
436     eBroadcastBitWatchpointChanged = (1 << 3),
437     eBroadcastBitSymbolsLoaded = (1 << 4)
438   };
439
440   // These two functions fill out the Broadcaster interface:
441
442   static ConstString &GetStaticBroadcasterClass();
443
444   ConstString &GetBroadcasterClass() const override {
445     return GetStaticBroadcasterClass();
446   }
447
448   // This event data class is for use by the TargetList to broadcast new target
449   // notifications.
450   class TargetEventData : public EventData {
451   public:
452     TargetEventData(const lldb::TargetSP &target_sp);
453
454     TargetEventData(const lldb::TargetSP &target_sp,
455                     const ModuleList &module_list);
456
457     ~TargetEventData() override;
458
459     static ConstString GetFlavorString();
460
461     ConstString GetFlavor() const override {
462       return TargetEventData::GetFlavorString();
463     }
464
465     void Dump(Stream *s) const override;
466
467     static const TargetEventData *GetEventDataFromEvent(const Event *event_ptr);
468
469     static lldb::TargetSP GetTargetFromEvent(const Event *event_ptr);
470
471     static ModuleList GetModuleListFromEvent(const Event *event_ptr);
472
473     const lldb::TargetSP &GetTarget() const { return m_target_sp; }
474
475     const ModuleList &GetModuleList() const { return m_module_list; }
476
477   private:
478     lldb::TargetSP m_target_sp;
479     ModuleList m_module_list;
480
481     DISALLOW_COPY_AND_ASSIGN(TargetEventData);
482   };
483
484   ~Target() override;
485
486   static void SettingsInitialize();
487
488   static void SettingsTerminate();
489
490   static FileSpecList GetDefaultExecutableSearchPaths();
491
492   static FileSpecList GetDefaultDebugFileSearchPaths();
493
494   static ArchSpec GetDefaultArchitecture();
495
496   static void SetDefaultArchitecture(const ArchSpec &arch);
497
498   /// Find a binary on the system and return its Module, 
499   /// or return an existing Module that is already in the Target.
500   ///
501   /// Given a ModuleSpec, find a binary satisifying that specification,
502   /// or identify a matching Module already present in the Target,
503   /// and return a shared pointer to it.
504   ///
505   /// \param[in] module_spec
506   ///     The criteria that must be matched for the binary being loaded.
507   ///     e.g. UUID, architecture, file path.
508   ///
509   /// \param[in] notify
510   ///     If notify is true, and the Module is new to this Target, 
511   ///     Target::ModulesDidLoad will be called.  
512   ///     If notify is false, it is assumed that the caller is adding 
513   ///     multiple Modules and will call ModulesDidLoad with the 
514   ///     full list at the end.
515   ///     ModulesDidLoad must be called when a Module/Modules have
516   ///     been added to the target, one way or the other.
517   ///
518   /// \param[out] error_ptr
519   ///     Optional argument, pointing to a Status object to fill in 
520   ///     with any results / messages while attempting to find/load
521   ///     this binary.  Many callers will be internal functions that
522   ///     will handle / summarize the failures in a custom way and
523   ///     don't use these messages.
524   ///
525   /// \return 
526   ///     An empty ModuleSP will be returned if no matching file
527   ///     was found.  If error_ptr was non-nullptr, an error message
528   ///     will likely be provided.
529   lldb::ModuleSP GetOrCreateModule(const ModuleSpec &module_spec,
530                                    bool notify,
531                                    Status *error_ptr = nullptr);
532
533   // Settings accessors
534
535   static const lldb::TargetPropertiesSP &GetGlobalProperties();
536
537   std::recursive_mutex &GetAPIMutex() { return m_mutex; }
538
539   void DeleteCurrentProcess();
540
541   void CleanupProcess();
542
543   /// Dump a description of this object to a Stream.
544   ///
545   /// Dump a description of the contents of this object to the
546   /// supplied stream \a s. The dumped content will be only what has
547   /// been loaded or parsed up to this point at which this function
548   /// is called, so this is a good way to see what has been parsed
549   /// in a target.
550   ///
551   /// \param[in] s
552   ///     The stream to which to dump the object description.
553   void Dump(Stream *s, lldb::DescriptionLevel description_level);
554
555   // If listener_sp is null, the listener of the owning Debugger object will be
556   // used.
557   const lldb::ProcessSP &CreateProcess(lldb::ListenerSP listener_sp,
558                                        llvm::StringRef plugin_name,
559                                        const FileSpec *crash_file);
560
561   const lldb::ProcessSP &GetProcessSP() const;
562
563   bool IsValid() { return m_valid; }
564
565   void Destroy();
566
567   Status Launch(ProcessLaunchInfo &launch_info,
568                 Stream *stream); // Optional stream to receive first stop info
569
570   Status Attach(ProcessAttachInfo &attach_info,
571                 Stream *stream); // Optional stream to receive first stop info
572
573   // This part handles the breakpoints.
574
575   BreakpointList &GetBreakpointList(bool internal = false);
576
577   const BreakpointList &GetBreakpointList(bool internal = false) const;
578
579   lldb::BreakpointSP GetLastCreatedBreakpoint() {
580     return m_last_created_breakpoint;
581   }
582
583   lldb::BreakpointSP GetBreakpointByID(lldb::break_id_t break_id);
584
585   // Use this to create a file and line breakpoint to a given module or all
586   // module it is nullptr
587   lldb::BreakpointSP CreateBreakpoint(const FileSpecList *containingModules,
588                                       const FileSpec &file, uint32_t line_no,
589                                       uint32_t column, lldb::addr_t offset,
590                                       LazyBool check_inlines,
591                                       LazyBool skip_prologue, bool internal,
592                                       bool request_hardware,
593                                       LazyBool move_to_nearest_code);
594
595   // Use this to create breakpoint that matches regex against the source lines
596   // in files given in source_file_list: If function_names is non-empty, also
597   // filter by function after the matches are made.
598   lldb::BreakpointSP CreateSourceRegexBreakpoint(
599       const FileSpecList *containingModules,
600       const FileSpecList *source_file_list,
601       const std::unordered_set<std::string> &function_names,
602       RegularExpression &source_regex, bool internal, bool request_hardware,
603       LazyBool move_to_nearest_code);
604
605   // Use this to create a breakpoint from a load address
606   lldb::BreakpointSP CreateBreakpoint(lldb::addr_t load_addr, bool internal,
607                                       bool request_hardware);
608
609   // Use this to create a breakpoint from a load address and a module file spec
610   lldb::BreakpointSP CreateAddressInModuleBreakpoint(lldb::addr_t file_addr,
611                                                      bool internal,
612                                                      const FileSpec *file_spec,
613                                                      bool request_hardware);
614
615   // Use this to create Address breakpoints:
616   lldb::BreakpointSP CreateBreakpoint(const Address &addr, bool internal,
617                                       bool request_hardware);
618
619   // Use this to create a function breakpoint by regexp in
620   // containingModule/containingSourceFiles, or all modules if it is nullptr
621   // When "skip_prologue is set to eLazyBoolCalculate, we use the current
622   // target setting, else we use the values passed in
623   lldb::BreakpointSP CreateFuncRegexBreakpoint(
624       const FileSpecList *containingModules,
625       const FileSpecList *containingSourceFiles, RegularExpression &func_regexp,
626       lldb::LanguageType requested_language, LazyBool skip_prologue,
627       bool internal, bool request_hardware);
628
629   // Use this to create a function breakpoint by name in containingModule, or
630   // all modules if it is nullptr When "skip_prologue is set to
631   // eLazyBoolCalculate, we use the current target setting, else we use the
632   // values passed in. func_name_type_mask is or'ed values from the
633   // FunctionNameType enum.
634   lldb::BreakpointSP CreateBreakpoint(
635       const FileSpecList *containingModules,
636       const FileSpecList *containingSourceFiles, const char *func_name,
637       lldb::FunctionNameType func_name_type_mask, lldb::LanguageType language,
638       lldb::addr_t offset, LazyBool skip_prologue, bool internal,
639       bool request_hardware);
640
641   lldb::BreakpointSP
642   CreateExceptionBreakpoint(enum lldb::LanguageType language, bool catch_bp,
643                             bool throw_bp, bool internal,
644                             Args *additional_args = nullptr,
645                             Status *additional_args_error = nullptr);
646
647   lldb::BreakpointSP
648   CreateScriptedBreakpoint(const llvm::StringRef class_name,
649                            const FileSpecList *containingModules,
650                            const FileSpecList *containingSourceFiles,
651                            bool internal,
652                            bool request_hardware,
653                            StructuredData::ObjectSP extra_args_sp,
654                            Status *creation_error = nullptr);
655
656   // This is the same as the func_name breakpoint except that you can specify a
657   // vector of names.  This is cheaper than a regular expression breakpoint in
658   // the case where you just want to set a breakpoint on a set of names you
659   // already know. func_name_type_mask is or'ed values from the
660   // FunctionNameType enum.
661   lldb::BreakpointSP CreateBreakpoint(
662       const FileSpecList *containingModules,
663       const FileSpecList *containingSourceFiles, const char *func_names[],
664       size_t num_names, lldb::FunctionNameType func_name_type_mask,
665       lldb::LanguageType language, lldb::addr_t offset, LazyBool skip_prologue,
666       bool internal, bool request_hardware);
667
668   lldb::BreakpointSP
669   CreateBreakpoint(const FileSpecList *containingModules,
670                    const FileSpecList *containingSourceFiles,
671                    const std::vector<std::string> &func_names,
672                    lldb::FunctionNameType func_name_type_mask,
673                    lldb::LanguageType language, lldb::addr_t m_offset,
674                    LazyBool skip_prologue, bool internal,
675                    bool request_hardware);
676
677   // Use this to create a general breakpoint:
678   lldb::BreakpointSP CreateBreakpoint(lldb::SearchFilterSP &filter_sp,
679                                       lldb::BreakpointResolverSP &resolver_sp,
680                                       bool internal, bool request_hardware,
681                                       bool resolve_indirect_symbols);
682
683   // Use this to create a watchpoint:
684   lldb::WatchpointSP CreateWatchpoint(lldb::addr_t addr, size_t size,
685                                       const CompilerType *type, uint32_t kind,
686                                       Status &error);
687
688   lldb::WatchpointSP GetLastCreatedWatchpoint() {
689     return m_last_created_watchpoint;
690   }
691
692   WatchpointList &GetWatchpointList() { return m_watchpoint_list; }
693   
694   // Manages breakpoint names:
695   void AddNameToBreakpoint(BreakpointID &id, const char *name, Status &error);
696   
697   void AddNameToBreakpoint(lldb::BreakpointSP &bp_sp, const char *name, 
698                            Status &error);
699   
700   void RemoveNameFromBreakpoint(lldb::BreakpointSP &bp_sp, 
701                                 ConstString name);
702   
703   BreakpointName *FindBreakpointName(ConstString name, bool can_create, 
704                                      Status &error);
705                                      
706   void DeleteBreakpointName(ConstString name);
707   
708   void ConfigureBreakpointName(BreakpointName &bp_name,
709                                const BreakpointOptions &options,
710                                const BreakpointName::Permissions &permissions);
711  void ApplyNameToBreakpoints(BreakpointName &bp_name);
712   
713   // This takes ownership of the name obj passed in.
714   void AddBreakpointName(BreakpointName *bp_name);
715   
716   void GetBreakpointNames(std::vector<std::string> &names);
717                                
718   //This call removes ALL breakpoints regardless of permission.
719   void RemoveAllBreakpoints(bool internal_also = false);
720   
721   // This removes all the breakpoints, but obeys the ePermDelete on them.
722   void RemoveAllowedBreakpoints();
723
724   void DisableAllBreakpoints(bool internal_also = false);
725   
726   void DisableAllowedBreakpoints();
727
728   void EnableAllBreakpoints(bool internal_also = false);
729   
730   void EnableAllowedBreakpoints();
731
732   bool DisableBreakpointByID(lldb::break_id_t break_id);
733
734   bool EnableBreakpointByID(lldb::break_id_t break_id);
735
736   bool RemoveBreakpointByID(lldb::break_id_t break_id);
737
738   // The flag 'end_to_end', default to true, signifies that the operation is
739   // performed end to end, for both the debugger and the debuggee.
740
741   bool RemoveAllWatchpoints(bool end_to_end = true);
742
743   bool DisableAllWatchpoints(bool end_to_end = true);
744
745   bool EnableAllWatchpoints(bool end_to_end = true);
746
747   bool ClearAllWatchpointHitCounts();
748
749   bool ClearAllWatchpointHistoricValues();
750
751   bool IgnoreAllWatchpoints(uint32_t ignore_count);
752
753   bool DisableWatchpointByID(lldb::watch_id_t watch_id);
754
755   bool EnableWatchpointByID(lldb::watch_id_t watch_id);
756
757   bool RemoveWatchpointByID(lldb::watch_id_t watch_id);
758
759   bool IgnoreWatchpointByID(lldb::watch_id_t watch_id, uint32_t ignore_count);
760
761   Status SerializeBreakpointsToFile(const FileSpec &file,
762                                     const BreakpointIDList &bp_ids,
763                                     bool append);
764
765   Status CreateBreakpointsFromFile(const FileSpec &file,
766                                    BreakpointIDList &new_bps);
767
768   Status CreateBreakpointsFromFile(const FileSpec &file,
769                                    std::vector<std::string> &names,
770                                    BreakpointIDList &new_bps);
771
772   /// Get \a load_addr as a callable code load address for this target
773   ///
774   /// Take \a load_addr and potentially add any address bits that are
775   /// needed to make the address callable. For ARM this can set bit
776   /// zero (if it already isn't) if \a load_addr is a thumb function.
777   /// If \a addr_class is set to AddressClass::eInvalid, then the address
778   /// adjustment will always happen. If it is set to an address class
779   /// that doesn't have code in it, LLDB_INVALID_ADDRESS will be
780   /// returned.
781   lldb::addr_t GetCallableLoadAddress(
782       lldb::addr_t load_addr,
783       AddressClass addr_class = AddressClass::eInvalid) const;
784
785   /// Get \a load_addr as an opcode for this target.
786   ///
787   /// Take \a load_addr and potentially strip any address bits that are
788   /// needed to make the address point to an opcode. For ARM this can
789   /// clear bit zero (if it already isn't) if \a load_addr is a
790   /// thumb function and load_addr is in code.
791   /// If \a addr_class is set to AddressClass::eInvalid, then the address
792   /// adjustment will always happen. If it is set to an address class
793   /// that doesn't have code in it, LLDB_INVALID_ADDRESS will be
794   /// returned.
795   lldb::addr_t
796   GetOpcodeLoadAddress(lldb::addr_t load_addr,
797                        AddressClass addr_class = AddressClass::eInvalid) const;
798
799   // Get load_addr as breakable load address for this target. Take a addr and
800   // check if for any reason there is a better address than this to put a
801   // breakpoint on. If there is then return that address. For MIPS, if
802   // instruction at addr is a delay slot instruction then this method will find
803   // the address of its previous instruction and return that address.
804   lldb::addr_t GetBreakableLoadAddress(lldb::addr_t addr);
805
806   void ModulesDidLoad(ModuleList &module_list);
807
808   void ModulesDidUnload(ModuleList &module_list, bool delete_locations);
809
810   void SymbolsDidLoad(ModuleList &module_list);
811
812   void ClearModules(bool delete_locations);
813
814   /// Called as the last function in Process::DidExec().
815   ///
816   /// Process::DidExec() will clear a lot of state in the process,
817   /// then try to reload a dynamic loader plugin to discover what
818   /// binaries are currently available and then this function should
819   /// be called to allow the target to do any cleanup after everything
820   /// has been figured out. It can remove breakpoints that no longer
821   /// make sense as the exec might have changed the target
822   /// architecture, and unloaded some modules that might get deleted.
823   void DidExec();
824
825   /// Gets the module for the main executable.
826   ///
827   /// Each process has a notion of a main executable that is the file
828   /// that will be executed or attached to. Executable files can have
829   /// dependent modules that are discovered from the object files, or
830   /// discovered at runtime as things are dynamically loaded.
831   ///
832   /// \return
833   ///     The shared pointer to the executable module which can
834   ///     contains a nullptr Module object if no executable has been
835   ///     set.
836   ///
837   /// \see DynamicLoader
838   /// \see ObjectFile::GetDependentModules (FileSpecList&)
839   /// \see Process::SetExecutableModule(lldb::ModuleSP&)
840   lldb::ModuleSP GetExecutableModule();
841
842   Module *GetExecutableModulePointer();
843
844   /// Set the main executable module.
845   ///
846   /// Each process has a notion of a main executable that is the file
847   /// that will be executed or attached to. Executable files can have
848   /// dependent modules that are discovered from the object files, or
849   /// discovered at runtime as things are dynamically loaded.
850   ///
851   /// Setting the executable causes any of the current dependent
852   /// image information to be cleared and replaced with the static
853   /// dependent image information found by calling
854   /// ObjectFile::GetDependentModules (FileSpecList&) on the main
855   /// executable and any modules on which it depends. Calling
856   /// Process::GetImages() will return the newly found images that
857   /// were obtained from all of the object files.
858   ///
859   /// \param[in] module_sp
860   ///     A shared pointer reference to the module that will become
861   ///     the main executable for this process.
862   ///
863   /// \param[in] load_dependent_files
864   ///     If \b true then ask the object files to track down any
865   ///     known dependent files.
866   ///
867   /// \see ObjectFile::GetDependentModules (FileSpecList&)
868   /// \see Process::GetImages()
869   void SetExecutableModule(
870       lldb::ModuleSP &module_sp,
871       LoadDependentFiles load_dependent_files = eLoadDependentsDefault);
872
873   bool LoadScriptingResources(std::list<Status> &errors,
874                               Stream *feedback_stream = nullptr,
875                               bool continue_on_error = true) {
876     return m_images.LoadScriptingResourcesInTarget(
877         this, errors, feedback_stream, continue_on_error);
878   }
879
880   /// Get accessor for the images for this process.
881   ///
882   /// Each process has a notion of a main executable that is the file
883   /// that will be executed or attached to. Executable files can have
884   /// dependent modules that are discovered from the object files, or
885   /// discovered at runtime as things are dynamically loaded. After
886   /// a main executable has been set, the images will contain a list
887   /// of all the files that the executable depends upon as far as the
888   /// object files know. These images will usually contain valid file
889   /// virtual addresses only. When the process is launched or attached
890   /// to, the DynamicLoader plug-in will discover where these images
891   /// were loaded in memory and will resolve the load virtual
892   /// addresses is each image, and also in images that are loaded by
893   /// code.
894   ///
895   /// \return
896   ///     A list of Module objects in a module list.
897   const ModuleList &GetImages() const { return m_images; }
898
899   ModuleList &GetImages() { return m_images; }
900
901   /// Return whether this FileSpec corresponds to a module that should be
902   /// considered for general searches.
903   ///
904   /// This API will be consulted by the SearchFilterForUnconstrainedSearches
905   /// and any module that returns \b true will not be searched.  Note the
906   /// SearchFilterForUnconstrainedSearches is the search filter that
907   /// gets used in the CreateBreakpoint calls when no modules is provided.
908   ///
909   /// The target call at present just consults the Platform's call of the
910   /// same name.
911   ///
912   /// \param[in] module_sp
913   ///     A shared pointer reference to the module that checked.
914   ///
915   /// \return \b true if the module should be excluded, \b false otherwise.
916   bool ModuleIsExcludedForUnconstrainedSearches(const FileSpec &module_spec);
917
918   /// Return whether this module should be considered for general searches.
919   ///
920   /// This API will be consulted by the SearchFilterForUnconstrainedSearches
921   /// and any module that returns \b true will not be searched.  Note the
922   /// SearchFilterForUnconstrainedSearches is the search filter that
923   /// gets used in the CreateBreakpoint calls when no modules is provided.
924   ///
925   /// The target call at present just consults the Platform's call of the
926   /// same name.
927   ///
928   /// FIXME: When we get time we should add a way for the user to set modules
929   /// that they
930   /// don't want searched, in addition to or instead of the platform ones.
931   ///
932   /// \param[in] module_sp
933   ///     A shared pointer reference to the module that checked.
934   ///
935   /// \return \b true if the module should be excluded, \b false otherwise.
936   bool
937   ModuleIsExcludedForUnconstrainedSearches(const lldb::ModuleSP &module_sp);
938
939   const ArchSpec &GetArchitecture() const { return m_arch.GetSpec(); }
940
941   /// Set the architecture for this target.
942   ///
943   /// If the current target has no Images read in, then this just sets the
944   /// architecture, which will be used to select the architecture of the
945   /// ExecutableModule when that is set. If the current target has an
946   /// ExecutableModule, then calling SetArchitecture with a different
947   /// architecture from the currently selected one will reset the
948   /// ExecutableModule to that slice of the file backing the ExecutableModule.
949   /// If the file backing the ExecutableModule does not contain a fork of this
950   /// architecture, then this code will return false, and the architecture
951   /// won't be changed. If the input arch_spec is the same as the already set
952   /// architecture, this is a no-op.
953   ///
954   /// \param[in] arch_spec
955   ///     The new architecture.
956   ///
957   /// \param[in] set_platform
958   ///     If \b true, then the platform will be adjusted if the currently
959   ///     selected platform is not compatible with the archicture being set.
960   ///     If \b false, then just the architecture will be set even if the
961   ///     currently selected platform isn't compatible (in case it might be
962   ///     manually set following this function call).
963   ///
964   /// \return
965   ///     \b true if the architecture was successfully set, \bfalse otherwise.
966   bool SetArchitecture(const ArchSpec &arch_spec, bool set_platform = false);
967
968   bool MergeArchitecture(const ArchSpec &arch_spec);
969
970   Architecture *GetArchitecturePlugin() const { return m_arch.GetPlugin(); }
971
972   Debugger &GetDebugger() { return m_debugger; }
973
974   size_t ReadMemoryFromFileCache(const Address &addr, void *dst, size_t dst_len,
975                                  Status &error);
976
977   // Reading memory through the target allows us to skip going to the process
978   // for reading memory if possible and it allows us to try and read from any
979   // constant sections in our object files on disk. If you always want live
980   // program memory, read straight from the process. If you possibly want to
981   // read from const sections in object files, read from the target. This
982   // version of ReadMemory will try and read memory from the process if the
983   // process is alive. The order is:
984   // 1 - if (prefer_file_cache == true) then read from object file cache
985   // 2 - if there is a valid process, try and read from its memory
986   // 3 - if (prefer_file_cache == false) then read from object file cache
987   size_t ReadMemory(const Address &addr, bool prefer_file_cache, void *dst,
988                     size_t dst_len, Status &error,
989                     lldb::addr_t *load_addr_ptr = nullptr);
990
991   size_t ReadCStringFromMemory(const Address &addr, std::string &out_str,
992                                Status &error);
993
994   size_t ReadCStringFromMemory(const Address &addr, char *dst,
995                                size_t dst_max_len, Status &result_error);
996
997   size_t ReadScalarIntegerFromMemory(const Address &addr,
998                                      bool prefer_file_cache, uint32_t byte_size,
999                                      bool is_signed, Scalar &scalar,
1000                                      Status &error);
1001
1002   uint64_t ReadUnsignedIntegerFromMemory(const Address &addr,
1003                                          bool prefer_file_cache,
1004                                          size_t integer_byte_size,
1005                                          uint64_t fail_value, Status &error);
1006
1007   bool ReadPointerFromMemory(const Address &addr, bool prefer_file_cache,
1008                              Status &error, Address &pointer_addr);
1009
1010   SectionLoadList &GetSectionLoadList() {
1011     return m_section_load_history.GetCurrentSectionLoadList();
1012   }
1013
1014   static Target *GetTargetFromContexts(const ExecutionContext *exe_ctx_ptr,
1015                                        const SymbolContext *sc_ptr);
1016
1017   // lldb::ExecutionContextScope pure virtual functions
1018   lldb::TargetSP CalculateTarget() override;
1019
1020   lldb::ProcessSP CalculateProcess() override;
1021
1022   lldb::ThreadSP CalculateThread() override;
1023
1024   lldb::StackFrameSP CalculateStackFrame() override;
1025
1026   void CalculateExecutionContext(ExecutionContext &exe_ctx) override;
1027
1028   PathMappingList &GetImageSearchPathList();
1029
1030   TypeSystem *GetScratchTypeSystemForLanguage(Status *error,
1031                                               lldb::LanguageType language,
1032                                               bool create_on_demand = true);
1033
1034   PersistentExpressionState *
1035   GetPersistentExpressionStateForLanguage(lldb::LanguageType language);
1036
1037   // Creates a UserExpression for the given language, the rest of the
1038   // parameters have the same meaning as for the UserExpression constructor.
1039   // Returns a new-ed object which the caller owns.
1040
1041   UserExpression *GetUserExpressionForLanguage(
1042       llvm::StringRef expr, llvm::StringRef prefix, lldb::LanguageType language,
1043       Expression::ResultType desired_type,
1044       const EvaluateExpressionOptions &options,
1045       ValueObject *ctx_obj, Status &error);
1046
1047   // Creates a FunctionCaller for the given language, the rest of the
1048   // parameters have the same meaning as for the FunctionCaller constructor.
1049   // Since a FunctionCaller can't be
1050   // IR Interpreted, it makes no sense to call this with an
1051   // ExecutionContextScope that lacks
1052   // a Process.
1053   // Returns a new-ed object which the caller owns.
1054
1055   FunctionCaller *GetFunctionCallerForLanguage(lldb::LanguageType language,
1056                                                const CompilerType &return_type,
1057                                                const Address &function_address,
1058                                                const ValueList &arg_value_list,
1059                                                const char *name, Status &error);
1060
1061   // Creates a UtilityFunction for the given language, the rest of the
1062   // parameters have the same meaning as for the UtilityFunction constructor.
1063   // Returns a new-ed object which the caller owns.
1064
1065   UtilityFunction *GetUtilityFunctionForLanguage(const char *expr,
1066                                                  lldb::LanguageType language,
1067                                                  const char *name,
1068                                                  Status &error);
1069
1070   ClangASTContext *GetScratchClangASTContext(bool create_on_demand = true);
1071
1072   lldb::ClangASTImporterSP GetClangASTImporter();
1073
1074   // Install any files through the platform that need be to installed prior to
1075   // launching or attaching.
1076   Status Install(ProcessLaunchInfo *launch_info);
1077
1078   bool ResolveFileAddress(lldb::addr_t load_addr, Address &so_addr);
1079
1080   bool ResolveLoadAddress(lldb::addr_t load_addr, Address &so_addr,
1081                           uint32_t stop_id = SectionLoadHistory::eStopIDNow);
1082
1083   bool SetSectionLoadAddress(const lldb::SectionSP &section,
1084                              lldb::addr_t load_addr,
1085                              bool warn_multiple = false);
1086
1087   size_t UnloadModuleSections(const lldb::ModuleSP &module_sp);
1088
1089   size_t UnloadModuleSections(const ModuleList &module_list);
1090
1091   bool SetSectionUnloaded(const lldb::SectionSP &section_sp);
1092
1093   bool SetSectionUnloaded(const lldb::SectionSP &section_sp,
1094                           lldb::addr_t load_addr);
1095
1096   void ClearAllLoadedSections();
1097
1098   // Since expressions results can persist beyond the lifetime of a process,
1099   // and the const expression results are available after a process is gone, we
1100   // provide a way for expressions to be evaluated from the Target itself. If
1101   // an expression is going to be run, then it should have a frame filled in in
1102   // the execution context.
1103   lldb::ExpressionResults EvaluateExpression(
1104       llvm::StringRef expression, ExecutionContextScope *exe_scope,
1105       lldb::ValueObjectSP &result_valobj_sp,
1106       const EvaluateExpressionOptions &options = EvaluateExpressionOptions(),
1107       std::string *fixed_expression = nullptr,
1108       ValueObject *ctx_obj = nullptr);
1109
1110   lldb::ExpressionVariableSP GetPersistentVariable(ConstString name);
1111
1112   /// Return the next available number for numbered persistent variables.
1113   unsigned GetNextPersistentVariableIndex() {
1114     return m_next_persistent_variable_index++;
1115   }
1116
1117   lldb::addr_t GetPersistentSymbol(ConstString name);
1118
1119   // Target Stop Hooks
1120   class StopHook : public UserID {
1121   public:
1122     StopHook(const StopHook &rhs);
1123
1124     ~StopHook();
1125
1126     StringList *GetCommandPointer() { return &m_commands; }
1127
1128     const StringList &GetCommands() { return m_commands; }
1129
1130     lldb::TargetSP &GetTarget() { return m_target_sp; }
1131
1132     void SetCommands(StringList &in_commands) { m_commands = in_commands; }
1133
1134     // Set the specifier.  The stop hook will own the specifier, and is
1135     // responsible for deleting it when we're done.
1136     void SetSpecifier(SymbolContextSpecifier *specifier);
1137
1138     SymbolContextSpecifier *GetSpecifier() { return m_specifier_sp.get(); }
1139
1140     // Set the Thread Specifier.  The stop hook will own the thread specifier,
1141     // and is responsible for deleting it when we're done.
1142     void SetThreadSpecifier(ThreadSpec *specifier);
1143
1144     ThreadSpec *GetThreadSpecifier() { return m_thread_spec_up.get(); }
1145
1146     bool IsActive() { return m_active; }
1147
1148     void SetIsActive(bool is_active) { m_active = is_active; }
1149
1150     void SetAutoContinue(bool auto_continue) {m_auto_continue = auto_continue;}
1151
1152     bool GetAutoContinue() const { return m_auto_continue; }
1153
1154     void GetDescription(Stream *s, lldb::DescriptionLevel level) const;
1155
1156   private:
1157     lldb::TargetSP m_target_sp;
1158     StringList m_commands;
1159     lldb::SymbolContextSpecifierSP m_specifier_sp;
1160     std::unique_ptr<ThreadSpec> m_thread_spec_up;
1161     bool m_active = true;
1162     bool m_auto_continue = false;
1163
1164     // Use CreateStopHook to make a new empty stop hook. The GetCommandPointer
1165     // and fill it with commands, and SetSpecifier to set the specifier shared
1166     // pointer (can be null, that will match anything.)
1167     StopHook(lldb::TargetSP target_sp, lldb::user_id_t uid);
1168     friend class Target;
1169   };
1170   typedef std::shared_ptr<StopHook> StopHookSP;
1171
1172   // Add an empty stop hook to the Target's stop hook list, and returns a
1173   // shared pointer to it in new_hook. Returns the id of the new hook.
1174   StopHookSP CreateStopHook();
1175
1176   void RunStopHooks();
1177
1178   size_t GetStopHookSize();
1179
1180   bool SetSuppresStopHooks(bool suppress) {
1181     bool old_value = m_suppress_stop_hooks;
1182     m_suppress_stop_hooks = suppress;
1183     return old_value;
1184   }
1185
1186   bool GetSuppressStopHooks() { return m_suppress_stop_hooks; }
1187
1188   bool RemoveStopHookByID(lldb::user_id_t uid);
1189
1190   void RemoveAllStopHooks();
1191
1192   StopHookSP GetStopHookByID(lldb::user_id_t uid);
1193
1194   bool SetStopHookActiveStateByID(lldb::user_id_t uid, bool active_state);
1195
1196   void SetAllStopHooksActiveState(bool active_state);
1197
1198   size_t GetNumStopHooks() const { return m_stop_hooks.size(); }
1199
1200   StopHookSP GetStopHookAtIndex(size_t index) {
1201     if (index >= GetNumStopHooks())
1202       return StopHookSP();
1203     StopHookCollection::iterator pos = m_stop_hooks.begin();
1204
1205     while (index > 0) {
1206       pos++;
1207       index--;
1208     }
1209     return (*pos).second;
1210   }
1211
1212   lldb::PlatformSP GetPlatform() { return m_platform_sp; }
1213
1214   void SetPlatform(const lldb::PlatformSP &platform_sp) {
1215     m_platform_sp = platform_sp;
1216   }
1217
1218   SourceManager &GetSourceManager();
1219
1220   ClangModulesDeclVendor *GetClangModulesDeclVendor();
1221
1222   // Methods.
1223   lldb::SearchFilterSP
1224   GetSearchFilterForModule(const FileSpec *containingModule);
1225
1226   lldb::SearchFilterSP
1227   GetSearchFilterForModuleList(const FileSpecList *containingModuleList);
1228
1229   lldb::SearchFilterSP
1230   GetSearchFilterForModuleAndCUList(const FileSpecList *containingModules,
1231                                     const FileSpecList *containingSourceFiles);
1232
1233   lldb::REPLSP GetREPL(Status &err, lldb::LanguageType language,
1234                        const char *repl_options, bool can_create);
1235
1236   void SetREPL(lldb::LanguageType language, lldb::REPLSP repl_sp);
1237
1238 protected:
1239   /// Implementing of ModuleList::Notifier.
1240
1241   void NotifyModuleAdded(const ModuleList &module_list,
1242                          const lldb::ModuleSP &module_sp) override;
1243
1244   void NotifyModuleRemoved(const ModuleList &module_list,
1245                          const lldb::ModuleSP &module_sp) override;
1246
1247   void NotifyModuleUpdated(const ModuleList &module_list,
1248                            const lldb::ModuleSP &old_module_sp,
1249                            const lldb::ModuleSP &new_module_sp) override;
1250
1251   void NotifyWillClearList(const ModuleList &module_list) override;
1252
1253   void NotifyModulesRemoved(lldb_private::ModuleList &module_list) override;
1254
1255   class Arch {
1256   public:
1257     explicit Arch(const ArchSpec &spec);
1258     const Arch &operator=(const ArchSpec &spec);
1259
1260     const ArchSpec &GetSpec() const { return m_spec; }
1261     Architecture *GetPlugin() const { return m_plugin_up.get(); }
1262
1263   private:
1264     ArchSpec m_spec;
1265     std::unique_ptr<Architecture> m_plugin_up;
1266   };
1267   // Member variables.
1268   Debugger &m_debugger;
1269   lldb::PlatformSP m_platform_sp; ///< The platform for this target.
1270   std::recursive_mutex m_mutex; ///< An API mutex that is used by the lldb::SB*
1271                                 /// classes make the SB interface thread safe
1272   Arch m_arch;
1273   ModuleList m_images; ///< The list of images for this process (shared
1274                        /// libraries and anything dynamically loaded).
1275   SectionLoadHistory m_section_load_history;
1276   BreakpointList m_breakpoint_list;
1277   BreakpointList m_internal_breakpoint_list;
1278   using BreakpointNameList = std::map<ConstString, BreakpointName *>;
1279   BreakpointNameList m_breakpoint_names;
1280   
1281   lldb::BreakpointSP m_last_created_breakpoint;
1282   WatchpointList m_watchpoint_list;
1283   lldb::WatchpointSP m_last_created_watchpoint;
1284   // We want to tightly control the process destruction process so we can
1285   // correctly tear down everything that we need to, so the only class that
1286   // knows about the process lifespan is this target class.
1287   lldb::ProcessSP m_process_sp;
1288   lldb::SearchFilterSP m_search_filter_sp;
1289   PathMappingList m_image_search_paths;
1290   TypeSystemMap m_scratch_type_system_map;
1291
1292   typedef std::map<lldb::LanguageType, lldb::REPLSP> REPLMap;
1293   REPLMap m_repl_map;
1294
1295   lldb::ClangASTImporterSP m_ast_importer_sp;
1296   lldb::ClangModulesDeclVendorUP m_clang_modules_decl_vendor_up;
1297
1298   lldb::SourceManagerUP m_source_manager_up;
1299
1300   typedef std::map<lldb::user_id_t, StopHookSP> StopHookCollection;
1301   StopHookCollection m_stop_hooks;
1302   lldb::user_id_t m_stop_hook_next_id;
1303   bool m_valid;
1304   bool m_suppress_stop_hooks;
1305   bool m_is_dummy_target;
1306   unsigned m_next_persistent_variable_index = 0;
1307
1308   static void ImageSearchPathsChanged(const PathMappingList &path_list,
1309                                       void *baton);
1310
1311   // Utilities for `statistics` command.
1312 private:
1313   std::vector<uint32_t> m_stats_storage;
1314   bool m_collecting_stats = false;
1315
1316 public:
1317   void SetCollectingStats(bool v) { m_collecting_stats = v; }
1318
1319   bool GetCollectingStats() { return m_collecting_stats; }
1320
1321   void IncrementStats(lldb_private::StatisticKind key) {
1322     if (!GetCollectingStats())
1323       return;
1324     lldbassert(key < lldb_private::StatisticKind::StatisticMax &&
1325                "invalid statistics!");
1326     m_stats_storage[key] += 1;
1327   }
1328
1329   std::vector<uint32_t> GetStatistics() { return m_stats_storage; }
1330
1331 private:
1332   /// Construct with optional file and arch.
1333   ///
1334   /// This member is private. Clients must use
1335   /// TargetList::CreateTarget(const FileSpec*, const ArchSpec*)
1336   /// so all targets can be tracked from the central target list.
1337   ///
1338   /// \see TargetList::CreateTarget(const FileSpec*, const ArchSpec*)
1339   Target(Debugger &debugger, const ArchSpec &target_arch,
1340          const lldb::PlatformSP &platform_sp, bool is_dummy_target);
1341
1342   // Helper function.
1343   bool ProcessIsValid();
1344
1345   // Copy breakpoints, stop hooks and so forth from the dummy target:
1346   void PrimeFromDummyTarget(Target *dummy_target);
1347
1348   void AddBreakpoint(lldb::BreakpointSP breakpoint_sp, bool internal);
1349
1350   void FinalizeFileActions(ProcessLaunchInfo &info);
1351
1352   DISALLOW_COPY_AND_ASSIGN(Target);
1353 };
1354
1355 } // namespace lldb_private
1356
1357 #endif // liblldb_Target_h_