Summary: This patch is a stripped down from features a NetBSD process code (patch is kept under 2k LOC). This code has assumption that there is only one thread within a debugged process. The only debugger trap supported is software breakpoint (TRAP_BRKPT). The generic platform code requires to add dummy function for watchpoints etc. These functions are currently empty. This code is not the final platform support as is and it's treated as a base to extend, refactor and address issues afterwards. Supported features: - handle software breakpoints, - correctly attach to a tracee, - support NetBSD specific ptrace(2), - monitor process termination, - monitor SIGTRAP events, - monitor SIGSTOP events, - monitor other signals events, - resume the whole process, - get memory region info perms, - read memory from tracee, - write memory to tracee, - read ELF AUXV, - x86_64 GPR read and write code For the generic framework include: - halt, - detach, - signal, - kill, - allocatememory, - deallocatememory, - update threads, - getarchitecture, - getfileloadaddress, - and others. This code has preliminary AddThread code. Out of interest in this patch: - exec() traps, - hardware debug register traps, - single step trap, - thread creation/termination trap, - process fork(2), vfork(2) and vfork(2) done traps, - syscall entry and exit trap, - threads, - FPR registers, - retrieving tracee's thread name, - non x86_64 support. This code can be used to start a hello world application and trace it. This code can be used by other BSD systems as a starting point to get similar capabilities. Sponsored by <The NetBSD Foundation> Reviewers: emaste, joerg, kettenis, labath Subscribers: mgorny, #lldb Tags: #lldb Differential Revision: https://reviews.llvm.org/D31374 llvm-svn: 298953
71 lines
2.2 KiB
C++
71 lines
2.2 KiB
C++
//===-- NativeThreadNetBSD.h ---------------------------------- -*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef liblldb_NativeThreadNetBSD_H_
|
|
#define liblldb_NativeThreadNetBSD_H_
|
|
|
|
#include "lldb/Host/common/NativeThreadProtocol.h"
|
|
|
|
namespace lldb_private {
|
|
namespace process_netbsd {
|
|
|
|
class NativeProcessNetBSD;
|
|
|
|
class NativeThreadNetBSD : public NativeThreadProtocol {
|
|
friend class NativeProcessNetBSD;
|
|
|
|
public:
|
|
NativeThreadNetBSD(NativeProcessNetBSD *process, lldb::tid_t tid);
|
|
|
|
// ---------------------------------------------------------------------
|
|
// NativeThreadProtocol Interface
|
|
// ---------------------------------------------------------------------
|
|
std::string GetName() override;
|
|
|
|
lldb::StateType GetState() override;
|
|
|
|
bool GetStopReason(ThreadStopInfo &stop_info,
|
|
std::string &description) override;
|
|
|
|
NativeRegisterContextSP GetRegisterContext() override;
|
|
|
|
Error SetWatchpoint(lldb::addr_t addr, size_t size, uint32_t watch_flags,
|
|
bool hardware) override;
|
|
|
|
Error RemoveWatchpoint(lldb::addr_t addr) override;
|
|
|
|
Error SetHardwareBreakpoint(lldb::addr_t addr, size_t size) override;
|
|
|
|
Error RemoveHardwareBreakpoint(lldb::addr_t addr) override;
|
|
|
|
private:
|
|
// ---------------------------------------------------------------------
|
|
// Interface for friend classes
|
|
// ---------------------------------------------------------------------
|
|
|
|
void SetStoppedBySignal(uint32_t signo, const siginfo_t *info = nullptr);
|
|
void SetStoppedByBreakpoint();
|
|
void SetStopped();
|
|
void SetRunning();
|
|
|
|
// ---------------------------------------------------------------------
|
|
// Member Variables
|
|
// ---------------------------------------------------------------------
|
|
lldb::StateType m_state;
|
|
ThreadStopInfo m_stop_info;
|
|
NativeRegisterContextSP m_reg_context_sp;
|
|
std::string m_stop_description;
|
|
};
|
|
|
|
typedef std::shared_ptr<NativeThreadNetBSD> NativeThreadNetBSDSP;
|
|
} // namespace process_netbsd
|
|
} // namespace lldb_private
|
|
|
|
#endif // #ifndef liblldb_NativeThreadNetBSD_H_
|