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
39#include "lldb/lldb-public.h"
40
41namespace lldb_private {
42
44
49};
50
55};
56
61};
62
67};
68
74};
75
77public:
79};
80
82public:
83 TargetProperties(Target *target);
84
86
88
89 void SetDefaultArchitecture(const ArchSpec &arch);
90
91 bool GetMoveToNearestCode() const;
92
94
96
97 bool GetPreloadSymbols() const;
98
99 void SetPreloadSymbols(bool b);
100
101 bool GetDisableASLR() const;
102
103 void SetDisableASLR(bool b);
104
105 bool GetInheritTCC() const;
106
107 void SetInheritTCC(bool b);
108
109 bool GetDetachOnError() const;
110
111 void SetDetachOnError(bool b);
112
113 bool GetDisableSTDIO() const;
114
115 void SetDisableSTDIO(bool b);
116
117 const char *GetDisassemblyFlavor() const;
118
120
122
123 llvm::StringRef GetArg0() const;
124
125 void SetArg0(llvm::StringRef arg);
126
127 bool GetRunArguments(Args &args) const;
128
129 void SetRunArguments(const Args &args);
130
131 // Get the whole environment including the platform inherited environment and
132 // the target specific environment, excluding the unset environment variables.
134 // Get the platform inherited environment, excluding the unset environment
135 // variables.
137 // Get the target specific environment only, without the platform inherited
138 // environment.
140 // Set the target specific environment.
141 void SetEnvironment(Environment env);
142
143 bool GetSkipPrologue() const;
144
146
148
149 bool GetAutoSourceMapRelative() const;
150
152
154
156
158
160
162
164
165 bool GetEnableAutoApplyFixIts() const;
166
167 uint64_t GetNumberOfRetriesWithFixits() const;
168
169 bool GetEnableNotifyAboutFixIts() const;
170
172
173 bool GetEnableSyntheticValue() const;
174
176
177 uint32_t GetMaxZeroPaddingInFloatFormat() const;
178
180
181 /// Get the max depth value, augmented with a bool to indicate whether the
182 /// depth is the default.
183 ///
184 /// When the user has customized the max depth, the bool will be false.
185 ///
186 /// \returns the max depth, and true if the max depth is the system default,
187 /// otherwise false.
188 std::pair<uint32_t, bool> GetMaximumDepthOfChildrenToDisplay() const;
189
190 uint32_t GetMaximumSizeOfStringSummary() const;
191
192 uint32_t GetMaximumMemReadSize() const;
193
197
198 void SetStandardInputPath(llvm::StringRef path);
199 void SetStandardOutputPath(llvm::StringRef path);
200 void SetStandardErrorPath(llvm::StringRef path);
201
202 void SetStandardInputPath(const char *path) = delete;
203 void SetStandardOutputPath(const char *path) = delete;
204 void SetStandardErrorPath(const char *path) = delete;
205
207
209
210 llvm::StringRef GetExpressionPrefixContents();
211
212 uint64_t GetExprErrorLimit() const;
213
214 uint64_t GetExprAllocAddress() const;
215
216 uint64_t GetExprAllocSize() const;
217
218 uint64_t GetExprAllocAlign() const;
219
220 bool GetUseHexImmediates() const;
221
222 bool GetUseFastStepping() const;
223
225
227
229
231
233
234 bool GetUserSpecifiedTrapHandlerNames(Args &args) const;
235
236 void SetUserSpecifiedTrapHandlerNames(const Args &args);
237
239
241
243
245
247
248 void SetProcessLaunchInfo(const ProcessLaunchInfo &launch_info);
249
250 bool GetInjectLocalVariables(ExecutionContext *exe_ctx) const;
251
253
255
256 bool GetAutoInstallMainExecutable() const;
257
259
260 void SetDebugUtilityExpression(bool debug);
261
262 bool GetDebugUtilityExpression() const;
263
264private:
265 std::optional<bool>
266 GetExperimentalPropertyValue(size_t prop_idx,
267 ExecutionContext *exe_ctx = nullptr) const;
268
269 // Callbacks for m_launch_info.
280
281 // Settings checker for target.jit-save-objects-dir:
282 void CheckJITObjectsDir();
283
285
286 // Member variables.
288 std::unique_ptr<TargetExperimentalProperties> m_experimental_properties_up;
290};
291
293public:
294// MSVC has a bug here that reports C4268: 'const' static/global data
295// initialized with compiler generated default constructor fills the object
296// with zeros. Confirmed that MSVC is *not* zero-initializing, it's just a
297// bogus warning.
298#if defined(_MSC_VER)
299#pragma warning(push)
300#pragma warning(disable : 4268)
301#endif
302 static constexpr std::chrono::milliseconds default_timeout{500};
303#if defined(_MSC_VER)
304#pragma warning(pop)
305#endif
306
309
311
313
315 m_execution_policy = policy;
316 }
317
319
320 void SetLanguage(lldb::LanguageType language_type) {
321 m_language = SourceLanguage(language_type);
322 }
323
324 /// Set the language using a pair of language code and version as
325 /// defined by the DWARF 6 specification.
326 /// WARNING: These codes may change until DWARF 6 is finalized.
327 void SetLanguage(uint16_t name, uint32_t version) {
328 m_language = SourceLanguage(name, version);
329 }
330
331 bool DoesCoerceToId() const { return m_coerce_to_id; }
332
333 const char *GetPrefix() const {
334 return (m_prefix.empty() ? nullptr : m_prefix.c_str());
335 }
336
337 void SetPrefix(const char *prefix) {
338 if (prefix && prefix[0])
339 m_prefix = prefix;
340 else
341 m_prefix.clear();
342 }
343
344 void SetCoerceToId(bool coerce = true) { m_coerce_to_id = coerce; }
345
346 bool DoesUnwindOnError() const { return m_unwind_on_error; }
347
348 void SetUnwindOnError(bool unwind = false) { m_unwind_on_error = unwind; }
349
351
352 void SetIgnoreBreakpoints(bool ignore = false) {
353 m_ignore_breakpoints = ignore;
354 }
355
356 bool DoesKeepInMemory() const { return m_keep_in_memory; }
357
358 void SetKeepInMemory(bool keep = true) { m_keep_in_memory = keep; }
359
361
362 void
364 m_use_dynamic = dynamic;
365 }
366
367 const Timeout<std::micro> &GetTimeout() const { return m_timeout; }
368
369 void SetTimeout(const Timeout<std::micro> &timeout) { m_timeout = timeout; }
370
373 }
374
376 m_one_thread_timeout = timeout;
377 }
378
379 bool GetTryAllThreads() const { return m_try_others; }
380
381 void SetTryAllThreads(bool try_others = true) { m_try_others = try_others; }
382
383 bool GetStopOthers() const { return m_stop_others; }
384
385 void SetStopOthers(bool stop_others = true) { m_stop_others = stop_others; }
386
387 bool GetDebug() const { return m_debug; }
388
389 void SetDebug(bool b) {
390 m_debug = b;
391 if (m_debug)
393 }
394
396
398
399 bool GetColorizeErrors() const { return m_ansi_color_errors; }
400
402
403 bool GetTrapExceptions() const { return m_trap_exceptions; }
404
406
407 bool GetREPLEnabled() const { return m_repl; }
408
409 void SetREPLEnabled(bool b) { m_repl = b; }
410
413 m_cancel_callback = callback;
414 }
415
417 return ((m_cancel_callback != nullptr)
419 : false);
420 }
421
422 // Allows the expression contents to be remapped to point to the specified
423 // file and line using #line directives.
424 void SetPoundLine(const char *path, uint32_t line) const {
425 if (path && path[0]) {
426 m_pound_line_file = path;
427 m_pound_line_line = line;
428 } else {
429 m_pound_line_file.clear();
431 }
432 }
433
434 const char *GetPoundLineFilePath() const {
435 return (m_pound_line_file.empty() ? nullptr : m_pound_line_file.c_str());
436 }
437
438 uint32_t GetPoundLineLine() const { return m_pound_line_line; }
439
441
444 }
445
447
449
450 void SetRetriesWithFixIts(uint64_t number_of_retries) {
451 m_retries_with_fixits = number_of_retries;
452 }
453
454 uint64_t GetRetriesWithFixIts() const { return m_retries_with_fixits; }
455
457
459
460private:
463 std::string m_prefix;
464 bool m_coerce_to_id = false;
465 bool m_unwind_on_error = true;
467 bool m_keep_in_memory = false;
468 bool m_try_others = true;
469 bool m_stop_others = true;
470 bool m_debug = false;
471 bool m_trap_exceptions = true;
472 bool m_repl = false;
478 /// True if the executed code should be treated as utility code that is only
479 /// used by LLDB internally.
481
486 void *m_cancel_callback_baton = nullptr;
487 // If m_pound_line_file is not empty and m_pound_line_line is non-zero, use
488 // #line %u "%s" before the expression content to remap where the source
489 // originates
490 mutable std::string m_pound_line_file;
491 mutable uint32_t m_pound_line_line = 0;
492};
493
494// Target
495class Target : public std::enable_shared_from_this<Target>,
496 public TargetProperties,
497 public Broadcaster,
499 public ModuleList::Notifier {
500public:
501 friend class TargetList;
502 friend class Debugger;
503
504 /// Broadcaster event bits definitions.
505 enum {
512 };
513
514 // These two functions fill out the Broadcaster interface:
515
516 static llvm::StringRef GetStaticBroadcasterClass();
517
518 llvm::StringRef GetBroadcasterClass() const override {
520 }
521
522 // This event data class is for use by the TargetList to broadcast new target
523 // notifications.
524 class TargetEventData : public EventData {
525 public:
526 TargetEventData(const lldb::TargetSP &target_sp);
527
528 TargetEventData(const lldb::TargetSP &target_sp,
529 const ModuleList &module_list);
530
532
533 static llvm::StringRef GetFlavorString();
534
535 llvm::StringRef GetFlavor() const override {
537 }
538
539 void Dump(Stream *s) const override;
540
541 static const TargetEventData *GetEventDataFromEvent(const Event *event_ptr);
542
543 static lldb::TargetSP GetTargetFromEvent(const Event *event_ptr);
544
545 static ModuleList GetModuleListFromEvent(const Event *event_ptr);
546
547 const lldb::TargetSP &GetTarget() const { return m_target_sp; }
548
549 const ModuleList &GetModuleList() const { return m_module_list; }
550
551 private:
554
556 const TargetEventData &operator=(const TargetEventData &) = delete;
557 };
558
559 ~Target() override;
560
561 static void SettingsInitialize();
562
563 static void SettingsTerminate();
564
566
568
570
571 static void SetDefaultArchitecture(const ArchSpec &arch);
572
573 bool IsDummyTarget() const { return m_is_dummy_target; }
574
575 const std::string &GetLabel() const { return m_label; }
576
577 /// Set a label for a target.
578 ///
579 /// The label cannot be used by another target or be only integral.
580 ///
581 /// \return
582 /// The label for this target or an error if the label didn't match the
583 /// requirements.
584 llvm::Error SetLabel(llvm::StringRef label);
585
586 /// Find a binary on the system and return its Module,
587 /// or return an existing Module that is already in the Target.
588 ///
589 /// Given a ModuleSpec, find a binary satisifying that specification,
590 /// or identify a matching Module already present in the Target,
591 /// and return a shared pointer to it.
592 ///
593 /// \param[in] module_spec
594 /// The criteria that must be matched for the binary being loaded.
595 /// e.g. UUID, architecture, file path.
596 ///
597 /// \param[in] notify
598 /// If notify is true, and the Module is new to this Target,
599 /// Target::ModulesDidLoad will be called.
600 /// If notify is false, it is assumed that the caller is adding
601 /// multiple Modules and will call ModulesDidLoad with the
602 /// full list at the end.
603 /// ModulesDidLoad must be called when a Module/Modules have
604 /// been added to the target, one way or the other.
605 ///
606 /// \param[out] error_ptr
607 /// Optional argument, pointing to a Status object to fill in
608 /// with any results / messages while attempting to find/load
609 /// this binary. Many callers will be internal functions that
610 /// will handle / summarize the failures in a custom way and
611 /// don't use these messages.
612 ///
613 /// \return
614 /// An empty ModuleSP will be returned if no matching file
615 /// was found. If error_ptr was non-nullptr, an error message
616 /// will likely be provided.
617 lldb::ModuleSP GetOrCreateModule(const ModuleSpec &module_spec, bool notify,
618 Status *error_ptr = nullptr);
619
620 // Settings accessors
621
623
624 std::recursive_mutex &GetAPIMutex();
625
627
628 void CleanupProcess();
629
630 /// Dump a description of this object to a Stream.
631 ///
632 /// Dump a description of the contents of this object to the
633 /// supplied stream \a s. The dumped content will be only what has
634 /// been loaded or parsed up to this point at which this function
635 /// is called, so this is a good way to see what has been parsed
636 /// in a target.
637 ///
638 /// \param[in] s
639 /// The stream to which to dump the object description.
640 void Dump(Stream *s, lldb::DescriptionLevel description_level);
641
642 // If listener_sp is null, the listener of the owning Debugger object will be
643 // used.
645 llvm::StringRef plugin_name,
646 const FileSpec *crash_file,
647 bool can_connect);
648
649 const lldb::ProcessSP &GetProcessSP() const;
650
651 bool IsValid() { return m_valid; }
652
653 void Destroy();
654
655 Status Launch(ProcessLaunchInfo &launch_info,
656 Stream *stream); // Optional stream to receive first stop info
657
658 Status Attach(ProcessAttachInfo &attach_info,
659 Stream *stream); // Optional stream to receive first stop info
660
661 // This part handles the breakpoints.
662
663 BreakpointList &GetBreakpointList(bool internal = false);
664
665 const BreakpointList &GetBreakpointList(bool internal = false) const;
666
669 }
670
672
674
675 // Use this to create a file and line breakpoint to a given module or all
676 // module it is nullptr
677 lldb::BreakpointSP CreateBreakpoint(const FileSpecList *containingModules,
678 const FileSpec &file, uint32_t line_no,
679 uint32_t column, lldb::addr_t offset,
680 LazyBool check_inlines,
681 LazyBool skip_prologue, bool internal,
682 bool request_hardware,
683 LazyBool move_to_nearest_code);
684
685 // Use this to create breakpoint that matches regex against the source lines
686 // in files given in source_file_list: If function_names is non-empty, also
687 // filter by function after the matches are made.
689 const FileSpecList *containingModules,
690 const FileSpecList *source_file_list,
691 const std::unordered_set<std::string> &function_names,
692 RegularExpression source_regex, bool internal, bool request_hardware,
693 LazyBool move_to_nearest_code);
694
695 // Use this to create a breakpoint from a load address
696 lldb::BreakpointSP CreateBreakpoint(lldb::addr_t load_addr, bool internal,
697 bool request_hardware);
698
699 // Use this to create a breakpoint from a load address and a module file spec
701 bool internal,
702 const FileSpec &file_spec,
703 bool request_hardware);
704
705 // Use this to create Address breakpoints:
706 lldb::BreakpointSP CreateBreakpoint(const Address &addr, bool internal,
707 bool request_hardware);
708
709 // Use this to create a function breakpoint by regexp in
710 // containingModule/containingSourceFiles, or all modules if it is nullptr
711 // When "skip_prologue is set to eLazyBoolCalculate, we use the current
712 // target setting, else we use the values passed in
714 const FileSpecList *containingModules,
715 const FileSpecList *containingSourceFiles, RegularExpression func_regexp,
716 lldb::LanguageType requested_language, LazyBool skip_prologue,
717 bool internal, bool request_hardware);
718
719 // Use this to create a function breakpoint by name in containingModule, or
720 // all modules if it is nullptr When "skip_prologue is set to
721 // eLazyBoolCalculate, we use the current target setting, else we use the
722 // values passed in. func_name_type_mask is or'ed values from the
723 // FunctionNameType enum.
725 const FileSpecList *containingModules,
726 const FileSpecList *containingSourceFiles, const char *func_name,
727 lldb::FunctionNameType func_name_type_mask, lldb::LanguageType language,
728 lldb::addr_t offset, LazyBool skip_prologue, bool internal,
729 bool request_hardware);
730
732 CreateExceptionBreakpoint(enum lldb::LanguageType language, bool catch_bp,
733 bool throw_bp, bool internal,
734 Args *additional_args = nullptr,
735 Status *additional_args_error = nullptr);
736
738 const llvm::StringRef class_name, const FileSpecList *containingModules,
739 const FileSpecList *containingSourceFiles, bool internal,
740 bool request_hardware, StructuredData::ObjectSP extra_args_sp,
741 Status *creation_error = nullptr);
742
743 // This is the same as the func_name breakpoint except that you can specify a
744 // vector of names. This is cheaper than a regular expression breakpoint in
745 // the case where you just want to set a breakpoint on a set of names you
746 // already know. func_name_type_mask is or'ed values from the
747 // FunctionNameType enum.
749 const FileSpecList *containingModules,
750 const FileSpecList *containingSourceFiles, const char *func_names[],
751 size_t num_names, lldb::FunctionNameType func_name_type_mask,
752 lldb::LanguageType language, lldb::addr_t offset, LazyBool skip_prologue,
753 bool internal, bool request_hardware);
754
756 CreateBreakpoint(const FileSpecList *containingModules,
757 const FileSpecList *containingSourceFiles,
758 const std::vector<std::string> &func_names,
759 lldb::FunctionNameType func_name_type_mask,
760 lldb::LanguageType language, lldb::addr_t m_offset,
761 LazyBool skip_prologue, bool internal,
762 bool request_hardware);
763
764 // Use this to create a general breakpoint:
766 lldb::BreakpointResolverSP &resolver_sp,
767 bool internal, bool request_hardware,
768 bool resolve_indirect_symbols);
769
770 // Use this to create a watchpoint:
772 const CompilerType *type, uint32_t kind,
773 Status &error);
774
777 }
778
780
781 // Manages breakpoint names:
782 void AddNameToBreakpoint(BreakpointID &id, llvm::StringRef name,
783 Status &error);
784
785 void AddNameToBreakpoint(lldb::BreakpointSP &bp_sp, llvm::StringRef name,
786 Status &error);
787
789
790 BreakpointName *FindBreakpointName(ConstString name, bool can_create,
791 Status &error);
792
794
796 const BreakpointOptions &options,
797 const BreakpointName::Permissions &permissions);
799
800 void AddBreakpointName(std::unique_ptr<BreakpointName> bp_name);
801
802 void GetBreakpointNames(std::vector<std::string> &names);
803
804 // This call removes ALL breakpoints regardless of permission.
805 void RemoveAllBreakpoints(bool internal_also = false);
806
807 // This removes all the breakpoints, but obeys the ePermDelete on them.
809
810 void DisableAllBreakpoints(bool internal_also = false);
811
813
814 void EnableAllBreakpoints(bool internal_also = false);
815
817
819
821
823
824 /// Resets the hit count of all breakpoints.
826
827 // The flag 'end_to_end', default to true, signifies that the operation is
828 // performed end to end, for both the debugger and the debuggee.
829
830 bool RemoveAllWatchpoints(bool end_to_end = true);
831
832 bool DisableAllWatchpoints(bool end_to_end = true);
833
834 bool EnableAllWatchpoints(bool end_to_end = true);
835
837
839
840 bool IgnoreAllWatchpoints(uint32_t ignore_count);
841
843
845
847
848 bool IgnoreWatchpointByID(lldb::watch_id_t watch_id, uint32_t ignore_count);
849
851 const BreakpointIDList &bp_ids,
852 bool append);
853
855 BreakpointIDList &new_bps);
856
858 std::vector<std::string> &names,
859 BreakpointIDList &new_bps);
860
861 /// Get \a load_addr as a callable code load address for this target
862 ///
863 /// Take \a load_addr and potentially add any address bits that are
864 /// needed to make the address callable. For ARM this can set bit
865 /// zero (if it already isn't) if \a load_addr is a thumb function.
866 /// If \a addr_class is set to AddressClass::eInvalid, then the address
867 /// adjustment will always happen. If it is set to an address class
868 /// that doesn't have code in it, LLDB_INVALID_ADDRESS will be
869 /// returned.
871 lldb::addr_t load_addr,
872 AddressClass addr_class = AddressClass::eInvalid) const;
873
874 /// Get \a load_addr as an opcode for this target.
875 ///
876 /// Take \a load_addr and potentially strip any address bits that are
877 /// needed to make the address point to an opcode. For ARM this can
878 /// clear bit zero (if it already isn't) if \a load_addr is a
879 /// thumb function and load_addr is in code.
880 /// If \a addr_class is set to AddressClass::eInvalid, then the address
881 /// adjustment will always happen. If it is set to an address class
882 /// that doesn't have code in it, LLDB_INVALID_ADDRESS will be
883 /// returned.
886 AddressClass addr_class = AddressClass::eInvalid) const;
887
888 // Get load_addr as breakable load address for this target. Take a addr and
889 // check if for any reason there is a better address than this to put a
890 // breakpoint on. If there is then return that address. For MIPS, if
891 // instruction at addr is a delay slot instruction then this method will find
892 // the address of its previous instruction and return that address.
894
895 void ModulesDidLoad(ModuleList &module_list);
896
897 void ModulesDidUnload(ModuleList &module_list, bool delete_locations);
898
899 void SymbolsDidLoad(ModuleList &module_list);
900
901 void ClearModules(bool delete_locations);
902
903 /// Called as the last function in Process::DidExec().
904 ///
905 /// Process::DidExec() will clear a lot of state in the process,
906 /// then try to reload a dynamic loader plugin to discover what
907 /// binaries are currently available and then this function should
908 /// be called to allow the target to do any cleanup after everything
909 /// has been figured out. It can remove breakpoints that no longer
910 /// make sense as the exec might have changed the target
911 /// architecture, and unloaded some modules that might get deleted.
912 void DidExec();
913
914 /// Gets the module for the main executable.
915 ///
916 /// Each process has a notion of a main executable that is the file
917 /// that will be executed or attached to. Executable files can have
918 /// dependent modules that are discovered from the object files, or
919 /// discovered at runtime as things are dynamically loaded.
920 ///
921 /// \return
922 /// The shared pointer to the executable module which can
923 /// contains a nullptr Module object if no executable has been
924 /// set.
925 ///
926 /// \see DynamicLoader
927 /// \see ObjectFile::GetDependentModules (FileSpecList&)
928 /// \see Process::SetExecutableModule(lldb::ModuleSP&)
930
932
933 /// Set the main executable module.
934 ///
935 /// Each process has a notion of a main executable that is the file
936 /// that will be executed or attached to. Executable files can have
937 /// dependent modules that are discovered from the object files, or
938 /// discovered at runtime as things are dynamically loaded.
939 ///
940 /// Setting the executable causes any of the current dependent
941 /// image information to be cleared and replaced with the static
942 /// dependent image information found by calling
943 /// ObjectFile::GetDependentModules (FileSpecList&) on the main
944 /// executable and any modules on which it depends. Calling
945 /// Process::GetImages() will return the newly found images that
946 /// were obtained from all of the object files.
947 ///
948 /// \param[in] module_sp
949 /// A shared pointer reference to the module that will become
950 /// the main executable for this process.
951 ///
952 /// \param[in] load_dependent_files
953 /// If \b true then ask the object files to track down any
954 /// known dependent files.
955 ///
956 /// \see ObjectFile::GetDependentModules (FileSpecList&)
957 /// \see Process::GetImages()
959 lldb::ModuleSP &module_sp,
960 LoadDependentFiles load_dependent_files = eLoadDependentsDefault);
961
962 bool LoadScriptingResources(std::list<Status> &errors,
963 Stream &feedback_stream,
964 bool continue_on_error = true) {
966 this, errors, feedback_stream, continue_on_error);
967 }
968
969 /// Get accessor for the images for this process.
970 ///
971 /// Each process has a notion of a main executable that is the file
972 /// that will be executed or attached to. Executable files can have
973 /// dependent modules that are discovered from the object files, or
974 /// discovered at runtime as things are dynamically loaded. After
975 /// a main executable has been set, the images will contain a list
976 /// of all the files that the executable depends upon as far as the
977 /// object files know. These images will usually contain valid file
978 /// virtual addresses only. When the process is launched or attached
979 /// to, the DynamicLoader plug-in will discover where these images
980 /// were loaded in memory and will resolve the load virtual
981 /// addresses is each image, and also in images that are loaded by
982 /// code.
983 ///
984 /// \return
985 /// A list of Module objects in a module list.
986 const ModuleList &GetImages() const { return m_images; }
987
989
990 /// Return whether this FileSpec corresponds to a module that should be
991 /// considered for general searches.
992 ///
993 /// This API will be consulted by the SearchFilterForUnconstrainedSearches
994 /// and any module that returns \b true will not be searched. Note the
995 /// SearchFilterForUnconstrainedSearches is the search filter that
996 /// gets used in the CreateBreakpoint calls when no modules is provided.
997 ///
998 /// The target call at present just consults the Platform's call of the
999 /// same name.
1000 ///
1001 /// \param[in] module_spec
1002 /// Path to the module.
1003 ///
1004 /// \return \b true if the module should be excluded, \b false otherwise.
1005 bool ModuleIsExcludedForUnconstrainedSearches(const FileSpec &module_spec);
1006
1007 /// Return whether this module should be considered for general searches.
1008 ///
1009 /// This API will be consulted by the SearchFilterForUnconstrainedSearches
1010 /// and any module that returns \b true will not be searched. Note the
1011 /// SearchFilterForUnconstrainedSearches is the search filter that
1012 /// gets used in the CreateBreakpoint calls when no modules is provided.
1013 ///
1014 /// The target call at present just consults the Platform's call of the
1015 /// same name.
1016 ///
1017 /// FIXME: When we get time we should add a way for the user to set modules
1018 /// that they
1019 /// don't want searched, in addition to or instead of the platform ones.
1020 ///
1021 /// \param[in] module_sp
1022 /// A shared pointer reference to the module that checked.
1023 ///
1024 /// \return \b true if the module should be excluded, \b false otherwise.
1025 bool
1027
1028 const ArchSpec &GetArchitecture() const { return m_arch.GetSpec(); }
1029
1030 /// Returns the name of the target's ABI plugin.
1031 llvm::StringRef GetABIName() const;
1032
1033 /// Set the architecture for this target.
1034 ///
1035 /// If the current target has no Images read in, then this just sets the
1036 /// architecture, which will be used to select the architecture of the
1037 /// ExecutableModule when that is set. If the current target has an
1038 /// ExecutableModule, then calling SetArchitecture with a different
1039 /// architecture from the currently selected one will reset the
1040 /// ExecutableModule to that slice of the file backing the ExecutableModule.
1041 /// If the file backing the ExecutableModule does not contain a fork of this
1042 /// architecture, then this code will return false, and the architecture
1043 /// won't be changed. If the input arch_spec is the same as the already set
1044 /// architecture, this is a no-op.
1045 ///
1046 /// \param[in] arch_spec
1047 /// The new architecture.
1048 ///
1049 /// \param[in] set_platform
1050 /// If \b true, then the platform will be adjusted if the currently
1051 /// selected platform is not compatible with the architecture being set.
1052 /// If \b false, then just the architecture will be set even if the
1053 /// currently selected platform isn't compatible (in case it might be
1054 /// manually set following this function call).
1055 ///
1056 /// \param[in] merged
1057 /// If true, arch_spec is merged with the current
1058 /// architecture. Otherwise it's replaced.
1059 ///
1060 /// \return
1061 /// \b true if the architecture was successfully set, \b false otherwise.
1062 bool SetArchitecture(const ArchSpec &arch_spec, bool set_platform = false,
1063 bool merge = true);
1064
1065 bool MergeArchitecture(const ArchSpec &arch_spec);
1066
1068
1070
1071 size_t ReadMemoryFromFileCache(const Address &addr, void *dst, size_t dst_len,
1072 Status &error);
1073
1074 // Reading memory through the target allows us to skip going to the process
1075 // for reading memory if possible and it allows us to try and read from any
1076 // constant sections in our object files on disk. If you always want live
1077 // program memory, read straight from the process. If you possibly want to
1078 // read from const sections in object files, read from the target. This
1079 // version of ReadMemory will try and read memory from the process if the
1080 // process is alive. The order is:
1081 // 1 - if (force_live_memory == false) and the address falls in a read-only
1082 // section, then read from the file cache
1083 // 2 - if there is a process, then read from memory
1084 // 3 - if there is no process, then read from the file cache
1085 //
1086 // The method is virtual for mocking in the unit tests.
1087 virtual size_t ReadMemory(const Address &addr, void *dst, size_t dst_len,
1088 Status &error, bool force_live_memory = false,
1089 lldb::addr_t *load_addr_ptr = nullptr);
1090
1091 size_t ReadCStringFromMemory(const Address &addr, std::string &out_str,
1092 Status &error, bool force_live_memory = false);
1093
1094 size_t ReadCStringFromMemory(const Address &addr, char *dst,
1095 size_t dst_max_len, Status &result_error,
1096 bool force_live_memory = false);
1097
1098 /// Read a NULL terminated string from memory
1099 ///
1100 /// This function will read a cache page at a time until a NULL string
1101 /// terminator is found. It will stop reading if an aligned sequence of NULL
1102 /// termination \a type_width bytes is not found before reading \a
1103 /// cstr_max_len bytes. The results are always guaranteed to be NULL
1104 /// terminated, and that no more than (max_bytes - type_width) bytes will be
1105 /// read.
1106 ///
1107 /// \param[in] addr
1108 /// The address to start the memory read.
1109 ///
1110 /// \param[in] dst
1111 /// A character buffer containing at least max_bytes.
1112 ///
1113 /// \param[in] max_bytes
1114 /// The maximum number of bytes to read.
1115 ///
1116 /// \param[in] error
1117 /// The error status of the read operation.
1118 ///
1119 /// \param[in] type_width
1120 /// The size of the null terminator (1 to 4 bytes per
1121 /// character). Defaults to 1.
1122 ///
1123 /// \return
1124 /// The error status or the number of bytes prior to the null terminator.
1125 size_t ReadStringFromMemory(const Address &addr, char *dst, size_t max_bytes,
1126 Status &error, size_t type_width,
1127 bool force_live_memory = true);
1128
1129 size_t ReadScalarIntegerFromMemory(const Address &addr, uint32_t byte_size,
1130 bool is_signed, Scalar &scalar,
1131 Status &error,
1132 bool force_live_memory = false);
1133
1134 uint64_t ReadUnsignedIntegerFromMemory(const Address &addr,
1135 size_t integer_byte_size,
1136 uint64_t fail_value, Status &error,
1137 bool force_live_memory = false);
1138
1139 bool ReadPointerFromMemory(const Address &addr, Status &error,
1140 Address &pointer_addr,
1141 bool force_live_memory = false);
1142
1145 }
1146
1147 static Target *GetTargetFromContexts(const ExecutionContext *exe_ctx_ptr,
1148 const SymbolContext *sc_ptr);
1149
1150 // lldb::ExecutionContextScope pure virtual functions
1152
1154
1156
1158
1159 void CalculateExecutionContext(ExecutionContext &exe_ctx) override;
1160
1162
1163 llvm::Expected<lldb::TypeSystemSP>
1165 bool create_on_demand = true);
1166
1167 std::vector<lldb::TypeSystemSP>
1168 GetScratchTypeSystems(bool create_on_demand = true);
1169
1172
1173 // Creates a UserExpression for the given language, the rest of the
1174 // parameters have the same meaning as for the UserExpression constructor.
1175 // Returns a new-ed object which the caller owns.
1176
1178 GetUserExpressionForLanguage(llvm::StringRef expr, llvm::StringRef prefix,
1179 SourceLanguage language,
1180 Expression::ResultType desired_type,
1181 const EvaluateExpressionOptions &options,
1182 ValueObject *ctx_obj, Status &error);
1183
1184 // Creates a FunctionCaller for the given language, the rest of the
1185 // parameters have the same meaning as for the FunctionCaller constructor.
1186 // Since a FunctionCaller can't be
1187 // IR Interpreted, it makes no sense to call this with an
1188 // ExecutionContextScope that lacks
1189 // a Process.
1190 // Returns a new-ed object which the caller owns.
1191
1193 const CompilerType &return_type,
1194 const Address &function_address,
1195 const ValueList &arg_value_list,
1196 const char *name, Status &error);
1197
1198 /// Creates and installs a UtilityFunction for the given language.
1199 llvm::Expected<std::unique_ptr<UtilityFunction>>
1200 CreateUtilityFunction(std::string expression, std::string name,
1201 lldb::LanguageType language, ExecutionContext &exe_ctx);
1202
1203 // Install any files through the platform that need be to installed prior to
1204 // launching or attaching.
1205 Status Install(ProcessLaunchInfo *launch_info);
1206
1207 bool ResolveFileAddress(lldb::addr_t load_addr, Address &so_addr);
1208
1209 bool ResolveLoadAddress(lldb::addr_t load_addr, Address &so_addr,
1210 uint32_t stop_id = SectionLoadHistory::eStopIDNow);
1211
1212 bool SetSectionLoadAddress(const lldb::SectionSP &section,
1213 lldb::addr_t load_addr,
1214 bool warn_multiple = false);
1215
1216 size_t UnloadModuleSections(const lldb::ModuleSP &module_sp);
1217
1218 size_t UnloadModuleSections(const ModuleList &module_list);
1219
1220 bool SetSectionUnloaded(const lldb::SectionSP &section_sp);
1221
1222 bool SetSectionUnloaded(const lldb::SectionSP &section_sp,
1223 lldb::addr_t load_addr);
1224
1226
1227 /// Set the \a Trace object containing processor trace information of this
1228 /// target.
1229 ///
1230 /// \param[in] trace_sp
1231 /// The trace object.
1232 void SetTrace(const lldb::TraceSP &trace_sp);
1233
1234 /// Get the \a Trace object containing processor trace information of this
1235 /// target.
1236 ///
1237 /// \return
1238 /// The trace object. It might be undefined.
1240
1241 /// Create a \a Trace object for the current target using the using the
1242 /// default supported tracing technology for this process.
1243 ///
1244 /// \return
1245 /// The new \a Trace or an \a llvm::Error if a \a Trace already exists or
1246 /// the trace couldn't be created.
1247 llvm::Expected<lldb::TraceSP> CreateTrace();
1248
1249 /// If a \a Trace object is present, this returns it, otherwise a new Trace is
1250 /// created with \a Trace::CreateTrace.
1251 llvm::Expected<lldb::TraceSP> GetTraceOrCreate();
1252
1253 // Since expressions results can persist beyond the lifetime of a process,
1254 // and the const expression results are available after a process is gone, we
1255 // provide a way for expressions to be evaluated from the Target itself. If
1256 // an expression is going to be run, then it should have a frame filled in in
1257 // the execution context.
1259 llvm::StringRef expression, ExecutionContextScope *exe_scope,
1260 lldb::ValueObjectSP &result_valobj_sp,
1262 std::string *fixed_expression = nullptr, ValueObject *ctx_obj = nullptr);
1263
1265
1267
1268 /// This method will return the address of the starting function for
1269 /// this binary, e.g. main() or its equivalent. This can be used as
1270 /// an address of a function that is not called once a binary has
1271 /// started running - e.g. as a return address for inferior function
1272 /// calls that are unambiguous completion of the function call, not
1273 /// called during the course of the inferior function code running.
1274 ///
1275 /// If no entry point can be found, an invalid address is returned.
1276 ///
1277 /// \param [out] err
1278 /// This object will be set to failure if no entry address could
1279 /// be found, and may contain a helpful error message.
1280 //
1281 /// \return
1282 /// Returns the entry address for this program, or an error
1283 /// if none can be found.
1284 llvm::Expected<lldb_private::Address> GetEntryPointAddress();
1285
1286 CompilerType GetRegisterType(const std::string &name,
1287 const lldb_private::RegisterFlags &flags,
1288 uint32_t byte_size);
1289
1290 // Target Stop Hooks
1291 class StopHook : public UserID {
1292 public:
1293 StopHook(const StopHook &rhs);
1294 virtual ~StopHook() = default;
1295
1296 enum class StopHookKind : uint32_t { CommandBased = 0, ScriptBased };
1297 enum class StopHookResult : uint32_t {
1298 KeepStopped = 0,
1301 };
1302
1304
1305 // Set the specifier. The stop hook will own the specifier, and is
1306 // responsible for deleting it when we're done.
1307 void SetSpecifier(SymbolContextSpecifier *specifier);
1308
1310
1311 bool ExecutionContextPasses(const ExecutionContext &exe_ctx);
1312
1313 // Called on stop, this gets passed the ExecutionContext for each "stop
1314 // with a reason" thread. It should add to the stream whatever text it
1315 // wants to show the user, and return False to indicate it wants the target
1316 // not to stop.
1318 lldb::StreamSP output) = 0;
1319
1320 // Set the Thread Specifier. The stop hook will own the thread specifier,
1321 // and is responsible for deleting it when we're done.
1322 void SetThreadSpecifier(ThreadSpec *specifier);
1323
1325
1326 bool IsActive() { return m_active; }
1327
1328 void SetIsActive(bool is_active) { m_active = is_active; }
1329
1330 void SetAutoContinue(bool auto_continue) {
1331 m_auto_continue = auto_continue;
1332 }
1333
1334 bool GetAutoContinue() const { return m_auto_continue; }
1335
1336 void GetDescription(Stream &s, lldb::DescriptionLevel level) const;
1338 lldb::DescriptionLevel level) const = 0;
1339
1340 protected:
1343 std::unique_ptr<ThreadSpec> m_thread_spec_up;
1344 bool m_active = true;
1345 bool m_auto_continue = false;
1346
1347 StopHook(lldb::TargetSP target_sp, lldb::user_id_t uid);
1348 };
1349
1351 public:
1352 ~StopHookCommandLine() override = default;
1353
1355 void SetActionFromString(const std::string &strings);
1356 void SetActionFromStrings(const std::vector<std::string> &strings);
1357
1359 lldb::StreamSP output_sp) override;
1361 lldb::DescriptionLevel level) const override;
1362
1363 private:
1365 // Use CreateStopHook to make a new empty stop hook. The GetCommandPointer
1366 // and fill it with commands, and SetSpecifier to set the specifier shared
1367 // pointer (can be null, that will match anything.)
1369 : StopHook(target_sp, uid) {}
1370 friend class Target;
1371 };
1372
1374 public:
1375 ~StopHookScripted() override = default;
1377 lldb::StreamSP output) override;
1378
1379 Status SetScriptCallback(std::string class_name,
1380 StructuredData::ObjectSP extra_args_sp);
1381
1383 lldb::DescriptionLevel level) const override;
1384
1385 private:
1386 std::string m_class_name;
1387 /// This holds the dictionary of keys & values that can be used to
1388 /// parametrize any given callback's behavior.
1390 /// This holds the python callback object.
1392
1393 /// Use CreateStopHook to make a new empty stop hook. The GetCommandPointer
1394 /// and fill it with commands, and SetSpecifier to set the specifier shared
1395 /// pointer (can be null, that will match anything.)
1397 : StopHook(target_sp, uid) {}
1398 friend class Target;
1399 };
1400
1401 typedef std::shared_ptr<StopHook> StopHookSP;
1402
1403 /// Add an empty stop hook to the Target's stop hook list, and returns a
1404 /// shared pointer to it in new_hook. Returns the id of the new hook.
1406
1407 /// If you tried to create a stop hook, and that failed, call this to
1408 /// remove the stop hook, as it will also reset the stop hook counter.
1410
1411 // Runs the stop hooks that have been registered for this target.
1412 // Returns true if the stop hooks cause the target to resume.
1413 bool RunStopHooks();
1414
1416
1417 bool SetSuppresStopHooks(bool suppress) {
1418 bool old_value = m_suppress_stop_hooks;
1419 m_suppress_stop_hooks = suppress;
1420 return old_value;
1421 }
1422
1424
1426
1427 void RemoveAllStopHooks();
1428
1430
1431 bool SetStopHookActiveStateByID(lldb::user_id_t uid, bool active_state);
1432
1433 void SetAllStopHooksActiveState(bool active_state);
1434
1435 size_t GetNumStopHooks() const { return m_stop_hooks.size(); }
1436
1438 if (index >= GetNumStopHooks())
1439 return StopHookSP();
1440 StopHookCollection::iterator pos = m_stop_hooks.begin();
1441
1442 while (index > 0) {
1443 pos++;
1444 index--;
1445 }
1446 return (*pos).second;
1447 }
1448
1450
1451 void SetPlatform(const lldb::PlatformSP &platform_sp) {
1452 m_platform_sp = platform_sp;
1453 }
1454
1456
1457 // Methods.
1459 GetSearchFilterForModule(const FileSpec *containingModule);
1460
1462 GetSearchFilterForModuleList(const FileSpecList *containingModuleList);
1463
1465 GetSearchFilterForModuleAndCUList(const FileSpecList *containingModules,
1466 const FileSpecList *containingSourceFiles);
1467
1469 const char *repl_options, bool can_create);
1470
1471 void SetREPL(lldb::LanguageType language, lldb::REPLSP repl_sp);
1472
1475 }
1476
1478
1479 /// Add a signal for the target. This will get copied over to the process
1480 /// if the signal exists on that target. Only the values with Yes and No are
1481 /// set, Calculate values will be ignored.
1482protected:
1488 : pass(pass), notify(notify), stop(stop) {}
1490 };
1491 using DummySignalElement = llvm::StringMapEntry<DummySignalValues>;
1492 static bool UpdateSignalFromDummy(lldb::UnixSignalsSP signals_sp,
1493 const DummySignalElement &element);
1494 static bool ResetSignalFromDummy(lldb::UnixSignalsSP signals_sp,
1495 const DummySignalElement &element);
1496
1497public:
1498 /// Add a signal to the Target's list of stored signals/actions. These
1499 /// values will get copied into any processes launched from
1500 /// this target.
1501 void AddDummySignal(llvm::StringRef name, LazyBool pass, LazyBool print,
1502 LazyBool stop);
1503 /// Updates the signals in signals_sp using the stored dummy signals.
1504 /// If warning_stream_sp is not null, if any stored signals are not found in
1505 /// the current process, a warning will be emitted here.
1507 lldb::StreamSP warning_stream_sp);
1508 /// Clear the dummy signals in signal_names from the target, or all signals
1509 /// if signal_names is empty. Also remove the behaviors they set from the
1510 /// process's signals if it exists.
1511 void ClearDummySignals(Args &signal_names);
1512 /// Print all the signals set in this target.
1513 void PrintDummySignals(Stream &strm, Args &signals);
1514
1515protected:
1516 /// Implementing of ModuleList::Notifier.
1517
1518 void NotifyModuleAdded(const ModuleList &module_list,
1519 const lldb::ModuleSP &module_sp) override;
1520
1521 void NotifyModuleRemoved(const ModuleList &module_list,
1522 const lldb::ModuleSP &module_sp) override;
1523
1524 void NotifyModuleUpdated(const ModuleList &module_list,
1525 const lldb::ModuleSP &old_module_sp,
1526 const lldb::ModuleSP &new_module_sp) override;
1527
1528 void NotifyWillClearList(const ModuleList &module_list) override;
1529
1530 void NotifyModulesRemoved(lldb_private::ModuleList &module_list) override;
1531
1532 class Arch {
1533 public:
1534 explicit Arch(const ArchSpec &spec);
1535 const Arch &operator=(const ArchSpec &spec);
1536
1537 const ArchSpec &GetSpec() const { return m_spec; }
1538 Architecture *GetPlugin() const { return m_plugin_up.get(); }
1539
1540 private:
1542 std::unique_ptr<Architecture> m_plugin_up;
1543 };
1544
1545 // Member variables.
1547 lldb::PlatformSP m_platform_sp; ///< The platform for this target.
1548 std::recursive_mutex m_mutex; ///< An API mutex that is used by the lldb::SB*
1549 /// classes make the SB interface thread safe
1550 /// When the private state thread calls SB API's - usually because it is
1551 /// running OS plugin or Python ThreadPlan code - it should not block on the
1552 /// API mutex that is held by the code that kicked off the sequence of events
1553 /// that led us to run the code. We hand out this mutex instead when we
1554 /// detect that code is running on the private state thread.
1555 std::recursive_mutex m_private_mutex;
1557 std::string m_label;
1558 ModuleList m_images; ///< The list of images for this process (shared
1559 /// libraries and anything dynamically loaded).
1564 std::map<ConstString, std::unique_ptr<BreakpointName>>;
1566
1570 // We want to tightly control the process destruction process so we can
1571 // correctly tear down everything that we need to, so the only class that
1572 // knows about the process lifespan is this target class.
1577
1578 typedef std::map<lldb::LanguageType, lldb::REPLSP> REPLMap;
1580
1582
1583 typedef std::map<lldb::user_id_t, StopHookSP> StopHookCollection;
1586 uint32_t m_latest_stop_hook_id; /// This records the last natural stop at
1587 /// which we ran a stop-hook.
1589 bool m_suppress_stop_hooks; /// Used to not run stop hooks for expressions
1592 /// An optional \a lldb_private::Trace object containing processor trace
1593 /// information of this target.
1595 /// Stores the frame recognizers of this target.
1597 /// These are used to set the signal state when you don't have a process and
1598 /// more usefully in the Dummy target where you can't know exactly what
1599 /// signals you will have.
1600 llvm::StringMap<DummySignalValues> m_dummy_signals;
1601
1602 static void ImageSearchPathsChanged(const PathMappingList &path_list,
1603 void *baton);
1604
1605 // Utilities for `statistics` command.
1606private:
1607 // Target metrics storage.
1609
1610public:
1611 /// Get metrics associated with this target in JSON format.
1612 ///
1613 /// Target metrics help measure timings and information that is contained in
1614 /// a target. These are designed to help measure performance of a debug
1615 /// session as well as represent the current state of the target, like
1616 /// information on the currently modules, currently set breakpoints and more.
1617 ///
1618 /// \return
1619 /// Returns a JSON value that contains all target metrics.
1620 llvm::json::Value
1622
1624
1625protected:
1626 /// Construct with optional file and arch.
1627 ///
1628 /// This member is private. Clients must use
1629 /// TargetList::CreateTarget(const FileSpec*, const ArchSpec*)
1630 /// so all targets can be tracked from the central target list.
1631 ///
1632 /// \see TargetList::CreateTarget(const FileSpec*, const ArchSpec*)
1633 Target(Debugger &debugger, const ArchSpec &target_arch,
1634 const lldb::PlatformSP &platform_sp, bool is_dummy_target);
1635
1636 // Helper function.
1637 bool ProcessIsValid();
1638
1639 // Copy breakpoints, stop hooks and so forth from the dummy target:
1640 void PrimeFromDummyTarget(Target &target);
1641
1642 void AddBreakpoint(lldb::BreakpointSP breakpoint_sp, bool internal);
1643
1645
1646 /// Return a recommended size for memory reads at \a addr, optimizing for
1647 /// cache usage.
1649
1650 Target(const Target &) = delete;
1651 const Target &operator=(const Target &) = delete;
1652};
1653
1654} // namespace lldb_private
1655
1656#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...
An event broadcasting class.
Definition: Broadcaster.h:146
Generic representation of a type in a programming language.
Definition: CompilerType.h:36
A uniqued constant string class.
Definition: ConstString.h:40
A class to manage flag bits.
Definition: Debugger.h:80
const char * GetPrefix() const
Definition: Target.h:333
void SetOneThreadTimeout(const Timeout< std::micro > &timeout)
Definition: Target.h:375
uint64_t GetRetriesWithFixIts() const
Definition: Target.h:454
void SetUnwindOnError(bool unwind=false)
Definition: Target.h:348
SourceLanguage GetLanguage() const
Definition: Target.h:318
const char * GetPoundLineFilePath() const
Definition: Target.h:434
lldb::DynamicValueType m_use_dynamic
Definition: Target.h:482
void SetExecutionPolicy(ExecutionPolicy policy=eExecutionPolicyAlways)
Definition: Target.h:314
Timeout< std::micro > m_one_thread_timeout
Definition: Target.h:484
bool InvokeCancelCallback(lldb::ExpressionEvaluationPhase phase) const
Definition: Target.h:416
lldb::DynamicValueType GetUseDynamic() const
Definition: Target.h:360
void SetKeepInMemory(bool keep=true)
Definition: Target.h:358
void SetCoerceToId(bool coerce=true)
Definition: Target.h:344
void SetLanguage(lldb::LanguageType language_type)
Definition: Target.h:320
ExecutionPolicy GetExecutionPolicy() const
Definition: Target.h:312
Timeout< std::micro > m_timeout
Definition: Target.h:483
void SetPrefix(const char *prefix)
Definition: Target.h:337
void SetTryAllThreads(bool try_others=true)
Definition: Target.h:381
void SetPoundLine(const char *path, uint32_t line) const
Definition: Target.h:424
void SetRetriesWithFixIts(uint64_t number_of_retries)
Definition: Target.h:450
void SetTimeout(const Timeout< std::micro > &timeout)
Definition: Target.h:369
static constexpr ExecutionPolicy default_execution_policy
Definition: Target.h:307
void SetStopOthers(bool stop_others=true)
Definition: Target.h:385
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:480
void SetCancelCallback(lldb::ExpressionCancelCallback callback, void *baton)
Definition: Target.h:411
const Timeout< std::micro > & GetTimeout() const
Definition: Target.h:367
void SetIgnoreBreakpoints(bool ignore=false)
Definition: Target.h:352
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:327
void SetUseDynamic(lldb::DynamicValueType dynamic=lldb::eDynamicCanRunTarget)
Definition: Target.h:363
lldb::ExpressionCancelCallback m_cancel_callback
Definition: Target.h:485
static constexpr std::chrono::milliseconds default_timeout
Definition: Target.h:302
const Timeout< std::micro > & GetOneThreadTimeout() const
Definition: Target.h:371
"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.
Definition: FileSpecList.h:91
A file utility class.
Definition: FileSpec.h:56
Encapsulates a function that can be called.
A collection class for Module objects.
Definition: ModuleList.h:103
bool LoadScriptingResourcesInTarget(Target *target, std::list< Status > &errors, Stream &feedback_stream, bool continue_on_error=true)
A class that describes an executable image and its associated object and symbol files.
Definition: Module.h:88
SectionLoadList & GetCurrentSectionLoadList()
Class that provides a registry of known stack frame recognizers.
An error handling class.
Definition: Status.h:44
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
std::shared_ptr< Generic > GenericSP
std::shared_ptr< Object > ObjectSP
Defines a symbol context baton that can be handed other debug core functions.
Definition: SymbolContext.h:34
uint32_t GetMaximumSizeOfStringSummary() const
Definition: Target.cpp:4625
FileSpecList GetDebugFileSearchPaths()
Definition: Target.cpp:4506
bool GetDisplayRecognizedArguments() const
Definition: Target.cpp:4783
ImportStdModule GetImportStdModule() const
Definition: Target.cpp:4522
bool GetMoveToNearestCode() const
Definition: Target.cpp:4261
void AppendExecutableSearchPaths(const FileSpec &)
Definition: Target.cpp:4493
bool GetEnableSyntheticValue() const
Definition: Target.cpp:4592
void SetStandardInputPath(const char *path)=delete
ProcessLaunchInfo m_launch_info
Definition: Target.h:287
uint64_t GetExprAllocAlign() const
Definition: Target.cpp:4704
MemoryModuleLoadLevel GetMemoryModuleLoadLevel() const
Definition: Target.cpp:4755
llvm::StringRef GetArg0() const
Definition: Target.cpp:4365
uint32_t GetMaximumMemReadSize() const
Definition: Target.cpp:4631
void SetRunArguments(const Args &args)
Definition: Target.cpp:4382
FileSpec GetStandardErrorPath() const
Definition: Target.cpp:4657
bool GetEnableNotifyAboutFixIts() const
Definition: Target.cpp:4548
bool SetPreferDynamicValue(lldb::DynamicValueType d)
Definition: Target.cpp:4274
void SetDisplayRecognizedArguments(bool b)
Definition: Target.cpp:4789
std::optional< bool > GetExperimentalPropertyValue(size_t prop_idx, ExecutionContext *exe_ctx=nullptr) const
Definition: Target.cpp:4234
const ProcessLaunchInfo & GetProcessLaunchInfo() const
Definition: Target.cpp:4794
Environment ComputeEnvironment() const
Definition: Target.cpp:4388
void SetStandardOutputPath(const char *path)=delete
bool GetUserSpecifiedTrapHandlerNames(Args &args) const
Definition: Target.cpp:4762
uint64_t GetExprErrorLimit() const
Definition: Target.cpp:4686
bool GetEnableAutoImportClangModules() const
Definition: Target.cpp:4516
bool GetDebugUtilityExpression() const
Definition: Target.cpp:4900
DynamicClassInfoHelper GetDynamicClassInfoHelper() const
Definition: Target.cpp:4529
FileSpec GetStandardOutputPath() const
Definition: Target.cpp:4647
void SetDisplayRuntimeSupportValues(bool b)
Definition: Target.cpp:4778
uint32_t GetMaximumNumberOfChildrenToDisplay() const
Definition: Target.cpp:4610
void SetRequireHardwareBreakpoints(bool b)
Definition: Target.cpp:4832
bool GetAutoInstallMainExecutable() const
Definition: Target.cpp:4837
RealpathPrefixes GetSourceRealpathPrefixes() const
Definition: Target.cpp:4360
uint64_t GetNumberOfRetriesWithFixits() const
Definition: Target.cpp:4542
uint64_t GetExprAllocSize() const
Definition: Target.cpp:4698
llvm::StringRef GetExpressionPrefixContents()
Definition: Target.cpp:4672
PathMappingList & GetObjectPathMap() const
Definition: Target.cpp:4479
const char * GetDisassemblyFlavor() const
Definition: Target.cpp:4338
FileSpec GetStandardInputPath() const
Definition: Target.cpp:4637
lldb::DynamicValueType GetPreferDynamicValue() const
Definition: Target.cpp:4267
InlineStrategy GetInlineStrategy() const
Definition: Target.cpp:4351
Environment GetTargetEnvironment() const
Definition: Target.cpp:4448
bool GetDisplayRuntimeSupportValues() const
Definition: Target.cpp:4772
void SetUserSpecifiedTrapHandlerNames(const Args &args)
Definition: Target.cpp:4767
bool GetUseHexImmediates() const
Definition: Target.cpp:4716
uint32_t GetMaxZeroPaddingInFloatFormat() const
Definition: Target.cpp:4604
uint64_t GetExprAllocAddress() const
Definition: Target.cpp:4692
LoadCWDlldbinitFile GetLoadCWDlldbinitFile() const
Definition: Target.cpp:4741
Environment GetInheritedEnvironment() const
Definition: Target.cpp:4420
void SetArg0(llvm::StringRef arg)
Definition: Target.cpp:4371
bool GetInjectLocalVariables(ExecutionContext *exe_ctx) const
Definition: Target.cpp:4245
void SetStandardErrorPath(const char *path)=delete
bool ShowHexVariableValuesWithLeadingZeroes() const
Definition: Target.cpp:4598
SourceLanguage GetLanguage() const
Definition: Target.cpp:4667
Environment GetEnvironment() const
Definition: Target.cpp:4416
void SetProcessLaunchInfo(const ProcessLaunchInfo &launch_info)
Definition: Target.cpp:4798
FileSpec GetSaveJITObjectsDir() const
Definition: Target.cpp:4554
void SetEnvironment(Environment env)
Definition: Target.cpp:4459
LoadScriptFromSymFile GetLoadScriptFromSymbolFile() const
Definition: Target.cpp:4734
void SetStandardErrorPath(llvm::StringRef path)
Definition: Target.cpp:4662
bool GetRunArguments(Args &args) const
Definition: Target.cpp:4377
bool GetBreakpointsConsultPlatformAvoidList()
Definition: Target.cpp:4710
FileSpecList GetExecutableSearchPaths()
Definition: Target.cpp:4501
ArchSpec GetDefaultArchitecture() const
Definition: Target.cpp:4251
Disassembler::HexImmediateStyle GetHexImmediateStyle() const
Definition: Target.cpp:4748
std::unique_ptr< TargetExperimentalProperties > m_experimental_properties_up
Definition: Target.h:288
FileSpecList GetClangModuleSearchPaths()
Definition: Target.cpp:4511
void SetStandardOutputPath(llvm::StringRef path)
Definition: Target.cpp:4652
bool GetRequireHardwareBreakpoints() const
Definition: Target.cpp:4826
PathMappingList & GetSourcePathMap() const
Definition: Target.cpp:4471
bool GetAutoSourceMapRelative() const
Definition: Target.cpp:4487
void SetDefaultArchitecture(const ArchSpec &arch)
Definition: Target.cpp:4256
void SetStandardInputPath(llvm::StringRef path)
Definition: Target.cpp:4642
bool GetDisplayExpressionsInCrashlogs() const
Definition: Target.cpp:4728
bool GetEnableAutoApplyFixIts() const
Definition: Target.cpp:4536
void SetDebugUtilityExpression(bool debug)
Definition: Target.cpp:4906
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:4617
A class that represents statistics for a since lldb_private::Target.
Definition: Statistics.h:179
std::unique_ptr< Architecture > m_plugin_up
Definition: Target.h:1542
const ArchSpec & GetSpec() const
Definition: Target.h:1537
const Arch & operator=(const ArchSpec &spec)
Definition: Target.cpp:85
Architecture * GetPlugin() const
Definition: Target.h:1538
void SetActionFromString(const std::string &strings)
Definition: Target.cpp:3798
StopHookCommandLine(lldb::TargetSP target_sp, lldb::user_id_t uid)
Definition: Target.h:1368
void SetActionFromStrings(const std::vector< std::string > &strings)
Definition: Target.cpp:3802
StopHookResult HandleStop(ExecutionContext &exc_ctx, lldb::StreamSP output_sp) override
Definition: Target.cpp:3809
void GetSubclassDescription(Stream &s, lldb::DescriptionLevel level) const override
Definition: Target.cpp:3779
StructuredData::GenericSP m_implementation_sp
This holds the python callback object.
Definition: Target.h:1391
Status SetScriptCallback(std::string class_name, StructuredData::ObjectSP extra_args_sp)
Definition: Target.cpp:3843
StopHookResult HandleStop(ExecutionContext &exc_ctx, lldb::StreamSP output) override
Definition: Target.cpp:3864
StopHookScripted(lldb::TargetSP target_sp, lldb::user_id_t uid)
Use CreateStopHook to make a new empty stop hook.
Definition: Target.h:1396
void GetSubclassDescription(Stream &s, lldb::DescriptionLevel level) const override
Definition: Target.cpp:3881
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:1389
SymbolContextSpecifier * GetSpecifier()
Definition: Target.h:1309
void SetSpecifier(SymbolContextSpecifier *specifier)
Definition: Target.cpp:3713
virtual StopHookResult HandleStop(ExecutionContext &exe_ctx, lldb::StreamSP output)=0
std::unique_ptr< ThreadSpec > m_thread_spec_up
Definition: Target.h:1343
void SetIsActive(bool is_active)
Definition: Target.h:1328
void SetThreadSpecifier(ThreadSpec *specifier)
Definition: Target.cpp:3717
ThreadSpec * GetThreadSpecifier()
Definition: Target.h:1324
lldb::TargetSP m_target_sp
Definition: Target.h:1341
bool GetAutoContinue() const
Definition: Target.h:1334
bool ExecutionContextPasses(const ExecutionContext &exe_ctx)
Definition: Target.cpp:3721
lldb::TargetSP & GetTarget()
Definition: Target.h:1303
lldb::SymbolContextSpecifierSP m_specifier_sp
Definition: Target.h:1342
virtual void GetSubclassDescription(Stream &s, lldb::DescriptionLevel level) const =0
void GetDescription(Stream &s, lldb::DescriptionLevel level) const
Definition: Target.cpp:3737
void SetAutoContinue(bool auto_continue)
Definition: Target.h:1330
const ModuleList & GetModuleList() const
Definition: Target.h:549
void Dump(Stream *s) const override
Definition: Target.cpp:4926
static llvm::StringRef GetFlavorString()
Definition: Target.cpp:4922
static ModuleList GetModuleListFromEvent(const Event *event_ptr)
Definition: Target.cpp:4955
static const TargetEventData * GetEventDataFromEvent(const Event *event_ptr)
Definition: Target.cpp:4936
llvm::StringRef GetFlavor() const override
Definition: Target.h:535
const lldb::TargetSP & GetTarget() const
Definition: Target.h:547
TargetEventData(const TargetEventData &)=delete
const TargetEventData & operator=(const TargetEventData &)=delete
static lldb::TargetSP GetTargetFromEvent(const Event *event_ptr)
Definition: Target.cpp:4946
void ModulesDidLoad(ModuleList &module_list)
Definition: Target.cpp:1691
lldb::ThreadSP CalculateThread() override
Definition: Target.cpp:2402
REPLMap m_repl_map
Definition: Target.h:1579
StopHookCollection m_stop_hooks
Definition: Target.h:1584
Module * GetExecutableModulePointer()
Definition: Target.cpp:1437
void Dump(Stream *s, lldb::DescriptionLevel description_level)
Dump a description of this object to a Stream.
Definition: Target.cpp:159
bool m_suppress_stop_hooks
Definition: Target.h:1589
void DisableAllBreakpoints(bool internal_also=false)
Definition: Target.cpp:971
lldb::WatchpointSP CreateWatchpoint(lldb::addr_t addr, size_t size, const CompilerType *type, uint32_t kind, Status &error)
Definition: Target.cpp:856
void ApplyNameToBreakpoints(BreakpointName &bp_name)
Definition: Target.cpp:810
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:2832
lldb::TraceSP GetTrace()
Get the Trace object containing processor trace information of this target.
Definition: Target.cpp:3378
PathMappingList & GetImageSearchPathList()
Definition: Target.cpp:2411
void FinalizeFileActions(ProcessLaunchInfo &info)
Definition: Target.cpp:3497
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:2806
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:2814
ModuleList & GetImages()
Definition: Target.h:988
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:664
static Target * GetTargetFromContexts(const ExecutionContext *exe_ctx_ptr, const SymbolContext *sc_ptr)
Definition: Target.cpp:2646
lldb::addr_t GetBreakableLoadAddress(lldb::addr_t addr)
Definition: Target.cpp:2821
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:3645
bool SetSuppresStopHooks(bool suppress)
Definition: Target.h:1417
static void ImageSearchPathsChanged(const PathMappingList &path_list, void *baton)
Definition: Target.cpp:2415
llvm::Expected< lldb_private::Address > GetEntryPointAddress()
This method will return the address of the starting function for this binary, e.g.
Definition: Target.cpp:2772
bool IgnoreWatchpointByID(lldb::watch_id_t watch_id, uint32_t ignore_count)
Definition: Target.cpp:1407
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:630
lldb::BreakpointSP GetBreakpointByID(lldb::break_id_t break_id)
Definition: Target.cpp:329
std::shared_ptr< StopHook > StopHookSP
Definition: Target.h:1401
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:518
void SymbolsDidLoad(ModuleList &module_list)
Definition: Target.cpp:1709
bool ClearAllWatchpointHistoricValues()
Definition: Target.cpp:1321
void SetTrace(const lldb::TraceSP &trace_sp)
Set the Trace object containing processor trace information of this target.
Definition: Target.cpp:3376
BreakpointList & GetBreakpointList(bool internal=false)
Definition: Target.cpp:315
CompilerType GetRegisterType(const std::string &name, const lldb_private::RegisterFlags &flags, uint32_t byte_size)
Definition: Target.cpp:2450
BreakpointNameList m_breakpoint_names
Definition: Target.h:1565
llvm::StringRef GetABIName() const
Returns the name of the target's ABI plugin.
Definition: Target.cpp:304
SourceManager & GetSourceManager()
Definition: Target.cpp:2826
lldb::SearchFilterSP GetSearchFilterForModuleList(const FileSpecList *containingModuleList)
Definition: Target.cpp:593
StopHookSP GetStopHookByID(lldb::user_id_t uid)
Definition: Target.cpp:2861
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:1600
lldb::ProcessSP m_process_sp
Definition: Target.h:1573
lldb::SearchFilterSP m_search_filter_sp
Definition: Target.h:1574
PersistentExpressionState * GetPersistentExpressionStateForLanguage(lldb::LanguageType language)
Definition: Target.cpp:2494
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:3633
bool m_is_dummy_target
Used to not run stop hooks for expressions.
Definition: Target.h:1590
static bool UpdateSignalFromDummy(lldb::UnixSignalsSP signals_sp, const DummySignalElement &element)
Definition: Target.cpp:3591
PathMappingList m_image_search_paths
Definition: Target.h:1575
bool ModuleIsExcludedForUnconstrainedSearches(const FileSpec &module_spec)
Return whether this FileSpec corresponds to a module that should be considered for general searches.
Definition: Target.cpp:1765
lldb::StackFrameSP CalculateStackFrame() override
Definition: Target.cpp:2404
SectionLoadList & GetSectionLoadList()
Definition: Target.h:1143
lldb::addr_t GetPersistentSymbol(ConstString name)
Definition: Target.cpp:2752
void PrimeFromDummyTarget(Target &target)
Definition: Target.cpp:137
std::map< ConstString, std::unique_ptr< BreakpointName > > BreakpointNameList
Definition: Target.h:1564
static void SettingsTerminate()
Definition: Target.cpp:2605
bool EnableWatchpointByID(lldb::watch_id_t watch_id)
Definition: Target.cpp:1372
bool ResolveFileAddress(lldb::addr_t load_addr, Address &so_addr)
Definition: Target.cpp:3119
Debugger & GetDebugger()
Definition: Target.h:1069
bool ClearAllWatchpointHitCounts()
Definition: Target.cpp:1307
size_t ReadMemoryFromFileCache(const Address &addr, void *dst, size_t dst_len, Status &error)
Definition: Target.cpp:1797
void ClearAllLoadedSections()
Definition: Target.cpp:3195
size_t GetNumStopHooks() const
Definition: Target.h:1435
std::vector< lldb::TypeSystemSP > GetScratchTypeSystems(bool create_on_demand=true)
Definition: Target.cpp:2459
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:2089
void AddNameToBreakpoint(BreakpointID &id, llvm::StringRef name, Status &error)
Definition: Target.cpp:732
bool LoadScriptingResources(std::list< Status > &errors, Stream &feedback_stream, bool continue_on_error=true)
Definition: Target.h:962
void DeleteCurrentProcess()
Definition: Target.cpp:194
BreakpointList m_internal_breakpoint_list
Definition: Target.h:1562
void DisableAllowedBreakpoints()
Definition: Target.cpp:981
bool SetSectionUnloaded(const lldb::SectionSP &section_sp)
Definition: Target.cpp:3173
lldb::TargetSP CalculateTarget() override
Definition: Target.cpp:2398
const lldb::ProcessSP & GetProcessSP() const
Definition: Target.cpp:222
void ClearModules(bool delete_locations)
Definition: Target.cpp:1459
bool RemoveBreakpointByID(lldb::break_id_t break_id)
Definition: Target.cpp:1005
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:2159
static bool ResetSignalFromDummy(lldb::UnixSignalsSP signals_sp, const DummySignalElement &element)
Definition: Target.cpp:3618
Architecture * GetArchitecturePlugin() const
Definition: Target.h:1067
llvm::json::Value ReportStatistics(const lldb_private::StatisticsOptions &options)
Get metrics associated with this target in JSON format.
Definition: Target.cpp:4972
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:2547
TargetStats & GetStatistics()
Definition: Target.h:1623
void EnableAllBreakpoints(bool internal_also=false)
Definition: Target.cpp:988
Status Launch(ProcessLaunchInfo &launch_info, Stream *stream)
Definition: Target.cpp:3208
bool DisableBreakpointByID(lldb::break_id_t break_id)
Definition: Target.cpp:1025
lldb::BreakpointSP CreateBreakpointAtUserEntry(Status &error)
Definition: Target.cpp:341
BreakpointName * FindBreakpointName(ConstString name, bool can_create, Status &error)
Definition: Target.cpp:763
std::map< lldb::user_id_t, StopHookSP > StopHookCollection
Definition: Target.h:1583
llvm::Expected< lldb::TraceSP > CreateTrace()
Create a Trace object for the current target using the using the default supported tracing technology...
Definition: Target.cpp:3380
lldb::TraceSP m_trace_sp
An optional lldb_private::Trace object containing processor trace information of this target.
Definition: Target.h:1594
bool RemoveAllWatchpoints(bool end_to_end=true)
Definition: Target.cpp:1225
bool ReadPointerFromMemory(const Address &addr, Status &error, Address &pointer_addr, bool force_live_memory=false)
Definition: Target.cpp:2129
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:2847
WatchpointList m_watchpoint_list
Definition: Target.h:1568
BreakpointList m_breakpoint_list
Definition: Target.h:1561
lldb::SourceManagerUP m_source_manager_up
Definition: Target.h:1581
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)
Definition: Target.cpp:1829
bool RemoveWatchpointByID(lldb::watch_id_t watch_id)
Definition: Target.cpp:1391
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:2040
void DeleteBreakpointName(ConstString name)
Definition: Target.cpp:786
void NotifyWillClearList(const ModuleList &module_list) override
Definition: Target.cpp:1653
bool SetArchitecture(const ArchSpec &arch_spec, bool set_platform=false, bool merge=true)
Set the architecture for this target.
Definition: Target.cpp:1539
void NotifyModuleAdded(const ModuleList &module_list, const lldb::ModuleSP &module_sp) override
Implementing of ModuleList::Notifier.
Definition: Target.cpp:1655
llvm::Expected< lldb::TypeSystemSP > GetScratchTypeSystemForLanguage(lldb::LanguageType language, bool create_on_demand=true)
Definition: Target.cpp:2424
void ConfigureBreakpointName(BreakpointName &bp_name, const BreakpointOptions &options, const BreakpointName::Permissions &permissions)
Definition: Target.cpp:802
lldb::SearchFilterSP GetSearchFilterForModuleAndCUList(const FileSpecList *containingModules, const FileSpecList *containingSourceFiles)
Definition: Target.cpp:610
lldb::ModuleSP GetExecutableModule()
Gets the module for the main executable.
Definition: Target.cpp:1423
bool SetStopHookActiveStateByID(lldb::user_id_t uid, bool active_state)
Definition: Target.cpp:2871
const lldb::ProcessSP & CreateProcess(lldb::ListenerSP listener_sp, llvm::StringRef plugin_name, const FileSpec *crash_file, bool can_connect)
Definition: Target.cpp:210
void SetAllStopHooksActiveState(bool active_state)
Definition: Target.cpp:2882
lldb::ExpressionVariableSP GetPersistentVariable(ConstString name)
Definition: Target.cpp:2733
void NotifyModulesRemoved(lldb_private::ModuleList &module_list) override
Definition: Target.cpp:1687
size_t ReadCStringFromMemory(const Address &addr, std::string &out_str, Status &error, bool force_live_memory=false)
Definition: Target.cpp:1950
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:1548
void ModulesDidUnload(ModuleList &module_list, bool delete_locations)
Definition: Target.cpp:1725
void CalculateExecutionContext(ExecutionContext &exe_ctx) override
Reconstruct the object's execution context into sc.
Definition: Target.cpp:2406
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:3405
void NotifyModuleUpdated(const ModuleList &module_list, const lldb::ModuleSP &old_module_sp, const lldb::ModuleSP &new_module_sp) override
Definition: Target.cpp:1675
Target(const Target &)=delete
Status SerializeBreakpointsToFile(const FileSpec &file, const BreakpointIDList &bp_ids, bool append)
Definition: Target.cpp:1066
void DidExec()
Called as the last function in Process::DidExec().
Definition: Target.cpp:1466
void SaveScriptedLaunchInfo(lldb_private::ProcessInfo &process_info)
Definition: Target.cpp:3197
bool GetSuppressStopHooks()
Definition: Target.h:1423
std::string m_label
Definition: Target.h:1557
lldb::user_id_t m_stop_hook_next_id
Definition: Target.h:1585
void RemoveAllStopHooks()
Definition: Target.cpp:2859
static FileSpecList GetDefaultExecutableSearchPaths()
Definition: Target.cpp:2607
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:647
lldb::SearchFilterSP GetSearchFilterForModule(const FileSpec *containingModule)
Definition: Target.cpp:575
llvm::StringMapEntry< DummySignalValues > DummySignalElement
Definition: Target.h:1491
std::recursive_mutex & GetAPIMutex()
Definition: Target.cpp:4963
static llvm::StringRef GetStaticBroadcasterClass()
Definition: Target.cpp:91
static FileSpecList GetDefaultDebugFileSearchPaths()
Definition: Target.cpp:2611
void EnableAllowedBreakpoints()
Definition: Target.cpp:998
llvm::Error SetLabel(llvm::StringRef label)
Set a label for a target.
Definition: Target.cpp:2626
uint32_t m_latest_stop_hook_id
Definition: Target.h:1586
@ eBroadcastBitModulesLoaded
Definition: Target.h:507
@ eBroadcastBitSymbolsChanged
Definition: Target.h:511
@ eBroadcastBitSymbolsLoaded
Definition: Target.h:510
@ eBroadcastBitModulesUnloaded
Definition: Target.h:508
@ eBroadcastBitWatchpointChanged
Definition: Target.h:509
@ eBroadcastBitBreakpointChanged
Definition: Target.h:506
StackFrameRecognizerManager & GetFrameRecognizerManager()
Definition: Target.h:1473
void RemoveAllowedBreakpoints()
Definition: Target.cpp:950
StopHookSP GetStopHookAtIndex(size_t index)
Definition: Target.h:1437
bool DisableAllWatchpoints(bool end_to_end=true)
Definition: Target.cpp:1254
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:2027
lldb::PlatformSP m_platform_sp
The platform for this target.
Definition: Target.h:1547
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:2577
static TargetProperties & GetGlobalProperties()
Definition: Target.cpp:3058
Status Install(ProcessLaunchInfo *launch_info)
Definition: Target.cpp:3066
lldb::PlatformSP GetPlatform()
Definition: Target.h:1449
void NotifyModuleRemoved(const ModuleList &module_list, const lldb::ModuleSP &module_sp) override
Definition: Target.cpp:1665
lldb::BreakpointSP CreateAddressInModuleBreakpoint(lldb::addr_t file_addr, bool internal, const FileSpec &file_spec, bool request_hardware)
Definition: Target.cpp:484
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:396
bool ResolveLoadAddress(lldb::addr_t load_addr, Address &so_addr, uint32_t stop_id=SectionLoadHistory::eStopIDNow)
Definition: Target.cpp:3114
void RemoveAllBreakpoints(bool internal_also=false)
Definition: Target.cpp:959
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:379
static ArchSpec GetDefaultArchitecture()
Definition: Target.cpp:2615
void ResetBreakpointHitCounts()
Resets the hit count of all breakpoints.
Definition: Target.cpp:1062
const ModuleList & GetImages() const
Get accessor for the images for this process.
Definition: Target.h:986
const ArchSpec & GetArchitecture() const
Definition: Target.h:1028
WatchpointList & GetWatchpointList()
Definition: Target.h:779
unsigned m_next_persistent_variable_index
Definition: Target.h:1591
bool EnableBreakpointByID(lldb::break_id_t break_id)
Definition: Target.cpp:1043
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, LazyBool skip_prologue, bool internal, bool request_hardware)
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:2118
TargetStats m_stats
Definition: Target.h:1608
bool IgnoreAllWatchpoints(uint32_t ignore_count)
Definition: Target.cpp:1336
void AddBreakpoint(lldb::BreakpointSP breakpoint_sp, bool internal)
Definition: Target.cpp:709
TypeSystemMap m_scratch_type_system_map
Definition: Target.h:1576
void AddBreakpointName(std::unique_ptr< BreakpointName > bp_name)
Definition: Target.cpp:758
SectionLoadHistory m_section_load_history
Definition: Target.h:1560
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:824
bool IsDummyTarget() const
Definition: Target.h:573
size_t UnloadModuleSections(const lldb::ModuleSP &module_sp)
Definition: Target.cpp:3154
const std::string & GetLabel() const
Definition: Target.h:575
bool m_valid
This records the last natural stop at which we ran a stop-hook.
Definition: Target.h:1588
bool DisableWatchpointByID(lldb::watch_id_t watch_id)
Definition: Target.cpp:1353
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:3576
lldb::WatchpointSP m_last_created_watchpoint
Definition: Target.h:1569
Status CreateBreakpointsFromFile(const FileSpec &file, BreakpointIDList &new_bps)
Definition: Target.cpp:1158
Debugger & m_debugger
Definition: Target.h:1546
void SetREPL(lldb::LanguageType language, lldb::REPLSP repl_sp)
Definition: Target.cpp:274
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:1472
lldb::StackFrameRecognizerManagerUP m_frame_recognizer_manager_up
Stores the frame recognizers of this target.
Definition: Target.h:1596
lldb::REPLSP GetREPL(Status &err, lldb::LanguageType language, const char *repl_options, bool can_create)
Definition: Target.cpp:224
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:2514
ModuleList m_images
The list of images for this process (shared libraries and anything dynamically loaded).
Definition: Target.h:1558
lldb::ProcessSP CalculateProcess() override
Definition: Target.cpp:2400
void PrintDummySignals(Stream &strm, Args &signals)
Print all the signals set in this target.
Definition: Target.cpp:3670
void SetPlatform(const lldb::PlatformSP &platform_sp)
Definition: Target.h:1451
bool SetSectionLoadAddress(const lldb::SectionSP &section, lldb::addr_t load_addr, bool warn_multiple=false)
Definition: Target.cpp:3124
Status Attach(ProcessAttachInfo &attach_info, Stream *stream)
Definition: Target.cpp:3411
std::map< lldb::LanguageType, lldb::REPLSP > REPLMap
Definition: Target.h:1578
static void SetDefaultArchitecture(const ArchSpec &arch)
Definition: Target.cpp:2619
lldb::BreakpointSP m_last_created_breakpoint
Definition: Target.h:1567
lldb::WatchpointSP GetLastCreatedWatchpoint()
Definition: Target.h:775
void RemoveNameFromBreakpoint(lldb::BreakpointSP &bp_sp, ConstString name)
Definition: Target.cpp:797
bool RemoveStopHookByID(lldb::user_id_t uid)
Definition: Target.cpp:2854
lldb::BreakpointSP GetLastCreatedBreakpoint()
Definition: Target.h:667
static void SettingsInitialize()
Definition: Target.cpp:2603
~Target() override
Definition: Target.cpp:131
bool EnableAllWatchpoints(bool end_to_end=true)
Definition: Target.cpp:1281
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:1555
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:2660
bool MergeArchitecture(const ArchSpec &arch_spec)
Definition: Target.cpp:1628
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.
LoadScriptFromSymFile
Definition: Target.h:51
@ eLoadScriptFromSymFileTrue
Definition: Target.h:52
@ eLoadScriptFromSymFileFalse
Definition: Target.h:53
@ eLoadScriptFromSymFileWarn
Definition: Target.h:54
ExecutionPolicy
Expression execution policies.
DynamicClassInfoHelper
Definition: Target.h:69
@ eDynamicClassInfoHelperCopyRealizedClassList
Definition: Target.h:72
@ eDynamicClassInfoHelperGetRealizedClassList
Definition: Target.h:73
@ eDynamicClassInfoHelperAuto
Definition: Target.h:70
@ eDynamicClassInfoHelperRealizedClassesStruct
Definition: Target.h:71
OptionEnumValues GetDynamicValueTypes()
Definition: Target.cpp:3941
ImportStdModule
Definition: Target.h:63
@ eImportStdModuleFalse
Definition: Target.h:64
@ eImportStdModuleFallback
Definition: Target.h:65
@ eImportStdModuleTrue
Definition: Target.h:66
LoadCWDlldbinitFile
Definition: Target.h:57
@ eLoadCWDlldbinitTrue
Definition: Target.h:58
@ eLoadCWDlldbinitFalse
Definition: Target.h:59
@ eLoadCWDlldbinitWarn
Definition: Target.h:60
llvm::ArrayRef< OptionEnumValueElement > OptionEnumValues
InlineStrategy
Definition: Target.h:45
@ eInlineBreakpointsNever
Definition: Target.h:46
@ eInlineBreakpointsAlways
Definition: Target.h:48
@ eInlineBreakpointsHeaders
Definition: Target.h:47
ExpressionEvaluationPhase
Expression Evaluation Stages.
std::shared_ptr< lldb_private::Trace > TraceSP
Definition: lldb-forward.h:454
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
Definition: lldb-forward.h:420
std::shared_ptr< lldb_private::SearchFilter > SearchFilterSP
Definition: lldb-forward.h:418
std::shared_ptr< lldb_private::BreakpointResolver > BreakpointResolverSP
Definition: lldb-forward.h:326
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
std::unique_ptr< lldb_private::StackFrameRecognizerManager > StackFrameRecognizerManagerUP
Definition: lldb-forward.h:426
std::shared_ptr< lldb_private::Thread > ThreadSP
Definition: lldb-forward.h:446
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
Definition: lldb-forward.h:480
std::shared_ptr< lldb_private::ExpressionVariable > ExpressionVariableSP
Definition: lldb-forward.h:349
std::shared_ptr< lldb_private::UnixSignals > UnixSignalsSP
Definition: lldb-forward.h:476
std::shared_ptr< lldb_private::Platform > PlatformSP
Definition: lldb-forward.h:386
LanguageType
Programming language type.
std::shared_ptr< lldb_private::Stream > StreamSP
Definition: lldb-forward.h:428
std::shared_ptr< lldb_private::Breakpoint > BreakpointSP
Definition: lldb-forward.h:319
ExpressionResults
The results of expression evaluation.
int32_t break_id_t
Definition: lldb-types.h:86
std::unique_ptr< lldb_private::SourceManager > SourceManagerUP
Definition: lldb-forward.h:419
std::shared_ptr< lldb_private::Process > ProcessSP
Definition: lldb-forward.h:387
std::shared_ptr< lldb_private::SymbolContextSpecifier > SymbolContextSpecifierSP
Definition: lldb-forward.h:439
std::shared_ptr< lldb_private::Watchpoint > WatchpointSP
Definition: lldb-forward.h:485
std::shared_ptr< lldb_private::Listener > ListenerSP
Definition: lldb-forward.h:366
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
Definition: lldb-forward.h:414
uint64_t addr_t
Definition: lldb-types.h:80
std::shared_ptr< lldb_private::Target > TargetSP
Definition: lldb-forward.h:444
@ eDynamicCanRunTarget
@ eNoDynamicValues
bool(* ExpressionCancelCallback)(lldb::ExpressionEvaluationPhase phase, void *baton)
Definition: lldb-types.h:75
std::shared_ptr< lldb_private::Module > ModuleSP
Definition: lldb-forward.h:371
std::shared_ptr< lldb_private::REPL > REPLSP
Definition: lldb-forward.h:399
A type-erased pair of llvm::dwarf::SourceLanguageName and version.
Add a signal for the target.
Definition: Target.h:1483
DummySignalValues(LazyBool pass, LazyBool notify, LazyBool stop)
Definition: Target.h:1487
A mix in class that contains a generic user ID.
Definition: UserID.h:31