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