LLDB mainline
Process.h
Go to the documentation of this file.
1//===-- Process.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_PROCESS_H
10#define LLDB_TARGET_PROCESS_H
11
12#include "lldb/Host/Config.h"
13
14#include <climits>
15
16#include <chrono>
17#include <list>
18#include <memory>
19#include <mutex>
20#include <optional>
21#include <string>
22#include <unordered_set>
23#include <vector>
24
42#include "lldb/Target/Memory.h"
47#include "lldb/Target/Trace.h"
51#include "lldb/Utility/Event.h"
55#include "lldb/Utility/Status.h"
60#include "lldb/lldb-private.h"
61
62#include "llvm/ADT/AddressRanges.h"
63#include "llvm/ADT/ArrayRef.h"
64#include "llvm/Support/Error.h"
65#include "llvm/Support/Threading.h"
66#include "llvm/Support/VersionTuple.h"
67
68namespace lldb_private {
69
70template <typename B, typename S> struct Range;
71
76
78public:
79 // Pass nullptr for "process" if the ProcessProperties are to be the global
80 // copy
82
84
85 bool GetDisableMemoryCache() const;
86 uint64_t GetMemoryCacheLineSize() const;
88 void SetExtraStartupCommands(const Args &args);
90 uint32_t GetVirtualAddressableBits() const;
91 void SetVirtualAddressableBits(uint32_t bits);
92 uint32_t GetHighmemVirtualAddressableBits() const;
94 void SetPythonOSPluginPath(const FileSpec &file);
96 void SetIgnoreBreakpointsInExpressions(bool ignore);
98 void SetUnwindOnErrorInExpressions(bool ignore);
100 void SetStopOnSharedLibraryEvents(bool stop);
102 void SetDisableLangRuntimeUnwindPlans(bool disable);
104 bool GetDetachKeepsStopped() const;
105 void SetDetachKeepsStopped(bool keep_stopped);
106 bool GetWarningsOptimization() const;
108 bool GetStopOnExec() const;
109 std::chrono::seconds GetUtilityExpressionTimeout() const;
110 std::chrono::seconds GetInterruptTimeout() const;
111 bool GetOSPluginReportsAllThreads() const;
112 void SetOSPluginReportsAllThreads(bool does_report);
113 bool GetSteppingRunsAllThreads() const;
115 bool TrackMemoryCacheChanges() const;
116
117protected:
118 Process *m_process; // Can be nullptr for global ProcessProperties
119 std::unique_ptr<ProcessExperimentalProperties> m_experimental_properties_up;
120};
121
122// ProcessAttachInfo
123//
124// Describes any information that is required to attach to a process.
125
127public:
128 ProcessAttachInfo() = default;
129
131 ProcessInfo::operator=(launch_info);
133 SetResumeCount(launch_info.GetResumeCount());
134 m_detach_on_error = launch_info.GetDetachOnError();
135 }
136
137 bool GetWaitForLaunch() const { return m_wait_for_launch; }
138
140
141 bool GetAsync() const { return m_async; }
142
143 void SetAsync(bool b) { m_async = b; }
144
145 bool GetIgnoreExisting() const { return m_ignore_existing; }
146
148
150
152
153 uint32_t GetResumeCount() const { return m_resume_count; }
154
155 void SetResumeCount(uint32_t c) { m_resume_count = c; }
156
157 llvm::StringRef GetProcessPluginName() const {
158 return llvm::StringRef(m_plugin_name);
159 }
160
161 void SetProcessPluginName(llvm::StringRef plugin) {
162 m_plugin_name = std::string(plugin);
163 }
164
165 void Clear() {
167 m_plugin_name.clear();
168 m_resume_count = 0;
169 m_wait_for_launch = false;
170 m_ignore_existing = true;
172 }
173
174 bool ProcessInfoSpecified() const {
175 if (GetExecutableFile())
176 return true;
178 return true;
180 return true;
181 return false;
182 }
183
184 bool GetDetachOnError() const { return m_detach_on_error; }
185
186 void SetDetachOnError(bool enable) { m_detach_on_error = enable; }
187
189
190protected:
191 std::string m_plugin_name;
192 uint32_t m_resume_count = 0; // How many times do we resume after launching
193 bool m_wait_for_launch = false;
194 bool m_ignore_existing = true;
195 bool m_continue_once_attached = false; // Supports the use-case scenario of
196 // immediately continuing the process
197 // once attached.
199 true; // If we are debugging remotely, instruct the stub to
200 // detach rather than killing the target on error.
201 bool m_async =
202 false; // Use an async attach where we start the attach and return
203 // immediately (used by GUI programs with --waitfor so they can
204 // call SBProcess::Stop() to cancel attach)
205};
206
207// This class tracks the Modification state of the process. Things that can
208// currently modify the program are running the program (which will up the
209// StopID) and writing memory (which will up the MemoryID.)
210// FIXME: Should we also include modification of register states?
211
213 friend bool operator==(const ProcessModID &lhs, const ProcessModID &rhs);
214
215public:
216 ProcessModID() = default;
217
220
222 if (this != &rhs) {
223 m_stop_id = rhs.m_stop_id;
225 }
226 return *this;
227 }
228
229 ~ProcessModID() = default;
230
231 uint32_t BumpStopID() {
232 const uint32_t prev_stop_id = m_stop_id++;
235 return prev_stop_id;
236 }
237
239
245
248 }
249
250 uint32_t GetStopID() const { return m_stop_id; }
251 uint32_t GetLastNaturalStopID() const { return m_last_natural_stop_id; }
252 uint32_t GetMemoryID() const { return m_memory_id; }
253 uint32_t GetResumeID() const { return m_resume_id; }
257
258 bool MemoryIDEqual(const ProcessModID &compare) const {
259 return m_memory_id == compare.m_memory_id;
260 }
261
262 bool StopIDEqual(const ProcessModID &compare) const {
263 return m_stop_id == compare.m_stop_id;
264 }
265
267
268 bool IsValid() const { return m_stop_id != UINT32_MAX; }
269
271 // If we haven't yet resumed the target, then it can't be for a user
272 // expression...
273 if (m_resume_id == 0)
274 return false;
275
277 }
278
279 bool IsRunningExpression() const {
280 // Don't return true if we are no longer running an expression:
282 return true;
283 return false;
284 }
285
287 if (on)
289 else
291 }
292
294 if (on)
296 else {
297 assert(m_running_utility_function > 0 &&
298 "Called SetRunningUtilityFunction(false) without calling "
299 "SetRunningUtilityFunction(true) before?");
301 }
302 }
303
305 m_last_natural_stop_event = std::move(event_sp);
306 }
307
308 lldb::EventSP GetStopEventForStopID(uint32_t stop_id) const {
309 if (stop_id == m_last_natural_stop_id)
311 return lldb::EventSP();
312 }
313
314 void Dump(Stream &stream) const {
315 stream.Format("ProcessModID:\n"
316 " m_stop_id: {0}\n m_last_natural_stop_id: {1}\n"
317 " m_resume_id: {2}\n m_memory_id: {3}\n"
318 " m_last_user_expression_resume: {4}\n"
319 " m_running_user_expression: {5}\n"
320 " m_running_utility_function: {6}\n",
324 }
325
326private:
327 uint32_t m_stop_id = 0;
329 uint32_t m_resume_id = 0;
330 uint32_t m_memory_id = 0;
335};
336
337inline bool operator==(const ProcessModID &lhs, const ProcessModID &rhs) {
338 if (lhs.StopIDEqual(rhs) && lhs.MemoryIDEqual(rhs))
339 return true;
340 else
341 return false;
342}
343
344inline bool operator!=(const ProcessModID &lhs, const ProcessModID &rhs) {
345 return (!lhs.StopIDEqual(rhs) || !lhs.MemoryIDEqual(rhs));
346}
347
348/// \class Process Process.h "lldb/Target/Process.h"
349/// A plug-in interface definition class for debugging a process.
350class Process : public std::enable_shared_from_this<Process>,
351 public ProcessProperties,
352 public Broadcaster,
354 public PluginInterface {
355 friend class FunctionCaller; // For WaitForStateChangeEventsPrivate
356 friend class Debugger; // For PopProcessIOHandler and ProcessIOHandlerIsActive
357 friend class DynamicLoader; // For LoadOperatingSystemPlugin
358 friend class ProcessEventData;
359 friend class StopInfo;
360 friend class Target;
361 friend class ThreadList;
362
363public:
364 /// Broadcaster event bits definitions.
365 enum {
372 };
373 // This is all the event bits the public process broadcaster broadcasts.
374 // The process shadow listener signs up for all these bits...
375 static constexpr int g_all_event_bits =
379
380 enum {
384 };
385
387 // We use a read/write lock to allow on or more clients to access the process
388 // state while the process is stopped (reader). We lock the write lock to
389 // control access to the process while it is running (readers, or clients
390 // that want the process stopped can block waiting for the process to stop,
391 // or just try to lock it to see if they can immediately access the stopped
392 // process. If the try read lock fails, then the process is running.
394
395 // These two functions fill out the Broadcaster interface:
396
397 static llvm::StringRef GetStaticBroadcasterClass();
398
399 static constexpr llvm::StringRef AttachSynchronousHijackListenerName =
400 "lldb.internal.Process.AttachSynchronous.hijack";
401 static constexpr llvm::StringRef LaunchSynchronousHijackListenerName =
402 "lldb.internal.Process.LaunchSynchronous.hijack";
403 static constexpr llvm::StringRef ResumeSynchronousHijackListenerName =
404 "lldb.internal.Process.ResumeSynchronous.hijack";
405
406 llvm::StringRef GetBroadcasterClass() const override {
408 }
409
410/// A notification structure that can be used by clients to listen
411/// for changes in a process's lifetime.
412///
413/// \see RegisterNotificationCallbacks (const Notifications&) @see
414/// UnregisterNotificationCallbacks (const Notifications&)
415 typedef struct {
416 void *baton;
417 void (*initialize)(void *baton, Process *process);
418 void (*process_state_changed)(void *baton, Process *process,
419 lldb::StateType state);
421
423 friend class Process;
424
425 public:
427 ProcessEventData(const lldb::ProcessSP &process, lldb::StateType state);
428
430
431 static llvm::StringRef GetFlavorString();
432
433 llvm::StringRef GetFlavor() const override;
434
435 lldb::ProcessSP GetProcessSP() const { return m_process_wp.lock(); }
436
437 lldb::StateType GetState() const { return m_state; }
438 bool GetRestarted() const { return m_restarted; }
439
440 size_t GetNumRestartedReasons() { return m_restarted_reasons.size(); }
441
442 const char *GetRestartedReasonAtIndex(size_t idx) {
443 return ((idx < m_restarted_reasons.size())
444 ? m_restarted_reasons[idx].c_str()
445 : nullptr);
446 }
447
448 bool GetInterrupted() const { return m_interrupted; }
449
450 void Dump(Stream *s) const override;
451
452 virtual bool ShouldStop(Event *event_ptr, bool &found_valid_stopinfo);
453
454 void DoOnRemoval(Event *event_ptr) override;
455
456 static const Process::ProcessEventData *
457 GetEventDataFromEvent(const Event *event_ptr);
458
459 static lldb::ProcessSP GetProcessFromEvent(const Event *event_ptr);
460
461 static lldb::StateType GetStateFromEvent(const Event *event_ptr);
462
463 static bool GetRestartedFromEvent(const Event *event_ptr);
464
465 static size_t GetNumRestartedReasons(const Event *event_ptr);
466
467 static const char *GetRestartedReasonAtIndex(const Event *event_ptr,
468 size_t idx);
469
470 static void AddRestartedReason(Event *event_ptr, const char *reason);
471
472 static void SetRestartedInEvent(Event *event_ptr, bool new_value);
473
474 static bool GetInterruptedFromEvent(const Event *event_ptr);
475
476 static void SetInterruptedInEvent(Event *event_ptr, bool new_value);
477
478 static bool SetUpdateStateOnRemoval(Event *event_ptr);
479
480 private:
481 bool ForwardEventToPendingListeners(Event *event_ptr) override;
482
484
485 void SetRestarted(bool new_value) { m_restarted = new_value; }
486
487 void SetInterrupted(bool new_value) { m_interrupted = new_value; }
488
489 void AddRestartedReason(const char *reason) {
490 m_restarted_reasons.push_back(reason);
491 }
492
495 std::vector<std::string> m_restarted_reasons;
496 bool m_restarted = false; // For "eStateStopped" events, this is true if the
497 // target was automatically restarted.
499 bool m_interrupted = false;
500
503 };
504
505 /// Destructor.
506 ///
507 /// The destructor is virtual since this class is designed to be inherited
508 /// from by the plug-in instance.
509 ~Process() override;
510
511 static void SettingsInitialize();
512
513 static void SettingsTerminate();
514
516
517 /// Find a Process plug-in that can debug \a module using the currently
518 /// selected architecture.
519 ///
520 /// Scans all loaded plug-in interfaces that implement versions of the
521 /// Process plug-in interface and returns the first instance that can debug
522 /// the file.
523 ///
524 /// \see Process::CanDebug ()
526 llvm::StringRef plugin_name,
527 lldb::ListenerSP listener_sp,
528 const FileSpec *crash_file_path,
529 bool can_connect);
530
531 /// Static function that can be used with the \b host function
532 /// Host::StartMonitoringChildProcess ().
533 ///
534 /// This function can be used by lldb_private::Process subclasses when they
535 /// want to watch for a local process and have its exit status automatically
536 /// set when the host child process exits. Subclasses should call
537 /// Host::StartMonitoringChildProcess () with:
538 /// callback = Process::SetHostProcessExitStatus
539 /// pid = Process::GetID()
540 /// monitor_signals = false
541 static bool
542 SetProcessExitStatus(lldb::pid_t pid, // The process ID we want to monitor
543 bool exited,
544 int signo, // Zero for no signal
545 int status); // Exit value of process if signal is zero
546
548
549 uint32_t GetAddressByteSize() const;
550
551 /// Returns the pid of the process or LLDB_INVALID_PROCESS_ID if there is
552 /// no known pid.
553 lldb::pid_t GetID() const { return m_pid; }
554
555 /// Sets the stored pid.
556 ///
557 /// This does not change the pid of underlying process.
558 void SetID(lldb::pid_t new_pid) { m_pid = new_pid; }
559
560 uint32_t GetUniqueID() const { return m_process_unique_id; }
561
562 /// Check if a plug-in instance can debug the file in \a module.
563 ///
564 /// Each plug-in is given a chance to say whether it can debug the file in
565 /// \a module. If the Process plug-in instance can debug a file on the
566 /// current system, it should return \b true.
567 ///
568 /// \return
569 /// Returns \b true if this Process plug-in instance can
570 /// debug the executable, \b false otherwise.
571 virtual bool CanDebug(lldb::TargetSP target,
572 bool plugin_specified_by_name) = 0;
573
574 /// This object is about to be destroyed, do any necessary cleanup.
575 ///
576 /// Subclasses that override this method should always call this superclass
577 /// method.
578 /// If you are running Finalize in your Process subclass Destructor, pass
579 /// \b true. If we are in the destructor, shared_from_this will no longer
580 /// work, so we have to avoid doing anything that might trigger that.
581 virtual void Finalize(bool destructing);
582
583 /// Return whether this object is valid (i.e. has not been finalized.)
584 ///
585 /// \return
586 /// Returns \b true if this Process has not been finalized
587 /// and \b false otherwise.
588 bool IsValid() const { return !m_finalizing; }
589
590 /// Return a multi-word command object that can be used to expose plug-in
591 /// specific commands.
592 ///
593 /// This object will be used to resolve plug-in commands and can be
594 /// triggered by a call to:
595 ///
596 /// (lldb) process command <args>
597 ///
598 /// \return
599 /// A CommandObject which can be one of the concrete subclasses
600 /// of CommandObject like CommandObjectRaw, CommandObjectParsed,
601 /// or CommandObjectMultiword.
602 virtual CommandObject *GetPluginCommandObject() { return nullptr; }
603
604 /// The underlying plugin might store the low-level communication history for
605 /// this session. Dump it into the provided stream.
606 virtual void DumpPluginHistory(Stream &s) {}
607
608 /// Launch a new process.
609 ///
610 /// Launch a new process by spawning a new process using the target object's
611 /// executable module's file as the file to launch.
612 ///
613 /// This function is not meant to be overridden by Process subclasses. It
614 /// will first call Process::WillLaunch (Module *) and if that returns \b
615 /// true, Process::DoLaunch (Module*, char const *[],char const *[],const
616 /// char *,const char *, const char *) will be called to actually do the
617 /// launching. If DoLaunch returns \b true, then Process::DidLaunch() will
618 /// be called.
619 ///
620 /// \param[in] launch_info
621 /// Details regarding the environment, STDIN/STDOUT/STDERR
622 /// redirection, working path, etc. related to the requested launch.
623 ///
624 /// \return
625 /// An error object. Call GetID() to get the process ID if
626 /// the error object is success.
627 virtual Status Launch(ProcessLaunchInfo &launch_info);
628
629 virtual Status LoadCore();
630
631 virtual Status DoLoadCore() {
633 "error: {0} does not support loading core files.", GetPluginName());
634 }
635
636 /// The "ShadowListener" for a process is just an ordinary Listener that
637 /// listens for all the Process event bits. It's convenient because you can
638 /// specify it in the LaunchInfo or AttachInfo, so it will get events from
639 /// the very start of the process.
640 void SetShadowListener(lldb::ListenerSP shadow_listener_sp) {
641 if (shadow_listener_sp)
642 AddListener(shadow_listener_sp, g_all_event_bits);
643 }
644
645 // FUTURE WORK: GetLoadImageUtilityFunction are the first use we've
646 // had of having other plugins cache data in the Process. This is handy for
647 // long-living plugins - like the Platform - which manage interactions whose
648 // lifetime is governed by the Process lifetime. If we find we need to do
649 // this more often, we should construct a general solution to the problem.
650 // The consensus suggestion was that we have a token based registry in the
651 // Process. Some undecided questions are (1) who manages the tokens. It's
652 // probably best that you add the element and get back a token that
653 // represents it. That will avoid collisions. But there may be some utility
654 // in the registerer controlling the token? (2) whether the thing added
655 // should be simply owned by Process, and just go away when it does (3)
656 // whether the registree should be notified of the Process' demise.
657 //
658 // We are postponing designing this till we have at least a second use case.
659 /// Get the cached UtilityFunction that assists in loading binary images
660 /// into the process.
661 ///
662 /// \param[in] platform
663 /// The platform fetching the UtilityFunction.
664 /// \param[in] factory
665 /// A function that will be called only once per-process in a
666 /// thread-safe way to create the UtilityFunction if it has not
667 /// been initialized yet.
668 ///
669 /// \return
670 /// The cached utility function or null if the platform is not the
671 /// same as the target's platform.
673 Platform *platform,
674 llvm::function_ref<std::unique_ptr<UtilityFunction>()> factory);
675
676 /// Get the dynamic loader plug-in for this process.
677 ///
678 /// The default action is to let the DynamicLoader plug-ins check the main
679 /// executable and the DynamicLoader will select itself automatically.
680 /// Subclasses can override this if inspecting the executable is not
681 /// desired, or if Process subclasses can only use a specific DynamicLoader
682 /// plug-in.
684
686
687 // Returns AUXV structure found in many ELF-based environments.
688 //
689 // The default action is to return an empty data buffer.
690 //
691 // \return
692 // A data extractor containing the contents of the AUXV data.
693 virtual DataExtractor GetAuxvData();
694
695 /// Sometimes processes know how to retrieve and load shared libraries. This
696 /// is normally done by DynamicLoader plug-ins, but sometimes the connection
697 /// to the process allows retrieving this information. The dynamic loader
698 /// plug-ins can use this function if they can't determine the current
699 /// shared library load state.
700 ///
701 /// \return
702 /// A status object indicating if the operation was sucessful or not.
703 virtual llvm::Error LoadModules() {
704 return llvm::make_error<llvm::StringError>("Not implemented.",
705 llvm::inconvertibleErrorCode());
706 }
707
708 /// Query remote GDBServer for a detailed loaded library list
709 /// \return
710 /// The list of modules currently loaded by the process, or an error.
711 virtual llvm::Expected<LoadedModuleInfoList> GetLoadedModuleList() {
712 return llvm::createStringError(llvm::inconvertibleErrorCode(),
713 "Not implemented");
714 }
715
716 /// Save core dump into the specified file.
717 ///
718 /// \param[in] outfile
719 /// Path to store core dump in.
720 ///
721 /// \return
722 /// true if saved successfully, false if saving the core dump
723 /// is not supported by the plugin, error otherwise.
724 virtual llvm::Expected<bool> SaveCore(llvm::StringRef outfile);
725
726 /// Helper function for Process::SaveCore(...) that calculates the address
727 /// ranges that should be saved. This allows all core file plug-ins to save
728 /// consistent memory ranges given a \a core_style.
730 CoreFileMemoryRanges &ranges);
731
732 /// Helper function for Process::SaveCore(...) that calculates the thread list
733 /// based upon options set within a given \a core_options object.
734 /// \note If there is no thread list defined, all threads will be saved.
735 std::vector<lldb::ThreadSP>
736 CalculateCoreFileThreadList(const SaveCoreOptions &core_options);
737
738protected:
739 virtual JITLoaderList &GetJITLoaders();
740
741public:
742 /// Get the system architecture for this process.
743 virtual ArchSpec GetSystemArchitecture() { return {}; }
744
745 /// Get the system runtime plug-in for this process.
746 ///
747 /// \return
748 /// Returns a pointer to the SystemRuntime plugin for this Process
749 /// if one is available. Else returns nullptr.
751
752 /// Attach to an existing process using the process attach info.
753 ///
754 /// This function is not meant to be overridden by Process subclasses. It
755 /// will first call WillAttach (lldb::pid_t) or WillAttach (const char *),
756 /// and if that returns \b true, DoAttach (lldb::pid_t) or DoAttach (const
757 /// char *) will be called to actually do the attach. If DoAttach returns \b
758 /// true, then Process::DidAttach() will be called.
759 ///
760 /// \param[in] attach_info
761 /// The process attach info.
762 ///
763 /// \return
764 /// Returns \a pid if attaching was successful, or
765 /// LLDB_INVALID_PROCESS_ID if attaching fails.
766 virtual Status Attach(ProcessAttachInfo &attach_info);
767
768 /// Attach to a remote system via a URL
769 ///
770 /// \param[in] remote_url
771 /// The URL format that we are connecting to.
772 ///
773 /// \return
774 /// Returns an error object.
775 virtual Status ConnectRemote(llvm::StringRef remote_url);
776
777 bool GetShouldDetach() const { return m_should_detach; }
778
779 void SetShouldDetach(bool b) { m_should_detach = b; }
780
781 /// Get the image vector for the current process.
782 ///
783 /// \return
784 /// The constant reference to the member m_image_tokens.
785 const std::vector<lldb::addr_t>& GetImageTokens() { return m_image_tokens; }
786
787 /// Get the image information address for the current process.
788 ///
789 /// Some runtimes have system functions that can help dynamic loaders locate
790 /// the dynamic loader information needed to observe shared libraries being
791 /// loaded or unloaded. This function is in the Process interface (as
792 /// opposed to the DynamicLoader interface) to ensure that remote debugging
793 /// can take advantage of this functionality.
794 ///
795 /// \return
796 /// The address of the dynamic loader information, or
797 /// LLDB_INVALID_ADDRESS if this is not supported by this
798 /// interface.
800
801 /// Called when the process is about to broadcast a public stop.
802 ///
803 /// There are public and private stops. Private stops are when the process
804 /// is doing things like stepping and the client doesn't need to know about
805 /// starts and stop that implement a thread plan. Single stepping over a
806 /// source line in code might end up being implemented by one or more
807 /// process starts and stops. Public stops are when clients will be notified
808 /// that the process is stopped. These events typically trigger UI updates
809 /// (thread stack frames to be displayed, variables to be displayed, and
810 /// more). This function can be overriden and allows process subclasses to
811 /// do something before the eBroadcastBitStateChanged event is sent to
812 /// public clients.
813 virtual void WillPublicStop() {}
814
815/// Register for process and thread notifications.
816///
817/// Clients can register notification callbacks by filling out a
818/// Process::Notifications structure and calling this function.
819///
820/// \param[in] callbacks
821/// A structure that contains the notification baton and
822/// callback functions.
823///
824/// \see Process::Notifications
826
827/// Unregister for process and thread notifications.
828///
829/// Clients can unregister notification callbacks by passing a copy of the
830/// original baton and callbacks in \a callbacks.
831///
832/// \param[in] callbacks
833/// A structure that contains the notification baton and
834/// callback functions.
835///
836/// \return
837/// Returns \b true if the notification callbacks were
838/// successfully removed from the process, \b false otherwise.
839///
840/// \see Process::Notifications
842
843 //==================================================================
844 // Built in Process Control functions
845 //==================================================================
846 /// Resumes all of a process's threads as configured using the Thread run
847 /// control functions.
848 ///
849 /// Threads for a process should be updated with one of the run control
850 /// actions (resume, step, or suspend) that they should take when the
851 /// process is resumed. If no run control action is given to a thread it
852 /// will be resumed by default.
853 ///
854 /// This function is not meant to be overridden by Process subclasses. This
855 /// function will take care of disabling any breakpoints that threads may be
856 /// stopped at, single stepping, and re-enabling breakpoints, and enabling
857 /// the basic flow control that the plug-in instances need not worry about.
858 ///
859 /// N.B. This function also sets the Write side of the Run Lock, which is
860 /// unset when the corresponding stop event is pulled off the Public Event
861 /// Queue. If you need to resume the process without setting the Run Lock,
862 /// use PrivateResume (though you should only do that from inside the
863 /// Process class.
864 ///
865 /// \return
866 /// Returns an error object.
867 ///
868 /// \see Thread:Resume()
869 /// \see Thread:Step()
870 /// \see Thread:Suspend()
871 Status Resume();
872
873 /// Resume a process, and wait for it to stop.
875
876 /// Halts a running process.
877 ///
878 /// This function is not meant to be overridden by Process subclasses. If
879 /// the process is successfully halted, a eStateStopped process event with
880 /// GetInterrupted will be broadcast. If false, we will halt the process
881 /// with no events generated by the halt.
882 ///
883 /// \param[in] clear_thread_plans
884 /// If true, when the process stops, clear all thread plans.
885 ///
886 /// \param[in] use_run_lock
887 /// Whether to release the run lock after the stop.
888 ///
889 /// \return
890 /// Returns an error object. If the error is empty, the process is
891 /// halted.
892 /// otherwise the halt has failed.
893 Status Halt(bool clear_thread_plans = false, bool use_run_lock = true);
894
895 /// Detaches from a running or stopped process.
896 ///
897 /// This function is not meant to be overridden by Process subclasses.
898 ///
899 /// \param[in] keep_stopped
900 /// If true, don't resume the process on detach.
901 ///
902 /// \return
903 /// Returns an error object.
904 Status Detach(bool keep_stopped);
905
906 /// Kills the process and shuts down all threads that were spawned to track
907 /// and monitor the process.
908 ///
909 /// This function is not meant to be overridden by Process subclasses.
910 ///
911 /// \param[in] force_kill
912 /// Whether lldb should force a kill (instead of a detach) from
913 /// the inferior process. Normally if lldb launched a binary and
914 /// Destroy is called, lldb kills it. If lldb attached to a
915 /// running process and Destroy is called, lldb detaches. If
916 /// this behavior needs to be over-ridden, this is the bool that
917 /// can be used.
918 ///
919 /// \return
920 /// Returns an error object.
921 Status Destroy(bool force_kill);
922
923 /// Sends a process a UNIX signal \a signal.
924 ///
925 /// This function is not meant to be overridden by Process subclasses.
926 ///
927 /// \return
928 /// Returns an error object.
929 Status Signal(int signal);
930
931 void SetUnixSignals(lldb::UnixSignalsSP &&signals_sp);
932
934
935 //==================================================================
936 // Plug-in Process Control Overrides
937 //==================================================================
938
939 /// Called before attaching to a process.
940 ///
941 /// \return
942 /// Returns an error object.
944
945 /// Called before attaching to a process.
946 ///
947 /// Allow Process plug-ins to execute some code before attaching a process.
948 ///
949 /// \return
950 /// Returns an error object.
952 return Status();
953 }
954
955 /// Called before attaching to a process.
956 ///
957 /// \return
958 /// Returns an error object.
959 Status WillAttachToProcessWithName(const char *process_name,
960 bool wait_for_launch);
961
962 /// Called before attaching to a process.
963 ///
964 /// Allow Process plug-ins to execute some code before attaching a process.
965 ///
966 /// \return
967 /// Returns an error object.
968 virtual Status DoWillAttachToProcessWithName(const char *process_name,
969 bool wait_for_launch) {
970 return Status();
971 }
972
973 /// Attach to a remote system via a URL
974 ///
975 /// \param[in] remote_url
976 /// The URL format that we are connecting to.
977 ///
978 /// \return
979 /// Returns an error object.
980 virtual Status DoConnectRemote(llvm::StringRef remote_url) {
981 return Status::FromErrorString("remote connections are not supported");
982 }
983
984 /// Attach to an existing process using a process ID.
985 ///
986 /// \param[in] pid
987 /// The process ID that we should attempt to attach to.
988 ///
989 /// \param[in] attach_info
990 /// Information on how to do the attach. For example, GetUserID()
991 /// will return the uid to attach as.
992 ///
993 /// \return
994 /// Returns a successful Status attaching was successful, or
995 /// an appropriate (possibly platform-specific) error code if
996 /// attaching fails.
997 /// hanming : need flag
999 const ProcessAttachInfo &attach_info) {
1001 "error: {0} does not support attaching to a process by pid",
1002 GetPluginName());
1003 }
1004
1005 /// Attach to an existing process using a partial process name.
1006 ///
1007 /// \param[in] process_name
1008 /// The name of the process to attach to.
1009 ///
1010 /// \param[in] attach_info
1011 /// Information on how to do the attach. For example, GetUserID()
1012 /// will return the uid to attach as.
1013 ///
1014 /// \return
1015 /// Returns a successful Status attaching was successful, or
1016 /// an appropriate (possibly platform-specific) error code if
1017 /// attaching fails.
1018 virtual Status
1019 DoAttachToProcessWithName(const char *process_name,
1020 const ProcessAttachInfo &attach_info) {
1021 return Status::FromErrorString("attach by name is not supported");
1022 }
1023
1024 /// Called after attaching a process.
1025 ///
1026 /// \param[in] process_arch
1027 /// If you can figure out the process architecture after attach, fill it
1028 /// in here.
1029 ///
1030 /// Allow Process plug-ins to execute some code after attaching to a
1031 /// process.
1032 virtual void DidAttach(ArchSpec &process_arch) { process_arch.Clear(); }
1033
1034 /// Called after a process re-execs itself.
1035 ///
1036 /// Allow Process plug-ins to execute some code after a process has exec'ed
1037 /// itself. Subclasses typically should override DoDidExec() as the
1038 /// lldb_private::Process class needs to remove its dynamic loader, runtime,
1039 /// ABI and other plug-ins, as well as unload all shared libraries.
1040 virtual void DidExec();
1041
1042 /// Subclasses of Process should implement this function if they need to do
1043 /// anything after a process exec's itself.
1044 virtual void DoDidExec() {}
1045
1046 /// Called after a reported fork.
1047 virtual void DidFork(lldb::pid_t child_pid, lldb::tid_t child_tid) {}
1048
1049 /// Called after a reported vfork.
1050 virtual void DidVFork(lldb::pid_t child_pid, lldb::tid_t child_tid) {}
1051
1052 /// Called after reported vfork completion.
1053 virtual void DidVForkDone() {}
1054
1055 /// Called before launching to a process.
1056 /// \return
1057 /// Returns an error object.
1058 Status WillLaunch(Module *module);
1059
1060 /// Called before launching to a process.
1061 ///
1062 /// Allow Process plug-ins to execute some code before launching a process.
1063 ///
1064 /// \return
1065 /// Returns an error object.
1066 virtual Status DoWillLaunch(Module *module) { return Status(); }
1067
1068 /// Launch a new process.
1069 ///
1070 /// Launch a new process by spawning a new process using \a exe_module's
1071 /// file as the file to launch. Launch details are provided in \a
1072 /// launch_info.
1073 ///
1074 /// \param[in] exe_module
1075 /// The module from which to extract the file specification and
1076 /// launch.
1077 ///
1078 /// \param[in] launch_info
1079 /// Details (e.g. arguments, stdio redirection, etc.) for the
1080 /// requested launch.
1081 ///
1082 /// \return
1083 /// An Status instance indicating success or failure of the
1084 /// operation.
1085 virtual Status DoLaunch(Module *exe_module, ProcessLaunchInfo &launch_info) {
1087 "error: {0} does not support launching processes", GetPluginName());
1088 }
1089
1090 /// Called after launching a process.
1091 ///
1092 /// Allow Process plug-ins to execute some code after launching a process.
1093 virtual void DidLaunch() {}
1094
1095 /// Called before resuming to a process.
1096 ///
1097 /// Allow Process plug-ins to execute some code before resuming a process.
1098 ///
1099 /// \return
1100 /// Returns an error object.
1101 virtual Status WillResume() { return Status(); }
1102
1103 /// Reports whether this process supports reverse execution.
1104 ///
1105 /// \return
1106 /// Returns true if the process supports reverse execution (at least
1107 /// under some circumstances).
1108 virtual bool SupportsReverseDirection() { return false; }
1109
1110 /// Resumes all of a process's threads as configured using the Thread run
1111 /// control functions.
1112 ///
1113 /// Threads for a process should be updated with one of the run control
1114 /// actions (resume, step, or suspend) that they should take when the
1115 /// process is resumed. If no run control action is given to a thread it
1116 /// will be resumed by default.
1117 ///
1118 /// \return
1119 /// Returns \b true if the process successfully resumes using
1120 /// the thread run control actions, \b false otherwise.
1121 ///
1122 /// \see Thread:Resume()
1123 /// \see Thread:Step()
1124 /// \see Thread:Suspend()
1126 if (direction == lldb::RunDirection::eRunForward)
1128 "{0} does not support resuming processes", GetPluginName());
1130 "{0} does not support reverse execution of processes", GetPluginName());
1131 }
1132
1133 /// Called after resuming a process.
1134 ///
1135 /// Allow Process plug-ins to execute some code after resuming a process.
1136 virtual void DidResume() {}
1137
1138 /// Called before halting to a process.
1139 ///
1140 /// Allow Process plug-ins to execute some code before halting a process.
1141 ///
1142 /// \return
1143 /// Returns an error object.
1144 virtual Status WillHalt() { return Status(); }
1145
1146 /// Halts a running process.
1147 ///
1148 /// DoHalt must produce one and only one stop StateChanged event if it
1149 /// actually stops the process. If the stop happens through some natural
1150 /// event (for instance a SIGSTOP), then forwarding that event will do.
1151 /// Otherwise, you must generate the event manually. This function is called
1152 /// from the context of the private state thread.
1153 ///
1154 /// \param[out] caused_stop
1155 /// If true, then this Halt caused the stop, otherwise, the
1156 /// process was already stopped.
1157 ///
1158 /// \return
1159 /// Returns \b true if the process successfully halts, \b false
1160 /// otherwise.
1161 virtual Status DoHalt(bool &caused_stop) {
1163 "error: {0} does not support halting processes", GetPluginName());
1164 }
1165
1166 /// Called after halting a process.
1167 ///
1168 /// Allow Process plug-ins to execute some code after halting a process.
1169 virtual void DidHalt() {}
1170
1171 /// Called before detaching from a process.
1172 ///
1173 /// Allow Process plug-ins to execute some code before detaching from a
1174 /// process.
1175 ///
1176 /// \return
1177 /// Returns an error object.
1178 virtual Status WillDetach() { return Status(); }
1179
1180 /// Detaches from a running or stopped process.
1181 ///
1182 /// \return
1183 /// Returns \b true if the process successfully detaches, \b
1184 /// false otherwise.
1185 virtual Status DoDetach(bool keep_stopped) {
1187 "error: {0} does not support detaching from processes",
1188 GetPluginName());
1189 }
1190
1191 /// Called after detaching from a process.
1192 ///
1193 /// Allow Process plug-ins to execute some code after detaching from a
1194 /// process.
1195 virtual void DidDetach() {}
1196
1197 virtual bool DetachRequiresHalt() { return false; }
1198
1199 /// Called before sending a signal to a process.
1200 ///
1201 /// Allow Process plug-ins to execute some code before sending a signal to a
1202 /// process.
1203 ///
1204 /// \return
1205 /// Returns no error if it is safe to proceed with a call to
1206 /// Process::DoSignal(int), otherwise an error describing what
1207 /// prevents the signal from being sent.
1208 virtual Status WillSignal() { return Status(); }
1209
1210 /// Sends a process a UNIX signal \a signal.
1211 ///
1212 /// \return
1213 /// Returns an error object.
1214 virtual Status DoSignal(int signal) {
1216 "error: {0} does not support sending signals to processes",
1217 GetPluginName());
1218 }
1219
1220 virtual Status WillDestroy() { return Status(); }
1221
1222 virtual Status DoDestroy() = 0;
1223
1224 virtual void DidDestroy() {}
1225
1226 virtual bool DestroyRequiresHalt() { return true; }
1227
1228 /// Called after sending a signal to a process.
1229 ///
1230 /// Allow Process plug-ins to execute some code after sending a signal to a
1231 /// process.
1232 virtual void DidSignal() {}
1233
1234 /// Currently called as part of ShouldStop.
1235 /// FIXME: Should really happen when the target stops before the
1236 /// event is taken from the queue...
1237 ///
1238 /// This callback is called as the event
1239 /// is about to be queued up to allow Process plug-ins to execute some code
1240 /// prior to clients being notified that a process was stopped. Common
1241 /// operations include updating the thread list, invalidating any thread
1242 /// state (registers, stack, etc) prior to letting the notification go out.
1243 ///
1244 virtual void RefreshStateAfterStop() = 0;
1245
1246 /// Sometimes the connection to a process can detect the host OS version
1247 /// that the process is running on. The current platform should be checked
1248 /// first in case the platform is connected, but clients can fall back onto
1249 /// this function if the platform fails to identify the host OS version. The
1250 /// platform should be checked first in case you are running a simulator
1251 /// platform that might itself be running natively, but have different
1252 /// heuristics for figuring out which OS is emulating.
1253 ///
1254 /// \return
1255 /// Returns the version tuple of the host OS. In case of failure an empty
1256 /// VersionTuple is returner.
1257 virtual llvm::VersionTuple GetHostOSVersion() { return llvm::VersionTuple(); }
1258
1259 /// \return the macCatalyst version of the host OS.
1260 virtual llvm::VersionTuple GetHostMacCatalystVersion() { return {}; }
1261
1262 /// Get the target object pointer for this module.
1263 ///
1264 /// \return
1265 /// A Target object pointer to the target that owns this
1266 /// module.
1267 Target &GetTarget() { return *m_target_wp.lock(); }
1268
1269 /// Get the const target object pointer for this module.
1270 ///
1271 /// \return
1272 /// A const Target object pointer to the target that owns this
1273 /// module.
1274 const Target &GetTarget() const { return *m_target_wp.lock(); }
1275
1276 /// Flush all data in the process.
1277 ///
1278 /// Flush the memory caches, all threads, and any other cached data in the
1279 /// process.
1280 ///
1281 /// This function can be called after a world changing event like adding a
1282 /// new symbol file, or after the process makes a large context switch (from
1283 /// boot ROM to booted into an OS).
1284 void Flush();
1285
1286 /// Get accessor for the current process state.
1287 ///
1288 /// \return
1289 /// The current state of the process.
1290 ///
1291 /// \see lldb::StateType
1293
1295 RunThreadPlan(ExecutionContext &exe_ctx, lldb::ThreadPlanSP &thread_plan_sp,
1296 const EvaluateExpressionOptions &options,
1297 DiagnosticManager &diagnostic_manager);
1298
1299 void GetStatus(Stream &ostrm);
1300
1301 size_t GetThreadStatus(Stream &ostrm, bool only_threads_with_stop_reason,
1302 uint32_t start_frame, uint32_t num_frames,
1303 uint32_t num_frames_with_source, bool stop_format);
1304
1305 /// Send an async interrupt request.
1306 ///
1307 /// If \a thread is specified the async interrupt stop will be attributed to
1308 /// the specified thread.
1309 ///
1310 /// \param[in] thread
1311 /// The thread the async interrupt will be attributed to.
1312 void SendAsyncInterrupt(Thread *thread = nullptr);
1313
1314 // Notify this process class that modules got loaded.
1315 //
1316 // If subclasses override this method, they must call this version before
1317 // doing anything in the subclass version of the function.
1318 virtual void ModulesDidLoad(ModuleList &module_list);
1319
1320 /// Retrieve the list of shared libraries that are loaded for this process
1321 /// This method is used on pre-macOS 10.12, pre-iOS 10, pre-tvOS 10, pre-
1322 /// watchOS 3 systems. The following two methods are for newer versions of
1323 /// those OSes.
1324 ///
1325 /// For certain platforms, the time it takes for the DynamicLoader plugin to
1326 /// read all of the shared libraries out of memory over a slow communication
1327 /// channel may be too long. In that instance, the gdb-remote stub may be
1328 /// able to retrieve the necessary information about the solibs out of
1329 /// memory and return a concise summary sufficient for the DynamicLoader
1330 /// plugin.
1331 ///
1332 /// \param [in] image_list_address
1333 /// The address where the table of shared libraries is stored in memory,
1334 /// if that is appropriate for this platform. Else this may be
1335 /// passed as LLDB_INVALID_ADDRESS.
1336 ///
1337 /// \param [in] image_count
1338 /// The number of shared libraries that are present in this process, if
1339 /// that is appropriate for this platofrm Else this may be passed as
1340 /// LLDB_INVALID_ADDRESS.
1341 ///
1342 /// \return
1343 /// A StructuredDataSP object which, if non-empty, will contain the
1344 /// information the DynamicLoader needs to get the initial scan of
1345 /// solibs resolved.
1348 lldb::addr_t image_count) {
1349 return StructuredData::ObjectSP();
1350 }
1351
1352 // On macOS 10.12, tvOS 10, iOS 10, watchOS 3 and newer, debugserver can
1353 // return the full list of loaded shared libraries without needing any input.
1358
1359 // On macOS 10.12, tvOS 10, iOS 10, watchOS 3 and newer, debugserver can
1360 // return information about binaries given their load addresses.
1362 const std::vector<lldb::addr_t> &load_addresses) {
1363 return StructuredData::ObjectSP();
1364 }
1365
1366 // Get information about the library shared cache, if that exists
1367 //
1368 // On macOS 10.12, tvOS 10, iOS 10, watchOS 3 and newer, debugserver can
1369 // return information about the library shared cache (a set of standard
1370 // libraries that are loaded at the same location for all processes on a
1371 // system) in use.
1375
1376 // Get information about the launch state of the process, if possible.
1377 //
1378 // On Darwin systems, libdyld can report on process state, most importantly
1379 // the startup stages where the system library is not yet initialized.
1382 return {};
1383 }
1384
1385 /// Print a user-visible warning about a module being built with
1386 /// optimization
1387 ///
1388 /// Prints a async warning message to the user one time per Module where a
1389 /// function is found that was compiled with optimization, per Process.
1390 ///
1391 /// \param [in] sc
1392 /// A SymbolContext with eSymbolContextFunction and eSymbolContextModule
1393 /// pre-computed.
1395
1396 /// Print a user-visible warning about a function written in a
1397 /// language that this version of LLDB doesn't support.
1398 ///
1399 /// \see PrintWarningOptimization
1401
1402 virtual bool GetProcessInfo(ProcessInstanceInfo &info);
1403
1404 virtual lldb_private::UUID FindModuleUUID(const llvm::StringRef path);
1405
1406 /// Get the exit status for a process.
1407 ///
1408 /// \return
1409 /// The process's return code, or -1 if the current process
1410 /// state is not eStateExited.
1411 int GetExitStatus();
1412
1413 /// Get a textual description of what the process exited.
1414 ///
1415 /// \return
1416 /// The textual description of why the process exited, or nullptr
1417 /// if there is no description available.
1418 const char *GetExitDescription();
1419
1420 virtual void DidExit() {}
1421
1422 /// Get the current address mask in the Process
1423 ///
1424 /// This mask can used to set/clear non-address bits in an addr_t.
1425 ///
1426 /// \return
1427 /// The current address mask.
1428 /// Bits which are set to 1 are not used for addressing.
1429 /// An address mask of 0 means all bits are used for addressing.
1430 /// An address mask of LLDB_INVALID_ADDRESS_MASK (all 1's) means
1431 /// that no mask has been set.
1434
1435 /// The highmem masks are for targets where we may have different masks
1436 /// for low memory versus high memory addresses, and they will be left
1437 /// as LLDB_INVALID_ADDRESS_MASK normally, meaning the base masks
1438 /// should be applied to all addresses.
1441
1442 void SetCodeAddressMask(lldb::addr_t code_address_mask);
1443 void SetDataAddressMask(lldb::addr_t data_address_mask);
1444
1445 void SetHighmemCodeAddressMask(lldb::addr_t code_address_mask);
1446 void SetHighmemDataAddressMask(lldb::addr_t data_address_mask);
1447
1448 /// Some targets might use bits in a code address to indicate a mode switch,
1449 /// ARM uses bit zero to signify a code address is thumb, so any ARM ABI
1450 /// plug-ins would strip those bits.
1451 /// Or use the high bits to authenticate a pointer value.
1454
1455 /// Use this method when you do not know, or do not care what kind of address
1456 /// you are fixing. On platforms where there would be a difference between the
1457 /// two types, it will pick the safest option.
1458 ///
1459 /// Its purpose is to signal that no specific choice was made and provide an
1460 /// alternative to randomly picking FixCode/FixData address. Which could break
1461 /// platforms where there is a difference (only Arm Thumb at this time).
1463
1464 /// Get the Modification ID of the process.
1465 ///
1466 /// \return
1467 /// The modification ID of the process.
1468 ProcessModID GetModID() const { return m_mod_id; }
1469
1470 const ProcessModID &GetModIDRef() const { return m_mod_id; }
1471
1472 uint32_t GetStopID() const { return m_mod_id.GetStopID(); }
1473
1474 uint32_t GetResumeID() const { return m_mod_id.GetResumeID(); }
1475
1477 return m_mod_id.GetLastUserExpressionResumeID();
1478 }
1479
1480 uint32_t GetLastNaturalStopID() const {
1481 return m_mod_id.GetLastNaturalStopID();
1482 }
1483
1484 lldb::EventSP GetStopEventForStopID(uint32_t stop_id) const {
1485 return m_mod_id.GetStopEventForStopID(stop_id);
1486 }
1487
1488 /// Set accessor for the process exit status (return code).
1489 ///
1490 /// Sometimes a child exits and the exit can be detected by global functions
1491 /// (signal handler for SIGCHLD for example). This accessor allows the exit
1492 /// status to be set from an external source.
1493 ///
1494 /// Setting this will cause a eStateExited event to be posted to the process
1495 /// event queue.
1496 ///
1497 /// \param[in] exit_status
1498 /// The value for the process's return code.
1499 ///
1500 /// \param[in] exit_string
1501 /// A StringRef containing the reason for exiting. May be empty.
1502 ///
1503 /// \return
1504 /// Returns \b false if the process was already in an exited state, \b
1505 /// true otherwise.
1506 virtual bool SetExitStatus(int exit_status, llvm::StringRef exit_string);
1507
1508 /// Check if a process is still alive.
1509 ///
1510 /// \return
1511 /// Returns \b true if the process is still valid, \b false
1512 /// otherwise.
1513 virtual bool IsAlive();
1514
1515 /// Check if a process is a live debug session, or a corefile/post-mortem.
1516 virtual bool IsLiveDebugSession() const { return true; };
1517
1518 /// Provide a way to retrieve the core dump file that is loaded for debugging.
1519 /// Only available if IsLiveDebugSession() returns false.
1520 ///
1521 /// \return
1522 /// File path to the core file.
1523 virtual FileSpec GetCoreFile() const { return {}; }
1524
1525 /// Before lldb detaches from a process, it warns the user that they are
1526 /// about to lose their debug session. In some cases, this warning doesn't
1527 /// need to be emitted -- for instance, with core file debugging where the
1528 /// user can reconstruct the "state" by simply re-running the debugger on
1529 /// the core file.
1530 ///
1531 /// \return
1532 /// Returns \b true if the user should be warned about detaching from
1533 /// this process.
1534 virtual bool WarnBeforeDetach() const { return true; }
1535
1536 /// Read of memory from a process.
1537 ///
1538 /// This function will read memory from the current process's address space
1539 /// and remove any traps that may have been inserted into the memory.
1540 ///
1541 /// This function is not meant to be overridden by Process subclasses, the
1542 /// subclasses should implement Process::DoReadMemory (lldb::addr_t, size_t,
1543 /// void *).
1544 ///
1545 /// \param[in] vm_addr
1546 /// A virtual load address that indicates where to start reading
1547 /// memory from.
1548 ///
1549 /// \param[out] buf
1550 /// A byte buffer that is at least \a size bytes long that
1551 /// will receive the memory bytes.
1552 ///
1553 /// \param[in] size
1554 /// The number of bytes to read.
1555 ///
1556 /// \param[out] error
1557 /// An error that indicates the success or failure of this
1558 /// operation. If error indicates success (error.Success()),
1559 /// then the value returned can be trusted, otherwise zero
1560 /// will be returned.
1561 ///
1562 /// \return
1563 /// The number of bytes that were actually read into \a buf. If
1564 /// the returned number is greater than zero, yet less than \a
1565 /// size, then this function will get called again with \a
1566 /// vm_addr, \a buf, and \a size updated appropriately. Zero is
1567 /// returned in the case of an error.
1568 virtual size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size,
1569 Status &error);
1570
1571 /// Read from multiple memory ranges and write the results into buffer.
1572 /// This calls ReadMemoryFromInferior multiple times, once per range,
1573 /// bypassing the read cache. Process implementations that can perform this
1574 /// operation more efficiently should override this.
1575 ///
1576 /// \param[in] ranges
1577 /// A collection of ranges (base address + size) to read from.
1578 ///
1579 /// \param[out] buffer
1580 /// A buffer where the read memory will be written to. It must be at least
1581 /// as long as the sum of the sizes of each range.
1582 ///
1583 /// \return
1584 /// A vector of MutableArrayRef, where each MutableArrayRef is a slice of
1585 /// the input buffer into which the memory contents were copied. The size
1586 /// of the slice indicates how many bytes were read successfully. Partial
1587 /// reads are always performed from the start of the requested range,
1588 /// never from the middle or end.
1589 virtual llvm::SmallVector<llvm::MutableArrayRef<uint8_t>>
1590 ReadMemoryRanges(llvm::ArrayRef<Range<lldb::addr_t, size_t>> ranges,
1591 llvm::MutableArrayRef<uint8_t> buffer);
1592
1593 /// Read of memory from a process.
1594 ///
1595 /// This function has the same semantics of ReadMemory except that it
1596 /// bypasses caching.
1597 ///
1598 /// \param[in] vm_addr
1599 /// A virtual load address that indicates where to start reading
1600 /// memory from.
1601 ///
1602 /// \param[out] buf
1603 /// A byte buffer that is at least \a size bytes long that
1604 /// will receive the memory bytes.
1605 ///
1606 /// \param[in] size
1607 /// The number of bytes to read.
1608 ///
1609 /// \param[out] error
1610 /// An error that indicates the success or failure of this
1611 /// operation. If error indicates success (error.Success()),
1612 /// then the value returned can be trusted, otherwise zero
1613 /// will be returned.
1614 ///
1615 /// \return
1616 /// The number of bytes that were actually read into \a buf. If
1617 /// the returned number is greater than zero, yet less than \a
1618 /// size, then this function will get called again with \a
1619 /// vm_addr, \a buf, and \a size updated appropriately. Zero is
1620 /// returned in the case of an error.
1621 size_t ReadMemoryFromInferior(lldb::addr_t vm_addr, void *buf, size_t size,
1622 Status &error);
1623
1624 // Callback definition for read Memory in chunks
1625 //
1626 // Status, the status returned from ReadMemoryFromInferior
1627 // addr_t, the bytes_addr, start + bytes read so far.
1628 // void*, pointer to the bytes read
1629 // bytes_size, the count of bytes read for this chunk
1630 typedef std::function<IterationAction(
1631 lldb_private::Status &error, lldb::addr_t bytes_addr, const void *bytes,
1632 lldb::offset_t bytes_size)>
1634
1635 /// Read of memory from a process in discrete chunks, terminating
1636 /// either when all bytes are read, or the supplied callback returns
1637 /// IterationAction::Stop
1638 ///
1639 /// \param[in] vm_addr
1640 /// A virtual load address that indicates where to start reading
1641 /// memory from.
1642 ///
1643 /// \param[in] buf
1644 /// If NULL, a buffer of \a chunk_size will be created and used for the
1645 /// callback. If non NULL, this buffer must be at least \a chunk_size bytes
1646 /// and will be used for storing chunked memory reads.
1647 ///
1648 /// \param[in] chunk_size
1649 /// The minimum size of the byte buffer, and the chunk size of memory
1650 /// to read.
1651 ///
1652 /// \param[in] total_size
1653 /// The total number of bytes to read.
1654 ///
1655 /// \param[in] callback
1656 /// The callback to invoke when a chunk is read from memory.
1657 ///
1658 /// \return
1659 /// The number of bytes that were actually read into \a buf and
1660 /// written to the provided callback.
1661 /// If the returned number is greater than zero, yet less than \a
1662 /// size, then this function will get called again with \a
1663 /// vm_addr, \a buf, and \a size updated appropriately. Zero is
1664 /// returned in the case of an error.
1666 lldb::addr_t chunk_size,
1667 lldb::offset_t total_size,
1668 ReadMemoryChunkCallback callback);
1669
1670 /// Read a NULL terminated C string from memory
1671 ///
1672 /// This function will read a cache page at a time until the NULL
1673 /// C string terminator is found. It will stop reading if the NULL
1674 /// termination byte isn't found before reading \a cstr_max_len bytes, and
1675 /// the results are always guaranteed to be NULL terminated (at most
1676 /// cstr_max_len - 1 bytes will be read).
1677 size_t ReadCStringFromMemory(lldb::addr_t vm_addr, char *cstr,
1678 size_t cstr_max_len, Status &error);
1679
1680 size_t ReadCStringFromMemory(lldb::addr_t vm_addr, std::string &out_str,
1681 Status &error);
1682
1683 /// Reads an unsigned integer of the specified byte size from process
1684 /// memory.
1685 ///
1686 /// \param[in] load_addr
1687 /// A load address of the integer to read.
1688 ///
1689 /// \param[in] byte_size
1690 /// The size in byte of the integer to read.
1691 ///
1692 /// \param[in] fail_value
1693 /// The value to return if we fail to read an integer.
1694 ///
1695 /// \param[out] error
1696 /// An error that indicates the success or failure of this
1697 /// operation. If error indicates success (error.Success()),
1698 /// then the value returned can be trusted, otherwise zero
1699 /// will be returned.
1700 ///
1701 /// \return
1702 /// The unsigned integer that was read from the process memory
1703 /// space. If the integer was smaller than a uint64_t, any
1704 /// unused upper bytes will be zero filled. If the process
1705 /// byte order differs from the host byte order, the integer
1706 /// value will be appropriately byte swapped into host byte
1707 /// order.
1709 size_t byte_size, uint64_t fail_value,
1710 Status &error);
1711
1712 int64_t ReadSignedIntegerFromMemory(lldb::addr_t load_addr, size_t byte_size,
1713 int64_t fail_value, Status &error);
1714
1716
1717 bool WritePointerToMemory(lldb::addr_t vm_addr, lldb::addr_t ptr_value,
1718 Status &error);
1719
1720 /// Actually do the writing of memory to a process.
1721 ///
1722 /// \param[in] vm_addr
1723 /// A virtual load address that indicates where to start writing
1724 /// memory to.
1725 ///
1726 /// \param[in] buf
1727 /// A byte buffer that is at least \a size bytes long that
1728 /// contains the data to write.
1729 ///
1730 /// \param[in] size
1731 /// The number of bytes to write.
1732 ///
1733 /// \param[out] error
1734 /// An error value in case the memory write fails.
1735 ///
1736 /// \return
1737 /// The number of bytes that were actually written.
1738 virtual size_t DoWriteMemory(lldb::addr_t vm_addr, const void *buf,
1739 size_t size, Status &error) {
1741 "error: {0} does not support writing to processes", GetPluginName());
1742 return 0;
1743 }
1744
1745 /// Write all or part of a scalar value to memory.
1746 ///
1747 /// The value contained in \a scalar will be swapped to match the byte order
1748 /// of the process that is being debugged. If \a size is less than the size
1749 /// of scalar, the least significant \a size bytes from scalar will be
1750 /// written. If \a size is larger than the byte size of scalar, then the
1751 /// extra space will be padded with zeros and the scalar value will be
1752 /// placed in the least significant bytes in memory.
1753 ///
1754 /// \param[in] vm_addr
1755 /// A virtual load address that indicates where to start writing
1756 /// memory to.
1757 ///
1758 /// \param[in] scalar
1759 /// The scalar to write to the debugged process.
1760 ///
1761 /// \param[in] size
1762 /// This value can be smaller or larger than the scalar value
1763 /// itself. If \a size is smaller than the size of \a scalar,
1764 /// the least significant bytes in \a scalar will be used. If
1765 /// \a size is larger than the byte size of \a scalar, then
1766 /// the extra space will be padded with zeros. If \a size is
1767 /// set to UINT32_MAX, then the size of \a scalar will be used.
1768 ///
1769 /// \param[out] error
1770 /// An error value in case the memory write fails.
1771 ///
1772 /// \return
1773 /// The number of bytes that were actually written.
1774 size_t WriteScalarToMemory(lldb::addr_t vm_addr, const Scalar &scalar,
1775 size_t size, Status &error);
1776
1777 size_t ReadScalarIntegerFromMemory(lldb::addr_t addr, uint32_t byte_size,
1778 bool is_signed, Scalar &scalar,
1779 Status &error);
1780
1781 /// Write memory to a process.
1782 ///
1783 /// This function will write memory to the current process's address space
1784 /// and maintain any traps that might be present due to software
1785 /// breakpoints.
1786 ///
1787 /// This function is not meant to be overridden by Process subclasses, the
1788 /// subclasses should implement Process::DoWriteMemory (lldb::addr_t,
1789 /// size_t, void *).
1790 ///
1791 /// \param[in] vm_addr
1792 /// A virtual load address that indicates where to start writing
1793 /// memory to.
1794 ///
1795 /// \param[in] buf
1796 /// A byte buffer that is at least \a size bytes long that
1797 /// contains the data to write.
1798 ///
1799 /// \param[in] size
1800 /// The number of bytes to write.
1801 ///
1802 /// \return
1803 /// The number of bytes that were actually written.
1804 // TODO: change this to take an ArrayRef<uint8_t>
1805 size_t WriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size,
1806 Status &error);
1807
1808 /// Actually allocate memory in the process.
1809 ///
1810 /// This function will allocate memory in the process's address space. This
1811 /// can't rely on the generic function calling mechanism, since that
1812 /// requires this function.
1813 ///
1814 /// \param[in] size
1815 /// The size of the allocation requested.
1816 ///
1817 /// \return
1818 /// The address of the allocated buffer in the process, or
1819 /// LLDB_INVALID_ADDRESS if the allocation failed.
1820
1821 virtual lldb::addr_t DoAllocateMemory(size_t size, uint32_t permissions,
1822 Status &error) {
1824 "error: {0} does not support allocating in the debug process",
1825 GetPluginName());
1826 return LLDB_INVALID_ADDRESS;
1827 }
1828
1829 virtual Status WriteObjectFile(std::vector<ObjectFile::LoadableData> entries);
1830
1831 /// The public interface to allocating memory in the process.
1832 ///
1833 /// This function will allocate memory in the process's address space. This
1834 /// can't rely on the generic function calling mechanism, since that
1835 /// requires this function.
1836 ///
1837 /// \param[in] size
1838 /// The size of the allocation requested.
1839 ///
1840 /// \param[in] permissions
1841 /// Or together any of the lldb::Permissions bits. The permissions on
1842 /// a given memory allocation can't be changed after allocation. Note
1843 /// that a block that isn't set writable can still be written on from
1844 /// lldb,
1845 /// just not by the process itself.
1846 ///
1847 /// \param[in,out] error
1848 /// An error object to fill in if things go wrong.
1849 /// \return
1850 /// The address of the allocated buffer in the process, or
1851 /// LLDB_INVALID_ADDRESS if the allocation failed.
1852 lldb::addr_t AllocateMemory(size_t size, uint32_t permissions, Status &error);
1853
1854 /// The public interface to allocating memory in the process, this also
1855 /// clears the allocated memory.
1856 ///
1857 /// This function will allocate memory in the process's address space. This
1858 /// can't rely on the generic function calling mechanism, since that
1859 /// requires this function.
1860 ///
1861 /// \param[in] size
1862 /// The size of the allocation requested.
1863 ///
1864 /// \param[in] permissions
1865 /// Or together any of the lldb::Permissions bits. The permissions on
1866 /// a given memory allocation can't be changed after allocation. Note
1867 /// that a block that isn't set writable can still be written on from
1868 /// lldb,
1869 /// just not by the process itself.
1870 ///
1871 /// \param[in,out] error
1872 /// An error object to fill in if things go wrong.
1873 ///
1874 /// \return
1875 /// The address of the allocated buffer in the process, or
1876 /// LLDB_INVALID_ADDRESS if the allocation failed.
1877
1878 lldb::addr_t CallocateMemory(size_t size, uint32_t permissions,
1879 Status &error);
1880
1881 /// If this architecture and process supports memory tagging, return a tag
1882 /// manager that can be used to maniupulate those memory tags.
1883 ///
1884 /// \return
1885 /// Either a valid pointer to a tag manager or an error describing why one
1886 /// could not be provided.
1887 llvm::Expected<const MemoryTagManager *> GetMemoryTagManager();
1888
1889 /// Read memory tags for the range addr to addr+len. It is assumed
1890 /// that this range has already been granule aligned.
1891 /// (see MemoryTagManager::MakeTaggedRange)
1892 ///
1893 /// This calls DoReadMemoryTags to do the target specific operations.
1894 ///
1895 /// \param[in] addr
1896 /// Start of memory range to read tags for.
1897 ///
1898 /// \param[in] len
1899 /// Length of memory range to read tags for (in bytes).
1900 ///
1901 /// \return
1902 /// If this architecture or process does not support memory tagging,
1903 /// an error saying so.
1904 /// If it does, either the memory tags or an error describing a
1905 /// failure to read or unpack them.
1906 virtual llvm::Expected<std::vector<lldb::addr_t>>
1907 ReadMemoryTags(lldb::addr_t addr, size_t len);
1908
1909 /// Write memory tags for a range of memory.
1910 /// (calls DoWriteMemoryTags to do the target specific work)
1911 ///
1912 /// \param[in] addr
1913 /// The address to start writing tags from. It is assumed that this
1914 /// address is granule aligned.
1915 ///
1916 /// \param[in] len
1917 /// The size of the range to write tags for. It is assumed that this
1918 /// is some multiple of the granule size. This len can be different
1919 /// from (number of tags * granule size) in the case where you want
1920 /// lldb-server to repeat tags across the range.
1921 ///
1922 /// \param[in] tags
1923 /// Allocation tags to be written. Since lldb-server can repeat tags for a
1924 /// range, the number of tags doesn't have to match the number of granules
1925 /// in the range. (though most of the time it will)
1926 ///
1927 /// \return
1928 /// A Status telling you if the write succeeded or not.
1929 Status WriteMemoryTags(lldb::addr_t addr, size_t len,
1930 const std::vector<lldb::addr_t> &tags);
1931
1932 /// Resolve dynamically loaded indirect functions.
1933 ///
1934 /// \param[in] address
1935 /// The load address of the indirect function to resolve.
1936 ///
1937 /// \param[out] error
1938 /// An error value in case the resolve fails.
1939 ///
1940 /// \return
1941 /// The address of the resolved function.
1942 /// LLDB_INVALID_ADDRESS if the resolution failed.
1943 virtual lldb::addr_t ResolveIndirectFunction(const Address *address,
1944 Status &error);
1945
1946 /// Locate the memory region that contains load_addr.
1947 ///
1948 /// If load_addr is within the address space the process has mapped
1949 /// range_info will be filled in with the start and end of that range as
1950 /// well as the permissions for that range and range_info. GetMapped will
1951 /// return true.
1952 ///
1953 /// If load_addr is outside any mapped region then range_info will have its
1954 /// start address set to load_addr and the end of the range will indicate
1955 /// the start of the next mapped range or be set to LLDB_INVALID_ADDRESS if
1956 /// there are no valid mapped ranges between load_addr and the end of the
1957 /// process address space.
1958 ///
1959 /// GetMemoryRegionInfo calls DoGetMemoryRegionInfo. Override that function in
1960 /// process subclasses.
1961 ///
1962 /// \param[in] load_addr
1963 /// The load address to query the range_info for. May include non
1964 /// address bits, these will be removed by the ABI plugin if there is
1965 /// one.
1966 ///
1967 /// \param[out] range_info
1968 /// An range_info value containing the details of the range.
1969 ///
1970 /// \return
1971 /// An error value.
1973 MemoryRegionInfo &range_info);
1974
1975 /// Obtain all the mapped memory regions within this process.
1976 ///
1977 /// \param[out] region_list
1978 /// A vector to contain MemoryRegionInfo objects for all mapped
1979 /// ranges.
1980 ///
1981 /// \return
1982 /// An error value.
1983 virtual Status
1985
1986 /// Get the number of watchpoints supported by this target.
1987 ///
1988 /// We may be able to determine the number of watchpoints available
1989 /// on this target; retrieve this value if possible.
1990 ///
1991 /// This number may be less than the number of watchpoints a user
1992 /// can specify. This is because a single user watchpoint may require
1993 /// multiple watchpoint slots to implement. Due to the size
1994 /// and/or alignment of objects.
1995 ///
1996 /// \return
1997 /// Returns the number of watchpoints, if available.
1998 virtual std::optional<uint32_t> GetWatchpointSlotCount() {
1999 return std::nullopt;
2000 }
2001
2002 /// Whether lldb will be notified about watchpoints after
2003 /// the instruction has completed executing, or if the
2004 /// instruction is rolled back and it is notified before it
2005 /// executes.
2006 /// The default behavior is "exceptions received after instruction
2007 /// has executed", except for certain CPU architectures.
2008 /// Process subclasses may override this if they have additional
2009 /// information.
2010 ///
2011 /// \return
2012 /// Returns true for targets where lldb is notified after
2013 /// the instruction has completed executing.
2015
2017 lldb::addr_t header_addr,
2018 size_t size_to_read = 512);
2019
2020 /// Attempt to get the attributes for a region of memory in the process.
2021 ///
2022 /// It may be possible for the remote debug server to inspect attributes for
2023 /// a region of memory in the process, such as whether there is a valid page
2024 /// of memory at a given address or whether that page is
2025 /// readable/writable/executable by the process.
2026 ///
2027 /// \param[in] load_addr
2028 /// The address of interest in the process.
2029 ///
2030 /// \param[out] permissions
2031 /// If this call returns successfully, this bitmask will have
2032 /// its Permissions bits set to indicate whether the region is
2033 /// readable/writable/executable. If this call fails, the
2034 /// bitmask values are undefined.
2035 ///
2036 /// \return
2037 /// Returns true if it was able to determine the attributes of the
2038 /// memory region. False if not.
2039 virtual bool GetLoadAddressPermissions(lldb::addr_t load_addr,
2040 uint32_t &permissions);
2041
2042 /// Determines whether executing JIT-compiled code in this process is
2043 /// possible.
2044 ///
2045 /// \return
2046 /// True if execution of JIT code is possible; false otherwise.
2047 bool CanJIT();
2048
2049 /// Sets whether executing JIT-compiled code in this process is possible.
2050 ///
2051 /// \param[in] can_jit
2052 /// True if execution of JIT code is possible; false otherwise.
2053 void SetCanJIT(bool can_jit);
2054
2055 /// Determines whether executing function calls using the interpreter is
2056 /// possible for this process.
2057 ///
2058 /// \return
2059 /// True if possible; false otherwise.
2061
2062 /// Sets whether executing function calls using the interpreter is possible
2063 /// for this process.
2064 ///
2065 /// \param[in] can_interpret_function_calls
2066 /// True if possible; false otherwise.
2067 void SetCanInterpretFunctionCalls(bool can_interpret_function_calls) {
2068 m_can_interpret_function_calls = can_interpret_function_calls;
2069 }
2070
2071 /// Sets whether executing code in this process is possible. This could be
2072 /// either through JIT or interpreting.
2073 ///
2074 /// \param[in] can_run_code
2075 /// True if execution of code is possible; false otherwise.
2076 void SetCanRunCode(bool can_run_code);
2077
2078 /// Actually deallocate memory in the process.
2079 ///
2080 /// This function will deallocate memory in the process's address space that
2081 /// was allocated with AllocateMemory.
2082 ///
2083 /// \param[in] ptr
2084 /// A return value from AllocateMemory, pointing to the memory you
2085 /// want to deallocate.
2086 ///
2087 /// \return
2088 /// \b true if the memory was deallocated, \b false otherwise.
2091 "error: {0} does not support deallocating in the debug process",
2092 GetPluginName());
2093 }
2094
2095 /// The public interface to deallocating memory in the process.
2096 ///
2097 /// This function will deallocate memory in the process's address space that
2098 /// was allocated with AllocateMemory.
2099 ///
2100 /// \param[in] ptr
2101 /// A return value from AllocateMemory, pointing to the memory you
2102 /// want to deallocate.
2103 ///
2104 /// \return
2105 /// \b true if the memory was deallocated, \b false otherwise.
2107
2108 /// Get any available STDOUT.
2109 ///
2110 /// Calling this method is a valid operation only if all of the following
2111 /// conditions are true: 1) The process was launched, and not attached to.
2112 /// 2) The process was not launched with eLaunchFlagDisableSTDIO. 3) The
2113 /// process was launched without supplying a valid file path
2114 /// for STDOUT.
2115 ///
2116 /// Note that the implementation will probably need to start a read thread
2117 /// in the background to make sure that the pipe is drained and the STDOUT
2118 /// buffered appropriately, to prevent the process from deadlocking trying
2119 /// to write to a full buffer.
2120 ///
2121 /// Events will be queued indicating that there is STDOUT available that can
2122 /// be retrieved using this function.
2123 ///
2124 /// \param[out] buf
2125 /// A buffer that will receive any STDOUT bytes that are
2126 /// currently available.
2127 ///
2128 /// \param[in] buf_size
2129 /// The size in bytes for the buffer \a buf.
2130 ///
2131 /// \return
2132 /// The number of bytes written into \a buf. If this value is
2133 /// equal to \a buf_size, another call to this function should
2134 /// be made to retrieve more STDOUT data.
2135 virtual size_t GetSTDOUT(char *buf, size_t buf_size, Status &error);
2136
2137 /// Get any available STDERR.
2138 ///
2139 /// Calling this method is a valid operation only if all of the following
2140 /// conditions are true: 1) The process was launched, and not attached to.
2141 /// 2) The process was not launched with eLaunchFlagDisableSTDIO. 3) The
2142 /// process was launched without supplying a valid file path
2143 /// for STDERR.
2144 ///
2145 /// Note that the implementation will probably need to start a read thread
2146 /// in the background to make sure that the pipe is drained and the STDERR
2147 /// buffered appropriately, to prevent the process from deadlocking trying
2148 /// to write to a full buffer.
2149 ///
2150 /// Events will be queued indicating that there is STDERR available that can
2151 /// be retrieved using this function.
2152 ///
2153 /// \param[in] buf
2154 /// A buffer that will receive any STDERR bytes that are
2155 /// currently available.
2156 ///
2157 /// \param[out] buf_size
2158 /// The size in bytes for the buffer \a buf.
2159 ///
2160 /// \return
2161 /// The number of bytes written into \a buf. If this value is
2162 /// equal to \a buf_size, another call to this function should
2163 /// be made to retrieve more STDERR data.
2164 virtual size_t GetSTDERR(char *buf, size_t buf_size, Status &error);
2165
2166 /// Puts data into this process's STDIN.
2167 ///
2168 /// Calling this method is a valid operation only if all of the following
2169 /// conditions are true: 1) The process was launched, and not attached to.
2170 /// 2) The process was not launched with eLaunchFlagDisableSTDIO. 3) The
2171 /// process was launched without supplying a valid file path
2172 /// for STDIN.
2173 ///
2174 /// \param[in] buf
2175 /// A buffer that contains the data to write to the process's STDIN.
2176 ///
2177 /// \param[in] buf_size
2178 /// The size in bytes for the buffer \a buf.
2179 ///
2180 /// \return
2181 /// The number of bytes written into \a buf. If this value is
2182 /// less than \a buf_size, another call to this function should
2183 /// be made to write the rest of the data.
2184 virtual size_t PutSTDIN(const char *buf, size_t buf_size, Status &error) {
2185 error = Status::FromErrorString("stdin unsupported");
2186 return 0;
2187 }
2188
2189 /// Get any available profile data.
2190 ///
2191 /// \param[out] buf
2192 /// A buffer that will receive any profile data bytes that are
2193 /// currently available.
2194 ///
2195 /// \param[out] buf_size
2196 /// The size in bytes for the buffer \a buf.
2197 ///
2198 /// \return
2199 /// The number of bytes written into \a buf. If this value is
2200 /// equal to \a buf_size, another call to this function should
2201 /// be made to retrieve more profile data.
2202 virtual size_t GetAsyncProfileData(char *buf, size_t buf_size, Status &error);
2203
2204 // Process Breakpoints
2206
2209 "error: {0} does not support enabling breakpoints", GetPluginName());
2210 }
2211
2214 "error: {0} does not support disabling breakpoints", GetPluginName());
2215 }
2216
2217 // This is implemented completely using the lldb::Process API. Subclasses
2218 // don't need to implement this function unless the standard flow of read
2219 // existing opcode, write breakpoint opcode, verify breakpoint opcode doesn't
2220 // work for a specific process plug-in.
2222
2223 // This is implemented completely using the lldb::Process API. Subclasses
2224 // don't need to implement this function unless the standard flow of
2225 // restoring original opcode in memory and verifying the restored opcode
2226 // doesn't work for a specific process plug-in.
2228
2230
2232 GetBreakpointSiteList() const;
2233
2235
2237
2239 bool use_hardware);
2240
2242
2244
2245 // BreakpointLocations use RemoveConstituentFromBreakpointSite to remove
2246 // themselves from the constituent's list of this breakpoint sites.
2248 lldb::user_id_t constituent_id,
2249 lldb::BreakpointSiteSP &bp_site_sp);
2250
2251 // Process Watchpoints (optional)
2252 virtual Status EnableWatchpoint(lldb::WatchpointSP wp_sp, bool notify = true);
2253
2255 bool notify = true);
2256
2257 // Thread Queries
2258
2259 /// Update the thread list.
2260 ///
2261 /// This method performs some general clean up before invoking
2262 /// \a DoUpdateThreadList, which should be implemented by each
2263 /// process plugin.
2264 ///
2265 /// \return
2266 /// \b true if the new thread list could be generated, \b false otherwise.
2267 bool UpdateThreadList(ThreadList &old_thread_list,
2268 ThreadList &new_thread_list);
2269
2271
2273
2278
2279 // When ExtendedBacktraces are requested, the HistoryThreads that are created
2280 // need an owner -- they're saved here in the Process. The threads in this
2281 // list are not iterated over - driver programs need to request the extended
2282 // backtrace calls starting from a root concrete thread one by one.
2284
2286
2287 uint32_t GetNextThreadIndexID(uint64_t thread_id);
2288
2290
2291 // Returns true if an index id has been assigned to a thread.
2292 bool HasAssignedIndexIDToThread(uint64_t sb_thread_id);
2293
2294 // Given a thread_id, it will assign a more reasonable index id for display
2295 // to the user. If the thread_id has previously been assigned, the same index
2296 // id will be used.
2297 uint32_t AssignIndexIDToThread(uint64_t thread_id);
2298
2299 // Queue Queries
2300
2301 virtual void UpdateQueueListIfNeeded();
2302
2307
2312
2313 // Event Handling
2315
2316 // Returns the process state when it is stopped. If specified, event_sp_ptr
2317 // is set to the event which triggered the stop. If wait_always = false, and
2318 // the process is already stopped, this function returns immediately. If the
2319 // process is hijacked and use_run_lock is true (the default), then this
2320 // function releases the run lock after the stop. Setting use_run_lock to
2321 // false will avoid this behavior.
2322 // If we are waiting to stop that will return control to the user,
2323 // then we also want to run SelectMostRelevantFrame, which is controlled
2324 // by "select_most_relevant".
2327 lldb::EventSP *event_sp_ptr = nullptr,
2328 bool wait_always = true,
2329 lldb::ListenerSP hijack_listener = lldb::ListenerSP(),
2330 Stream *stream = nullptr, bool use_run_lock = true,
2331 SelectMostRelevant select_most_relevant =
2333
2334 uint32_t GetIOHandlerID() const { return m_iohandler_sync.GetValue(); }
2335
2336 /// Waits for the process state to be running within a given msec timeout.
2337 ///
2338 /// The main purpose of this is to implement an interlock waiting for
2339 /// HandlePrivateEvent to push an IOHandler.
2340 ///
2341 /// \param[in] timeout
2342 /// The maximum time length to wait for the process to transition to the
2343 /// eStateRunning state.
2344 void SyncIOHandler(uint32_t iohandler_id, const Timeout<std::micro> &timeout);
2345
2347 lldb::EventSP &event_sp, const Timeout<std::micro> &timeout,
2349 hijack_listener); // Pass an empty ListenerSP to use builtin listener
2350
2351 /// Centralize the code that handles and prints descriptions for process
2352 /// state changes.
2353 ///
2354 /// \param[in] event_sp
2355 /// The process state changed event
2356 ///
2357 /// \param[in] stream
2358 /// The output stream to get the state change description
2359 ///
2360 /// \param[in,out] pop_process_io_handler
2361 /// If this value comes in set to \b true, then pop the Process IOHandler
2362 /// if needed.
2363 /// Else this variable will be set to \b true or \b false to indicate if
2364 /// the process
2365 /// needs to have its process IOHandler popped.
2366 ///
2367 /// \return
2368 /// \b true if the event describes a process state changed event, \b false
2369 /// otherwise.
2370 static bool
2371 HandleProcessStateChangedEvent(const lldb::EventSP &event_sp, Stream *stream,
2372 SelectMostRelevant select_most_relevant,
2373 bool &pop_process_io_handler);
2374
2376
2378 public:
2380 : m_process(process) {
2381 m_process.HijackProcessEvents(std::move(listener_sp));
2382 }
2383
2384 ~ProcessEventHijacker() { m_process.RestoreProcessEvents(); }
2385
2386 private:
2388 };
2389
2391 friend class ProcessProperties;
2392 /// If you need to ensure that you and only you will hear about some public
2393 /// event, then make a new listener, set to listen to process events, and
2394 /// then call this with that listener. Then you will have to wait on that
2395 /// listener explicitly for events (rather than using the GetNextEvent &
2396 /// WaitFor* calls above. Be sure to call RestoreProcessEvents when you are
2397 /// done.
2398 ///
2399 /// \param[in] listener_sp
2400 /// This is the new listener to whom all process events will be delivered.
2401 ///
2402 /// \return
2403 /// Returns \b true if the new listener could be installed,
2404 /// \b false otherwise.
2405 bool HijackProcessEvents(lldb::ListenerSP listener_sp);
2406
2407 /// Restores the process event broadcasting to its normal state.
2408 ///
2409 void RestoreProcessEvents();
2410
2412
2414
2415 const lldb::ABISP &GetABI();
2416
2418
2419 std::vector<LanguageRuntime *> GetLanguageRuntimes();
2420
2422
2423 bool IsPossibleDynamicValue(ValueObject &in_value);
2424
2425 bool IsRunning() const;
2426
2430
2431 void SetDynamicCheckers(DynamicCheckerFunctions *dynamic_checkers);
2432
2433/// Prune ThreadPlanStacks for unreported threads.
2434///
2435/// \param[in] tid
2436/// The tid whose Plan Stack we are seeking to prune.
2437///
2438/// \return
2439/// \b true if the TID is found or \b false if not.
2441
2442/// Prune ThreadPlanStacks for all unreported threads.
2443void PruneThreadPlans();
2444
2445 /// Find the thread plan stack associated with thread with \a tid.
2446 ///
2447 /// \param[in] tid
2448 /// The tid whose Plan Stack we are seeking.
2449 ///
2450 /// \return
2451 /// Returns a ThreadPlan if the TID is found or nullptr if not.
2453
2454 /// Dump the thread plans associated with thread with \a tid.
2455 ///
2456 /// \param[in,out] strm
2457 /// The stream to which to dump the output
2458 ///
2459 /// \param[in] tid
2460 /// The tid whose Plan Stack we are dumping
2461 ///
2462 /// \param[in] desc_level
2463 /// How much detail to dump
2464 ///
2465 /// \param[in] internal
2466 /// If \b true dump all plans, if false only user initiated plans
2467 ///
2468 /// \param[in] condense_trivial
2469 /// If true, only dump a header if the plan stack is just the base plan.
2470 ///
2471 /// \param[in] skip_unreported_plans
2472 /// If true, only dump a plan if it is currently backed by an
2473 /// lldb_private::Thread *.
2474 ///
2475 /// \return
2476 /// Returns \b true if TID was found, \b false otherwise
2478 lldb::DescriptionLevel desc_level, bool internal,
2479 bool condense_trivial, bool skip_unreported_plans);
2480
2481 /// Dump all the thread plans for this process.
2482 ///
2483 /// \param[in,out] strm
2484 /// The stream to which to dump the output
2485 ///
2486 /// \param[in] desc_level
2487 /// How much detail to dump
2488 ///
2489 /// \param[in] internal
2490 /// If \b true dump all plans, if false only user initiated plans
2491 ///
2492 /// \param[in] condense_trivial
2493 /// If true, only dump a header if the plan stack is just the base plan.
2494 ///
2495 /// \param[in] skip_unreported_plans
2496 /// If true, skip printing all thread plan stacks that don't currently
2497 /// have a backing lldb_private::Thread *.
2498 void DumpThreadPlans(Stream &strm, lldb::DescriptionLevel desc_level,
2499 bool internal, bool condense_trivial,
2500 bool skip_unreported_plans);
2501
2502 /// Call this to set the lldb in the mode where it breaks on new thread
2503 /// creations, and then auto-restarts. This is useful when you are trying
2504 /// to run only one thread, but either that thread or the kernel is creating
2505 /// new threads in the process. If you stop when the thread is created, you
2506 /// can immediately suspend it, and keep executing only the one thread you
2507 /// intend.
2508 ///
2509 /// \return
2510 /// Returns \b true if we were able to start up the notification
2511 /// \b false otherwise.
2512 virtual bool StartNoticingNewThreads() { return true; }
2513
2514 /// Call this to turn off the stop & notice new threads mode.
2515 ///
2516 /// \return
2517 /// Returns \b true if we were able to start up the notification
2518 /// \b false otherwise.
2519 virtual bool StopNoticingNewThreads() { return true; }
2520
2521 void SetRunningUserExpression(bool on);
2522 void SetRunningUtilityFunction(bool on);
2523
2524 // lldb::ExecutionContextScope pure virtual functions
2526
2527 lldb::ProcessSP CalculateProcess() override { return shared_from_this(); }
2528
2530
2534
2535 void CalculateExecutionContext(ExecutionContext &exe_ctx) override;
2536
2537 void SetSTDIOFileDescriptor(int file_descriptor);
2538
2539 // Add a permanent region of memory that should never be read or written to.
2540 // This can be used to ensure that memory reads or writes to certain areas of
2541 // memory never end up being sent to the DoReadMemory or DoWriteMemory
2542 // functions which can improve performance.
2543 void AddInvalidMemoryRegion(const LoadRange &region);
2544
2545 // Remove a permanent region of memory that should never be read or written
2546 // to that was previously added with AddInvalidMemoryRegion.
2547 bool RemoveInvalidMemoryRange(const LoadRange &region);
2548
2549 // If the setup code of a thread plan needs to do work that might involve
2550 // calling a function in the target, it should not do that work directly in
2551 // one of the thread plan functions (DidPush/WillResume) because such work
2552 // needs to be handled carefully. Instead, put that work in a
2553 // PreResumeAction callback, and register it with the process. It will get
2554 // done before the actual "DoResume" gets called.
2555
2557
2558 void AddPreResumeAction(PreResumeActionCallback callback, void *baton);
2559
2560 bool RunPreResumeActions();
2561
2562 void ClearPreResumeActions();
2563
2564 void ClearPreResumeAction(PreResumeActionCallback callback, void *baton);
2565
2567
2569
2571
2572 virtual Status SendEventData(const char *data) {
2574 "Sending an event is not supported for this process.");
2575 }
2576
2578
2581
2582 /// Try to fetch the module specification for a module with the given file
2583 /// name and architecture. Process sub-classes have to override this method
2584 /// if they support platforms where the Platform object can't get the module
2585 /// spec for all module.
2586 ///
2587 /// \param[in] module_file_spec
2588 /// The file name of the module to get specification for.
2589 ///
2590 /// \param[in] arch
2591 /// The architecture of the module to get specification for.
2592 ///
2593 /// \param[out] module_spec
2594 /// The fetched module specification if the return value is
2595 /// \b true, unchanged otherwise.
2596 ///
2597 /// \return
2598 /// Returns \b true if the module spec fetched successfully,
2599 /// \b false otherwise.
2600 virtual bool GetModuleSpec(const FileSpec &module_file_spec,
2601 const ArchSpec &arch, ModuleSpec &module_spec);
2602
2603 virtual void PrefetchModuleSpecs(llvm::ArrayRef<FileSpec> module_file_specs,
2604 const llvm::Triple &triple) {}
2605
2606 /// Try to find the load address of a file.
2607 /// The load address is defined as the address of the first memory region
2608 /// what contains data mapped from the specified file.
2609 ///
2610 /// \param[in] file
2611 /// The name of the file whose load address we are looking for
2612 ///
2613 /// \param[out] is_loaded
2614 /// \b True if the file is loaded into the memory and false
2615 /// otherwise.
2616 ///
2617 /// \param[out] load_addr
2618 /// The load address of the file if it is loaded into the
2619 /// processes address space, LLDB_INVALID_ADDRESS otherwise.
2620 virtual Status GetFileLoadAddress(const FileSpec &file, bool &is_loaded,
2621 lldb::addr_t &load_addr) {
2622 return Status::FromErrorString("Not supported");
2623 }
2624
2625 /// Fetch process defined metadata.
2626 ///
2627 /// \return
2628 /// A StructuredDataSP object which, if non-empty, will contain the
2629 /// information related to the process.
2630 virtual StructuredData::DictionarySP GetMetadata() { return nullptr; }
2631
2632 /// Fetch extended crash information held by the process. This will never be
2633 /// an empty shared pointer, it will always have a dict, though it may be
2634 /// empty.
2636 assert(m_crash_info_dict_sp && "We always have a valid dictionary");
2637 return m_crash_info_dict_sp;
2638 }
2639
2641 // StructuredData::Dictionary is add only, so we have to make a new one:
2642 m_crash_info_dict_sp = std::make_shared<StructuredData::Dictionary>();
2643 }
2644
2645 size_t AddImageToken(lldb::addr_t image_ptr);
2646
2647 lldb::addr_t GetImagePtrFromToken(size_t token) const;
2648
2649 void ResetImageToken(size_t token);
2650
2651 /// Find the next branch instruction to set a breakpoint on
2652 ///
2653 /// When instruction stepping through a source line, instead of stepping
2654 /// through each instruction, we can put a breakpoint on the next branch
2655 /// instruction (within the range of instructions we are stepping through)
2656 /// and continue the process to there, yielding significant performance
2657 /// benefits over instruction stepping.
2658 ///
2659 /// \param[in] default_stop_addr
2660 /// The address of the instruction where lldb would put a
2661 /// breakpoint normally.
2662 ///
2663 /// \param[in] range_bounds
2664 /// The range which the breakpoint must be contained within.
2665 /// Typically a source line.
2666 ///
2667 /// \return
2668 /// The address of the next branch instruction, or the end of
2669 /// the range provided in range_bounds. If there are any
2670 /// problems with the disassembly or getting the instructions,
2671 /// the original default_stop_addr will be returned.
2673 AddressRange range_bounds);
2674
2675 /// Configure asynchronous structured data feature.
2676 ///
2677 /// Each Process type that supports using an asynchronous StructuredData
2678 /// feature should implement this to enable/disable/configure the feature.
2679 /// The default implementation here will always return an error indiciating
2680 /// the feature is unsupported.
2681 ///
2682 /// StructuredDataPlugin implementations will call this to configure a
2683 /// feature that has been reported as being supported.
2684 ///
2685 /// \param[in] type_name
2686 /// The StructuredData type name as previously discovered by
2687 /// the Process-derived instance.
2688 ///
2689 /// \param[in] config_sp
2690 /// Configuration data for the feature being enabled. This config
2691 /// data, which may be null, will be passed along to the feature
2692 /// to process. The feature will dictate whether this is a dictionary,
2693 /// an array or some other object. If the feature needs to be
2694 /// set up properly before it can be enabled, then the config should
2695 /// also take an enable/disable flag.
2696 ///
2697 /// \return
2698 /// Returns the result of attempting to configure the feature.
2699 virtual Status
2700 ConfigureStructuredData(llvm::StringRef type_name,
2701 const StructuredData::ObjectSP &config_sp);
2702
2703 /// Broadcasts the given structured data object from the given plugin.
2704 ///
2705 /// StructuredDataPlugin instances can use this to optionally broadcast any
2706 /// of their data if they want to make it available for clients. The data
2707 /// will come in on the structured data event bit
2708 /// (eBroadcastBitStructuredData).
2709 ///
2710 /// \param[in] object_sp
2711 /// The structured data object to broadcast.
2712 ///
2713 /// \param[in] plugin_sp
2714 /// The plugin that will be reported in the event's plugin
2715 /// parameter.
2717 const lldb::StructuredDataPluginSP &plugin_sp);
2718
2719 /// Returns the StructuredDataPlugin associated with a given type name, if
2720 /// there is one.
2721 ///
2722 /// There will only be a plugin for a given StructuredDataType if the
2723 /// debugged process monitor claims that the feature is supported. This is
2724 /// one way to tell whether a feature is available.
2725 ///
2726 /// \return
2727 /// The plugin if one is available for the specified feature;
2728 /// otherwise, returns an empty shared pointer.
2730 GetStructuredDataPlugin(llvm::StringRef type_name) const;
2731
2732 virtual void *GetImplementation() { return nullptr; }
2733
2735
2739
2740 /// Find a pattern within a memory region.
2741 ///
2742 /// This function searches for a pattern represented by the provided buffer
2743 /// within the memory range specified by the low and high addresses. It uses
2744 /// a bad character heuristic to optimize the search process.
2745 ///
2746 /// \param[in] low The starting address of the memory region to be searched.
2747 /// (inclusive)
2748 ///
2749 /// \param[in] high The ending address of the memory region to be searched.
2750 /// (exclusive)
2751 ///
2752 /// \param[in] buf A pointer to the buffer containing the pattern to be
2753 /// searched.
2754 ///
2755 /// \param[in] buffer_size The size of the buffer in bytes.
2756 ///
2757 /// \return The address where the pattern was found or LLDB_INVALID_ADDRESS if
2758 /// not found.
2760 const uint8_t *buf, size_t size);
2761
2762 AddressRanges FindRangesInMemory(const uint8_t *buf, uint64_t size,
2763 const AddressRanges &ranges,
2764 size_t alignment, size_t max_matches,
2765 Status &error);
2766
2767 lldb::addr_t FindInMemory(const uint8_t *buf, uint64_t size,
2768 const AddressRange &range, size_t alignment,
2769 Status &error);
2770
2771 /// Get the base run direction for the process.
2772 /// The base direction is the direction the process will execute in
2773 /// (forward or backward) if no thread plan overrides the direction.
2775 /// Set the base run direction for the process.
2776 /// As a side-effect, if this changes the base direction, then we
2777 /// discard all non-base thread plans to ensure that when execution resumes
2778 /// we definitely execute in the requested direction.
2779 /// FIXME: this is overkill. In some situations ensuring the latter
2780 /// would not require discarding all non-base thread plans.
2781 void SetBaseDirection(lldb::RunDirection direction);
2782
2783protected:
2784 friend class Trace;
2785
2786 /// Construct with a shared pointer to a target, and the Process listener.
2787 /// Uses the Host UnixSignalsSP by default.
2788 Process(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp);
2789
2790 /// Construct with a shared pointer to a target, the Process listener, and
2791 /// the appropriate UnixSignalsSP for the process.
2792 Process(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
2793 const lldb::UnixSignalsSP &unix_signals_sp);
2794
2795 /// Get the processor tracing type supported for this process.
2796 /// Responses might be different depending on the architecture and
2797 /// capabilities of the underlying OS.
2798 ///
2799 /// \return
2800 /// The supported trace type or an \a llvm::Error if tracing is
2801 /// not supported for the inferior.
2802 virtual llvm::Expected<TraceSupportedResponse> TraceSupported();
2803
2804 /// Start tracing a process or its threads.
2805 ///
2806 /// \param[in] request
2807 /// JSON object with the information necessary to start tracing. In the
2808 /// case of gdb-remote processes, this JSON object should conform to the
2809 /// jLLDBTraceStart packet.
2810 ///
2811 /// \return
2812 /// \a llvm::Error::success if the operation was successful, or
2813 /// \a llvm::Error otherwise.
2814 virtual llvm::Error TraceStart(const llvm::json::Value &request) {
2815 return llvm::make_error<UnimplementedError>();
2816 }
2817
2818 /// Stop tracing a live process or its threads.
2819 ///
2820 /// \param[in] request
2821 /// The information determining which threads or process to stop tracing.
2822 ///
2823 /// \return
2824 /// \a llvm::Error::success if the operation was successful, or
2825 /// \a llvm::Error otherwise.
2826 virtual llvm::Error TraceStop(const TraceStopRequest &request) {
2827 return llvm::make_error<UnimplementedError>();
2828 }
2829
2830 /// Get the current tracing state of the process and its threads.
2831 ///
2832 /// \param[in] type
2833 /// Tracing technology type to consider.
2834 ///
2835 /// \return
2836 /// A JSON object string with custom data depending on the trace
2837 /// technology, or an \a llvm::Error in case of errors.
2838 virtual llvm::Expected<std::string> TraceGetState(llvm::StringRef type) {
2839 return llvm::make_error<UnimplementedError>();
2840 }
2841
2842 /// Get binary data given a trace technology and a data identifier.
2843 ///
2844 /// \param[in] request
2845 /// Object with the params of the requested data.
2846 ///
2847 /// \return
2848 /// A vector of bytes with the requested data, or an \a llvm::Error in
2849 /// case of failures.
2850 virtual llvm::Expected<std::vector<uint8_t>>
2852 return llvm::make_error<UnimplementedError>();
2853 }
2854
2855 // This calls a function of the form "void * (*)(void)".
2856 bool CallVoidArgVoidPtrReturn(const Address *address,
2857 lldb::addr_t &returned_func,
2858 bool trap_exceptions = false);
2859
2860 /// Update the thread list following process plug-in's specific logic.
2861 ///
2862 /// This method should only be invoked by \a UpdateThreadList.
2863 ///
2864 /// \return
2865 /// \b true if the new thread list could be generated, \b false otherwise.
2866 virtual bool DoUpdateThreadList(ThreadList &old_thread_list,
2867 ThreadList &new_thread_list) = 0;
2868
2869 /// Actually do the reading of memory from a process.
2870 ///
2871 /// Subclasses must override this function and can return fewer bytes than
2872 /// requested when memory requests are too large. This class will break up
2873 /// the memory requests and keep advancing the arguments along as needed.
2874 ///
2875 /// \param[in] vm_addr
2876 /// A virtual load address that indicates where to start reading
2877 /// memory from.
2878 ///
2879 /// \param[in] size
2880 /// The number of bytes to read.
2881 ///
2882 /// \param[out] buf
2883 /// A byte buffer that is at least \a size bytes long that
2884 /// will receive the memory bytes.
2885 ///
2886 /// \param[out] error
2887 /// An error that indicates the success or failure of this
2888 /// operation. If error indicates success (error.Success()),
2889 /// then the value returned can be trusted, otherwise zero
2890 /// will be returned.
2891 ///
2892 /// \return
2893 /// The number of bytes that were actually read into \a buf.
2894 /// Zero is returned in the case of an error.
2895 virtual size_t DoReadMemory(lldb::addr_t vm_addr, void *buf, size_t size,
2896 Status &error) = 0;
2897
2898 virtual void DoFindInMemory(lldb::addr_t start_addr, lldb::addr_t end_addr,
2899 const uint8_t *buf, size_t size,
2900 AddressRanges &matches, size_t alignment,
2901 size_t max_matches);
2902
2903 /// DoGetMemoryRegionInfo is called by GetMemoryRegionInfo after it has
2904 /// removed non address bits from load_addr. Override this method in
2905 /// subclasses of Process.
2906 ///
2907 /// See GetMemoryRegionInfo for details of the logic.
2908 ///
2909 /// \param[in] load_addr
2910 /// The load address to query the range_info for. (non address bits
2911 /// removed)
2912 ///
2913 /// \param[out] range_info
2914 /// An range_info value containing the details of the range.
2915 ///
2916 /// \return
2917 /// An error value.
2919 MemoryRegionInfo &range_info) {
2921 "Process::DoGetMemoryRegionInfo() not supported");
2922 }
2923
2924 /// Provide an override value in the subclass for lldb's
2925 /// CPU-based logic for whether watchpoint exceptions are
2926 /// received before or after an instruction executes.
2927 ///
2928 /// If a Process subclass needs to override this architecture-based
2929 /// result, it may do so by overriding this method.
2930 ///
2931 /// \return
2932 /// No boolean returned means there is no override of the
2933 /// default architecture-based behavior.
2934 /// true is returned for targets where watchpoints are reported
2935 /// after the instruction has completed.
2936 /// false is returned for targets where watchpoints are reported
2937 /// before the instruction executes.
2938 virtual std::optional<bool> DoGetWatchpointReportedAfter() {
2939 return std::nullopt;
2940 }
2941
2942 /// Handle thread specific async interrupt and return the original thread
2943 /// that requested the async interrupt. It can be null if original thread
2944 /// has exited.
2945 ///
2946 /// \param[in] description
2947 /// Returns the stop reason description of the async interrupt.
2948 virtual lldb::ThreadSP
2949 HandleThreadAsyncInterrupt(uint8_t signo, const std::string &description) {
2950 return lldb::ThreadSP();
2951 }
2952
2954
2955 /// The "private" side of resuming a process. This doesn't alter the state
2956 /// of m_run_lock, but just causes the process to resume.
2957 ///
2958 /// \return
2959 /// An Status object describing the success or failure of the resume.
2961
2962 // Called internally
2963 void CompleteAttach();
2964
2965 // NextEventAction provides a way to register an action on the next event
2966 // that is delivered to this process. There is currently only one next event
2967 // action allowed in the process at one time. If a new "NextEventAction" is
2968 // added while one is already present, the old action will be discarded (with
2969 // HandleBeingUnshipped called after it is discarded.)
2970 //
2971 // If you want to resume the process as a result of a resume action, call
2972 // RequestResume, don't call Resume directly.
2974 public:
2980
2981 NextEventAction(Process *process) : m_process(process) {}
2982
2983 virtual ~NextEventAction() = default;
2984
2986 virtual void HandleBeingUnshipped() {}
2988 virtual const char *GetExitString() = 0;
2989 void RequestResume() { m_process->m_resume_requested = true; }
2990
2991 protected:
2993 };
2994
2997 m_next_event_action_up->HandleBeingUnshipped();
2998
2999 m_next_event_action_up.reset(next_event_action);
3000 }
3001
3002 // This is the completer for Attaching:
3004 public:
3005 AttachCompletionHandler(Process *process, uint32_t exec_count);
3006
3007 ~AttachCompletionHandler() override = default;
3008
3009 EventActionResult PerformAction(lldb::EventSP &event_sp) override;
3011 const char *GetExitString() override;
3012
3013 private:
3015 std::string m_exit_string;
3016 };
3017
3019 lldb::StateType state = m_private_state.GetValue();
3020 return state != lldb::eStateInvalid && state != lldb::eStateDetached &&
3021 state != lldb::eStateExited && m_private_state_thread.IsJoinable();
3022 }
3023
3025
3026 /// Loads any plugins associated with asynchronous structured data and maps
3027 /// the relevant supported type name to the plugin.
3028 ///
3029 /// Processes can receive asynchronous structured data from the process
3030 /// monitor. This method will load and map any structured data plugins that
3031 /// support the given set of supported type names. Later, if any of these
3032 /// features are enabled, the process monitor is free to generate
3033 /// asynchronous structured data. The data must come in as a single \b
3034 /// StructuredData::Dictionary. That dictionary must have a string field
3035 /// named 'type', with a value that equals the relevant type name string
3036 /// (one of the values in \b supported_type_names).
3037 ///
3038 /// \param[in] supported_type_names
3039 /// An array of zero or more type names. Each must be unique.
3040 /// For each entry in the list, a StructuredDataPlugin will be
3041 /// searched for that supports the structured data type name.
3043 const StructuredData::Array &supported_type_names);
3044
3045 /// Route the incoming structured data dictionary to the right plugin.
3046 ///
3047 /// The incoming structured data must be a dictionary, and it must have a
3048 /// key named 'type' that stores a string value. The string value must be
3049 /// the name of the structured data feature that knows how to handle it.
3050 ///
3051 /// \param[in] object_sp
3052 /// When non-null and pointing to a dictionary, the 'type'
3053 /// key's string value is used to look up the plugin that
3054 /// was registered for that structured data type. It then
3055 /// calls the following method on the StructuredDataPlugin
3056 /// instance:
3057 ///
3058 /// virtual void
3059 /// HandleArrivalOfStructuredData(Process &process,
3060 /// llvm::StringRef type_name,
3061 /// const StructuredData::ObjectSP
3062 /// &object_sp)
3063 ///
3064 /// \return
3065 /// True if the structured data was routed to a plugin; otherwise,
3066 /// false.
3068
3069 /// Check whether the process supports memory tagging.
3070 ///
3071 /// \return
3072 /// true if the process supports memory tagging,
3073 /// false otherwise.
3074 virtual bool SupportsMemoryTagging() { return false; }
3075
3076 /// Does the final operation to read memory tags. E.g. sending a GDB packet.
3077 /// It assumes that ReadMemoryTags has checked that memory tagging is enabled
3078 /// and has expanded the memory range as needed.
3079 ///
3080 /// \param[in] addr
3081 /// Start of address range to read memory tags for.
3082 ///
3083 /// \param[in] len
3084 /// Length of the memory range to read tags for (in bytes).
3085 ///
3086 /// \param[in] type
3087 /// Type of tags to read (get this from a MemoryTagManager)
3088 ///
3089 /// \return
3090 /// The packed tag data received from the remote or an error
3091 /// if the read failed.
3092 virtual llvm::Expected<std::vector<uint8_t>>
3093 DoReadMemoryTags(lldb::addr_t addr, size_t len, int32_t type) {
3094 return llvm::createStringError(
3095 llvm::inconvertibleErrorCode(),
3096 llvm::formatv("{0} does not support reading memory tags",
3097 GetPluginName()));
3098 }
3099
3100 /// Does the final operation to write memory tags. E.g. sending a GDB packet.
3101 /// It assumes that WriteMemoryTags has checked that memory tagging is enabled
3102 /// and has packed the tag data.
3103 ///
3104 /// \param[in] addr
3105 /// Start of address range to write memory tags for.
3106 ///
3107 /// \param[in] len
3108 /// Length of the memory range to write tags for (in bytes).
3109 ///
3110 /// \param[in] type
3111 /// Type of tags to read (get this from a MemoryTagManager)
3112 ///
3113 /// \param[in] tags
3114 /// Packed tags to be written.
3115 ///
3116 /// \return
3117 /// Status telling you whether the write succeeded.
3118 virtual Status DoWriteMemoryTags(lldb::addr_t addr, size_t len, int32_t type,
3119 const std::vector<uint8_t> &tags) {
3121 "{0} does not support writing memory tags", GetPluginName());
3122 }
3123
3124 // Type definitions
3125 typedef std::map<lldb::LanguageType, lldb::LanguageRuntimeSP>
3127
3129 bool (*callback)(void *);
3130 void *baton;
3132 void *in_baton)
3133 : callback(in_callback), baton(in_baton) {}
3135 return callback == rhs.callback && baton == rhs.baton;
3136 }
3137 };
3138
3139 // Member variables
3140 std::weak_ptr<Target> m_target_wp; ///< The target that owns this process.
3144 m_private_state; // The actual state of our process
3145 Broadcaster m_private_state_broadcaster; // This broadcaster feeds state
3146 // changed events into the private
3147 // state thread's listener.
3149 // broadcaster, used to
3150 // pause, resume & stop the
3151 // private state thread.
3152 lldb::ListenerSP m_private_state_listener_sp; // This is the listener for the
3153 // private state thread.
3154 HostThread m_private_state_thread; ///< Thread ID for the thread that watches
3155 ///internal state events
3156 ProcessModID m_mod_id; ///< Tracks the state of the process over stops and
3157 ///other alterations.
3158 uint32_t m_process_unique_id; ///< Each lldb_private::Process class that is
3159 ///created gets a unique integer ID that
3160 ///increments with each new instance
3161 uint32_t m_thread_index_id; ///< Each thread is created with a 1 based index
3162 ///that won't get re-used.
3163 std::map<uint64_t, uint32_t> m_thread_id_to_index_id_map;
3164 int m_exit_status; ///< The exit status of the process, or -1 if not set.
3165 std::string m_exit_string; ///< A textual description of why a process exited.
3166 std::mutex m_exit_status_mutex; ///< Mutex so m_exit_status m_exit_string can
3167 ///be safely accessed from multiple threads
3168 std::recursive_mutex m_thread_mutex;
3169 ThreadList m_thread_list_real; ///< The threads for this process as are known
3170 ///to the protocol we are debugging with
3171 ThreadList m_thread_list; ///< The threads for this process as the user will
3172 ///see them. This is usually the same as
3173 ///< m_thread_list_real, but might be different if there is an OS plug-in
3174 ///creating memory threads
3175 ThreadPlanStackMap m_thread_plans; ///< This is the list of thread plans for
3176 /// threads in m_thread_list, as well as
3177 /// threads we knew existed, but haven't
3178 /// determined that they have died yet.
3180 m_extended_thread_list; ///< Constituent for extended threads that may be
3181 /// generated, cleared on natural stops
3182 lldb::RunDirection m_base_direction; ///< ThreadPlanBase run direction
3183 uint32_t m_extended_thread_stop_id; ///< The natural stop id when
3184 ///extended_thread_list was last updated
3185 QueueList
3186 m_queue_list; ///< The list of libdispatch queues at a given stop point
3187 uint32_t m_queue_list_stop_id; ///< The natural stop id when queue list was
3188 ///last fetched
3190 m_watchpoint_resource_list; ///< Watchpoint resources currently in use.
3191 std::vector<Notifications> m_notifications; ///< The list of notifications
3192 ///that this process can deliver.
3193 std::vector<lldb::addr_t> m_image_tokens;
3195 m_breakpoint_site_list; ///< This is the list of breakpoint
3196 /// locations we intend to insert in
3197 /// the target.
3201 /// by the expression
3202 /// parser to validate
3203 /// data that
3204 /// expressions use.
3208 m_unix_signals_sp; /// This is the current signal set for this process.
3213 std::recursive_mutex m_stdio_communication_mutex;
3214 bool m_stdin_forward; /// Remember if stdin must be forwarded to remote debug
3215 /// server
3216 std::string m_stdout_data;
3217 std::string m_stderr_data;
3218 std::recursive_mutex m_profile_data_comm_mutex;
3219 std::vector<std::string> m_profile_data;
3223 bool m_should_detach; /// Should we detach if the process object goes away
3224 /// with an explicit call to Kill or Detach?
3226 std::recursive_mutex m_language_runtimes_mutex;
3228 std::unique_ptr<NextEventAction> m_next_event_action_up;
3229 std::vector<PreResumeCallbackAndBaton> m_pre_resume_actions;
3233 bool m_resume_requested; // If m_currently_handling_event or
3234 // m_currently_handling_do_on_removals are true,
3235 // Resume will only request a resume, using this
3236 // flag to check.
3237
3238 lldb::tid_t m_interrupt_tid; /// The tid of the thread that issued the async
3239 /// interrupt, used by thread plan timeout. It
3240 /// can be LLDB_INVALID_THREAD_ID to indicate
3241 /// user level async interrupt.
3242
3243 /// This is set at the beginning of Process::Finalize() to stop functions
3244 /// from looking up or creating things during or after a finalize call.
3245 std::atomic<bool> m_finalizing;
3246 // When we are "Finalizing" we need to do some cleanup. But if the Finalize
3247 // call is coming in the Destructor, we can't do any actual work in the
3248 // process because that is likely to call "shared_from_this" which crashes
3249 // if run while destructing. We use this flag to determine that.
3250 std::atomic<bool> m_destructing;
3251
3252 /// Mask for code an data addresses.
3253 /// The default value LLDB_INVALID_ADDRESS_MASK means no mask has been set,
3254 /// and addresses values should not be modified.
3255 /// In these masks, the bits are set to 1 indicate bits that are not
3256 /// significant for addressing.
3257 /// The highmem masks are for targets where we may have different masks
3258 /// for low memory versus high memory addresses, and they will be left
3259 /// as LLDB_INVALID_ADDRESS_MASK normally, meaning the base masks
3260 /// should be applied to all addresses.
3261 /// @{
3266 /// @}
3267
3270 lldb::StateType m_last_broadcast_state; /// This helps with the Public event
3271 /// coalescing in
3272 /// ShouldBroadcastEvent.
3273 std::map<lldb::addr_t, lldb::addr_t> m_resolved_indirect_addresses;
3275 bool m_can_interpret_function_calls; // Some targets, e.g the OSX kernel,
3276 // don't support the ability to modify
3277 // the stack.
3279 llvm::StringMap<lldb::StructuredDataPluginSP> m_structured_data_plugin_map;
3280
3282
3283 std::unique_ptr<UtilityFunction> m_dlopen_utility_func_up;
3285
3286 /// Per process source file cache.
3288
3289 /// A repository for extra crash information, consulted in
3290 /// GetExtendedCrashInformation.
3292
3293 size_t RemoveBreakpointOpcodesFromBuffer(lldb::addr_t addr, size_t size,
3294 uint8_t *buf) const;
3295
3297
3298 void SetPublicState(lldb::StateType new_state, bool restarted);
3299
3300 void SetPrivateState(lldb::StateType state);
3301
3302 bool StartPrivateStateThread(bool is_secondary_thread = false);
3303
3305
3307
3309
3310private:
3311 // The starts up the private state thread that will watch for events from the
3312 // debugee. Pass true for is_secondary_thread in the case where you have to
3313 // temporarily spin up a secondary state thread to handle events from a hand-
3314 // called function on the primary private state thread.
3315
3316 lldb::thread_result_t RunPrivateStateThread(bool is_secondary_thread);
3317
3318protected:
3319 void HandlePrivateEvent(lldb::EventSP &event_sp);
3320
3322
3324 const Timeout<std::micro> &timeout);
3325
3326 // This waits for both the state change broadcaster, and the control
3327 // broadcaster. If control_only, it only waits for the control broadcaster.
3328
3329 bool GetEventsPrivate(lldb::EventSP &event_sp,
3330 const Timeout<std::micro> &timeout, bool control_only);
3331
3334 const Timeout<std::micro> &timeout);
3335
3336 size_t WriteMemoryPrivate(lldb::addr_t addr, const void *buf, size_t size,
3337 Status &error);
3338
3339 void AppendSTDOUT(const char *s, size_t len);
3340
3341 void AppendSTDERR(const char *s, size_t len);
3342
3343 void BroadcastAsyncProfileData(const std::string &one_profile_data);
3344
3345 static void STDIOReadThreadBytesReceived(void *baton, const void *src,
3346 size_t src_len);
3347
3348 bool PushProcessIOHandler();
3349
3350 bool PopProcessIOHandler();
3351
3353
3355 std::lock_guard<std::mutex> guard(m_process_input_reader_mutex);
3356 return static_cast<bool>(m_process_input_reader);
3357 }
3358
3360
3362
3363 void LoadOperatingSystemPlugin(bool flush);
3364
3366
3367private:
3368 Status DestroyImpl(bool force_kill);
3369
3370 /// This is the part of the event handling that for a process event. It
3371 /// decides what to do with the event and returns true if the event needs to
3372 /// be propagated to the user, and false otherwise. If the event is not
3373 /// propagated, this call will most likely set the target to executing
3374 /// again. There is only one place where this call should be called,
3375 /// HandlePrivateEvent. Don't call it from anywhere else...
3376 ///
3377 /// \param[in] event_ptr
3378 /// This is the event we are handling.
3379 ///
3380 /// \return
3381 /// Returns \b true if the event should be reported to the
3382 /// user, \b false otherwise.
3383 bool ShouldBroadcastEvent(Event *event_ptr);
3384
3385 void ControlPrivateStateThread(uint32_t signal);
3386
3388 lldb::EventSP &event_sp);
3389
3390 lldb::EventSP CreateEventFromProcessState(uint32_t event_type);
3391
3392 Process(const Process &) = delete;
3393 const Process &operator=(const Process &) = delete;
3394};
3395
3396/// RAII guard that should be acquired when an utility function is called within
3397/// a given process.
3400
3401public:
3403 if (m_process)
3404 m_process->SetRunningUtilityFunction(true);
3405 }
3407 if (m_process)
3408 m_process->SetRunningUtilityFunction(false);
3409 }
3410};
3411
3412} // namespace lldb_private
3413
3414#endif // LLDB_TARGET_PROCESS_H
static llvm::raw_ostream & error(Stream &strm)
A section + offset based address range class.
A section + offset based address class.
Definition Address.h:62
A class which holds the metadata from a remote stub/corefile note about how many bits are used for ad...
An architecture specification class.
Definition ArchSpec.h:31
void Clear()
Clears the object state.
Definition ArchSpec.cpp:538
A command line argument class.
Definition Args.h:33
Class that manages the actual breakpoint that will be inserted into the running program.
uint32_t AddListener(const lldb::ListenerSP &listener_sp, uint32_t event_mask)
Listen for any events specified by event_mask.
Broadcaster(lldb::BroadcasterManagerSP manager_sp, std::string name)
Construct with a broadcaster with a name.
An data extractor class.
A class to manage flag bits.
Definition Debugger.h:80
Encapsulates dynamic check functions used by expressions.
A plug-in interface definition class for dynamic loaders.
"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 utility class.
Definition FileSpec.h:57
Class used by the Process to hold a list of its JITLoaders.
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
A plug-in interface definition class for halted OS helpers.
A plug-in interface definition class for debug platform that includes many platform abilities such as...
Definition Platform.h:77
virtual llvm::StringRef GetPluginName()=0
A C++ wrapper class for providing threaded access to a value of type T.
Definition Predicate.h:42
void SetDetachOnError(bool enable)
Definition Process.h:186
bool ProcessInfoSpecified() const
Definition Process.h:174
ProcessAttachInfo(const ProcessLaunchInfo &launch_info)
Definition Process.h:130
void SetContinueOnceAttached(bool b)
Definition Process.h:151
uint32_t GetResumeCount() const
Definition Process.h:153
void SetResumeCount(uint32_t c)
Definition Process.h:155
void SetProcessPluginName(llvm::StringRef plugin)
Definition Process.h:161
bool GetContinueOnceAttached() const
Definition Process.h:149
lldb::ListenerSP GetListenerForProcess(Debugger &debugger)
Definition Process.cpp:2973
llvm::StringRef GetProcessPluginName() const
Definition Process.h:157
lldb::pid_t GetProcessID() const
Definition ProcessInfo.h:68
FileSpec & GetExecutableFile()
Definition ProcessInfo.h:43
lldb::pid_t GetParentProcessID() const
llvm::StringRef GetProcessPluginName() const
void SetRunningUserExpression(bool on)
Definition Process.h:286
lldb::EventSP GetStopEventForStopID(uint32_t stop_id) const
Definition Process.h:308
const ProcessModID & operator=(const ProcessModID &rhs)
Definition Process.h:221
uint32_t GetMemoryID() const
Definition Process.h:252
friend bool operator==(const ProcessModID &lhs, const ProcessModID &rhs)
Definition Process.h:337
uint32_t m_running_utility_function
Definition Process.h:333
ProcessModID(const ProcessModID &rhs)
Definition Process.h:218
void SetStopEventForLastNaturalStopID(lldb::EventSP event_sp)
Definition Process.h:304
uint32_t m_running_user_expression
Definition Process.h:332
uint32_t GetStopID() const
Definition Process.h:250
bool IsRunningUtilityFunction() const
Definition Process.h:246
uint32_t m_last_natural_stop_id
Definition Process.h:328
bool IsLastResumeForUserExpression() const
Definition Process.h:270
uint32_t GetResumeID() const
Definition Process.h:253
bool IsRunningExpression() const
Definition Process.h:279
uint32_t m_last_user_expression_resume
Definition Process.h:331
uint32_t GetLastNaturalStopID() const
Definition Process.h:251
lldb::EventSP m_last_natural_stop_event
Definition Process.h:334
uint32_t GetLastUserExpressionResumeID() const
Definition Process.h:254
bool MemoryIDEqual(const ProcessModID &compare) const
Definition Process.h:258
void Dump(Stream &stream) const
Definition Process.h:314
bool StopIDEqual(const ProcessModID &compare) const
Definition Process.h:262
void SetRunningUtilityFunction(bool on)
Definition Process.h:293
bool GetSteppingRunsAllThreads() const
Definition Process.cpp:338
void SetStopOnSharedLibraryEvents(bool stop)
Definition Process.cpp:269
std::unique_ptr< ProcessExperimentalProperties > m_experimental_properties_up
Definition Process.h:119
FollowForkMode GetFollowForkMode() const
Definition Process.cpp:368
uint32_t GetVirtualAddressableBits() const
Definition Process.cpp:214
void SetIgnoreBreakpointsInExpressions(bool ignore)
Definition Process.cpp:247
bool GetUnwindOnErrorInExpressions() const
Definition Process.cpp:252
std::chrono::seconds GetInterruptTimeout() const
Definition Process.cpp:331
bool GetDisableLangRuntimeUnwindPlans() const
Definition Process.cpp:274
void SetDetachKeepsStopped(bool keep_stopped)
Definition Process.cpp:301
void SetDisableLangRuntimeUnwindPlans(bool disable)
Definition Process.cpp:280
std::chrono::seconds GetUtilityExpressionTimeout() const
Definition Process.cpp:324
void SetVirtualAddressableBits(uint32_t bits)
Definition Process.cpp:220
bool GetStopOnSharedLibraryEvents() const
Definition Process.cpp:263
void SetHighmemVirtualAddressableBits(uint32_t bits)
Definition Process.cpp:231
void SetOSPluginReportsAllThreads(bool does_report)
Definition Process.cpp:358
void SetUnwindOnErrorInExpressions(bool ignore)
Definition Process.cpp:258
FileSpec GetPythonOSPluginPath() const
Definition Process.cpp:209
void SetPythonOSPluginPath(const FileSpec &file)
Definition Process.cpp:236
void SetExtraStartupCommands(const Args &args)
Definition Process.cpp:204
bool GetOSPluginReportsAllThreads() const
Definition Process.cpp:344
bool GetWarningsUnsupportedLanguage() const
Definition Process.cpp:312
uint32_t GetHighmemVirtualAddressableBits() const
Definition Process.cpp:225
bool GetIgnoreBreakpointsInExpressions() const
Definition Process.cpp:241
uint64_t GetMemoryCacheLineSize() const
Definition Process.cpp:191
ProcessProperties(lldb_private::Process *process)
Definition Process.cpp:152
A class used to prevent the process from starting while other threads are accessing its data,...
EventActionResult HandleBeingInterrupted() override
Definition Process.cpp:2965
EventActionResult PerformAction(lldb::EventSP &event_sp) override
Definition Process.cpp:2908
AttachCompletionHandler(Process *process, uint32_t exec_count)
Definition Process.cpp:2897
virtual EventActionResult HandleBeingInterrupted()=0
virtual const char * GetExitString()=0
virtual EventActionResult PerformAction(lldb::EventSP &event_sp)=0
static bool GetRestartedFromEvent(const Event *event_ptr)
Definition Process.cpp:4463
virtual bool ShouldStop(Event *event_ptr, bool &found_valid_stopinfo)
Definition Process.cpp:4236
static void AddRestartedReason(Event *event_ptr, const char *reason)
Definition Process.cpp:4500
void SetInterrupted(bool new_value)
Definition Process.h:487
lldb::ProcessSP GetProcessSP() const
Definition Process.h:435
std::vector< std::string > m_restarted_reasons
Definition Process.h:495
void SetRestarted(bool new_value)
Definition Process.h:485
static void SetRestartedInEvent(Event *event_ptr, bool new_value)
Definition Process.cpp:4471
const ProcessEventData & operator=(const ProcessEventData &)=delete
static lldb::ProcessSP GetProcessFromEvent(const Event *event_ptr)
Definition Process.cpp:4447
static void SetInterruptedInEvent(Event *event_ptr, bool new_value)
Definition Process.cpp:4517
bool ForwardEventToPendingListeners(Event *event_ptr) override
This will be queried for a Broadcaster with a primary and some secondary listeners after the primary ...
Definition Process.cpp:4340
ProcessEventData(const ProcessEventData &)=delete
llvm::StringRef GetFlavor() const override
Definition Process.cpp:4232
static bool GetInterruptedFromEvent(const Event *event_ptr)
Definition Process.cpp:4508
const char * GetRestartedReasonAtIndex(size_t idx)
Definition Process.h:442
static lldb::StateType GetStateFromEvent(const Event *event_ptr)
Definition Process.cpp:4455
lldb::StateType GetState() const
Definition Process.h:437
static const Process::ProcessEventData * GetEventDataFromEvent(const Event *event_ptr)
Definition Process.cpp:4436
static llvm::StringRef GetFlavorString()
Definition Process.cpp:4228
void DoOnRemoval(Event *event_ptr) override
Definition Process.cpp:4351
void AddRestartedReason(const char *reason)
Definition Process.h:489
void Dump(Stream *s) const override
Definition Process.cpp:4423
ProcessEventHijacker(Process &process, lldb::ListenerSP listener_sp)
Definition Process.h:2379
A plug-in interface definition class for debugging a process.
Definition Process.h:354
virtual Status EnableBreakpointSite(BreakpointSite *bp_site)
Definition Process.h:2207
Status WillAttachToProcessWithName(const char *process_name, bool wait_for_launch)
Called before attaching to a process.
Definition Process.cpp:2988
virtual llvm::Expected< TraceSupportedResponse > TraceSupported()
Get the processor tracing type supported for this process.
Definition Process.cpp:6429
lldb::IOHandlerSP m_process_input_reader
Definition Process.h:3210
friend class ProcessProperties
Definition Process.h:2391
UtilityFunction * GetLoadImageUtilityFunction(Platform *platform, llvm::function_ref< std::unique_ptr< UtilityFunction >()> factory)
Get the cached UtilityFunction that assists in loading binary images into the process.
Definition Process.cpp:6419
virtual void DidVForkDone()
Called after reported vfork completion.
Definition Process.h:1053
virtual void DidFork(lldb::pid_t child_pid, lldb::tid_t child_tid)
Called after a reported fork.
Definition Process.h:1047
virtual Status DoSignal(int signal)
Sends a process a UNIX signal signal.
Definition Process.h:1214
virtual Status WillResume()
Called before resuming to a process.
Definition Process.h:1101
std::mutex m_process_input_reader_mutex
Definition Process.h:3211
lldb::addr_t m_code_address_mask
Mask for code an data addresses.
Definition Process.h:3262
StopPointSiteList< lldb_private::BreakpointSite > & GetBreakpointSiteList()
Definition Process.cpp:1560
std::vector< lldb::addr_t > m_image_tokens
Definition Process.h:3193
bool PrivateStateThreadIsValid() const
Definition Process.h:3018
virtual Status DoHalt(bool &caused_stop)
Halts a running process.
Definition Process.h:1161
virtual void DidLaunch()
Called after launching a process.
Definition Process.h:1093
virtual Status DisableSoftwareBreakpoint(BreakpointSite *bp_site)
Definition Process.cpp:1833
lldb::pid_t GetID() const
Returns the pid of the process or LLDB_INVALID_PROCESS_ID if there is no known pid.
Definition Process.h:553
lldb::EventSP GetStopEventForStopID(uint32_t stop_id) const
Definition Process.h:1484
lldb::break_id_t CreateBreakpointSite(const lldb::BreakpointLocationSP &owner, bool use_hardware)
Definition Process.cpp:1613
virtual Status WillSignal()
Called before sending a signal to a process.
Definition Process.h:1208
void ResetImageToken(size_t token)
Definition Process.cpp:6200
lldb::JITLoaderListUP m_jit_loaders_up
Definition Process.h:3199
lldb::addr_t CallocateMemory(size_t size, uint32_t permissions, Status &error)
The public interface to allocating memory in the process, this also clears the allocated memory.
Definition Process.cpp:2490
void SetNextEventAction(Process::NextEventAction *next_event_action)
Definition Process.h:2995
Status Destroy(bool force_kill)
Kills the process and shuts down all threads that were spawned to track and monitor the process.
Definition Process.cpp:3558
virtual Status WillDetach()
Called before detaching from a process.
Definition Process.h:1178
virtual Status DoLaunch(Module *exe_module, ProcessLaunchInfo &launch_info)
Launch a new process.
Definition Process.h:1085
virtual size_t PutSTDIN(const char *buf, size_t buf_size, Status &error)
Puts data into this process's STDIN.
Definition Process.h:2184
StopPointSiteList< lldb_private::BreakpointSite > m_breakpoint_site_list
This is the list of breakpoint locations we intend to insert in the target.
Definition Process.h:3195
void ControlPrivateStateThread(uint32_t signal)
Definition Process.cpp:3891
ThreadList & GetThreadList()
Definition Process.h:2272
void SetAddressableBitMasks(AddressableBits bit_masks)
Definition Process.cpp:6846
virtual DataExtractor GetAuxvData()
Definition Process.cpp:2877
virtual std::optional< uint32_t > GetWatchpointSlotCount()
Get the number of watchpoints supported by this target.
Definition Process.h:1998
void SetShadowListener(lldb::ListenerSP shadow_listener_sp)
The "ShadowListener" for a process is just an ordinary Listener that listens for all the Process even...
Definition Process.h:640
Process(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp)
Construct with a shared pointer to a target, and the Process listener.
Definition Process.cpp:427
lldb::ExpressionResults RunThreadPlan(ExecutionContext &exe_ctx, lldb::ThreadPlanSP &thread_plan_sp, const EvaluateExpressionOptions &options, DiagnosticManager &diagnostic_manager)
Definition Process.cpp:5013
void PrintWarningUnsupportedLanguage(const SymbolContext &sc)
Print a user-visible warning about a function written in a language that this version of LLDB doesn't...
Definition Process.cpp:6125
lldb::StateType GetPrivateState()
Definition Process.cpp:1402
Status LaunchPrivate(ProcessLaunchInfo &launch_info, lldb::StateType &state, lldb::EventSP &event_sp)
Definition Process.cpp:2684
std::vector< std::string > m_profile_data
Definition Process.h:3219
bool m_can_interpret_function_calls
Definition Process.h:3275
Status Resume()
Resumes all of a process's threads as configured using the Thread run control functions.
Definition Process.cpp:1332
void PruneThreadPlans()
Prune ThreadPlanStacks for all unreported threads.
Definition Process.cpp:1229
void SetUnixSignals(lldb::UnixSignalsSP &&signals_sp)
Definition Process.cpp:3649
virtual void DidExit()
Definition Process.h:1420
std::string m_stdout_data
Remember if stdin must be forwarded to remote debug server.
Definition Process.h:3216
bool RemoveInvalidMemoryRange(const LoadRange &region)
Definition Process.cpp:5880
uint32_t GetNextThreadIndexID(uint64_t thread_id)
Definition Process.cpp:1267
Status PrivateResume()
The "private" side of resuming a process.
Definition Process.cpp:3284
void SetDynamicCheckers(DynamicCheckerFunctions *dynamic_checkers)
Definition Process.cpp:1556
QueueList::QueueIterable Queues()
Definition Process.h:2308
void SendAsyncInterrupt(Thread *thread=nullptr)
Send an async interrupt request.
Definition Process.cpp:3941
uint32_t GetResumeID() const
Definition Process.h:1474
void AddInvalidMemoryRegion(const LoadRange &region)
Definition Process.cpp:5876
virtual void ModulesDidLoad(ModuleList &module_list)
Definition Process.cpp:6083
virtual bool WarnBeforeDetach() const
Before lldb detaches from a process, it warns the user that they are about to lose their debug sessio...
Definition Process.h:1534
InstrumentationRuntimeCollection m_instrumentation_runtimes
Definition Process.h:3227
std::atomic< bool > m_destructing
Definition Process.h:3250
virtual Status DoGetMemoryRegionInfo(lldb::addr_t load_addr, MemoryRegionInfo &range_info)
DoGetMemoryRegionInfo is called by GetMemoryRegionInfo after it has removed non address bits from loa...
Definition Process.h:2918
@ eBroadcastInternalStateControlResume
Definition Process.h:383
@ eBroadcastInternalStateControlStop
Definition Process.h:381
@ eBroadcastInternalStateControlPause
Definition Process.h:382
int GetExitStatus()
Get the exit status for a process.
Definition Process.cpp:1008
OperatingSystem * GetOperatingSystem()
Definition Process.h:2417
Status WillAttachToProcessWithID(lldb::pid_t pid)
Called before attaching to a process.
Definition Process.cpp:2984
virtual Status DoDetach(bool keep_stopped)
Detaches from a running or stopped process.
Definition Process.h:1185
std::unique_ptr< UtilityFunction > m_dlopen_utility_func_up
Definition Process.h:3283
void SetRunningUtilityFunction(bool on)
Definition Process.cpp:1475
void DisableAllBreakpointSites()
Definition Process.cpp:1569
uint32_t m_process_unique_id
Each lldb_private::Process class that is created gets a unique integer ID that increments with each n...
Definition Process.h:3158
int64_t ReadSignedIntegerFromMemory(lldb::addr_t load_addr, size_t byte_size, int64_t fail_value, Status &error)
Definition Process.cpp:2292
Address AdvanceAddressToNextBranchInstruction(Address default_stop_addr, AddressRange range_bounds)
Find the next branch instruction to set a breakpoint on.
Definition Process.cpp:6206
virtual bool GetLoadAddressPermissions(lldb::addr_t load_addr, uint32_t &permissions)
Attempt to get the attributes for a region of memory in the process.
Definition Process.cpp:2593
static bool HandleProcessStateChangedEvent(const lldb::EventSP &event_sp, Stream *stream, SelectMostRelevant select_most_relevant, bool &pop_process_io_handler)
Centralize the code that handles and prints descriptions for process state changes.
Definition Process.cpp:733
virtual size_t GetAsyncProfileData(char *buf, size_t buf_size, Status &error)
Get any available profile data.
Definition Process.cpp:4606
lldb::addr_t FixDataAddress(lldb::addr_t pc)
Definition Process.cpp:6005
lldb::addr_t AllocateMemory(size_t size, uint32_t permissions, Status &error)
The public interface to allocating memory in the process.
Definition Process.cpp:2479
std::unique_ptr< NextEventAction > m_next_event_action_up
Definition Process.h:3228
void SetHighmemDataAddressMask(lldb::addr_t data_address_mask)
Definition Process.cpp:5992
bool PruneThreadPlansForTID(lldb::tid_t tid)
Prune ThreadPlanStacks for unreported threads.
Definition Process.cpp:1225
virtual void DidDetach()
Called after detaching from a process.
Definition Process.h:1195
std::function< IterationAction(lldb_private::Status &error, lldb::addr_t bytes_addr, const void *bytes, lldb::offset_t bytes_size)> ReadMemoryChunkCallback
Definition Process.h:1633
HostThread m_private_state_thread
Thread ID for the thread that watches internal state events.
Definition Process.h:3154
Status EnableBreakpointSiteByID(lldb::user_id_t break_id)
Definition Process.cpp:1599
ProcessModID GetModID() const
Get the Modification ID of the process.
Definition Process.h:1468
lldb::RunDirection GetBaseDirection() const
Get the base run direction for the process.
Definition Process.h:2774
size_t ReadMemoryFromInferior(lldb::addr_t vm_addr, void *buf, size_t size, Status &error)
Read of memory from a process.
Definition Process.cpp:2208
size_t ReadScalarIntegerFromMemory(lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Status &error)
Definition Process.cpp:2438
virtual Status Launch(ProcessLaunchInfo &launch_info)
Launch a new process.
Definition Process.cpp:2652
DynamicCheckerFunctions * GetDynamicCheckers()
Definition Process.h:2427
std::mutex m_run_thread_plan_lock
Definition Process.h:3278
static void SettingsInitialize()
Definition Process.cpp:4876
virtual StructuredData::DictionarySP GetMetadata()
Fetch process defined metadata.
Definition Process.h:2630
virtual void DumpPluginHistory(Stream &s)
The underlying plugin might store the low-level communication history for this session.
Definition Process.h:606
static constexpr llvm::StringRef AttachSynchronousHijackListenerName
Definition Process.h:399
void BroadcastStructuredData(const StructuredData::ObjectSP &object_sp, const lldb::StructuredDataPluginSP &plugin_sp)
Broadcasts the given structured data object from the given plugin.
Definition Process.cpp:4590
void Flush()
Flush all data in the process.
Definition Process.cpp:5933
bool m_clear_thread_plans_on_stop
Definition Process.h:3268
lldb::ProcessSP CalculateProcess() override
Definition Process.h:2527
ProcessRunLock m_public_run_lock
Definition Process.h:3230
size_t ReadCStringFromMemory(lldb::addr_t vm_addr, char *cstr, size_t cstr_max_len, Status &error)
Read a NULL terminated C string from memory.
Definition Process.cpp:2162
void ResumePrivateStateThread()
Definition Process.cpp:3876
void MapSupportedStructuredDataPlugins(const StructuredData::Array &supported_type_names)
Loads any plugins associated with asynchronous structured data and maps the relevant supported type n...
Definition Process.cpp:6314
bool GetEventsPrivate(lldb::EventSP &event_sp, const Timeout< std::micro > &timeout, bool control_only)
Definition Process.cpp:991
lldb::ABISP m_abi_sp
This is the current signal set for this process.
Definition Process.h:3209
virtual void DidSignal()
Called after sending a signal to a process.
Definition Process.h:1232
virtual SystemRuntime * GetSystemRuntime()
Get the system runtime plug-in for this process.
Definition Process.cpp:2891
std::map< uint64_t, uint32_t > m_thread_id_to_index_id_map
Definition Process.h:3163
bool DumpThreadPlansForTID(Stream &strm, lldb::tid_t tid, lldb::DescriptionLevel desc_level, bool internal, bool condense_trivial, bool skip_unreported_plans)
Dump the thread plans associated with thread with tid.
Definition Process.cpp:1233
lldb::ListenerSP m_private_state_listener_sp
Definition Process.h:3152
uint32_t m_extended_thread_stop_id
The natural stop id when extended_thread_list was last updated.
Definition Process.h:3183
bool PreResumeActionCallback(void *)
Definition Process.h:2556
lldb::RunDirection m_base_direction
ThreadPlanBase run direction.
Definition Process.h:3182
Range< lldb::addr_t, lldb::addr_t > LoadRange
Definition Process.h:386
static constexpr llvm::StringRef ResumeSynchronousHijackListenerName
Definition Process.h:403
bool WritePointerToMemory(lldb::addr_t vm_addr, lldb::addr_t ptr_value, Status &error)
Definition Process.cpp:2311
QueueList m_queue_list
The list of libdispatch queues at a given stop point.
Definition Process.h:3186
void ClearPreResumeAction(PreResumeActionCallback callback, void *baton)
Definition Process.cpp:5904
virtual Status WillDestroy()
Definition Process.h:1220
lldb::ThreadSP CreateOSPluginThread(lldb::tid_t tid, lldb::addr_t context)
Definition Process.cpp:1260
std::vector< PreResumeCallbackAndBaton > m_pre_resume_actions
Definition Process.h:3229
void SetCanJIT(bool can_jit)
Sets whether executing JIT-compiled code in this process is possible.
Definition Process.cpp:2529
lldb::StateType GetStateChangedEventsPrivate(lldb::EventSP &event_sp, const Timeout< std::micro > &timeout)
Definition Process.cpp:973
void LoadOperatingSystemPlugin(bool flush)
Definition Process.cpp:2643
lldb::StructuredDataPluginSP GetStructuredDataPlugin(llvm::StringRef type_name) const
Returns the StructuredDataPlugin associated with a given type name, if there is one.
Definition Process.cpp:4598
lldb::DynamicLoaderUP m_dyld_up
Definition Process.h:3198
ThreadList & GetExtendedThreadList()
Definition Process.h:2283
void ResetExtendedCrashInfoDict()
Definition Process.h:2640
AddressRanges FindRangesInMemory(const uint8_t *buf, uint64_t size, const AddressRanges &ranges, size_t alignment, size_t max_matches, Status &error)
Definition Process.cpp:2048
virtual bool GetModuleSpec(const FileSpec &module_file_spec, const ArchSpec &arch, ModuleSpec &module_spec)
Try to fetch the module specification for a module with the given file name and architecture.
Definition Process.cpp:6183
virtual lldb_private::StructuredData::ObjectSP GetLoadedDynamicLibrariesInfos(const std::vector< lldb::addr_t > &load_addresses)
Definition Process.h:1361
virtual size_t DoWriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size, Status &error)
Actually do the writing of memory to a process.
Definition Process.h:1738
virtual llvm::Expected< std::vector< uint8_t > > TraceGetBinaryData(const TraceGetBinaryDataRequest &request)
Get binary data given a trace technology and a data identifier.
Definition Process.h:2851
virtual Status WriteObjectFile(std::vector< ObjectFile::LoadableData > entries)
Definition Process.cpp:2468
std::recursive_mutex m_stdio_communication_mutex
Definition Process.h:3213
static lldb::ProcessSP FindPlugin(lldb::TargetSP target_sp, llvm::StringRef plugin_name, lldb::ListenerSP listener_sp, const FileSpec *crash_file_path, bool can_connect)
Find a Process plug-in that can debug module using the currently selected architecture.
Definition Process.cpp:381
std::map< lldb::LanguageType, lldb::LanguageRuntimeSP > LanguageRuntimeCollection
Definition Process.h:3126
virtual bool SupportsReverseDirection()
Reports whether this process supports reverse execution.
Definition Process.h:1108
StopPointSiteList< lldb_private::WatchpointResource > m_watchpoint_resource_list
Watchpoint resources currently in use.
Definition Process.h:3190
Status DisableBreakpointSiteByID(lldb::user_id_t break_id)
Definition Process.cpp:1585
llvm::Expected< const MemoryTagManager * > GetMemoryTagManager()
If this architecture and process supports memory tagging, return a tag manager that can be used to ma...
Definition Process.cpp:6494
~Process() override
Destructor.
Definition Process.cpp:519
virtual llvm::Expected< LoadedModuleInfoList > GetLoadedModuleList()
Query remote GDBServer for a detailed loaded library list.
Definition Process.h:711
virtual Status DoWriteMemoryTags(lldb::addr_t addr, size_t len, int32_t type, const std::vector< uint8_t > &tags)
Does the final operation to write memory tags.
Definition Process.h:3118
friend class StopInfo
Definition Process.h:359
std::recursive_mutex m_profile_data_comm_mutex
Definition Process.h:3218
lldb::InstrumentationRuntimeSP GetInstrumentationRuntime(lldb::InstrumentationRuntimeType type)
Definition Process.cpp:6174
ProcessRunLock::ProcessRunLocker StopLocker
Definition Process.h:393
Status ResumeSynchronous(Stream *stream)
Resume a process, and wait for it to stop.
Definition Process.cpp:1349
virtual Status SendEventData(const char *data)
Definition Process.h:2572
lldb::addr_t FixAnyAddress(lldb::addr_t pc)
Use this method when you do not know, or do not care what kind of address you are fixing.
Definition Process.cpp:6011
lldb::thread_result_t RunPrivateStateThread(bool is_secondary_thread)
Definition Process.cpp:4078
virtual Status DoWillLaunch(Module *module)
Called before launching to a process.
Definition Process.h:1066
virtual Status ConnectRemote(llvm::StringRef remote_url)
Attach to a remote system via a URL.
Definition Process.cpp:3242
void AppendSTDOUT(const char *s, size_t len)
Definition Process.cpp:4569
llvm::StringMap< lldb::StructuredDataPluginSP > m_structured_data_plugin_map
Definition Process.h:3279
SourceManager::SourceFileCache m_source_file_cache
Per process source file cache.
Definition Process.h:3287
virtual Status DisableBreakpointSite(BreakpointSite *bp_site)
Definition Process.h:2212
size_t GetThreadStatus(Stream &ostrm, bool only_threads_with_stop_reason, uint32_t start_frame, uint32_t num_frames, uint32_t num_frames_with_source, bool stop_format)
Definition Process.cpp:5830
void CalculateExecutionContext(ExecutionContext &exe_ctx) override
Reconstruct the object's execution context into sc.
Definition Process.cpp:4537
virtual size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, Status &error)
Read of memory from a process.
Definition Process.cpp:1930
Event * PeekAtStateChangedEvents()
Definition Process.cpp:953
std::vector< Notifications > m_notifications
The list of notifications that this process can deliver.
Definition Process.h:3191
bool HasAssignedIndexIDToThread(uint64_t sb_thread_id)
Definition Process.cpp:1271
ThreadSafeValue< lldb::StateType > m_private_state
Definition Process.h:3144
size_t AddImageToken(lldb::addr_t image_ptr)
Definition Process.cpp:6189
virtual void DoFindInMemory(lldb::addr_t start_addr, lldb::addr_t end_addr, const uint8_t *buf, size_t size, AddressRanges &matches, size_t alignment, size_t max_matches)
Definition Process.cpp:2017
virtual bool DestroyRequiresHalt()
Definition Process.h:1226
lldb::EventSP CreateEventFromProcessState(uint32_t event_type)
Definition Process.cpp:4563
StructuredData::DictionarySP m_crash_info_dict_sp
A repository for extra crash information, consulted in GetExtendedCrashInformation.
Definition Process.h:3291
Status CalculateCoreFileSaveRanges(const SaveCoreOptions &core_options, CoreFileMemoryRanges &ranges)
Helper function for Process::SaveCore(...) that calculates the address ranges that should be saved.
Definition Process.cpp:6777
lldb::ThreadSP CalculateThread() override
Definition Process.h:2529
lldb::TargetSP CalculateTarget() override
Definition Process.cpp:4535
void SetHighmemCodeAddressMask(lldb::addr_t code_address_mask)
Definition Process.cpp:5985
virtual lldb_private::StructuredData::ObjectSP GetSharedCacheInfo()
Definition Process.h:1372
virtual lldb_private::StructuredData::ObjectSP GetLoadedDynamicLibrariesInfos(lldb::addr_t image_list_address, lldb::addr_t image_count)
Retrieve the list of shared libraries that are loaded for this process This method is used on pre-mac...
Definition Process.h:1347
lldb::ByteOrder GetByteOrder() const
Definition Process.cpp:3659
Status Detach(bool keep_stopped)
Detaches from a running or stopped process.
Definition Process.cpp:3506
virtual void DidVFork(lldb::pid_t child_pid, lldb::tid_t child_tid)
Called after a reported vfork.
Definition Process.h:1050
void UpdateThreadListIfNeeded()
Definition Process.cpp:1134
static constexpr llvm::StringRef LaunchSynchronousHijackListenerName
Definition Process.h:401
virtual llvm::Expected< std::vector< lldb::addr_t > > ReadMemoryTags(lldb::addr_t addr, size_t len)
Read memory tags for the range addr to addr+len.
Definition Process.cpp:6513
bool IsValid() const
Return whether this object is valid (i.e.
Definition Process.h:588
virtual void DidResume()
Called after resuming a process.
Definition Process.h:1136
virtual void DidExec()
Called after a process re-execs itself.
Definition Process.cpp:6017
void SetCodeAddressMask(lldb::addr_t code_address_mask)
Definition Process.cpp:5973
AllocatedMemoryCache m_allocated_memory_cache
Definition Process.h:3222
ThreadList::ThreadIterable Threads()
Definition Process.h:2285
virtual Status LoadCore()
Definition Process.cpp:2816
uint32_t GetUniqueID() const
Definition Process.h:560
std::mutex m_exit_status_mutex
Mutex so m_exit_status m_exit_string can be safely accessed from multiple threads.
Definition Process.h:3166
Status Signal(int signal)
Sends a process a UNIX signal signal.
Definition Process.cpp:3639
void SetDynamicLoader(lldb::DynamicLoaderUP dyld)
Definition Process.cpp:2873
virtual lldb_private::StructuredData::ObjectSP GetLoadedDynamicLibrariesInfos()
Definition Process.h:1355
ThreadPlanStackMap m_thread_plans
This is the list of thread plans for threads in m_thread_list, as well as threads we knew existed,...
Definition Process.h:3175
std::recursive_mutex m_thread_mutex
Definition Process.h:3168
virtual Status ConfigureStructuredData(llvm::StringRef type_name, const StructuredData::ObjectSP &config_sp)
Configure asynchronous structured data feature.
Definition Process.cpp:6306
virtual Status DoWillAttachToProcessWithName(const char *process_name, bool wait_for_launch)
Called before attaching to a process.
Definition Process.h:968
bool m_currently_handling_do_on_removals
Definition Process.h:3232
bool StartPrivateStateThread(bool is_secondary_thread=false)
Definition Process.cpp:3821
void HandlePrivateEvent(lldb::EventSP &event_sp)
Definition Process.cpp:3953
void BroadcastAsyncProfileData(const std::string &one_profile_data)
Definition Process.cpp:4583
lldb::StateType GetState()
Get accessor for the current process state.
Definition Process.cpp:1285
virtual Status DoWillAttachToProcessWithID(lldb::pid_t pid)
Called before attaching to a process.
Definition Process.h:951
ProcessRunLock & GetRunLock()
Definition Process.cpp:5914
virtual Status DoLoadCore()
Definition Process.h:631
Predicate< uint32_t > m_iohandler_sync
Definition Process.h:3220
virtual llvm::Error TraceStop(const TraceStopRequest &request)
Stop tracing a live process or its threads.
Definition Process.h:2826
LanguageRuntimeCollection m_language_runtimes
Should we detach if the process object goes away with an explicit call to Kill or Detach?
Definition Process.h:3225
virtual Status GetMemoryRegions(lldb_private::MemoryRegionInfos &region_list)
Obtain all the mapped memory regions within this process.
Definition Process.cpp:6269
size_t WriteMemoryPrivate(lldb::addr_t addr, const void *buf, size_t size, Status &error)
Definition Process.cpp:2323
virtual bool StopNoticingNewThreads()
Call this to turn off the stop & notice new threads mode.
Definition Process.h:2519
void GetStatus(Stream &ostrm)
Definition Process.cpp:5810
virtual llvm::VersionTuple GetHostMacCatalystVersion()
Definition Process.h:1260
void SetRunningUserExpression(bool on)
Definition Process.cpp:1471
enum lldb_private::Process::@120260360120067272255351105340035202127223005263 m_can_jit
bool IsPossibleDynamicValue(ValueObject &in_value)
Definition Process.cpp:1535
uint32_t GetIOHandlerID() const
Definition Process.h:2334
bool CurrentThreadPosesAsPrivateStateThread()
Definition Process.cpp:5925
Process(const Process &)=delete
const Target & GetTarget() const
Get the const target object pointer for this module.
Definition Process.h:1274
static bool SetProcessExitStatus(lldb::pid_t pid, bool exited, int signo, int status)
Static function that can be used with the host function Host::StartMonitoringChildProcess ().
Definition Process.cpp:1102
virtual FileSpec GetCoreFile() const
Provide a way to retrieve the core dump file that is loaded for debugging.
Definition Process.h:1523
virtual llvm::Error TraceStart(const llvm::json::Value &request)
Start tracing a process or its threads.
Definition Process.h:2814
void RemoveConstituentFromBreakpointSite(lldb::user_id_t site_id, lldb::user_id_t constituent_id, lldb::BreakpointSiteSP &bp_site_sp)
Definition Process.cpp:1703
lldb::addr_t FindInMemory(lldb::addr_t low, lldb::addr_t high, const uint8_t *buf, size_t size)
Find a pattern within a memory region.
Definition Process.cpp:3397
lldb::OperatingSystemUP m_os_up
Definition Process.h:3205
StructuredData::DictionarySP GetExtendedCrashInfoDict()
Fetch extended crash information held by the process.
Definition Process.h:2635
uint32_t GetLastNaturalStopID() const
Definition Process.h:1480
lldb::StateType WaitForProcessToStop(const Timeout< std::micro > &timeout, lldb::EventSP *event_sp_ptr=nullptr, bool wait_always=true, lldb::ListenerSP hijack_listener=lldb::ListenerSP(), Stream *stream=nullptr, bool use_run_lock=true, SelectMostRelevant select_most_relevant=DoNoSelectMostRelevantFrame)
Definition Process.cpp:665
virtual void ForceScriptedState(lldb::StateType state)
Definition Process.h:2734
virtual lldb::ThreadSP HandleThreadAsyncInterrupt(uint8_t signo, const std::string &description)
Handle thread specific async interrupt and return the original thread that requested the async interr...
Definition Process.h:2949
lldb::UnixSignalsSP m_unix_signals_sp
Definition Process.h:3208
bool StateChangedIsHijackedForSynchronousResume()
Definition Process.cpp:1393
const char * GetExitDescription()
Get a textual description of what the process exited.
Definition Process.cpp:1016
void SetPublicState(lldb::StateType new_state, bool restarted)
Definition Process.cpp:1292
lldb::tid_t m_interrupt_tid
Definition Process.h:3238
void SetDataAddressMask(lldb::addr_t data_address_mask)
Definition Process.cpp:5979
virtual Status DoConnectRemote(llvm::StringRef remote_url)
Attach to a remote system via a URL.
Definition Process.h:980
uint64_t ReadUnsignedIntegerFromMemory(lldb::addr_t load_addr, size_t byte_size, uint64_t fail_value, Status &error)
Reads an unsigned integer of the specified byte size from process memory.
Definition Process.cpp:2281
llvm::once_flag m_dlopen_utility_func_flag_once
Definition Process.h:3284
virtual llvm::VersionTuple GetHostOSVersion()
Sometimes the connection to a process can detect the host OS version that the process is running on.
Definition Process.h:1257
virtual void UpdateQueueListIfNeeded()
Definition Process.cpp:1247
virtual Status UpdateAutomaticSignalFiltering()
Definition Process.cpp:6413
virtual lldb::addr_t GetImageInfoAddress()
Get the image information address for the current process.
Definition Process.cpp:1479
std::map< lldb::addr_t, lldb::addr_t > m_resolved_indirect_addresses
This helps with the Public event coalescing in ShouldBroadcastEvent.
Definition Process.h:3273
virtual Status DoAttachToProcessWithID(lldb::pid_t pid, const ProcessAttachInfo &attach_info)
Attach to an existing process using a process ID.
Definition Process.h:998
void SetCanRunCode(bool can_run_code)
Sets whether executing code in this process is possible.
Definition Process.cpp:2533
Status ClearBreakpointSiteByID(lldb::user_id_t break_id)
Definition Process.cpp:1576
virtual Status EnableSoftwareBreakpoint(BreakpointSite *bp_site)
Definition Process.cpp:1753
void AppendSTDERR(const char *s, size_t len)
Definition Process.cpp:4576
bool GetShouldDetach() const
Definition Process.h:777
static llvm::StringRef GetStaticBroadcasterClass()
Definition Process.cpp:422
uint32_t m_thread_index_id
Each thread is created with a 1 based index that won't get re-used.
Definition Process.h:3161
bool ProcessIOHandlerExists() const
Definition Process.h:3354
virtual Status DoResume(lldb::RunDirection direction)
Resumes all of a process's threads as configured using the Thread run control functions.
Definition Process.h:1125
bool RouteAsyncStructuredData(const StructuredData::ObjectSP object_sp)
Route the incoming structured data dictionary to the right plugin.
Definition Process.cpp:6384
virtual void DidDestroy()
Definition Process.h:1224
lldb::offset_t ReadMemoryInChunks(lldb::addr_t vm_addr, void *buf, lldb::addr_t chunk_size, lldb::offset_t total_size, ReadMemoryChunkCallback callback)
Read of memory from a process in discrete chunks, terminating either when all bytes are read,...
Definition Process.cpp:2237
virtual void WillPublicStop()
Called when the process is about to broadcast a public stop.
Definition Process.h:813
friend class Trace
Definition Process.h:2784
lldb::addr_t ReadPointerFromMemory(lldb::addr_t vm_addr, Status &error)
Definition Process.cpp:2303
virtual void PrefetchModuleSpecs(llvm::ArrayRef< FileSpec > module_file_specs, const llvm::Triple &triple)
Definition Process.h:2603
Broadcaster m_private_state_control_broadcaster
Definition Process.h:3148
const std::vector< lldb::addr_t > & GetImageTokens()
Get the image vector for the current process.
Definition Process.h:785
lldb::addr_t GetHighmemCodeAddressMask()
The highmem masks are for targets where we may have different masks for low memory versus high memory...
Definition Process.cpp:5955
bool IsRunning() const
Definition Process.cpp:1004
size_t RemoveBreakpointOpcodesFromBuffer(lldb::addr_t addr, size_t size, uint8_t *buf) const
Definition Process.cpp:1716
Broadcaster m_private_state_broadcaster
Definition Process.h:3145
const Process & operator=(const Process &)=delete
virtual bool DetachRequiresHalt()
Definition Process.h:1197
virtual bool IsAlive()
Check if a process is still alive.
Definition Process.cpp:1082
ThreadList m_thread_list_real
The threads for this process as are known to the protocol we are debugging with.
Definition Process.h:3169
ThreadSafeValue< lldb::StateType > m_public_state
Definition Process.h:3142
lldb::addr_t m_data_address_mask
Definition Process.h:3263
virtual ArchSpec GetSystemArchitecture()
Get the system architecture for this process.
Definition Process.h:743
Status DeallocateMemory(lldb::addr_t ptr)
The public interface to deallocating memory in the process.
Definition Process.cpp:2538
virtual Status DisableWatchpoint(lldb::WatchpointSP wp_sp, bool notify=true)
Definition Process.cpp:2615
void RegisterNotificationCallbacks(const Process::Notifications &callbacks)
Register for process and thread notifications.
Definition Process.cpp:593
virtual void DidAttach(ArchSpec &process_arch)
Called after attaching a process.
Definition Process.h:1032
virtual lldb::addr_t ResolveIndirectFunction(const Address *address, Status &error)
Resolve dynamically loaded indirect functions.
Definition Process.cpp:6053
lldb::StateType m_last_broadcast_state
Definition Process.h:3270
LanguageRuntime * GetLanguageRuntime(lldb::LanguageType language)
Definition Process.cpp:1507
ProcessModID m_mod_id
Tracks the state of the process over stops and other alterations.
Definition Process.h:3156
virtual CommandObject * GetPluginCommandObject()
Return a multi-word command object that can be used to expose plug-in specific commands.
Definition Process.h:602
void SetID(lldb::pid_t new_pid)
Sets the stored pid.
Definition Process.h:558
friend class Target
Definition Process.h:360
virtual Status GetFileLoadAddress(const FileSpec &file, bool &is_loaded, lldb::addr_t &load_addr)
Try to find the load address of a file.
Definition Process.h:2620
virtual JITLoaderList & GetJITLoaders()
Definition Process.cpp:2883
uint32_t AssignIndexIDToThread(uint64_t thread_id)
Definition Process.cpp:1276
virtual bool SetExitStatus(int exit_status, llvm::StringRef exit_string)
Set accessor for the process exit status (return code).
Definition Process.cpp:1024
uint32_t m_queue_list_stop_id
The natural stop id when queue list was last fetched.
Definition Process.h:3187
void PrintWarningOptimization(const SymbolContext &sc)
Print a user-visible warning about a module being built with optimization.
Definition Process.cpp:6117
friend class FunctionCaller
Definition Process.h:355
ProcessRunLock m_private_run_lock
Definition Process.h:3231
virtual bool CanDebug(lldb::TargetSP target, bool plugin_specified_by_name)=0
Check if a plug-in instance can debug the file in module.
virtual std::optional< bool > DoGetWatchpointReportedAfter()
Provide an override value in the subclass for lldb's CPU-based logic for whether watchpoint exception...
Definition Process.h:2938
static ProcessProperties & GetGlobalProperties()
Definition Process.cpp:530
lldb::addr_t m_highmem_code_address_mask
Definition Process.h:3264
lldb::addr_t GetImagePtrFromToken(size_t token) const
Definition Process.cpp:6194
int m_exit_status
The exit status of the process, or -1 if not set.
Definition Process.h:3164
std::vector< LanguageRuntime * > GetLanguageRuntimes()
Definition Process.cpp:1487
void SetShouldDetach(bool b)
Definition Process.h:779
virtual lldb_private::StructuredData::ObjectSP GetDynamicLoaderProcessState()
Definition Process.h:1381
MemoryCache m_memory_cache
Definition Process.h:3221
static void STDIOReadThreadBytesReceived(void *baton, const void *src, size_t src_len)
Definition Process.cpp:4669
virtual bool GetProcessInfo(ProcessInstanceInfo &info)
Definition Process.cpp:6143
virtual void DidHalt()
Called after halting a process.
Definition Process.h:1169
lldb::addr_t FixCodeAddress(lldb::addr_t pc)
Some targets might use bits in a code address to indicate a mode switch, ARM uses bit zero to signify...
Definition Process.cpp:5999
lldb::StateType WaitForProcessStopPrivate(lldb::EventSP &event_sp, const Timeout< std::micro > &timeout)
Definition Process.cpp:2622
void RestoreProcessEvents()
Restores the process event broadcasting to its normal state.
Definition Process.cpp:927
virtual bool SupportsMemoryTagging()
Check whether the process supports memory tagging.
Definition Process.h:3074
void DumpThreadPlans(Stream &strm, lldb::DescriptionLevel desc_level, bool internal, bool condense_trivial, bool skip_unreported_plans)
Dump all the thread plans for this process.
Definition Process.cpp:1240
uint32_t GetAddressByteSize() const
Definition Process.cpp:3663
uint32_t GetStopID() const
Definition Process.h:1472
void SetPrivateState(lldb::StateType state)
Definition Process.cpp:1404
lldb::addr_t m_highmem_data_address_mask
Definition Process.h:3265
virtual Status DoDestroy()=0
Status StopForDestroyOrDetach(lldb::EventSP &exit_event_sp)
Definition Process.cpp:3453
virtual llvm::Error LoadModules()
Sometimes processes know how to retrieve and load shared libraries.
Definition Process.h:703
bool GetWatchpointReportedAfter()
Whether lldb will be notified about watchpoints after the instruction has completed executing,...
Definition Process.cpp:2547
SourceManager::SourceFileCache & GetSourceFileCache()
Definition Process.h:2736
lldb::StateType GetNextEvent(lldb::EventSP &event_sp)
Definition Process.cpp:633
virtual bool DoUpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list)=0
Update the thread list following process plug-in's specific logic.
virtual llvm::Expected< std::vector< uint8_t > > DoReadMemoryTags(lldb::addr_t addr, size_t len, int32_t type)
Does the final operation to read memory tags.
Definition Process.h:3093
bool StateChangedIsExternallyHijacked()
Definition Process.cpp:1384
void SetCanInterpretFunctionCalls(bool can_interpret_function_calls)
Sets whether executing function calls using the interpreter is possible for this process.
Definition Process.h:2067
virtual size_t GetSTDERR(char *buf, size_t buf_size, Status &error)
Get any available STDERR.
Definition Process.cpp:4650
size_t WriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size, Status &error)
Write memory to a process.
Definition Process.cpp:2339
virtual llvm::Expected< bool > SaveCore(llvm::StringRef outfile)
Save core dump into the specified file.
Definition Process.cpp:2879
bool ProcessIOHandlerIsActive()
Definition Process.cpp:4839
Status DestroyImpl(bool force_kill)
Definition Process.cpp:3566
bool m_force_next_event_delivery
Definition Process.h:3269
lldb::SystemRuntimeUP m_system_runtime_up
Definition Process.h:3206
virtual Status WillHalt()
Called before halting to a process.
Definition Process.h:1144
bool ShouldBroadcastEvent(Event *event_ptr)
This is the part of the event handling that for a process event.
Definition Process.cpp:3667
virtual DynamicLoader * GetDynamicLoader()
Get the dynamic loader plug-in for this process.
Definition Process.cpp:2867
std::string m_exit_string
A textual description of why a process exited.
Definition Process.h:3165
lldb::DynamicCheckerFunctionsUP m_dynamic_checkers_up
The functions used by the expression parser to validate data that expressions use.
Definition Process.h:3200
void SyncIOHandler(uint32_t iohandler_id, const Timeout< std::micro > &timeout)
Waits for the process state to be running within a given msec timeout.
Definition Process.cpp:644
void ForceNextEventDelivery()
Definition Process.h:3024
ThreadPlanStack * FindThreadPlans(lldb::tid_t tid)
Find the thread plan stack associated with thread with tid.
Definition Process.cpp:1221
void SetSTDIOFileDescriptor(int file_descriptor)
Definition Process.cpp:4820
virtual Status Attach(ProcessAttachInfo &attach_info)
Attach to an existing process using the process attach info.
Definition Process.cpp:2993
virtual void Finalize(bool destructing)
This object is about to be destroyed, do any necessary cleanup.
Definition Process.cpp:538
lldb::addr_t GetDataAddressMask()
Definition Process.cpp:5948
void SynchronouslyNotifyStateChanged(lldb::StateType state)
Definition Process.cpp:612
bool CanJIT()
Determines whether executing JIT-compiled code in this process is possible.
Definition Process.cpp:2500
StopPointSiteList< lldb_private::WatchpointResource > & GetWatchpointResourceList()
Definition Process.h:2275
llvm::StringRef GetBroadcasterClass() const override
This needs to be filled in if you are going to register the broadcaster with the broadcaster manager ...
Definition Process.h:406
virtual lldb_private::UUID FindModuleUUID(const llvm::StringRef path)
Definition Process.cpp:6153
virtual Status DoAttachToProcessWithName(const char *process_name, const ProcessAttachInfo &attach_info)
Attach to an existing process using a partial process name.
Definition Process.h:1019
ThreadList m_thread_list
The threads for this process as the user will see them.
Definition Process.h:3171
virtual bool StartNoticingNewThreads()
Call this to set the lldb in the mode where it breaks on new thread creations, and then auto-restarts...
Definition Process.h:2512
bool UpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list)
Update the thread list.
Definition Process.cpp:1128
const lldb::UnixSignalsSP & GetUnixSignals()
Definition Process.cpp:3654
void SetBaseDirection(lldb::RunDirection direction)
Set the base run direction for the process.
Definition Process.cpp:3277
Status WriteMemoryTags(lldb::addr_t addr, size_t len, const std::vector< lldb::addr_t > &tags)
Write memory tags for a range of memory.
Definition Process.cpp:6529
virtual size_t DoReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, Status &error)=0
Actually do the reading of memory from a process.
virtual bool IsLiveDebugSession() const
Check if a process is a live debug session, or a corefile/post-mortem.
Definition Process.h:1516
std::weak_ptr< Target > m_target_wp
The target that owns this process.
Definition Process.h:3140
virtual void DoDidExec()
Subclasses of Process should implement this function if they need to do anything after a process exec...
Definition Process.h:1044
virtual void RefreshStateAfterStop()=0
Currently called as part of ShouldStop.
virtual llvm::SmallVector< llvm::MutableArrayRef< uint8_t > > ReadMemoryRanges(llvm::ArrayRef< Range< lldb::addr_t, size_t > > ranges, llvm::MutableArrayRef< uint8_t > buffer)
Read from multiple memory ranges and write the results into buffer.
Definition Process.cpp:1975
lldb::addr_t GetCodeAddressMask()
Get the current address mask in the Process.
Definition Process.cpp:5941
bool UnregisterNotificationCallbacks(const Process::Notifications &callbacks)
Unregister for process and thread notifications.
Definition Process.cpp:599
bool HijackProcessEvents(lldb::ListenerSP listener_sp)
If you need to ensure that you and only you will hear about some public event, then make a new listen...
Definition Process.cpp:919
QueueList & GetQueueList()
Definition Process.h:2303
virtual Status DoDeallocateMemory(lldb::addr_t ptr)
Actually deallocate memory in the process.
Definition Process.h:2089
Status GetMemoryRegionInfo(lldb::addr_t load_addr, MemoryRegionInfo &range_info)
Locate the memory region that contains load_addr.
Definition Process.cpp:6257
friend class DynamicLoader
Definition Process.h:357
static void SettingsTerminate()
Definition Process.cpp:4878
virtual void * GetImplementation()
Definition Process.h:2732
lldb::addr_t GetHighmemDataAddressMask()
Definition Process.cpp:5964
ThreadList m_extended_thread_list
Constituent for extended threads that may be generated, cleared on natural stops.
Definition Process.h:3180
bool CallVoidArgVoidPtrReturn(const Address *address, lldb::addr_t &returned_func, bool trap_exceptions=false)
Definition Process.cpp:6436
bool CurrentThreadIsPrivateStateThread()
Definition Process.cpp:5920
void AddPreResumeAction(PreResumeActionCallback callback, void *baton)
Definition Process.cpp:5885
size_t GetSoftwareBreakpointTrapOpcode(BreakpointSite *bp_site)
Definition Process.cpp:1746
Status Halt(bool clear_thread_plans=false, bool use_run_lock=true)
Halts a running process.
Definition Process.cpp:3351
lldb::pid_t m_pid
Definition Process.h:3141
const lldb::ABISP & GetABI()
Definition Process.cpp:1481
friend class Debugger
Definition Process.h:356
Status WillLaunch(Module *module)
Called before launching to a process.
Definition Process.cpp:2980
lldb::ModuleSP ReadModuleFromMemory(const FileSpec &file_spec, lldb::addr_t header_addr, size_t size_to_read=512)
Definition Process.cpp:2565
std::vector< lldb::ThreadSP > CalculateCoreFileThreadList(const SaveCoreOptions &core_options)
Helper function for Process::SaveCore(...) that calculates the thread list based upon options set wit...
Definition Process.cpp:6835
size_t WriteScalarToMemory(lldb::addr_t vm_addr, const Scalar &scalar, size_t size, Status &error)
Write all or part of a scalar value to memory.
Definition Process.cpp:2420
uint32_t GetLastUserExpressionResumeID() const
Definition Process.h:1476
virtual size_t GetSTDOUT(char *buf, size_t buf_size, Status &error)
Get any available STDOUT.
Definition Process.cpp:4631
lldb::ThreadCollectionSP GetHistoryThreads(lldb::addr_t addr)
Definition Process.cpp:6157
const ProcessModID & GetModIDRef() const
Definition Process.h:1470
lldb::StateType GetStateChangedEvents(lldb::EventSP &event_sp, const Timeout< std::micro > &timeout, lldb::ListenerSP hijack_listener)
Definition Process.cpp:929
ThreadedCommunication m_stdio_communication
Definition Process.h:3212
lldb::StackFrameSP CalculateStackFrame() override
Definition Process.h:2531
static constexpr int g_all_event_bits
Definition Process.h:375
virtual lldb::addr_t DoAllocateMemory(size_t size, uint32_t permissions, Status &error)
Actually allocate memory in the process.
Definition Process.h:1821
std::atomic< bool > m_finalizing
The tid of the thread that issued the async interrupt, used by thread plan timeout.
Definition Process.h:3245
virtual llvm::Expected< std::string > TraceGetState(llvm::StringRef type)
Get the current tracing state of the process and its threads.
Definition Process.h:2838
bool CanInterpretFunctionCalls()
Determines whether executing function calls using the interpreter is possible for this process.
Definition Process.h:2060
std::recursive_mutex m_language_runtimes_mutex
Definition Process.h:3226
std::string m_stderr_data
Definition Process.h:3217
friend class ThreadList
Definition Process.h:361
Target & GetTarget()
Get the target object pointer for this module.
Definition Process.h:1267
virtual Status EnableWatchpoint(lldb::WatchpointSP wp_sp, bool notify=true)
Definition Process.cpp:2609
LockingAdaptedIterable< std::mutex, collection > QueueIterable
Definition QueueList.h:51
The SourceFileCache class separates the source manager from the cache of source files.
An error handling class.
Definition Status.h:118
static Status FromErrorString(const char *str)
Definition Status.h:141
static Status static Status FromErrorStringWithFormatv(const char *format, Args &&...args)
Definition Status.h:151
A stream class that can stream formatted output to a file.
Definition Stream.h:28
void Format(const char *format, Args &&... args)
Definition Stream.h:344
std::shared_ptr< Dictionary > DictionarySP
std::shared_ptr< Object > ObjectSP
Defines a symbol context baton that can be handed other debug core functions.
A plug-in interface definition class for system runtimes.
LockingAdaptedIterable< std::recursive_mutex, collection > ThreadIterable
"lldb/Core/ThreadedCommunication.h" Variation of Communication that supports threaded reads.
Represents UUID's of various sizes.
Definition UUID.h:27
"lldb/Expression/UtilityFunction.h" Encapsulates a bit of source code that provides a function that i...
#define LLDB_INVALID_ADDRESS_MASK
Address Mask Bits not used for addressing are set to 1 in the mask; all mask bits set is an invalid v...
#define LLDB_INVALID_ADDRESS
#define UINT32_MAX
#define LLDB_INVALID_PROCESS_ID
@ DoNoSelectMostRelevantFrame
A class that represents a running process on the host machine.
std::map< lldb::InstrumentationRuntimeType, lldb::InstrumentationRuntimeSP > InstrumentationRuntimeCollection
bool operator!=(const Address &lhs, const Address &rhs)
Definition Address.cpp:1017
llvm::APFloat::cmpResult compare(Scalar lhs, Scalar rhs)
Definition Scalar.cpp:872
IterationAction
Useful for callbacks whose return type indicates whether to continue iteration or short-circuit.
bool operator==(const Address &lhs, const Address &rhs)
Definition Address.cpp:1011
static uint32_t bits(const uint32_t val, const uint32_t msbit, const uint32_t lsbit)
Definition ARMUtils.h:265
std::shared_ptr< lldb_private::ThreadPlan > ThreadPlanSP
std::shared_ptr< lldb_private::ABI > ABISP
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
std::unique_ptr< lldb_private::SystemRuntime > SystemRuntimeUP
std::shared_ptr< lldb_private::BreakpointSite > BreakpointSiteSP
std::shared_ptr< lldb_private::BreakpointLocation > BreakpointLocationSP
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
RunDirection
Execution directions.
std::shared_ptr< lldb_private::IOHandler > IOHandlerSP
std::unique_ptr< lldb_private::OperatingSystem > OperatingSystemUP
std::shared_ptr< lldb_private::Thread > ThreadSP
void * thread_result_t
Definition lldb-types.h:62
std::shared_ptr< lldb_private::UnixSignals > UnixSignalsSP
uint64_t offset_t
Definition lldb-types.h:85
std::unique_ptr< lldb_private::DynamicCheckerFunctions > DynamicCheckerFunctionsUP
StateType
Process and Thread States.
@ eStateDetached
Process has been detached and can't be examined.
@ eStateExited
Process has exited and can't be examined.
LanguageType
Programming language type.
ExpressionResults
The results of expression evaluation.
std::shared_ptr< lldb_private::StructuredDataPlugin > StructuredDataPluginSP
int32_t break_id_t
Definition lldb-types.h:86
std::shared_ptr< lldb_private::Process > ProcessSP
InstrumentationRuntimeType
std::shared_ptr< lldb_private::Event > EventSP
std::unique_ptr< lldb_private::DynamicLoader > DynamicLoaderUP
std::unique_ptr< lldb_private::JITLoaderList > JITLoaderListUP
uint64_t pid_t
Definition lldb-types.h:83
ByteOrder
Byte ordering definitions.
std::shared_ptr< lldb_private::Watchpoint > WatchpointSP
std::weak_ptr< lldb_private::Process > ProcessWP
std::shared_ptr< lldb_private::Listener > ListenerSP
uint64_t user_id_t
Definition lldb-types.h:82
uint64_t addr_t
Definition lldb-types.h:80
std::shared_ptr< lldb_private::Target > TargetSP
std::shared_ptr< lldb_private::InstrumentationRuntime > InstrumentationRuntimeSP
uint64_t tid_t
Definition lldb-types.h:84
std::shared_ptr< lldb_private::Module > ModuleSP
std::shared_ptr< lldb_private::ThreadCollection > ThreadCollectionSP
A notification structure that can be used by clients to listen for changes in a process's lifetime.
Definition Process.h:415
void(* process_state_changed)(void *baton, Process *process, lldb::StateType state)
Definition Process.h:418
void(* initialize)(void *baton, Process *process)
Definition Process.h:417
bool operator==(const PreResumeCallbackAndBaton &rhs)
Definition Process.h:3134
PreResumeCallbackAndBaton(PreResumeActionCallback in_callback, void *in_baton)
Definition Process.h:3131
jLLDBTraceGetBinaryData gdb-remote packet
jLLDBTraceStop gdb-remote packet