krytarowski created this revision.
krytarowski added a project: LLDB.
Herald added a subscriber: mgorny.

This is the base for introduction of further features to support Process 
Tracing on NetBSD, in local and remote setup.

This code contains stubs of the needed functions. Their bodies will be added in 
next commits.

The layout of functions is not set in stone and can be changed in future, 
however the current one with set of local patches to fill the missing function 
bodies was used to handle functional debugging session.

This code is also a starting point to synchronize the development with other 
BSDs, Currently only NetBSD is ahead and other can catch up.

Sponsored by <The NetBSD Foundation>


Repository:
  rL LLVM

https://reviews.llvm.org/D31138

Files:
  source/Plugins/Process/CMakeLists.txt
  source/Plugins/Process/NetBSD/CMakeLists.txt
  source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
  source/Plugins/Process/NetBSD/NativeProcessNetBSD.h
  source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp
  source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h
  source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
  source/Plugins/Process/NetBSD/NativeThreadNetBSD.h
  tools/lldb-server/CMakeLists.txt

Index: tools/lldb-server/CMakeLists.txt
===================================================================
--- tools/lldb-server/CMakeLists.txt
+++ tools/lldb-server/CMakeLists.txt
@@ -17,6 +17,7 @@
 if ( CMAKE_SYSTEM_NAME MATCHES "NetBSD" )
 include_directories(
   ../../../../llvm/include
+  ../../source/Plugins/Process/NetBSD
   ../../source/Plugins/Process/POSIX
   )
 endif ()
