pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

lldb-netbsd: Reintroduce SetStoppedBySignal() in NativeThreadNetBSD



Module Name:	pkgsrc-wip
Committed By:	Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By:	kamil
Date:		Mon Dec 26 09:50:52 2016 +0100
Changeset:	f9cd8c4f659bf6dcd3133b24f00b54a49be9c1ad

Modified Files:
	lldb-netbsd/distinfo
	lldb-netbsd/patches/patch-include_lldb_Host_netbsd_ProcessLauncherNetBSD.h
	lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.cpp
	lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.h
	lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.cpp
	lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.h

Log Message:
lldb-netbsd: Reintroduce SetStoppedBySignal() in NativeThreadNetBSD

In the current design it's required to set per-thread stopped status, as this
data is queried by generic LLDB layers.

This fixed attaching to a process:

(lldb) r
Hello world!
Process 11113 launched: './hello' (x86_64)
Process 11113 exited with status = -1 (0xffffffff) lost connection
(lldb)

Thread has exited abnormally and it has to be addressed now.

While there, implement NetBSD specific siginfo(2) interfaces in
SetStoppedBySignal(). Currently this code cannot be reused as there is no
trivial way to query siginfo_t of tracee.

Sponsored by <The NetBSD Foundation>

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=f9cd8c4f659bf6dcd3133b24f00b54a49be9c1ad

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 lldb-netbsd/distinfo                               |  10 +-
 ...nclude_lldb_Host_netbsd_ProcessLauncherNetBSD.h |   2 +-
 ..._Plugins_Process_NetBSD_NativeProcessNetBSD.cpp |   9 +-
 ...ce_Plugins_Process_NetBSD_NativeProcessNetBSD.h |   2 +-
 ...e_Plugins_Process_NetBSD_NativeThreadNetBSD.cpp | 183 ++++++++++++++++++++-
 ...rce_Plugins_Process_NetBSD_NativeThreadNetBSD.h |   6 +-
 6 files changed, 194 insertions(+), 18 deletions(-)

diffs:
diff --git a/lldb-netbsd/distinfo b/lldb-netbsd/distinfo
index 7b4bd45..aef4585 100644
--- a/lldb-netbsd/distinfo
+++ b/lldb-netbsd/distinfo
@@ -15,7 +15,7 @@ Size (llvm-3.6.2.src.tar.xz) = 12802380 bytes
 SHA1 (patch-cmake_LLDBDependencies.cmake) = 81673d8624ca7a9ad60bcaf530587fbfbd695dca
 SHA1 (patch-cmake_modules_AddLLDB.cmake) = 39de9d6ff91641b9c625dbb95c2618f336be28c4
 SHA1 (patch-include_lldb_Host_netbsd_HostThreadNetBSD.h) = 79f207cdb9da2ef57d39eeb307ec6d10cf828925
-SHA1 (patch-include_lldb_Host_netbsd_ProcessLauncherNetBSD.h) = 2da864092aed3f3c212e6760138fb82b4aa5c594
+SHA1 (patch-include_lldb_Host_netbsd_ProcessLauncherNetBSD.h) = fe65d50b595974e69ec9bd331dda30abfd3482dd
 SHA1 (patch-source_CMakeLists.txt) = 5dacabc3f39c23bdfd432b5a4895866157b97aa0
 SHA1 (patch-source_Host_CMakeLists.txt) = b7b5fbf2354e05c33c63bf47ffa1ef58f58727ef
 SHA1 (patch-source_Host_common_Host.cpp) = 4d9b4f9ef3c2600c46e5f5d5f1f11aa59f15e87f
@@ -28,10 +28,10 @@ SHA1 (patch-source_Plugins_Platform_NetBSD_PlatformNetBSD.cpp) = 129e853c1f93f06
 SHA1 (patch-source_Plugins_Platform_NetBSD_PlatformNetBSD.h) = 4327a21e79378b8f35adb07614adb41c37bbaf61
 SHA1 (patch-source_Plugins_Process_CMakeLists.txt) = c0168f81da56d9896eb414e6b8bb7262de04ac33
 SHA1 (patch-source_Plugins_Process_NetBSD_CMakeLists.txt) = df17afdf71c29d945c887e318718904793cd48ad
