Commit ab8a7a29 authored by Kamil Rytarowski's avatar Kamil Rytarowski
Browse files

[lldb] Adapt for NetBSD-9.99.30 ptrace(2) API changes

Switch from PT_LWPINFO to PT_LWPSTATUS/PT_LWPNEXT.

Keep compat support for < 9.99.30.

No functional change intended.
parent 4b8232d4
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -914,15 +914,23 @@ Status NativeProcessNetBSD::ReinitializeThreads() {
  m_threads.clear();

  // Initialize new thread
#ifdef PT_LWPSTATUS
  struct ptrace_lwpstatus info = {};
  int op = PT_LWPNEXT;
#else
  struct ptrace_lwpinfo info = {};
  Status error = PtraceWrapper(PT_LWPINFO, GetID(), &info, sizeof(info));
  int op = PT_LWPINFO;
#endif

  Status error = PtraceWrapper(op, GetID(), &info, sizeof(info));

  if (error.Fail()) {
    return error;
  }
  // Reinitialize from scratch threads and register them in process
  while (info.pl_lwpid != 0) {
    AddThread(info.pl_lwpid);
    error = PtraceWrapper(PT_LWPINFO, GetID(), &info, sizeof(info));
    error = PtraceWrapper(op, GetID(), &info, sizeof(info));
    if (error.Fail()) {
      return error;
    }
+11 −0
Original line number Diff line number Diff line
@@ -158,6 +158,16 @@ void NativeThreadNetBSD::SetStepping() {
std::string NativeThreadNetBSD::GetName() {
  Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD));

#ifdef PT_LWPSTATUS
  struct ptrace_lwpstatus info = {};
  info.pl_lwpid = m_tid;
  Status error = NativeProcessNetBSD::PtraceWrapper(
      PT_LWPSTATUS, static_cast<int>(m_process.GetID()), &info, sizeof(info));
  if (error.Fail()) {
    return "";
  }
  return info.pl_name;
#else
  std::vector<struct kinfo_lwp> infos;
  int mib[5] = {CTL_KERN, KERN_LWP, static_cast<int>(m_process.GetID()),
                sizeof(struct kinfo_lwp), 0};
@@ -186,6 +196,7 @@ std::string NativeThreadNetBSD::GetName() {

  LLDB_LOG(log, "unable to find lwp {0} in LWP infos", m_tid);
  return "";
#endif
}

lldb::StateType NativeThreadNetBSD::GetState() { return m_state; }