pkgsrc-WIP-changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
lldb-netbsd: Refactor SIGTRAP handling - intial code to support TRAP_EXEC
Module Name: pkgsrc-wip
Committed By: Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By: kamil
Date: Thu Jan 19 04:08:07 2017 +0100
Changeset: b203b2f74ee13e756b5dac8c0f1587bdaf887cc8
Modified Files:
lldb-netbsd/distinfo
lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.cpp
lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.cpp
lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.h
Log Message:
lldb-netbsd: Refactor SIGTRAP handling - intial code to support TRAP_EXEC
Add new functions:
- NativeThreadNetBSD::SetStopped
- NativeThreadNetBSD::SetStoppedByExec
The code properly enters the TRAP_EXEC path in the MonitorCallback function,
when a tracee triggers execve(2).
However LLDB is hanging waiting for more information, for now not determined
what kind of it.
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=b203b2f74ee13e756b5dac8c0f1587bdaf887cc8
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
diffstat:
lldb-netbsd/distinfo | 6 +-
..._Plugins_Process_NetBSD_NativeProcessNetBSD.cpp | 64 ++++++++++++++++------
...e_Plugins_Process_NetBSD_NativeThreadNetBSD.cpp | 21 ++++++-
...rce_Plugins_Process_NetBSD_NativeThreadNetBSD.h | 8 ++-
4 files changed, 74 insertions(+), 25 deletions(-)
diffs:
diff --git a/lldb-netbsd/distinfo b/lldb-netbsd/distinfo
index 40d747f..3f94923 100644
--- a/lldb-netbsd/distinfo
+++ b/lldb-netbsd/distinfo
@@ -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) = 497884c941bbabd7f69e23c2b51ea96145b3a63a
+SHA1 (patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.cpp) = 4b167799f06e78849689db1fd06e2b7021de5f91
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-source_Plugins_Process_NetBSD_NativeThreadNetBSD.cpp) = 7b5525df457a5884e8c5159913a54289feb291ed
+SHA1 (patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.h) = abc9154b9ccafd515def84869ba236387c4ecaa4
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-source_Plugins_Process_NetBSD_NativeProcessNetBSD.cpp b/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.cpp
index 49996a5..64a94b7 100644
--- a/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.cpp
+++ b/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.cpp
@@ -2,7 +2,7 @@ $NetBSD$
--- source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp.orig 2017-01-19 01:40:16.619517153 +0000
+++ source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
-@@ -0,0 +1,1651 @@
+@@ -0,0 +1,1681 @@
+//===-- NativeProcessNetBSD.cpp -------------------------------- -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
@@ -488,18 +488,47 @@ $NetBSD$
+
+ // Get details on the signal raised.
+ if (siginfo_err.Success() && state_err.Success()) {
-+ switch(info.psi_siginfo.si_signo) {
++ switch (info.psi_siginfo.si_signo) {
+ case SIGTRAP:
-+ // breakpoint
-+ if ((info.psi_siginfo.si_code & TRAP_BRKPT) != 0)
++ switch (info.psi_siginfo.si_code) {
++ case TRAP_BRKPT:
+ printf("Breakpoint reported\n");
-+ // single step (and temporarily also hardware watchpoint on x86)
-+ else if ((info.psi_siginfo.si_code & TRAP_TRACE) != 0)
++ break;
++ case TRAP_TRACE:
+ printf("Single step reported\n");
-+ // exec()
-+ else if ((info.psi_siginfo.si_code & TRAP_EXEC) != 0)
-+ printf("exec() reported\n");
-+ else if ((info.psi_siginfo.si_code & TRAP_CHLD) != 0) {
++ break;
++ case TRAP_EXEC:
++ {
++ // Clear old threads
++ m_threads.clear();
++
++ // Initialize new thread
++ struct ptrace_lwpinfo info = {};
++ Error error = PtraceWrapper(PT_LWPINFO, pid, &info, sizeof(info));
++ if (error.Fail()) {
++ SetState(StateType::eStateInvalid);
++ return;
++ }
++
++ // Reinitialize from scratch threads and register them in process
++ while (info.pl_lwpid != 0) {
++ NativeThreadNetBSDSP thread_sp = AddThread(info.pl_lwpid);
++ thread_sp->SetStoppedByExec();
++ error = PtraceWrapper(PT_LWPINFO, pid, &info, sizeof(info));
++ if (error.Fail()) {
++ SetState(StateType::eStateInvalid);
++ return;
++ }
++ }
++
++ // Let our delegate know we have just exec'd.
++ NotifyDidExec();
++
++ SetState(StateType::eStateStopped, true);
++ }
++ break;
++ case TRAP_CHLD:
++ {
+ // fork(2)
+ if ((state.pe_report_event & PTRACE_FORK) != 0)
+ printf("Fork reported\n");
@@ -509,21 +538,22 @@ $NetBSD$
+ // vfork(2) done
+ else if ((state.pe_report_event & PTRACE_VFORK_DONE) != 0)
+ printf("VFork Done reported\n");
-+ } else if ((info.psi_siginfo.si_code & TRAP_LWP) != 0) {
++ }
++ break;
++ case TRAP_LWP:
++ {
+ // _lwp_create(2)
+ if ((state.pe_report_event & PTRACE_LWP_CREATE) != 0)
+ printf("LWP created reported\n");
+ // _lwp_exit(2)
+ if ((state.pe_report_event & PTRACE_LWP_EXIT) != 0)
+ printf("LWP terminated reported\n");
-+ } else if ((info.psi_siginfo.si_code & TRAP_HWWPT) != 0) {
-+ // hardware watchpoint
++ }
++ break;
++ case TRAP_HWWPT:
+ printf("hw watchpoint reported\n");
++ break;
+ }
-+ // Unknown
-+ else
-+ printf("Unknown event for SIGTRAP\n");
-+ break;
+ case SIGSTOP:
+ // Handle SIGSTOP from LLGS (LLDB GDB Server)
+ if (info.psi_siginfo.si_code == SI_USER && info.psi_siginfo.si_pid == ::getpid()) {
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 832539c..82a9e4a 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 05:32:46.180058637 +0000
+--- source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp.orig 2017-01-19 01:40:16.657343698 +0000
+++ source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
-@@ -0,0 +1,340 @@
+@@ -0,0 +1,355 @@
+//===-- NativeThreadNetBSD.cpp --------------------------------- -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
@@ -166,7 +166,7 @@ $NetBSD$
+ const siginfo_t *info) {
+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
+ if (log)
-+ log->Printf("NativeThreadLinux::%s called with signal %s (value 0x%02" PRIx32 ")",
++ log->Printf("NativeThreadNetBSD::%s called with signal %s (value 0x%02" PRIx32 ")",
+ __FUNCTION__, strsignal(signo), signo);
+
+ m_state = eStateStopped;
@@ -337,6 +337,21 @@ $NetBSD$
+ m_stop_description = stringStream.str();
+}
+
++void NativeThreadNetBSD::SetStopped() {
++ const StateType new_state = StateType::eStateStopped;
++ m_state = new_state;
++ m_stop_description.clear();
++}
++
++void NativeThreadNetBSD::SetStoppedByExec() {
++ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
++ if (log)
++ log->Printf("NativeThreadNetBSD::%s()", __FUNCTION__);
++ SetStopped();
++ m_stop_info.reason = StopReason::eStopReasonExec;
++ m_stop_info.details.signal.signo = SIGTRAP;
++}
++
+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 244573a..c3d899d 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 05:32:46.186458822 +0000
+--- source/Plugins/Process/NetBSD/NativeThreadNetBSD.h.orig 2017-01-19 01:40:16.675674059 +0000
+++ source/Plugins/Process/NetBSD/NativeThreadNetBSD.h
-@@ -0,0 +1,79 @@
+@@ -0,0 +1,83 @@
+//===-- NativeThreadNetBSD.h ----------------------------------- -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
@@ -63,11 +63,15 @@ $NetBSD$
+
+ void SetStoppedBySignal(uint32_t signo, const siginfo_t *info = nullptr);
+
++ void SetStoppedByExec();
++
+ // ---------------------------------------------------------------------
+ // Private interface
+ // ---------------------------------------------------------------------
+ NativeProcessNetBSD &GetProcess();
+
++ void SetStopped();
++
+ // ---------------------------------------------------------------------
+ // Member Variables
+ // ---------------------------------------------------------------------
Home |
Main Index |
Thread Index |
Old Index