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