pkgsrc-WIP-changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
lldb-netbsd: Remove more unused code
Module Name: pkgsrc-wip
Committed By: Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By: kamil
Date: Sun Dec 18 00:13:37 2016 +0100
Changeset: e517bed1f6c990528b96de32d688d9e3a81c50ff
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
Log Message:
lldb-netbsd: Remove more unused code
Killed:
- TRAP_HWBKPT redefinition -- currently Linux specific
- kill GetSignalInfo() - reading siginfo_t from tracee not supported
- kill remnants from PT_STEP walkaround for arm64
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=e517bed1f6c990528b96de32d688d9e3a81c50ff
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
diffstat:
lldb-netbsd/distinfo | 4 +-
..._Plugins_Process_NetBSD_NativeProcessNetBSD.cpp | 619 +--------------------
...e_Plugins_Process_NetBSD_NativeThreadNetBSD.cpp | 54 +-
3 files changed, 4 insertions(+), 673 deletions(-)
diffs:
diff --git a/lldb-netbsd/distinfo b/lldb-netbsd/distinfo
index 27913f3..a946e44 100644
--- a/lldb-netbsd/distinfo
+++ b/lldb-netbsd/distinfo
@@ -18,13 +18,13 @@ SHA1 (patch-include_lldb_Host_netbsd_Ptrace.h) = 3ef61ded004c2acb81e132dc0e46d0a
SHA1 (patch-source_CMakeLists.txt) = 5dacabc3f39c23bdfd432b5a4895866157b97aa0
SHA1 (patch-source_Plugins_Process_CMakeLists.txt) = c0168f81da56d9896eb414e6b8bb7262de04ac33
SHA1 (patch-source_Plugins_Process_NetBSD_CMakeLists.txt) = 8c1d8274523f6ef4bce90caa6c981160ef930cb9
-SHA1 (patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.cpp) = d0cc6c3a5761e983cc3747dd05222fb473a75445
+SHA1 (patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.cpp) = 6daf733dbf5715c9909daac3dfe499e8e4e13ce3
SHA1 (patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.h) = 11641e9c3a5fdf4d9feb098c9c0bb2d9e05aa274
SHA1 (patch-source_Plugins_Process_NetBSD_NativeRegisterContextNetBSD.cpp) = cf569f95362538af5a2709aab9ff61770744a78d
SHA1 (patch-source_Plugins_Process_NetBSD_NativeRegisterContextNetBSD.h) = 558e8514b2a8f0595c0e375f308c53d8a9a6e9f1
SHA1 (patch-source_Plugins_Process_NetBSD_NativeRegisterContextNetBSD__x86__64.cpp) = d372b0b6d8063f88dc1a48e3e457cc12e2864e18
SHA1 (patch-source_Plugins_Process_NetBSD_NativeRegisterContextNetBSD__x86__64.h) = b92d756199555c2ba890afa383808ec094266cf1
-SHA1 (patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.cpp) = ef75b910fd7125ce5ed79b453ef5c304282e88a5
+SHA1 (patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.cpp) = 9beda569915c550be6a3369000aa3687e18ceedb
SHA1 (patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.h) = 9ed9cd17600e661c7fc0e53a3ecb4db91fb62566
SHA1 (patch-source_Plugins_Process_NetBSD_ProcFileReader.cpp) = dff1193e16aa79d8a577a3db4a9056521911d6f1
SHA1 (patch-source_Plugins_Process_NetBSD_ProcFileReader.h) = c8393049c7303b466d3ce98ec5581a3155b71aff
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 c926ec4..866c7fa 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 2016-12-17 13:23:23.782610208 +0000
+++ source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
-@@ -0,0 +1,2630 @@
+@@ -0,0 +1,2013 @@
+//===-- NativeProcessNetBSD.cpp -------------------------------- -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
@@ -63,11 +63,6 @@ $NetBSD$
+
+#include "lldb/Host/netbsd/Ptrace.h"
+
-+// Support hardware breakpoints in case it has not been defined
-+#ifndef TRAP_HWBKPT
-+#define TRAP_HWBKPT 4
-+#endif
-+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::process_netbsd;
@@ -564,117 +559,6 @@ $NetBSD$
+ }
+ return;
+ }
-+
-+ siginfo_t info;
-+ const auto info_err = GetSignalInfo(pid, &info);
-+ auto thread_sp = GetThreadByID(pid);
-+
-+ if (!thread_sp) {
-+ // Normally, the only situation when we cannot find the thread is if we have
-+ // just
-+ // received a new thread notification. This is indicated by GetSignalInfo()
-+ // returning
-+ // si_code == SI_USER and si_pid == 0
-+ if (log)
-+ log->Printf("NativeProcessNetBSD::%s received notification about an "
-+ "unknown tid %" PRIu64 ".",
-+ __FUNCTION__, pid);
-+
-+ if (info_err.Fail()) {
-+ if (log)
-+ log->Printf("NativeProcessNetBSD::%s (tid %" PRIu64
-+ ") GetSignalInfo failed (%s). Ingoring this notification.",
-+ __FUNCTION__, pid, info_err.AsCString());
-+ return;
-+ }
-+
-+ if (log && (info.si_code != SI_USER || info.si_pid != 0))
-+ log->Printf("NativeProcessNetBSD::%s (tid %" PRIu64
-+ ") unexpected signal info (si_code: %d, si_pid: %d). "
-+ "Treating as a new thread notification anyway.",
-+ __FUNCTION__, pid, info.si_code, info.si_pid);
-+
-+ auto thread_sp = AddThread(pid);
-+ // Resume the newly created thread.
-+ ResumeThread(*thread_sp, eStateRunning, LLDB_INVALID_SIGNAL_NUMBER);
-+ ThreadWasCreated(*thread_sp);
-+ return;
-+ }
-+
-+ // Get details on the signal raised.
-+ if (info_err.Success()) {
-+ // We have retrieved the signal info. Dispatch appropriately.
-+ if (info.si_signo == SIGTRAP)
-+ MonitorSIGTRAP(info, *thread_sp);
-+ else
-+ MonitorSignal(info, *thread_sp, exited);
-+ } else {
-+ if (info_err.GetError() == EINVAL) {
-+ // This is a group stop reception for this tid.
-+ // We can reach here if we reinject SIGSTOP, SIGSTP, SIGTTIN or SIGTTOU
-+ // into the
-+ // tracee, triggering the group-stop mechanism. Normally receiving these
-+ // would stop
-+ // the process, pending a SIGCONT. Simulating this state in a debugger is
-+ // hard and is
-+ // generally not needed (one use case is debugging background task being
-+ // managed by a
-+ // shell). For general use, it is sufficient to stop the process in a
-+ // signal-delivery
-+ // stop which happens before the group stop. This done by MonitorSignal
-+ // and works
-+ // correctly for all signals.
-+ if (log)
-+ log->Printf(
-+ "NativeProcessNetBSD::%s received a group stop for pid %" PRIu64
-+ " tid %" PRIu64 ". Transparent handling of group stops not "
-+ "supported, resuming the thread.",
-+ __FUNCTION__, GetID(), pid);
-+ ResumeThread(*thread_sp, thread_sp->GetState(),
-+ LLDB_INVALID_SIGNAL_NUMBER);
-+ } else {
-+ // ptrace(GETSIGINFO) failed (but not due to group-stop).
-+
-+ // A return value of ESRCH means the thread/process is no longer on the
-+ // system,
-+ // so it was killed somehow outside of our control. Either way, we can't
-+ // do anything
-+ // with it anymore.
-+
-+ // Stop tracking the metadata for the thread since it's entirely off the
-+ // system now.
-+ const bool thread_found = StopTrackingThread(pid);
-+
-+ if (log)
-+ log->Printf(
-+ "NativeProcessNetBSD::%s GetSignalInfo failed: %s, tid = %" PRIu64
-+ ", signal = %d, status = %d (%s, %s, %s)",
-+ __FUNCTION__, info_err.AsCString(), pid, signal, status,
-+ info_err.GetError() == ESRCH ? "thread/process killed"
-+ : "unknown reason",
-+ is_main_thread ? "is main thread" : "is not main thread",
-+ thread_found ? "thread metadata removed"
-+ : "thread metadata not found");
-+
-+ if (is_main_thread) {
-+ // Notify the delegate - our process is not available but appears to
-+ // have been killed outside
-+ // our control. Is eStateExited the right exit state in this case?
-+ SetExitStatus(convert_pid_status_to_exit_type(status),
-+ convert_pid_status_to_return_code(status), nullptr, true);
-+ SetState(StateType::eStateExited, true);
-+ } else {
-+ // This thread was pulled out from underneath us. Anything to do here?
-+ // Do we want to do an all stop?
-+ if (log)
-+ log->Printf("NativeProcessNetBSD::%s pid %" PRIu64 " tid %" PRIu64
-+ " non-main thread exit occurred, didn't tell delegate "
-+ "anything since thread disappeared out from underneath "
-+ "us",
-+ __FUNCTION__, GetID(), pid);
-+ }
-+ }
-+ }
+}
+
+void NativeProcessNetBSD::WaitForNewThread(::pid_t tid) {
@@ -723,30 +607,6 @@ $NetBSD$
+ return;
+ }
+
-+ siginfo_t info;
-+ Error error = GetSignalInfo(tid, &info);
-+ if (error.Fail()) {
-+ if (log)
-+ log->Printf(
-+ "NativeProcessNetBSD::%s() GetSignalInfo for tid %" PRIu32
-+ " failed. Assuming the thread has disappeared in the meantime.",
-+ __FUNCTION__, tid);
-+ return;
-+ }
-+
-+ if (((info.si_pid != 0) || (info.si_code != SI_USER)) && log) {
-+ // We should be getting a thread creation signal here, but we received
-+ // something
-+ // else. There isn't much we can do about it now, so we will just log that.
-+ // Since the
-+ // thread is alive and we are receiving events from it, we shall pretend
-+ // that it was
-+ // created properly.
-+ log->Printf("NativeProcessNetBSD::%s() GetSignalInfo for tid %" PRIu32
-+ " received unexpected signal with code %d from pid %d.",
-+ __FUNCTION__, tid, info.si_code, info.si_pid);
-+ }
-+
+ if (log)
+ log->Printf("NativeProcessNetBSD::%s() pid = %" PRIu64
+ ": tracking new thread tid %" PRIu32,
@@ -757,218 +617,6 @@ $NetBSD$
+ ThreadWasCreated(*new_thread_sp);
+}
+
-+void NativeProcessNetBSD::MonitorSIGTRAP(const siginfo_t &info,
-+ NativeThreadNetBSD &thread) {
-+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
-+ const bool is_main_thread = (thread.GetID() == GetID());
-+
-+ assert(info.si_signo == SIGTRAP && "Unexpected child signal!");
-+
-+ switch (info.si_code) {
-+ // TODO: these two cases are required if we want to support tracing of the
-+ // inferiors' children. We'd need this to debug a monitor.
-+ // case (SIGTRAP | (PTRACE_EVENT_FORK << 8)):
-+ // case (SIGTRAP | (PTRACE_EVENT_VFORK << 8)):
-+
-+ case (SIGTRAP | (PTRACE_EVENT_CLONE << 8)): {
-+ // This is the notification on the parent thread which informs us of new
-+ // thread
-+ // creation.
-+ // We don't want to do anything with the parent thread so we just resume it.
-+ // In case we
-+ // want to implement "break on thread creation" functionality, we would need
-+ // to stop
-+ // here.
-+
-+ unsigned long event_message = 0;
-+ if (GetEventMessage(thread.GetID(), &event_message).Fail()) {
-+ if (log)
-+ log->Printf("NativeProcessNetBSD::%s() pid %" PRIu64
-+ " received thread creation event but GetEventMessage "
-+ "failed so we don't know the new tid",
-+ __FUNCTION__, thread.GetID());
-+ } else
-+ WaitForNewThread(event_message);
-+
-+ ResumeThread(thread, thread.GetState(), LLDB_INVALID_SIGNAL_NUMBER);
-+ break;
-+ }
-+
-+ case (SIGTRAP | (PTRACE_EVENT_EXEC << 8)): {
-+ NativeThreadNetBSDSP main_thread_sp;
-+ if (log)
-+ log->Printf("NativeProcessNetBSD::%s() received exec event, code = %d",
-+ __FUNCTION__, info.si_code ^ SIGTRAP);
-+
-+ // Exec clears any pending notifications.
-+ m_pending_notification_tid = LLDB_INVALID_THREAD_ID;
-+
-+ // Remove all but the main thread here. NetBSD fork creates a new process
-+ // which only copies the main thread.
-+ if (log)
-+ log->Printf("NativeProcessNetBSD::%s exec received, stop tracking all but "
-+ "main thread",
-+ __FUNCTION__);
-+
-+ for (auto thread_sp : m_threads) {
-+ const bool is_main_thread = thread_sp && thread_sp->GetID() == GetID();
-+ if (is_main_thread) {
-+ main_thread_sp = std::static_pointer_cast<NativeThreadNetBSD>(thread_sp);
-+ if (log)
-+ log->Printf(
-+ "NativeProcessNetBSD::%s found main thread with tid %" PRIu64
-+ ", keeping",
-+ __FUNCTION__, main_thread_sp->GetID());
-+ } else {
-+ if (log)
-+ log->Printf(
-+ "NativeProcessNetBSD::%s discarding non-main-thread tid %" PRIu64
-+ " due to exec",
-+ __FUNCTION__, thread_sp->GetID());
-+ }
-+ }
-+
-+ m_threads.clear();
-+
-+ if (main_thread_sp) {
-+ m_threads.push_back(main_thread_sp);
-+ SetCurrentThreadID(main_thread_sp->GetID());
-+ main_thread_sp->SetStoppedByExec();
-+ } else {
-+ SetCurrentThreadID(LLDB_INVALID_THREAD_ID);
-+ if (log)
-+ log->Printf("NativeProcessNetBSD::%s pid %" PRIu64
-+ "no main thread found, discarded all threads, we're in a "
-+ "no-thread state!",
-+ __FUNCTION__, GetID());
-+ }
-+
-+ // Tell coordinator about about the "new" (since exec) stopped main thread.
-+ ThreadWasCreated(*main_thread_sp);
-+
-+ // Let our delegate know we have just exec'd.
-+ NotifyDidExec();
-+
-+ // If we have a main thread, indicate we are stopped.
-+ assert(main_thread_sp && "exec called during ptraced process but no main "
-+ "thread metadata tracked");
-+
-+ // Let the process know we're stopped.
-+ StopRunningThreads(main_thread_sp->GetID());
-+
-+ break;
-+ }
-+
-+ case (SIGTRAP | (PTRACE_EVENT_EXIT << 8)): {
-+ // The inferior process or one of its threads is about to exit.
-+ // We don't want to do anything with the thread so we just resume it. In
-+ // case we
-+ // want to implement "break on thread exit" functionality, we would need to
-+ // stop
-+ // here.
-+
-+ unsigned long data = 0;
-+ if (GetEventMessage(thread.GetID(), &data).Fail())
-+ data = -1;
-+
-+ if (log) {
-+ log->Printf("NativeProcessNetBSD::%s() received PTRACE_EVENT_EXIT, data = "
-+ "%lx (WIFEXITED=%s,WIFSIGNALED=%s), pid = %" PRIu64 " (%s)",
-+ __FUNCTION__, data, WIFEXITED(data) ? "true" : "false",
-+ WIFSIGNALED(data) ? "true" : "false", thread.GetID(),
-+ is_main_thread ? "is main thread" : "not main thread");
-+ }
-+
-+ if (is_main_thread) {
-+ SetExitStatus(convert_pid_status_to_exit_type(data),
-+ convert_pid_status_to_return_code(data), nullptr, true);
-+ }
-+
-+ StateType state = thread.GetState();
-+ if (!StateIsRunningState(state)) {
-+ // Due to a kernel bug, we may sometimes get this stop after the inferior
-+ // gets a
-+ // SIGKILL. This confuses our state tracking logic in ResumeThread(),
-+ // since normally,
-+ // we should not be receiving any ptrace events while the inferior is
-+ // stopped. This
-+ // makes sure that the inferior is resumed and exits normally.
-+ state = eStateRunning;
-+ }
-+ ResumeThread(thread, state, LLDB_INVALID_SIGNAL_NUMBER);
-+
-+ break;
-+ }
-+
-+ case 0:
-+ case TRAP_TRACE: // We receive this on single stepping.
-+ case TRAP_HWBKPT: // We receive this on watchpoint hit
-+ {
-+ // If a watchpoint was hit, report it
-+ uint32_t wp_index;
-+ Error error = thread.GetRegisterContext()->GetWatchpointHitIndex(
-+ wp_index, (uintptr_t)info.si_addr);
-+ if (error.Fail() && log)
-+ log->Printf("NativeProcessNetBSD::%s() "
-+ "received error while checking for watchpoint hits, "
-+ "pid = %" PRIu64 " error = %s",
-+ __FUNCTION__, thread.GetID(), error.AsCString());
-+ if (wp_index != LLDB_INVALID_INDEX32) {
-+ MonitorWatchpoint(thread, wp_index);
-+ break;
-+ }
-+
-+ // Otherwise, report step over
-+ MonitorTrace(thread);
-+ break;
-+ }
-+
-+ case SI_KERNEL:
-+#if defined __mips__
-+ // For mips there is no special signal for watchpoint
-+ // So we check for watchpoint in kernel trap
-+ {
-+ // If a watchpoint was hit, report it
-+ uint32_t wp_index;
-+ Error error = thread.GetRegisterContext()->GetWatchpointHitIndex(
-+ wp_index, LLDB_INVALID_ADDRESS);
-+ if (error.Fail() && log)
-+ log->Printf("NativeProcessNetBSD::%s() "
-+ "received error while checking for watchpoint hits, "
-+ "pid = %" PRIu64 " error = %s",
-+ __FUNCTION__, thread.GetID(), error.AsCString());
-+ if (wp_index != LLDB_INVALID_INDEX32) {
-+ MonitorWatchpoint(thread, wp_index);
-+ break;
-+ }
-+ }
-+// NO BREAK
-+#endif
-+ case TRAP_BRKPT:
-+ MonitorBreakpoint(thread);
-+ break;
-+
-+ case SIGTRAP:
-+ case (SIGTRAP | 0x80):
-+ if (log)
-+ log->Printf("NativeProcessNetBSD::%s() received unknown SIGTRAP system "
-+ "call stop event, pid %" PRIu64 "tid %" PRIu64 ", resuming",
-+ __FUNCTION__, GetID(), thread.GetID());
-+
-+ // Ignore these signals until we know more about them.
-+ ResumeThread(thread, thread.GetState(), LLDB_INVALID_SIGNAL_NUMBER);
-+ break;
-+
-+ default:
-+ assert(false && "Unexpected SIGTRAP code!");
-+ if (log)
-+ log->Printf("NativeProcessNetBSD::%s() pid %" PRIu64 "tid %" PRIu64
-+ " received unhandled SIGTRAP code: 0x%d",
-+ __FUNCTION__, GetID(), thread.GetID(), info.si_code);
-+ break;
-+ }
-+}
-+
+void NativeProcessNetBSD::MonitorTrace(NativeThreadNetBSD &thread) {
+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
+ if (log)
@@ -1023,118 +671,6 @@ $NetBSD$
+ StopRunningThreads(thread.GetID());
+}
+
-+void NativeProcessNetBSD::MonitorSignal(const siginfo_t &info,
-+ NativeThreadNetBSD &thread, bool exited) {
-+ const int signo = info.si_signo;
-+ const bool is_from_llgs = info.si_pid == getpid();
-+
-+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
-+
-+ // POSIX says that process behaviour is undefined after it ignores a SIGFPE,
-+ // SIGILL, SIGSEGV, or SIGBUS *unless* that signal was generated by a
-+ // kill(2) or raise(3). Similarly for tgkill(2) on NetBSD.
-+ //
-+ // IOW, user generated signals never generate what we consider to be a
-+ // "crash".
-+ //
-+ // Similarly, ACK signals generated by this monitor.
-+
-+ // Handle the signal.
-+ if (info.si_code == SI_TKILL || info.si_code == SI_USER) {
-+ if (log)
-+ log->Printf("NativeProcessNetBSD::%s() received signal %s (%d) with code "
-+ "%s, (siginfo pid = %d (%s), waitpid pid = %" PRIu64 ")",
-+ __FUNCTION__, Host::GetSignalAsCString(signo), signo,
-+ (info.si_code == SI_TKILL ? "SI_TKILL" : "SI_USER"),
-+ info.si_pid, is_from_llgs ? "from llgs" : "not from llgs",
-+ thread.GetID());
-+ }
-+
-+ // Check for thread stop notification.
-+ if (is_from_llgs && (info.si_code == SI_TKILL) && (signo == SIGSTOP)) {
-+ // This is a tgkill()-based stop.
-+ if (log)
-+ log->Printf("NativeProcessNetBSD::%s() pid %" PRIu64 " tid %" PRIu64
-+ ", thread stopped",
-+ __FUNCTION__, GetID(), thread.GetID());
-+
-+ // Check that we're not already marked with a stop reason.
-+ // Note this thread really shouldn't already be marked as stopped - if we
-+ // were, that would imply that
-+ // the kernel signaled us with the thread stopping which we handled and
-+ // marked as stopped,
-+ // and that, without an intervening resume, we received another stop. It is
-+ // more likely
-+ // that we are missing the marking of a run state somewhere if we find that
-+ // the thread was
-+ // marked as stopped.
-+ const StateType thread_state = thread.GetState();
-+ if (!StateIsStoppedState(thread_state, false)) {
-+ // An inferior thread has stopped because of a SIGSTOP we have sent it.
-+ // Generally, these are not important stops and we don't want to report
-+ // them as
-+ // they are just used to stop other threads when one thread (the one with
-+ // the
-+ // *real* stop reason) hits a breakpoint (watchpoint, etc...). However, in
-+ // the
-+ // case of an asynchronous Interrupt(), this *is* the real stop reason, so
-+ // we
-+ // leave the signal intact if this is the thread that was chosen as the
-+ // triggering thread.
-+ if (m_pending_notification_tid != LLDB_INVALID_THREAD_ID) {
-+ if (m_pending_notification_tid == thread.GetID())
-+ thread.SetStoppedBySignal(SIGSTOP, &info);
-+ else
-+ thread.SetStoppedWithNoReason();
-+
-+ SetCurrentThreadID(thread.GetID());
-+ SignalIfAllThreadsStopped();
-+ } else {
-+ // We can end up here if stop was initiated by LLGS but by this time a
-+ // thread stop has occurred - maybe initiated by another event.
-+ Error error = ResumeThread(thread, thread.GetState(), 0);
-+ if (error.Fail() && log) {
-+ log->Printf(
-+ "NativeProcessNetBSD::%s failed to resume thread tid %" PRIu64
-+ ": %s",
-+ __FUNCTION__, thread.GetID(), error.AsCString());
-+ }
-+ }
-+ } else {
-+ if (log) {
-+ // Retrieve the signal name if the thread was stopped by a signal.
-+ int stop_signo = 0;
-+ const bool stopped_by_signal = thread.IsStopped(&stop_signo);
-+ const char *signal_name = stopped_by_signal
-+ ? Host::GetSignalAsCString(stop_signo)
-+ : "<not stopped by signal>";
-+ if (!signal_name)
-+ signal_name = "<no-signal-name>";
-+
-+ log->Printf("NativeProcessNetBSD::%s() pid %" PRIu64 " tid %" PRIu64
-+ ", thread was already marked as a stopped state (state=%s, "
-+ "signal=%d (%s)), leaving stop signal as is",
-+ __FUNCTION__, GetID(), thread.GetID(),
-+ StateAsCString(thread_state), stop_signo, signal_name);
-+ }
-+ SignalIfAllThreadsStopped();
-+ }
-+
-+ // Done handling.
-+ return;
-+ }
-+
-+ if (log)
-+ log->Printf("NativeProcessNetBSD::%s() received signal %s", __FUNCTION__,
-+ Host::GetSignalAsCString(signo));
-+
-+ // This thread is stopped.
-+ thread.SetStoppedBySignal(signo, &info);
-+
-+ // Send a stop to the debugger after we get all other threads to stop.
-+ StopRunningThreads(thread.GetID());
-+}
-+
+namespace {
+
+struct EmulatorBaton {
@@ -1910,155 +1446,6 @@ $NetBSD$
+ }
+}
+
-+#if 0
-+ProcessMessage::CrashReason
-+NativeProcessNetBSD::GetCrashReasonForSIGSEGV(const siginfo_t *info)
-+{
-+ ProcessMessage::CrashReason reason;
-+ assert(info->si_signo == SIGSEGV);
-+
-+ reason = ProcessMessage::eInvalidCrashReason;
-+
-+ switch (info->si_code)
-+ {
-+ default:
-+ assert(false && "unexpected si_code for SIGSEGV");
-+ break;
-+ case SI_KERNEL:
-+ // NetBSD will occasionally send spurious SI_KERNEL codes.
-+ // (this is poorly documented in sigaction)
-+ // One way to get this is via unaligned SIMD loads.
-+ reason = ProcessMessage::eInvalidAddress; // for lack of anything better
-+ break;
-+ case SEGV_MAPERR:
-+ reason = ProcessMessage::eInvalidAddress;
-+ break;
-+ case SEGV_ACCERR:
-+ reason = ProcessMessage::ePrivilegedAddress;
-+ break;
-+ }
-+
-+ return reason;
-+}
-+#endif
-+
-+#if 0
-+ProcessMessage::CrashReason
-+NativeProcessNetBSD::GetCrashReasonForSIGILL(const siginfo_t *info)
-+{
-+ ProcessMessage::CrashReason reason;
-+ assert(info->si_signo == SIGILL);
-+
-+ reason = ProcessMessage::eInvalidCrashReason;
-+
-+ switch (info->si_code)
-+ {
-+ default:
-+ assert(false && "unexpected si_code for SIGILL");
-+ break;
-+ case ILL_ILLOPC:
-+ reason = ProcessMessage::eIllegalOpcode;
-+ break;
-+ case ILL_ILLOPN:
-+ reason = ProcessMessage::eIllegalOperand;
-+ break;
-+ case ILL_ILLADR:
-+ reason = ProcessMessage::eIllegalAddressingMode;
-+ break;
-+ case ILL_ILLTRP:
-+ reason = ProcessMessage::eIllegalTrap;
-+ break;
-+ case ILL_PRVOPC:
-+ reason = ProcessMessage::ePrivilegedOpcode;
-+ break;
-+ case ILL_PRVREG:
-+ reason = ProcessMessage::ePrivilegedRegister;
-+ break;
-+ case ILL_COPROC:
-+ reason = ProcessMessage::eCoprocessorError;
-+ break;
-+ case ILL_BADSTK:
-+ reason = ProcessMessage::eInternalStackError;
-+ break;
-+ }
-+
-+ return reason;
-+}
-+#endif
-+
-+#if 0
-+ProcessMessage::CrashReason
-+NativeProcessNetBSD::GetCrashReasonForSIGFPE(const siginfo_t *info)
-+{
-+ ProcessMessage::CrashReason reason;
-+ assert(info->si_signo == SIGFPE);
-+
-+ reason = ProcessMessage::eInvalidCrashReason;
-+
-+ switch (info->si_code)
-+ {
-+ default:
-+ assert(false && "unexpected si_code for SIGFPE");
-+ break;
-+ case FPE_INTDIV:
-+ reason = ProcessMessage::eIntegerDivideByZero;
-+ break;
-+ case FPE_INTOVF:
-+ reason = ProcessMessage::eIntegerOverflow;
-+ break;
-+ case FPE_FLTDIV:
-+ reason = ProcessMessage::eFloatDivideByZero;
-+ break;
-+ case FPE_FLTOVF:
-+ reason = ProcessMessage::eFloatOverflow;
-+ break;
-+ case FPE_FLTUND:
-+ reason = ProcessMessage::eFloatUnderflow;
-+ break;
-+ case FPE_FLTRES:
-+ reason = ProcessMessage::eFloatInexactResult;
-+ break;
-+ case FPE_FLTINV:
-+ reason = ProcessMessage::eFloatInvalidOperation;
-+ break;
-+ case FPE_FLTSUB:
-+ reason = ProcessMessage::eFloatSubscriptRange;
-+ break;
-+ }
-+
-+ return reason;
-+}
-+#endif
-+
-+#if 0
-+ProcessMessage::CrashReason
-+NativeProcessNetBSD::GetCrashReasonForSIGBUS(const siginfo_t *info)
-+{
-+ ProcessMessage::CrashReason reason;
-+ assert(info->si_signo == SIGBUS);
-+
-+ reason = ProcessMessage::eInvalidCrashReason;
-+
-+ switch (info->si_code)
-+ {
-+ default:
-+ assert(false && "unexpected si_code for SIGBUS");
-+ break;
-+ case BUS_ADRALN:
-+ reason = ProcessMessage::eIllegalAlignment;
-+ break;
-+ case BUS_ADRERR:
-+ reason = ProcessMessage::eIllegalAddress;
-+ break;
-+ case BUS_OBJERR:
-+ reason = ProcessMessage::eHardwareError;
-+ break;
-+ }
-+
-+ return reason;
-+}
-+#endif
-+
+Error NativeProcessNetBSD::ReadMemory(lldb::addr_t addr, void *buf, size_t size,
+ size_t &bytes_read) {
+ unsigned char *dst = static_cast<unsigned char *>(buf);
@@ -2178,10 +1565,6 @@ $NetBSD$
+ return error;
+}
+
-+Error NativeProcessNetBSD::GetSignalInfo(lldb::tid_t tid, void *siginfo) {
-+ return PtraceWrapper(PTRACE_GETSIGINFO, tid, nullptr, siginfo);
-+}
-+
+Error NativeProcessNetBSD::GetEventMessage(lldb::tid_t tid,
+ unsigned long *message) {
+ return PtraceWrapper(PTRACE_GETEVENTMSG, tid, nullptr, message);
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 566cc32..40bc083 100644
--- a/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.cpp
+++ b/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.cpp
@@ -2,7 +2,7 @@ $NetBSD$
--- source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp.orig 2016-12-17 13:23:23.784878149 +0000
+++ source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
-@@ -0,0 +1,481 @@
+@@ -0,0 +1,429 @@
+//===-- NativeThreadNetBSD.cpp --------------------------------- -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
@@ -225,64 +225,12 @@ $NetBSD$
+ reinterpret_cast<void *>(data));
+}
+
-+void NativeThreadNetBSD::MaybePrepareSingleStepWorkaround() {
-+ if (!SingleStepWorkaroundNeeded())
-+ return;
-+
-+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
-+
-+ if (sched_getaffinity(static_cast<::pid_t>(m_tid), sizeof m_original_cpu_set,
-+ &m_original_cpu_set) != 0) {
-+ // This should really not fail. But, just in case...
-+ if (log) {
-+ Error error(errno, eErrorTypePOSIX);
-+ log->Printf(
-+ "NativeThreadNetBSD::%s Unable to get cpu affinity for thread %" PRIx64
-+ ": %s",
-+ __FUNCTION__, m_tid, error.AsCString());
-+ }
-+ return;
-+ }
-+
-+ cpu_set_t set;
-+ CPU_ZERO(&set);
-+ CPU_SET(0, &set);
-+ if (sched_setaffinity(static_cast<::pid_t>(m_tid), sizeof set, &set) != 0 &&
-+ log) {
-+ // This may fail in very locked down systems, if the thread is not allowed
-+ // to run on
-+ // cpu 0. If that happens, only thing we can do is it log it and continue...
-+ Error error(errno, eErrorTypePOSIX);
-+ log->Printf(
-+ "NativeThreadNetBSD::%s Unable to set cpu affinity for thread %" PRIx64
-+ ": %s",
-+ __FUNCTION__, m_tid, error.AsCString());
-+ }
-+}
-+
-+void NativeThreadNetBSD::MaybeCleanupSingleStepWorkaround() {
-+ if (!SingleStepWorkaroundNeeded())
-+ return;
-+
-+ if (sched_setaffinity(static_cast<::pid_t>(m_tid), sizeof m_original_cpu_set,
-+ &m_original_cpu_set) != 0) {
-+ Error error(errno, eErrorTypePOSIX);
-+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
-+ log->Printf(
-+ "NativeThreadNetBSD::%s Unable to reset cpu affinity for thread %" PRIx64
-+ ": %s",
-+ __FUNCTION__, m_tid, error.AsCString());
-+ }
-+}
-+
+Error NativeThreadNetBSD::SingleStep(uint32_t signo) {
+ const StateType new_state = StateType::eStateStepping;
+ MaybeLogStateChange(new_state);
+ m_state = new_state;
+ m_stop_info.reason = StopReason::eStopReasonNone;
+
-+ MaybePrepareSingleStepWorkaround();
-+
+ intptr_t data = 0;
+ if (signo != LLDB_INVALID_SIGNAL_NUMBER)
+ data = signo;
Home |
Main Index |
Thread Index |
Old Index