Index: source/Plugins/Process/NetBSD/NativeThreadNetBSD.h
===================================================================
--- /dev/null
+++ source/Plugins/Process/NetBSD/NativeThreadNetBSD.h
@@ -0,0 +1,84 @@
+//===-- 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 SetStoppedByExec();
+
+  void SetStoppedByTrace();
+
+  void SetStoppedByBreakpoint();
+
+  void SetRunning();
+
+  void SetStepping();
+
+  // ---------------------------------------------------------------------
+  // Private interface
+  // ---------------------------------------------------------------------
+  NativeProcessNetBSD &GetProcess();
+
+  void SetStopped();
+
+  // ---------------------------------------------------------------------
+  // 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_
Index: source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
===================================================================
--- /dev/null
+++ source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
@@ -0,0 +1,97 @@
+//===-- NativeThreadNetBSD.cpp -------------------------------- -*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "NativeThreadNetBSD.h"
+#include "NativeRegisterContextNetBSD.h"
+
+#include "NativeProcessNetBSD.h"
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::process_netbsd;
+
+namespace {
+void LogThreadStopInfo(Log &log, const ThreadStopInfo &stop_info,
+                       const char *const header) {}
+} // namespace
+
+NativeThreadNetBSD::NativeThreadNetBSD(NativeProcessNetBSD *process,
+                                       lldb::tid_t tid)
+    : NativeThreadProtocol(process, tid), m_state(StateType::eStateInvalid),
+      m_stop_info(), m_reg_context_sp(), m_stop_description() {}
+
+std::string NativeThreadNetBSD::GetName() { return std::string(); }
+
+lldb::StateType NativeThreadNetBSD::GetState() { return m_state; }
+
+bool NativeThreadNetBSD::GetStopReason(ThreadStopInfo &stop_info,
+                                       std::string &description) {
+  return false;
+}
+
+NativeRegisterContextSP NativeThreadNetBSD::GetRegisterContext() {
+  // Return the register context if we already created it.
+  if (m_reg_context_sp)
+    return m_reg_context_sp;
+
+  NativeProcessProtocolSP m_process_sp = m_process_wp.lock();
+  if (!m_process_sp)
+    return NativeRegisterContextSP();
+
+  ArchSpec target_arch;
+  if (!m_process_sp->GetArchitecture(target_arch))
+    return NativeRegisterContextSP();
+
+  const uint32_t concrete_frame_idx = 0;
+  m_reg_context_sp.reset(
+      NativeRegisterContextNetBSD::CreateHostNativeRegisterContextNetBSD(
+          target_arch, *this, concrete_frame_idx));
+
+  return m_reg_context_sp;
+}
+
+Error NativeThreadNetBSD::SetWatchpoint(lldb::addr_t addr, size_t size,
+                                        uint32_t watch_flags, bool hardware) {
+  return Error();
+}
+
+Error NativeThreadNetBSD::RemoveWatchpoint(lldb::addr_t addr) {
+  return Error();
+}
+
+void NativeThreadNetBSD::SetStoppedBySignal(uint32_t signo,
+                                            const siginfo_t *info) {}
+
+void NativeThreadNetBSD::SetStopped() {}
+
+void NativeThreadNetBSD::SetStoppedByExec() {}
+
+void NativeThreadNetBSD::SetRunning() {}
+
+void NativeThreadNetBSD::SetStepping() {}
+
+void NativeThreadNetBSD::SetStoppedByTrace() {}
+
+void NativeThreadNetBSD::SetStoppedByBreakpoint() {}
+
+NativeProcessNetBSD &NativeThreadNetBSD::GetProcess() {
+  auto process_sp = std::static_pointer_cast<NativeProcessNetBSD>(
+      NativeThreadProtocol::GetProcess());
+  assert(process_sp);
+  return *process_sp;
+}
+
+Error NativeThreadNetBSD::SetHardwareBreakpoint(lldb::addr_t addr,
+                                                size_t size) {
+  return Error();
+}
+
+Error NativeThreadNetBSD::RemoveHardwareBreakpoint(lldb::addr_t addr) {
+  return Error();
+}
Index: source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h
===================================================================
--- /dev/null
+++ source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h
@@ -0,0 +1,76 @@
+//===-- NativeRegisterContextNetBSD.h ---------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef lldb_NativeRegisterContextNetBSD_h
+#define lldb_NativeRegisterContextNetBSD_h
+
+#include "lldb/Host/common/NativeRegisterContextRegisterInfo.h"
+#include "lldb/Host/common/NativeThreadProtocol.h"
+
+#include "Plugins/Process/NetBSD/NativeProcessNetBSD.h"
+
+namespace lldb_private {
+namespace process_netbsd {
+
+class NativeRegisterContextNetBSD : public NativeRegisterContextRegisterInfo {
+public:
+  NativeRegisterContextNetBSD(NativeThreadProtocol &native_thread,
+                              uint32_t concrete_frame_idx,
+                              RegisterInfoInterface *reg_info_interface_p);
+
+  // This function is implemented in the NativeRegisterContextNetBSD_*
+  // subclasses to create a new instance of the host specific
+  // NativeRegisterContextNetBSD. The implementations can't collide as only one
+  // NativeRegisterContextNetBSD_* variant should be compiled into the final
+  // executable.
+  static NativeRegisterContextNetBSD *
+  CreateHostNativeRegisterContextNetBSD(const ArchSpec &target_arch,
+                                        NativeThreadProtocol &native_thread,
+                                        uint32_t concrete_frame_idx);
+
+protected:
+  lldb::ByteOrder GetByteOrder() const;
+
+  virtual Error ReadGPR();
+
+  virtual Error WriteGPR();
+
+  virtual Error ReadFPR();
+
+  virtual Error WriteFPR();
+
+  virtual void *GetGPRBuffer() { return nullptr; }
+
+  virtual size_t GetGPRSize() {
+    return GetRegisterInfoInterface().GetGPRSize();
+  }
+
+  virtual void *GetFPRBuffer() { return nullptr; }
+
+  virtual void *GetDBRBuffer() { return nullptr; }
+
+  virtual size_t GetFPRSize() { return 0; }
+
+  virtual Error DoReadGPR(void *buf);
+
+  virtual Error DoWriteGPR(void *buf);
+
+  virtual Error DoReadFPR(void *buf);
+
+  virtual Error DoWriteFPR(void *buf);
+
+  virtual NativeProcessNetBSD &GetProcess();
+
+  virtual ::pid_t GetProcessPid();
+};
+
+} // namespace process_netbsd
+} // namespace lldb_private
+
+#endif // #ifndef lldb_NativeRegisterContextNetBSD_h
Index: source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp
===================================================================
--- /dev/null
+++ source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp
@@ -0,0 +1,49 @@
+//===-- NativeRegisterContextNetBSD.cpp --------------------------*- C++
+//-*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "NativeRegisterContextNetBSD.h"
+
+using namespace lldb_private;
+using namespace lldb_private::process_netbsd;
+
+NativeRegisterContextNetBSD::NativeRegisterContextNetBSD(
+    NativeThreadProtocol &native_thread, uint32_t concrete_frame_idx,
+    RegisterInfoInterface *reg_info_interface_p)
+    : NativeRegisterContextRegisterInfo(native_thread, concrete_frame_idx,
+                                        reg_info_interface_p) {}
+
+lldb::ByteOrder NativeRegisterContextNetBSD::GetByteOrder() const {
+  return lldb::eByteOrderInvalid;
+}
+
+Error NativeRegisterContextNetBSD::ReadGPR() { return Error(); }
+
+Error NativeRegisterContextNetBSD::WriteGPR() { return Error(); }
+
+Error NativeRegisterContextNetBSD::ReadFPR() { return Error(); }
+
+Error NativeRegisterContextNetBSD::WriteFPR() { return Error(); }
+
+Error NativeRegisterContextNetBSD::DoReadGPR(void *buf) { return Error(); }
+
+Error NativeRegisterContextNetBSD::DoWriteGPR(void *buf) { return Error(); }
+
+Error NativeRegisterContextNetBSD::DoReadFPR(void *buf) { return Error(); }
+
+Error NativeRegisterContextNetBSD::DoWriteFPR(void *buf) { return Error(); }
+
+NativeProcessNetBSD &NativeRegisterContextNetBSD::GetProcess() {
+  auto process_sp =
+      std::static_pointer_cast<NativeProcessNetBSD>(m_thread.GetProcess());
+  assert(process_sp);
+  return *process_sp;
+}
+
+::pid_t NativeRegisterContextNetBSD::GetProcessPid() { return -1; }
Index: source/Plugins/Process/NetBSD/NativeProcessNetBSD.h
===================================================================
--- /dev/null
+++ source/Plugins/Process/NetBSD/NativeProcessNetBSD.h
@@ -0,0 +1,184 @@
+//===-- NativeProcessNetBSD.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_NativeProcessNetBSD_H_
+#define liblldb_NativeProcessNetBSD_H_
+
+// C++ Includes
+
+// Other libraries and framework includes
+
+#include "lldb/Core/ArchSpec.h"
+#include "lldb/Host/FileSpec.h"
+#include "lldb/Target/MemoryRegionInfo.h"
+
+#include "NativeThreadNetBSD.h"
+#include "lldb/Host/common/NativeProcessProtocol.h"
+
+namespace lldb_private {
+class Error;
+class Scalar;
+
+namespace process_netbsd {
+/// @class NativeProcessNetBSD
+/// @brief Manages communication with the inferior (debugee) process.
+///
+/// Upon construction, this class prepares and launches an inferior process for
+/// debugging.
+///
+/// Changes in the inferior process state are broadcasted.
+class NativeProcessNetBSD : public NativeProcessProtocol {
+  friend Error NativeProcessProtocol::Launch(
+      ProcessLaunchInfo &launch_info, NativeDelegate &native_delegate,
+      MainLoop &mainloop, NativeProcessProtocolSP &process_sp);
+
+  friend Error NativeProcessProtocol::Attach(
+      lldb::pid_t pid, NativeProcessProtocol::NativeDelegate &native_delegate,
+      MainLoop &mainloop, NativeProcessProtocolSP &process_sp);
+
+public:
+  // ---------------------------------------------------------------------
+  // NativeProcessProtocol Interface
+  // ---------------------------------------------------------------------
+  Error Resume(const ResumeActionList &resume_actions) override;
+
+  Error Halt() override;
+
+  Error Detach() override;
+
+  Error Signal(int signo) override;
+
+  Error Interrupt() override;
+
+  Error Kill() override;
+
+  Error GetMemoryRegionInfo(lldb::addr_t load_addr,
+                            MemoryRegionInfo &range_info) override;
+
+  Error ReadMemory(lldb::addr_t addr, void *buf, size_t size,
+                   size_t &bytes_read) override;
+
+  Error ReadMemoryWithoutTrap(lldb::addr_t addr, void *buf, size_t size,
+                              size_t &bytes_read) override;
+
+  Error WriteMemory(lldb::addr_t addr, const void *buf, size_t size,
+                    size_t &bytes_written) override;
+
+  Error AllocateMemory(size_t size, uint32_t permissions,
+                       lldb::addr_t &addr) override;
+
+  Error DeallocateMemory(lldb::addr_t addr) override;
+
+  lldb::addr_t GetSharedLibraryInfoAddress() override;
+
+  size_t UpdateThreads() override;
+
+  bool GetArchitecture(ArchSpec &arch) const override;
+
+  Error SetBreakpoint(lldb::addr_t addr, uint32_t size, bool hardware) override;
+
+  void DoStopIDBumped(uint32_t newBumpId) override;
+
+  Error GetLoadedModuleFileSpec(const char *module_path,
+                                FileSpec &file_spec) override;
+
+  Error GetFileLoadAddress(const llvm::StringRef &file_name,
+                           lldb::addr_t &load_addr) override;
+
+  NativeThreadNetBSDSP GetThreadByID(lldb::tid_t id);
+
+  llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
+  GetAuxvData() const override;
+
+  // ---------------------------------------------------------------------
+  // Interface used by NativeRegisterContext-derived classes.
+  // ---------------------------------------------------------------------
+  static Error PtraceWrapper(int req, lldb::pid_t pid, void *addr = nullptr,
+                             int data = 0, int *result = nullptr);
+
+protected:
+  // ---------------------------------------------------------------------
+  // NativeProcessProtocol protected interface
+  // ---------------------------------------------------------------------
+
+  Error
+  GetSoftwareBreakpointTrapOpcode(size_t trap_opcode_size_hint,
+                                  size_t &actual_opcode_size,
+                                  const uint8_t *&trap_opcode_bytes) override;
+
+private:
+  MainLoop::SignalHandleUP m_sigchld_handle;
+  ArchSpec m_arch;
+
+  LazyBool m_supports_mem_region;
+  std::vector<std::pair<MemoryRegionInfo, FileSpec>> m_mem_region_cache;
+
+  lldb::tid_t m_pending_notification_tid;
+
+  // List of thread ids stepping with a breakpoint with the address of
+  // the relevan breakpoint
+  std::map<lldb::tid_t, lldb::addr_t> m_threads_stepping_with_breakpoint;
+
+  // ---------------------------------------------------------------------
+  // Private Instance Methods
+  // ---------------------------------------------------------------------
+  NativeProcessNetBSD();
+
+  Error LaunchInferior(MainLoop &mainloop, ProcessLaunchInfo &launch_info);
+
+  /// Attaches to an existing process.  Forms the
+  /// implementation of Process::DoAttach
+  void AttachToInferior(MainLoop &mainloop, lldb::pid_t pid, Error &error);
+
+  ::pid_t Attach(lldb::pid_t pid, Error &error);
+
+  static Error SetDefaultPtraceOpts(const lldb::pid_t);
+
+  static void *MonitorThread(void *baton);
+
+  void MonitorCallback(lldb::pid_t pid, bool exited, int signal, int status);
+
+  void MonitorSIGTRAP(const siginfo_t &info, NativeThreadNetBSD &thread);
+
+  Error SetupSoftwareSingleStepping(NativeThreadNetBSD &thread);
+
+  bool HasThreadNoLock(lldb::tid_t thread_id);
+
+  NativeThreadNetBSDSP AddThread(lldb::tid_t thread_id);
+
+  Error GetSoftwareBreakpointPCOffset(uint32_t &actual_opcode_size);
+
+  Error FixupBreakpointPCAsNeeded(NativeThreadNetBSD &thread);
+
+  /// Writes a siginfo_t structure corresponding to the given thread ID to the
+  /// memory region pointed to by @p siginfo.
+  Error GetSignalInfo(lldb::tid_t tid, void *siginfo);
+
+  void NotifyThreadDeath(lldb::tid_t tid);
+
+  Error Detach(lldb::tid_t tid);
+
+  // Notify the delegate if all threads have stopped.
+  void SignalIfAllThreadsStopped();
+
+  // Resume the given thread, optionally passing it the given signal. The type
+  // of resume
+  // operation (continue, single-step) depends on the state parameter.
+  Error ResumeThread(NativeThreadNetBSD &thread, lldb::StateType state,
+                     int signo);
+
+  void SigchldHandler();
+
+  Error PopulateMemoryRegionCache();
+};
+
+} // namespace process_netbsd
+} // namespace lldb_private
+
+#endif // #ifndef liblldb_NativeProcessNetBSD_H_
Index: source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
===================================================================
--- /dev/null
+++ source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
@@ -0,0 +1,200 @@
+//===-- NativeProcessNetBSD.cpp ------------------------------- -*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "NativeProcessNetBSD.h"
+
+// C Includes
+
+// C++ Includes
+
+// Other libraries and framework includes
+
+#include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
+
+// System includes - They have to be included after framework includes because
+// they define some
+// macros which collide with variable names in other modules
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::process_netbsd;
+using namespace llvm;
+
+namespace {
+void MaybeLogLaunchInfo(const ProcessLaunchInfo &info) {}
+
+void DisplayBytes(StreamString &s, void *bytes, uint32_t count) {}
+
+void PtraceDisplayBytes(int &req, void *addr, int data) {}
+
+} // end of anonymous namespace
+
+// -----------------------------------------------------------------------------
+// Public Static Methods
+// -----------------------------------------------------------------------------
+
+Error NativeProcessProtocol::Launch(
+    ProcessLaunchInfo &launch_info,
+    NativeProcessProtocol::NativeDelegate &native_delegate, MainLoop &mainloop,
+    NativeProcessProtocolSP &native_process_sp) {
+  return Error();
+}
+
+Error NativeProcessProtocol::Attach(
+    lldb::pid_t pid, NativeProcessProtocol::NativeDelegate &native_delegate,
+    MainLoop &mainloop, NativeProcessProtocolSP &native_process_sp) {
+  return Error();
+}
+
+// -----------------------------------------------------------------------------
+// Public Instance Methods
+// -----------------------------------------------------------------------------
+
+NativeProcessNetBSD::NativeProcessNetBSD()
+    : NativeProcessProtocol(LLDB_INVALID_PROCESS_ID), m_arch(),
+      m_supports_mem_region(eLazyBoolCalculate), m_mem_region_cache(),
+      m_pending_notification_tid(LLDB_INVALID_THREAD_ID) {}
+
+void NativeProcessNetBSD::AttachToInferior(MainLoop &mainloop, lldb::pid_t pid,
+                                           Error &error) {}
+
+Error NativeProcessNetBSD::LaunchInferior(MainLoop &mainloop,
+                                          ProcessLaunchInfo &launch_info) {
+  return Error();
+}
+
+::pid_t NativeProcessNetBSD::Attach(lldb::pid_t pid, Error &error) {
+  return -1;
+}
+
+Error NativeProcessNetBSD::SetDefaultPtraceOpts(lldb::pid_t pid) {
+  return Error();
+}
+
+// Handles all waitpid events from the inferior process.
+void NativeProcessNetBSD::MonitorCallback(lldb::pid_t pid, bool exited,
+                                          int signal, int status) {}
+
+Error NativeProcessNetBSD::Resume(const ResumeActionList &resume_actions) {
+  return Error();
+}
+
+Error NativeProcessNetBSD::Halt() { return Error(); }
+
+Error NativeProcessNetBSD::Detach() { return Error(); }
+
+Error NativeProcessNetBSD::Signal(int signo) { return Error(); }
+
+Error NativeProcessNetBSD::Interrupt() { return Error(); }
+
+Error NativeProcessNetBSD::Kill() { return Error(); }
+
+Error NativeProcessNetBSD::GetMemoryRegionInfo(lldb::addr_t load_addr,
+                                               MemoryRegionInfo &range_info) {
+  return Error();
+}
+
+Error NativeProcessNetBSD::PopulateMemoryRegionCache() { return Error(); }
+
+Error NativeProcessNetBSD::AllocateMemory(size_t size, uint32_t permissions,
+                                          lldb::addr_t &addr) {
+  return Error();
+}
+
+Error NativeProcessNetBSD::DeallocateMemory(lldb::addr_t addr) {
+  return Error("not implemented");
+}
+
+lldb::addr_t NativeProcessNetBSD::GetSharedLibraryInfoAddress() {
+  return LLDB_INVALID_ADDRESS;
+}
+
+size_t NativeProcessNetBSD::UpdateThreads() { return 0; }
+
+bool NativeProcessNetBSD::GetArchitecture(ArchSpec &arch) const {
+  arch = m_arch;
+  return true;
+}
+
+Error NativeProcessNetBSD::FixupBreakpointPCAsNeeded(
+    NativeThreadNetBSD &thread) {
+  return Error();
+}
+
+Error NativeProcessNetBSD::SetBreakpoint(lldb::addr_t addr, uint32_t size,
+                                         bool hardware) {
+  return Error();
+}
+
+Error NativeProcessNetBSD::GetSoftwareBreakpointTrapOpcode(
+    size_t trap_opcode_size_hint, size_t &actual_opcode_size,
+    const uint8_t *&trap_opcode_bytes) {
+  return Error();
+}
+
+Error NativeProcessNetBSD::GetSoftwareBreakpointPCOffset(
+    uint32_t &actual_opcode_size) {
+  return Error();
+}
+
+Error NativeProcessNetBSD::ReadMemory(lldb::addr_t addr, void *buf, size_t size,
+                                      size_t &bytes_read) {
+  return Error();
+}
+
+Error NativeProcessNetBSD::ReadMemoryWithoutTrap(lldb::addr_t addr, void *buf,
+                                                 size_t size,
+                                                 size_t &bytes_read) {
+  return Error();
+}
+
+Error NativeProcessNetBSD::WriteMemory(lldb::addr_t addr, const void *buf,
+                                       size_t size, size_t &bytes_written) {
+  return Error();
+}
+
+bool NativeProcessNetBSD::HasThreadNoLock(lldb::tid_t thread_id) {
+  return false;
+}
+
+NativeThreadNetBSDSP NativeProcessNetBSD::AddThread(lldb::tid_t thread_id) {
+  auto thread_sp = std::make_shared<NativeThreadNetBSD>(this, thread_id);
+  m_threads.push_back(thread_sp);
+  return thread_sp;
+}
+
+Error NativeProcessNetBSD::GetLoadedModuleFileSpec(const char *module_path,
+                                                   FileSpec &file_spec) {
+  return Error();
+}
+
+Error NativeProcessNetBSD::GetFileLoadAddress(const llvm::StringRef &file_name,
+                                              lldb::addr_t &load_addr) {
+  return Error();
+}
+
+NativeThreadNetBSDSP NativeProcessNetBSD::GetThreadByID(lldb::tid_t tid) {
+  return std::static_pointer_cast<NativeThreadNetBSD>(
+      NativeProcessProtocol::GetThreadByID(tid));
+}
+
+llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
+NativeProcessNetBSD::GetAuxvData() const {}
+
+//===----------------------------------------------------------------------===//
+
+void NativeProcessNetBSD::SigchldHandler() {}
+
+// Wrapper for ptrace to catch errors and log calls.
+// Note that ptrace sets errno on error because -1 can be a valid result (i.e.
+// for PT_READ*)
+Error NativeProcessNetBSD::PtraceWrapper(int req, lldb::pid_t pid, void *addr,
+                                         int data, int *result) {
+  return Error();
+}
Index: source/Plugins/Process/NetBSD/CMakeLists.txt
===================================================================
--- /dev/null
+++ source/Plugins/Process/NetBSD/CMakeLists.txt
@@ -0,0 +1,20 @@
+include_directories(.)
+include_directories(../POSIX)
+include_directories(../Utility)
+
+add_lldb_library(lldbPluginProcessNetBSD PLUGIN
+  NativeProcessNetBSD.cpp
+  NativeRegisterContextNetBSD.cpp
+  NativeThreadNetBSD.cpp
+
+  LINK_LIBS
+    lldbCore
+    lldbHost
+    lldbSymbol
+    lldbTarget
+    lldbUtility
+    lldbPluginProcessPOSIX
+    lldbPluginProcessUtility
+  LINK_COMPONENTS
+    Support
+  )
Index: source/Plugins/Process/CMakeLists.txt
===================================================================
--- source/Plugins/Process/CMakeLists.txt
+++ source/Plugins/Process/CMakeLists.txt
@@ -5,6 +5,7 @@
   add_subdirectory(FreeBSD)
   add_subdirectory(POSIX)
 elseif (CMAKE_SYSTEM_NAME MATCHES "NetBSD")
+  add_subdirectory(NetBSD)
   add_subdirectory(POSIX)
 elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
   add_subdirectory(Windows/Common)
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to