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 LLDB_TARGET_TARGET_H
10#define LLDB_TARGET_TARGET_H
11
12#include <list>
13#include <map>
14#include <memory>
15#include <string>
16#include <vector>
17
21#include "lldb/Core/Address.h"
42#include "lldb/Utility/Stream.h"
45#include "lldb/lldb-public.h"
46#include "llvm/ADT/MapVector.h"
47#include "llvm/ADT/StringRef.h"
48
49namespace lldb_private {
50
52
58
65
71
77
84
89
91public:
92 TargetProperties(Target *target);
93
95
97
98 void SetDefaultArchitecture(const ArchSpec &arch);
99
100 bool GetMoveToNearestCode() const;
101
103
105
106 bool GetPreloadSymbols() const;
107
108 void SetPreloadSymbols(bool b);
109
110 bool GetDisableASLR() const;
111
112 void SetDisableASLR(bool b);
113
114 bool GetInheritTCC() const;
115
116 void SetInheritTCC(bool b);
117
118 bool GetDetachOnError() const;
119
120 void SetDetachOnError(bool b);
121
122 bool GetDisableSTDIO() const;
123
124 void SetDisableSTDIO(bool b);
125
126 llvm::StringRef GetLaunchWorkingDirectory() const;
127
128 bool GetParallelModuleLoad() const;
129
130 const char *GetDisassemblyFlavor() const;
131
132 const char *GetDisassemblyCPU() const;
133
134 const char *GetDisassemblyFeatures() const;
135
137
139
140 llvm::StringRef GetArg0() const;
141
142 void SetArg0(llvm::StringRef arg);
143
144 bool GetRunArguments(Args &args) const;
145
146 void SetRunArguments(const Args &args);
147
148 // Get the whole environment including the platform inherited environment and
149 // the target specific environment, excluding the unset environment variables.
151 // Get the platform inherited environment, excluding the unset environment
152 // variables.
154 // Get the target specific environment only, without the platform inherited
155 // environment.
157 // Set the target specific environment.
158 void SetEnvironment(Environment env);
159
160 bool GetSkipPrologue() const;
161
163
165
166 bool GetAutoSourceMapRelative() const;
167
169
171
173
175
177
179
181
182 bool GetEnableAutoApplyFixIts() const;
183
184 uint64_t GetNumberOfRetriesWithFixits() const;
185
186 bool GetEnableNotifyAboutFixIts() const;
187
189
190 bool GetEnableSyntheticValue() const;
191
193
194 uint32_t GetMaxZeroPaddingInFloatFormat() const;
195
197
198 /// Get the max depth value, augmented with a bool to indicate whether the
199 /// depth is the default.
200 ///
201 /// When the user has customized the max depth, the bool will be false.
202 ///
203 /// \returns the max depth, and true if the max depth is the system default,
204 /// otherwise false.
205 std::pair<uint32_t, bool> GetMaximumDepthOfChildrenToDisplay() const;
206
207 uint32_t GetMaximumSizeOfStringSummary() const;
208
209 uint32_t GetMaximumMemReadSize() const;
210
214
215 void SetStandardInputPath(llvm::StringRef path);
216 void SetStandardOutputPath(llvm::StringRef path);
217 void SetStandardErrorPath(llvm::StringRef path);
218
219 void SetStandardInputPath(const char *path) = delete;
220 void SetStandardOutputPath(const char *path) = delete;
221 void SetStandardErrorPath(const char *path) = delete;
222
224
226
227 llvm::StringRef GetExpressionPrefixContents();
228
229 uint64_t GetExprErrorLimit() const;
230
231 uint64_t GetExprAllocAddress() const;
232
233 uint64_t GetExprAllocSize() const;
234
235 uint64_t GetExprAllocAlign() const;
236
237 bool GetUseHexImmediates() const;
238
239 bool GetUseFastStepping() const;
240
242
244
245 /// Set the target-wide target.load-script-from-symbol-file setting.
246 /// See \c SetAutoLoadScriptsForModule for overriding this setting
247 /// per-module.
249
251
253
255
256 bool GetUserSpecifiedTrapHandlerNames(Args &args) const;
257
258 void SetUserSpecifiedTrapHandlerNames(const Args &args);
259
261
263
265
267
269
270 void SetProcessLaunchInfo(const ProcessLaunchInfo &launch_info);
271
272 bool GetInjectLocalVariables(ExecutionContext *exe_ctx) const;
273
274 bool GetUseDIL(ExecutionContext *exe_ctx) const;
275
276 void SetUseDIL(ExecutionContext *exe_ctx, bool b);
277
279
281
282 bool GetAutoInstallMainExecutable() const;
283
285
286 void SetDebugUtilityExpression(bool debug);
287
288 bool GetDebugUtilityExpression() const;
289
290 void SetCheckValueObjectOwnership(bool check);
291
292 bool GetCheckValueObjectOwnership() const;
293
294 std::optional<LoadScriptFromSymFile>
295 GetAutoLoadScriptsForModule(llvm::StringRef module_name) const;
296
297 /// Set the \c LoadScriptFromSymFile for a module called \c module_name
298 /// (excluding file extension). LLDB will prefer this over the target-wide
299 /// target.load-script-from-symbol-file setting
300 /// (see \c SetLoadScriptFromSymbolFile).
301 void SetAutoLoadScriptsForModule(llvm::StringRef module_name,
302 LoadScriptFromSymFile load_style);
303
304private:
305 std::optional<bool>
306 GetExperimentalPropertyValue(size_t prop_idx,
307 ExecutionContext *exe_ctx = nullptr) const;
308
309 // Callbacks for m_launch_info.
320
321 // Settings checker for target.jit-save-objects-dir:
322 void CheckJITObjectsDir();
323
325
326 // Member variables.
328 std::unique_ptr<TargetExperimentalProperties> m_experimental_properties_up;
330};
331
333public:
335
336// MSVC has a bug here that reports C4268: 'const' static/global data
337// initialized with compiler generated default constructor fills the object
338// with zeros. Confirmed that MSVC is *not* zero-initializing, it's just a
339// bogus warning.
340#if defined(_MSC_VER)
341#pragma warning(push)
342#pragma warning(disable : 4268)
343#endif
344 static constexpr std::chrono::milliseconds default_timeout{500};
345#if defined(_MSC_VER)
346#pragma warning(pop)
347#endif
348
351
353
357
359
360 void SetLanguage(lldb::LanguageType language_type) {
361 m_language = SourceLanguage(language_type);
362 }
363
365 m_preferred_lookup_contexts = std::move(contexts);
366 }
367
371
372 /// Set the language using a pair of language code and version as
373 /// defined by the DWARF 6 specification.
374 /// WARNING: These codes may change until DWARF 6 is finalized.
375 void SetLanguage(uint16_t name, uint32_t version) {
376 m_language = SourceLanguage(name, version);
377 }
378
379 bool DoesCoerceToId() const { return m_coerce_to_id; }
380
381 const char *GetPrefix() const {
382 return (m_prefix.empty() ? nullptr : m_prefix.c_str());
383 }
384
385 void SetPrefix(const char *prefix) {
386 if (prefix && prefix[0])
387 m_prefix = prefix;
388 else
389 m_prefix.clear();
390 }
391
392 void SetCoerceToId(bool coerce = true) { m_coerce_to_id = coerce; }
393
394 bool DoesUnwindOnError() const { return m_unwind_on_error; }
395
396 void SetUnwindOnError(bool unwind = false) { m_unwind_on_error = unwind; }
397
399
400 void SetIgnoreBreakpoints(bool ignore = false) {
401 m_ignore_breakpoints = ignore;
402 }
403
404 bool DoesKeepInMemory() const { return m_keep_in_memory; }
405
406 void SetKeepInMemory(bool keep = true) { m_keep_in_memory = keep; }
407
409
410 void
414
415 const Timeout<std::micro> &GetTimeout() const { return m_timeout; }
416
417 void SetTimeout(const Timeout<std::micro> &timeout) { m_timeout = timeout; }
418
422
424 m_one_thread_timeout = timeout;
425 }
426
427 bool GetTryAllThreads() const { return m_try_others; }
428
429 void SetTryAllThreads(bool try_others = true) { m_try_others = try_others; }
430
431 bool GetStopOthers() const { return m_stop_others; }
432
433 void SetStopOthers(bool stop_others = true) { m_stop_others = stop_others; }
434
435 bool GetDebug() const { return m_debug; }
436
437 void SetDebug(bool b) {
438 m_debug = b;
439 if (m_debug)
441 }
442
444
446
447 bool GetColorizeErrors() const { return m_ansi_color_errors; }
448
450
451 bool GetTrapExceptions() const { return m_trap_exceptions; }
452
454
455 bool GetStopOnFork() const { return m_stop_on_fork; }
456
457 void SetStopOnFork(bool b) { m_stop_on_fork = b; }
458
459 bool GetREPLEnabled() const { return m_repl; }
460
461 void SetREPLEnabled(bool b) { m_repl = b; }
462
465 m_cancel_callback = callback;
466 }
467
469 return ((m_cancel_callback != nullptr)
471 : false);
472 }
473
474 // Allows the expression contents to be remapped to point to the specified
475 // file and line using #line directives.
476 void SetPoundLine(const char *path, uint32_t line) const {
477 if (path && path[0]) {
478 m_pound_line_file = path;
479 m_pound_line_line = line;
480 } else {
481 m_pound_line_file.clear();
483 }
484 }
485
486 const char *GetPoundLineFilePath() const {
487 return (m_pound_line_file.empty() ? nullptr : m_pound_line_file.c_str());
488 }
489
490 uint32_t GetPoundLineLine() const { return m_pound_line_line; }
491
493
497
499
501
502 void SetRetriesWithFixIts(uint64_t number_of_retries) {
503 m_retries_with_fixits = number_of_retries;
504 }
505
506 uint64_t GetRetriesWithFixIts() const { return m_retries_with_fixits; }
507
509
511
512 /// Set language-plugin specific option called \c option_name to
513 /// the specified boolean \c value.
514 llvm::Error SetBooleanLanguageOption(llvm::StringRef option_name, bool value);
515
516 /// Get the language-plugin specific boolean option called \c option_name.
517 ///
518 /// If the option doesn't exist or is not a boolean option, returns false.
519 /// Otherwise returns the boolean value of the option.
520 llvm::Expected<bool>
521 GetBooleanLanguageOption(llvm::StringRef option_name) const;
522
523 void SetCppIgnoreContextQualifiers(bool value);
524
526
527private:
529
531
534 std::string m_prefix;
535 bool m_coerce_to_id = false;
536 bool m_unwind_on_error = true;
538 bool m_keep_in_memory = false;
539 bool m_try_others = true;
540 bool m_stop_others = true;
541 bool m_debug = false;
542 bool m_trap_exceptions = true;
543 bool m_stop_on_fork = false;
544 bool m_repl = false;
550 /// True if the executed code should be treated as utility code that is only
551 /// used by LLDB internally.
553
558 void *m_cancel_callback_baton = nullptr;
559 // If m_pound_line_file is not empty and m_pound_line_line is non-zero, use
560 // #line %u "%s" before the expression content to remap where the source
561 // originates
562 mutable std::string m_pound_line_file;
563 mutable uint32_t m_pound_line_line = 0;
564
565 /// Dictionary mapping names of language-plugin specific options
566 /// to values.
568
569 /// During expression evaluation, any SymbolContext in this list will be
570 /// used for symbol/function lookup before any other context (except for
571 /// the module corresponding to the current frame).
573};
574
575// Target
576class Target : public std::enable_shared_from_this<Target>,
577 public TargetProperties,
578 public Broadcaster,
580 public ModuleList::Notifier {
581public:
582 friend class TargetList;
583 friend class Debugger;
584
585 /// Broadcaster event bits definitions.
586 enum {
594 };
595
596 // These two functions fill out the Broadcaster interface:
597
598 static llvm::StringRef GetStaticBroadcasterClass();
599
600 llvm::StringRef GetBroadcasterClass() const override {
602 }
603
604 // This event data class is for use by the TargetList to broadcast new target
605 // notifications.
606 class TargetEventData : public EventData {
607 public:
608 TargetEventData(const lldb::TargetSP &target_sp);
609
610 TargetEventData(const lldb::TargetSP &target_sp,
611 const ModuleList &module_list);
612
613 // Constructor for eBroadcastBitNewTargetCreated events. For this event
614 // type:
615 // - target_sp is the parent target (the subject/broadcaster of the event)
616 // - created_target_sp is the newly created target
617 TargetEventData(const lldb::TargetSP &target_sp,
618 const lldb::TargetSP &created_target_sp);
619
621
622 static llvm::StringRef GetFlavorString();
623
624 llvm::StringRef GetFlavor() const override {
626 }
627
628 void Dump(Stream *s) const override;
629
630 static const TargetEventData *GetEventDataFromEvent(const Event *event_ptr);
631
632 static lldb::TargetSP GetTargetFromEvent(const Event *event_ptr);
633
634 // For eBroadcastBitNewTargetCreated events, returns the newly created
635 // target. For other event types, returns an invalid target.
636 static lldb::TargetSP GetCreatedTargetFromEvent(const Event *event_ptr);
637
638 static ModuleList GetModuleListFromEvent(const Event *event_ptr);
639
640 const lldb::TargetSP &GetTarget() const { return m_target_sp; }
641
643 return m_created_target_sp;
644 }
645
646 const ModuleList &GetModuleList() const { return m_module_list; }
647
648 private:
652
654 const TargetEventData &operator=(const TargetEventData &) = delete;
655 };
656
657 ~Target() override;
658
659 static void SettingsInitialize();
660
661 static void SettingsTerminate();
662
664
666
668
669 static void SetDefaultArchitecture(const ArchSpec &arch);
670
671 bool IsDummyTarget() const { return m_is_dummy_target; }
672
673 /// Get the globally unique ID for this target.
674 ///
675 /// This ID is unique across all debugger instances and all targets,
676 /// within the same lldb process. The ID is assigned
677 /// during target construction and remains constant for the target's lifetime.
678 /// The first target created (typically the dummy target) gets ID 1.
679 ///
680 /// \return
681 /// The globally unique ID for this target.
683
684 const std::string &GetLabel() const { return m_label; }
685
686 /// Set a label for a target.
687 ///
688 /// The label cannot be used by another target or be only integral.
689 ///
690 /// \return
691 /// The label for this target or an error if the label didn't match the
692 /// requirements.
693 llvm::Error SetLabel(llvm::StringRef label);
694
695 /// Get the target session name for this target.
696 ///
697 /// Provides a meaningful name for IDEs or tools to display for dynamically
698 /// created targets. Defaults to "Session {ID}" based on the globally unique
699 /// ID.
700 ///
701 /// \return
702 /// The target session name for this target.
703 llvm::StringRef GetTargetSessionName() { return m_target_session_name; }
704
705 /// Set the target session name for this target.
706 ///
707 /// This should typically be set along with the event
708 /// eBroadcastBitNewTargetCreated. Useful for scripts or triggers that
709 /// automatically create targets and want to provide meaningful names that
710 /// IDEs or other tools can display to help users identify the origin and
711 /// purpose of each target.
712 ///
713 /// \param[in] target_session_name
714 /// The target session name to set for this target.
715 void SetTargetSessionName(llvm::StringRef target_session_name) {
716 m_target_session_name = target_session_name.str();
717 }
718
719 /// Find a binary on the system and return its Module,
720 /// or return an existing Module that is already in the Target.
721 ///
722 /// Given a ModuleSpec, find a binary satisifying that specification,
723 /// or identify a matching Module already present in the Target,
724 /// and return a shared pointer to it.
725 ///
726 /// Note that this function previously also preloaded the module's symbols
727 /// depending on a setting. This function no longer does any module
728 /// preloading because that can potentially cause deadlocks when called in
729 /// parallel with this function.
730 ///
731 /// \param[in] module_spec
732 /// The criteria that must be matched for the binary being loaded.
733 /// e.g. UUID, architecture, file path.
734 ///
735 /// \param[in] notify
736 /// If notify is true, and the Module is new to this Target,
737 /// Target::ModulesDidLoad will be called. See note in
738 /// Target::ModulesDidLoad about thread-safety with
739 /// Target::GetOrCreateModule.
740 /// If notify is false, it is assumed that the caller is adding
741 /// multiple Modules and will call ModulesDidLoad with the
742 /// full list at the end.
743 /// ModulesDidLoad must be called when a Module/Modules have
744 /// been added to the target, one way or the other.
745 ///
746 /// \param[out] error_ptr
747 /// Optional argument, pointing to a Status object to fill in
748 /// with any results / messages while attempting to find/load
749 /// this binary. Many callers will be internal functions that
750 /// will handle / summarize the failures in a custom way and
751 /// don't use these messages.
752 ///
753 /// \return
754 /// An empty ModuleSP will be returned if no matching file
755 /// was found. If error_ptr was non-nullptr, an error message
756 /// will likely be provided.
757 lldb::ModuleSP GetOrCreateModule(const ModuleSpec &module_spec, bool notify,
758 Status *error_ptr = nullptr);
759
760 // Settings accessors
761
763
764 std::recursive_mutex &GetAPIMutex();
765
767
768 void CleanupProcess();
769
770 /// Dump a description of this object to a Stream.
771 ///
772 /// Dump a description of the contents of this object to the
773 /// supplied stream \a s. The dumped content will be only what has
774 /// been loaded or parsed up to this point at which this function
775 /// is called, so this is a good way to see what has been parsed
776 /// in a target.
777 ///
778 /// \param[in] s
779 /// The stream to which to dump the object description.
780 void Dump(Stream *s, lldb::DescriptionLevel description_level);
781
782 // If listener_sp is null, the listener of the owning Debugger object will be
783 // used.
785 llvm::StringRef plugin_name,
786 const FileSpec *crash_file,
787 bool can_connect);
788
789 const lldb::ProcessSP &GetProcessSP() const;
790
791 bool IsValid() { return m_valid; }
792
793 void Destroy();
794
795 Status Launch(ProcessLaunchInfo &launch_info,
796 Stream *stream); // Optional stream to receive first stop info
797
798 Status Attach(ProcessAttachInfo &attach_info,
799 Stream *stream); // Optional stream to receive first stop info
800
801 /// Add or update a scripted frame provider descriptor for this target.
802 /// All new threads in this target will check if they match any descriptors
803 /// to create their frame providers.
804 ///
805 /// \param[in] descriptor
806 /// The descriptor to add or update.
807 ///
808 /// \return
809 /// The descriptor identifier if the registration succeeded, otherwise an
810 /// llvm::Error.
811 llvm::Expected<uint32_t> AddScriptedFrameProviderDescriptor(
812 const ScriptedFrameProviderDescriptor &descriptor);
813
814 /// Remove a scripted frame provider descriptor by id.
815 ///
816 /// \param[in] id
817 /// The id of the descriptor to remove.
818 ///
819 /// \return
820 /// True if a descriptor was removed, false if no descriptor with that
821 /// id existed.
823
824 /// Clear all scripted frame provider descriptors for this target.
826
827 /// Get all scripted frame provider descriptors for this target.
828 const llvm::MapVector<uint32_t, ScriptedFrameProviderDescriptor> &
830
831protected:
832 /// Invalidate all potentially cached frame providers for all threads
833 /// and trigger a stack changed event for all threads.
835
836public:
837 // This part handles the breakpoints.
838
839 BreakpointList &GetBreakpointList(bool internal = false);
840
841 const BreakpointList &GetBreakpointList(bool internal = false) const;
842
846
848
850
851 // Use this to create a file and line breakpoint to a given module or all
852 // module it is nullptr
853 lldb::BreakpointSP CreateBreakpoint(const FileSpecList *containingModules,
854 const FileSpec &file, uint32_t line_no,
855 uint32_t column, lldb::addr_t offset,
856 LazyBool check_inlines,
857 LazyBool skip_prologue, bool internal,
858 bool request_hardware,
859 LazyBool move_to_nearest_code);
860
861 // Use this to create breakpoint that matches regex against the source lines
862 // in files given in source_file_list: If function_names is non-empty, also
863 // filter by function after the matches are made.
865 const FileSpecList *containingModules,
866 const FileSpecList *source_file_list,
867 const std::unordered_set<std::string> &function_names,
868 RegularExpression source_regex, bool internal, bool request_hardware,
869 LazyBool move_to_nearest_code);
870
871 // Use this to create a breakpoint from a load address
872 lldb::BreakpointSP CreateBreakpoint(lldb::addr_t load_addr, bool internal,
873 bool request_hardware);
874
875 // Use this to create a breakpoint from a file address and a module file spec
877 bool internal,
878 const FileSpec &file_spec,
879 bool request_hardware);
880
881 // Use this to create Address breakpoints:
882 lldb::BreakpointSP CreateBreakpoint(const Address &addr, bool internal,
883 bool request_hardware);
884
885 // Use this to create a function breakpoint by regexp in
886 // containingModule/containingSourceFiles, or all modules if it is nullptr
887 // When "skip_prologue is set to eLazyBoolCalculate, we use the current
888 // target setting, else we use the values passed in
890 const FileSpecList *containingModules,
891 const FileSpecList *containingSourceFiles, RegularExpression func_regexp,
892 lldb::LanguageType requested_language, LazyBool skip_prologue,
893 bool internal, bool request_hardware);
894
895 // Use this to create a function breakpoint by name in containingModule, or
896 // all modules if it is nullptr When "skip_prologue is set to
897 // eLazyBoolCalculate, we use the current target setting, else we use the
898 // values passed in. func_name_type_mask is or'ed values from the
899 // FunctionNameType enum.
901 const FileSpecList *containingModules,
902 const FileSpecList *containingSourceFiles, const char *func_name,
903 lldb::FunctionNameType func_name_type_mask, lldb::LanguageType language,
904 lldb::addr_t offset, bool offset_is_insn_count, LazyBool skip_prologue,
905 bool internal, bool request_hardware);
906
908 CreateExceptionBreakpoint(enum lldb::LanguageType language, bool catch_bp,
909 bool throw_bp, bool internal,
910 Args *additional_args = nullptr,
911 Status *additional_args_error = nullptr);
912
914 const llvm::StringRef class_name, const FileSpecList *containingModules,
915 const FileSpecList *containingSourceFiles, bool internal,
916 bool request_hardware, StructuredData::ObjectSP extra_args_sp,
917 Status *creation_error = nullptr);
918
919 // This is the same as the func_name breakpoint except that you can specify a
920 // vector of names. This is cheaper than a regular expression breakpoint in
921 // the case where you just want to set a breakpoint on a set of names you
922 // already know. func_name_type_mask is or'ed values from the
923 // FunctionNameType enum.
925 const FileSpecList *containingModules,
926 const FileSpecList *containingSourceFiles, const char *func_names[],
927 size_t num_names, lldb::FunctionNameType func_name_type_mask,
928 lldb::LanguageType language, lldb::addr_t offset, LazyBool skip_prologue,
929 bool internal, bool request_hardware);
930
932 CreateBreakpoint(const FileSpecList *containingModules,
933 const FileSpecList *containingSourceFiles,
934 const std::vector<std::string> &func_names,
935 lldb::FunctionNameType func_name_type_mask,
936 lldb::LanguageType language, lldb::addr_t m_offset,
937 LazyBool skip_prologue, bool internal,
938 bool request_hardware);
939
940 // Use this to create a general breakpoint:
942 lldb::BreakpointResolverSP &resolver_sp,
943 bool internal, bool request_hardware,
944 bool resolve_indirect_symbols);
945
946 // Use this to create a watchpoint:
948 const CompilerType *type, uint32_t kind,
949 Status &error);
950
954
956
957 // Manages breakpoint names:
958 void AddNameToBreakpoint(BreakpointID &id, llvm::StringRef name,
959 Status &error);
960
961 void AddNameToBreakpoint(lldb::BreakpointSP &bp_sp, llvm::StringRef name,
962 Status &error);
963
965
966 BreakpointName *FindBreakpointName(ConstString name, bool can_create,
967 Status &error);
968
970
972 const BreakpointOptions &options,
973 const BreakpointName::Permissions &permissions);
975
976 void AddBreakpointName(std::unique_ptr<BreakpointName> bp_name);
977
978 void GetBreakpointNames(std::vector<std::string> &names);
979
980 // This call removes ALL breakpoints regardless of permission.
981 void RemoveAllBreakpoints(bool internal_also = false);
982
983 // This removes all the breakpoints, but obeys the ePermDelete on them.
985
986 void DisableAllBreakpoints(bool internal_also = false);
987
989
990 void EnableAllBreakpoints(bool internal_also = false);
991
993
995
997
999
1000 /// Resets the hit count of all breakpoints.
1002
1003 // This callout implements the "Resolver Override". When we have determined
1004 // the Resolver for a given breakpoint, we pass each of the registered
1005 // overrides the "natural" resolver, and then we will use whatever resolver
1006 // we get back from it if it is non-null.
1007 // We keep a list of overrides ordered by ID - and we search through the list
1008 // by ID order, and the first override that returns a non-null Resolver will
1009 // be the one we use. If no overrides return an override resolver, we'll use
1010 // the original one.
1011
1012 // This is the abstract version of the override. Particular implementations
1013 // e.g. the scripted override will derive from this.
1014 class BreakpointResolverOverride;
1016 std::unique_ptr<BreakpointResolverOverride>;
1017
1019 public:
1020 BreakpointResolverOverride(Target &target, const std::string &description)
1021 : m_target(target), m_desc(description) {}
1022
1024
1028 // Return whether constructing this resolver was successful.
1029 virtual llvm::Error Validate() = 0;
1030 const std::string &GetDescription() { return m_desc; }
1031
1032 protected:
1034 std::string m_desc;
1035 };
1036
1037 /// Add a breakpoint override resolver. This version can't fail.
1041 m_breakpoint_overrides.emplace(m_override_id, std::move(override_up));
1042 m_override_id++;
1043 return id_used;
1044 }
1045
1046 /// Add a breakpoint override resolver. Return the ID or an error:
1047 llvm::Expected<lldb::user_id_t>
1048 AddBreakpointResolverOverride(llvm::StringRef class_name,
1049 StructuredData::DictionarySP args_data_sp,
1050 llvm::StringRef description);
1051
1053 size_t removed = m_breakpoint_overrides.erase(override_id);
1054 return removed == 1;
1055 }
1056
1058
1061 for (auto const &elem : m_breakpoint_overrides) {
1062 if (lldb::BreakpointResolverSP overriden_sp =
1063 elem.second->CheckForOverride(*this, original_sp))
1064 return overriden_sp;
1065 }
1066 return {};
1067 }
1068
1069 /// Describe the breakpoint overrides. If ixds is empty, list all. Otherwise
1070 /// list the overrides whose ids match the ones given in idxs. The matched
1071 /// elements are removed from the list, so any elements remaining in idxs are
1072 /// indexes that are not breakpoint override indexes.
1074 std::vector<lldb::user_id_t> &idxs);
1075
1076 // The flag 'end_to_end', default to true, signifies that the operation is
1077 // performed end to end, for both the debugger and the debuggee.
1078
1079 bool RemoveAllWatchpoints(bool end_to_end = true);
1080
1081 bool DisableAllWatchpoints(bool end_to_end = true);
1082
1083 bool EnableAllWatchpoints(bool end_to_end = true);
1084
1086
1088
1089 bool IgnoreAllWatchpoints(uint32_t ignore_count);
1090
1092
1094
1096
1097 bool IgnoreWatchpointByID(lldb::watch_id_t watch_id, uint32_t ignore_count);
1098
1100 const BreakpointIDList &bp_ids,
1101 bool append);
1102
1104 BreakpointIDList &new_bps);
1105
1107 std::vector<std::string> &names,
1108 BreakpointIDList &new_bps);
1109
1110 /// Get \a load_addr as a callable code load address for this target
1111 ///
1112 /// Take \a load_addr and potentially add any address bits that are
1113 /// needed to make the address callable. For ARM this can set bit
1114 /// zero (if it already isn't) if \a load_addr is a thumb function.
1115 /// If \a addr_class is set to AddressClass::eInvalid, then the address
1116 /// adjustment will always happen. If it is set to an address class
1117 /// that doesn't have code in it, LLDB_INVALID_ADDRESS will be
1118 /// returned.
1120 lldb::addr_t load_addr,
1121 AddressClass addr_class = AddressClass::eInvalid) const;
1122
1123 /// Get \a load_addr as an opcode for this target.
1124 ///
1125 /// Take \a load_addr and potentially strip any address bits that are
1126 /// needed to make the address point to an opcode. For ARM this can
1127 /// clear bit zero (if it already isn't) if \a load_addr is a
1128 /// thumb function and load_addr is in code.
1129 /// If \a addr_class is set to AddressClass::eInvalid, then the address
1130 /// adjustment will always happen. If it is set to an address class
1131 /// that doesn't have code in it, LLDB_INVALID_ADDRESS will be
1132 /// returned.
1135 AddressClass addr_class = AddressClass::eInvalid) const;
1136
1137 // Get load_addr as breakable load address for this target. Take a addr and
1138 // check if for any reason there is a better address than this to put a
1139 // breakpoint on. If there is then return that address. For MIPS, if
1140 // instruction at addr is a delay slot instruction then this method will find
1141 // the address of its previous instruction and return that address.
1143
1144 /// This call may preload module symbols, and may do so in parallel depending
1145 /// on the following target settings:
1146 /// - TargetProperties::GetPreloadSymbols()
1147 /// - TargetProperties::GetParallelModuleLoad()
1148 ///
1149 /// Warning: if preloading is active and this is called in parallel with
1150 /// Target::GetOrCreateModule, this may result in a ABBA deadlock situation.
1151 void ModulesDidLoad(ModuleList &module_list);
1152
1153 void ModulesDidUnload(ModuleList &module_list, bool delete_locations);
1154
1155 void SymbolsDidLoad(ModuleList &module_list);
1156
1157 void ClearModules(bool delete_locations);
1158
1159 /// Called as the last function in Process::DidExec().
1160 ///
1161 /// Process::DidExec() will clear a lot of state in the process,
1162 /// then try to reload a dynamic loader plugin to discover what
1163 /// binaries are currently available and then this function should
1164 /// be called to allow the target to do any cleanup after everything
1165 /// has been figured out. It can remove breakpoints that no longer
1166 /// make sense as the exec might have changed the target
1167 /// architecture, and unloaded some modules that might get deleted.
1168 void DidExec();
1169
1170 /// Gets the module for the main executable.
1171 ///
1172 /// Each process has a notion of a main executable that is the file
1173 /// that will be executed or attached to. Executable files can have
1174 /// dependent modules that are discovered from the object files, or
1175 /// discovered at runtime as things are dynamically loaded.
1176 ///
1177 /// \return
1178 /// The shared pointer to the executable module which can
1179 /// contains a nullptr Module object if no executable has been
1180 /// set.
1181 ///
1182 /// \see DynamicLoader
1183 /// \see ObjectFile::GetDependentModules (FileSpecList&)
1184 /// \see Process::SetExecutableModule(lldb::ModuleSP&)
1186
1188
1189 /// Set the main executable module.
1190 ///
1191 /// Each process has a notion of a main executable that is the file
1192 /// that will be executed or attached to. Executable files can have
1193 /// dependent modules that are discovered from the object files, or
1194 /// discovered at runtime as things are dynamically loaded.
1195 ///
1196 /// Setting the executable causes any of the current dependent
1197 /// image information to be cleared and replaced with the static
1198 /// dependent image information found by calling
1199 /// ObjectFile::GetDependentModules (FileSpecList&) on the main
1200 /// executable and any modules on which it depends. Calling
1201 /// Process::GetImages() will return the newly found images that
1202 /// were obtained from all of the object files.
1203 ///
1204 /// \param[in] module_sp
1205 /// A shared pointer reference to the module that will become
1206 /// the main executable for this process.
1207 ///
1208 /// \param[in] load_dependent_files
1209 /// If \b true then ask the object files to track down any
1210 /// known dependent files.
1211 ///
1212 /// \see ObjectFile::GetDependentModules (FileSpecList&)
1213 /// \see Process::GetImages()
1215 lldb::ModuleSP &module_sp,
1216 LoadDependentFiles load_dependent_files = eLoadDependentsDefault);
1217
1218 bool LoadScriptingResources(std::list<Status> &errors,
1219 bool continue_on_error = true) {
1220 return m_images.LoadScriptingResourcesInTarget(this, errors,
1221 continue_on_error);
1222 }
1223
1224 /// Get accessor for the images for this process.
1225 ///
1226 /// Each process has a notion of a main executable that is the file
1227 /// that will be executed or attached to. Executable files can have
1228 /// dependent modules that are discovered from the object files, or
1229 /// discovered at runtime as things are dynamically loaded. After
1230 /// a main executable has been set, the images will contain a list
1231 /// of all the files that the executable depends upon as far as the
1232 /// object files know. These images will usually contain valid file
1233 /// virtual addresses only. When the process is launched or attached
1234 /// to, the DynamicLoader plug-in will discover where these images
1235 /// were loaded in memory and will resolve the load virtual
1236 /// addresses is each image, and also in images that are loaded by
1237 /// code.
1238 ///
1239 /// \return
1240 /// A list of Module objects in a module list.
1241 const ModuleList &GetImages() const { return m_images; }
1242
1244
1245 /// Return whether this FileSpec corresponds to a module that should be
1246 /// considered for general searches.
1247 ///
1248 /// This API will be consulted by the SearchFilterForUnconstrainedSearches
1249 /// and any module that returns \b true will not be searched. Note the
1250 /// SearchFilterForUnconstrainedSearches is the search filter that
1251 /// gets used in the CreateBreakpoint calls when no modules is provided.
1252 ///
1253 /// The target call at present just consults the Platform's call of the
1254 /// same name.
1255 ///
1256 /// \param[in] module_spec
1257 /// Path to the module.
1258 ///
1259 /// \return \b true if the module should be excluded, \b false otherwise.
1260 bool ModuleIsExcludedForUnconstrainedSearches(const FileSpec &module_spec);
1261
1262 /// Return whether this module should be considered for general searches.
1263 ///
1264 /// This API will be consulted by the SearchFilterForUnconstrainedSearches
1265 /// and any module that returns \b true will not be searched. Note the
1266 /// SearchFilterForUnconstrainedSearches is the search filter that
1267 /// gets used in the CreateBreakpoint calls when no modules is provided.
1268 ///
1269 /// The target call at present just consults the Platform's call of the
1270 /// same name.
1271 ///
1272 /// FIXME: When we get time we should add a way for the user to set modules
1273 /// that they
1274 /// don't want searched, in addition to or instead of the platform ones.
1275 ///
1276 /// \param[in] module_sp
1277 /// A shared pointer reference to the module that checked.
1278 ///
1279 /// \return \b true if the module should be excluded, \b false otherwise.
1280 bool
1282
1283 const ArchSpec &GetArchitecture() const { return m_arch.GetSpec(); }
1284
1285 /// Returns the name of the target's ABI plugin.
1286 llvm::StringRef GetABIName() const;
1287
1288 /// Set the architecture for this target.
1289 ///
1290 /// If the current target has no Images read in, then this just sets the
1291 /// architecture, which will be used to select the architecture of the
1292 /// ExecutableModule when that is set. If the current target has an
1293 /// ExecutableModule, then calling SetArchitecture with a different
1294 /// architecture from the currently selected one will reset the
1295 /// ExecutableModule to that slice of the file backing the ExecutableModule.
1296 /// If the file backing the ExecutableModule does not contain a fork of this
1297 /// architecture, then this code will return false, and the architecture
1298 /// won't be changed. If the input arch_spec is the same as the already set
1299 /// architecture, this is a no-op.
1300 ///
1301 /// \param[in] arch_spec
1302 /// The new architecture.
1303 ///
1304 /// \param[in] set_platform
1305 /// If \b true, then the platform will be adjusted if the currently
1306 /// selected platform is not compatible with the architecture being set.
1307 /// If \b false, then just the architecture will be set even if the
1308 /// currently selected platform isn't compatible (in case it might be
1309 /// manually set following this function call).
1310 ///
1311 /// \param[in] merged
1312 /// If true, arch_spec is merged with the current
1313 /// architecture. Otherwise it's replaced.
1314 ///
1315 /// \return
1316 /// \b true if the architecture was successfully set, \b false otherwise.
1317 bool SetArchitecture(const ArchSpec &arch_spec, bool set_platform = false,
1318 bool merge = true);
1319
1320 bool MergeArchitecture(const ArchSpec &arch_spec);
1321
1322 Architecture *GetArchitecturePlugin() const { return m_arch.GetPlugin(); }
1323
1324 Debugger &GetDebugger() const { return m_debugger; }
1325
1326 size_t ReadMemoryFromFileCache(const Address &addr, void *dst, size_t dst_len,
1327 Status &error);
1328
1329 // Reading memory through the target allows us to skip going to the process
1330 // for reading memory if possible and it allows us to try and read from any
1331 // constant sections in our object files on disk. If you always want live
1332 // program memory, read straight from the process. If you possibly want to
1333 // read from const sections in object files, read from the target. This
1334 // version of ReadMemory will try and read memory from the process if the
1335 // process is alive. The order is:
1336 // 1 - if (force_live_memory == false) and the address falls in a read-only
1337 // section, then read from the file cache
1338 // 2 - if there is a process, then read from memory
1339 // 3 - if there is no process, then read from the file cache
1340 //
1341 // If did_read_live_memory is provided, will indicate if the read was from
1342 // live memory, or from file contents. A caller which needs to treat these two
1343 // sources differently should use this argument to disambiguate where the data
1344 // was read from.
1345 //
1346 // The method is virtual for mocking in the unit tests.
1347 virtual size_t ReadMemory(const Address &addr, void *dst, size_t dst_len,
1348 Status &error, bool force_live_memory = false,
1349 lldb::addr_t *load_addr_ptr = nullptr,
1350 bool *did_read_live_memory = nullptr);
1351
1352 size_t ReadCStringFromMemory(const Address &addr, std::string &out_str,
1353 Status &error, bool force_live_memory = false);
1354
1355 size_t ReadCStringFromMemory(const Address &addr, char *dst,
1356 size_t dst_max_len, Status &result_error,
1357 bool force_live_memory = false);
1358
1359 /// Read a NULL terminated string from memory
1360 ///
1361 /// This function will read a cache page at a time until a NULL string
1362 /// terminator is found. It will stop reading if an aligned sequence of NULL
1363 /// termination \a type_width bytes is not found before reading \a
1364 /// cstr_max_len bytes. The results are always guaranteed to be NULL
1365 /// terminated, and that no more than (max_bytes - type_width) bytes will be
1366 /// read.
1367 ///
1368 /// \param[in] addr
1369 /// The address to start the memory read.
1370 ///
1371 /// \param[in] dst
1372 /// A character buffer containing at least max_bytes.
1373 ///
1374 /// \param[in] max_bytes
1375 /// The maximum number of bytes to read.
1376 ///
1377 /// \param[in] error
1378 /// The error status of the read operation.
1379 ///
1380 /// \param[in] type_width
1381 /// The size of the null terminator (1 to 4 bytes per
1382 /// character). Defaults to 1.
1383 ///
1384 /// \return
1385 /// The error status or the number of bytes prior to the null terminator.
1386 size_t ReadStringFromMemory(const Address &addr, char *dst, size_t max_bytes,
1387 Status &error, size_t type_width,
1388 bool force_live_memory = true);
1389
1390 size_t ReadScalarIntegerFromMemory(const Address &addr, uint32_t byte_size,
1391 bool is_signed, Scalar &scalar,
1392 Status &error,
1393 bool force_live_memory = false);
1394
1395 int64_t ReadSignedIntegerFromMemory(const Address &addr,
1396 size_t integer_byte_size,
1397 int64_t fail_value, Status &error,
1398 bool force_live_memory = false);
1399
1400 uint64_t ReadUnsignedIntegerFromMemory(const Address &addr,
1401 size_t integer_byte_size,
1402 uint64_t fail_value, Status &error,
1403 bool force_live_memory = false);
1404
1405 bool ReadPointerFromMemory(const Address &addr, Status &error,
1406 Address &pointer_addr,
1407 bool force_live_memory = false);
1408
1409 bool HasLoadedSections();
1410
1412
1413 void ClearSectionLoadList();
1414
1415 void DumpSectionLoadList(Stream &s);
1416
1417 static Target *GetTargetFromContexts(const ExecutionContext *exe_ctx_ptr,
1418 const SymbolContext *sc_ptr);
1419
1420 // lldb::ExecutionContextScope pure virtual functions
1422
1424
1426
1428
1429 void CalculateExecutionContext(ExecutionContext &exe_ctx) override;
1430
1432
1433 llvm::Expected<lldb::TypeSystemSP>
1435 bool create_on_demand = true);
1436
1437 std::vector<lldb::TypeSystemSP>
1438 GetScratchTypeSystems(bool create_on_demand = true);
1439
1442
1443 // Creates a UserExpression for the given language, the rest of the
1444 // parameters have the same meaning as for the UserExpression constructor.
1445 // Returns a new-ed object which the caller owns.
1446
1448 GetUserExpressionForLanguage(llvm::StringRef expr, llvm::StringRef prefix,
1449 SourceLanguage language,
1450 Expression::ResultType desired_type,
1451 const EvaluateExpressionOptions &options,
1452 ValueObject *ctx_obj, Status &error);
1453
1454 // Creates a FunctionCaller for the given language, the rest of the
1455 // parameters have the same meaning as for the FunctionCaller constructor.
1456 // Since a FunctionCaller can't be
1457 // IR Interpreted, it makes no sense to call this with an
1458 // ExecutionContextScope that lacks
1459 // a Process.
1460 // Returns a new-ed object which the caller owns.
1461
1463 const CompilerType &return_type,
1464 const Address &function_address,
1465 const ValueList &arg_value_list,
1466 const char *name, Status &error);
1467
1468 /// Creates and installs a UtilityFunction for the given language.
1469 llvm::Expected<std::unique_ptr<UtilityFunction>>
1470 CreateUtilityFunction(std::string expression, std::string name,
1471 lldb::LanguageType language, ExecutionContext &exe_ctx);
1472
1473 // Install any files through the platform that need be to installed prior to
1474 // launching or attaching.
1475 Status Install(ProcessLaunchInfo *launch_info);
1476
1477 bool ResolveFileAddress(lldb::addr_t load_addr, Address &so_addr);
1478
1479 bool ResolveLoadAddress(lldb::addr_t load_addr, Address &so_addr,
1480 uint32_t stop_id = SectionLoadHistory::eStopIDNow,
1481 bool allow_section_end = false);
1482
1483 bool SetSectionLoadAddress(const lldb::SectionSP &section,
1484 lldb::addr_t load_addr,
1485 bool warn_multiple = false);
1486
1487 size_t UnloadModuleSections(const lldb::ModuleSP &module_sp);
1488
1489 size_t UnloadModuleSections(const ModuleList &module_list);
1490
1491 bool SetSectionUnloaded(const lldb::SectionSP &section_sp);
1492
1493 bool SetSectionUnloaded(const lldb::SectionSP &section_sp,
1494 lldb::addr_t load_addr);
1495
1497
1499 lldb_private::TypeSummaryImpl &summary_provider);
1501
1502 /// Set the \a Trace object containing processor trace information of this
1503 /// target.
1504 ///
1505 /// \param[in] trace_sp
1506 /// The trace object.
1507 void SetTrace(const lldb::TraceSP &trace_sp);
1508
1509 /// Get the \a Trace object containing processor trace information of this
1510 /// target.
1511 ///
1512 /// \return
1513 /// The trace object. It might be undefined.
1515
1516 /// Create a \a Trace object for the current target using the using the
1517 /// default supported tracing technology for this process.
1518 ///
1519 /// \return
1520 /// The new \a Trace or an \a llvm::Error if a \a Trace already exists or
1521 /// the trace couldn't be created.
1522 llvm::Expected<lldb::TraceSP> CreateTrace();
1523
1524 /// If a \a Trace object is present, this returns it, otherwise a new Trace is
1525 /// created with \a Trace::CreateTrace.
1526 llvm::Expected<lldb::TraceSP> GetTraceOrCreate();
1527
1528 // Since expressions results can persist beyond the lifetime of a process,
1529 // and the const expression results are available after a process is gone, we
1530 // provide a way for expressions to be evaluated from the Target itself. If
1531 // an expression is going to be run, then it should have a frame filled in in
1532 // the execution context.
1534 llvm::StringRef expression, ExecutionContextScope *exe_scope,
1535 lldb::ValueObjectSP &result_valobj_sp,
1537 std::string *fixed_expression = nullptr, ValueObject *ctx_obj = nullptr);
1538
1540
1542
1543 /// This method will return the address of the starting function for
1544 /// this binary, e.g. main() or its equivalent. This can be used as
1545 /// an address of a function that is not called once a binary has
1546 /// started running - e.g. as a return address for inferior function
1547 /// calls that are unambiguous completion of the function call, not
1548 /// called during the course of the inferior function code running.
1549 ///
1550 /// If no entry point can be found, an invalid address is returned.
1551 ///
1552 /// \param [out] err
1553 /// This object will be set to failure if no entry address could
1554 /// be found, and may contain a helpful error message.
1555 //
1556 /// \return
1557 /// Returns the entry address for this program, or an error
1558 /// if none can be found.
1559 llvm::Expected<lldb_private::Address> GetEntryPointAddress();
1560
1561 CompilerType GetRegisterType(const std::string &name,
1562 const lldb_private::RegisterFlags &flags,
1563 uint32_t byte_size);
1564
1565 /// Sends a breakpoint notification event.
1567 lldb::BreakpointEventType event_kind);
1568 /// Sends a breakpoint notification event.
1570 const lldb::EventDataSP &breakpoint_data_sp);
1571
1572 llvm::Expected<lldb::DisassemblerSP>
1573 ReadInstructions(const Address &start_addr, uint32_t count,
1574 const char *flavor_string = nullptr);
1575
1576 // Target Stop Hooks
1577 class StopHook : public UserID {
1578 public:
1579 StopHook(const StopHook &rhs);
1580 virtual ~StopHook() = default;
1581
1582 enum class StopHookKind : uint32_t {
1586 };
1593
1595
1596 // Set the specifier. The stop hook will own the specifier, and is
1597 // responsible for deleting it when we're done.
1598 void SetSpecifier(SymbolContextSpecifier *specifier);
1599
1601
1602 bool ExecutionContextPasses(const ExecutionContext &exe_ctx);
1603
1604 // Called on stop, this gets passed the ExecutionContext for each "stop
1605 // with a reason" thread. It should add to the stream whatever text it
1606 // wants to show the user, and return False to indicate it wants the target
1607 // not to stop.
1609 lldb::StreamSP output) = 0;
1610
1611 // Set the Thread Specifier. The stop hook will own the thread specifier,
1612 // and is responsible for deleting it when we're done.
1613 void SetThreadSpecifier(ThreadSpec *specifier);
1614
1616
1617 bool IsActive() { return m_active; }
1618
1619 void SetIsActive(bool is_active) { m_active = is_active; }
1620
1621 void SetAutoContinue(bool auto_continue) {
1622 m_auto_continue = auto_continue;
1623 }
1624
1625 bool GetAutoContinue() const { return m_auto_continue; }
1626
1627 void SetRunAtInitialStop(bool at_initial_stop) {
1628 m_at_initial_stop = at_initial_stop;
1629 }
1630
1632
1633 void SetSuppressOutput(bool suppress_output) {
1634 m_suppress_output = suppress_output;
1635 }
1636
1637 bool GetSuppressOutput() const { return m_suppress_output; }
1638
1639 void GetDescription(Stream &s, lldb::DescriptionLevel level) const;
1641 lldb::DescriptionLevel level) const = 0;
1642
1643 protected:
1646 std::unique_ptr<ThreadSpec> m_thread_spec_up;
1647 bool m_active = true;
1648 bool m_auto_continue = false;
1650 bool m_suppress_output = false;
1651
1652 StopHook(lldb::TargetSP target_sp, lldb::user_id_t uid);
1653 };
1654
1656 public:
1657 ~StopHookCommandLine() override = default;
1658
1660 void SetActionFromString(const std::string &strings);
1661 void SetActionFromStrings(const std::vector<std::string> &strings);
1662
1664 lldb::StreamSP output_sp) override;
1666 lldb::DescriptionLevel level) const override;
1667
1668 private:
1670 // Use CreateStopHook to make a new empty stop hook. Use SetActionFromString
1671 // to fill it with commands, and SetSpecifier to set the specifier shared
1672 // pointer (can be null, that will match anything.)
1674 : StopHook(target_sp, uid) {}
1675 friend class Target;
1676 };
1677
1679 public:
1680 ~StopHookScripted() override = default;
1682 lldb::StreamSP output) override;
1683
1684 Status SetScriptCallback(const ScriptedMetadata &scripted_metadata);
1685
1687 lldb::DescriptionLevel level) const override;
1688
1689 private:
1690 llvm::StringRef GetScriptClassName() const;
1691
1693
1694 /// Use CreateStopHook to make a new empty stop hook. Use SetScriptCallback
1695 /// to set the script to execute, and SetSpecifier to set the specifier
1696 /// shared pointer (can be null, that will match anything.)
1698 : StopHook(target_sp, uid) {}
1699 friend class Target;
1700 };
1701
1702 class StopHookCoded : public StopHook {
1703 public:
1704 ~StopHookCoded() override = default;
1705
1707 lldb::StreamSP output);
1708
1709 void SetCallback(llvm::StringRef name, HandleStopCallback *callback) {
1710 m_name = name;
1711 m_callback = callback;
1712 }
1713
1715 lldb::StreamSP output) override {
1716 return m_callback(exc_ctx, output);
1717 }
1718
1720 lldb::DescriptionLevel level) const override {
1721 s.Indent();
1722 s.Printf("%s (built-in)\n", m_name.c_str());
1723 }
1724
1725 private:
1726 std::string m_name;
1728
1729 /// Use CreateStopHook to make a new empty stop hook. Use SetCallback to set
1730 /// the callback to execute, and SetSpecifier to set the specifier shared
1731 /// pointer (can be null, that will match anything.)
1733 : StopHook(target_sp, uid) {}
1734 friend class Target;
1735 };
1736
1738
1739 typedef std::shared_ptr<StopHook> StopHookSP;
1740
1741 // Target Hooks
1742 //
1743 // Hooks fire on target lifecycle events. There are two flows:
1744 //
1745 // Command-based hooks: the user specifies which triggers the hook responds
1746 // to (--on-load, --on-unload, --on-stop) and provides a list of commands.
1747 // All commands run for every trigger the hook is signed up for.
1748 //
1749 // Python class hooks: the user provides a Python class name and optional
1750 // extra_args that will be passed to the hook init method (-k key -v value).
1751 // The class controls which events it handles by implementing the
1752 // corresponding callback methods (handle_module_loaded,
1753 // handle_module_unloaded, handle_stop). Triggers are set automatically
1754 // based on which methods exist.
1755 class Hook : public UserID {
1756 public:
1757 Hook(const Hook &rhs);
1758 virtual ~Hook() = default;
1759
1760 enum class HookKind : uint32_t { CommandBased = 0, ScriptBased };
1761
1762 HookKind GetHookKind() const { return m_kind; }
1763
1764 /// Individual trigger bits. Combine with bitwise OR to form a trigger mask.
1765 // FIXME: Add kProcessExit, kProcessDetach, etc. as needed.
1766 enum TriggerBit : uint32_t {
1767 kModulesLoaded = (1u << 0),
1768 kModulesUnloaded = (1u << 1),
1769 kProcessStop = (1u << 2),
1770 };
1771
1773
1774 bool IsEnabled() { return m_enabled; }
1775 void SetIsEnabled(bool enabled) { m_enabled = enabled; }
1776
1777 /// Return the bitmask of triggers this hook responds to.
1778 /// Each bit corresponds to a TriggerBit value.
1779 uint32_t GetTriggerMask() const { return m_trigger_mask; }
1780
1781 /// Return true if this hook fires on the given trigger.
1782 bool FiresOn(uint32_t trigger) const { return m_trigger_mask & trigger; }
1783
1784 // Filter fields
1785
1786 /// Set the symbol context specifier. The hook takes ownership.
1787 void SetSCSpecifier(SymbolContextSpecifier *specifier);
1789
1790 /// Check if the execution context passes the specifier and thread spec
1791 /// filters. Always returns true if no filters are set.
1792 bool ExecutionContextPasses(const ExecutionContext &exe_ctx);
1793
1794 /// Set the thread specifier. The hook takes ownership.
1795 void SetThreadSpecifier(ThreadSpec *specifier);
1797
1798 void SetRunAtInitialStop(bool at_initial_stop) {
1799 m_at_initial_stop = at_initial_stop;
1800 }
1802
1803 // Reaction settings
1804
1805 void SetAutoContinue(bool auto_continue) {
1806 m_auto_continue = auto_continue;
1807 }
1808 bool GetAutoContinue() const { return m_auto_continue; }
1809
1810 void SetSuppressOutput(bool suppress_output) {
1811 m_suppress_output = suppress_output;
1812 }
1813 bool GetSuppressOutput() const { return m_suppress_output; }
1814
1815 // Event handler methods (default no-ops)
1816
1817 virtual void HandleModuleLoaded(lldb::StreamSP output) {}
1818 virtual void HandleModuleUnloaded(lldb::StreamSP output) {}
1819
1820 /// Called when the process stops. Returns a StopHookResult indicating
1821 /// whether the process should remain stopped or continue.
1826
1827 virtual void GetDescription(Stream &s, lldb::DescriptionLevel level) const;
1828
1829 protected:
1830 /// Print the filter portion of the description (AutoContinue, Specifier,
1831 /// ThreadSpec). Called by subclass GetDescription after printing the
1832 /// hook-specific content (commands or class).
1836 bool m_enabled = true;
1837 uint32_t m_trigger_mask = 0; // No default, triggers must be explicit.
1838
1839 // Filters
1841 std::unique_ptr<ThreadSpec> m_thread_spec_up;
1843
1844 // Reaction settings
1845 bool m_auto_continue = false;
1846 bool m_suppress_output = false;
1847
1848 Hook(lldb::TargetSP target_sp, lldb::user_id_t uid, HookKind kind);
1849 };
1850
1851 class HookCommandLine : public Hook {
1852 public:
1853 ~HookCommandLine() override = default;
1854
1855 /// Replace the trigger mask. \a mask is a bitwise OR of TriggerBit values.
1856 void SetTriggerMask(uint32_t mask) { m_trigger_mask = mask; }
1857
1858 /// Add a trigger to the mask. \a trigger is a single TriggerBit value.
1859 void AddTrigger(uint32_t trigger) { m_trigger_mask |= trigger; }
1860
1861 /// Remove a trigger from the mask. \a trigger is a single TriggerBit value.
1862 void RemoveTrigger(uint32_t trigger) { m_trigger_mask &= ~trigger; }
1863
1864 /// Return the list of commands that this hook runs.
1866
1867 /// Populate the command list by splitting a single string on newlines.
1868 void SetActionFromString(const std::string &string);
1869
1870 /// Populate the command list from a vector of individual command strings.
1871 void SetActionFromStrings(const std::vector<std::string> &strings);
1872
1873 void GetDescription(Stream &s, lldb::DescriptionLevel level) const override;
1874 void HandleModuleLoaded(lldb::StreamSP output) override;
1875 void HandleModuleUnloaded(lldb::StreamSP output) override;
1877 lldb::StreamSP output) override;
1878
1879 private:
1881
1883 : Hook(target_sp, uid, HookKind::CommandBased) {}
1884 friend class Target;
1885 };
1886
1887 class HookScripted : public Hook {
1888 public:
1889 ~HookScripted() override = default;
1890
1891 void GetDescription(Stream &s, lldb::DescriptionLevel level) const override;
1892
1893 void HandleModuleLoaded(lldb::StreamSP output) override;
1894 void HandleModuleUnloaded(lldb::StreamSP output) override;
1896 lldb::StreamSP output) override;
1897
1898 Status SetScriptCallback(const ScriptedMetadata &scripted_metadata);
1899
1900 private:
1901 llvm::StringRef GetScriptClassName() const;
1902
1904
1906 : Hook(target_sp, uid, HookKind::ScriptBased) {}
1907 friend class Target;
1908 };
1909
1910 typedef std::shared_ptr<Hook> HookSP;
1911
1913
1914 /// Removes the most recently created hook. Used to roll back a
1915 /// hook creation when an error occurs (e.g., invalid script class name
1916 /// or empty interactive input).
1918
1920
1921 void RemoveAllHooks();
1922
1924
1925 bool SetHookEnabledStateByID(lldb::user_id_t uid, bool enabled);
1926
1927 void SetAllHooksEnabledState(bool enabled);
1928
1929 size_t GetNumHooks() const { return m_hooks.size(); }
1930
1931 HookSP GetHookAtIndex(size_t index);
1932
1933 void RunModuleHooks(bool is_load);
1934
1935 /// Add an empty stop hook to the Target's stop hook list, and returns a
1936 /// shared pointer to the new hook.
1937 StopHookSP CreateStopHook(StopHook::StopHookKind kind, bool internal = false);
1938
1939 /// If you tried to create a stop hook, and that failed, call this to
1940 /// remove the stop hook, as it will also reset the stop hook counter.
1942
1943 // Runs the stop hooks that have been registered for this target.
1944 // Returns true if the stop hooks cause the target to resume.
1945 // Pass at_initial_stop if this is the stop where lldb gains
1946 // control over the process for the first time.
1947 bool RunStopHooks(bool at_initial_stop = false);
1948
1949 bool SetSuppresStopHooks(bool suppress) {
1950 bool old_value = m_suppress_stop_hooks;
1951 m_suppress_stop_hooks = suppress;
1952 return old_value;
1953 }
1954
1956
1958
1959 void RemoveAllStopHooks();
1960
1961 StopHookSP GetStopHookByID(lldb::user_id_t uid);
1962
1963 bool SetStopHookActiveStateByID(lldb::user_id_t uid, bool active_state);
1964
1965 void SetAllStopHooksActiveState(bool active_state);
1966
1967 const std::vector<StopHookSP> GetStopHooks(bool internal = false) const;
1968
1970
1971 void SetPlatform(const lldb::PlatformSP &platform_sp) {
1972 m_platform_sp = platform_sp;
1973 }
1974
1976
1977 // Methods.
1979 GetSearchFilterForModule(const FileSpec *containingModule);
1980
1982 GetSearchFilterForModuleList(const FileSpecList *containingModuleList);
1983
1985 GetSearchFilterForModuleAndCUList(const FileSpecList *containingModules,
1986 const FileSpecList *containingSourceFiles);
1987
1989 const char *repl_options, bool can_create);
1990
1991 void SetREPL(lldb::LanguageType language, lldb::REPLSP repl_sp);
1992
1996
1998
1999 /// Get the list of paths that LLDB will consider automatically loading
2000 /// scripting resources from. Currently whether to load scripts
2001 /// unconditionally is controlled via the
2002 /// `target.load-script-from-symbol-file` setting.
2004
2005 /// Add a signal for the target. This will get copied over to the process
2006 /// if the signal exists on that target. Only the values with Yes and No are
2007 /// set, Calculate values will be ignored.
2008protected:
2017 using DummySignalElement = llvm::StringMapEntry<DummySignalValues>;
2018 static bool UpdateSignalFromDummy(lldb::UnixSignalsSP signals_sp,
2019 const DummySignalElement &element);
2020 static bool ResetSignalFromDummy(lldb::UnixSignalsSP signals_sp,
2021 const DummySignalElement &element);
2022
2023public:
2024 /// Add a signal to the Target's list of stored signals/actions. These
2025 /// values will get copied into any processes launched from
2026 /// this target.
2027 void AddDummySignal(llvm::StringRef name, LazyBool pass, LazyBool print,
2028 LazyBool stop);
2029 /// Updates the signals in signals_sp using the stored dummy signals.
2030 /// If warning_stream_sp is not null, if any stored signals are not found in
2031 /// the current process, a warning will be emitted here.
2033 lldb::StreamSP warning_stream_sp);
2034 /// Clear the dummy signals in signal_names from the target, or all signals
2035 /// if signal_names is empty. Also remove the behaviors they set from the
2036 /// process's signals if it exists.
2037 void ClearDummySignals(Args &signal_names);
2038 /// Print all the signals set in this target.
2039 void PrintDummySignals(Stream &strm, Args &signals);
2040
2041protected:
2042 /// Implementing of ModuleList::Notifier.
2043
2044 void NotifyModuleAdded(const ModuleList &module_list,
2045 const lldb::ModuleSP &module_sp) override;
2046
2047 void NotifyModuleRemoved(const ModuleList &module_list,
2048 const lldb::ModuleSP &module_sp) override;
2049
2050 void NotifyModuleUpdated(const ModuleList &module_list,
2051 const lldb::ModuleSP &old_module_sp,
2052 const lldb::ModuleSP &new_module_sp) override;
2053
2054 void NotifyWillClearList(const ModuleList &module_list) override;
2055
2056 void NotifyModulesRemoved(lldb_private::ModuleList &module_list) override;
2057
2058 class Arch {
2059 public:
2060 explicit Arch(const ArchSpec &spec);
2061 const Arch &operator=(const ArchSpec &spec);
2062
2063 const ArchSpec &GetSpec() const { return m_spec; }
2064 Architecture *GetPlugin() const { return m_plugin_up.get(); }
2065
2066 private:
2068 std::unique_ptr<Architecture> m_plugin_up;
2069 };
2070
2071 // Member variables.
2073 lldb::PlatformSP m_platform_sp; ///< The platform for this target.
2074 std::recursive_mutex m_mutex; ///< An API mutex that is used by the lldb::SB*
2075 /// classes make the SB interface thread safe
2076 /// When the private state thread calls SB API's - usually because it is
2077 /// running OS plugin or Python ThreadPlan code - it should not block on the
2078 /// API mutex that is held by the code that kicked off the sequence of events
2079 /// that led us to run the code. We hand out this mutex instead when we
2080 /// detect that code is running on the private state thread.
2081 std::recursive_mutex m_private_mutex;
2083 std::string m_label;
2084 ModuleList m_images; ///< The list of images for this process (shared
2085 /// libraries and anything dynamically loaded).
2091 std::map<ConstString, std::unique_ptr<BreakpointName>>;
2093
2094 std::map<lldb::user_id_t, BreakpointResolverOverrideUP>
2096 /// This is the ID that will be handed out for the next added breakpoint
2097 /// override resolver for this target.
2099
2103 // We want to tightly control the process destruction process so we can
2104 // correctly tear down everything that we need to, so the only class that
2105 // knows about the process lifespan is this target class.
2110
2111 /// Map of scripted frame provider descriptors for this target.
2112 /// Keys are the provider descriptor IDs, values are the descriptors.
2113 /// Insertion order is preserved so that equal-priority providers chain
2114 /// in registration order.
2115 llvm::MapVector<uint32_t, ScriptedFrameProviderDescriptor>
2117 mutable std::recursive_mutex m_frame_provider_descriptors_mutex;
2119
2120 typedef std::map<lldb::LanguageType, lldb::REPLSP> REPLMap;
2122
2124
2125 typedef std::map<lldb::user_id_t, StopHookSP> StopHookCollection;
2128 std::vector<StopHookSP> m_internal_stop_hooks;
2129 uint32_t m_latest_stop_hook_id; /// This records the last natural stop at
2130 /// which we ran a stop-hook.
2132 bool m_suppress_stop_hooks; /// Used to not run stop hooks for expressions
2134
2135 typedef std::map<lldb::user_id_t, HookSP> HookCollection;
2140 LLDB_INVALID_GLOBALLY_UNIQUE_TARGET_ID; ///< The globally unique ID
2141 /// assigned to this target
2142 std::string m_target_session_name; ///< The target session name for this
2143 /// target, used to name debugging
2144 /// sessions in DAP.
2145 /// An optional \a lldb_private::Trace object containing processor trace
2146 /// information of this target.
2148 /// Stores the frame recognizers of this target.
2150 /// These are used to set the signal state when you don't have a process and
2151 /// more usefully in the Dummy target where you can't know exactly what
2152 /// signals you will have.
2153 llvm::StringMap<DummySignalValues> m_dummy_signals;
2154
2156
2157 static void ImageSearchPathsChanged(const PathMappingList &path_list,
2158 void *baton);
2159
2160 // Utilities for `statistics` command.
2161private:
2162 // Target metrics storage.
2164
2165public:
2166 /// Get metrics associated with this target in JSON format.
2167 ///
2168 /// Target metrics help measure timings and information that is contained in
2169 /// a target. These are designed to help measure performance of a debug
2170 /// session as well as represent the current state of the target, like
2171 /// information on the currently modules, currently set breakpoints and more.
2172 ///
2173 /// \return
2174 /// Returns a JSON value that contains all target metrics.
2175 llvm::json::Value
2177
2178 void ResetStatistics();
2179
2181
2182protected:
2183 /// Construct with optional file and arch.
2184 ///
2185 /// This member is private. Clients must use
2186 /// TargetList::CreateTarget(const FileSpec*, const ArchSpec*)
2187 /// so all targets can be tracked from the central target list.
2188 ///
2189 /// \see TargetList::CreateTarget(const FileSpec*, const ArchSpec*)
2190 Target(Debugger &debugger, const ArchSpec &target_arch,
2191 const lldb::PlatformSP &platform_sp, bool is_dummy_target);
2192
2193 // Helper function.
2194 bool ProcessIsValid();
2195
2196 // Copy breakpoints, stop hooks and so forth from the dummy target:
2197 void PrimeFromDummyTarget(Target &target);
2198
2199 void AddBreakpoint(lldb::BreakpointSP breakpoint_sp, bool internal);
2200
2202
2203 /// Return a recommended size for memory reads at \a addr, optimizing for
2204 /// cache usage.
2206
2207 Target(const Target &) = delete;
2208 const Target &operator=(const Target &) = delete;
2209
2211 return m_section_load_history.GetCurrentSectionLoadList();
2212 }
2213};
2214
2215} // namespace lldb_private
2216
2217#endif // LLDB_TARGET_TARGET_H
static llvm::raw_ostream & error(Stream &strm)
A section + offset based address class.
Definition Address.h:62
An architecture specification class.
Definition ArchSpec.h:32
A command line argument class.
Definition Args.h:33
General Outline: Allows adding and removing breakpoints and find by ID and index.
"lldb/Breakpoint/BreakpointOptions.h" Class that manages the options on a breakpoint or breakpoint lo...
General Outline: A breakpoint has four main parts, a filter, a resolver, the list of breakpoint locat...
Definition Breakpoint.h:81
Broadcaster(lldb::BroadcasterManagerSP manager_sp, std::string name)
Construct with a broadcaster with a name.
Generic representation of a type in a programming language.
A uniqued constant string class.
Definition ConstString.h:40
A class to manage flag bits.
Definition Debugger.h:100
void SetPreferredSymbolContexts(SymbolContextList contexts)
Definition Target.h:364
void SetOneThreadTimeout(const Timeout< std::micro > &timeout)
Definition Target.h:423
void SetUnwindOnError(bool unwind=false)
Definition Target.h:396
SourceLanguage GetLanguage() const
Definition Target.h:358
const char * GetPoundLineFilePath() const
Definition Target.h:486
lldb::DynamicValueType m_use_dynamic
Definition Target.h:554
void SetExecutionPolicy(ExecutionPolicy policy=eExecutionPolicyAlways)
Definition Target.h:354
Timeout< std::micro > m_one_thread_timeout
Definition Target.h:556
bool InvokeCancelCallback(lldb::ExpressionEvaluationPhase phase) const
Definition Target.h:468
lldb::DynamicValueType GetUseDynamic() const
Definition Target.h:408
void SetKeepInMemory(bool keep=true)
Definition Target.h:406
void SetCoerceToId(bool coerce=true)
Definition Target.h:392
void SetLanguage(lldb::LanguageType language_type)
Definition Target.h:360
ExecutionPolicy GetExecutionPolicy() const
Definition Target.h:352
Timeout< std::micro > m_timeout
Definition Target.h:555
void SetCppIgnoreContextQualifiers(bool value)
Definition Target.cpp:6090
const StructuredData::Dictionary & GetLanguageOptions() const
Definition Target.cpp:6068
llvm::Expected< bool > GetBooleanLanguageOption(llvm::StringRef option_name) const
Get the language-plugin specific boolean option called option_name.
Definition Target.cpp:6052
void SetPrefix(const char *prefix)
Definition Target.h:385
void SetTryAllThreads(bool try_others=true)
Definition Target.h:429
static constexpr std::chrono::milliseconds default_timeout
Definition Target.h:344
void SetPoundLine(const char *path, uint32_t line) const
Definition Target.h:476
void SetRetriesWithFixIts(uint64_t number_of_retries)
Definition Target.h:502
SymbolContextList m_preferred_lookup_contexts
During expression evaluation, any SymbolContext in this list will be used for symbol/function lookup ...
Definition Target.h:572
void SetTimeout(const Timeout< std::micro > &timeout)
Definition Target.h:417
static constexpr ExecutionPolicy default_execution_policy
Definition Target.h:349
void SetStopOthers(bool stop_others=true)
Definition Target.h:433
bool m_running_utility_expression
True if the executed code should be treated as utility code that is only used by LLDB internally.
Definition Target.h:552
llvm::Error SetBooleanLanguageOption(llvm::StringRef option_name, bool value)
Set language-plugin specific option called option_name to the specified boolean value.
Definition Target.cpp:6035
StructuredData::DictionarySP m_language_options_sp
Dictionary mapping names of language-plugin specific options to values.
Definition Target.h:567
void SetCancelCallback(lldb::ExpressionCancelCallback callback, void *baton)
Definition Target.h:463
const Timeout< std::micro > & GetTimeout() const
Definition Target.h:415
const SymbolContextList & GetPreferredSymbolContexts() const
Definition Target.h:368
void SetIgnoreBreakpoints(bool ignore=false)
Definition Target.h:400
void SetLanguage(uint16_t name, uint32_t version)
Set the language using a pair of language code and version as defined by the DWARF 6 specification.
Definition Target.h:375
void SetUseDynamic(lldb::DynamicValueType dynamic=lldb::eDynamicCanRunTarget)
Definition Target.h:411
lldb::ExpressionCancelCallback m_cancel_callback
Definition Target.h:557
const Timeout< std::micro > & GetOneThreadTimeout() const
Definition Target.h:419
"lldb/Target/ExecutionContextScope.h" Inherit from this if your object can reconstruct its execution ...
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
A file collection class.
A file utility class.
Definition FileSpec.h:57
Encapsulates a function that can be called.
A collection class for Module objects.
Definition ModuleList.h:125
A class that describes an executable image and its associated object and symbol files.
Definition Module.h:91
Class that provides a registry of known stack frame recognizers.
An error handling class.
Definition Status.h:118
A stream class that can stream formatted output to a file.
Definition Stream.h:28
size_t Indent(llvm::StringRef s="")
Indent the current line in the stream.
Definition Stream.cpp:157
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition Stream.cpp:134
std::shared_ptr< Dictionary > DictionarySP
std::shared_ptr< Object > ObjectSP
A class that wraps a std::map of SummaryStatistics objects behind a mutex.
Definition Statistics.h:281
Defines a list of symbol context objects.
Defines a symbol context baton that can be handed other debug core functions.
uint32_t GetMaximumSizeOfStringSummary() const
Definition Target.cpp:5563
FileSpecList GetDebugFileSearchPaths()
Definition Target.cpp:5444
llvm::StringRef GetLaunchWorkingDirectory() const
Definition Target.cpp:5250
bool GetDisplayRecognizedArguments() const
Definition Target.cpp:5727
ImportStdModule GetImportStdModule() const
Definition Target.cpp:5460
void AppendExecutableSearchPaths(const FileSpec &)
Definition Target.cpp:5431
bool GetEnableSyntheticValue() const
Definition Target.cpp:5530
void SetStandardInputPath(const char *path)=delete
ProcessLaunchInfo m_launch_info
Definition Target.h:327
bool GetCheckValueObjectOwnership() const
Definition Target.cpp:5855
uint64_t GetExprAllocAlign() const
Definition Target.cpp:5642
MemoryModuleLoadLevel GetMemoryModuleLoadLevel() const
Definition Target.cpp:5699
llvm::StringRef GetArg0() const
Definition Target.cpp:5303
uint32_t GetMaximumMemReadSize() const
Definition Target.cpp:5569
void SetRunArguments(const Args &args)
Definition Target.cpp:5320
FileSpec GetStandardErrorPath() const
Definition Target.cpp:5595
void SetLoadScriptFromSymbolFile(LoadScriptFromSymFile load_style)
Set the target-wide target.load-script-from-symbol-file setting.
Definition Target.cpp:5679
bool GetEnableNotifyAboutFixIts() const
Definition Target.cpp:5486
bool SetPreferDynamicValue(lldb::DynamicValueType d)
Definition Target.cpp:5187
void SetDisplayRecognizedArguments(bool b)
Definition Target.cpp:5733
std::optional< bool > GetExperimentalPropertyValue(size_t prop_idx, ExecutionContext *exe_ctx=nullptr) const
Definition Target.cpp:5126
const ProcessLaunchInfo & GetProcessLaunchInfo() const
Definition Target.cpp:5738
Environment ComputeEnvironment() const
Definition Target.cpp:5326
void SetStandardOutputPath(const char *path)=delete
bool GetUserSpecifiedTrapHandlerNames(Args &args) const
Definition Target.cpp:5706
uint64_t GetExprErrorLimit() const
Definition Target.cpp:5624
bool GetEnableAutoImportClangModules() const
Definition Target.cpp:5454
bool GetDebugUtilityExpression() const
Definition Target.cpp:5844
DynamicClassInfoHelper GetDynamicClassInfoHelper() const
Definition Target.cpp:5467
FileSpec GetStandardOutputPath() const
Definition Target.cpp:5585
void SetDisplayRuntimeSupportValues(bool b)
Definition Target.cpp:5722
uint32_t GetMaximumNumberOfChildrenToDisplay() const
Definition Target.cpp:5548
void SetRequireHardwareBreakpoints(bool b)
Definition Target.cpp:5776
bool GetAutoInstallMainExecutable() const
Definition Target.cpp:5781
const char * GetDisassemblyFeatures() const
Definition Target.cpp:5282
void SetAutoLoadScriptsForModule(llvm::StringRef module_name, LoadScriptFromSymFile load_style)
Set the LoadScriptFromSymFile for a module called module_name (excluding file extension).
Definition Target.cpp:5881
RealpathPrefixes GetSourceRealpathPrefixes() const
Definition Target.cpp:5298
void SetCheckValueObjectOwnership(bool check)
Definition Target.cpp:5861
uint64_t GetNumberOfRetriesWithFixits() const
Definition Target.cpp:5480
uint64_t GetExprAllocSize() const
Definition Target.cpp:5636
std::optional< LoadScriptFromSymFile > GetAutoLoadScriptsForModule(llvm::StringRef module_name) const
Definition Target.cpp:5867
llvm::StringRef GetExpressionPrefixContents()
Definition Target.cpp:5610
PathMappingList & GetObjectPathMap() const
Definition Target.cpp:5417
const char * GetDisassemblyFlavor() const
Definition Target.cpp:5262
FileSpec GetStandardInputPath() const
Definition Target.cpp:5575
lldb::DynamicValueType GetPreferDynamicValue() const
Definition Target.cpp:5180
InlineStrategy GetInlineStrategy() const
Definition Target.cpp:5289
Environment GetTargetEnvironment() const
Definition Target.cpp:5386
bool GetDisplayRuntimeSupportValues() const
Definition Target.cpp:5716
void SetUserSpecifiedTrapHandlerNames(const Args &args)
Definition Target.cpp:5711
uint32_t GetMaxZeroPaddingInFloatFormat() const
Definition Target.cpp:5542
uint64_t GetExprAllocAddress() const
Definition Target.cpp:5630
LoadCWDlldbinitFile GetLoadCWDlldbinitFile() const
Definition Target.cpp:5685
Environment GetInheritedEnvironment() const
Definition Target.cpp:5358
void SetArg0(llvm::StringRef arg)
Definition Target.cpp:5309
bool GetInjectLocalVariables(ExecutionContext *exe_ctx) const
Definition Target.cpp:5137
void SetStandardErrorPath(const char *path)=delete
bool ShowHexVariableValuesWithLeadingZeroes() const
Definition Target.cpp:5536
SourceLanguage GetLanguage() const
Definition Target.cpp:5605
Environment GetEnvironment() const
Definition Target.cpp:5354
void SetProcessLaunchInfo(const ProcessLaunchInfo &launch_info)
Definition Target.cpp:5742
FileSpec GetSaveJITObjectsDir() const
Definition Target.cpp:5492
void SetEnvironment(Environment env)
Definition Target.cpp:5397
LoadScriptFromSymFile GetLoadScriptFromSymbolFile() const
Definition Target.cpp:5672
const char * GetDisassemblyCPU() const
Definition Target.cpp:5275
void SetStandardErrorPath(llvm::StringRef path)
Definition Target.cpp:5600
bool GetRunArguments(Args &args) const
Definition Target.cpp:5315
FileSpecList GetExecutableSearchPaths()
Definition Target.cpp:5439
ArchSpec GetDefaultArchitecture() const
Definition Target.cpp:5164
Disassembler::HexImmediateStyle GetHexImmediateStyle() const
Definition Target.cpp:5692
void SetUseDIL(ExecutionContext *exe_ctx, bool b)
Definition Target.cpp:5155
std::unique_ptr< TargetExperimentalProperties > m_experimental_properties_up
Definition Target.h:328
FileSpecList GetClangModuleSearchPaths()
Definition Target.cpp:5449
void SetStandardOutputPath(llvm::StringRef path)
Definition Target.cpp:5590
bool GetRequireHardwareBreakpoints() const
Definition Target.cpp:5770
PathMappingList & GetSourcePathMap() const
Definition Target.cpp:5409
bool GetAutoSourceMapRelative() const
Definition Target.cpp:5425
bool GetUseDIL(ExecutionContext *exe_ctx) const
Definition Target.cpp:5143
void SetDefaultArchitecture(const ArchSpec &arch)
Definition Target.cpp:5169
void SetStandardInputPath(llvm::StringRef path)
Definition Target.cpp:5580
TargetProperties(Target *target)
Definition Target.cpp:5050
bool GetDisplayExpressionsInCrashlogs() const
Definition Target.cpp:5666
bool GetEnableAutoApplyFixIts() const
Definition Target.cpp:5474
void SetDebugUtilityExpression(bool debug)
Definition Target.cpp:5850
std::pair< uint32_t, bool > GetMaximumDepthOfChildrenToDisplay() const
Get the max depth value, augmented with a bool to indicate whether the depth is the default.
Definition Target.cpp:5555
A class that represents statistics for a since lldb_private::Target.
Definition Statistics.h:309
std::unique_ptr< Architecture > m_plugin_up
Definition Target.h:2068
const ArchSpec & GetSpec() const
Definition Target.h:2063
const Arch & operator=(const ArchSpec &spec)
Definition Target.cpp:169
Arch(const ArchSpec &spec)
Definition Target.cpp:165
Architecture * GetPlugin() const
Definition Target.h:2064
virtual BreakpointResolverOverrideUP CopyIntoNewTarget(Target &target)=0
BreakpointResolverOverride(Target &target, const std::string &description)
Definition Target.h:1020
virtual lldb::BreakpointResolverSP CheckForOverride(Target &target, lldb::BreakpointResolverSP initial_sp)=0
void AddTrigger(uint32_t trigger)
Add a trigger to the mask. trigger is a single TriggerBit value.
Definition Target.h:1859
void RemoveTrigger(uint32_t trigger)
Remove a trigger from the mask. trigger is a single TriggerBit value.
Definition Target.h:1862
void GetDescription(Stream &s, lldb::DescriptionLevel level) const override
Definition Target.cpp:4486
HookCommandLine(lldb::TargetSP target_sp, lldb::user_id_t uid)
Definition Target.h:1882
void SetTriggerMask(uint32_t mask)
Replace the trigger mask. mask is a bitwise OR of TriggerBit values.
Definition Target.h:1856
void SetActionFromString(const std::string &string)
Populate the command list by splitting a single string on newlines.
Definition Target.cpp:4513
void SetActionFromStrings(const std::vector< std::string > &strings)
Populate the command list from a vector of individual command strings.
Definition Target.cpp:4517
void HandleModuleLoaded(lldb::StreamSP output) override
Definition Target.cpp:4523
StringList & GetCommands()
Return the list of commands that this hook runs.
Definition Target.h:1865
StopHook::StopHookResult HandleStop(ExecutionContext &exe_ctx, lldb::StreamSP output) override
Called when the process stops.
Definition Target.cpp:4563
void HandleModuleUnloaded(lldb::StreamSP output) override
Definition Target.cpp:4557
llvm::StringRef GetScriptClassName() const
Definition Target.cpp:4676
Status SetScriptCallback(const ScriptedMetadata &scripted_metadata)
Definition Target.cpp:4597
void HandleModuleLoaded(lldb::StreamSP output) override
Definition Target.cpp:4639
StopHook::StopHookResult HandleStop(ExecutionContext &exe_ctx, lldb::StreamSP output) override
Called when the process stops.
Definition Target.cpp:4658
HookScripted(lldb::TargetSP target_sp, lldb::user_id_t uid)
Definition Target.h:1905
void GetDescription(Stream &s, lldb::DescriptionLevel level) const override
Definition Target.cpp:4682
lldb::ScriptedHookInterfaceSP m_interface_sp
Definition Target.h:1903
void HandleModuleUnloaded(lldb::StreamSP output) override
Definition Target.cpp:4648
virtual ~Hook()=default
void SetSuppressOutput(bool suppress_output)
Definition Target.h:1810
bool GetRunAtInitialStop() const
Definition Target.h:1801
ThreadSpec * GetThreadSpecifier()
Definition Target.h:1796
TriggerBit
Individual trigger bits. Combine with bitwise OR to form a trigger mask.
Definition Target.h:1766
bool GetSuppressOutput() const
Definition Target.h:1813
void SetRunAtInitialStop(bool at_initial_stop)
Definition Target.h:1798
lldb::SymbolContextSpecifierSP m_sc_specifier_sp
Definition Target.h:1840
void SetIsEnabled(bool enabled)
Definition Target.h:1775
bool ExecutionContextPasses(const ExecutionContext &exe_ctx)
Check if the execution context passes the specifier and thread spec filters.
Definition Target.cpp:4409
HookKind GetHookKind() const
Definition Target.h:1762
Hook(const Hook &rhs)
Definition Target.cpp:4390
virtual StopHook::StopHookResult HandleStop(ExecutionContext &exe_ctx, lldb::StreamSP output)
Called when the process stops.
Definition Target.h:1822
void GetFilterDescription(Stream &s, lldb::DescriptionLevel level) const
Print the filter portion of the description (AutoContinue, Specifier, ThreadSpec).
Definition Target.cpp:4458
void SetAutoContinue(bool auto_continue)
Definition Target.h:1805
bool GetAutoContinue() const
Definition Target.h:1808
virtual void HandleModuleUnloaded(lldb::StreamSP output)
Definition Target.h:1818
uint32_t GetTriggerMask() const
Return the bitmask of triggers this hook responds to.
Definition Target.h:1779
lldb::TargetSP & GetTarget()
Definition Target.h:1772
SymbolContextSpecifier * GetSCSpecifier()
Definition Target.h:1788
lldb::TargetSP m_target_sp
Definition Target.h:1834
virtual void GetDescription(Stream &s, lldb::DescriptionLevel level) const
Definition Target.cpp:4425
void SetSCSpecifier(SymbolContextSpecifier *specifier)
Set the symbol context specifier. The hook takes ownership.
Definition Target.cpp:4401
void SetThreadSpecifier(ThreadSpec *specifier)
Set the thread specifier. The hook takes ownership.
Definition Target.cpp:4405
virtual void HandleModuleLoaded(lldb::StreamSP output)
Definition Target.h:1817
bool FiresOn(uint32_t trigger) const
Return true if this hook fires on the given trigger.
Definition Target.h:1782
std::unique_ptr< ThreadSpec > m_thread_spec_up
Definition Target.h:1841
void GetSubclassDescription(Stream &s, lldb::DescriptionLevel level) const override
Definition Target.h:1719
HandleStopCallback * m_callback
Definition Target.h:1727
StopHookResult HandleStop(ExecutionContext &exc_ctx, lldb::StreamSP output) override
Definition Target.h:1714
StopHookCoded(lldb::TargetSP target_sp, lldb::user_id_t uid)
Use CreateStopHook to make a new empty stop hook.
Definition Target.h:1732
void SetCallback(llvm::StringRef name, HandleStopCallback *callback)
Definition Target.h:1709
StopHookResult(ExecutionContext &exc_ctx, lldb::StreamSP output) HandleStopCallback
Definition Target.h:1706
void SetActionFromString(const std::string &strings)
Definition Target.cpp:4238
StopHookCommandLine(lldb::TargetSP target_sp, lldb::user_id_t uid)
Definition Target.h:1673
void SetActionFromStrings(const std::vector< std::string > &strings)
Definition Target.cpp:4242
StopHookResult HandleStop(ExecutionContext &exc_ctx, lldb::StreamSP output_sp) override
Definition Target.cpp:4249
void GetSubclassDescription(Stream &s, lldb::DescriptionLevel level) const override
Definition Target.cpp:4220
StopHookResult HandleStop(ExecutionContext &exc_ctx, lldb::StreamSP output) override
Definition Target.cpp:4320
Status SetScriptCallback(const ScriptedMetadata &scripted_metadata)
Definition Target.cpp:4283
StopHookScripted(lldb::TargetSP target_sp, lldb::user_id_t uid)
Use CreateStopHook to make a new empty stop hook.
Definition Target.h:1697
void GetSubclassDescription(Stream &s, lldb::DescriptionLevel level) const override
Definition Target.cpp:4348
llvm::StringRef GetScriptClassName() const
Definition Target.cpp:4342
lldb::ScriptedStopHookInterfaceSP m_interface_sp
Definition Target.h:1692
bool GetRunAtInitialStop() const
Definition Target.h:1631
SymbolContextSpecifier * GetSpecifier()
Definition Target.h:1600
void SetSpecifier(SymbolContextSpecifier *specifier)
Definition Target.cpp:4158
virtual StopHookResult HandleStop(ExecutionContext &exe_ctx, lldb::StreamSP output)=0
std::unique_ptr< ThreadSpec > m_thread_spec_up
Definition Target.h:1646
void SetIsActive(bool is_active)
Definition Target.h:1619
void SetSuppressOutput(bool suppress_output)
Definition Target.h:1633
void SetThreadSpecifier(ThreadSpec *specifier)
Definition Target.cpp:4162
ThreadSpec * GetThreadSpecifier()
Definition Target.h:1615
StopHook(const StopHook &rhs)
Definition Target.cpp:4150
bool ExecutionContextPasses(const ExecutionContext &exe_ctx)
Definition Target.cpp:4166
lldb::TargetSP & GetTarget()
Definition Target.h:1594
void SetRunAtInitialStop(bool at_initial_stop)
Definition Target.h:1627
lldb::SymbolContextSpecifierSP m_specifier_sp
Definition Target.h:1645
virtual void GetSubclassDescription(Stream &s, lldb::DescriptionLevel level) const =0
void GetDescription(Stream &s, lldb::DescriptionLevel level) const
Definition Target.cpp:4182
void SetAutoContinue(bool auto_continue)
Definition Target.h:1621
const ModuleList & GetModuleList() const
Definition Target.h:646
void Dump(Stream *s) const override
Definition Target.cpp:5913
static llvm::StringRef GetFlavorString()
Definition Target.cpp:5909
static lldb::TargetSP GetCreatedTargetFromEvent(const Event *event_ptr)
Definition Target.cpp:5942
static ModuleList GetModuleListFromEvent(const Event *event_ptr)
Definition Target.cpp:5951
static const TargetEventData * GetEventDataFromEvent(const Event *event_ptr)
Definition Target.cpp:5923
llvm::StringRef GetFlavor() const override
Definition Target.h:624
const lldb::TargetSP & GetTarget() const
Definition Target.h:640
TargetEventData(const lldb::TargetSP &target_sp)
Definition Target.cpp:5895
TargetEventData(const TargetEventData &)=delete
const lldb::TargetSP & GetCreatedTarget() const
Definition Target.h:642
const TargetEventData & operator=(const TargetEventData &)=delete
static lldb::TargetSP GetTargetFromEvent(const Event *event_ptr)
Definition Target.cpp:5933
void ModulesDidLoad(ModuleList &module_list)
This call may preload module symbols, and may do so in parallel depending on the following target set...
Definition Target.cpp:1909
void DescribeBreakpointOverrides(Stream &stream, std::vector< lldb::user_id_t > &idxs)
Describe the breakpoint overrides.
Definition Target.cpp:974
lldb::ThreadSP CalculateThread() override
Definition Target.cpp:2650
llvm::Expected< uint32_t > AddScriptedFrameProviderDescriptor(const ScriptedFrameProviderDescriptor &descriptor)
Add or update a scripted frame provider descriptor for this target.
Definition Target.cpp:3848
StopHookCollection m_stop_hooks
Definition Target.h:2126
Module * GetExecutableModulePointer()
Definition Target.cpp:1609
void Dump(Stream *s, lldb::DescriptionLevel description_level)
Dump a description of this object to a Stream.
Definition Target.cpp:258
void DisableAllBreakpoints(bool internal_also=false)
Definition Target.cpp:1141
bool RemoveHookByID(lldb::user_id_t uid)
Definition Target.cpp:4744
lldb::WatchpointSP CreateWatchpoint(lldb::addr_t addr, size_t size, const CompilerType *type, uint32_t kind, Status &error)
Definition Target.cpp:1023
void ApplyNameToBreakpoints(BreakpointName &bp_name)
Definition Target.cpp:931
lldb::user_id_t m_hook_next_id
Definition Target.h:2137
lldb::TraceSP GetTrace()
Get the Trace object containing processor trace information of this target.
Definition Target.cpp:3723
PathMappingList & GetImageSearchPathList()
Definition Target.cpp:2659
void FinalizeFileActions(ProcessLaunchInfo &info)
Definition Target.cpp:3930
lldb::addr_t GetCallableLoadAddress(lldb::addr_t load_addr, AddressClass addr_class=AddressClass::eInvalid) const
Get load_addr as a callable code load address for this target.
Definition Target.cpp:3058
lldb::addr_t GetOpcodeLoadAddress(lldb::addr_t load_addr, AddressClass addr_class=AddressClass::eInvalid) const
Get load_addr as an opcode for this target.
Definition Target.cpp:3066
ModuleList & GetImages()
Definition Target.h:1243
lldb::BreakpointSP CreateScriptedBreakpoint(const llvm::StringRef class_name, const FileSpecList *containingModules, const FileSpecList *containingSourceFiles, bool internal, bool request_hardware, StructuredData::ObjectSP extra_args_sp, Status *creation_error=nullptr)
Definition Target.cpp:776
static Target * GetTargetFromContexts(const ExecutionContext *exe_ctx_ptr, const SymbolContext *sc_ptr)
Definition Target.cpp:2893
lldb::BreakpointResolverSP CheckBreakpointOverrides(lldb::BreakpointResolverSP original_sp)
Definition Target.h:1060
lldb::addr_t GetBreakableLoadAddress(lldb::addr_t addr)
Definition Target.cpp:3073
void ClearDummySignals(Args &signal_names)
Clear the dummy signals in signal_names from the target, or all signals if signal_names is empty.
Definition Target.cpp:4090
bool SetSuppresStopHooks(bool suppress)
Definition Target.h:1949
static void ImageSearchPathsChanged(const PathMappingList &path_list, void *baton)
Definition Target.cpp:2663
llvm::Expected< lldb_private::Address > GetEntryPointAddress()
This method will return the address of the starting function for this binary, e.g.
Definition Target.cpp:3024
bool IgnoreWatchpointByID(lldb::watch_id_t watch_id, uint32_t ignore_count)
Definition Target.cpp:1577
lldb::BreakpointSP CreateFuncRegexBreakpoint(const FileSpecList *containingModules, const FileSpecList *containingSourceFiles, RegularExpression func_regexp, lldb::LanguageType requested_language, LazyBool skip_prologue, bool internal, bool request_hardware)
Definition Target.cpp:742
size_t GetNumHooks() const
Definition Target.h:1929
lldb::BreakpointSP GetBreakpointByID(lldb::break_id_t break_id)
Definition Target.cpp:437
std::shared_ptr< StopHook > StopHookSP
Definition Target.h:1739
llvm::StringRef GetBroadcasterClass() const override
This needs to be filled in if you are going to register the broadcaster with the broadcaster manager ...
Definition Target.h:600
void SymbolsDidLoad(ModuleList &module_list)
Definition Target.cpp:1937
bool ClearAllWatchpointHistoricValues()
Definition Target.cpp:1491
const std::vector< StopHookSP > GetStopHooks(bool internal=false) const
Definition Target.cpp:3186
void SetTrace(const lldb::TraceSP &trace_sp)
Set the Trace object containing processor trace information of this target.
Definition Target.cpp:3721
BreakpointList & GetBreakpointList(bool internal=false)
Definition Target.cpp:423
uint32_t m_next_frame_provider_id
Definition Target.h:2118
CompilerType GetRegisterType(const std::string &name, const lldb_private::RegisterFlags &flags, uint32_t byte_size)
Definition Target.cpp:2699
BreakpointNameList m_breakpoint_names
Definition Target.h:2092
lldb_private::SummaryStatisticsCache & GetSummaryStatisticsCache()
Definition Target.cpp:3538
const llvm::MapVector< uint32_t, ScriptedFrameProviderDescriptor > & GetScriptedFrameProviderDescriptors() const
Get all scripted frame provider descriptors for this target.
Definition Target.cpp:3909
lldb::addr_t GetSectionLoadAddress(const lldb::SectionSP &section_sp)
Definition Target.cpp:5980
llvm::StringRef GetABIName() const
Returns the name of the target's ABI plugin.
Definition Target.cpp:412
SourceManager & GetSourceManager()
Definition Target.cpp:3110
lldb::SearchFilterSP GetSearchFilterForModuleList(const FileSpecList *containingModuleList)
Definition Target.cpp:705
StopHookSP GetStopHookByID(lldb::user_id_t uid)
Definition Target.cpp:3152
llvm::StringMap< DummySignalValues > m_dummy_signals
These are used to set the signal state when you don't have a process and more usefully in the Dummy t...
Definition Target.h:2153
lldb::user_id_t AddBreakpointResolverOverride(BreakpointResolverOverrideUP override_up)
Add a breakpoint override resolver. This version can't fail.
Definition Target.h:1039
lldb::ProcessSP m_process_sp
Definition Target.h:2106
Debugger & GetDebugger() const
Definition Target.h:1324
lldb::SearchFilterSP m_search_filter_sp
Definition Target.h:2107
PersistentExpressionState * GetPersistentExpressionStateForLanguage(lldb::LanguageType language)
Definition Target.cpp:2743
void UpdateSignalsFromDummy(lldb::UnixSignalsSP signals_sp, lldb::StreamSP warning_stream_sp)
Updates the signals in signals_sp using the stored dummy signals.
Definition Target.cpp:4078
bool m_is_dummy_target
Used to not run stop hooks for expressions.
Definition Target.h:2133
static bool UpdateSignalFromDummy(lldb::UnixSignalsSP signals_sp, const DummySignalElement &element)
Definition Target.cpp:4036
PathMappingList m_image_search_paths
Definition Target.h:2108
bool ModuleIsExcludedForUnconstrainedSearches(const FileSpec &module_spec)
Return whether this FileSpec corresponds to a module that should be considered for general searches.
Definition Target.cpp:1995
lldb::StackFrameSP CalculateStackFrame() override
Definition Target.cpp:2652
SectionLoadList & GetSectionLoadList()
Definition Target.h:2210
lldb::addr_t GetPersistentSymbol(ConstString name)
Definition Target.cpp:3004
void PrimeFromDummyTarget(Target &target)
Definition Target.cpp:225
bool RemoveScriptedFrameProviderDescriptor(uint32_t id)
Remove a scripted frame provider descriptor by id.
Definition Target.cpp:3884
lldb::RegisterTypeBuilderSP m_register_type_builder_sp
Definition Target.h:2155
static void SettingsTerminate()
Definition Target.cpp:2855
bool EnableWatchpointByID(lldb::watch_id_t watch_id)
Definition Target.cpp:1542
HookSP CreateHook(Hook::HookKind kind)
Definition Target.cpp:4722
bool ResolveFileAddress(lldb::addr_t load_addr, Address &so_addr)
Definition Target.cpp:3454
bool ClearAllWatchpointHitCounts()
Definition Target.cpp:1477
size_t ReadMemoryFromFileCache(const Address &addr, void *dst, size_t dst_len, Status &error)
Definition Target.cpp:2027
void ClearAllLoadedSections()
Definition Target.cpp:3530
std::vector< lldb::TypeSystemSP > GetScratchTypeSystems(bool create_on_demand=true)
Definition Target.cpp:2709
size_t ReadScalarIntegerFromMemory(const Address &addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Status &error, bool force_live_memory=false)
Definition Target.cpp:2326
void AddNameToBreakpoint(BreakpointID &id, llvm::StringRef name, Status &error)
Definition Target.cpp:853
void DumpSectionLoadList(Stream &s)
Definition Target.cpp:5986
void DeleteCurrentProcess()
Definition Target.cpp:294
BreakpointList m_internal_breakpoint_list
Definition Target.h:2089
int64_t ReadSignedIntegerFromMemory(const Address &addr, size_t integer_byte_size, int64_t fail_value, Status &error, bool force_live_memory=false)
Definition Target.cpp:2357
void DisableAllowedBreakpoints()
Definition Target.cpp:1151
bool SetHookEnabledStateByID(lldb::user_id_t uid, bool enabled)
Definition Target.cpp:4766
bool LoadScriptingResources(std::list< Status > &errors, bool continue_on_error=true)
Definition Target.h:1218
bool SetSectionUnloaded(const lldb::SectionSP &section_sp)
Definition Target.cpp:3508
lldb::TargetSP CalculateTarget() override
Definition Target.cpp:2646
const lldb::ProcessSP & GetProcessSP() const
Definition Target.cpp:328
void ClearModules(bool delete_locations)
Definition Target.cpp:1613
bool RemoveBreakpointByID(lldb::break_id_t break_id)
Definition Target.cpp:1175
llvm::MapVector< uint32_t, ScriptedFrameProviderDescriptor > m_frame_provider_descriptors
Map of scripted frame provider descriptors for this target.
Definition Target.h:2116
lldb::ModuleSP GetOrCreateModule(const ModuleSpec &module_spec, bool notify, Status *error_ptr=nullptr)
Find a binary on the system and return its Module, or return an existing Module that is already in th...
Definition Target.cpp:2409
static bool ResetSignalFromDummy(lldb::UnixSignalsSP signals_sp, const DummySignalElement &element)
Definition Target.cpp:4063
Architecture * GetArchitecturePlugin() const
Definition Target.h:1322
llvm::json::Value ReportStatistics(const lldb_private::StatisticsOptions &options)
Get metrics associated with this target in JSON format.
Definition Target.cpp:5972
friend class TargetList
Definition Target.h:582
FunctionCaller * GetFunctionCallerForLanguage(lldb::LanguageType language, const CompilerType &return_type, const Address &function_address, const ValueList &arg_value_list, const char *name, Status &error)
Definition Target.cpp:2796
TargetStats & GetStatistics()
Definition Target.h:2180
void EnableAllBreakpoints(bool internal_also=false)
Definition Target.cpp:1158
Status Launch(ProcessLaunchInfo &launch_info, Stream *stream)
Definition Target.cpp:3553
bool DisableBreakpointByID(lldb::break_id_t break_id)
Definition Target.cpp:1195
lldb::BreakpointSP CreateBreakpointAtUserEntry(Status &error)
Definition Target.cpp:449
BreakpointName * FindBreakpointName(ConstString name, bool can_create, Status &error)
Definition Target.cpp:885
std::map< lldb::user_id_t, StopHookSP > StopHookCollection
Definition Target.h:2125
llvm::Expected< lldb::TraceSP > CreateTrace()
Create a Trace object for the current target using the using the default supported tracing technology...
Definition Target.cpp:3725
lldb::TraceSP m_trace_sp
An optional lldb_private::Trace object containing processor trace information of this target.
Definition Target.h:2147
lldb::user_id_t GetGloballyUniqueID() const
Get the globally unique ID for this target.
Definition Target.h:682
bool RemoveAllWatchpoints(bool end_to_end=true)
Definition Target.cpp:1395
bool ReadPointerFromMemory(const Address &addr, Status &error, Address &pointer_addr, bool force_live_memory=false)
Definition Target.cpp:2379
void UndoCreateStopHook(lldb::user_id_t uid)
If you tried to create a stop hook, and that failed, call this to remove the stop hook,...
Definition Target.cpp:3138
WatchpointList m_watchpoint_list
Definition Target.h:2101
BreakpointList m_breakpoint_list
Definition Target.h:2088
lldb::SourceManagerUP m_source_manager_up
Definition Target.h:2123
lldb::user_id_t m_override_id
This is the ID that will be handed out for the next added breakpoint override resolver for this targe...
Definition Target.h:2098
bool RemoveWatchpointByID(lldb::watch_id_t watch_id)
Definition Target.cpp:1561
bool ResolveLoadAddress(lldb::addr_t load_addr, Address &so_addr, uint32_t stop_id=SectionLoadHistory::eStopIDNow, bool allow_section_end=false)
Definition Target.cpp:3448
size_t ReadStringFromMemory(const Address &addr, char *dst, size_t max_bytes, Status &error, size_t type_width, bool force_live_memory=true)
Read a NULL terminated string from memory.
Definition Target.cpp:2277
HookSP GetHookByID(lldb::user_id_t uid)
Definition Target.cpp:4751
void DeleteBreakpointName(ConstString name)
Definition Target.cpp:907
void NotifyWillClearList(const ModuleList &module_list) override
Definition Target.cpp:1871
bool SetArchitecture(const ArchSpec &arch_spec, bool set_platform=false, bool merge=true)
Set the architecture for this target.
Definition Target.cpp:1755
void ClearBreakpointResolverOverrides()
Definition Target.h:1057
bool RemoveBreakpointResolverOverride(lldb::user_id_t override_id)
Definition Target.h:1052
void NotifyModuleAdded(const ModuleList &module_list, const lldb::ModuleSP &module_sp) override
Implementing of ModuleList::Notifier.
Definition Target.cpp:1873
llvm::Expected< lldb::TypeSystemSP > GetScratchTypeSystemForLanguage(lldb::LanguageType language, bool create_on_demand=true)
Definition Target.cpp:2672
void ConfigureBreakpointName(BreakpointName &bp_name, const BreakpointOptions &options, const BreakpointName::Permissions &permissions)
Definition Target.cpp:923
lldb_private::SummaryStatisticsSP GetSummaryStatisticsSPForProviderName(lldb_private::TypeSummaryImpl &summary_provider)
Definition Target.cpp:3532
lldb::SearchFilterSP GetSearchFilterForModuleAndCUList(const FileSpecList *containingModules, const FileSpecList *containingSourceFiles)
Definition Target.cpp:722
lldb::ModuleSP GetExecutableModule()
Gets the module for the main executable.
Definition Target.cpp:1593
bool SetStopHookActiveStateByID(lldb::user_id_t uid, bool active_state)
Definition Target.cpp:3162
const lldb::ProcessSP & CreateProcess(lldb::ListenerSP listener_sp, llvm::StringRef plugin_name, const FileSpec *crash_file, bool can_connect)
Definition Target.cpp:316
void SetAllStopHooksActiveState(bool active_state)
Definition Target.cpp:3173
std::vector< StopHookSP > m_internal_stop_hooks
Definition Target.h:2128
lldb::ExpressionVariableSP GetPersistentVariable(ConstString name)
Definition Target.cpp:2985
void NotifyModulesRemoved(lldb_private::ModuleList &module_list) override
Definition Target.cpp:1905
StopHookSP CreateStopHook(StopHook::StopHookKind kind, bool internal=false)
Add an empty stop hook to the Target's stop hook list, and returns a shared pointer to the new hook.
Definition Target.cpp:3116
size_t ReadCStringFromMemory(const Address &addr, std::string &out_str, Status &error, bool force_live_memory=false)
Definition Target.cpp:2187
void SetAllHooksEnabledState(bool enabled)
Definition Target.cpp:4774
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:2074
std::recursive_mutex m_frame_provider_descriptors_mutex
Definition Target.h:2117
lldb::user_id_t m_target_unique_id
The globally unique ID assigned to this target.
Definition Target.h:2139
void ModulesDidUnload(ModuleList &module_list, bool delete_locations)
Definition Target.cpp:1953
void CalculateExecutionContext(ExecutionContext &exe_ctx) override
Reconstruct the object's execution context into sc.
Definition Target.cpp:2654
llvm::Expected< lldb::DisassemblerSP > ReadInstructions(const Address &start_addr, uint32_t count, const char *flavor_string=nullptr)
Definition Target.cpp:3079
llvm::Expected< lldb::TraceSP > GetTraceOrCreate()
If a Trace object is present, this returns it, otherwise a new Trace is created with Trace::CreateTra...
Definition Target.cpp:3750
void NotifyModuleUpdated(const ModuleList &module_list, const lldb::ModuleSP &old_module_sp, const lldb::ModuleSP &new_module_sp) override
Definition Target.cpp:1893
SummaryStatisticsCache m_summary_statistics_cache
Definition Target.h:2086
Target(const Target &)=delete
void RegisterInternalStopHooks()
Status SerializeBreakpointsToFile(const FileSpec &file, const BreakpointIDList &bp_ids, bool append)
Definition Target.cpp:1236
void DidExec()
Called as the last function in Process::DidExec().
Definition Target.cpp:1620
void SaveScriptedLaunchInfo(lldb_private::ProcessInfo &process_info)
Definition Target.cpp:3542
bool GetSuppressStopHooks()
Definition Target.h:1955
std::string m_label
Definition Target.h:2083
lldb::user_id_t m_stop_hook_next_id
Definition Target.h:2127
static FileSpecList GetDefaultExecutableSearchPaths()
Definition Target.cpp:2857
lldb::BreakpointSP CreateExceptionBreakpoint(enum lldb::LanguageType language, bool catch_bp, bool throw_bp, bool internal, Args *additional_args=nullptr, Status *additional_args_error=nullptr)
Definition Target.cpp:759
void NotifyBreakpointChanged(Breakpoint &bp, lldb::BreakpointEventType event_kind)
Sends a breakpoint notification event.
Definition Target.cpp:5990
lldb::SearchFilterSP GetSearchFilterForModule(const FileSpec *containingModule)
Definition Target.cpp:687
llvm::StringMapEntry< DummySignalValues > DummySignalElement
Definition Target.h:2017
std::recursive_mutex & GetAPIMutex()
Definition Target.cpp:5959
static llvm::StringRef GetStaticBroadcasterClass()
Definition Target.cpp:175
static FileSpecList GetDefaultDebugFileSearchPaths()
Definition Target.cpp:2861
void EnableAllowedBreakpoints()
Definition Target.cpp:1168
virtual size_t ReadMemory(const Address &addr, void *dst, size_t dst_len, Status &error, bool force_live_memory=false, lldb::addr_t *load_addr_ptr=nullptr, bool *did_read_live_memory=nullptr)
Definition Target.cpp:2061
llvm::Error SetLabel(llvm::StringRef label)
Set a label for a target.
Definition Target.cpp:2876
uint32_t m_latest_stop_hook_id
Definition Target.h:2129
void RunModuleHooks(bool is_load)
Definition Target.cpp:4779
std::map< lldb::user_id_t, BreakpointResolverOverrideUP > m_breakpoint_overrides
Definition Target.h:2095
StackFrameRecognizerManager & GetFrameRecognizerManager()
Definition Target.h:1993
void RemoveAllowedBreakpoints()
Definition Target.cpp:1120
bool DisableAllWatchpoints(bool end_to_end=true)
Definition Target.cpp:1424
bool RunStopHooks(bool at_initial_stop=false)
Definition Target.cpp:3197
void ClearSectionLoadList()
Definition Target.cpp:5984
const Target & operator=(const Target &)=delete
lldb::addr_t GetReasonableReadSize(const Address &addr)
Return a recommended size for memory reads at addr, optimizing for cache usage.
Definition Target.cpp:2264
lldb::PlatformSP m_platform_sp
The platform for this target.
Definition Target.h:2073
void UndoCreateHook(lldb::user_id_t uid)
Removes the most recently created hook.
Definition Target.cpp:4737
llvm::Expected< std::unique_ptr< UtilityFunction > > CreateUtilityFunction(std::string expression, std::string name, lldb::LanguageType language, ExecutionContext &exe_ctx)
Creates and installs a UtilityFunction for the given language.
Definition Target.cpp:2826
FileSpecList GetSafeAutoLoadPaths() const
Get the list of paths that LLDB will consider automatically loading scripting resources from.
Definition Target.cpp:6006
static TargetProperties & GetGlobalProperties()
Definition Target.cpp:3412
Status Install(ProcessLaunchInfo *launch_info)
Definition Target.cpp:3420
HookSP GetHookAtIndex(size_t index)
Definition Target.cpp:4758
lldb::PlatformSP GetPlatform()
Definition Target.h:1969
void NotifyModuleRemoved(const ModuleList &module_list, const lldb::ModuleSP &module_sp) override
Definition Target.cpp:1883
lldb::BreakpointSP CreateAddressInModuleBreakpoint(lldb::addr_t file_addr, bool internal, const FileSpec &file_spec, bool request_hardware)
Definition Target.cpp:593
lldb::BreakpointSP CreateBreakpoint(const FileSpecList *containingModules, const FileSpec &file, uint32_t line_no, uint32_t column, lldb::addr_t offset, LazyBool check_inlines, LazyBool skip_prologue, bool internal, bool request_hardware, LazyBool move_to_nearest_code)
Definition Target.cpp:504
void RemoveAllBreakpoints(bool internal_also=false)
Definition Target.cpp:1129
lldb::BreakpointSP CreateSourceRegexBreakpoint(const FileSpecList *containingModules, const FileSpecList *source_file_list, const std::unordered_set< std::string > &function_names, RegularExpression source_regex, bool internal, bool request_hardware, LazyBool move_to_nearest_code)
Definition Target.cpp:487
lldb::BreakpointSP CreateBreakpoint(const FileSpecList *containingModules, const FileSpecList *containingSourceFiles, const char *func_name, lldb::FunctionNameType func_name_type_mask, lldb::LanguageType language, lldb::addr_t offset, bool offset_is_insn_count, LazyBool skip_prologue, bool internal, bool request_hardware)
static ArchSpec GetDefaultArchitecture()
Definition Target.cpp:2865
void ResetBreakpointHitCounts()
Resets the hit count of all breakpoints.
Definition Target.cpp:1232
std::unique_ptr< BreakpointResolverOverride > BreakpointResolverOverrideUP
Definition Target.h:1015
const ModuleList & GetImages() const
Get accessor for the images for this process.
Definition Target.h:1241
const ArchSpec & GetArchitecture() const
Definition Target.h:1283
WatchpointList & GetWatchpointList()
Definition Target.h:955
@ eBroadcastBitWatchpointChanged
Definition Target.h:590
@ eBroadcastBitBreakpointChanged
Definition Target.h:587
@ eBroadcastBitNewTargetCreated
Definition Target.h:593
unsigned m_next_persistent_variable_index
Definition Target.h:2138
bool EnableBreakpointByID(lldb::break_id_t break_id)
Definition Target.cpp:1213
uint64_t ReadUnsignedIntegerFromMemory(const Address &addr, size_t integer_byte_size, uint64_t fail_value, Status &error, bool force_live_memory=false)
Definition Target.cpp:2368
void InvalidateThreadFrameProviders()
Invalidate all potentially cached frame providers for all threads and trigger a stack changed event f...
Definition Target.cpp:3915
TargetStats m_stats
Definition Target.h:2163
bool IgnoreAllWatchpoints(uint32_t ignore_count)
Definition Target.cpp:1506
void AddBreakpoint(lldb::BreakpointSP breakpoint_sp, bool internal)
Definition Target.cpp:830
std::string m_target_session_name
The target session name for this target, used to name debugging sessions in DAP.
Definition Target.h:2142
TypeSystemMap m_scratch_type_system_map
Definition Target.h:2109
void AddBreakpointName(std::unique_ptr< BreakpointName > bp_name)
Definition Target.cpp:880
void SetTargetSessionName(llvm::StringRef target_session_name)
Set the target session name for this target.
Definition Target.h:715
SectionLoadHistory m_section_load_history
Definition Target.h:2087
lldb::BreakpointSP CreateBreakpoint(const FileSpecList *containingModules, const FileSpecList *containingSourceFiles, const std::vector< std::string > &func_names, lldb::FunctionNameType func_name_type_mask, lldb::LanguageType language, lldb::addr_t m_offset, LazyBool skip_prologue, bool internal, bool request_hardware)
void GetBreakpointNames(std::vector< std::string > &names)
Definition Target.cpp:946
bool IsDummyTarget() const
Definition Target.h:671
Target(Debugger &debugger, const ArchSpec &target_arch, const lldb::PlatformSP &platform_sp, bool is_dummy_target)
Construct with optional file and arch.
Definition Target.cpp:180
size_t UnloadModuleSections(const lldb::ModuleSP &module_sp)
Definition Target.cpp:3489
llvm::StringRef GetTargetSessionName()
Get the target session name for this target.
Definition Target.h:703
const std::string & GetLabel() const
Definition Target.h:684
std::map< lldb::user_id_t, HookSP > HookCollection
Definition Target.h:2135
bool m_valid
This records the last natural stop at which we ran a stop-hook.
Definition Target.h:2131
bool DisableWatchpointByID(lldb::watch_id_t watch_id)
Definition Target.cpp:1523
void AddDummySignal(llvm::StringRef name, LazyBool pass, LazyBool print, LazyBool stop)
Add a signal to the Target's list of stored signals/actions.
Definition Target.cpp:4021
void ClearScriptedFrameProviderDescriptors()
Clear all scripted frame provider descriptors for this target.
Definition Target.cpp:3897
std::map< ConstString, std::unique_ptr< BreakpointName > > BreakpointNameList
Definition Target.h:2090
lldb::WatchpointSP m_last_created_watchpoint
Definition Target.h:2102
Status CreateBreakpointsFromFile(const FileSpec &file, BreakpointIDList &new_bps)
Definition Target.cpp:1328
Debugger & m_debugger
Definition Target.h:2072
void SetREPL(lldb::LanguageType language, lldb::REPLSP repl_sp)
Definition Target.cpp:381
lldb::BreakpointSP CreateBreakpoint(const FileSpecList *containingModules, const FileSpecList *containingSourceFiles, const char *func_names[], size_t num_names, lldb::FunctionNameType func_name_type_mask, lldb::LanguageType language, lldb::addr_t offset, LazyBool skip_prologue, bool internal, bool request_hardware)
void SetExecutableModule(lldb::ModuleSP &module_sp, LoadDependentFiles load_dependent_files=eLoadDependentsDefault)
Set the main executable module.
Definition Target.cpp:1626
lldb::StackFrameRecognizerManagerUP m_frame_recognizer_manager_up
Stores the frame recognizers of this target.
Definition Target.h:2149
HookCollection m_hooks
Definition Target.h:2136
lldb::REPLSP GetREPL(Status &err, lldb::LanguageType language, const char *repl_options, bool can_create)
Definition Target.cpp:330
std::shared_ptr< Hook > HookSP
Definition Target.h:1910
UserExpression * GetUserExpressionForLanguage(llvm::StringRef expr, llvm::StringRef prefix, SourceLanguage language, Expression::ResultType desired_type, const EvaluateExpressionOptions &options, ValueObject *ctx_obj, Status &error)
Definition Target.cpp:2763
ModuleList m_images
The list of images for this process (shared libraries and anything dynamically loaded).
Definition Target.h:2084
lldb::ProcessSP CalculateProcess() override
Definition Target.cpp:2648
void PrintDummySignals(Stream &strm, Args &signals)
Print all the signals set in this target.
Definition Target.cpp:4115
void SetPlatform(const lldb::PlatformSP &platform_sp)
Definition Target.h:1971
bool SetSectionLoadAddress(const lldb::SectionSP &section, lldb::addr_t load_addr, bool warn_multiple=false)
Definition Target.cpp:3459
Status Attach(ProcessAttachInfo &attach_info, Stream *stream)
Definition Target.cpp:3756
std::map< lldb::LanguageType, lldb::REPLSP > REPLMap
Definition Target.h:2120
static void SetDefaultArchitecture(const ArchSpec &arch)
Definition Target.cpp:2869
lldb::BreakpointSP m_last_created_breakpoint
Definition Target.h:2100
lldb::WatchpointSP GetLastCreatedWatchpoint()
Definition Target.h:951
void RemoveNameFromBreakpoint(lldb::BreakpointSP &bp_sp, ConstString name)
Definition Target.cpp:918
bool RemoveStopHookByID(lldb::user_id_t uid)
Definition Target.cpp:3145
friend class Debugger
Definition Target.h:583
lldb::BreakpointSP GetLastCreatedBreakpoint()
Definition Target.h:843
static void SettingsInitialize()
Definition Target.cpp:2853
~Target() override
Definition Target.cpp:219
bool EnableAllWatchpoints(bool end_to_end=true)
Definition Target.cpp:1451
std::recursive_mutex m_private_mutex
When the private state thread calls SB API's - usually because it is running OS plugin or Python Thre...
Definition Target.h:2081
lldb::ExpressionResults EvaluateExpression(llvm::StringRef expression, ExecutionContextScope *exe_scope, lldb::ValueObjectSP &result_valobj_sp, const EvaluateExpressionOptions &options=EvaluateExpressionOptions(), std::string *fixed_expression=nullptr, ValueObject *ctx_obj=nullptr)
Definition Target.cpp:2907
bool MergeArchitecture(const ArchSpec &arch_spec)
Definition Target.cpp:1846
Encapsulates a one-time expression for use in lldb.
This class is used by Watchpoint to manage a list of watchpoints,.
#define LLDB_INVALID_GLOBALLY_UNIQUE_TARGET_ID
A class that represents a running process on the host machine.
std::shared_ptr< SummaryStatistics > SummaryStatisticsSP
Definition Statistics.h:33
LoadScriptFromSymFile
Definition Target.h:59
@ eLoadScriptFromSymFileTrue
Definition Target.h:60
@ eLoadScriptFromSymFileTrusted
Definition Target.h:63
@ eLoadScriptFromSymFileFalse
Definition Target.h:61
@ eLoadScriptFromSymFileWarn
Definition Target.h:62
ExecutionPolicy
Expression execution policies.
DynamicClassInfoHelper
Definition Target.h:78
@ eDynamicClassInfoHelperCopyRealizedClassList
Definition Target.h:81
@ eDynamicClassInfoHelperGetRealizedClassList
Definition Target.h:82
@ eDynamicClassInfoHelperAuto
Definition Target.h:79
@ eDynamicClassInfoHelperRealizedClassesStruct
Definition Target.h:80
OptionEnumValues GetDynamicValueTypes()
Definition Target.cpp:4827
@ eImportStdModuleFalse
Definition Target.h:73
@ eImportStdModuleFallback
Definition Target.h:74
@ eImportStdModuleTrue
Definition Target.h:75
LoadCWDlldbinitFile
Definition Target.h:66
@ eLoadCWDlldbinitTrue
Definition Target.h:67
@ eLoadCWDlldbinitFalse
Definition Target.h:68
@ eLoadCWDlldbinitWarn
Definition Target.h:69
llvm::ArrayRef< OptionEnumValueElement > OptionEnumValues
@ eInlineBreakpointsNever
Definition Target.h:54
@ eInlineBreakpointsAlways
Definition Target.h:56
@ eInlineBreakpointsHeaders
Definition Target.h:55
ExpressionEvaluationPhase
Expression Evaluation Stages.
std::shared_ptr< lldb_private::Trace > TraceSP
std::shared_ptr< lldb_private::ScriptedHookInterface > ScriptedHookInterfaceSP
std::shared_ptr< lldb_private::ScriptedStopHookInterface > ScriptedStopHookInterfaceSP
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
std::shared_ptr< lldb_private::SearchFilter > SearchFilterSP
std::shared_ptr< lldb_private::BreakpointResolver > BreakpointResolverSP
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
std::unique_ptr< lldb_private::StackFrameRecognizerManager > StackFrameRecognizerManagerUP
std::shared_ptr< lldb_private::Thread > ThreadSP
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
std::shared_ptr< lldb_private::ExpressionVariable > ExpressionVariableSP
std::shared_ptr< lldb_private::UnixSignals > UnixSignalsSP
std::shared_ptr< lldb_private::Platform > PlatformSP
std::shared_ptr< lldb_private::RegisterTypeBuilder > RegisterTypeBuilderSP
LanguageType
Programming language type.
std::shared_ptr< lldb_private::Stream > StreamSP
std::shared_ptr< lldb_private::Breakpoint > BreakpointSP
ExpressionResults
The results of expression evaluation.
int32_t break_id_t
Definition lldb-types.h:87
std::unique_ptr< lldb_private::SourceManager > SourceManagerUP
std::shared_ptr< lldb_private::Process > ProcessSP
std::shared_ptr< lldb_private::SymbolContextSpecifier > SymbolContextSpecifierSP
std::shared_ptr< lldb_private::Watchpoint > WatchpointSP
std::shared_ptr< lldb_private::Listener > ListenerSP
int32_t watch_id_t
Definition lldb-types.h:88
uint64_t user_id_t
Definition lldb-types.h:82
std::shared_ptr< lldb_private::Section > SectionSP
uint64_t addr_t
Definition lldb-types.h:80
std::shared_ptr< lldb_private::Target > TargetSP
@ eDynamicCanRunTarget
bool(* ExpressionCancelCallback)(lldb::ExpressionEvaluationPhase phase, void *baton)
Definition lldb-types.h:75
std::shared_ptr< lldb_private::Module > ModuleSP
std::shared_ptr< lldb_private::EventData > EventDataSP
std::shared_ptr< lldb_private::REPL > REPLSP
This struct contains the metadata needed to instantiate a frame provider and optional filters to cont...
A type-erased pair of llvm::dwarf::SourceLanguageName and version.
DummySignalValues(LazyBool pass, LazyBool notify, LazyBool stop)
Definition Target.h:2013
UserID(lldb::user_id_t uid=LLDB_INVALID_UID)
Construct with optional user ID.
Definition UserID.h:33