-SHA1 (patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.cpp) = 6c75f6bf86b434ff7d7bff7623d5994000080642
-SHA1 (patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.h) = 79f932301008b16f60fc77f345c3ec9eeb4dc4c6
-SHA1 (patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.cpp) = 27f4de5eb966e568db284be00c9e740bebe6d95d
-SHA1 (patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.h) = ceeb4e5dbd0d63075cd3fcf95c73ae0caf5ec56a
+SHA1 (patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.cpp) = 69619e6a98078c13c87969a06b2ea488e51fd531
+SHA1 (patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.h) = 063478b318cd6c891a78b0649ae7a16968020abf
+SHA1 (patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.cpp) = a90056d84664722cf7ed21a8b929b2a9adb00564
+SHA1 (patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.h) = 68c7f7976e48275b6554a03da0e55c8bf59ead47
 SHA1 (patch-tools_lldb-mi_MICmnBase.cpp) = 851c82ac61e1241018755fbd7236af00379ac986
 SHA1 (patch-tools_lldb-mi_MICmnBase.h) = f550d5e10bcf02fb46472733acdbb820791f22e5
 SHA1 (patch-tools_lldb-mi_MIDriver.cpp) = bf1b5399e82bcfe54d6d852f64ed155328f2064d
diff --git a/lldb-netbsd/patches/patch-include_lldb_Host_netbsd_ProcessLauncherNetBSD.h b/lldb-netbsd/patches/patch-include_lldb_Host_netbsd_ProcessLauncherNetBSD.h
index 853e436..6dc6481 100644
--- a/lldb-netbsd/patches/patch-include_lldb_Host_netbsd_ProcessLauncherNetBSD.h
+++ b/lldb-netbsd/patches/patch-include_lldb_Host_netbsd_ProcessLauncherNetBSD.h
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- include/lldb/Host/netbsd/ProcessLauncherNetBSD.h.orig	2016-12-26 00:06:01.618251830 +0000
+--- include/lldb/Host/netbsd/ProcessLauncherNetBSD.h.orig	2016-12-26 05:32:46.084693165 +0000
 +++ include/lldb/Host/netbsd/ProcessLauncherNetBSD.h
 @@ -0,0 +1,25 @@
 +//===-- ProcessLauncherNetBSD.h --------------------------------*- C++ -*-===//
diff --git a/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.cpp b/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.cpp
index 8c1013f..85dca20 100644
--- a/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.cpp
+++ b/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.cpp
@@ -1,8 +1,8 @@
 $NetBSD$
 
---- source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp.orig	2016-12-26 00:06:02.274927609 +0000
+--- source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp.orig	2016-12-26 05:32:46.166552242 +0000
 +++ source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
-@@ -0,0 +1,1592 @@
+@@ -0,0 +1,1593 @@
 +//===-- NativeProcessNetBSD.cpp -------------------------------- -*- C++ -*-===//
 +//
 +//                     The LLVM Compiler Infrastructure
@@ -316,7 +316,7 @@ $NetBSD$
 +  // Wait for the child process to trap on its call to execve.
 +  ::pid_t wpid;
 +  int status;
