9#ifndef LLDB_HOST_COMMON_NATIVEPROCESSPROTOCOL_H
10#define LLDB_HOST_COMMON_NATIVEPROCESSPROTOCOL_H
26#include "llvm/ADT/ArrayRef.h"
27#include "llvm/ADT/DenseSet.h"
28#include "llvm/ADT/StringRef.h"
29#include "llvm/Support/Error.h"
30#include "llvm/Support/MemoryBuffer.h"
65 llvm::pointee_iterator<thread_collection::const_iterator>>
106 size_t &bytes_read) = 0;
109 size_t size,
size_t &bytes_read);
112 std::vector<uint8_t> &tags);
115 const std::vector<uint8_t> &tags);
138 llvm::Expected<llvm::StringRef>
140 size_t &total_bytes_read);
145 size_t &bytes_written);
148 uint32_t permissions) {
149 return llvm::make_error<UnimplementedError>();
153 return llvm::make_error<UnimplementedError>();
158 virtual llvm::Expected<std::vector<SVR4LibraryInfo>>
160 return llvm::createStringError(llvm::inconvertibleErrorCode(),
169 return llvm::createStringError(llvm::inconvertibleErrorCode(),
201 virtual std::optional<std::pair<uint32_t, uint32_t>>
205 uint32_t watch_flags,
bool hardware);
230 virtual llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
280 std::unique_ptr<NativeProcessProtocol> child_process) = 0;
285 llvm::StringRef data) {}
339 virtual llvm::Expected<std::unique_ptr<NativeProcessProtocol>>
361 virtual llvm::Expected<std::unique_ptr<NativeProcessProtocol>>
397 llvm::StringRef type) {
398 return llvm::createStringError(llvm::inconvertibleErrorCode(),
399 "Unsupported tracing type '%s'",
405 return llvm::createStringError(llvm::inconvertibleErrorCode(),
406 "Unsupported tracing type '%s'",
407 request.
type.data());
411 virtual llvm::Expected<llvm::json::Value>
413 return llvm::createStringError(llvm::inconvertibleErrorCode(),
414 "Unsupported tracing type '%s'",
419 virtual llvm::Expected<std::vector<uint8_t>>
421 return llvm::createStringError(
422 llvm::inconvertibleErrorCode(),
423 "Unsupported data kind '%s' for the '%s' tracing technology",
424 request.
kind.c_str(), request.
type.c_str());
429 return llvm::make_error<UnimplementedError>();
449 virtual llvm::Expected<std::string>
SaveCore(llvm::StringRef path_hint) {
450 return llvm::createStringError(llvm::inconvertibleErrorCode(),
473 std::vector<std::unique_ptr<NativeThreadProtocol>>
m_threads;
500 size_t &bytes_written) = 0;
525 virtual llvm::Expected<llvm::ArrayRef<uint8_t>>
549 llvm::Expected<SoftwareBreakpoint>
static llvm::raw_ostream & error(Stream &strm)
An architecture specification class.
uint32_t GetAddressByteSize() const
Returns the size in bytes of an address of the current architecture.
lldb::ByteOrder GetByteOrder() const
Returns the byte order for the architecture specification.
Manager & operator=(const Manager &)=delete
virtual llvm::Expected< std::unique_ptr< NativeProcessProtocol > > Attach(lldb::pid_t pid, NativeDelegate &native_delegate)=0
Attach to an existing process.
Manager(const Manager &)=delete
virtual llvm::Expected< std::unique_ptr< NativeProcessProtocol > > Launch(ProcessLaunchInfo &launch_info, NativeDelegate &native_delegate)=0
Launch a process for debugging.
Manager(MainLoop &mainloop)
virtual Extension GetSupportedExtensions() const
Get the bitmask of extensions supported by this process plugin.
virtual void ProcessStateChanged(NativeProcessProtocol *process, lldb::StateType state)=0
virtual void DidExec(NativeProcessProtocol *process)=0
virtual ~NativeDelegate()=default
virtual void NewSubprocess(NativeProcessProtocol *parent_process, std::unique_ptr< NativeProcessProtocol > child_process)=0
virtual void NewProcessOutput(NativeProcessProtocol *process, llvm::StringRef data)
Called by the platform when the inferior writes to stdout/stderr through a redirected pseudoconsole t...
virtual void InitializeDelegate(NativeProcessProtocol *process)=0
virtual Status SetWatchpoint(lldb::addr_t addr, size_t size, uint32_t watch_flags, bool hardware)
virtual lldb::addr_t GetSharedLibraryInfoAddress()=0
virtual Status ReadMemoryTags(int32_t type, lldb::addr_t addr, size_t len, std::vector< uint8_t > &tags)
llvm::Expected< SoftwareBreakpoint > EnableSoftwareBreakpoint(lldb::addr_t addr, uint32_t size_hint)
virtual llvm::Expected< TraceSupportedResponse > TraceSupported()
Get the processor tracing type supported for this process.
virtual Status GetMemoryRegionInfo(lldb::addr_t load_addr, MemoryRegionInfo &range_info)
std::vector< std::unique_ptr< NativeThreadProtocol > > thread_collection
virtual std::vector< std::string > GetStructuredDataPlugins()
Get the list of structured data plugins supported by this process.
virtual std::vector< AddressSpaceInfo > GetAddressSpaces()
Served over the "jAddressSpacesInfo" packet.
virtual void NotifyTracersProcessWillResume()
Notify tracers that the target process will resume.
virtual void NotifyTracersProcessDidStop()
Notify tracers that the target process just stopped.
virtual std::optional< WaitStatus > GetExitStatus()
virtual void SetEnabledExtensions(Extension flags)
Method called in order to propagate the bitmap of protocol extensions supported by the client.
virtual Status RemoveWatchpoint(lldb::addr_t addr)
virtual Status Interrupt()
Tells a process to interrupt all operations as if by a Ctrl-C.
uint32_t GetAddressByteSize() const
virtual Status WriteMemoryTags(int32_t type, lldb::addr_t addr, size_t len, const std::vector< uint8_t > &tags)
virtual void DoStopIDBumped(uint32_t newBumpId)
NativeProcessProtocol(lldb::pid_t pid, int terminal_fd, NativeDelegate &delegate)
virtual llvm::Expected< std::vector< SVR4LibraryInfo > > GetLoadedSVR4Libraries()
virtual size_t GetSoftwareBreakpointPCOffset()
Return the offset of the PC relative to the software breakpoint that was hit.
virtual llvm::Expected< std::vector< uint8_t > > TraceGetBinaryData(const TraceGetBinaryDataRequest &request)
Get binary data given a trace technology and a data identifier.
lldb::pid_t GetID() const
virtual const HardwareBreakpointMap & GetHardwareBreakpointMap() const
lldb::tid_t m_current_thread_id
virtual llvm::Error TraceStop(const TraceStopRequest &request)
Stop tracing a live process or its threads.
virtual Status GetLoadedModuleFileSpec(const char *module_path, FileSpec &file_spec)=0
Status SetSoftwareBreakpoint(lldb::addr_t addr, uint32_t size_hint)
virtual Status IgnoreSignals(llvm::ArrayRef< int > signals)
virtual llvm::Expected< std::vector< LoadedLibraryInfo > > GetLoadedLibraries()
Return the currently loaded libraries of the target in the qXfer:libraries:read form (generic name + ...
NativeThreadProtocol * GetThreadByIDUnlocked(lldb::tid_t tid)
virtual llvm::Expected< llvm::json::Value > TraceGetState(llvm::StringRef type)
Get the current tracing state of the process and its threads.
virtual Status SetBreakpoint(lldb::addr_t addr, uint32_t size, bool hardware)=0
lldb::ByteOrder GetByteOrder() const
virtual const ArchSpec & GetArchitecture() const =0
LockingAdaptedIterable< std::recursive_mutex, thread_collection, llvm::pointee_iterator< thread_collection::const_iterator > > ThreadIterable
virtual const NativeWatchpointList::WatchpointMap & GetWatchpointMap() const
virtual llvm::Error DeallocateMemory(lldb::addr_t addr)
lldb::StateType GetState() const
void SetState(lldb::StateType state, bool notify_delegates=true)
HardwareBreakpointMap m_hw_breakpoints_map
llvm::Expected< llvm::StringRef > ReadCStringFromMemory(lldb::addr_t addr, char *buffer, size_t max_size, size_t &total_bytes_read)
Reads a null terminated string from memory.
virtual Status DoWriteMemory(lldb::addr_t addr, const void *buf, size_t size, size_t &bytes_written)=0
NativeThreadProtocol * GetThreadByID(lldb::tid_t tid)
virtual Status GetFileLoadAddress(const llvm::StringRef &file_name, lldb::addr_t &load_addr)=0
Status ReadMemoryWithoutTrap(const ProcessAddress &addr, void *buf, size_t size, size_t &bytes_read)
NativeThreadProtocol * GetCurrentThread()
void SynchronouslyNotifyProcessStateChanged(lldb::StateType state)
uint32_t GetStopID() const
virtual llvm::Expected< std::string > SaveCore(llvm::StringRef path_hint)
Write a core dump (without crashing the program).
Status WriteMemory(lldb::addr_t addr, const void *buf, size_t size, size_t &bytes_written)
Write memory while not overwriting breakpoints in memory.
void SetCurrentThreadID(lldb::tid_t tid)
std::recursive_mutex m_threads_mutex
std::vector< std::unique_ptr< NativeThreadProtocol > > m_threads
llvm::DenseSet< int > m_signals_to_ignore
virtual int GetTerminalFileDescriptor()
std::optional< WaitStatus > m_exit_status
virtual bool SetExitStatus(WaitStatus status, bool bNotifyStateChange)
virtual Status RemoveBreakpoint(lldb::addr_t addr, bool hardware=false)
virtual size_t WriteStdin(const void *buf, size_t len, Status &error)
Write up to len bytes from buf to the inferior's stdin.
void SetID(lldb::pid_t pid)
virtual Status Resume(const ResumeActionList &resume_actions)=0
virtual ~NativeProcessProtocol()=default
virtual Status Signal(int signo)=0
Sends a process a UNIX signal signal.
NativeDelegate & m_delegate
Status RemoveSoftwareBreakpoint(lldb::addr_t addr)
void FixupBreakpointPCAsNeeded(NativeThreadProtocol &thread)
bool HasSoftwareBreakpoint(lldb::addr_t addr)
NativeThreadProtocol * GetThreadAtIndex(uint32_t idx)
virtual bool HasPendingLibraryEvents()
lldb::tid_t GetCurrentThreadID() const
virtual size_t UpdateThreads()=0
virtual void NotifyDidExec()
Notify the delegate that an exec occurred.
virtual Status ReadMemory(const ProcessAddress &addr, void *buf, size_t size, size_t &bytes_read)=0
Plugins without address spaces should error on a non-default one.
virtual llvm::Expected< lldb::addr_t > AllocateMemory(size_t size, uint32_t permissions)
virtual bool IsAlive() const
Extension
Extension flag constants, returned by Manager::GetSupportedExtensions() and passed to SetEnabledExten...
virtual Status SetHardwareBreakpoint(lldb::addr_t addr, size_t size)
std::map< lldb::addr_t, SoftwareBreakpoint > m_software_breakpoints
virtual llvm::ErrorOr< std::unique_ptr< llvm::MemoryBuffer > > GetAuxvData() const =0
virtual Status Detach()=0
virtual std::optional< std::pair< uint32_t, uint32_t > > GetHardwareDebugSupportInfo() const
virtual llvm::Expected< llvm::ArrayRef< uint8_t > > GetSoftwareBreakpointTrapOpcode(size_t size_hint)
Extension m_enabled_extensions
virtual llvm::Error TraceStart(llvm::StringRef json_params, llvm::StringRef type)
Start tracing a process or its threads.
std::recursive_mutex m_state_mutex
virtual Status RemoveHardwareBreakpoint(lldb::addr_t addr)
ThreadIterable Threads() const
NativeWatchpointList m_watchpoint_list
std::map< lldb::addr_t, NativeWatchpoint > WatchpointMap
An address in a process, qualified by an address space.
#define LLDB_INVALID_THREAD_ID
A class that represents a running process on the host machine.
@ LLVM_MARK_AS_BITMASK_ENUM
LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE()
std::map< lldb::addr_t, HardwareBreakpoint > HardwareBreakpointMap
StateType
Process and Thread States.
@ eStateStopped
Process or thread is stopped and can be examined.
@ eStateRunning
Process or thread is running and can't be examined.
@ eStateStepping
Process or thread is in the process of stepping and can not be examined.
ByteOrder
Byte ordering definitions.
Generic loaded-library entry used by the non-SVR4 qXfer:libraries:read form of the GDB remote library...
llvm::ArrayRef< uint8_t > breakpoint_opcodes
llvm::SmallVector< uint8_t, 4 > saved_opcodes
jLLDBTraceGetBinaryData gdb-remote packet
std::string kind
Identifier for the data.
std::string type
Tracing technology name, e.g. intel-pt, arm-coresight.
jLLDBTraceStop gdb-remote packet
std::string type
Tracing technology name, e.g. intel-pt, arm-coresight.