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 const std::string &GetLabel() const { return m_label; }
604
605 /// Set a label for a target.
606 ///
607 /// The label cannot be used by another target or be only integral.
608 ///
609 /// \return
610 /// The label for this target or an error if the label didn't match the
611 /// requirements.
612 llvm::Error SetLabel(llvm::StringRef label);
613
614 /// Find a binary on the system and return its Module,
615 /// or return an existing Module that is already in the Target.
616 ///
617 /// Given a ModuleSpec, find a binary satisifying that specification,
618 /// or identify a matching Module already present in the Target,
619 /// and return a shared pointer to it.
620 ///
621 /// \param[in] module_spec
622 /// The criteria that must be matched for the binary being loaded.
623 /// e.g. UUID, architecture, file path.
624 ///
625 /// \param[in] notify
626 /// If notify is true, and the Module is new to this Target,
627 /// Target::ModulesDidLoad will be called.
628 /// If notify is false, it is assumed that the caller is adding
629 /// multiple Modules and will call ModulesDidLoad with the
630 /// full list at the end.
631 /// ModulesDidLoad must be called when a Module/Modules have
632 /// been added to the target, one way or the other.
633 ///
634 /// \param[out] error_ptr
635 /// Optional argument, pointing to a Status object to fill in
636 /// with any results / messages while attempting to find/load
637 /// this binary. Many callers will be internal functions that
638 /// will handle / summarize the failures in a custom way and
639 /// don't use these messages.
640 ///
641 /// \return
642 /// An empty ModuleSP will be returned if no matching file
643 /// was found. If error_ptr was non-nullptr, an error message
644 /// will likely be provided.
645 lldb::ModuleSP GetOrCreateModule(const ModuleSpec &module_spec, bool notify,
646 Status *error_ptr = nullptr);
647
648 // Settings accessors
649
651
652 std::recursive_mutex &GetAPIMutex();
653
655
656 void CleanupProcess();
657
658 /// Dump a description of this object to a Stream.
659 ///
660 /// Dump a description of the contents of this object to the
661 /// supplied stream \a s. The dumped content will be only what has
662 /// been loaded or parsed up to this point at which this function
663 /// is called, so this is a good way to see what has been parsed
664 /// in a target.
665 ///
666 /// \param[in] s
667 /// The stream to which to dump the object description.
668 void Dump(Stream *s, lldb::DescriptionLevel description_level);
669
670 // If listener_sp is null, the listener of the owning Debugger object will be
671 // used.
673 llvm::StringRef plugin_name,
674 const FileSpec *crash_file,
675 bool can_connect);
676
677 const lldb::ProcessSP &GetProcessSP() const;
678
679 bool IsValid() { return m_valid; }
680
681 void Destroy();
682
683 Status Launch(ProcessLaunchInfo &launch_info,
684 Stream *stream); // Optional stream to receive first stop info
685
686 Status Attach(ProcessAttachInfo &attach_info,
687 Stream *stream); // Optional stream to receive first stop info
688
689 // This part handles the breakpoints.
690
691 BreakpointList &GetBreakpointList(bool internal = false);
692
693 const BreakpointList &GetBreakpointList(bool internal = false) const;
694
698
700
702
703 // Use this to create a file and line breakpoint to a given module or all
704 // module it is nullptr
705 lldb::BreakpointSP CreateBreakpoint(const FileSpecList *containingModules,
706 const FileSpec &file, uint32_t line_no,
707 uint32_t column, lldb::addr_t offset,
708 LazyBool check_inlines,
709 LazyBool skip_prologue, bool internal,
710 bool request_hardware,
711 LazyBool move_to_nearest_code);
712
713 // Use this to create breakpoint that matches regex against the source lines
714 // in files given in source_file_list: If function_names is non-empty, also
715 // filter by function after the matches are made.
717 const FileSpecList *containingModules,
718 const FileSpecList *source_file_list,
719 const std::unordered_set<std::string> &function_names,
720 RegularExpression source_regex, bool internal, bool request_hardware,
721 LazyBool move_to_nearest_code);
722
723 // Use this to create a breakpoint from a load address
724 lldb::BreakpointSP CreateBreakpoint(lldb::addr_t load_addr, bool internal,
725 bool request_hardware);
726
727 // Use this to create a breakpoint from a file address and a module file spec
729 bool internal,
730 const FileSpec &file_spec,
731 bool request_hardware);
732
733 // Use this to create Address breakpoints:
734 lldb::BreakpointSP CreateBreakpoint(const Address &addr, bool internal,
735 bool request_hardware);
736
737 // Use this to create a function breakpoint by regexp in
738 // containingModule/containingSourceFiles, or all modules if it is nullptr
739 // When "skip_prologue is set to eLazyBoolCalculate, we use the current
740 // target setting, else we use the values passed in
742 const FileSpecList *containingModules,
743 const FileSpecList *containingSourceFiles, RegularExpression func_regexp,
744 lldb::LanguageType requested_language, LazyBool skip_prologue,
745 bool internal, bool request_hardware);
746
747 // Use this to create a function breakpoint by name in containingModule, or
748 // all modules if it is nullptr When "skip_prologue is set to
749 // eLazyBoolCalculate, we use the current target setting, else we use the
750 // values passed in. func_name_type_mask is or'ed values from the
751 // FunctionNameType enum.
753 const FileSpecList *containingModules,
754 const FileSpecList *containingSourceFiles, const char *func_name,
755 lldb::FunctionNameType func_name_type_mask, lldb::LanguageType language,
756 lldb::addr_t offset, bool offset_is_insn_count, LazyBool skip_prologue,
757 bool internal, bool request_hardware);
758
760 CreateExceptionBreakpoint(enum lldb::LanguageType language, bool catch_bp,
761 bool throw_bp, bool internal,
762 Args *additional_args = nullptr,
763 Status *additional_args_error = nullptr);
764
766 const llvm::StringRef class_name, const FileSpecList *containingModules,
767 const FileSpecList *containingSourceFiles, bool internal,
768 bool request_hardware, StructuredData::ObjectSP extra_args_sp,
769 Status *creation_error = nullptr);
770
771 // This is the same as the func_name breakpoint except that you can specify a
772 // vector of names. This is cheaper than a regular expression breakpoint in
773 // the case where you just want to set a breakpoint on a set of names you
774 // already know. func_name_type_mask is or'ed values from the
775 // FunctionNameType enum.
777 const FileSpecList *containingModules,
778 const FileSpecList *containingSourceFiles, const char *func_names[],
779 size_t num_names, lldb::FunctionNameType func_name_type_mask,
780 lldb::LanguageType language, lldb::addr_t offset, LazyBool skip_prologue,
781 bool internal, bool request_hardware);
782
784 CreateBreakpoint(const FileSpecList *containingModules,
785 const FileSpecList *containingSourceFiles,
786 const std::vector<std::string> &func_names,
787 lldb::FunctionNameType func_name_type_mask,
788 lldb::LanguageType language, lldb::addr_t m_offset,
789 LazyBool skip_prologue, bool internal,
790 bool request_hardware);
791
792 // Use this to create a general breakpoint:
794 lldb::BreakpointResolverSP &resolver_sp,
795 bool internal, bool request_hardware,
796 bool resolve_indirect_symbols);
797
798 // Use this to create a watchpoint:
800 const CompilerType *type, uint32_t kind,
801 Status &error);
802
806
808
809 // Manages breakpoint names:
810 void AddNameToBreakpoint(BreakpointID &id, llvm::StringRef name,
811 Status &error);
812
813 void AddNameToBreakpoint(lldb::BreakpointSP &bp_sp, llvm::StringRef name,
814 Status &error);
815
817
818 BreakpointName *FindBreakpointName(ConstString name, bool can_create,
819 Status &error);
820
822
824 const BreakpointOptions &options,
825 const BreakpointName::Permissions &permissions);
827
828 void AddBreakpointName(std::unique_ptr<BreakpointName> bp_name);
829
830 void GetBreakpointNames(std::vector<std::string> &names);
831
832 // This call removes ALL breakpoints regardless of permission.
833 void RemoveAllBreakpoints(bool internal_also = false);
834
835 // This removes all the breakpoints, but obeys the ePermDelete on them.
837
838 void DisableAllBreakpoints(bool internal_also = false);
839
841
842 void EnableAllBreakpoints(bool internal_also = false);
843
845
847
849
851
852 /// Resets the hit count of all breakpoints.
854
855 // The flag 'end_to_end', default to true, signifies that the operation is
856 // performed end to end, for both the debugger and the debuggee.
857
858 bool RemoveAllWatchpoints(bool end_to_end = true);
859
860 bool DisableAllWatchpoints(bool end_to_end = true);
861
862 bool EnableAllWatchpoints(bool end_to_end = true);
863
865
867
868 bool IgnoreAllWatchpoints(uint32_t ignore_count);
869
871
873
875
876 bool IgnoreWatchpointByID(lldb::watch_id_t watch_id, uint32_t ignore_count);
877
879 const BreakpointIDList &bp_ids,
880 bool append);
881
883 BreakpointIDList &new_bps);
884
886 std::vector<std::string> &names,
887 BreakpointIDList &new_bps);
888
889 /// Get \a load_addr as a callable code load address for this target
890 ///
891 /// Take \a load_addr and potentially add any address bits that are
892 /// needed to make the address callable. For ARM this can set bit
893 /// zero (if it already isn't) if \a load_addr is a thumb function.
894 /// If \a addr_class is set to AddressClass::eInvalid, then the address
895 /// adjustment will always happen. If it is set to an address class
896 /// that doesn't have code in it, LLDB_INVALID_ADDRESS will be
897 /// returned.
899 lldb::addr_t load_addr,
900 AddressClass addr_class = AddressClass::eInvalid) const;
901
902 /// Get \a load_addr as an opcode for this target.
903 ///
904 /// Take \a load_addr and potentially strip any address bits that are
905 /// needed to make the address point to an opcode. For ARM this can
906 /// clear bit zero (if it already isn't) if \a load_addr is a
907 /// thumb function and load_addr is in code.
908 /// If \a addr_class is set to AddressClass::eInvalid, then the address
909 /// adjustment will always happen. If it is set to an address class
910 /// that doesn't have code in it, LLDB_INVALID_ADDRESS will be
911 /// returned.
914 AddressClass addr_class = AddressClass::eInvalid) const;
915
916 // Get load_addr as breakable load address for this target. Take a addr and
917 // check if for any reason there is a better address than this to put a
918 // breakpoint on. If there is then return that address. For MIPS, if
919 // instruction at addr is a delay slot instruction then this method will find
920 // the address of its previous instruction and return that address.
922
923 void ModulesDidLoad(ModuleList &module_list);
924
925 void ModulesDidUnload(ModuleList &module_list, bool delete_locations);
926
927 void SymbolsDidLoad(ModuleList &module_list);
928
929 void ClearModules(bool delete_locations);
930
931 /// Called as the last function in Process::DidExec().
932 ///
933 /// Process::DidExec() will clear a lot of state in the process,
934 /// then try to reload a dynamic loader plugin to discover what
935 /// binaries are currently available and then this function should
936 /// be called to allow the target to do any cleanup after everything
937 /// has been figured out. It can remove breakpoints that no longer
938 /// make sense as the exec might have changed the target
939 /// architecture, and unloaded some modules that might get deleted.
940 void DidExec();
941
942 /// Gets the module for the main executable.
943 ///
944 /// Each process has a notion of a main executable that is the file
945 /// that will be executed or attached to. Executable files can have
946 /// dependent modules that are discovered from the object files, or
947 /// discovered at runtime as things are dynamically loaded.
948 ///
949 /// \return
950 /// The shared pointer to the executable module which can
951 /// contains a nullptr Module object if no executable has been
952 /// set.
953 ///
954 /// \see DynamicLoader
955 /// \see ObjectFile::GetDependentModules (FileSpecList&)
956 /// \see Process::SetExecutableModule(lldb::ModuleSP&)
958
960
961 /// Set the main executable module.
962 ///
963 /// Each process has a notion of a main executable that is the file
964 /// that will be executed or attached to. Executable files can have
965 /// dependent modules that are discovered from the object files, or
966 /// discovered at runtime as things are dynamically loaded.
967 ///
968 /// Setting the executable causes any of the current dependent
969 /// image information to be cleared and replaced with the static
970 /// dependent image information found by calling
971 /// ObjectFile::GetDependentModules (FileSpecList&) on the main
972 /// executable and any modules on which it depends. Calling
973 /// Process::GetImages() will return the newly found images that
974 /// were obtained from all of the object files.
975 ///
976 /// \param[in] module_sp
977 /// A shared pointer reference to the module that will become
978 /// the main executable for this process.
979 ///
980 /// \param[in] load_dependent_files
981 /// If \b true then ask the object files to track down any
982 /// known dependent files.
983 ///
984 /// \see ObjectFile::GetDependentModules (FileSpecList&)
985 /// \see Process::GetImages()
987 lldb::ModuleSP &module_sp,
988 LoadDependentFiles load_dependent_files = eLoadDependentsDefault);
989
990 bool LoadScriptingResources(std::list<Status> &errors,
991 Stream &feedback_stream,
992 bool continue_on_error = true) {
993 return m_images.LoadScriptingResourcesInTarget(
994 this, errors, feedback_stream, continue_on_error);
995 }
996
997 /// Get accessor for the images for this process.
998 ///
999 /// Each process has a notion of a main executable that is the file
1000 /// that will be executed or attached to. Executable files can have
1001 /// dependent modules that are discovered from the object files, or
1002 /// discovered at runtime as things are dynamically loaded. After
1003 /// a main executable has been set, the images will contain a list
1004 /// of all the files that the executable depends upon as far as the
1005 /// object files know. These images will usually contain valid file
1006 /// virtual addresses only. When the process is launched or attached
1007 /// to, the DynamicLoader plug-in will discover where these images
1008 /// were loaded in memory and will resolve the load virtual
1009 /// addresses is each image, and also in images that are loaded by
1010 /// code.
1011 ///
1012 /// \return
1013 /// A list of Module objects in a module list.
1014 const ModuleList &GetImages() const { return m_images; }
1015
1017
1018 /// Return whether this FileSpec corresponds to a module that should be
1019 /// considered for general searches.
1020 ///
1021 /// This API will be consulted by the SearchFilterForUnconstrainedSearches
1022 /// and any module that returns \b true will not be searched. Note the
1023 /// SearchFilterForUnconstrainedSearches is the search filter that
1024 /// gets used in the CreateBreakpoint calls when no modules is provided.
1025 ///
1026 /// The target call at present just consults the Platform's call of the
1027 /// same name.
1028 ///
1029 /// \param[in] module_spec
1030 /// Path to the module.
1031 ///
1032 /// \return \b true if the module should be excluded, \b false otherwise.
1033 bool ModuleIsExcludedForUnconstrainedSearches(const FileSpec &module_spec);
1034
1035 /// Return whether this module should be considered for general searches.
1036 ///
1037 /// This API will be consulted by the SearchFilterForUnconstrainedSearches
1038 /// and any module that returns \b true will not be searched. Note the
1039 /// SearchFilterForUnconstrainedSearches is the search filter that
1040 /// gets used in the CreateBreakpoint calls when no modules is provided.
1041 ///
1042 /// The target call at present just consults the Platform's call of the
1043 /// same name.
1044 ///
1045 /// FIXME: When we get time we should add a way for the user to set modules
1046 /// that they
1047 /// don't want searched, in addition to or instead of the platform ones.
1048 ///
1049 /// \param[in] module_sp
1050 /// A shared pointer reference to the module that checked.
1051 ///
1052 /// \return \b true if the module should be excluded, \b false otherwise.
1053 bool
1055
1056 const ArchSpec &GetArchitecture() const { return m_arch.GetSpec(); }
1057
1058 /// Returns the name of the target's ABI plugin.
1059 llvm::StringRef GetABIName() const;
1060
1061 /// Set the architecture for this target.
1062 ///
1063 /// If the current target has no Images read in, then this just sets the
1064 /// architecture, which will be used to select the architecture of the
1065 /// ExecutableModule when that is set. If the current target has an
1066 /// ExecutableModule, then calling SetArchitecture with a different
1067 /// architecture from the currently selected one will reset the
1068 /// ExecutableModule to that slice of the file backing the ExecutableModule.
1069 /// If the file backing the ExecutableModule does not contain a fork of this
1070 /// architecture, then this code will return false, and the architecture
1071 /// won't be changed. If the input arch_spec is the same as the already set
1072 /// architecture, this is a no-op.
1073 ///
1074 /// \param[in] arch_spec
1075 /// The new architecture.
1076 ///
1077 /// \param[in] set_platform
1078 /// If \b true, then the platform will be adjusted if the currently
1079 /// selected platform is not compatible with the architecture being set.
1080 /// If \b false, then just the architecture will be set even if the
1081 /// currently selected platform isn't compatible (in case it might be
1082 /// manually set following this function call).
1083 ///
1084 /// \param[in] merged
1085 /// If true, arch_spec is merged with the current
1086 /// architecture. Otherwise it's replaced.
1087 ///
1088 /// \return
1089 /// \b true if the architecture was successfully set, \b false otherwise.
1090 bool SetArchitecture(const ArchSpec &arch_spec, bool set_platform = false,
1091 bool merge = true);
1092
1093 bool MergeArchitecture(const ArchSpec &arch_spec);
1094
1095 Architecture *GetArchitecturePlugin() const { return m_arch.GetPlugin(); }
1096
1097 Debugger &GetDebugger() const { return m_debugger; }
1098
1099 size_t ReadMemoryFromFileCache(const Address &addr, void *dst, size_t dst_len,
1100 Status &error);
1101
1102 // Reading memory through the target allows us to skip going to the process
1103 // for reading memory if possible and it allows us to try and read from any
1104 // constant sections in our object files on disk. If you always want live
1105 // program memory, read straight from the process. If you possibly want to
1106 // read from const sections in object files, read from the target. This
1107 // version of ReadMemory will try and read memory from the process if the
1108 // process is alive. The order is:
1109 // 1 - if (force_live_memory == false) and the address falls in a read-only
1110 // section, then read from the file cache
1111 // 2 - if there is a process, then read from memory
1112 // 3 - if there is no process, then read from the file cache
1113 //
1114 // If did_read_live_memory is provided, will indicate if the read was from
1115 // live memory, or from file contents. A caller which needs to treat these two
1116 // sources differently should use this argument to disambiguate where the data
1117 // was read from.
1118 //
1119 // The method is virtual for mocking in the unit tests.
1120 virtual size_t ReadMemory(const Address &addr, void *dst, size_t dst_len,
1121 Status &error, bool force_live_memory = false,
1122 lldb::addr_t *load_addr_ptr = nullptr,
1123 bool *did_read_live_memory = nullptr);
1124
1125 size_t ReadCStringFromMemory(const Address &addr, std::string &out_str,
1126 Status &error, bool force_live_memory = false);
1127
1128 size_t ReadCStringFromMemory(const Address &addr, char *dst,
1129 size_t dst_max_len, Status &result_error,
1130 bool force_live_memory = false);
1131
1132 /// Read a NULL terminated string from memory
1133 ///
1134 /// This function will read a cache page at a time until a NULL string
1135 /// terminator is found. It will stop reading if an aligned sequence of NULL
1136 /// termination \a type_width bytes is not found before reading \a
1137 /// cstr_max_len bytes. The results are always guaranteed to be NULL
1138 /// terminated, and that no more than (max_bytes - type_width) bytes will be
1139 /// read.
1140 ///
1141 /// \param[in] addr
1142 /// The address to start the memory read.
1143 ///
1144 /// \param[in] dst
1145 /// A character buffer containing at least max_bytes.
1146 ///
1147 /// \param[in] max_bytes
1148 /// The maximum number of bytes to read.
1149 ///
1150 /// \param[in] error
1151 /// The error status of the read operation.
1152 ///
1153 /// \param[in] type_width
1154 /// The size of the null terminator (1 to 4 bytes per
1155 /// character). Defaults to 1.
1156 ///
1157 /// \return
1158 /// The error status or the number of bytes prior to the null terminator.
1159 size_t ReadStringFromMemory(const Address &addr, char *dst, size_t max_bytes,
1160 Status &error, size_t type_width,
1161 bool force_live_memory = true);
1162
1163 size_t ReadScalarIntegerFromMemory(const Address &addr, uint32_t byte_size,
1164 bool is_signed, Scalar &scalar,
1165 Status &error,
1166 bool force_live_memory = false);
1167
1168 int64_t ReadSignedIntegerFromMemory(const Address &addr,
1169 size_t integer_byte_size,
1170 int64_t fail_value, Status &error,
1171 bool force_live_memory = false);
1172
1173 uint64_t ReadUnsignedIntegerFromMemory(const Address &addr,
1174 size_t integer_byte_size,
1175 uint64_t fail_value, Status &error,
1176 bool force_live_memory = false);
1177
1178 bool ReadPointerFromMemory(const Address &addr, Status &error,
1179 Address &pointer_addr,
1180 bool force_live_memory = false);
1181
1182 bool HasLoadedSections();
1183
1185
1186 void ClearSectionLoadList();
1187
1188 void DumpSectionLoadList(Stream &s);
1189
1190 static Target *GetTargetFromContexts(const ExecutionContext *exe_ctx_ptr,
1191 const SymbolContext *sc_ptr);
1192
1193 // lldb::ExecutionContextScope pure virtual functions
1195
1197
1199
1201
1202 void CalculateExecutionContext(ExecutionContext &exe_ctx) override;
1203
1205
1206 llvm::Expected<lldb::TypeSystemSP>
1208 bool create_on_demand = true);
1209
1210 std::vector<lldb::TypeSystemSP>
1211 GetScratchTypeSystems(bool create_on_demand = true);
1212
1215
1216 // Creates a UserExpression for the given language, the rest of the
1217 // parameters have the same meaning as for the UserExpression constructor.
1218 // Returns a new-ed object which the caller owns.
1219
1221 GetUserExpressionForLanguage(llvm::StringRef expr, llvm::StringRef prefix,
1222 SourceLanguage language,
1223 Expression::ResultType desired_type,
1224 const EvaluateExpressionOptions &options,
1225 ValueObject *ctx_obj, Status &error);
1226
1227 // Creates a FunctionCaller for the given language, the rest of the
1228 // parameters have the same meaning as for the FunctionCaller constructor.
1229 // Since a FunctionCaller can't be
1230 // IR Interpreted, it makes no sense to call this with an
1231 // ExecutionContextScope that lacks
1232 // a Process.
1233 // Returns a new-ed object which the caller owns.
1234
1236 const CompilerType &return_type,
1237 const Address &function_address,
1238 const ValueList &arg_value_list,
1239 const char *name, Status &error);
1240
1241 /// Creates and installs a UtilityFunction for the given language.
1242 llvm::Expected<std::unique_ptr<UtilityFunction>>
1243 CreateUtilityFunction(std::string expression, std::string name,
1244 lldb::LanguageType language, ExecutionContext &exe_ctx);
1245
1246 // Install any files through the platform that need be to installed prior to
1247 // launching or attaching.
1248 Status Install(ProcessLaunchInfo *launch_info);
1249
1250 bool ResolveFileAddress(lldb::addr_t load_addr, Address &so_addr);
1251
1252 bool ResolveLoadAddress(lldb::addr_t load_addr, Address &so_addr,
1253 uint32_t stop_id = SectionLoadHistory::eStopIDNow,
1254 bool allow_section_end = false);
1255
1256 bool SetSectionLoadAddress(const lldb::SectionSP &section,
1257 lldb::addr_t load_addr,
1258 bool warn_multiple = false);
1259
1260 size_t UnloadModuleSections(const lldb::ModuleSP &module_sp);
1261
1262 size_t UnloadModuleSections(const ModuleList &module_list);
1263
1264 bool SetSectionUnloaded(const lldb::SectionSP &section_sp);
1265
1266 bool SetSectionUnloaded(const lldb::SectionSP &section_sp,
1267 lldb::addr_t load_addr);
1268
1270
1272 lldb_private::TypeSummaryImpl &summary_provider);
1274
1275 /// Set the \a Trace object containing processor trace information of this
1276 /// target.
1277 ///
1278 /// \param[in] trace_sp
1279 /// The trace object.
1280 void SetTrace(const lldb::TraceSP &trace_sp);
1281
1282 /// Get the \a Trace object containing processor trace information of this
1283 /// target.
1284 ///
1285 /// \return
1286 /// The trace object. It might be undefined.
1288
1289 /// Create a \a Trace object for the current target using the using the
1290 /// default supported tracing technology for this process.
1291 ///
1292 /// \return
1293 /// The new \a Trace or an \a llvm::Error if a \a Trace already exists or
1294 /// the trace couldn't be created.
1295 llvm::Expected<lldb::TraceSP> CreateTrace();
1296
1297 /// If a \a Trace object is present, this returns it, otherwise a new Trace is
1298 /// created with \a Trace::CreateTrace.
1299 llvm::Expected<lldb::TraceSP> GetTraceOrCreate();
1300
1301 // Since expressions results can persist beyond the lifetime of a process,
1302 // and the const expression results are available after a process is gone, we
1303 // provide a way for expressions to be evaluated from the Target itself. If
1304 // an expression is going to be run, then it should have a frame filled in in
1305 // the execution context.
1307 llvm::StringRef expression, ExecutionContextScope *exe_scope,
1308 lldb::ValueObjectSP &result_valobj_sp,
1310 std::string *fixed_expression = nullptr, ValueObject *ctx_obj = nullptr);
1311
1313
1315
1316 /// This method will return the address of the starting function for
1317 /// this binary, e.g. main() or its equivalent. This can be used as
1318 /// an address of a function that is not called once a binary has
1319 /// started running - e.g. as a return address for inferior function
1320 /// calls that are unambiguous completion of the function call, not
1321 /// called during the course of the inferior function code running.
1322 ///
1323 /// If no entry point can be found, an invalid address is returned.
1324 ///
1325 /// \param [out] err
1326 /// This object will be set to failure if no entry address could
1327 /// be found, and may contain a helpful error message.
1328 //
1329 /// \return
1330 /// Returns the entry address for this program, or an error
1331 /// if none can be found.
1332 llvm::Expected<lldb_private::Address> GetEntryPointAddress();
1333
1334 CompilerType GetRegisterType(const std::string &name,
1335 const lldb_private::RegisterFlags &flags,
1336 uint32_t byte_size);
1337
1338 llvm::Expected<lldb::DisassemblerSP>
1339 ReadInstructions(const Address &start_addr, uint32_t count,
1340 const char *flavor_string = nullptr);
1341
1342 // Target Stop Hooks
1343 class StopHook : public UserID {
1344 public:
1345 StopHook(const StopHook &rhs);
1346 virtual ~StopHook() = default;
1347
1348 enum class StopHookKind : uint32_t { CommandBased = 0, ScriptBased };
1355
1357
1358 // Set the specifier. The stop hook will own the specifier, and is
1359 // responsible for deleting it when we're done.
1360 void SetSpecifier(SymbolContextSpecifier *specifier);
1361
1363
1364 bool ExecutionContextPasses(const ExecutionContext &exe_ctx);
1365
1366 // Called on stop, this gets passed the ExecutionContext for each "stop
1367 // with a reason" thread. It should add to the stream whatever text it
1368 // wants to show the user, and return False to indicate it wants the target
1369 // not to stop.
1371 lldb::StreamSP output) = 0;
1372
1373 // Set the Thread Specifier. The stop hook will own the thread specifier,
1374 // and is responsible for deleting it when we're done.
1375 void SetThreadSpecifier(ThreadSpec *specifier);
1376
1378
1379 bool IsActive() { return m_active; }
1380
1381 void SetIsActive(bool is_active) { m_active = is_active; }
1382
1383 void SetAutoContinue(bool auto_continue) {
1384 m_auto_continue = auto_continue;
1385 }
1386
1387 bool GetAutoContinue() const { return m_auto_continue; }
1388
1389 void SetRunAtInitialStop(bool at_initial_stop) {
1390 m_at_initial_stop = at_initial_stop;
1391 }
1392
1394
1395 void GetDescription(Stream &s, lldb::DescriptionLevel level) const;
1397 lldb::DescriptionLevel level) const = 0;
1398
1399 protected:
1402 std::unique_ptr<ThreadSpec> m_thread_spec_up;
1403 bool m_active = true;
1404 bool m_auto_continue = false;
1406
1407 StopHook(lldb::TargetSP target_sp, lldb::user_id_t uid);
1408 };
1409
1411 public:
1412 ~StopHookCommandLine() override = default;
1413
1415 void SetActionFromString(const std::string &strings);
1416 void SetActionFromStrings(const std::vector<std::string> &strings);
1417
1419 lldb::StreamSP output_sp) override;
1421 lldb::DescriptionLevel level) const override;
1422
1423 private:
1425 // Use CreateStopHook to make a new empty stop hook. The GetCommandPointer
1426 // and fill it with commands, and SetSpecifier to set the specifier shared
1427 // pointer (can be null, that will match anything.)
1429 : StopHook(target_sp, uid) {}
1430 friend class Target;
1431 };
1432
1434 public:
1435 ~StopHookScripted() override = default;
1437 lldb::StreamSP output) override;
1438
1439 Status SetScriptCallback(std::string class_name,
1440 StructuredData::ObjectSP extra_args_sp);
1441
1443 lldb::DescriptionLevel level) const override;
1444
1445 private:
1446 std::string m_class_name;
1447 /// This holds the dictionary of keys & values that can be used to
1448 /// parametrize any given callback's behavior.
1451
1452 /// Use CreateStopHook to make a new empty stop hook. The GetCommandPointer
1453 /// and fill it with commands, and SetSpecifier to set the specifier shared
1454 /// pointer (can be null, that will match anything.)
1456 : StopHook(target_sp, uid) {}
1457 friend class Target;
1458 };
1459
1460 typedef std::shared_ptr<StopHook> StopHookSP;
1461
1462 /// Add an empty stop hook to the Target's stop hook list, and returns a
1463 /// shared pointer to it in new_hook. Returns the id of the new hook.
1465
1466 /// If you tried to create a stop hook, and that failed, call this to
1467 /// remove the stop hook, as it will also reset the stop hook counter.
1469
1470 // Runs the stop hooks that have been registered for this target.
1471 // Returns true if the stop hooks cause the target to resume.
1472 // Pass at_initial_stop if this is the stop where lldb gains
1473 // control over the process for the first time.
1474 bool RunStopHooks(bool at_initial_stop = false);
1475
1477
1478 bool SetSuppresStopHooks(bool suppress) {
1479 bool old_value = m_suppress_stop_hooks;
1480 m_suppress_stop_hooks = suppress;
1481 return old_value;
1482 }
1483
1485
1487
1488 void RemoveAllStopHooks();
1489
1490 StopHookSP GetStopHookByID(lldb::user_id_t uid);
1491
1492 bool SetStopHookActiveStateByID(lldb::user_id_t uid, bool active_state);
1493
1494 void SetAllStopHooksActiveState(bool active_state);
1495
1496 size_t GetNumStopHooks() const { return m_stop_hooks.size(); }
1497
1499 if (index >= GetNumStopHooks())
1500 return StopHookSP();
1501 StopHookCollection::iterator pos = m_stop_hooks.begin();
1502
1503 while (index > 0) {
1504 pos++;
1505 index--;
1506 }
1507 return (*pos).second;
1508 }
1509
1511
1512 void SetPlatform(const lldb::PlatformSP &platform_sp) {
1513 m_platform_sp = platform_sp;
1514 }
1515
1517
1518 // Methods.
1520 GetSearchFilterForModule(const FileSpec *containingModule);
1521
1523 GetSearchFilterForModuleList(const FileSpecList *containingModuleList);
1524
1526 GetSearchFilterForModuleAndCUList(const FileSpecList *containingModules,
1527 const FileSpecList *containingSourceFiles);
1528
1530 const char *repl_options, bool can_create);
1531
1532 void SetREPL(lldb::LanguageType language, lldb::REPLSP repl_sp);
1533
1537
1539
1540 /// Add a signal for the target. This will get copied over to the process
1541 /// if the signal exists on that target. Only the values with Yes and No are
1542 /// set, Calculate values will be ignored.
1543protected:
1552 using DummySignalElement = llvm::StringMapEntry<DummySignalValues>;
1553 static bool UpdateSignalFromDummy(lldb::UnixSignalsSP signals_sp,
1554 const DummySignalElement &element);
1555 static bool ResetSignalFromDummy(lldb::UnixSignalsSP signals_sp,
1556 const DummySignalElement &element);
1557
1558public:
1559 /// Add a signal to the Target's list of stored signals/actions. These
1560 /// values will get copied into any processes launched from
1561 /// this target.
1562 void AddDummySignal(llvm::StringRef name, LazyBool pass, LazyBool print,
1563 LazyBool stop);
1564 /// Updates the signals in signals_sp using the stored dummy signals.
1565 /// If warning_stream_sp is not null, if any stored signals are not found in
1566 /// the current process, a warning will be emitted here.
1568 lldb::StreamSP warning_stream_sp);
1569 /// Clear the dummy signals in signal_names from the target, or all signals
1570 /// if signal_names is empty. Also remove the behaviors they set from the
1571 /// process's signals if it exists.
1572 void ClearDummySignals(Args &signal_names);
1573 /// Print all the signals set in this target.
1574 void PrintDummySignals(Stream &strm, Args &signals);
1575
1576protected:
1577 /// Implementing of ModuleList::Notifier.
1578
1579 void NotifyModuleAdded(const ModuleList &module_list,
1580 const lldb::ModuleSP &module_sp) override;
1581
1582 void NotifyModuleRemoved(const ModuleList &module_list,
1583 const lldb::ModuleSP &module_sp) override;
1584
1585 void NotifyModuleUpdated(const ModuleList &module_list,
1586 const lldb::ModuleSP &old_module_sp,
1587 const lldb::ModuleSP &new_module_sp) override;
1588
1589 void NotifyWillClearList(const ModuleList &module_list) override;
1590
1591 void NotifyModulesRemoved(lldb_private::ModuleList &module_list) override;
1592
1593 class Arch {
1594 public:
1595 explicit Arch(const ArchSpec &spec);
1596 const Arch &operator=(const ArchSpec &spec);
1597
1598 const ArchSpec &GetSpec() const { return m_spec; }
1599 Architecture *GetPlugin() const { return m_plugin_up.get(); }
1600
1601 private:
1603 std::unique_ptr<Architecture> m_plugin_up;
1604 };
1605
1606 // Member variables.
1608 lldb::PlatformSP m_platform_sp; ///< The platform for this target.
1609 std::recursive_mutex m_mutex; ///< An API mutex that is used by the lldb::SB*
1610 /// classes make the SB interface thread safe
1611 /// When the private state thread calls SB API's - usually because it is
1612 /// running OS plugin or Python ThreadPlan code - it should not block on the
1613 /// API mutex that is held by the code that kicked off the sequence of events
1614 /// that led us to run the code. We hand out this mutex instead when we
1615 /// detect that code is running on the private state thread.
1616 std::recursive_mutex m_private_mutex;
1618 std::string m_label;
1619 ModuleList m_images; ///< The list of images for this process (shared
1620 /// libraries and anything dynamically loaded).
1626 std::map<ConstString, std::unique_ptr<BreakpointName>>;
1628
1632 // We want to tightly control the process destruction process so we can
1633 // correctly tear down everything that we need to, so the only class that
1634 // knows about the process lifespan is this target class.
1639
1640 typedef std::map<lldb::LanguageType, lldb::REPLSP> REPLMap;
1642
1644
1645 typedef std::map<lldb::user_id_t, StopHookSP> StopHookCollection;
1648 uint32_t m_latest_stop_hook_id; /// This records the last natural stop at
1649 /// which we ran a stop-hook.
1651 bool m_suppress_stop_hooks; /// Used to not run stop hooks for expressions
1654 /// An optional \a lldb_private::Trace object containing processor trace
1655 /// information of this target.
1657 /// Stores the frame recognizers of this target.
1659 /// These are used to set the signal state when you don't have a process and
1660 /// more usefully in the Dummy target where you can't know exactly what
1661 /// signals you will have.
1662 llvm::StringMap<DummySignalValues> m_dummy_signals;
1663
1664 static void ImageSearchPathsChanged(const PathMappingList &path_list,
1665 void *baton);
1666
1667 // Utilities for `statistics` command.
1668private:
1669 // Target metrics storage.
1671
1672public:
1673 /// Get metrics associated with this target in JSON format.
1674 ///
1675 /// Target metrics help measure timings and information that is contained in
1676 /// a target. These are designed to help measure performance of a debug
1677 /// session as well as represent the current state of the target, like
1678 /// information on the currently modules, currently set breakpoints and more.
1679 ///
1680 /// \return
1681 /// Returns a JSON value that contains all target metrics.
1682 llvm::json::Value
1684
1685 void ResetStatistics();
1686
1688
1689protected:
1690 /// Construct with optional file and arch.
1691 ///
1692 /// This member is private. Clients must use
1693 /// TargetList::CreateTarget(const FileSpec*, const ArchSpec*)
1694 /// so all targets can be tracked from the central target list.
1695 ///
1696 /// \see TargetList::CreateTarget(const FileSpec*, const ArchSpec*)
1697 Target(Debugger &debugger, const ArchSpec &target_arch,
1698 const lldb::PlatformSP &platform_sp, bool is_dummy_target);
1699
1700 // Helper function.
1701 bool ProcessIsValid();
1702
1703 // Copy breakpoints, stop hooks and so forth from the dummy target:
1704 void PrimeFromDummyTarget(Target &target);
1705
1706 void AddBreakpoint(lldb::BreakpointSP breakpoint_sp, bool internal);
1707
1709
1710 /// Return a recommended size for memory reads at \a addr, optimizing for
1711 /// cache usage.
1713
1714 Target(const Target &) = delete;
1715 const Target &operator=(const Target &) = delete;
1716
1718 return m_section_load_history.GetCurrentSectionLoadList();
1719 }
1720};
1721
1722} // namespace lldb_private
1723
1724#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...
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
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:4880
FileSpecList GetDebugFileSearchPaths()
Definition Target.cpp:4761
llvm::StringRef GetLaunchWorkingDirectory() const
Definition Target.cpp:4567
bool GetDisplayRecognizedArguments() const
Definition Target.cpp:5038
ImportStdModule GetImportStdModule() const
Definition Target.cpp:4777
void AppendExecutableSearchPaths(const FileSpec &)
Definition Target.cpp:4748
bool GetEnableSyntheticValue() const
Definition Target.cpp:4847
void SetStandardInputPath(const char *path)=delete
ProcessLaunchInfo m_launch_info
Definition Target.h:302
uint64_t GetExprAllocAlign() const
Definition Target.cpp:4959
MemoryModuleLoadLevel GetMemoryModuleLoadLevel() const
Definition Target.cpp:5010
llvm::StringRef GetArg0() const
Definition Target.cpp:4620
uint32_t GetMaximumMemReadSize() const
Definition Target.cpp:4886
void SetRunArguments(const Args &args)
Definition Target.cpp:4637
FileSpec GetStandardErrorPath() const
Definition Target.cpp:4912
bool GetEnableNotifyAboutFixIts() const
Definition Target.cpp:4803
bool SetPreferDynamicValue(lldb::DynamicValueType d)
Definition Target.cpp:4504
void SetDisplayRecognizedArguments(bool b)
Definition Target.cpp:5044
std::optional< bool > GetExperimentalPropertyValue(size_t prop_idx, ExecutionContext *exe_ctx=nullptr) const
Definition Target.cpp:4443
const ProcessLaunchInfo & GetProcessLaunchInfo() const
Definition Target.cpp:5049
Environment ComputeEnvironment() const
Definition Target.cpp:4643
void SetStandardOutputPath(const char *path)=delete
bool GetUserSpecifiedTrapHandlerNames(Args &args) const
Definition Target.cpp:5017
uint64_t GetExprErrorLimit() const
Definition Target.cpp:4941
bool GetEnableAutoImportClangModules() const
Definition Target.cpp:4771
bool GetDebugUtilityExpression() const
Definition Target.cpp:5155
DynamicClassInfoHelper GetDynamicClassInfoHelper() const
Definition Target.cpp:4784
FileSpec GetStandardOutputPath() const
Definition Target.cpp:4902
void SetDisplayRuntimeSupportValues(bool b)
Definition Target.cpp:5033
uint32_t GetMaximumNumberOfChildrenToDisplay() const
Definition Target.cpp:4865
void SetRequireHardwareBreakpoints(bool b)
Definition Target.cpp:5087
bool GetAutoInstallMainExecutable() const
Definition Target.cpp:5092
const char * GetDisassemblyFeatures() const
Definition Target.cpp:4599
RealpathPrefixes GetSourceRealpathPrefixes() const
Definition Target.cpp:4615
uint64_t GetNumberOfRetriesWithFixits() const
Definition Target.cpp:4797
uint64_t GetExprAllocSize() const
Definition Target.cpp:4953
llvm::StringRef GetExpressionPrefixContents()
Definition Target.cpp:4927
PathMappingList & GetObjectPathMap() const
Definition Target.cpp:4734
const char * GetDisassemblyFlavor() const
Definition Target.cpp:4579
FileSpec GetStandardInputPath() const
Definition Target.cpp:4892
lldb::DynamicValueType GetPreferDynamicValue() const
Definition Target.cpp:4497
InlineStrategy GetInlineStrategy() const
Definition Target.cpp:4606
Environment GetTargetEnvironment() const
Definition Target.cpp:4703
bool GetDisplayRuntimeSupportValues() const
Definition Target.cpp:5027
void SetUserSpecifiedTrapHandlerNames(const Args &args)
Definition Target.cpp:5022
uint32_t GetMaxZeroPaddingInFloatFormat() const
Definition Target.cpp:4859
uint64_t GetExprAllocAddress() const
Definition Target.cpp:4947
LoadCWDlldbinitFile GetLoadCWDlldbinitFile() const
Definition Target.cpp:4996
Environment GetInheritedEnvironment() const
Definition Target.cpp:4675
void SetArg0(llvm::StringRef arg)
Definition Target.cpp:4626
bool GetInjectLocalVariables(ExecutionContext *exe_ctx) const
Definition Target.cpp:4454
void SetStandardErrorPath(const char *path)=delete
bool ShowHexVariableValuesWithLeadingZeroes() const
Definition Target.cpp:4853
SourceLanguage GetLanguage() const
Definition Target.cpp:4922
Environment GetEnvironment() const
Definition Target.cpp:4671
void SetProcessLaunchInfo(const ProcessLaunchInfo &launch_info)
Definition Target.cpp:5053
FileSpec GetSaveJITObjectsDir() const
Definition Target.cpp:4809
void SetEnvironment(Environment env)
Definition Target.cpp:4714
LoadScriptFromSymFile GetLoadScriptFromSymbolFile() const
Definition Target.cpp:4989
const char * GetDisassemblyCPU() const
Definition Target.cpp:4592
void SetStandardErrorPath(llvm::StringRef path)
Definition Target.cpp:4917
bool GetRunArguments(Args &args) const
Definition Target.cpp:4632
FileSpecList GetExecutableSearchPaths()
Definition Target.cpp:4756
ArchSpec GetDefaultArchitecture() const
Definition Target.cpp:4481
Disassembler::HexImmediateStyle GetHexImmediateStyle() const
Definition Target.cpp:5003
void SetUseDIL(ExecutionContext *exe_ctx, bool b)
Definition Target.cpp:4472
std::unique_ptr< TargetExperimentalProperties > m_experimental_properties_up
Definition Target.h:303
FileSpecList GetClangModuleSearchPaths()
Definition Target.cpp:4766
void SetStandardOutputPath(llvm::StringRef path)
Definition Target.cpp:4907
bool GetRequireHardwareBreakpoints() const
Definition Target.cpp:5081
PathMappingList & GetSourcePathMap() const
Definition Target.cpp:4726
bool GetAutoSourceMapRelative() const
Definition Target.cpp:4742
bool GetUseDIL(ExecutionContext *exe_ctx) const
Definition Target.cpp:4460
void SetDefaultArchitecture(const ArchSpec &arch)
Definition Target.cpp:4486
void SetStandardInputPath(llvm::StringRef path)
Definition Target.cpp:4897
TargetProperties(Target *target)
Definition Target.cpp:4367
bool GetDisplayExpressionsInCrashlogs() const
Definition Target.cpp:4983
bool GetEnableAutoApplyFixIts() const
Definition Target.cpp:4791
void SetDebugUtilityExpression(bool debug)
Definition Target.cpp:5161
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:4872
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:1603
const ArchSpec & GetSpec() const
Definition Target.h:1598
const Arch & operator=(const ArchSpec &spec)
Definition Target.cpp:162
Arch(const ArchSpec &spec)
Definition Target.cpp:158
Architecture * GetPlugin() const
Definition Target.h:1599
void SetActionFromString(const std::string &strings)
Definition Target.cpp:3986
StopHookCommandLine(lldb::TargetSP target_sp, lldb::user_id_t uid)
Definition Target.h:1428
void SetActionFromStrings(const std::vector< std::string > &strings)
Definition Target.cpp:3990
StopHookResult HandleStop(ExecutionContext &exc_ctx, lldb::StreamSP output_sp) override
Definition Target.cpp:3997
void GetSubclassDescription(Stream &s, lldb::DescriptionLevel level) const override
Definition Target.cpp:3967
Status SetScriptCallback(std::string class_name, StructuredData::ObjectSP extra_args_sp)
Definition Target.cpp:4031
StopHookResult HandleStop(ExecutionContext &exc_ctx, lldb::StreamSP output) override
Definition Target.cpp:4071
StopHookScripted(lldb::TargetSP target_sp, lldb::user_id_t uid)
Use CreateStopHook to make a new empty stop hook.
Definition Target.h:1455
void GetSubclassDescription(Stream &s, lldb::DescriptionLevel level) const override
Definition Target.cpp:4090
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:1449
lldb::ScriptedStopHookInterfaceSP m_interface_sp
Definition Target.h:1450
bool GetRunAtInitialStop() const
Definition Target.h:1393
SymbolContextSpecifier * GetSpecifier()
Definition Target.h:1362
void SetSpecifier(SymbolContextSpecifier *specifier)
Definition Target.cpp:3901
virtual StopHookResult HandleStop(ExecutionContext &exe_ctx, lldb::StreamSP output)=0
std::unique_ptr< ThreadSpec > m_thread_spec_up
Definition Target.h:1402
void SetIsActive(bool is_active)
Definition Target.h:1381
void SetThreadSpecifier(ThreadSpec *specifier)
Definition Target.cpp:3905
ThreadSpec * GetThreadSpecifier()
Definition Target.h:1377
StopHook(const StopHook &rhs)
Definition Target.cpp:3893
bool ExecutionContextPasses(const ExecutionContext &exe_ctx)
Definition Target.cpp:3909
lldb::TargetSP & GetTarget()
Definition Target.h:1356
void SetRunAtInitialStop(bool at_initial_stop)
Definition Target.h:1389
lldb::SymbolContextSpecifierSP m_specifier_sp
Definition Target.h:1401
virtual void GetSubclassDescription(Stream &s, lldb::DescriptionLevel level) const =0
void GetDescription(Stream &s, lldb::DescriptionLevel level) const
Definition Target.cpp:3925
void SetAutoContinue(bool auto_continue)
Definition Target.h:1383
const ModuleList & GetModuleList() const
Definition Target.h:577
void Dump(Stream *s) const override
Definition Target.cpp:5181
static llvm::StringRef GetFlavorString()
Definition Target.cpp:5177
static ModuleList GetModuleListFromEvent(const Event *event_ptr)
Definition Target.cpp:5210
static const TargetEventData * GetEventDataFromEvent(const Event *event_ptr)
Definition Target.cpp:5191
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:5168
TargetEventData(const TargetEventData &)=delete
const TargetEventData & operator=(const TargetEventData &)=delete
static lldb::TargetSP GetTargetFromEvent(const Event *event_ptr)
Definition Target.cpp:5201
void ModulesDidLoad(ModuleList &module_list)
Definition Target.cpp:1851
lldb::ThreadSP CalculateThread() override
Definition Target.cpp:2584
StopHookCollection m_stop_hooks
Definition Target.h:1646
Module * GetExecutableModulePointer()
Definition Target.cpp:1533
void Dump(Stream *s, lldb::DescriptionLevel description_level)
Dump a description of this object to a Stream.
Definition Target.cpp:237
void DisableAllBreakpoints(bool internal_also=false)
Definition Target.cpp:1065
@ eBroadcastBitWatchpointChanged
Definition Target.h:537
@ eBroadcastBitBreakpointChanged
Definition Target.h:534
lldb::WatchpointSP CreateWatchpoint(lldb::addr_t addr, size_t size, const CompilerType *type, uint32_t kind, Status &error)
Definition Target.cpp:947
void ApplyNameToBreakpoints(BreakpointName &bp_name)
Definition Target.cpp:901
StopHookSP CreateStopHook(StopHook::StopHookKind kind)
Add an empty stop hook to the Target's stop hook list, and returns a shared pointer to it in new_hook...
Definition Target.cpp:3041
lldb::TraceSP GetTrace()
Get the Trace object containing processor trace information of this target.
Definition Target.cpp:3560
PathMappingList & GetImageSearchPathList()
Definition Target.cpp:2593
void FinalizeFileActions(ProcessLaunchInfo &info)
Definition Target.cpp:3685
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:2983
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:2991
ModuleList & GetImages()
Definition Target.h:1016
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:753
static Target * GetTargetFromContexts(const ExecutionContext *exe_ctx_ptr, const SymbolContext *sc_ptr)
Definition Target.cpp:2828
lldb::addr_t GetBreakableLoadAddress(lldb::addr_t addr)
Definition Target.cpp:2998
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:3833
bool SetSuppresStopHooks(bool suppress)
Definition Target.h:1478
static void ImageSearchPathsChanged(const PathMappingList &path_list, void *baton)
Definition Target.cpp:2597
llvm::Expected< lldb_private::Address > GetEntryPointAddress()
This method will return the address of the starting function for this binary, e.g.
Definition Target.cpp:2949
bool IgnoreWatchpointByID(lldb::watch_id_t watch_id, uint32_t ignore_count)
Definition Target.cpp:1501
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:719
lldb::BreakpointSP GetBreakpointByID(lldb::break_id_t break_id)
Definition Target.cpp:414
std::shared_ptr< StopHook > StopHookSP
Definition Target.h:1460
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:1871
bool ClearAllWatchpointHistoricValues()
Definition Target.cpp:1415
void SetTrace(const lldb::TraceSP &trace_sp)
Set the Trace object containing processor trace information of this target.
Definition Target.cpp:3558
BreakpointList & GetBreakpointList(bool internal=false)
Definition Target.cpp:400
CompilerType GetRegisterType(const std::string &name, const lldb_private::RegisterFlags &flags, uint32_t byte_size)
Definition Target.cpp:2632
BreakpointNameList m_breakpoint_names
Definition Target.h:1627
lldb_private::SummaryStatisticsCache & GetSummaryStatisticsCache()
Definition Target.cpp:3375
lldb::addr_t GetSectionLoadAddress(const lldb::SectionSP &section_sp)
Definition Target.cpp:5235
llvm::StringRef GetABIName() const
Returns the name of the target's ABI plugin.
Definition Target.cpp:389
SourceManager & GetSourceManager()
Definition Target.cpp:3035
lldb::SearchFilterSP GetSearchFilterForModuleList(const FileSpecList *containingModuleList)
Definition Target.cpp:682
StopHookSP GetStopHookByID(lldb::user_id_t uid)
Definition Target.cpp:3070
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:1662
lldb::ProcessSP m_process_sp
Definition Target.h:1635
Debugger & GetDebugger() const
Definition Target.h:1097
lldb::SearchFilterSP m_search_filter_sp
Definition Target.h:1636
PersistentExpressionState * GetPersistentExpressionStateForLanguage(lldb::LanguageType language)
Definition Target.cpp:2675
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:3821
bool m_is_dummy_target
Used to not run stop hooks for expressions.
Definition Target.h:1652
static bool UpdateSignalFromDummy(lldb::UnixSignalsSP signals_sp, const DummySignalElement &element)
Definition Target.cpp:3779
PathMappingList m_image_search_paths
Definition Target.h:1637
bool ModuleIsExcludedForUnconstrainedSearches(const FileSpec &module_spec)
Return whether this FileSpec corresponds to a module that should be considered for general searches.
Definition Target.cpp:1927
lldb::StackFrameSP CalculateStackFrame() override
Definition Target.cpp:2586
SectionLoadList & GetSectionLoadList()
Definition Target.h:1717
lldb::addr_t GetPersistentSymbol(ConstString name)
Definition Target.cpp:2929
void PrimeFromDummyTarget(Target &target)
Definition Target.cpp:214
static void SettingsTerminate()
Definition Target.cpp:2787
bool EnableWatchpointByID(lldb::watch_id_t watch_id)
Definition Target.cpp:1466
bool ResolveFileAddress(lldb::addr_t load_addr, Address &so_addr)
Definition Target.cpp:3291
bool ClearAllWatchpointHitCounts()
Definition Target.cpp:1401
size_t ReadMemoryFromFileCache(const Address &addr, void *dst, size_t dst_len, Status &error)
Definition Target.cpp:1959
void ClearAllLoadedSections()
Definition Target.cpp:3367
size_t GetNumStopHooks() const
Definition Target.h:1496
std::vector< lldb::TypeSystemSP > GetScratchTypeSystems(bool create_on_demand=true)
Definition Target.cpp:2641
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:2258
void AddNameToBreakpoint(BreakpointID &id, llvm::StringRef name, Status &error)
Definition Target.cpp:821
bool LoadScriptingResources(std::list< Status > &errors, Stream &feedback_stream, bool continue_on_error=true)
Definition Target.h:990
void DumpSectionLoadList(Stream &s)
Definition Target.cpp:5241
void DeleteCurrentProcess()
Definition Target.cpp:272
BreakpointList m_internal_breakpoint_list
Definition Target.h:1624
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:2287
void DisableAllowedBreakpoints()
Definition Target.cpp:1075
bool SetSectionUnloaded(const lldb::SectionSP &section_sp)
Definition Target.cpp:3345
lldb::TargetSP CalculateTarget() override
Definition Target.cpp:2580
const lldb::ProcessSP & GetProcessSP() const
Definition Target.cpp:306
void ClearModules(bool delete_locations)
Definition Target.cpp:1555
bool RemoveBreakpointByID(lldb::break_id_t break_id)
Definition Target.cpp:1099
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:2339
static bool ResetSignalFromDummy(lldb::UnixSignalsSP signals_sp, const DummySignalElement &element)
Definition Target.cpp:3806
Architecture * GetArchitecturePlugin() const
Definition Target.h:1095
llvm::json::Value ReportStatistics(const lldb_private::StatisticsOptions &options)
Get metrics associated with this target in JSON format.
Definition Target.cpp:5227
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:2728
TargetStats & GetStatistics()
Definition Target.h:1687
void EnableAllBreakpoints(bool internal_also=false)
Definition Target.cpp:1082
Status Launch(ProcessLaunchInfo &launch_info, Stream *stream)
Definition Target.cpp:3390
bool DisableBreakpointByID(lldb::break_id_t break_id)
Definition Target.cpp:1119
lldb::BreakpointSP CreateBreakpointAtUserEntry(Status &error)
Definition Target.cpp:426
BreakpointName * FindBreakpointName(ConstString name, bool can_create, Status &error)
Definition Target.cpp:853
std::map< lldb::user_id_t, StopHookSP > StopHookCollection
Definition Target.h:1645
llvm::Expected< lldb::TraceSP > CreateTrace()
Create a Trace object for the current target using the using the default supported tracing technology...
Definition Target.cpp:3562
lldb::TraceSP m_trace_sp
An optional lldb_private::Trace object containing processor trace information of this target.
Definition Target.h:1656
bool RemoveAllWatchpoints(bool end_to_end=true)
Definition Target.cpp:1319
bool ReadPointerFromMemory(const Address &addr, Status &error, Address &pointer_addr, bool force_live_memory=false)
Definition Target.cpp:2309
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:3056
WatchpointList m_watchpoint_list
Definition Target.h:1630
BreakpointList m_breakpoint_list
Definition Target.h:1623
lldb::SourceManagerUP m_source_manager_up
Definition Target.h:1643
bool RemoveWatchpointByID(lldb::watch_id_t watch_id)
Definition Target.cpp:1485
bool ResolveLoadAddress(lldb::addr_t load_addr, Address &so_addr, uint32_t stop_id=SectionLoadHistory::eStopIDNow, bool allow_section_end=false)
Definition Target.cpp:3285
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:2209
void DeleteBreakpointName(ConstString name)
Definition Target.cpp:877
void NotifyWillClearList(const ModuleList &module_list) override
Definition Target.cpp:1813
bool SetArchitecture(const ArchSpec &arch_spec, bool set_platform=false, bool merge=true)
Set the architecture for this target.
Definition Target.cpp:1697
void NotifyModuleAdded(const ModuleList &module_list, const lldb::ModuleSP &module_sp) override
Implementing of ModuleList::Notifier.
Definition Target.cpp:1815
llvm::Expected< lldb::TypeSystemSP > GetScratchTypeSystemForLanguage(lldb::LanguageType language, bool create_on_demand=true)
Definition Target.cpp:2606
void ConfigureBreakpointName(BreakpointName &bp_name, const BreakpointOptions &options, const BreakpointName::Permissions &permissions)
Definition Target.cpp:893
lldb_private::SummaryStatisticsSP GetSummaryStatisticsSPForProviderName(lldb_private::TypeSummaryImpl &summary_provider)
Definition Target.cpp:3369
lldb::SearchFilterSP GetSearchFilterForModuleAndCUList(const FileSpecList *containingModules, const FileSpecList *containingSourceFiles)
Definition Target.cpp:699
lldb::ModuleSP GetExecutableModule()
Gets the module for the main executable.
Definition Target.cpp:1517
bool SetStopHookActiveStateByID(lldb::user_id_t uid, bool active_state)
Definition Target.cpp:3080
const lldb::ProcessSP & CreateProcess(lldb::ListenerSP listener_sp, llvm::StringRef plugin_name, const FileSpec *crash_file, bool can_connect)
Definition Target.cpp:294
void SetAllStopHooksActiveState(bool active_state)
Definition Target.cpp:3091
lldb::ExpressionVariableSP GetPersistentVariable(ConstString name)
Definition Target.cpp:2910
void NotifyModulesRemoved(lldb_private::ModuleList &module_list) override
Definition Target.cpp:1847
size_t ReadCStringFromMemory(const Address &addr, std::string &out_str, Status &error, bool force_live_memory=false)
Definition Target.cpp:2119
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:1609
void ModulesDidUnload(ModuleList &module_list, bool delete_locations)
Definition Target.cpp:1887
void CalculateExecutionContext(ExecutionContext &exe_ctx) override
Reconstruct the object's execution context into sc.
Definition Target.cpp:2588
llvm::Expected< lldb::DisassemblerSP > ReadInstructions(const Address &start_addr, uint32_t count, const char *flavor_string=nullptr)
Definition Target.cpp:3004
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:3587
void NotifyModuleUpdated(const ModuleList &module_list, const lldb::ModuleSP &old_module_sp, const lldb::ModuleSP &new_module_sp) override
Definition Target.cpp:1835
SummaryStatisticsCache m_summary_statistics_cache
Definition Target.h:1621
Target(const Target &)=delete
Status SerializeBreakpointsToFile(const FileSpec &file, const BreakpointIDList &bp_ids, bool append)
Definition Target.cpp:1160
void DidExec()
Called as the last function in Process::DidExec().
Definition Target.cpp:1562
void SaveScriptedLaunchInfo(lldb_private::ProcessInfo &process_info)
Definition Target.cpp:3379
bool GetSuppressStopHooks()
Definition Target.h:1484
std::string m_label
Definition Target.h:1618
lldb::user_id_t m_stop_hook_next_id
Definition Target.h:1647
static FileSpecList GetDefaultExecutableSearchPaths()
Definition Target.cpp:2789
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:736
lldb::SearchFilterSP GetSearchFilterForModule(const FileSpec *containingModule)
Definition Target.cpp:664
llvm::StringMapEntry< DummySignalValues > DummySignalElement
Definition Target.h:1552
std::recursive_mutex & GetAPIMutex()
Definition Target.cpp:5218
static llvm::StringRef GetStaticBroadcasterClass()
Definition Target.cpp:168
static FileSpecList GetDefaultDebugFileSearchPaths()
Definition Target.cpp:2793
void EnableAllowedBreakpoints()
Definition Target.cpp:1092
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:1993
llvm::Error SetLabel(llvm::StringRef label)
Set a label for a target.
Definition Target.cpp:2808
uint32_t m_latest_stop_hook_id
Definition Target.h:1648
StackFrameRecognizerManager & GetFrameRecognizerManager()
Definition Target.h:1534
void RemoveAllowedBreakpoints()
Definition Target.cpp:1044
StopHookSP GetStopHookAtIndex(size_t index)
Definition Target.h:1498
bool DisableAllWatchpoints(bool end_to_end=true)
Definition Target.cpp:1348
bool RunStopHooks(bool at_initial_stop=false)
Definition Target.cpp:3098
void ClearSectionLoadList()
Definition Target.cpp:5239
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:2196
lldb::PlatformSP m_platform_sp
The platform for this target.
Definition Target.h:1608
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:2758
static TargetProperties & GetGlobalProperties()
Definition Target.cpp:3249
Status Install(ProcessLaunchInfo *launch_info)
Definition Target.cpp:3257
lldb::PlatformSP GetPlatform()
Definition Target.h:1510
void NotifyModuleRemoved(const ModuleList &module_list, const lldb::ModuleSP &module_sp) override
Definition Target.cpp:1825
lldb::BreakpointSP CreateAddressInModuleBreakpoint(lldb::addr_t file_addr, bool internal, const FileSpec &file_spec, bool request_hardware)
Definition Target.cpp:570
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:481
void RemoveAllBreakpoints(bool internal_also=false)
Definition Target.cpp:1053
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:464
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:2797
void ResetBreakpointHitCounts()
Resets the hit count of all breakpoints.
Definition Target.cpp:1156
const ModuleList & GetImages() const
Get accessor for the images for this process.
Definition Target.h:1014
const ArchSpec & GetArchitecture() const
Definition Target.h:1056
WatchpointList & GetWatchpointList()
Definition Target.h:807
unsigned m_next_persistent_variable_index
Definition Target.h:1653
bool EnableBreakpointByID(lldb::break_id_t break_id)
Definition Target.cpp:1137
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:2298
TargetStats m_stats
Definition Target.h:1670
bool IgnoreAllWatchpoints(uint32_t ignore_count)
Definition Target.cpp:1430
void AddBreakpoint(lldb::BreakpointSP breakpoint_sp, bool internal)
Definition Target.cpp:798
TypeSystemMap m_scratch_type_system_map
Definition Target.h:1638
void AddBreakpointName(std::unique_ptr< BreakpointName > bp_name)
Definition Target.cpp:848
SectionLoadHistory m_section_load_history
Definition Target.h:1622
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:915
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:173
size_t UnloadModuleSections(const lldb::ModuleSP &module_sp)
Definition Target.cpp:3326
const std::string & GetLabel() const
Definition Target.h:603
bool m_valid
This records the last natural stop at which we ran a stop-hook.
Definition Target.h:1650
bool DisableWatchpointByID(lldb::watch_id_t watch_id)
Definition Target.cpp:1447
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:3764
std::map< ConstString, std::unique_ptr< BreakpointName > > BreakpointNameList
Definition Target.h:1625
lldb::WatchpointSP m_last_created_watchpoint
Definition Target.h:1631
Status CreateBreakpointsFromFile(const FileSpec &file, BreakpointIDList &new_bps)
Definition Target.cpp:1252
Debugger & m_debugger
Definition Target.h:1607
void SetREPL(lldb::LanguageType language, lldb::REPLSP repl_sp)
Definition Target.cpp:359
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:1568
lldb::StackFrameRecognizerManagerUP m_frame_recognizer_manager_up
Stores the frame recognizers of this target.
Definition Target.h:1658
lldb::REPLSP GetREPL(Status &err, lldb::LanguageType language, const char *repl_options, bool can_create)
Definition Target.cpp:308
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:2695
ModuleList m_images
The list of images for this process (shared libraries and anything dynamically loaded).
Definition Target.h:1619
lldb::ProcessSP CalculateProcess() override
Definition Target.cpp:2582
void PrintDummySignals(Stream &strm, Args &signals)
Print all the signals set in this target.
Definition Target.cpp:3858
void SetPlatform(const lldb::PlatformSP &platform_sp)
Definition Target.h:1512
bool SetSectionLoadAddress(const lldb::SectionSP &section, lldb::addr_t load_addr, bool warn_multiple=false)
Definition Target.cpp:3296
Status Attach(ProcessAttachInfo &attach_info, Stream *stream)
Definition Target.cpp:3593
std::map< lldb::LanguageType, lldb::REPLSP > REPLMap
Definition Target.h:1640
static void SetDefaultArchitecture(const ArchSpec &arch)
Definition Target.cpp:2801
lldb::BreakpointSP m_last_created_breakpoint
Definition Target.h:1629
lldb::WatchpointSP GetLastCreatedWatchpoint()
Definition Target.h:803
void RemoveNameFromBreakpoint(lldb::BreakpointSP &bp_sp, ConstString name)
Definition Target.cpp:888
bool RemoveStopHookByID(lldb::user_id_t uid)
Definition Target.cpp:3063
friend class Debugger
Definition Target.h:530
lldb::BreakpointSP GetLastCreatedBreakpoint()
Definition Target.h:695
static void SettingsInitialize()
Definition Target.cpp:2785
~Target() override
Definition Target.cpp:208
bool EnableAllWatchpoints(bool end_to_end=true)
Definition Target.cpp:1375
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:1616
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:2842
bool MergeArchitecture(const ArchSpec &arch_spec)
Definition Target.cpp:1788
Encapsulates a one-time expression for use in lldb.
This class is used by Watchpoint to manage a list of watchpoints,.
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:4150
@ 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::REPL > REPLSP
A type-erased pair of llvm::dwarf::SourceLanguageName and version.
DummySignalValues(LazyBool pass, LazyBool notify, LazyBool stop)
Definition Target.h:1548
UserID(lldb::user_id_t uid=LLDB_INVALID_UID)
Construct with optional user ID.
Definition UserID.h:33