-+  if ((wpid = waitpid(pid, &status, 0)) < 0) {
++  if ((wpid = waitpid( pid, &status, 0)) < 0) {
 +    error.SetErrorToErrno();
 +    if (log)
 +      log->Printf("NativeProcessNetBSD::%s waitpid for inferior failed with %s",
@@ -373,7 +373,8 @@ $NetBSD$
 +    return error;
 +  }
 +  while (info.pl_lwpid != 0) {
-+    AddThread(info.pl_lwpid);
++    NativeThreadNetBSDSP thread_sp = AddThread(info.pl_lwpid);
++    thread_sp->SetStoppedBySignal(SIGSTOP);
 +    error = PtraceWrapper(PT_LWPINFO, pid, &info, sizeof(info));
 +    if (error.Fail()) {
 +      SetState(StateType::eStateInvalid);
diff --git a/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.h b/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.h
index 1d13b5c..0e3042d 100644
--- a/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.h
+++ b/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.h
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- source/Plugins/Process/NetBSD/NativeProcessNetBSD.h.orig	2016-12-26 00:06:02.335419166 +0000
+--- source/Plugins/Process/NetBSD/NativeProcessNetBSD.h.orig	2016-12-26 05:32:46.173568985 +0000
 +++ source/Plugins/Process/NetBSD/NativeProcessNetBSD.h
 @@ -0,0 +1,180 @@
 +//===-- NativeProcessNetBSD.h ---------------------------------- -*- C++ -*-===//
diff --git a/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.cpp b/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.cpp
index d1b7c7b..832539c 100644
--- a/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.cpp
+++ b/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.cpp
@@ -1,8 +1,8 @@
 $NetBSD$
 
---- source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp.orig	2016-12-26 00:06:02.394454741 +0000
+--- source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp.orig	2016-12-26 05:32:46.180058637 +0000
 +++ source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
-@@ -0,0 +1,167 @@
+@@ -0,0 +1,340 @@
 +//===-- NativeThreadNetBSD.cpp --------------------------------- -*- C++ -*-===//
 +//
 +//                     The LLVM Compiler Infrastructure
@@ -31,6 +31,7 @@ $NetBSD$
 +
 +#include <sys/ptrace.h>
 +#include <sys/syscall.h>
++#include <poll.h>
 +
 +using namespace lldb;
 +using namespace lldb_private;
@@ -158,12 +159,184 @@ $NetBSD$
 +  if (signo != LLDB_INVALID_SIGNAL_NUMBER)
 +    data = signo;
 +
-+  // If hardware single-stepping is not supported, we just do a continue. The
-+  // breakpoint on the
-+  // next instruction has been setup in NativeProcessNetBSD::Resume.
 +  return NativeProcessNetBSD::PtraceWrapper(PT_STEP, GetID(), (void *)1, data);
 +}
 +
++void NativeThreadNetBSD::SetStoppedBySignal(uint32_t signo,
++                                            const siginfo_t *info) {
++  Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
++  if (log)
++    log->Printf("NativeThreadLinux::%s called with signal %s (value 0x%02" PRIx32 ")",
++                __FUNCTION__, strsignal(signo), signo);
++
++  m_state = eStateStopped;
++
++  m_stop_info.reason = StopReason::eStopReasonSignal;
++  m_stop_info.details.signal.signo = signo;
++
++  std::ostringstream stringStream;
++
++  if (!info) {
++    stringStream << "The signal " << strsignal(signo) << " was caught";
++    m_stop_description = stringStream.str();
++    return;
++  }
++
++  switch(info->si_code) {
++  case SI_USER:
++    stringStream << "The signal was generated via kill(2) from pid="
++                 << info->si_pid << ", uid=" << info->si_uid;
++    break;
++  case SI_QUEUE:
++    stringStream << "The signal was generated via sigqueue(2)";
++    break;
++  case SI_TIMER:
++    stringStream << "The signal was generated because a timer set by timer_settime(2) has expired"
++                 << " with si_value set to sival_int=" << info->si_value.sival_int << " and "
++                 << "sival_ptr=" << info->si_value.sival_ptr;
++    break;
++  case SI_ASYNCIO:
++    stringStream << "The signal was generated by completion of an asynchronous I/O operation with "
++                 << info->si_fd << " file descriptor number on which the operation was completed "
++                 << " and side and priority of the operation set to ";
++    switch (info->si_band) {
++    case POLLIN | POLLRDNORM:
++      stringStream << "normal read ";
++      break;
++    case POLLPRI | POLLRDNORM:
++      stringStream << "out-of-band read ";
++      break;
++    case POLLOUT | POLLWRNORM:
++      stringStream << "normal write ";
++      break;
++    case POLLPRI | POLLWRBAND:
++      stringStream << "normal write ";
++      break;
++    default:
++      stringStream << "unspecified value ";
++    }
++    stringStream << std::hex << std::showbase << info->si_band;
++  case SI_MESGQ:
++    stringStream << "The signal was generated by arrival of a message on an empty message queue "
++                 << "with si_value set to sival_int=" << info->si_value.sival_int << " and "
++                 << "sival_ptr=" << info->si_value.sival_ptr;
++  case SI_LWP:
++    stringStream << "The signal was generated via _lwp_kill(2) from pid="
++                 << info->si_pid << ", uid=" << info->si_uid;
++    break;
++  case SI_NOINFO:
++    stringStream << "There is no signal specific info available";
++    break;
++  default:
++    switch (info->si_signo) {
++    case SIGTRAP:
++      stringStream << "SIGTRAP has been caught with ";
++      switch (info->si_code) {
++      case TRAP_BRKPT:
++        stringStream << "Process Breakpoint type";
++        break;
++      case TRAP_TRACE:
++        stringStream << "Process Trace Trap type";
++        break;
++      default:
++        stringStream << "unknown si_code value " << std::hex << std::showbase
++                     << info->si_code;
++      }
++      break;
++    case SIGCHLD:
++      stringStream << "SIGCHLD has been caught with ";
++      switch (info->si_code) {
++      case CLD_EXITED:
++        stringStream << "Child Has Exited type";
++        break;
++      case CLD_KILLED:
++        stringStream << "Child Has Terminated Abnormally "
++                        "(without a core file) type";
++        break;
++      case CLD_DUMPED:
++        stringStream << "Child Has Terminated Abnormally "
++                     << "(with a core file) type";
++        break;
++      case CLD_TRAPPED:
++        stringStream << "Child Has Trapped type";
++        break;
++      case CLD_STOPPED:
++        stringStream << "Child Has Stopped type";
++        break;
++      case CLD_CONTINUED:
++        stringStream << "Child Has Continued type";
++        break;
++      default:
++        stringStream << "unknown si_code value " << std::hex << std::showbase
++                     << info->si_code;
++      }
++      stringStream << "with pid=" << std::dec << info->si_pid << " of the process who's status "
++                   << "changed, user id=" << info->si_uid << " of that process, "
++                   << std::hex << std::showbase << ((info->si_code == CLD_EXITED) ?
++                   "exit code of the process " : "signal number received by the process ")
++                   << std::dec << info->si_status << ", user process accounting time "
++                   << info->si_utime << ", system process accounting time " << info->si_stime;
++      break;
++    case SIGIO:
++      stringStream << "SIGIO has been caught with ";
++      switch (info->si_code) {
++      case POLL_IN:
++        stringStream << "Data Input Available type";
++        break;
++      case POLL_OUT:
++        stringStream << "Output Buffers Available type";
++        break;
++      case POLL_MSG:
++        stringStream << "Input Message type";
++        break;
++      case POLL_ERR:
++        stringStream << "I/O Error type";
++        break;
++      case POLL_PRI:
++        stringStream << "High Priority Input Available type";
++        break;
++      case POLL_HUP:
++        stringStream << "Device Disconnected type";
++        break;
++      default:
++        stringStream << "unknown si_code value " << std::hex << std::showbase
++                     << info->si_code;
++      }
++      stringStream << "with " << std::dec << info->si_fd << " file descriptor number on which the "
++                   << "operation was completed and side and priority of the operation set to ";
++      switch (info->si_band) {
++      case POLLIN | POLLRDNORM:
++        stringStream << "normal read ";
++        break;
++      case POLLPRI | POLLRDNORM:
++        stringStream << "out-of-band read ";
++        break;
++      case POLLOUT | POLLWRNORM:
++        stringStream << "normal write ";
++        break;
++      case POLLPRI | POLLWRBAND:
++        stringStream << "normal write ";
++        break;
++      default:
++        stringStream << "unspecified value ";
++      }
++      stringStream << std::hex << std::showbase << info->si_band;
++
++      break;
++    /* The following signals are defined by POSIX common platform code */
++    case SIGSEGV:
++    case SIGBUS:
++    case SIGFPE:
++    case SIGILL:
++      stringStream << GetCrashReasonString(GetCrashReason(*info), *info);
++      break;
++    default:
++      stringStream << "The signal " << strsignal(info->si_signo) << " was caught";
++    }
++  }
++  m_stop_description = stringStream.str();
++}
++
 +NativeProcessNetBSD &NativeThreadNetBSD::GetProcess() {
 +  auto process_sp = std::static_pointer_cast<NativeProcessNetBSD>(
 +      NativeThreadProtocol::GetProcess());
diff --git a/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.h b/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.h
index 2292b6c..244573a 100644
--- a/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.h
+++ b/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.h
@@ -1,8 +1,8 @@
 $NetBSD$
 
---- source/Plugins/Process/NetBSD/NativeThreadNetBSD.h.orig	2016-12-26 00:06:02.439980709 +0000
+--- source/Plugins/Process/NetBSD/NativeThreadNetBSD.h.orig	2016-12-26 05:32:46.186458822 +0000
 +++ source/Plugins/Process/NetBSD/NativeThreadNetBSD.h
-@@ -0,0 +1,77 @@
+@@ -0,0 +1,79 @@
 +//===-- NativeThreadNetBSD.h ----------------------------------- -*- C++ -*-===//
 +//
 +//                     The LLVM Compiler Infrastructure
@@ -61,6 +61,8 @@ $NetBSD$
 +  /// LLDB_INVALID_SIGNAL_NUMBER, deliver that signal to the thread.
 +  Error SingleStep(uint32_t signo);
 +
++  void SetStoppedBySignal(uint32_t signo, const siginfo_t *info = nullptr);
++
 +  // ---------------------------------------------------------------------
 +  // Private interface
 +  // ---------------------------------------------------------------------


Home | Main Index | Thread Index | Old Index