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"
41#include "lldb/lldb-public.h"
42#include "llvm/ADT/StringRef.h"
43
44namespace lldb_private {
45
47
53
59
65
71
78
83
85public:
86 TargetProperties(Target *target);
87
89
91
92 void SetDefaultArchitecture(const ArchSpec &arch);
93
94 bool GetMoveToNearestCode() const;
95
97
99
100 bool GetPreloadSymbols() const;
101
102 void SetPreloadSymbols(bool b);
103
104 bool GetDisableASLR() const;
105
106 void SetDisableASLR(bool b);
107
108 bool GetInheritTCC() const;
109
110 void SetInheritTCC(bool b);
111
112 bool GetDetachOnError() const;
113
114 void SetDetachOnError(bool b);
115
116 bool GetDisableSTDIO() const;
117
118 void SetDisableSTDIO(bool b);
119
120 llvm::StringRef GetLaunchWorkingDirectory() const;
121
122 bool GetParallelModuleLoad() const;
123
124 const char *GetDisassemblyFlavor() const;
125
126 const char *GetDisassemblyCPU() const;
127
128 const char *GetDisassemblyFeatures() const;
129
131
133
134 llvm::StringRef GetArg0() const;
135
136 void SetArg0(llvm::StringRef arg);
137
138 bool GetRunArguments(Args &args) const;
139
140 void SetRunArguments(const Args &args);
141
142 // Get the whole environment including the platform inherited environment and
143 // the target specific environment, excluding the unset environment variables.
145 // Get the platform inherited environment, excluding the unset environment
146 // variables.
148 // Get the target specific environment only, without the platform inherited
149 // environment.
151 // Set the target specific environment.
152 void SetEnvironment(Environment env);
153
154 bool GetSkipPrologue() const;
155
157
159
160 bool GetAutoSourceMapRelative() const;
161
163
165
167
169
171
173
175
176 bool GetEnableAutoApplyFixIts() const;
177
178 uint64_t GetNumberOfRetriesWithFixits() const;
179
180 bool GetEnableNotifyAboutFixIts() const;
181
183
184 bool GetEnableSyntheticValue() const;
185
187
188 uint32_t GetMaxZeroPaddingInFloatFormat() const;
189
191
192 /// Get the max depth value, augmented with a bool to indicate whether the
193 /// depth is the default.
194 ///
195 /// When the user has customized the max depth, the bool will be false.
196 ///
197 /// \returns the max depth, and true if the max depth is the system default,
198 /// otherwise false.
199 std::pair<uint32_t, bool> GetMaximumDepthOfChildrenToDisplay() const;
200
201 uint32_t GetMaximumSizeOfStringSummary() const;
202
203 uint32_t GetMaximumMemReadSize() const;
204
208
209 void SetStandardInputPath(llvm::StringRef path);
210 void SetStandardOutputPath(llvm::StringRef path);
211 void SetStandardErrorPath(llvm::StringRef path);
212
213 void SetStandardInputPath(const char *path) = delete;
214 void SetStandardOutputPath(const char *path) = delete;
215 void SetStandardErrorPath(const char *path) = delete;
216
218
220
221 llvm::StringRef GetExpressionPrefixContents();
222
223 uint64_t GetExprErrorLimit() const;
224
225 uint64_t GetExprAllocAddress() const;
226
227 uint64_t GetExprAllocSize() const;
228
229 uint64_t GetExprAllocAlign() const;
230
231 bool GetUseHexImmediates() const;
232
233 bool GetUseFastStepping() const;
234
236
238
240
242
244
245 bool GetUserSpecifiedTrapHandlerNames(Args &args) const;
246
247 void SetUserSpecifiedTrapHandlerNames(const Args &args);
248
250
252
254
256
258
259 void SetProcessLaunchInfo(const ProcessLaunchInfo &launch_info);
260
261 bool GetInjectLocalVariables(ExecutionContext *exe_ctx) const;
262
263 bool GetUseDIL(ExecutionContext *exe_ctx) const;
264
265 void SetUseDIL(ExecutionContext *exe_ctx, bool b);
266
268
270
271 bool GetAutoInstallMainExecutable() const;
272
274
275 void SetDebugUtilityExpression(bool debug);
276
277 bool GetDebugUtilityExpression() const;
278
279private:
280 std::optional<bool>
281 GetExperimentalPropertyValue(size_t prop_idx,
282 ExecutionContext *exe_ctx = nullptr) const;
283
284 // Callbacks for m_launch_info.
295
296 // Settings checker for target.jit-save-objects-dir:
297 void CheckJITObjectsDir();
298
300
301 // Member variables.
303 std::unique_ptr<TargetExperimentalProperties> m_experimental_properties_up;
305};
306
308public:
309// MSVC has a bug here that reports C4268: 'const' static/global data
310// initialized with compiler generated default constructor fills the object
311// with zeros. Confirmed that MSVC is *not* zero-initializing, it's just a
312// bogus warning.
313#if defined(_MSC_VER)
314#pragma warning(push)
315#pragma warning(disable : 4268)
316#endif
317 static constexpr std::chrono::milliseconds default_timeout{500};
318#if defined(_MSC_VER)
319#pragma warning(pop)
320#endif
321
324
326
328
332
334
335 void SetLanguage(lldb::LanguageType language_type) {
336 m_language = SourceLanguage(language_type);
337 }
338
340 m_preferred_lookup_contexts = std::move(contexts);
341 }
342
346
347 /// Set the language using a pair of language code and version as
348 /// defined by the DWARF 6 specification.
349 /// WARNING: These codes may change until DWARF 6 is finalized.
350 void SetLanguage(uint16_t name, uint32_t version) {
351 m_language = SourceLanguage(name, version);
352 }
353
354 bool DoesCoerceToId() const { return m_coerce_to_id; }
355
356 const char *GetPrefix() const {
357 return (m_prefix.empty() ? nullptr : m_prefix.c_str());
358 }
359
360 void SetPrefix(const char *prefix) {
361 if (prefix && prefix[0])
362 m_prefix = prefix;
363 else
364 m_prefix.clear();
365 }
366
367 void SetCoerceToId(bool coerce = true) { m_coerce_to_id = coerce; }
368
369 bool DoesUnwindOnError() const { return m_unwind_on_error; }
370
371 void SetUnwindOnError(bool unwind = false) { m_unwind_on_error = unwind; }
372
374
375 void SetIgnoreBreakpoints(bool ignore = false) {
376 m_ignore_breakpoints = ignore;
377 }
378
379 bool DoesKeepInMemory() const { return m_keep_in_memory; }
380
381 void SetKeepInMemory(bool keep = true) { m_keep_in_memory = keep; }
382
384
385 void
389
390 const Timeout<std::micro> &GetTimeout() const { return m_timeout; }
391
392 void SetTimeout(const Timeout<std::micro> &timeout) { m_timeout = timeout; }
393
397
399 m_one_thread_timeout = timeout;
400 }
401
402 bool GetTryAllThreads() const { return m_try_others; }
403
404 void SetTryAllThreads(bool try_others = true) { m_try_others = try_others; }
405
406 bool GetStopOthers() const { return m_stop_others; }
407
408 void SetStopOthers(bool stop_others = true) { m_stop_others = stop_others; }
409
410 bool GetDebug() const { return m_debug; }
411
412 void SetDebug(bool b) {
413 m_debug = b;
414 if (m_debug)
416 }
417
419
421
422 bool GetColorizeErrors() const { return m_ansi_color_errors; }
423
425
426 bool GetTrapExceptions() const { return m_trap_exceptions; }
427
429
430 bool GetREPLEnabled() const { return m_repl; }
431
432 void SetREPLEnabled(bool b) { m_repl = b; }
433
436 m_cancel_callback = callback;
437 }
438
440 return ((m_cancel_callback != nullptr)
442 : false);
443 }
444
445 // Allows the expression contents to be remapped to point to the specified
446 // file and line using #line directives.
447 void SetPoundLine(const char *path, uint32_t line) const {
448 if (path && path[0]) {
449 m_pound_line_file = path;
450 m_pound_line_line = line;
451 } else {
452 m_pound_line_file.clear();
454 }
455 }
456
457 const char *GetPoundLineFilePath() const {
458 return (m_pound_line_file.empty() ? nullptr : m_pound_line_file.c_str());
459 }
460
461 uint32_t GetPoundLineLine() const { return m_pound_line_line; }
462
464
468
470
472
473 void SetRetriesWithFixIts(uint64_t number_of_retries) {
474 m_retries_with_fixits = number_of_retries;
475 }
476
477 uint64_t GetRetriesWithFixIts() const { return m_retries_with_fixits; }
478
480
482
483private:
486 std::string m_prefix;
487 bool m_coerce_to_id = false;
488 bool m_unwind_on_error = true;
490 bool m_keep_in_memory = false;
491 bool m_try_others = true;
492 bool m_stop_others = true;
493 bool m_debug = false;
494 bool m_trap_exceptions = true;
495 bool m_repl = false;
501 /// True if the executed code should be treated as utility code that is only
502 /// used by LLDB internally.
504
509 void *m_cancel_callback_baton = nullptr;
510 // If m_pound_line_file is not empty and m_pound_line_line is non-zero, use
511 // #line %u "%s" before the expression content to remap where the source
512 // originates
513 mutable std::string m_pound_line_file;
514 mutable uint32_t m_pound_line_line = 0;
515
516 /// During expression evaluation, any SymbolContext in this list will be
517 /// used for symbol/function lookup before any other context (except for
518 /// the module corresponding to the current frame).
520};
521
522// Target
523class Target : public std::enable_shared_from_this<Target>,
524 public TargetProperties,
525 public Broadcaster,
527 public ModuleList::Notifier {
528public:
529 friend class TargetList;
530 friend class Debugger;
531
532 /// Broadcaster event bits definitions.
533 enum {
540 };
541
542 // These two functions fill out the Broadcaster interface:
543
544 static llvm::StringRef GetStaticBroadcasterClass();
545
546 llvm::StringRef GetBroadcasterClass() const override {
548 }
549
550 // This event data class is for use by the TargetList to broadcast new target
551 // notifications.
552 class TargetEventData : public EventData {
553 public:
554 TargetEventData(const lldb::TargetSP &target_sp);
555
556 TargetEventData(const lldb::TargetSP &target_sp,
557 const ModuleList &module_list);
558
560
561 static llvm::StringRef GetFlavorString();
562
563 llvm::StringRef GetFlavor() const override {
565 }
566
567 void Dump(Stream *s) const override;
568
569 static const TargetEventData *GetEventDataFromEvent(const Event *event_ptr);
570
571 static lldb::TargetSP GetTargetFromEvent(const Event *event_ptr);
572
573 static ModuleList GetModuleListFromEvent(const Event *event_ptr);
574
575 const lldb::TargetSP &GetTarget() const { return m_target_sp; }
576
577 const ModuleList &GetModuleList() const { return m_module_list; }
578
579 private:
582
584 const TargetEventData &operator=(const TargetEventData &) = delete;
585 };
586
587 ~Target() override;
588
589 static void SettingsInitialize();
590
591 static void SettingsTerminate();
592
594
596
598
599 static void SetDefaultArchitecture(const ArchSpec &arch);
600
601 bool IsDummyTarget() const { return m_is_dummy_target; }
602
603 /// Get the globally unique ID for this target.
604 ///
605 /// This ID is unique across all debugger instances and all targets,
606 /// within the same lldb process. The ID is assigned
607 /// during target construction and remains constant for the target's lifetime.
608 /// The first target created (typically the dummy target) gets ID 1.
609 ///
610 /// \return
611 /// The globally unique ID for this target.
613
614 const std::string &GetLabel() const { return m_label; }
615
616 /// Set a label for a target.
617 ///
618 /// The label cannot be used by another target or be only integral.
619 ///
620 /// \return
621 /// The label for this target or an error if the label didn't match the
622 /// requirements.
623 llvm::Error SetLabel(llvm::StringRef label);
624
625 /// Find a binary on the system and return its Module,
626 /// or return an existing Module that is already in the Target.
627 ///
628 /// Given a ModuleSpec, find a binary satisifying that specification,
629 /// or identify a matching Module already present in the Target,
630 /// and return a shared pointer to it.
631 ///
632 /// Note that this function previously also preloaded the module's symbols
633 /// depending on a setting. This function no longer does any module
634 /// preloading because that can potentially cause deadlocks when called in
635 /// parallel with this function.
636 ///
637 /// \param[in] module_spec
638 /// The criteria that must be matched for the binary being loaded.
639 /// e.g. UUID, architecture, file path.
640 ///
641 /// \param[in] notify
642 /// If notify is true, and the Module is new to this Target,
643 /// Target::ModulesDidLoad will be called. See note in
644 /// Target::ModulesDidLoad about thread-safety with
645 /// Target::GetOrCreateModule.
646 /// If notify is false, it is assumed that the caller is adding
647 /// multiple Modules and will call ModulesDidLoad with the
648 /// full list at the end.
649 /// ModulesDidLoad must be called when a Module/Modules have
650 /// been added to the target, one way or the other.
651 ///
652 /// \param[out] error_ptr
653 /// Optional argument, pointing to a Status object to fill in
654 /// with any results / messages while attempting to find/load
655 /// this binary. Many callers will be internal functions that
656 /// will handle / summarize the failures in a custom way and
657 /// don't use these messages.
658 ///
659 /// \return
660 /// An empty ModuleSP will be returned if no matching file
661 /// was found. If error_ptr was non-nullptr, an error message
662 /// will likely be provided.
663 lldb::ModuleSP GetOrCreateModule(const ModuleSpec &module_spec, bool notify,
664 Status *error_ptr = nullptr);
665
666 // Settings accessors
667
669
670 std::recursive_mutex &GetAPIMutex();
671
673
674 void CleanupProcess();
675
676 /// Dump a description of this object to a Stream.
677 ///
678 /// Dump a description of the contents of this object to the
679 /// supplied stream \a s. The dumped content will be only what has
680 /// been loaded or parsed up to this point at which this function
681 /// is called, so this is a good way to see what has been parsed
682 /// in a target.
683 ///
684 /// \param[in] s
685 /// The stream to which to dump the object description.
686 void Dump(Stream *s, lldb::DescriptionLevel description_level);
687
688 // If listener_sp is null, the listener of the owning Debugger object will be
689 // used.
691 llvm::StringRef plugin_name,
692 const FileSpec *crash_file,
693 bool can_connect);
694
695 const lldb::ProcessSP &GetProcessSP() const;
696
697 bool IsValid() { return m_valid; }
698
699 void Destroy();
700
701 Status Launch(ProcessLaunchInfo &launch_info,
702 Stream *stream); // Optional stream to receive first stop info
703
704 Status Attach(ProcessAttachInfo &attach_info,
705 Stream *stream); // Optional stream to receive first stop info
706
707 // This part handles the breakpoints.
708
709 BreakpointList &GetBreakpointList(bool internal = false);
710
711 const BreakpointList &GetBreakpointList(bool internal = false) const;
712
716
718
720
721 // Use this to create a file and line breakpoint to a given module or all
722 // module it is nullptr
723 lldb::BreakpointSP CreateBreakpoint(const FileSpecList *containingModules,
724 const FileSpec &file, uint32_t line_no,
725 uint32_t column, lldb::addr_t offset,
726 LazyBool check_inlines,
727 LazyBool skip_prologue, bool internal,
728 bool request_hardware,
729 LazyBool move_to_nearest_code);
730
731 // Use this to create breakpoint that matches regex against the source lines
732 // in files given in source_file_list: If function_names is non-empty, also
733 // filter by function after the matches are made.
735 const FileSpecList *containingModules,
736 const FileSpecList *source_file_list,
737 const std::unordered_set<std::string> &function_names,
738 RegularExpression source_regex, bool internal, bool request_hardware,
739 LazyBool move_to_nearest_code);
740
741 // Use this to create a breakpoint from a load address
742 lldb::BreakpointSP CreateBreakpoint(lldb::addr_t load_addr, bool internal,
743 bool request_hardware);
744
745 // Use this to create a breakpoint from a file address and a module file spec
747 bool internal,
748 const FileSpec &file_spec,
749 bool request_hardware);
750
751 // Use this to create Address breakpoints:
752 lldb::BreakpointSP CreateBreakpoint(const Address &addr, bool internal,
753 bool request_hardware);
754
755 // Use this to create a function breakpoint by regexp in
756 // containingModule/containingSourceFiles, or all modules if it is nullptr
757 // When "skip_prologue is set to eLazyBoolCalculate, we use the current
758 // target setting, else we use the values passed in
760 const FileSpecList *containingModules,
761 const FileSpecList *containingSourceFiles, RegularExpression func_regexp,
762 lldb::LanguageType requested_language, LazyBool skip_prologue,
763 bool internal, bool request_hardware);
764
765 // Use this to create a function breakpoint by name in containingModule, or
766 // all modules if it is nullptr When "skip_prologue is set to
767 // eLazyBoolCalculate, we use the current target setting, else we use the
768 // values passed in. func_name_type_mask is or'ed values from the
769 // FunctionNameType enum.
771 const FileSpecList *containingModules,
772 const FileSpecList *containingSourceFiles, const char *func_name,
773 lldb::FunctionNameType func_name_type_mask, lldb::LanguageType language,
774 lldb::addr_t offset, bool offset_is_insn_count, LazyBool skip_prologue,
775 bool internal, bool request_hardware);
776
778 CreateExceptionBreakpoint(enum lldb::LanguageType language, bool catch_bp,
779 bool throw_bp, bool internal,
780 Args *additional_args = nullptr,
781 Status *additional_args_error = nullptr);
782
784 const llvm::StringRef class_name, const FileSpecList *containingModules,
785 const FileSpecList *containingSourceFiles, bool internal,
786 bool request_hardware, StructuredData::ObjectSP extra_args_sp,
787 Status *creation_error = nullptr);
788
789 // This is the same as the func_name breakpoint except that you can specify a
790 // vector of names. This is cheaper than a regular expression breakpoint in
791 // the case where you just want to set a breakpoint on a set of names you
792 // already know. func_name_type_mask is or'ed values from the
793 // FunctionNameType enum.
795 const FileSpecList *containingModules,
796 const FileSpecList *containingSourceFiles, const char *func_names[],
797 size_t num_names, lldb::FunctionNameType func_name_type_mask,
798 lldb::LanguageType language, lldb::addr_t offset, LazyBool skip_prologue,
799 bool internal, bool request_hardware);
800
802 CreateBreakpoint(const FileSpecList *containingModules,
803 const FileSpecList *containingSourceFiles,
804 const std::vector<std::string> &func_names,
805 lldb::FunctionNameType func_name_type_mask,
806 lldb::LanguageType language, lldb::addr_t m_offset,
807 LazyBool skip_prologue, bool internal,
808 bool request_hardware);
809
810 // Use this to create a general breakpoint:
812 lldb::BreakpointResolverSP &resolver_sp,
813 bool internal, bool request_hardware,
814 bool resolve_indirect_symbols);
815
816 // Use this to create a watchpoint:
818 const CompilerType *type, uint32_t kind,
819 Status &error);
820
824
826
827 // Manages breakpoint names:
828 void AddNameToBreakpoint(BreakpointID &id, llvm::StringRef name,
829 Status &error);
830
831 void AddNameToBreakpoint(lldb::BreakpointSP &bp_sp, llvm::StringRef name,
832 Status &error);
833
835
836 BreakpointName *FindBreakpointName(ConstString name, bool can_create,
837 Status &error);
838
840
842 const BreakpointOptions &options,
843 const BreakpointName::Permissions &permissions);
845
846 void AddBreakpointName(std::unique_ptr<BreakpointName> bp_name);
847
848 void GetBreakpointNames(std::vector<std::string> &names);
849
850 // This call removes ALL breakpoints regardless of permission.
851 void RemoveAllBreakpoints(bool internal_also = false);
852
853 // This removes all the breakpoints, but obeys the ePermDelete on them.
855
856 void DisableAllBreakpoints(bool internal_also = false);
857
859
860 void EnableAllBreakpoints(bool internal_also = false);
861
863
865
867
869
870 /// Resets the hit count of all breakpoints.
872
873 // The flag 'end_to_end', default to true, signifies that the operation is
874 // performed end to end, for both the debugger and the debuggee.
875
876 bool RemoveAllWatchpoints(bool end_to_end = true);
877
878 bool DisableAllWatchpoints(bool end_to_end = true);
879
880 bool EnableAllWatchpoints(bool end_to_end = true);
881
883
885
886 bool IgnoreAllWatchpoints(uint32_t ignore_count);
887
889
891
893
894 bool IgnoreWatchpointByID(lldb::watch_id_t watch_id, uint32_t ignore_count);
895
897 const BreakpointIDList &bp_ids,
898 bool append);
899
901 BreakpointIDList &new_bps);
902
904 std::vector<std::string> &names,
905 BreakpointIDList &new_bps);
906
907 /// Get \a load_addr as a callable code load address for this target
908 ///
909 /// Take \a load_addr and potentially add any address bits that are
910 /// needed to make the address callable. For ARM this can set bit
911 /// zero (if it already isn't) if \a load_addr is a thumb function.
912 /// If \a addr_class is set to AddressClass::eInvalid, then the address
913 /// adjustment will always happen. If it is set to an address class
914 /// that doesn't have code in it, LLDB_INVALID_ADDRESS will be
915 /// returned.
917 lldb::addr_t load_addr,
918 AddressClass addr_class = AddressClass::eInvalid) const;
919
920 /// Get \a load_addr as an opcode for this target.
921 ///
922 /// Take \a load_addr and potentially strip any address bits that are
923 /// needed to make the address point to an opcode. For ARM this can
924 /// clear bit zero (if it already isn't) if \a load_addr is a
925 /// thumb function and load_addr is in code.
926 /// If \a addr_class is set to AddressClass::eInvalid, then the address
927 /// adjustment will always happen. If it is set to an address class
928 /// that doesn't have code in it, LLDB_INVALID_ADDRESS will be
929 /// returned.
932 AddressClass addr_class = AddressClass::eInvalid) const;
933
934 // Get load_addr as breakable load address for this target. Take a addr and
935 // check if for any reason there is a better address than this to put a
936 // breakpoint on. If there is then return that address. For MIPS, if
937 // instruction at addr is a delay slot instruction then this method will find
938 // the address of its previous instruction and return that address.
940
941 /// This call may preload module symbols, and may do so in parallel depending
942 /// on the following target settings:
943 /// - TargetProperties::GetPreloadSymbols()
944 /// - TargetProperties::GetParallelModuleLoad()
945 ///
946 /// Warning: if preloading is active and this is called in parallel with
947 /// Target::GetOrCreateModule, this may result in a ABBA deadlock situation.
948 void ModulesDidLoad(ModuleList &module_list);
949
950 void ModulesDidUnload(ModuleList &module_list, bool delete_locations);
951
952 void SymbolsDidLoad(ModuleList &module_list);
953
954 void ClearModules(bool delete_locations);
955
956 /// Called as the last function in Process::DidExec().
957 ///
958 /// Process::DidExec() will clear a lot of state in the process,
959 /// then try to reload a dynamic loader plugin to discover what
960 /// binaries are currently available and then this function should
961 /// be called to allow the target to do any cleanup after everything
962 /// has been figured out. It can remove breakpoints that no longer
963 /// make sense as the exec might have changed the target
964 /// architecture, and unloaded some modules that might get deleted.
965 void DidExec();
966
967 /// Gets the module for the main executable.
968 ///
969 /// Each process has a notion of a main executable that is the file
970 /// that will be executed or attached to. Executable files can have
971 /// dependent modules that are discovered from the object files, or
972 /// discovered at runtime as things are dynamically loaded.
973 ///
974 /// \return
975 /// The shared pointer to the executable module which can
976 /// contains a nullptr Module object if no executable has been
977 /// set.
978 ///
979 /// \see DynamicLoader
980 /// \see ObjectFile::GetDependentModules (FileSpecList&)
981 /// \see Process::SetExecutableModule(lldb::ModuleSP&)
983
985
986 /// Set the main executable module.
987 ///
988 /// Each process has a notion of a main executable that is the file
989 /// that will be executed or attached to. Executable files can have
990 /// dependent modules that are discovered from the object files, or
991 /// discovered at runtime as things are dynamically loaded.
992 ///
993 /// Setting the executable causes any of the current dependent
994 /// image information to be cleared and replaced with the static
995 /// dependent image information found by calling
996 /// ObjectFile::GetDependentModules (FileSpecList&) on the main
997 /// executable and any modules on which it depends. Calling
998 /// Process::GetImages() will return the newly found images that
999 /// were obtained from all of the object files.
1000 ///
1001 /// \param[in] module_sp
1002 /// A shared pointer reference to the module that will become
1003 /// the main executable for this process.
1004 ///
1005 /// \param[in] load_dependent_files
1006 /// If \b true then ask the object files to track down any
1007 /// known dependent files.
1008 ///
1009 /// \see ObjectFile::GetDependentModules (FileSpecList&)
1010 /// \see Process::GetImages()
1012 lldb::ModuleSP &module_sp,
1013 LoadDependentFiles load_dependent_files = eLoadDependentsDefault);
1014
1015 bool LoadScriptingResources(std::list<Status> &errors,
1016 Stream &feedback_stream,
1017 bool continue_on_error = true) {
1018 return m_images.LoadScriptingResourcesInTarget(
1019 this, errors, feedback_stream, continue_on_error);
1020 }
1021
1022 /// Get accessor for the images for this process.
1023 ///
1024 /// Each process has a notion of a main executable that is the file
1025 /// that will be executed or attached to. Executable files can have
1026 /// dependent modules that are discovered from the object files, or
1027 /// discovered at runtime as things are dynamically loaded. After
1028 /// a main executable has been set, the images will contain a list
1029 /// of all the files that the executable depends upon as far as the
1030 /// object files know. These images will usually contain valid file
1031 /// virtual addresses only. When the process is launched or attached
1032 /// to, the DynamicLoader plug-in will discover where these images
1033 /// were loaded in memory and will resolve the load virtual
1034 /// addresses is each image, and also in images that are loaded by
1035 /// code.
1036 ///
1037 /// \return
1038 /// A list of Module objects in a module list.
1039 const ModuleList &GetImages() const { return m_images; }
1040
1042
1043 /// Return whether this FileSpec corresponds to a module that should be
1044 /// considered for general searches.
1045 ///
1046 /// This API will be consulted by the SearchFilterForUnconstrainedSearches
1047 /// and any module that returns \b true will not be searched. Note the
1048 /// SearchFilterForUnconstrainedSearches is the search filter that
1049 /// gets used in the CreateBreakpoint calls when no modules is provided.
1050 ///
1051 /// The target call at present just consults the Platform's call of the
1052 /// same name.
1053 ///
1054 /// \param[in] module_spec
1055 /// Path to the module.
1056 ///
1057 /// \return \b true if the module should be excluded, \b false otherwise.
1058 bool ModuleIsExcludedForUnconstrainedSearches(const FileSpec &module_spec);
1059
1060 /// Return whether this module should be considered for general searches.
1061 ///
1062 /// This API will be consulted by the SearchFilterForUnconstrainedSearches
1063 /// and any module that returns \b true will not be searched. Note the
1064 /// SearchFilterForUnconstrainedSearches is the search filter that
1065 /// gets used in the CreateBreakpoint calls when no modules is provided.
1066 ///
1067 /// The target call at present just consults the Platform's call of the
1068 /// same name.
1069 ///
1070 /// FIXME: When we get time we should add a way for the user to set modules
1071 /// that they
1072 /// don't want searched, in addition to or instead of the platform ones.
1073 ///
1074 /// \param[in] module_sp
1075 /// A shared pointer reference to the module that checked.
1076 ///
1077 /// \return \b true if the module should be excluded, \b false otherwise.
1078 bool
1080
1081 const ArchSpec &GetArchitecture() const { return m_arch.GetSpec(); }
1082
1083 /// Returns the name of the target's ABI plugin.
1084 llvm::StringRef GetABIName() const;
1085
1086 /// Set the architecture for this target.
1087 ///
1088 /// If the current target has no Images read in, then this just sets the
1089 /// architecture, which will be used to select the architecture of the
1090 /// ExecutableModule when that is set. If the current target has an
1091 /// ExecutableModule, then calling SetArchitecture with a different
1092 /// architecture from the currently selected one will reset the
1093 /// ExecutableModule to that slice of the file backing the ExecutableModule.
1094 /// If the file backing the ExecutableModule does not contain a fork of this
1095 /// architecture, then this code will return false, and the architecture
1096 /// won't be changed. If the input arch_spec is the same as the already set
1097 /// architecture, this is a no-op.
1098 ///
1099 /// \param[in] arch_spec
1100 /// The new architecture.
1101 ///
1102 /// \param[in] set_platform
1103 /// If \b true, then the platform will be adjusted if the currently
1104 /// selected platform is not compatible with the architecture being set.
1105 /// If \b false, then just the architecture will be set even if the
1106 /// currently selected platform isn't compatible (in case it might be
1107 /// manually set following this function call).
1108 ///
1109 /// \param[in] merged
1110 /// If true, arch_spec is merged with the current
1111 /// architecture. Otherwise it's replaced.
1112 ///
1113 /// \return
1114 /// \b true if the architecture was successfully set, \b false otherwise.
1115 bool SetArchitecture(const ArchSpec &arch_spec, bool set_platform = false,
1116 bool merge = true);
1117
1118 bool MergeArchitecture(const ArchSpec &arch_spec);
1119
1120 Architecture *GetArchitecturePlugin() const { return m_arch.GetPlugin(); }
1121
1122 Debugger &GetDebugger() const { return m_debugger; }
1123
1124 size_t ReadMemoryFromFileCache(const Address &addr, void *dst, size_t dst_len,
1125 Status &error);
1126
1127 // Reading memory through the target allows us to skip going to the process
1128 // for reading memory if possible and it allows us to try and read from any
1129 // constant sections in our object files on disk. If you always want live
1130 // program memory, read straight from the process. If you possibly want to
1131 // read from const sections in object files, read from the target. This
1132 // version of ReadMemory will try and read memory from the process if the
1133 // process is alive. The order is:
1134 // 1 - if (force_live_memory == false) and the address falls in a read-only
1135 // section, then read from the file cache
1136 // 2 - if there is a process, then read from memory
1137 // 3 - if there is no process, then read from the file cache
1138 //
1139 // If did_read_live_memory is provided, will indicate if the read was from
1140 // live memory, or from file contents. A caller which needs to treat these two
1141 // sources differently should use this argument to disambiguate where the data
1142 // was read from.
1143 //
1144 // The method is virtual for mocking in the unit tests.
1145 virtual size_t ReadMemory(const Address &addr, void *dst, size_t dst_len,
1146 Status &error, bool force_live_memory = false,
1147 lldb::addr_t *load_addr_ptr = nullptr,
1148 bool *did_read_live_memory = nullptr);
1149
1150 size_t ReadCStringFromMemory(const Address &addr, std::string &out_str,
1151 Status &error, bool force_live_memory = false);
1152
1153 size_t ReadCStringFromMemory(const Address &addr, char *dst,
1154 size_t dst_max_len, Status &result_error,
1155 bool force_live_memory = false);
1156
1157 /// Read a NULL terminated string from memory
1158 ///
1159 /// This function will read a cache page at a time until a NULL string
1160 /// terminator is found. It will stop reading if an aligned sequence of NULL
1161 /// termination \a type_width bytes is not found before reading \a
1162 /// cstr_max_len bytes. The results are always guaranteed to be NULL
1163 /// terminated, and that no more than (max_bytes - type_width) bytes will be
1164 /// read.
1165 ///
1166 /// \param[in] addr
1167 /// The address to start the memory read.
1168 ///
1169 /// \param[in] dst
1170 /// A character buffer containing at least max_bytes.
1171 ///
1172 /// \param[in] max_bytes
1173 /// The maximum number of bytes to read.
1174 ///
1175 /// \param[in] error
1176 /// The error status of the read operation.
1177 ///
1178 /// \param[in] type_width
1179 /// The size of the null terminator (1 to 4 bytes per
1180 /// character). Defaults to 1.
1181 ///
1182 /// \return
1183 /// The error status or the number of bytes prior to the null terminator.
1184 size_t ReadStringFromMemory(const Address &addr, char *dst, size_t max_bytes,
1185 Status &error, size_t type_width,
1186 bool force_live_memory = true);
1187
1188 size_t ReadScalarIntegerFromMemory(const Address &addr, uint32_t byte_size,
1189 bool is_signed, Scalar &scalar,
1190 Status &error,
1191 bool force_live_memory = false);
1192
1193 int64_t ReadSignedIntegerFromMemory(const Address &addr,
1194 size_t integer_byte_size,
1195 int64_t fail_value, Status &error,
1196 bool force_live_memory = false);
1197
1198 uint64_t ReadUnsignedIntegerFromMemory(const Address &addr,
1199 size_t integer_byte_size,
1200 uint64_t fail_value, Status &error,
1201 bool force_live_memory = false);
1202
1203 bool ReadPointerFromMemory(const Address &addr, Status &error,
1204 Address &pointer_addr,
1205 bool force_live_memory = false);
1206
1207 bool HasLoadedSections();
1208
1210
1211 void ClearSectionLoadList();
1212
1213 void DumpSectionLoadList(Stream &s);
1214
1215 static Target *GetTargetFromContexts(const ExecutionContext *exe_ctx_ptr,
1216 const SymbolContext *sc_ptr);
1217
1218 // lldb::ExecutionContextScope pure virtual functions
1220
1222
1224
1226
1227 void CalculateExecutionContext(ExecutionContext &exe_ctx) override;
1228
1230
1231 llvm::Expected<lldb::TypeSystemSP>
1233 bool create_on_demand = true);
1234
1235 std::vector<lldb::TypeSystemSP>
1236 GetScratchTypeSystems(bool create_on_demand = true);
1237
1240
1241 // Creates a UserExpression for the given language, the rest of the
1242 // parameters have the same meaning as for the UserExpression constructor.
1243 // Returns a new-ed object which the caller owns.
1244
1246 GetUserExpressionForLanguage(llvm::StringRef expr, llvm::StringRef prefix,
1247 SourceLanguage language,
1248 Expression::ResultType desired_type,
1249 const EvaluateExpressionOptions &options,
1250 ValueObject *ctx_obj, Status &error);
1251
1252 // Creates a FunctionCaller for the given language, the rest of the
1253 // parameters have the same meaning as for the FunctionCaller constructor.
1254 // Since a FunctionCaller can't be
1255 // IR Interpreted, it makes no sense to call this with an
1256 // ExecutionContextScope that lacks
1257 // a Process.
1258 // Returns a new-ed object which the caller owns.
1259
1261 const CompilerType &return_type,
1262 const Address &function_address,
1263 const ValueList &arg_value_list,
1264 const char *name, Status &error);
1265
1266 /// Creates and installs a UtilityFunction for the given language.
1267 llvm::Expected<std::unique_ptr<UtilityFunction>>
1268 CreateUtilityFunction(std::string expression, std::string name,
1269 lldb::LanguageType language, ExecutionContext &exe_ctx);
1270
1271 // Install any files through the platform that need be to installed prior to
1272 // launching or attaching.
1273 Status Install(ProcessLaunchInfo *launch_info);
1274
1275 bool ResolveFileAddress(lldb::addr_t load_addr, Address &so_addr);
1276
1277 bool ResolveLoadAddress(lldb::addr_t load_addr, Address &so_addr,
1278 uint32_t stop_id = SectionLoadHistory::eStopIDNow,
1279 bool allow_section_end = false);
1280
1281 bool SetSectionLoadAddress(const lldb::SectionSP &section,
1282 lldb::addr_t load_addr,
1283 bool warn_multiple = false);
1284
1285 size_t UnloadModuleSections(const lldb::ModuleSP &module_sp);
1286
1287 size_t UnloadModuleSections(const ModuleList &module_list);
1288
1289 bool SetSectionUnloaded(const lldb::SectionSP &section_sp);
1290
1291 bool SetSectionUnloaded(const lldb::SectionSP &section_sp,
1292 lldb::addr_t load_addr);
1293
1295
1297 lldb_private::TypeSummaryImpl &summary_provider);
1299
1300 /// Set the \a Trace object containing processor trace information of this
1301 /// target.
1302 ///
1303 /// \param[in] trace_sp
1304 /// The trace object.
1305 void SetTrace(const lldb::TraceSP &trace_sp);
1306
1307 /// Get the \a Trace object containing processor trace information of this
1308 /// target.
1309 ///
1310 /// \return
1311 /// The trace object. It might be undefined.
1313
1314 /// Create a \a Trace object for the current target using the using the
1315 /// default supported tracing technology for this process.
1316 ///
1317 /// \return
1318 /// The new \a Trace or an \a llvm::Error if a \a Trace already exists or
1319 /// the trace couldn't be created.
1320 llvm::Expected<lldb::TraceSP> CreateTrace();
1321
1322 /// If a \a Trace object is present, this returns it, otherwise a new Trace is
1323 /// created with \a Trace::CreateTrace.
1324 llvm::Expected<lldb::TraceSP> GetTraceOrCreate();
1325
1326 // Since expressions results can persist beyond the lifetime of a process,
1327 // and the const expression results are available after a process is gone, we
1328 // provide a way for expressions to be evaluated from the Target itself. If
1329 // an expression is going to be run, then it should have a frame filled in in
1330 // the execution context.
1332 llvm::StringRef expression, ExecutionContextScope *exe_scope,
1333 lldb::ValueObjectSP &result_valobj_sp,
1335 std::string *fixed_expression = nullptr, ValueObject *ctx_obj = nullptr);
1336
1338
1340
1341 /// This method will return the address of the starting function for
1342 /// this binary, e.g. main() or its equivalent. This can be used as
1343 /// an address of a function that is not called once a binary has
1344 /// started running - e.g. as a return address for inferior function
1345 /// calls that are unambiguous completion of the function call, not
1346 /// called during the course of the inferior function code running.
1347 ///
1348 /// If no entry point can be found, an invalid address is returned.
1349 ///
1350 /// \param [out] err
1351 /// This object will be set to failure if no entry address could
1352 /// be found, and may contain a helpful error message.
1353 //
1354 /// \return
1355 /// Returns the entry address for this program, or an error
1356 /// if none can be found.
1357 llvm::Expected<lldb_private::Address> GetEntryPointAddress();
1358
1359 CompilerType GetRegisterType(const std::string &name,
1360 const lldb_private::RegisterFlags &flags,
1361 uint32_t byte_size);
1362
1363 /// Sends a breakpoint notification event.
1365 lldb::BreakpointEventType event_kind);
1366 /// Sends a breakpoint notification event.
1368 const lldb::EventDataSP &breakpoint_data_sp);
1369
1370 llvm::Expected<lldb::DisassemblerSP>
1371 ReadInstructions(const Address &start_addr, uint32_t count,
1372 const char *flavor_string = nullptr);
1373
1374 // Target Stop Hooks
1375 class StopHook : public UserID {
1376 public:
1377 StopHook(const StopHook &rhs);
1378 virtual ~StopHook() = default;
1379
1380 enum class StopHookKind : uint32_t {
1384 };
1391
1393
1394 // Set the specifier. The stop hook will own the specifier, and is
1395 // responsible for deleting it when we're done.
1396 void SetSpecifier(SymbolContextSpecifier *specifier);
1397
1399
1400 bool ExecutionContextPasses(const ExecutionContext &exe_ctx);
1401
1402 // Called on stop, this gets passed the ExecutionContext for each "stop
1403 // with a reason" thread. It should add to the stream whatever text it
1404 // wants to show the user, and return False to indicate it wants the target
1405 // not to stop.
1407 lldb::StreamSP output) = 0;
1408
1409 // Set the Thread Specifier. The stop hook will own the thread specifier,
1410 // and is responsible for deleting it when we're done.
1411 void SetThreadSpecifier(ThreadSpec *specifier);
1412
1414
1415 bool IsActive() { return m_active; }
1416
1417 void SetIsActive(bool is_active) { m_active = is_active; }
1418
1419 void SetAutoContinue(bool auto_continue) {
1420 m_auto_continue = auto_continue;
1421 }
1422
1423 bool GetAutoContinue() const { return m_auto_continue; }
1424
1425 void SetRunAtInitialStop(bool at_initial_stop) {
1426 m_at_initial_stop = at_initial_stop;
1427 }
1428
1430
1431 void SetSuppressOutput(bool suppress_output) {
1432 m_suppress_output = suppress_output;
1433 }
1434
1435 bool GetSuppressOutput() const { return m_suppress_output; }
1436
1437 void GetDescription(Stream &s, lldb::DescriptionLevel level) const;
1439 lldb::DescriptionLevel level) const = 0;
1440
1441 protected:
1444 std::unique_ptr<ThreadSpec> m_thread_spec_up;
1445 bool m_active = true;
1446 bool m_auto_continue = false;
1448 bool m_suppress_output = false;
1449
1450 StopHook(lldb::TargetSP target_sp, lldb::user_id_t uid);
1451 };
1452
1454 public:
1455 ~StopHookCommandLine() override = default;
1456
1458 void SetActionFromString(const std::string &strings);
1459 void SetActionFromStrings(const std::vector<std::string> &strings);
1460
1462 lldb::StreamSP output_sp) override;
1464 lldb::DescriptionLevel level) const override;
1465
1466 private:
1468 // Use CreateStopHook to make a new empty stop hook. Use SetActionFromString
1469 // to fill it with commands, and SetSpecifier to set the specifier shared
1470 // pointer (can be null, that will match anything.)
1472 : StopHook(target_sp, uid) {}
1473 friend class Target;
1474 };
1475
1477 public:
1478 ~StopHookScripted() override = default;
1480 lldb::StreamSP output) override;
1481
1482 Status SetScriptCallback(std::string class_name,
1483 StructuredData::ObjectSP extra_args_sp);
1484
1486 lldb::DescriptionLevel level) const override;
1487
1488 private:
1489 std::string m_class_name;
1490 /// This holds the dictionary of keys & values that can be used to
1491 /// parametrize any given callback's behavior.
1494
1495 /// Use CreateStopHook to make a new empty stop hook. Use SetScriptCallback
1496 /// to set the script to execute, and SetSpecifier to set the specifier
1497 /// shared pointer (can be null, that will match anything.)
1499 : StopHook(target_sp, uid) {}
1500 friend class Target;
1501 };
1502
1503 class StopHookCoded : public StopHook {
1504 public:
1505 ~StopHookCoded() override = default;
1506
1508 lldb::StreamSP output);
1509
1510 void SetCallback(llvm::StringRef name, HandleStopCallback *callback) {
1511 m_name = name;
1512 m_callback = callback;
1513 }
1514
1516 lldb::StreamSP output) override {
1517 return m_callback(exc_ctx, output);
1518 }
1519
1521 lldb::DescriptionLevel level) const override {
1522 s.Indent();
1523 s.Printf("%s (built-in)\n", m_name.c_str());
1524 }
1525
1526 private:
1527 std::string m_name;
1529
1530 /// Use CreateStopHook to make a new empty stop hook. Use SetCallback to set
1531 /// the callback to execute, and SetSpecifier to set the specifier shared
1532 /// pointer (can be null, that will match anything.)
1534 : StopHook(target_sp, uid) {}
1535 friend class Target;
1536 };
1537
1539
1540 typedef std::shared_ptr<StopHook> StopHookSP;
1541
1542 /// Add an empty stop hook to the Target's stop hook list, and returns a
1543 /// shared pointer to the new hook.
1544 StopHookSP CreateStopHook(StopHook::StopHookKind kind, bool internal = false);
1545
1546 /// If you tried to create a stop hook, and that failed, call this to
1547 /// remove the stop hook, as it will also reset the stop hook counter.
1549
1550 // Runs the stop hooks that have been registered for this target.
1551 // Returns true if the stop hooks cause the target to resume.
1552 // Pass at_initial_stop if this is the stop where lldb gains
1553 // control over the process for the first time.
1554 bool RunStopHooks(bool at_initial_stop = false);
1555
1556 bool SetSuppresStopHooks(bool suppress) {
1557 bool old_value = m_suppress_stop_hooks;
1558 m_suppress_stop_hooks = suppress;
1559 return old_value;
1560 }
1561
1563
1565
1566 void RemoveAllStopHooks();
1567
1568 StopHookSP GetStopHookByID(lldb::user_id_t uid);
1569
1570 bool SetStopHookActiveStateByID(lldb::user_id_t uid, bool active_state);
1571
1572 void SetAllStopHooksActiveState(bool active_state);
1573
1574 const std::vector<StopHookSP> GetStopHooks(bool internal = false) const;
1575
1577
1578 void SetPlatform(const lldb::PlatformSP &platform_sp) {
1579 m_platform_sp = platform_sp;
1580 }
1581
1583
1584 // Methods.
1586 GetSearchFilterForModule(const FileSpec *containingModule);
1587
1589 GetSearchFilterForModuleList(const FileSpecList *containingModuleList);
1590
1592 GetSearchFilterForModuleAndCUList(const FileSpecList *containingModules,
1593 const FileSpecList *containingSourceFiles);
1594
1596 const char *repl_options, bool can_create);
1597
1598 void SetREPL(lldb::LanguageType language, lldb::REPLSP repl_sp);
1599
1603
1605
1606 /// Add a signal for the target. This will get copied over to the process
1607 /// if the signal exists on that target. Only the values with Yes and No are
1608 /// set, Calculate values will be ignored.
1609protected:
1618 using DummySignalElement = llvm::StringMapEntry<DummySignalValues>;
1619 static bool UpdateSignalFromDummy(lldb::UnixSignalsSP signals_sp,
1620 const DummySignalElement &element);
1621 static bool ResetSignalFromDummy(lldb::UnixSignalsSP signals_sp,
1622 const DummySignalElement &element);
1623
1624public:
1625 /// Add a signal to the Target's list of stored signals/actions. These
1626 /// values will get copied into any processes launched from
1627 /// this target.
1628 void AddDummySignal(llvm::StringRef name, LazyBool pass, LazyBool print,
1629 LazyBool stop);
1630 /// Updates the signals in signals_sp using the stored dummy signals.
1631 /// If warning_stream_sp is not null, if any stored signals are not found in
1632 /// the current process, a warning will be emitted here.
1634 lldb::StreamSP warning_stream_sp);
1635 /// Clear the dummy signals in signal_names from the target, or all signals
1636 /// if signal_names is empty. Also remove the behaviors they set from the
1637 /// process's signals if it exists.
1638 void ClearDummySignals(Args &signal_names);
1639 /// Print all the signals set in this target.
1640 void PrintDummySignals(Stream &strm, Args &signals);
1641
1642protected:
1643 /// Implementing of ModuleList::Notifier.
1644
1645 void NotifyModuleAdded(const ModuleList &module_list,
1646 const lldb::ModuleSP &module_sp) override;
1647
1648 void NotifyModuleRemoved(const ModuleList &module_list,
1649 const lldb::ModuleSP &module_sp) override;
1650
1651 void NotifyModuleUpdated(const ModuleList &module_list,
1652 const lldb::ModuleSP &old_module_sp,
1653 const lldb::ModuleSP &new_module_sp) override;
1654
1655 void NotifyWillClearList(const ModuleList &module_list) override;
1656
1657 void NotifyModulesRemoved(lldb_private::ModuleList &module_list) override;
1658
1659 class Arch {
1660 public:
1661 explicit Arch(const ArchSpec &spec);
1662 const Arch &operator=(const ArchSpec &spec);
1663
1664 const ArchSpec &GetSpec() const { return m_spec; }
1665 Architecture *GetPlugin() const { return m_plugin_up.get(); }
1666
1667 private:
1669 std::unique_ptr<Architecture> m_plugin_up;
1670 };
1671
1672 // Member variables.
1674 lldb::PlatformSP m_platform_sp; ///< The platform for this target.
1675 std::recursive_mutex m_mutex; ///< An API mutex that is used by the lldb::SB*
1676 /// classes make the SB interface thread safe
1677 /// When the private state thread calls SB API's - usually because it is
1678 /// running OS plugin or Python ThreadPlan code - it should not block on the
1679 /// API mutex that is held by the code that kicked off the sequence of events
1680 /// that led us to run the code. We hand out this mutex instead when we
1681 /// detect that code is running on the private state thread.
1682 std::recursive_mutex m_private_mutex;
1684 std::string m_label;
1685 ModuleList m_images; ///< The list of images for this process (shared
1686 /// libraries and anything dynamically loaded).
1692 std::map<ConstString, std::unique_ptr<BreakpointName>>;
1694
1698 // We want to tightly control the process destruction process so we can
1699 // correctly tear down everything that we need to, so the only class that
1700 // knows about the process lifespan is this target class.
1705
1706 typedef std::map<lldb::LanguageType, lldb::REPLSP> REPLMap;
1708
1710
1711 typedef std::map<lldb::user_id_t, StopHookSP> StopHookCollection;
1714 std::vector<StopHookSP> m_internal_stop_hooks;
1715 uint32_t m_latest_stop_hook_id; /// This records the last natural stop at
1716 /// which we ran a stop-hook.
1718 bool m_suppress_stop_hooks; /// Used to not run stop hooks for expressions
1722 LLDB_INVALID_GLOBALLY_UNIQUE_TARGET_ID; /// The globally unique ID
1723 /// assigned to this target
1724 /// An optional \a lldb_private::Trace object containing processor trace
1725 /// information of this target.
1727 /// Stores the frame recognizers of this target.
1729 /// These are used to set the signal state when you don't have a process and
1730 /// more usefully in the Dummy target where you can't know exactly what
1731 /// signals you will have.
1732 llvm::StringMap<DummySignalValues> m_dummy_signals;
1733
1734 static void ImageSearchPathsChanged(const PathMappingList &path_list,
1735 void *baton);
1736
1737 // Utilities for `statistics` command.
1738private:
1739 // Target metrics storage.
1741
1742public:
1743 /// Get metrics associated with this target in JSON format.
1744 ///
1745 /// Target metrics help measure timings and information that is contained in
1746 /// a target. These are designed to help measure performance of a debug
1747 /// session as well as represent the current state of the target, like
1748 /// information on the currently modules, currently set breakpoints and more.
1749 ///
1750 /// \return
1751 /// Returns a JSON value that contains all target metrics.
1752 llvm::json::Value
1754
1755 void ResetStatistics();
1756
1758
1759protected:
1760 /// Construct with optional file and arch.
1761 ///
1762 /// This member is private. Clients must use
1763 /// TargetList::CreateTarget(const FileSpec*, const ArchSpec*)
1764 /// so all targets can be tracked from the central target list.
1765 ///
1766 /// \see TargetList::CreateTarget(const FileSpec*, const ArchSpec*)
1767 Target(Debugger &debugger, const ArchSpec &target_arch,
1768 const lldb::PlatformSP &platform_sp, bool is_dummy_target);
1769
1770 // Helper function.
1771 bool ProcessIsValid();
1772
1773 // Copy breakpoints, stop hooks and so forth from the dummy target:
1774 void PrimeFromDummyTarget(Target &target);
1775
1776 void AddBreakpoint(lldb::BreakpointSP breakpoint_sp, bool internal);
1777
1779
1780 /// Return a recommended size for memory reads at \a addr, optimizing for
1781 /// cache usage.
1783
1784 Target(const Target &) = delete;
1785 const Target &operator=(const Target &) = delete;
1786
1788 return m_section_load_history.GetCurrentSectionLoadList();
1789 }
1790};
1791
1792} // namespace lldb_private
1793
1794#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:31
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:80
void SetPreferredSymbolContexts(SymbolContextList contexts)
Definition Target.h:339
void SetOneThreadTimeout(const Timeout< std::micro > &timeout)
Definition Target.h:398
void SetUnwindOnError(bool unwind=false)
Definition Target.h:371
SourceLanguage GetLanguage() const
Definition Target.h:333
const char * GetPoundLineFilePath() const
Definition Target.h:457
lldb::DynamicValueType m_use_dynamic
Definition Target.h:505
void SetExecutionPolicy(ExecutionPolicy policy=eExecutionPolicyAlways)
Definition Target.h:329
Timeout< std::micro > m_one_thread_timeout
Definition Target.h:507
bool InvokeCancelCallback(lldb::ExpressionEvaluationPhase phase) const
Definition Target.h:439
lldb::DynamicValueType GetUseDynamic() const
Definition Target.h:383
void SetKeepInMemory(bool keep=true)
Definition Target.h:381
void SetCoerceToId(bool coerce=true)
Definition Target.h:367
void SetLanguage(lldb::LanguageType language_type)
Definition Target.h:335
ExecutionPolicy GetExecutionPolicy() const
Definition Target.h:327
Timeout< std::micro > m_timeout
Definition Target.h:506
void SetPrefix(const char *prefix)
Definition Target.h:360
void SetTryAllThreads(bool try_others=true)
Definition Target.h:404
void SetPoundLine(const char *path, uint32_t line) const
Definition Target.h:447
void SetRetriesWithFixIts(uint64_t number_of_retries)
Definition Target.h:473
SymbolContextList m_preferred_lookup_contexts
During expression evaluation, any SymbolContext in this list will be used for symbol/function lookup ...
Definition Target.h:519
void SetTimeout(const Timeout< std::micro > &timeout)
Definition Target.h:392
static constexpr ExecutionPolicy default_execution_policy
Definition Target.h:322
void SetStopOthers(bool stop_others=true)
Definition Target.h:408
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:503
void SetCancelCallback(lldb::ExpressionCancelCallback callback, void *baton)
Definition Target.h:434
const Timeout< std::micro > & GetTimeout() const
Definition Target.h:390
const SymbolContextList & GetPreferredSymbolContexts() const
Definition Target.h:343
void SetIgnoreBreakpoints(bool ignore=false)
Definition Target.h:375
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:350
void SetUseDynamic(lldb::DynamicValueType dynamic=lldb::eDynamicCanRunTarget)
Definition Target.h:386
lldb::ExpressionCancelCallback m_cancel_callback
Definition Target.h:508
static constexpr std::chrono::milliseconds default_timeout
Definition Target.h:317
const Timeout< std::micro > & GetOneThreadTimeout() const
Definition Target.h:394
"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:104
A class that describes an executable image and its associated object and symbol files.
Definition Module.h:90
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< Object > ObjectSP
A class that wraps a std::map of SummaryStatistics objects behind a mutex.
Definition Statistics.h:284
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:4908
FileSpecList GetDebugFileSearchPaths()
Definition Target.cpp:4789
llvm::StringRef GetLaunchWorkingDirectory() const
Definition Target.cpp:4595
bool GetDisplayRecognizedArguments() const
Definition Target.cpp:5066
ImportStdModule GetImportStdModule() const
Definition Target.cpp:4805
void AppendExecutableSearchPaths(const FileSpec &)
Definition Target.cpp:4776
bool GetEnableSyntheticValue() const
Definition Target.cpp:4875
void SetStandardInputPath(const char *path)=delete
ProcessLaunchInfo m_launch_info
Definition Target.h:302
uint64_t GetExprAllocAlign() const
Definition Target.cpp:4987
MemoryModuleLoadLevel GetMemoryModuleLoadLevel() const
Definition Target.cpp:5038
llvm::StringRef GetArg0() const
Definition Target.cpp:4648
uint32_t GetMaximumMemReadSize() const
Definition Target.cpp:4914
void SetRunArguments(const Args &args)
Definition Target.cpp:4665
FileSpec GetStandardErrorPath() const
Definition Target.cpp:4940
bool GetEnableNotifyAboutFixIts() const
Definition Target.cpp:4831
bool SetPreferDynamicValue(lldb::DynamicValueType d)
Definition Target.cpp:4532
void SetDisplayRecognizedArguments(bool b)
Definition Target.cpp:5072
std::optional< bool > GetExperimentalPropertyValue(size_t prop_idx, ExecutionContext *exe_ctx=nullptr) const
Definition Target.cpp:4471
const ProcessLaunchInfo & GetProcessLaunchInfo() const
Definition Target.cpp:5077
Environment ComputeEnvironment() const
Definition Target.cpp:4671
void SetStandardOutputPath(const char *path)=delete
bool GetUserSpecifiedTrapHandlerNames(Args &args) const
Definition Target.cpp:5045
uint64_t GetExprErrorLimit() const
Definition Target.cpp:4969
bool GetEnableAutoImportClangModules() const
Definition Target.cpp:4799
bool GetDebugUtilityExpression() const
Definition Target.cpp:5183
DynamicClassInfoHelper GetDynamicClassInfoHelper() const
Definition Target.cpp:4812
FileSpec GetStandardOutputPath() const
Definition Target.cpp:4930
void SetDisplayRuntimeSupportValues(bool b)
Definition Target.cpp:5061
uint32_t GetMaximumNumberOfChildrenToDisplay() const
Definition Target.cpp:4893
void SetRequireHardwareBreakpoints(bool b)
Definition Target.cpp:5115
bool GetAutoInstallMainExecutable() const
Definition Target.cpp:5120
const char * GetDisassemblyFeatures() const
Definition Target.cpp:4627
RealpathPrefixes GetSourceRealpathPrefixes() const
Definition Target.cpp:4643
uint64_t GetNumberOfRetriesWithFixits() const
Definition Target.cpp:4825
uint64_t GetExprAllocSize() const
Definition Target.cpp:4981
llvm::StringRef GetExpressionPrefixContents()
Definition Target.cpp:4955
PathMappingList & GetObjectPathMap() const
Definition Target.cpp:4762
const char * GetDisassemblyFlavor() const
Definition Target.cpp:4607
FileSpec GetStandardInputPath() const
Definition Target.cpp:4920
lldb::DynamicValueType GetPreferDynamicValue() const
Definition Target.cpp:4525
InlineStrategy GetInlineStrategy() const
Definition Target.cpp:4634
Environment GetTargetEnvironment() const
Definition Target.cpp:4731
bool GetDisplayRuntimeSupportValues() const
Definition Target.cpp:5055
void SetUserSpecifiedTrapHandlerNames(const Args &args)
Definition Target.cpp:5050
uint32_t GetMaxZeroPaddingInFloatFormat() const
Definition Target.cpp:4887
uint64_t GetExprAllocAddress() const
Definition Target.cpp:4975
LoadCWDlldbinitFile GetLoadCWDlldbinitFile() const
Definition Target.cpp:5024
Environment GetInheritedEnvironment() const
Definition Target.cpp:4703
void SetArg0(llvm::StringRef arg)
Definition Target.cpp:4654
bool GetInjectLocalVariables(ExecutionContext *exe_ctx) const
Definition Target.cpp:4482
void SetStandardErrorPath(const char *path)=delete
bool ShowHexVariableValuesWithLeadingZeroes() const
Definition Target.cpp:4881
SourceLanguage GetLanguage() const
Definition Target.cpp:4950
Environment GetEnvironment() const
Definition Target.cpp:4699
void SetProcessLaunchInfo(const ProcessLaunchInfo &launch_info)
Definition Target.cpp:5081
FileSpec GetSaveJITObjectsDir() const
Definition Target.cpp:4837
void SetEnvironment(Environment env)
Definition Target.cpp:4742
LoadScriptFromSymFile GetLoadScriptFromSymbolFile() const
Definition Target.cpp:5017
const char * GetDisassemblyCPU() const
Definition Target.cpp:4620
void SetStandardErrorPath(llvm::StringRef path)
Definition Target.cpp:4945
bool GetRunArguments(Args &args) const
Definition Target.cpp:4660
FileSpecList GetExecutableSearchPaths()
Definition Target.cpp:4784
ArchSpec GetDefaultArchitecture() const
Definition Target.cpp:4509
Disassembler::HexImmediateStyle GetHexImmediateStyle() const
Definition Target.cpp:5031
void SetUseDIL(ExecutionContext *exe_ctx, bool b)
Definition Target.cpp:4500
std::unique_ptr< TargetExperimentalProperties > m_experimental_properties_up
Definition Target.h:303
FileSpecList GetClangModuleSearchPaths()
Definition Target.cpp:4794
void SetStandardOutputPath(llvm::StringRef path)
Definition Target.cpp:4935
bool GetRequireHardwareBreakpoints() const
Definition Target.cpp:5109
PathMappingList & GetSourcePathMap() const
Definition Target.cpp:4754
bool GetAutoSourceMapRelative() const
Definition Target.cpp:4770
bool GetUseDIL(ExecutionContext *exe_ctx) const
Definition Target.cpp:4488
void SetDefaultArchitecture(const ArchSpec &arch)
Definition Target.cpp:4514
void SetStandardInputPath(llvm::StringRef path)
Definition Target.cpp:4925
TargetProperties(Target *target)
Definition Target.cpp:4395
bool GetDisplayExpressionsInCrashlogs() const
Definition Target.cpp:5011
bool GetEnableAutoApplyFixIts() const
Definition Target.cpp:4819
void SetDebugUtilityExpression(bool debug)
Definition Target.cpp:5189
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:4900
A class that represents statistics for a since lldb_private::Target.
Definition Statistics.h:312
std::unique_ptr< Architecture > m_plugin_up
Definition Target.h:1669
const ArchSpec & GetSpec() const
Definition Target.h:1664
const Arch & operator=(const ArchSpec &spec)
Definition Target.cpp:165
Arch(const ArchSpec &spec)
Definition Target.cpp:161
Architecture * GetPlugin() const
Definition Target.h:1665
void GetSubclassDescription(Stream &s, lldb::DescriptionLevel level) const override
Definition Target.h:1520
HandleStopCallback * m_callback
Definition Target.h:1528
StopHookResult HandleStop(ExecutionContext &exc_ctx, lldb::StreamSP output) override
Definition Target.h:1515
StopHookCoded(lldb::TargetSP target_sp, lldb::user_id_t uid)
Use CreateStopHook to make a new empty stop hook.
Definition Target.h:1533
void SetCallback(llvm::StringRef name, HandleStopCallback *callback)
Definition Target.h:1510
StopHookResult(ExecutionContext &exc_ctx, lldb::StreamSP output) HandleStopCallback
Definition Target.h:1507
void SetActionFromString(const std::string &strings)
Definition Target.cpp:4016
StopHookCommandLine(lldb::TargetSP target_sp, lldb::user_id_t uid)
Definition Target.h:1471
void SetActionFromStrings(const std::vector< std::string > &strings)
Definition Target.cpp:4020
StopHookResult HandleStop(ExecutionContext &exc_ctx, lldb::StreamSP output_sp) override
Definition Target.cpp:4027
void GetSubclassDescription(Stream &s, lldb::DescriptionLevel level) const override
Definition Target.cpp:3998
Status SetScriptCallback(std::string class_name, StructuredData::ObjectSP extra_args_sp)
Definition Target.cpp:4061
StopHookResult HandleStop(ExecutionContext &exc_ctx, lldb::StreamSP output) override
Definition Target.cpp:4101
StopHookScripted(lldb::TargetSP target_sp, lldb::user_id_t uid)
Use CreateStopHook to make a new empty stop hook.
Definition Target.h:1498
void GetSubclassDescription(Stream &s, lldb::DescriptionLevel level) const override
Definition Target.cpp:4120
StructuredDataImpl m_extra_args
This holds the dictionary of keys & values that can be used to parametrize any given callback's behav...
Definition Target.h:1492
lldb::ScriptedStopHookInterfaceSP m_interface_sp
Definition Target.h:1493
bool GetRunAtInitialStop() const
Definition Target.h:1429
SymbolContextSpecifier * GetSpecifier()
Definition Target.h:1398
void SetSpecifier(SymbolContextSpecifier *specifier)
Definition Target.cpp:3936
virtual StopHookResult HandleStop(ExecutionContext &exe_ctx, lldb::StreamSP output)=0
std::unique_ptr< ThreadSpec > m_thread_spec_up
Definition Target.h:1444
void SetIsActive(bool is_active)
Definition Target.h:1417
void SetSuppressOutput(bool suppress_output)
Definition Target.h:1431
void SetThreadSpecifier(ThreadSpec *specifier)
Definition Target.cpp:3940
ThreadSpec * GetThreadSpecifier()
Definition Target.h:1413
StopHook(const StopHook &rhs)
Definition Target.cpp:3928
bool ExecutionContextPasses(const ExecutionContext &exe_ctx)
Definition Target.cpp:3944
lldb::TargetSP & GetTarget()
Definition Target.h:1392
void SetRunAtInitialStop(bool at_initial_stop)
Definition Target.h:1425
lldb::SymbolContextSpecifierSP m_specifier_sp
Definition Target.h:1443
virtual void GetSubclassDescription(Stream &s, lldb::DescriptionLevel level) const =0
void GetDescription(Stream &s, lldb::DescriptionLevel level) const
Definition Target.cpp:3960
void SetAutoContinue(bool auto_continue)
Definition Target.h:1419
const ModuleList & GetModuleList() const
Definition Target.h:577
void Dump(Stream *s) const override
Definition Target.cpp:5209
static llvm::StringRef GetFlavorString()
Definition Target.cpp:5205
static ModuleList GetModuleListFromEvent(const Event *event_ptr)
Definition Target.cpp:5238
static const TargetEventData * GetEventDataFromEvent(const Event *event_ptr)
Definition Target.cpp:5219
llvm::StringRef GetFlavor() const override
Definition Target.h:563
const lldb::TargetSP & GetTarget() const
Definition Target.h:575
TargetEventData(const lldb::TargetSP &target_sp)
Definition Target.cpp:5196
TargetEventData(const TargetEventData &)=delete
const TargetEventData & operator=(const TargetEventData &)=delete
static lldb::TargetSP GetTargetFromEvent(const Event *event_ptr)
Definition Target.cpp:5229
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:1857
lldb::ThreadSP CalculateThread() override
Definition Target.cpp:2589
StopHookCollection m_stop_hooks
Definition Target.h:1712
Module * GetExecutableModulePointer()
Definition Target.cpp:1539
void Dump(Stream *s, lldb::DescriptionLevel description_level)
Dump a description of this object to a Stream.
Definition Target.cpp:242
void DisableAllBreakpoints(bool internal_also=false)
Definition Target.cpp:1071
lldb::WatchpointSP CreateWatchpoint(lldb::addr_t addr, size_t size, const CompilerType *type, uint32_t kind, Status &error)
Definition Target.cpp:953
void ApplyNameToBreakpoints(BreakpointName &bp_name)
Definition Target.cpp:907
lldb::TraceSP GetTrace()
Get the Trace object containing processor trace information of this target.
Definition Target.cpp:3595
PathMappingList & GetImageSearchPathList()
Definition Target.cpp:2598
void FinalizeFileActions(ProcessLaunchInfo &info)
Definition Target.cpp:3720
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:2988
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:2996
ModuleList & GetImages()
Definition Target.h:1041
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:759
static Target * GetTargetFromContexts(const ExecutionContext *exe_ctx_ptr, const SymbolContext *sc_ptr)
Definition Target.cpp:2833
lldb::addr_t GetBreakableLoadAddress(lldb::addr_t addr)
Definition Target.cpp:3003
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:3868
bool SetSuppresStopHooks(bool suppress)
Definition Target.h:1556
static void ImageSearchPathsChanged(const PathMappingList &path_list, void *baton)
Definition Target.cpp:2602
llvm::Expected< lldb_private::Address > GetEntryPointAddress()
This method will return the address of the starting function for this binary, e.g.
Definition Target.cpp:2954
bool IgnoreWatchpointByID(lldb::watch_id_t watch_id, uint32_t ignore_count)
Definition Target.cpp:1507
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:725
lldb::BreakpointSP GetBreakpointByID(lldb::break_id_t break_id)
Definition Target.cpp:420
std::shared_ptr< StopHook > StopHookSP
Definition Target.h:1540
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:546
void SymbolsDidLoad(ModuleList &module_list)
Definition Target.cpp:1880
bool ClearAllWatchpointHistoricValues()
Definition Target.cpp:1421
const std::vector< StopHookSP > GetStopHooks(bool internal=false) const
Definition Target.cpp:3116
void SetTrace(const lldb::TraceSP &trace_sp)
Set the Trace object containing processor trace information of this target.
Definition Target.cpp:3593
BreakpointList & GetBreakpointList(bool internal=false)
Definition Target.cpp:406
CompilerType GetRegisterType(const std::string &name, const lldb_private::RegisterFlags &flags, uint32_t byte_size)
Definition Target.cpp:2637
BreakpointNameList m_breakpoint_names
Definition Target.h:1693
lldb_private::SummaryStatisticsCache & GetSummaryStatisticsCache()
Definition Target.cpp:3410
lldb::addr_t GetSectionLoadAddress(const lldb::SectionSP &section_sp)
Definition Target.cpp:5263
llvm::StringRef GetABIName() const
Returns the name of the target's ABI plugin.
Definition Target.cpp:395
SourceManager & GetSourceManager()
Definition Target.cpp:3040
lldb::SearchFilterSP GetSearchFilterForModuleList(const FileSpecList *containingModuleList)
Definition Target.cpp:688
StopHookSP GetStopHookByID(lldb::user_id_t uid)
Definition Target.cpp:3082
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:1732
lldb::ProcessSP m_process_sp
Definition Target.h:1701
Debugger & GetDebugger() const
Definition Target.h:1122
lldb::SearchFilterSP m_search_filter_sp
Definition Target.h:1702
PersistentExpressionState * GetPersistentExpressionStateForLanguage(lldb::LanguageType language)
Definition Target.cpp:2680
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:3856
bool m_is_dummy_target
Used to not run stop hooks for expressions.
Definition Target.h:1719
static bool UpdateSignalFromDummy(lldb::UnixSignalsSP signals_sp, const DummySignalElement &element)
Definition Target.cpp:3814
PathMappingList m_image_search_paths
Definition Target.h:1703
bool ModuleIsExcludedForUnconstrainedSearches(const FileSpec &module_spec)
Return whether this FileSpec corresponds to a module that should be considered for general searches.
Definition Target.cpp:1936
lldb::StackFrameSP CalculateStackFrame() override
Definition Target.cpp:2591
SectionLoadList & GetSectionLoadList()
Definition Target.h:1787
lldb::addr_t GetPersistentSymbol(ConstString name)
Definition Target.cpp:2934
void PrimeFromDummyTarget(Target &target)
Definition Target.cpp:218
static void SettingsTerminate()
Definition Target.cpp:2792
bool EnableWatchpointByID(lldb::watch_id_t watch_id)
Definition Target.cpp:1472
bool ResolveFileAddress(lldb::addr_t load_addr, Address &so_addr)
Definition Target.cpp:3326
bool ClearAllWatchpointHitCounts()
Definition Target.cpp:1407
size_t ReadMemoryFromFileCache(const Address &addr, void *dst, size_t dst_len, Status &error)
Definition Target.cpp:1968
void ClearAllLoadedSections()
Definition Target.cpp:3402
std::vector< lldb::TypeSystemSP > GetScratchTypeSystems(bool create_on_demand=true)
Definition Target.cpp:2646
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:2267
void AddNameToBreakpoint(BreakpointID &id, llvm::StringRef name, Status &error)
Definition Target.cpp:827
bool LoadScriptingResources(std::list< Status > &errors, Stream &feedback_stream, bool continue_on_error=true)
Definition Target.h:1015
void DumpSectionLoadList(Stream &s)
Definition Target.cpp:5269
void DeleteCurrentProcess()
Definition Target.cpp:277
BreakpointList m_internal_breakpoint_list
Definition Target.h:1690
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:2296
void DisableAllowedBreakpoints()
Definition Target.cpp:1081
bool SetSectionUnloaded(const lldb::SectionSP &section_sp)
Definition Target.cpp:3380
lldb::TargetSP CalculateTarget() override
Definition Target.cpp:2585
const lldb::ProcessSP & GetProcessSP() const
Definition Target.cpp:311
void ClearModules(bool delete_locations)
Definition Target.cpp:1561
bool RemoveBreakpointByID(lldb::break_id_t break_id)
Definition Target.cpp:1105
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:2348
static bool ResetSignalFromDummy(lldb::UnixSignalsSP signals_sp, const DummySignalElement &element)
Definition Target.cpp:3841
Architecture * GetArchitecturePlugin() const
Definition Target.h:1120
llvm::json::Value ReportStatistics(const lldb_private::StatisticsOptions &options)
Get metrics associated with this target in JSON format.
Definition Target.cpp:5255
friend class TargetList
Definition Target.h:529
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:2733
TargetStats & GetStatistics()
Definition Target.h:1757
void EnableAllBreakpoints(bool internal_also=false)
Definition Target.cpp:1088
Status Launch(ProcessLaunchInfo &launch_info, Stream *stream)
Definition Target.cpp:3425
bool DisableBreakpointByID(lldb::break_id_t break_id)
Definition Target.cpp:1125
lldb::BreakpointSP CreateBreakpointAtUserEntry(Status &error)
Definition Target.cpp:432
BreakpointName * FindBreakpointName(ConstString name, bool can_create, Status &error)
Definition Target.cpp:859
std::map< lldb::user_id_t, StopHookSP > StopHookCollection
Definition Target.h:1711
llvm::Expected< lldb::TraceSP > CreateTrace()
Create a Trace object for the current target using the using the default supported tracing technology...
Definition Target.cpp:3597
lldb::TraceSP m_trace_sp
The globally unique ID assigned to this target.
Definition Target.h:1726
lldb::user_id_t GetGloballyUniqueID() const
Get the globally unique ID for this target.
Definition Target.h:612
bool RemoveAllWatchpoints(bool end_to_end=true)
Definition Target.cpp:1325
bool ReadPointerFromMemory(const Address &addr, Status &error, Address &pointer_addr, bool force_live_memory=false)
Definition Target.cpp:2318
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:3068
WatchpointList m_watchpoint_list
Definition Target.h:1696
BreakpointList m_breakpoint_list
Definition Target.h:1689
lldb::SourceManagerUP m_source_manager_up
Definition Target.h:1709
bool RemoveWatchpointByID(lldb::watch_id_t watch_id)
Definition Target.cpp:1491
bool ResolveLoadAddress(lldb::addr_t load_addr, Address &so_addr, uint32_t stop_id=SectionLoadHistory::eStopIDNow, bool allow_section_end=false)
Definition Target.cpp:3320
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:2218
void DeleteBreakpointName(ConstString name)
Definition Target.cpp:883
void NotifyWillClearList(const ModuleList &module_list) override
Definition Target.cpp:1819
bool SetArchitecture(const ArchSpec &arch_spec, bool set_platform=false, bool merge=true)
Set the architecture for this target.
Definition Target.cpp:1703
void NotifyModuleAdded(const ModuleList &module_list, const lldb::ModuleSP &module_sp) override
Implementing of ModuleList::Notifier.
Definition Target.cpp:1821
llvm::Expected< lldb::TypeSystemSP > GetScratchTypeSystemForLanguage(lldb::LanguageType language, bool create_on_demand=true)
Definition Target.cpp:2611
void ConfigureBreakpointName(BreakpointName &bp_name, const BreakpointOptions &options, const BreakpointName::Permissions &permissions)
Definition Target.cpp:899
lldb_private::SummaryStatisticsSP GetSummaryStatisticsSPForProviderName(lldb_private::TypeSummaryImpl &summary_provider)
Definition Target.cpp:3404
lldb::SearchFilterSP GetSearchFilterForModuleAndCUList(const FileSpecList *containingModules, const FileSpecList *containingSourceFiles)
Definition Target.cpp:705
lldb::ModuleSP GetExecutableModule()
Gets the module for the main executable.
Definition Target.cpp:1523
bool SetStopHookActiveStateByID(lldb::user_id_t uid, bool active_state)
Definition Target.cpp:3092
const lldb::ProcessSP & CreateProcess(lldb::ListenerSP listener_sp, llvm::StringRef plugin_name, const FileSpec *crash_file, bool can_connect)
Definition Target.cpp:299
void SetAllStopHooksActiveState(bool active_state)
Definition Target.cpp:3103
std::vector< StopHookSP > m_internal_stop_hooks
Definition Target.h:1714
lldb::ExpressionVariableSP GetPersistentVariable(ConstString name)
Definition Target.cpp:2915
void NotifyModulesRemoved(lldb_private::ModuleList &module_list) override
Definition Target.cpp:1853
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:3046
size_t ReadCStringFromMemory(const Address &addr, std::string &out_str, Status &error, bool force_live_memory=false)
Definition Target.cpp:2128
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:1675
lldb::user_id_t m_target_unique_id
Definition Target.h:1721
void ModulesDidUnload(ModuleList &module_list, bool delete_locations)
Definition Target.cpp:1896
void CalculateExecutionContext(ExecutionContext &exe_ctx) override
Reconstruct the object's execution context into sc.
Definition Target.cpp:2593
llvm::Expected< lldb::DisassemblerSP > ReadInstructions(const Address &start_addr, uint32_t count, const char *flavor_string=nullptr)
Definition Target.cpp:3009
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:3622
void NotifyModuleUpdated(const ModuleList &module_list, const lldb::ModuleSP &old_module_sp, const lldb::ModuleSP &new_module_sp) override
Definition Target.cpp:1841
SummaryStatisticsCache m_summary_statistics_cache
Definition Target.h:1687
Target(const Target &)=delete
void RegisterInternalStopHooks()
Status SerializeBreakpointsToFile(const FileSpec &file, const BreakpointIDList &bp_ids, bool append)
Definition Target.cpp:1166
void DidExec()
Called as the last function in Process::DidExec().
Definition Target.cpp:1568
void SaveScriptedLaunchInfo(lldb_private::ProcessInfo &process_info)
Definition Target.cpp:3414
bool GetSuppressStopHooks()
Definition Target.h:1562
std::string m_label
Definition Target.h:1684
lldb::user_id_t m_stop_hook_next_id
Definition Target.h:1713
static FileSpecList GetDefaultExecutableSearchPaths()
Definition Target.cpp:2794
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:742
void NotifyBreakpointChanged(Breakpoint &bp, lldb::BreakpointEventType event_kind)
Sends a breakpoint notification event.
Definition Target.cpp:5273
lldb::SearchFilterSP GetSearchFilterForModule(const FileSpec *containingModule)
Definition Target.cpp:670
llvm::StringMapEntry< DummySignalValues > DummySignalElement
Definition Target.h:1618
std::recursive_mutex & GetAPIMutex()
Definition Target.cpp:5246
static llvm::StringRef GetStaticBroadcasterClass()
Definition Target.cpp:171
static FileSpecList GetDefaultDebugFileSearchPaths()
Definition Target.cpp:2798
void EnableAllowedBreakpoints()
Definition Target.cpp:1098
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:2002
llvm::Error SetLabel(llvm::StringRef label)
Set a label for a target.
Definition Target.cpp:2813
uint32_t m_latest_stop_hook_id
Definition Target.h:1715
StackFrameRecognizerManager & GetFrameRecognizerManager()
Definition Target.h:1600
void RemoveAllowedBreakpoints()
Definition Target.cpp:1050
bool DisableAllWatchpoints(bool end_to_end=true)
Definition Target.cpp:1354
bool RunStopHooks(bool at_initial_stop=false)
Definition Target.cpp:3127
void ClearSectionLoadList()
Definition Target.cpp:5267
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:2205
lldb::PlatformSP m_platform_sp
The platform for this target.
Definition Target.h:1674
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:2763
static TargetProperties & GetGlobalProperties()
Definition Target.cpp:3284
Status Install(ProcessLaunchInfo *launch_info)
Definition Target.cpp:3292
lldb::PlatformSP GetPlatform()
Definition Target.h:1576
void NotifyModuleRemoved(const ModuleList &module_list, const lldb::ModuleSP &module_sp) override
Definition Target.cpp:1831
lldb::BreakpointSP CreateAddressInModuleBreakpoint(lldb::addr_t file_addr, bool internal, const FileSpec &file_spec, bool request_hardware)
Definition Target.cpp:576
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:487
void RemoveAllBreakpoints(bool internal_also=false)
Definition Target.cpp:1059
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:470
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:2802
void ResetBreakpointHitCounts()
Resets the hit count of all breakpoints.
Definition Target.cpp:1162
const ModuleList & GetImages() const
Get accessor for the images for this process.
Definition Target.h:1039
const ArchSpec & GetArchitecture() const
Definition Target.h:1081
WatchpointList & GetWatchpointList()
Definition Target.h:825
@ eBroadcastBitWatchpointChanged
Definition Target.h:537
@ eBroadcastBitBreakpointChanged
Definition Target.h:534
unsigned m_next_persistent_variable_index
Definition Target.h:1720
bool EnableBreakpointByID(lldb::break_id_t break_id)
Definition Target.cpp:1143
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:2307
TargetStats m_stats
Definition Target.h:1740
bool IgnoreAllWatchpoints(uint32_t ignore_count)
Definition Target.cpp:1436
void AddBreakpoint(lldb::BreakpointSP breakpoint_sp, bool internal)
Definition Target.cpp:804
TypeSystemMap m_scratch_type_system_map
Definition Target.h:1704
void AddBreakpointName(std::unique_ptr< BreakpointName > bp_name)
Definition Target.cpp:854
SectionLoadHistory m_section_load_history
Definition Target.h:1688
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:921
bool IsDummyTarget() const
Definition Target.h:601
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:176
size_t UnloadModuleSections(const lldb::ModuleSP &module_sp)
Definition Target.cpp:3361
const std::string & GetLabel() const
Definition Target.h:614
bool m_valid
This records the last natural stop at which we ran a stop-hook.
Definition Target.h:1717
bool DisableWatchpointByID(lldb::watch_id_t watch_id)
Definition Target.cpp:1453
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:3799
std::map< ConstString, std::unique_ptr< BreakpointName > > BreakpointNameList
Definition Target.h:1691
lldb::WatchpointSP m_last_created_watchpoint
Definition Target.h:1697
Status CreateBreakpointsFromFile(const FileSpec &file, BreakpointIDList &new_bps)
Definition Target.cpp:1258
Debugger & m_debugger
Definition Target.h:1673
void SetREPL(lldb::LanguageType language, lldb::REPLSP repl_sp)
Definition Target.cpp:364
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:1574
lldb::StackFrameRecognizerManagerUP m_frame_recognizer_manager_up
Stores the frame recognizers of this target.
Definition Target.h:1728
lldb::REPLSP GetREPL(Status &err, lldb::LanguageType language, const char *repl_options, bool can_create)
Definition Target.cpp:313
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:2700
ModuleList m_images
The list of images for this process (shared libraries and anything dynamically loaded).
Definition Target.h:1685
lldb::ProcessSP CalculateProcess() override
Definition Target.cpp:2587
void PrintDummySignals(Stream &strm, Args &signals)
Print all the signals set in this target.
Definition Target.cpp:3893
void SetPlatform(const lldb::PlatformSP &platform_sp)
Definition Target.h:1578
bool SetSectionLoadAddress(const lldb::SectionSP &section, lldb::addr_t load_addr, bool warn_multiple=false)
Definition Target.cpp:3331
Status Attach(ProcessAttachInfo &attach_info, Stream *stream)
Definition Target.cpp:3628
std::map< lldb::LanguageType, lldb::REPLSP > REPLMap
Definition Target.h:1706
static void SetDefaultArchitecture(const ArchSpec &arch)
Definition Target.cpp:2806
lldb::BreakpointSP m_last_created_breakpoint
Definition Target.h:1695
lldb::WatchpointSP GetLastCreatedWatchpoint()
Definition Target.h:821
void RemoveNameFromBreakpoint(lldb::BreakpointSP &bp_sp, ConstString name)
Definition Target.cpp:894
bool RemoveStopHookByID(lldb::user_id_t uid)
Definition Target.cpp:3075
friend class Debugger
Definition Target.h:530
lldb::BreakpointSP GetLastCreatedBreakpoint()
Definition Target.h:713
static void SettingsInitialize()
Definition Target.cpp:2790
~Target() override
Definition Target.cpp:212
bool EnableAllWatchpoints(bool end_to_end=true)
Definition Target.cpp:1381
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:1682
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:2847
bool MergeArchitecture(const ArchSpec &arch_spec)
Definition Target.cpp:1794
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:54
@ eLoadScriptFromSymFileTrue
Definition Target.h:55
@ eLoadScriptFromSymFileFalse
Definition Target.h:56
@ eLoadScriptFromSymFileWarn
Definition Target.h:57
ExecutionPolicy
Expression execution policies.
DynamicClassInfoHelper
Definition Target.h:72
@ eDynamicClassInfoHelperCopyRealizedClassList
Definition Target.h:75
@ eDynamicClassInfoHelperGetRealizedClassList
Definition Target.h:76
@ eDynamicClassInfoHelperAuto
Definition Target.h:73
@ eDynamicClassInfoHelperRealizedClassesStruct
Definition Target.h:74
OptionEnumValues GetDynamicValueTypes()
Definition Target.cpp:4178
@ eImportStdModuleFalse
Definition Target.h:67
@ eImportStdModuleFallback
Definition Target.h:68
@ eImportStdModuleTrue
Definition Target.h:69
LoadCWDlldbinitFile
Definition Target.h:60
@ eLoadCWDlldbinitTrue
Definition Target.h:61
@ eLoadCWDlldbinitFalse
Definition Target.h:62
@ eLoadCWDlldbinitWarn
Definition Target.h:63
llvm::ArrayRef< OptionEnumValueElement > OptionEnumValues
@ eInlineBreakpointsNever
Definition Target.h:49
@ eInlineBreakpointsAlways
Definition Target.h:51
@ eInlineBreakpointsHeaders
Definition Target.h:50
ExpressionEvaluationPhase
Expression Evaluation Stages.
std::shared_ptr< lldb_private::Trace > TraceSP
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
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:86
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:87
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
A type-erased pair of llvm::dwarf::SourceLanguageName and version.
DummySignalValues(LazyBool pass, LazyBool notify, LazyBool stop)
Definition Target.h:1614
UserID(lldb::user_id_t uid=LLDB_INVALID_UID)
Construct with optional user ID.
Definition UserID.h:33