LLDB mainline
NativeProcessFreeBSD.h
Go to the documentation of this file.
1//===-- NativeProcessFreeBSD.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 liblldb_NativeProcessFreeBSD_H_
10#define liblldb_NativeProcessFreeBSD_H_
11
14
18
19#include "NativeThreadFreeBSD.h"
20
21namespace lldb_private {
22namespace process_freebsd {
23/// \class NativeProcessFreeBSD
24/// Manages communication with the inferior (debugee) process.
25///
26/// Upon construction, this class prepares and launches an inferior process
27/// for debugging.
28///
29/// Changes in the inferior process state are broadcasted.
32public:
34 public:
36
37 llvm::Expected<std::unique_ptr<NativeProcessProtocol>>
38 Launch(ProcessLaunchInfo &launch_info,
39 NativeDelegate &native_delegate) override;
40
41 llvm::Expected<std::unique_ptr<NativeProcessProtocol>>
42 Attach(lldb::pid_t pid, NativeDelegate &native_delegate) override;
43
44 Extension GetSupportedExtensions() const override;
45 };
46
47 // NativeProcessProtocol Interface
48 Status Resume(const ResumeActionList &resume_actions) override;
49
50 Status Halt() override;
51
52 Status Detach() override;
53
54 Status Signal(int signo) override;
55
56 Status Interrupt() override;
57
58 Status Kill() override;
59
61 MemoryRegionInfo &range_info) override;
62
63 Status ReadMemory(lldb::addr_t addr, void *buf, size_t size,
64 size_t &bytes_read) override;
65
66 Status WriteMemory(lldb::addr_t addr, const void *buf, size_t size,
67 size_t &bytes_written) override;
68
69 size_t UpdateThreads() override;
70
71 const ArchSpec &GetArchitecture() const override { return m_arch; }
72
73 Status SetBreakpoint(lldb::addr_t addr, uint32_t size,
74 bool hardware) override;
75
76 // The two following methods are probably not necessary and probably
77 // will never be called. Nevertheless, we implement them right now
78 // to reduce the differences between different platforms and reduce
79 // the risk of the lack of implementation actually breaking something,
80 // at least for the time being.
81 Status GetLoadedModuleFileSpec(const char *module_path,
82 FileSpec &file_spec) override;
83 Status GetFileLoadAddress(const llvm::StringRef &file_name,
84 lldb::addr_t &load_addr) override;
85
86 llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
87 GetAuxvData() const override;
88
89 // Interface used by NativeRegisterContext-derived classes.
90 static Status PtraceWrapper(int req, lldb::pid_t pid, void *addr = nullptr,
91 int data = 0, int *result = nullptr);
92
94
95 llvm::Expected<std::string> SaveCore(llvm::StringRef path_hint) override;
96
97protected:
98 llvm::Expected<llvm::ArrayRef<uint8_t>>
99 GetSoftwareBreakpointTrapOpcode(size_t size_hint) override;
100
101private:
106 std::vector<std::pair<MemoryRegionInfo, FileSpec>> m_mem_region_cache;
107
108 // Private Instance Methods
109 NativeProcessFreeBSD(::pid_t pid, int terminal_fd, NativeDelegate &delegate,
110 const ArchSpec &arch, MainLoop &mainloop);
111
112 bool HasThreadNoLock(lldb::tid_t thread_id);
113
115 void RemoveThread(lldb::tid_t thread_id);
116
117 void MonitorCallback(lldb::pid_t pid, int signal);
118 void MonitorExited(lldb::pid_t pid, WaitStatus status);
119 void MonitorSIGSTOP(lldb::pid_t pid);
120 void MonitorSIGTRAP(lldb::pid_t pid);
121 void MonitorSignal(lldb::pid_t pid, int signal);
122 void MonitorClone(::pid_t child_pid, bool is_vfork,
123 NativeThreadFreeBSD &parent_thread);
124
126 void SigchldHandler();
127
128 Status Attach();
131};
132
133} // namespace process_freebsd
134} // namespace lldb_private
135
136#endif // #ifndef liblldb_NativeProcessFreeBSD_H_
An architecture specification class.
Definition: ArchSpec.h:31
A file utility class.
Definition: FileSpec.h:56
std::unique_ptr< SignalHandle > SignalHandleUP
Definition: MainLoopPosix.h:32
Abstract class that extends NativeProcessProtocol with ELF specific logic.
Extension
Extension flag constants, returned by Manager::GetSupportedExtensions() and passed to SetEnabledExten...
An error handling class.
Definition: Status.h:115
llvm::Expected< std::unique_ptr< NativeProcessProtocol > > Launch(ProcessLaunchInfo &launch_info, NativeDelegate &native_delegate) override
Launch a process for debugging.
Extension GetSupportedExtensions() const override
Get the bitmask of extensions supported by this process plugin.
Manages communication with the inferior (debugee) process.
NativeThreadFreeBSD & AddThread(lldb::tid_t thread_id)
Status GetMemoryRegionInfo(lldb::addr_t load_addr, MemoryRegionInfo &range_info) override
Status Resume(const ResumeActionList &resume_actions) override
llvm::Expected< std::string > SaveCore(llvm::StringRef path_hint) override
Write a core dump (without crashing the program).
Status GetFileLoadAddress(const llvm::StringRef &file_name, lldb::addr_t &load_addr) override
llvm::ErrorOr< std::unique_ptr< llvm::MemoryBuffer > > GetAuxvData() const override
void MonitorClone(::pid_t child_pid, bool is_vfork, NativeThreadFreeBSD &parent_thread)
static Status PtraceWrapper(int req, lldb::pid_t pid, void *addr=nullptr, int data=0, int *result=nullptr)
Status Interrupt() override
Tells a process to interrupt all operations as if by a Ctrl-C.
Status Signal(int signo) override
Sends a process a UNIX signal signal.
Status ReadMemory(lldb::addr_t addr, void *buf, size_t size, size_t &bytes_read) override
Status GetLoadedModuleFileSpec(const char *module_path, FileSpec &file_spec) override
llvm::Expected< llvm::ArrayRef< uint8_t > > GetSoftwareBreakpointTrapOpcode(size_t size_hint) override
void MonitorExited(lldb::pid_t pid, WaitStatus status)
std::vector< std::pair< MemoryRegionInfo, FileSpec > > m_mem_region_cache
Status WriteMemory(lldb::addr_t addr, const void *buf, size_t size, size_t &bytes_written) override
Status SetBreakpoint(lldb::addr_t addr, uint32_t size, bool hardware) override
A class that represents a running process on the host machine.
uint64_t pid_t
Definition: lldb-types.h:83
uint64_t addr_t
Definition: lldb-types.h:80
uint64_t tid_t
Definition: lldb-types.h:84