LLDB  mainline
Target.h
Go to the documentation of this file.
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 
21 #include "lldb/Core/Architecture.h"
22 #include "lldb/Core/Disassembler.h"
23 #include "lldb/Core/ModuleList.h"
27 #include "lldb/Symbol/TypeSystem.h"
31 #include "lldb/Utility/ArchSpec.h"
34 #include "lldb/Utility/Timeout.h"
35 #include "lldb/lldb-public.h"
36 
37 namespace lldb_private {
38 
39 OptionEnumValues GetDynamicValueTypes();
40 
41 typedef enum InlineStrategy {
46 
47 typedef enum LoadScriptFromSymFile {
52 
53 typedef enum LoadCWDlldbinitFile {
58 
59 typedef enum LoadDependentFiles {
64 
65 // TargetProperties
67 public:
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 
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 =
255 
256  EvaluateExpressionOptions() = default;
257 
258  ExecutionPolicy GetExecutionPolicy() const { return m_execution_policy; }
259 
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
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 
309  return m_one_thread_timeout;
310  }
311 
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 
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;
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 
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 FileSpecList GetDefaultClangModuleSearchPaths();
495 
496  static ArchSpec GetDefaultArchitecture();
497 
498  static void SetDefaultArchitecture(const ArchSpec &arch);
499 
500  /// Find a binary on the system and return its Module,
501  /// or return an existing Module that is already in the Target.
502  ///
503  /// Given a ModuleSpec, find a binary satisifying that specification,
504  /// or identify a matching Module already present in the Target,
505  /// and return a shared pointer to it.
506  ///
507  /// \param[in] module_spec
508  /// The criteria that must be matched for the binary being loaded.
509  /// e.g. UUID, architecture, file path.
510  ///
511  /// \param[in] notify
512  /// If notify is true, and the Module is new to this Target,
513  /// Target::ModulesDidLoad will be called.
514  /// If notify is false, it is assumed that the caller is adding
515  /// multiple Modules and will call ModulesDidLoad with the
516  /// full list at the end.
517  /// ModulesDidLoad must be called when a Module/Modules have
518  /// been added to the target, one way or the other.
519  ///
520  /// \param[out] error_ptr
521  /// Optional argument, pointing to a Status object to fill in
522  /// with any results / messages while attempting to find/load
523  /// this binary. Many callers will be internal functions that
524  /// will handle / summarize the failures in a custom way and
525  /// don't use these messages.
526  ///
527  /// \return
528  /// An empty ModuleSP will be returned if no matching file
529  /// was found. If error_ptr was non-nullptr, an error message
530  /// will likely be provided.
531  lldb::ModuleSP GetOrCreateModule(const ModuleSpec &module_spec,
532  bool notify,
533  Status *error_ptr = nullptr);
534 
535  // Settings accessors
536 
537  static const lldb::TargetPropertiesSP &GetGlobalProperties();
538 
539  std::recursive_mutex &GetAPIMutex() { return m_mutex; }
540 
541  void DeleteCurrentProcess();
542 
543  void CleanupProcess();
544 
545  /// Dump a description of this object to a Stream.
546  ///
547  /// Dump a description of the contents of this object to the
548  /// supplied stream \a s. The dumped content will be only what has
549  /// been loaded or parsed up to this point at which this function
550  /// is called, so this is a good way to see what has been parsed
551  /// in a target.
552  ///
553  /// \param[in] s
554  /// The stream to which to dump the object description.
555  void Dump(Stream *s, lldb::DescriptionLevel description_level);
556 
557  // If listener_sp is null, the listener of the owning Debugger object will be
558  // used.
559  const lldb::ProcessSP &CreateProcess(lldb::ListenerSP listener_sp,
560  llvm::StringRef plugin_name,
561  const FileSpec *crash_file);
562 
563  const lldb::ProcessSP &GetProcessSP() const;
564 
565  bool IsValid() { return m_valid; }
566 
567  void Destroy();
568 
569  Status Launch(ProcessLaunchInfo &launch_info,
570  Stream *stream); // Optional stream to receive first stop info
571 
572  Status Attach(ProcessAttachInfo &attach_info,
573  Stream *stream); // Optional stream to receive first stop info
574 
575  // This part handles the breakpoints.
576 
577  BreakpointList &GetBreakpointList(bool internal = false);
578 
579  const BreakpointList &GetBreakpointList(bool internal = false) const;
580 
581  lldb::BreakpointSP GetLastCreatedBreakpoint() {
582  return m_last_created_breakpoint;
583  }
584 
585  lldb::BreakpointSP GetBreakpointByID(lldb::break_id_t break_id);
586 
587  // Use this to create a file and line breakpoint to a given module or all
588  // module it is nullptr
589  lldb::BreakpointSP CreateBreakpoint(const FileSpecList *containingModules,
590  const FileSpec &file, uint32_t line_no,
591  uint32_t column, lldb::addr_t offset,
592  LazyBool check_inlines,
593  LazyBool skip_prologue, bool internal,
594  bool request_hardware,
595  LazyBool move_to_nearest_code);
596 
597  // Use this to create breakpoint that matches regex against the source lines
598  // in files given in source_file_list: If function_names is non-empty, also
599  // filter by function after the matches are made.
600  lldb::BreakpointSP CreateSourceRegexBreakpoint(
601  const FileSpecList *containingModules,
602  const FileSpecList *source_file_list,
603  const std::unordered_set<std::string> &function_names,
604  RegularExpression &source_regex, bool internal, bool request_hardware,
605  LazyBool move_to_nearest_code);
606 
607  // Use this to create a breakpoint from a load address
608  lldb::BreakpointSP CreateBreakpoint(lldb::addr_t load_addr, bool internal,
609  bool request_hardware);
610 
611  // Use this to create a breakpoint from a load address and a module file spec
612  lldb::BreakpointSP CreateAddressInModuleBreakpoint(lldb::addr_t file_addr,
613  bool internal,
614  const FileSpec *file_spec,
615  bool request_hardware);
616 
617  // Use this to create Address breakpoints:
618  lldb::BreakpointSP CreateBreakpoint(const Address &addr, bool internal,
619  bool request_hardware);
620 
621  // Use this to create a function breakpoint by regexp in
622  // containingModule/containingSourceFiles, or all modules if it is nullptr
623  // When "skip_prologue is set to eLazyBoolCalculate, we use the current
624  // target setting, else we use the values passed in
625  lldb::BreakpointSP CreateFuncRegexBreakpoint(
626  const FileSpecList *containingModules,
627  const FileSpecList *containingSourceFiles, RegularExpression &func_regexp,
628  lldb::LanguageType requested_language, LazyBool skip_prologue,
629  bool internal, bool request_hardware);
630 
631  // Use this to create a function breakpoint by name in containingModule, or
632  // all modules if it is nullptr When "skip_prologue is set to
633  // eLazyBoolCalculate, we use the current target setting, else we use the
634  // values passed in. func_name_type_mask is or'ed values from the
635  // FunctionNameType enum.
636  lldb::BreakpointSP CreateBreakpoint(
637  const FileSpecList *containingModules,
638  const FileSpecList *containingSourceFiles, const char *func_name,
639  lldb::FunctionNameType func_name_type_mask, lldb::LanguageType language,
640  lldb::addr_t offset, LazyBool skip_prologue, bool internal,
641  bool request_hardware);
642 
643  lldb::BreakpointSP
644  CreateExceptionBreakpoint(enum lldb::LanguageType language, bool catch_bp,
645  bool throw_bp, bool internal,
646  Args *additional_args = nullptr,
647  Status *additional_args_error = nullptr);
648 
649  lldb::BreakpointSP
650  CreateScriptedBreakpoint(const llvm::StringRef class_name,
651  const FileSpecList *containingModules,
652  const FileSpecList *containingSourceFiles,
653  bool internal,
654  bool request_hardware,
655  StructuredData::ObjectSP extra_args_sp,
656  Status *creation_error = nullptr);
657 
658  // This is the same as the func_name breakpoint except that you can specify a
659  // vector of names. This is cheaper than a regular expression breakpoint in
660  // the case where you just want to set a breakpoint on a set of names you
661  // already know. func_name_type_mask is or'ed values from the
662  // FunctionNameType enum.
663  lldb::BreakpointSP CreateBreakpoint(
664  const FileSpecList *containingModules,
665  const FileSpecList *containingSourceFiles, const char *func_names[],
666  size_t num_names, lldb::FunctionNameType func_name_type_mask,
667  lldb::LanguageType language, lldb::addr_t offset, LazyBool skip_prologue,
668  bool internal, bool request_hardware);
669 
670  lldb::BreakpointSP
671  CreateBreakpoint(const FileSpecList *containingModules,
672  const FileSpecList *containingSourceFiles,
673  const std::vector<std::string> &func_names,
674  lldb::FunctionNameType func_name_type_mask,
675  lldb::LanguageType language, lldb::addr_t m_offset,
676  LazyBool skip_prologue, bool internal,
677  bool request_hardware);
678 
679  // Use this to create a general breakpoint:
680  lldb::BreakpointSP CreateBreakpoint(lldb::SearchFilterSP &filter_sp,
681  lldb::BreakpointResolverSP &resolver_sp,
682  bool internal, bool request_hardware,
683  bool resolve_indirect_symbols);
684 
685  // Use this to create a watchpoint:
686  lldb::WatchpointSP CreateWatchpoint(lldb::addr_t addr, size_t size,
687  const CompilerType *type, uint32_t kind,
688  Status &error);
689 
690  lldb::WatchpointSP GetLastCreatedWatchpoint() {
691  return m_last_created_watchpoint;
692  }
693 
694  WatchpointList &GetWatchpointList() { return m_watchpoint_list; }
695 
696  // Manages breakpoint names:
697  void AddNameToBreakpoint(BreakpointID &id, const char *name, Status &error);
698 
699  void AddNameToBreakpoint(lldb::BreakpointSP &bp_sp, const char *name,
700  Status &error);
701 
702  void RemoveNameFromBreakpoint(lldb::BreakpointSP &bp_sp,
703  ConstString name);
704 
705  BreakpointName *FindBreakpointName(ConstString name, bool can_create,
706  Status &error);
707 
708  void DeleteBreakpointName(ConstString name);
709 
710  void ConfigureBreakpointName(BreakpointName &bp_name,
711  const BreakpointOptions &options,
712  const BreakpointName::Permissions &permissions);
713  void ApplyNameToBreakpoints(BreakpointName &bp_name);
714 
715  // This takes ownership of the name obj passed in.
716  void AddBreakpointName(BreakpointName *bp_name);
717 
718  void GetBreakpointNames(std::vector<std::string> &names);
719 
720  //This call removes ALL breakpoints regardless of permission.
721  void RemoveAllBreakpoints(bool internal_also = false);
722 
723  // This removes all the breakpoints, but obeys the ePermDelete on them.
724  void RemoveAllowedBreakpoints();
725 
726  void DisableAllBreakpoints(bool internal_also = false);
727 
728  void DisableAllowedBreakpoints();
729 
730  void EnableAllBreakpoints(bool internal_also = false);
731 
732  void EnableAllowedBreakpoints();
733 
734  bool DisableBreakpointByID(lldb::break_id_t break_id);
735 
736  bool EnableBreakpointByID(lldb::break_id_t break_id);
737 
738  bool RemoveBreakpointByID(lldb::break_id_t break_id);
739 
740  // The flag 'end_to_end', default to true, signifies that the operation is
741  // performed end to end, for both the debugger and the debuggee.
742 
743  bool RemoveAllWatchpoints(bool end_to_end = true);
744 
745  bool DisableAllWatchpoints(bool end_to_end = true);
746 
747  bool EnableAllWatchpoints(bool end_to_end = true);
748 
749  bool ClearAllWatchpointHitCounts();
750 
751  bool ClearAllWatchpointHistoricValues();
752 
753  bool IgnoreAllWatchpoints(uint32_t ignore_count);
754 
755  bool DisableWatchpointByID(lldb::watch_id_t watch_id);
756 
757  bool EnableWatchpointByID(lldb::watch_id_t watch_id);
758 
759  bool RemoveWatchpointByID(lldb::watch_id_t watch_id);
760 
761  bool IgnoreWatchpointByID(lldb::watch_id_t watch_id, uint32_t ignore_count);
762 
763  Status SerializeBreakpointsToFile(const FileSpec &file,
764  const BreakpointIDList &bp_ids,
765  bool append);
766 
767  Status CreateBreakpointsFromFile(const FileSpec &file,
768  BreakpointIDList &new_bps);
769 
770  Status CreateBreakpointsFromFile(const FileSpec &file,
771  std::vector<std::string> &names,
772  BreakpointIDList &new_bps);
773 
774  /// Get \a load_addr as a callable code load address for this target
775  ///
776  /// Take \a load_addr and potentially add any address bits that are
777  /// needed to make the address callable. For ARM this can set bit
778  /// zero (if it already isn't) if \a load_addr is a thumb function.
779  /// If \a addr_class is set to AddressClass::eInvalid, then the address
780  /// adjustment will always happen. If it is set to an address class
781  /// that doesn't have code in it, LLDB_INVALID_ADDRESS will be
782  /// returned.
783  lldb::addr_t GetCallableLoadAddress(
784  lldb::addr_t load_addr,
785  AddressClass addr_class = AddressClass::eInvalid) const;
786 
787  /// Get \a load_addr as an opcode for this target.
788  ///
789  /// Take \a load_addr and potentially strip any address bits that are
790  /// needed to make the address point to an opcode. For ARM this can
791  /// clear bit zero (if it already isn't) if \a load_addr is a
792  /// thumb function and load_addr is in code.
793  /// If \a addr_class is set to AddressClass::eInvalid, then the address
794  /// adjustment will always happen. If it is set to an address class
795  /// that doesn't have code in it, LLDB_INVALID_ADDRESS will be
796  /// returned.
798  GetOpcodeLoadAddress(lldb::addr_t load_addr,
799  AddressClass addr_class = AddressClass::eInvalid) const;
800 
801  // Get load_addr as breakable load address for this target. Take a addr and
802  // check if for any reason there is a better address than this to put a
803  // breakpoint on. If there is then return that address. For MIPS, if
804  // instruction at addr is a delay slot instruction then this method will find
805  // the address of its previous instruction and return that address.
806  lldb::addr_t GetBreakableLoadAddress(lldb::addr_t addr);
807 
808  void ModulesDidLoad(ModuleList &module_list);
809 
810  void ModulesDidUnload(ModuleList &module_list, bool delete_locations);
811 
812  void SymbolsDidLoad(ModuleList &module_list);
813 
814  void ClearModules(bool delete_locations);
815 
816  /// Called as the last function in Process::DidExec().
817  ///
818  /// Process::DidExec() will clear a lot of state in the process,
819  /// then try to reload a dynamic loader plugin to discover what
820  /// binaries are currently available and then this function should
821  /// be called to allow the target to do any cleanup after everything
822  /// has been figured out. It can remove breakpoints that no longer
823  /// make sense as the exec might have changed the target
824  /// architecture, and unloaded some modules that might get deleted.
825  void DidExec();
826 
827  /// Gets the module for the main executable.
828  ///
829  /// Each process has a notion of a main executable that is the file
830  /// that will be executed or attached to. Executable files can have
831  /// dependent modules that are discovered from the object files, or
832  /// discovered at runtime as things are dynamically loaded.
833  ///
834  /// \return
835  /// The shared pointer to the executable module which can
836  /// contains a nullptr Module object if no executable has been
837  /// set.
838  ///
839  /// \see DynamicLoader
840  /// \see ObjectFile::GetDependentModules (FileSpecList&)
841  /// \see Process::SetExecutableModule(lldb::ModuleSP&)
842  lldb::ModuleSP GetExecutableModule();
843 
844  Module *GetExecutableModulePointer();
845 
846  /// Set the main executable module.
847  ///
848  /// Each process has a notion of a main executable that is the file
849  /// that will be executed or attached to. Executable files can have
850  /// dependent modules that are discovered from the object files, or
851  /// discovered at runtime as things are dynamically loaded.
852  ///
853  /// Setting the executable causes any of the current dependent
854  /// image information to be cleared and replaced with the static
855  /// dependent image information found by calling
856  /// ObjectFile::GetDependentModules (FileSpecList&) on the main
857  /// executable and any modules on which it depends. Calling
858  /// Process::GetImages() will return the newly found images that
859  /// were obtained from all of the object files.
860  ///
861  /// \param[in] module_sp
862  /// A shared pointer reference to the module that will become
863  /// the main executable for this process.
864  ///
865  /// \param[in] load_dependent_files
866  /// If \b true then ask the object files to track down any
867  /// known dependent files.
868  ///
869  /// \see ObjectFile::GetDependentModules (FileSpecList&)
870  /// \see Process::GetImages()
871  void SetExecutableModule(
872  lldb::ModuleSP &module_sp,
873  LoadDependentFiles load_dependent_files = eLoadDependentsDefault);
874 
875  bool LoadScriptingResources(std::list<Status> &errors,
876  Stream *feedback_stream = nullptr,
877  bool continue_on_error = true) {
878  return m_images.LoadScriptingResourcesInTarget(
879  this, errors, feedback_stream, continue_on_error);
880  }
881 
882  /// Get accessor for the images for this process.
883  ///
884  /// Each process has a notion of a main executable that is the file
885  /// that will be executed or attached to. Executable files can have
886  /// dependent modules that are discovered from the object files, or
887  /// discovered at runtime as things are dynamically loaded. After
888  /// a main executable has been set, the images will contain a list
889  /// of all the files that the executable depends upon as far as the
890  /// object files know. These images will usually contain valid file
891  /// virtual addresses only. When the process is launched or attached
892  /// to, the DynamicLoader plug-in will discover where these images
893  /// were loaded in memory and will resolve the load virtual
894  /// addresses is each image, and also in images that are loaded by
895  /// code.
896  ///
897  /// \return
898  /// A list of Module objects in a module list.
899  const ModuleList &GetImages() const { return m_images; }
900 
901  ModuleList &GetImages() { return m_images; }
902 
903  /// Return whether this FileSpec corresponds to a module that should be
904  /// considered for general searches.
905  ///
906  /// This API will be consulted by the SearchFilterForUnconstrainedSearches
907  /// and any module that returns \b true will not be searched. Note the
908  /// SearchFilterForUnconstrainedSearches is the search filter that
909  /// gets used in the CreateBreakpoint calls when no modules is provided.
910  ///
911  /// The target call at present just consults the Platform's call of the
912  /// same name.
913  ///
914  /// \param[in] module_sp
915  /// A shared pointer reference to the module that checked.
916  ///
917  /// \return \b true if the module should be excluded, \b false otherwise.
918  bool ModuleIsExcludedForUnconstrainedSearches(const FileSpec &module_spec);
919 
920  /// Return whether this module should be considered for general searches.
921  ///
922  /// This API will be consulted by the SearchFilterForUnconstrainedSearches
923  /// and any module that returns \b true will not be searched. Note the
924  /// SearchFilterForUnconstrainedSearches is the search filter that
925  /// gets used in the CreateBreakpoint calls when no modules is provided.
926  ///
927  /// The target call at present just consults the Platform's call of the
928  /// same name.
929  ///
930  /// FIXME: When we get time we should add a way for the user to set modules
931  /// that they
932  /// don't want searched, in addition to or instead of the platform ones.
933  ///
934  /// \param[in] module_sp
935  /// A shared pointer reference to the module that checked.
936  ///
937  /// \return \b true if the module should be excluded, \b false otherwise.
938  bool
939  ModuleIsExcludedForUnconstrainedSearches(const lldb::ModuleSP &module_sp);
940 
941  const ArchSpec &GetArchitecture() const { return m_arch.GetSpec(); }
942 
943  /// Set the architecture for this target.
944  ///
945  /// If the current target has no Images read in, then this just sets the
946  /// architecture, which will be used to select the architecture of the
947  /// ExecutableModule when that is set. If the current target has an
948  /// ExecutableModule, then calling SetArchitecture with a different
949  /// architecture from the currently selected one will reset the
950  /// ExecutableModule to that slice of the file backing the ExecutableModule.
951  /// If the file backing the ExecutableModule does not contain a fork of this
952  /// architecture, then this code will return false, and the architecture
953  /// won't be changed. If the input arch_spec is the same as the already set
954  /// architecture, this is a no-op.
955  ///
956  /// \param[in] arch_spec
957  /// The new architecture.
958  ///
959  /// \param[in] set_platform
960  /// If \b true, then the platform will be adjusted if the currently
961  /// selected platform is not compatible with the archicture being set.
962  /// If \b false, then just the architecture will be set even if the
963  /// currently selected platform isn't compatible (in case it might be
964  /// manually set following this function call).
965  ///
966  /// \return
967  /// \b true if the architecture was successfully set, \bfalse otherwise.
968  bool SetArchitecture(const ArchSpec &arch_spec, bool set_platform = false);
969 
970  bool MergeArchitecture(const ArchSpec &arch_spec);
971 
972  Architecture *GetArchitecturePlugin() const { return m_arch.GetPlugin(); }
973 
974  Debugger &GetDebugger() { return m_debugger; }
975 
976  size_t ReadMemoryFromFileCache(const Address &addr, void *dst, size_t dst_len,
977  Status &error);
978 
979  // Reading memory through the target allows us to skip going to the process
980  // for reading memory if possible and it allows us to try and read from any
981  // constant sections in our object files on disk. If you always want live
982  // program memory, read straight from the process. If you possibly want to
983  // read from const sections in object files, read from the target. This
984  // version of ReadMemory will try and read memory from the process if the
985  // process is alive. The order is:
986  // 1 - if (prefer_file_cache == true) then read from object file cache
987  // 2 - if there is a valid process, try and read from its memory
988  // 3 - if (prefer_file_cache == false) then read from object file cache
989  size_t ReadMemory(const Address &addr, bool prefer_file_cache, void *dst,
990  size_t dst_len, Status &error,
991  lldb::addr_t *load_addr_ptr = nullptr);
992 
993  size_t ReadCStringFromMemory(const Address &addr, std::string &out_str,
994  Status &error);
995 
996  size_t ReadCStringFromMemory(const Address &addr, char *dst,
997  size_t dst_max_len, Status &result_error);
998 
999  size_t ReadScalarIntegerFromMemory(const Address &addr,
1000  bool prefer_file_cache, uint32_t byte_size,
1001  bool is_signed, Scalar &scalar,
1002  Status &error);
1003 
1004  uint64_t ReadUnsignedIntegerFromMemory(const Address &addr,
1005  bool prefer_file_cache,
1006  size_t integer_byte_size,
1007  uint64_t fail_value, Status &error);
1008 
1009  bool ReadPointerFromMemory(const Address &addr, bool prefer_file_cache,
1010  Status &error, Address &pointer_addr);
1011 
1013  return m_section_load_history.GetCurrentSectionLoadList();
1014  }
1015 
1016  static Target *GetTargetFromContexts(const ExecutionContext *exe_ctx_ptr,
1017  const SymbolContext *sc_ptr);
1018 
1019  // lldb::ExecutionContextScope pure virtual functions
1020  lldb::TargetSP CalculateTarget() override;
1021 
1022  lldb::ProcessSP CalculateProcess() override;
1023 
1024  lldb::ThreadSP CalculateThread() override;
1025 
1026  lldb::StackFrameSP CalculateStackFrame() override;
1027 
1028  void CalculateExecutionContext(ExecutionContext &exe_ctx) override;
1029 
1030  PathMappingList &GetImageSearchPathList();
1031 
1032  TypeSystem *GetScratchTypeSystemForLanguage(Status *error,
1033  lldb::LanguageType language,
1034  bool create_on_demand = true);
1035 
1037  GetPersistentExpressionStateForLanguage(lldb::LanguageType language);
1038 
1039  // Creates a UserExpression for the given language, the rest of the
1040  // parameters have the same meaning as for the UserExpression constructor.
1041  // Returns a new-ed object which the caller owns.
1042 
1043  UserExpression *GetUserExpressionForLanguage(
1044  llvm::StringRef expr, llvm::StringRef prefix, lldb::LanguageType language,
1045  Expression::ResultType desired_type,
1046  const EvaluateExpressionOptions &options,
1047  ValueObject *ctx_obj, Status &error);
1048 
1049  // Creates a FunctionCaller for the given language, the rest of the
1050  // parameters have the same meaning as for the FunctionCaller constructor.
1051  // Since a FunctionCaller can't be
1052  // IR Interpreted, it makes no sense to call this with an
1053  // ExecutionContextScope that lacks
1054  // a Process.
1055  // Returns a new-ed object which the caller owns.
1056 
1057  FunctionCaller *GetFunctionCallerForLanguage(lldb::LanguageType language,
1058  const CompilerType &return_type,
1059  const Address &function_address,
1060  const ValueList &arg_value_list,
1061  const char *name, Status &error);
1062 
1063  // Creates a UtilityFunction for the given language, the rest of the
1064  // parameters have the same meaning as for the UtilityFunction constructor.
1065  // Returns a new-ed object which the caller owns.
1066 
1067  UtilityFunction *GetUtilityFunctionForLanguage(const char *expr,
1068  lldb::LanguageType language,
1069  const char *name,
1070  Status &error);
1071 
1072  ClangASTContext *GetScratchClangASTContext(bool create_on_demand = true);
1073 
1074  lldb::ClangASTImporterSP GetClangASTImporter();
1075 
1076  // Install any files through the platform that need be to installed prior to
1077  // launching or attaching.
1078  Status Install(ProcessLaunchInfo *launch_info);
1079 
1080  bool ResolveFileAddress(lldb::addr_t load_addr, Address &so_addr);
1081 
1082  bool ResolveLoadAddress(lldb::addr_t load_addr, Address &so_addr,
1084 
1085  bool SetSectionLoadAddress(const lldb::SectionSP &section,
1086  lldb::addr_t load_addr,
1087  bool warn_multiple = false);
1088 
1089  size_t UnloadModuleSections(const lldb::ModuleSP &module_sp);
1090 
1091  size_t UnloadModuleSections(const ModuleList &module_list);
1092 
1093  bool SetSectionUnloaded(const lldb::SectionSP &section_sp);
1094 
1095  bool SetSectionUnloaded(const lldb::SectionSP &section_sp,
1096  lldb::addr_t load_addr);
1097 
1098  void ClearAllLoadedSections();
1099 
1100  // Since expressions results can persist beyond the lifetime of a process,
1101  // and the const expression results are available after a process is gone, we
1102  // provide a way for expressions to be evaluated from the Target itself. If
1103  // an expression is going to be run, then it should have a frame filled in in
1104  // the execution context.
1105  lldb::ExpressionResults EvaluateExpression(
1106  llvm::StringRef expression, ExecutionContextScope *exe_scope,
1107  lldb::ValueObjectSP &result_valobj_sp,
1109  std::string *fixed_expression = nullptr,
1110  ValueObject *ctx_obj = nullptr);
1111 
1112  lldb::ExpressionVariableSP GetPersistentVariable(ConstString name);
1113 
1114  /// Return the next available number for numbered persistent variables.
1116  return m_next_persistent_variable_index++;
1117  }
1118 
1119  lldb::addr_t GetPersistentSymbol(ConstString name);
1120 
1121  // Target Stop Hooks
1122  class StopHook : public UserID {
1123  public:
1124  StopHook(const StopHook &rhs);
1125 
1126  ~StopHook();
1127 
1128  StringList *GetCommandPointer() { return &m_commands; }
1129 
1130  const StringList &GetCommands() { return m_commands; }
1131 
1132  lldb::TargetSP &GetTarget() { return m_target_sp; }
1133 
1134  void SetCommands(StringList &in_commands) { m_commands = in_commands; }
1135 
1136  // Set the specifier. The stop hook will own the specifier, and is
1137  // responsible for deleting it when we're done.
1138  void SetSpecifier(SymbolContextSpecifier *specifier);
1139 
1140  SymbolContextSpecifier *GetSpecifier() { return m_specifier_sp.get(); }
1141 
1142  // Set the Thread Specifier. The stop hook will own the thread specifier,
1143  // and is responsible for deleting it when we're done.
1144  void SetThreadSpecifier(ThreadSpec *specifier);
1145 
1146  ThreadSpec *GetThreadSpecifier() { return m_thread_spec_up.get(); }
1147 
1148  bool IsActive() { return m_active; }
1149 
1150  void SetIsActive(bool is_active) { m_active = is_active; }
1151 
1152  void SetAutoContinue(bool auto_continue) {m_auto_continue = auto_continue;}
1153 
1154  bool GetAutoContinue() const { return m_auto_continue; }
1155 
1156  void GetDescription(Stream *s, lldb::DescriptionLevel level) const;
1157 
1158  private:
1159  lldb::TargetSP m_target_sp;
1160  StringList m_commands;
1161  lldb::SymbolContextSpecifierSP m_specifier_sp;
1162  std::unique_ptr<ThreadSpec> m_thread_spec_up;
1163  bool m_active = true;
1164  bool m_auto_continue = false;
1165 
1166  // Use CreateStopHook to make a new empty stop hook. The GetCommandPointer
1167  // and fill it with commands, and SetSpecifier to set the specifier shared
1168  // pointer (can be null, that will match anything.)
1169  StopHook(lldb::TargetSP target_sp, lldb::user_id_t uid);
1170  friend class Target;
1171  };
1172  typedef std::shared_ptr<StopHook> StopHookSP;
1173 
1174  // Add an empty stop hook to the Target's stop hook list, and returns a
1175  // shared pointer to it in new_hook. Returns the id of the new hook.
1176  StopHookSP CreateStopHook();
1177 
1178  void RunStopHooks();
1179 
1180  size_t GetStopHookSize();
1181 
1182  bool SetSuppresStopHooks(bool suppress) {
1183  bool old_value = m_suppress_stop_hooks;
1184  m_suppress_stop_hooks = suppress;
1185  return old_value;
1186  }
1187 
1188  bool GetSuppressStopHooks() { return m_suppress_stop_hooks; }
1189 
1190  bool RemoveStopHookByID(lldb::user_id_t uid);
1191 
1192  void RemoveAllStopHooks();
1193 
1194  StopHookSP GetStopHookByID(lldb::user_id_t uid);
1195 
1196  bool SetStopHookActiveStateByID(lldb::user_id_t uid, bool active_state);
1197 
1198  void SetAllStopHooksActiveState(bool active_state);
1199 
1200  size_t GetNumStopHooks() const { return m_stop_hooks.size(); }
1201 
1202  StopHookSP GetStopHookAtIndex(size_t index) {
1203  if (index >= GetNumStopHooks())
1204  return StopHookSP();
1205  StopHookCollection::iterator pos = m_stop_hooks.begin();
1206 
1207  while (index > 0) {
1208  pos++;
1209  index--;
1210  }
1211  return (*pos).second;
1212  }
1213 
1214  lldb::PlatformSP GetPlatform() { return m_platform_sp; }
1215 
1216  void SetPlatform(const lldb::PlatformSP &platform_sp) {
1217  m_platform_sp = platform_sp;
1218  }
1219 
1220  SourceManager &GetSourceManager();
1221 
1222  ClangModulesDeclVendor *GetClangModulesDeclVendor();
1223 
1224  // Methods.
1225  lldb::SearchFilterSP
1226  GetSearchFilterForModule(const FileSpec *containingModule);
1227 
1228  lldb::SearchFilterSP
1229  GetSearchFilterForModuleList(const FileSpecList *containingModuleList);
1230 
1231  lldb::SearchFilterSP
1232  GetSearchFilterForModuleAndCUList(const FileSpecList *containingModules,
1233  const FileSpecList *containingSourceFiles);
1234 
1235  lldb::REPLSP GetREPL(Status &err, lldb::LanguageType language,
1236  const char *repl_options, bool can_create);
1237 
1238  void SetREPL(lldb::LanguageType language, lldb::REPLSP repl_sp);
1239 
1240 protected:
1241  /// Implementing of ModuleList::Notifier.
1242 
1243  void NotifyModuleAdded(const ModuleList &module_list,
1244  const lldb::ModuleSP &module_sp) override;
1245 
1246  void NotifyModuleRemoved(const ModuleList &module_list,
1247  const lldb::ModuleSP &module_sp) override;
1248 
1249  void NotifyModuleUpdated(const ModuleList &module_list,
1250  const lldb::ModuleSP &old_module_sp,
1251  const lldb::ModuleSP &new_module_sp) override;
1252 
1253  void NotifyWillClearList(const ModuleList &module_list) override;
1254 
1255  void NotifyModulesRemoved(lldb_private::ModuleList &module_list) override;
1256 
1257  class Arch {
1258  public:
1259  explicit Arch(const ArchSpec &spec);
1260  const Arch &operator=(const ArchSpec &spec);
1261 
1262  const ArchSpec &GetSpec() const { return m_spec; }
1263  Architecture *GetPlugin() const { return m_plugin_up.get(); }
1264 
1265  private:
1266  ArchSpec m_spec;
1267  std::unique_ptr<Architecture> m_plugin_up;
1268  };
1269  // Member variables.
1271  lldb::PlatformSP m_platform_sp; ///< The platform for this target.
1272  std::recursive_mutex m_mutex; ///< An API mutex that is used by the lldb::SB*
1273  /// classes make the SB interface thread safe
1275  ModuleList m_images; ///< The list of images for this process (shared
1276  /// libraries and anything dynamically loaded).
1280  using BreakpointNameList = std::map<ConstString, BreakpointName *>;
1282 
1283  lldb::BreakpointSP m_last_created_breakpoint;
1285  lldb::WatchpointSP m_last_created_watchpoint;
1286  // We want to tightly control the process destruction process so we can
1287  // correctly tear down everything that we need to, so the only class that
1288  // knows about the process lifespan is this target class.
1289  lldb::ProcessSP m_process_sp;
1290  lldb::SearchFilterSP m_search_filter_sp;
1293 
1294  typedef std::map<lldb::LanguageType, lldb::REPLSP> REPLMap;
1295  REPLMap m_repl_map;
1296 
1297  lldb::ClangASTImporterSP m_ast_importer_sp;
1298  lldb::ClangModulesDeclVendorUP m_clang_modules_decl_vendor_up;
1299 
1300  lldb::SourceManagerUP m_source_manager_up;
1301 
1302  typedef std::map<lldb::user_id_t, StopHookSP> StopHookCollection;
1303  StopHookCollection m_stop_hooks;
1305  bool m_valid;
1308  unsigned m_next_persistent_variable_index = 0;
1309 
1310  static void ImageSearchPathsChanged(const PathMappingList &path_list,
1311  void *baton);
1312 
1313  // Utilities for `statistics` command.
1314 private:
1315  std::vector<uint32_t> m_stats_storage;
1316  bool m_collecting_stats = false;
1317 
1318 public:
1319  void SetCollectingStats(bool v) { m_collecting_stats = v; }
1320 
1321  bool GetCollectingStats() { return m_collecting_stats; }
1322 
1324  if (!GetCollectingStats())
1325  return;
1327  "invalid statistics!");
1328  m_stats_storage[key] += 1;
1329  }
1330 
1331  std::vector<uint32_t> GetStatistics() { return m_stats_storage; }
1332 
1333 private:
1334  /// Construct with optional file and arch.
1335  ///
1336  /// This member is private. Clients must use
1337  /// TargetList::CreateTarget(const FileSpec*, const ArchSpec*)
1338  /// so all targets can be tracked from the central target list.
1339  ///
1340  /// \see TargetList::CreateTarget(const FileSpec*, const ArchSpec*)
1341  Target(Debugger &debugger, const ArchSpec &target_arch,
1342  const lldb::PlatformSP &platform_sp, bool is_dummy_target);
1343 
1344  // Helper function.
1345  bool ProcessIsValid();
1346 
1347  // Copy breakpoints, stop hooks and so forth from the dummy target:
1348  void PrimeFromDummyTarget(Target *dummy_target);
1349 
1350  void AddBreakpoint(lldb::BreakpointSP breakpoint_sp, bool internal);
1351 
1352  void FinalizeFileActions(ProcessLaunchInfo &info);
1353 
1354  DISALLOW_COPY_AND_ASSIGN(Target);
1355 };
1356 
1357 } // namespace lldb_private
1358 
1359 #endif // liblldb_Target_h_
static const DynamicLoaderDarwinKernelPropertiesSP & GetGlobalProperties()
void SetIgnoreBreakpoints(bool ignore=false)
Definition: Target.h:289
A class to manage flag bits.
Definition: Debugger.h:82
SymbolContextSpecifier * GetSpecifier()
Definition: Target.h:1140
A command line argument class.
Definition: Args.h:32
void SetExecutionPolicy(ExecutionPolicy policy=eExecutionPolicyAlways)
Definition: Target.h:260
const ArchSpec & GetSpec() const
Definition: Target.h:1262
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
const ArchSpec & GetArchitecture() const
Definition: Target.h:941
int32_t break_id_t
Definition: lldb-types.h:88
void SetPrefix(const char *prefix)
Definition: Target.h:274
ModuleList m_images
The list of images for this process (shared libraries and anything dynamically loaded).
Definition: Target.h:1275
WatchpointList & GetWatchpointList()
Definition: Target.h:694
const Timeout< std::micro > & GetTimeout() const
Definition: Target.h:304
void SetIsActive(bool is_active)
Definition: Target.h:1150
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
#define lldbassert(x)
Definition: LLDBAssert.h:15
void SetOneThreadTimeout(const Timeout< std::micro > &timeout)
Definition: Target.h:312
ExpressionEvaluationPhase
This class is used by Watchpoint to manage a list of watchpoints,.
Defines a symbol context baton that can be handed other debug core functions.
Definition: SymbolContext.h:33
std::map< lldb::user_id_t, StopHookSP > StopHookCollection
Definition: Target.h:1302
void SetUseDynamic(lldb::DynamicValueType dynamic=lldb::eDynamicCanRunTarget)
Definition: Target.h:300
void SetCancelCallback(lldb::ExpressionCancelCallback callback, void *baton)
Definition: Target.h:348
Encapsulates a one-time expression for use in lldb.
ModuleList & GetImages()
Definition: Target.h:901
void SetUnwindOnError(bool unwind=false)
Definition: Target.h:285
A mix in class that contains a generic user ID.
Definition: UserID.h:33
A file utility class.
Definition: FileSpec.h:55
"lldb/Utility/RegularExpression.h" A C++ wrapper class for regex.
An architecture specification class.
Definition: ArchSpec.h:32
lldb::TargetSP & GetTarget()
Definition: Target.h:1132
unsigned GetNextPersistentVariableIndex()
Return the next available number for numbered persistent variables.
Definition: Target.h:1115
bool m_suppress_stop_hooks
Definition: Target.h:1306
An event broadcasting class.
Definition: Broadcaster.h:250
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
int32_t watch_id_t
Definition: lldb-types.h:89
std::recursive_mutex & GetAPIMutex()
Definition: Target.h:539
lldb::BreakpointSP m_last_created_breakpoint
Definition: Target.h:1283
Debugger & m_debugger
Definition: Target.h:1270
std::map< lldb::LanguageType, lldb::REPLSP > REPLMap
Definition: Target.h:1294
LoadDependentFiles
Definition: Target.h:59
SectionLoadHistory m_section_load_history
Definition: Target.h:1277
BreakpointList m_internal_breakpoint_list
Definition: Target.h:1279
lldb::ClangModulesDeclVendorUP m_clang_modules_decl_vendor_up
Definition: Target.h:1298
WatchpointList m_watchpoint_list
Definition: Target.h:1284
Architecture * GetPlugin() const
Definition: Target.h:1263
StopHookSP GetStopHookAtIndex(size_t index)
Definition: Target.h:1202
const StringList & GetCommands()
Definition: Target.h:1130
void IncrementStats(lldb_private::StatisticKind key)
Definition: Target.h:1323
void SetKeepInMemory(bool keep=true)
Definition: Target.h:295
void SetAutoContinue(bool auto_continue)
Definition: Target.h:1152
void SetCommands(StringList &in_commands)
Definition: Target.h:1134
StopHookCollection m_stop_hooks
Definition: Target.h:1303
void SetTimeout(const Timeout< std::micro > &timeout)
Definition: Target.h:306
uint64_t user_id_t
Definition: lldb-types.h:84
bool GetSuppressStopHooks()
Definition: Target.h:1188
LanguageType
Programming language type.
lldb::BreakpointSP GetLastCreatedBreakpoint()
Definition: Target.h:581
ConstString GetFlavor() const override
Definition: Target.h:461
PathMappingList m_image_search_paths
Definition: Target.h:1291
lldb::PlatformSP m_platform_sp
The platform for this target.
Definition: Target.h:1271
lldb::SearchFilterSP m_search_filter_sp
Definition: Target.h:1290
std::recursive_mutex m_mutex
An API mutex that is used by the lldb::SB* classes make the SB interface thread safe.
Definition: Target.h:1272
size_t GetNumStopHooks() const
Definition: Target.h:1200
A collection class for Module objects.
Definition: ModuleList.h:91
void SetCollectingStats(bool v)
Definition: Target.h:1319
SectionLoadList & GetSectionLoadList()
Definition: Target.h:1012
A class that describes an executable image and its associated object and symbol files.
Definition: Module.h:109
static size_t ReadCStringFromMemory(ExecutionContextScope *exe_scope, const Address &address, Stream *strm)
Definition: Address.cpp:189
ConstString & GetBroadcasterClass() const override
Definition: Target.h:444
Encapsulates a function that can be called.
"lldb/Target/ExecutionContextScope.h" Inherit from this if your object can reconstruct its execution ...
lldb::user_id_t m_stop_hook_next_id
Definition: Target.h:1304
lldb::WatchpointSP GetLastCreatedWatchpoint()
Definition: Target.h:690
const char * GetPoundLineFilePath() const
Definition: Target.h:371
REPLMap m_repl_map
Definition: Target.h:1295
A section + offset based address class.
Definition: Address.h:80
std::vector< uint32_t > GetStatistics()
Definition: Target.h:1331
General Outline: Allows adding and removing breakpoints and find by ID and index. ...
lldb::WatchpointSP m_last_created_watchpoint
Definition: Target.h:1285
lldb::LanguageType GetLanguage() const
Definition: Target.h:264
bool SetSuppresStopHooks(bool suppress)
Definition: Target.h:1182
TypeSystemMap m_scratch_type_system_map
Definition: Target.h:1292
const lldb::TargetSP & GetTarget() const
Definition: Target.h:473
lldb::ClangASTImporterSP m_ast_importer_sp
Definition: Target.h:1297
const Timeout< std::micro > & GetOneThreadTimeout() const
Definition: Target.h:308
lldb::DynamicValueType GetUseDynamic() const
Definition: Target.h:297
StringList * GetCommandPointer()
Definition: Target.h:1128
void SetLanguage(lldb::LanguageType language)
Definition: Target.h:266
const ModuleList & GetImages() const
Get accessor for the images for this process.
Definition: Target.h:899
void SetStopOthers(bool stop_others=true)
Definition: Target.h:322
bool InvokeCancelCallback(lldb::ExpressionEvaluationPhase phase) const
Definition: Target.h:353
bool(* ExpressionCancelCallback)(ExpressionEvaluationPhase phase, void *baton)
Definition: lldb-types.h:74
void SetCoerceToId(bool coerce=true)
Definition: Target.h:281
bool GetAutoContinue() const
Definition: Target.h:1154
uint64_t addr_t
Definition: lldb-types.h:83
lldb::PlatformSP GetPlatform()
Definition: Target.h:1214
A uniqued constant string class.
Definition: ConstString.h:38
Unknown or invalid language value.
LoadCWDlldbinitFile
Definition: Target.h:53
"lldb/Breakpoint/BreakpointOptions.h" Class that manages the options on a breakpoint or breakpoint lo...
void SetTryAllThreads(bool try_others=true)
Definition: Target.h:318
void SetPlatform(const lldb::PlatformSP &platform_sp)
Definition: Target.h:1216
bool GetCollectingStats()
Definition: Target.h:1321
std::shared_ptr< Object > ObjectSP
std::shared_ptr< StopHook > StopHookSP
Definition: Target.h:1172
Architecture * GetArchitecturePlugin() const
Definition: Target.h:972
void SetPoundLine(const char *path, uint32_t line) const
Definition: Target.h:361
InlineStrategy
Definition: Target.h:41
LoadScriptFromSymFile
Definition: Target.h:47
OptionEnumValues GetDynamicValueTypes()
Definition: Target.cpp:3237
std::map< ConstString, BreakpointName * > BreakpointNameList
Definition: Target.h:1280
lldb::ProcessSP m_process_sp
Definition: Target.h:1289
"lldb/Expression/UtilityFunction.h" Encapsulates a bit of source code that provides a function that i...
BreakpointList m_breakpoint_list
Definition: Target.h:1278
const char * GetPrefix() const
Definition: Target.h:270
ExecutionPolicy
Expression execution policies.
ThreadSpec * GetThreadSpecifier()
Definition: Target.h:1146
Debugger & GetDebugger()
Definition: Target.h:974
bool LoadScriptingResources(std::list< Status > &errors, Stream *feedback_stream=nullptr, bool continue_on_error=true)
Definition: Target.h:875
lldb::SourceManagerUP m_source_manager_up
Definition: Target.h:1300
const ModuleList & GetModuleList() const
Definition: Target.h:475
BreakpointNameList m_breakpoint_names
Definition: Target.h:1281
An error handling class.
Definition: Status.h:44
ExecutionPolicy GetExecutionPolicy() const
Definition: Target.h:258