Path: blob/main/contrib/llvm-project/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.h
39644 views
//===-- NativeProcessFreeBSD.h -------------------------------- -*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef liblldb_NativeProcessFreeBSD_H_9#define liblldb_NativeProcessFreeBSD_H_1011#include "Plugins/Process/POSIX/NativeProcessELF.h"12#include "Plugins/Process/Utility/NativeProcessSoftwareSingleStep.h"1314#include "lldb/Target/MemoryRegionInfo.h"15#include "lldb/Utility/ArchSpec.h"16#include "lldb/Utility/FileSpec.h"1718#include "NativeThreadFreeBSD.h"1920namespace lldb_private {21namespace process_freebsd {22/// \class NativeProcessFreeBSD23/// Manages communication with the inferior (debugee) process.24///25/// Upon construction, this class prepares and launches an inferior process26/// for debugging.27///28/// Changes in the inferior process state are broadcasted.29class NativeProcessFreeBSD : public NativeProcessELF,30private NativeProcessSoftwareSingleStep {31public:32class Manager : public NativeProcessProtocol::Manager {33public:34using NativeProcessProtocol::Manager::Manager;3536llvm::Expected<std::unique_ptr<NativeProcessProtocol>>37Launch(ProcessLaunchInfo &launch_info,38NativeDelegate &native_delegate) override;3940llvm::Expected<std::unique_ptr<NativeProcessProtocol>>41Attach(lldb::pid_t pid, NativeDelegate &native_delegate) override;4243Extension GetSupportedExtensions() const override;44};4546// NativeProcessProtocol Interface47Status Resume(const ResumeActionList &resume_actions) override;4849Status Halt() override;5051Status Detach() override;5253Status Signal(int signo) override;5455Status Interrupt() override;5657Status Kill() override;5859Status GetMemoryRegionInfo(lldb::addr_t load_addr,60MemoryRegionInfo &range_info) override;6162Status ReadMemory(lldb::addr_t addr, void *buf, size_t size,63size_t &bytes_read) override;6465Status WriteMemory(lldb::addr_t addr, const void *buf, size_t size,66size_t &bytes_written) override;6768size_t UpdateThreads() override;6970const ArchSpec &GetArchitecture() const override { return m_arch; }7172Status SetBreakpoint(lldb::addr_t addr, uint32_t size,73bool hardware) override;7475// The two following methods are probably not necessary and probably76// will never be called. Nevertheless, we implement them right now77// to reduce the differences between different platforms and reduce78// the risk of the lack of implementation actually breaking something,79// at least for the time being.80Status GetLoadedModuleFileSpec(const char *module_path,81FileSpec &file_spec) override;82Status GetFileLoadAddress(const llvm::StringRef &file_name,83lldb::addr_t &load_addr) override;8485llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>86GetAuxvData() const override;8788// Interface used by NativeRegisterContext-derived classes.89static Status PtraceWrapper(int req, lldb::pid_t pid, void *addr = nullptr,90int data = 0, int *result = nullptr);9192bool SupportHardwareSingleStepping() const;9394llvm::Expected<std::string> SaveCore(llvm::StringRef path_hint) override;9596protected:97llvm::Expected<llvm::ArrayRef<uint8_t>>98GetSoftwareBreakpointTrapOpcode(size_t size_hint) override;99100private:101MainLoop::SignalHandleUP m_sigchld_handle;102ArchSpec m_arch;103MainLoop& m_main_loop;104LazyBool m_supports_mem_region = eLazyBoolCalculate;105std::vector<std::pair<MemoryRegionInfo, FileSpec>> m_mem_region_cache;106107// Private Instance Methods108NativeProcessFreeBSD(::pid_t pid, int terminal_fd, NativeDelegate &delegate,109const ArchSpec &arch, MainLoop &mainloop);110111bool HasThreadNoLock(lldb::tid_t thread_id);112113NativeThreadFreeBSD &AddThread(lldb::tid_t thread_id);114void RemoveThread(lldb::tid_t thread_id);115116void MonitorCallback(lldb::pid_t pid, int signal);117void MonitorExited(lldb::pid_t pid, WaitStatus status);118void MonitorSIGSTOP(lldb::pid_t pid);119void MonitorSIGTRAP(lldb::pid_t pid);120void MonitorSignal(lldb::pid_t pid, int signal);121void MonitorClone(::pid_t child_pid, bool is_vfork,122NativeThreadFreeBSD &parent_thread);123124Status PopulateMemoryRegionCache();125void SigchldHandler();126127Status Attach();128Status SetupTrace();129Status ReinitializeThreads();130};131132} // namespace process_freebsd133} // namespace lldb_private134135#endif // #ifndef liblldb_NativeProcessFreeBSD_H_136137138