[Lldb-commits] [lldb] r236707 - [NativeProcessLinux] Remove logging and error callbacks
Pavel Labath
labath at google.com
Thu May 7 01:30:32 PDT 2015
Author: labath
Date: Thu May 7 03:30:31 2015
New Revision: 236707
URL: http://llvm.org/viewvc/llvm-project?rev=236707&view=rev
Log:
[NativeProcessLinux] Remove logging and error callbacks
Summary:
These are remnants of the thread state coordinator, which are now unnecessary. I have basically
inlined the callbacks. No functional change.
Test Plan: Tests continue to pass.
Reviewers: chaoren, vharron
Subscribers: lldb-commits
Differential Revision: http://reviews.llvm.org/D9343
Modified:
lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.h
Modified: lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp?rev=236707&r1=236706&r2=236707&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp Thu May 7 03:30:31 2015
@@ -153,26 +153,6 @@ namespace
return signals;
}
- NativeProcessLinux::LogFunction
- GetThreadLoggerFunction ()
- {
- return [](const char *format, va_list args)
- {
- Log *const log = GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD);
- if (log)
- log->VAPrintf (format, args);
- };
- }
-
- void
- CoordinatorErrorHandler (const std::string &error_message)
- {
- Log *const log = GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD);
- if (log)
- log->Printf ("NativeProcessLinux::%s %s", __FUNCTION__, error_message.c_str ());
- assert (false && "NativeProcessLinux error reported");
- }
-
Error
ResolveProcessArchitecture (lldb::pid_t pid, Platform &platform, ArchSpec &arch)
{
@@ -1673,9 +1653,7 @@ NativeProcessLinux::NativeProcessLinux (
m_supports_mem_region (eLazyBoolCalculate),
m_mem_region_cache (),
m_mem_region_cache_mutex (),
- m_log_function (GetThreadLoggerFunction()),
- m_tid_map (),
- m_log_event_processing (false)
+ m_tid_map ()
{
}
@@ -2250,7 +2228,7 @@ NativeProcessLinux::MonitorCallback(lldb
// This is a group stop reception for this tid.
if (log)
log->Printf ("NativeThreadLinux::%s received a group stop for pid %" PRIu64 " tid %" PRIu64, __FUNCTION__, GetID (), pid);
- NotifyThreadStop (pid);
+ NotifyThreadStop (pid, false);
}
else
{
@@ -2353,7 +2331,7 @@ NativeProcessLinux::WaitForNewThread(::p
new_thread_sp = AddThread(tid);
std::static_pointer_cast<NativeThreadLinux> (new_thread_sp)->SetRunning ();
Resume (tid, LLDB_INVALID_SIGNAL_NUMBER);
- NotifyThreadCreate (tid, false, CoordinatorErrorHandler);
+ NotifyThreadCreate (tid, false);
}
void
@@ -2470,7 +2448,7 @@ NativeProcessLinux::MonitorSIGTRAP(const
// The inferior process or one of its threads is about to exit.
// This thread is currently stopped. It's not actually dead yet, just about to be.
- NotifyThreadStop (pid);
+ NotifyThreadStop (pid, false);
unsigned long data = 0;
if (GetEventMessage(pid, &data).Fail())
@@ -2496,8 +2474,7 @@ NativeProcessLinux::MonitorSIGTRAP(const
{
std::static_pointer_cast<NativeThreadLinux> (thread_sp)->SetRunning ();
return Resume (tid_to_resume, (supress_signal) ? LLDB_INVALID_SIGNAL_NUMBER : signo);
- },
- CoordinatorErrorHandler);
+ });
break;
}
@@ -2536,7 +2513,7 @@ NativeProcessLinux::MonitorSIGTRAP(const
log->Printf ("NativeProcessLinux::%s() received unknown SIGTRAP system call stop event, pid %" PRIu64 "tid %" PRIu64 ", resuming", __FUNCTION__, GetID (), pid);
// This thread is currently stopped.
- NotifyThreadStop (pid);
+ NotifyThreadStop (pid, false);
if (thread_sp)
std::static_pointer_cast<NativeThreadLinux> (thread_sp)->SetStoppedBySignal (SIGTRAP);
@@ -2547,8 +2524,7 @@ NativeProcessLinux::MonitorSIGTRAP(const
{
std::static_pointer_cast<NativeThreadLinux> (thread_sp)->SetRunning ();
return Resume (tid_to_resume, LLDB_INVALID_SIGNAL_NUMBER);
- },
- CoordinatorErrorHandler);
+ });
break;
default:
@@ -2572,7 +2548,7 @@ NativeProcessLinux::MonitorTrace(lldb::p
std::static_pointer_cast<NativeThreadLinux>(thread_sp)->SetStoppedByTrace();
// This thread is currently stopped.
- NotifyThreadStop(pid);
+ NotifyThreadStop(pid, false);
// Here we don't have to request the rest of the threads to stop or request a deferred stop.
// This would have already happened at the time the Resume() with step operation was signaled.
@@ -2592,7 +2568,7 @@ NativeProcessLinux::MonitorBreakpoint(ll
__FUNCTION__, pid);
// This thread is currently stopped.
- NotifyThreadStop(pid);
+ NotifyThreadStop(pid, false);
// Mark the thread as stopped at breakpoint.
if (thread_sp)
@@ -2638,7 +2614,7 @@ NativeProcessLinux::MonitorWatchpoint(ll
__FUNCTION__, pid, wp_index);
// This thread is currently stopped.
- NotifyThreadStop(pid);
+ NotifyThreadStop(pid, false);
// Mark the thread as stopped at watchpoint.
// The address is at (lldb::addr_t)info->si_addr if we need it.
@@ -2710,7 +2686,7 @@ NativeProcessLinux::MonitorSignal(const
// We can now resume the newly created thread.
std::static_pointer_cast<NativeThreadLinux> (thread_sp)->SetRunning ();
Resume (pid, LLDB_INVALID_SIGNAL_NUMBER);
- NotifyThreadCreate (pid, false, CoordinatorErrorHandler);
+ NotifyThreadCreate (pid, false);
// Done handling.
return;
}
@@ -2752,7 +2728,7 @@ NativeProcessLinux::MonitorSignal(const
linux_thread_sp->SetStoppedBySignal(0);
SetCurrentThreadID (thread_sp->GetID ());
- NotifyThreadStop (thread_sp->GetID (), true, CoordinatorErrorHandler);
+ NotifyThreadStop (thread_sp->GetID (), true);
}
else
{
@@ -2774,7 +2750,7 @@ NativeProcessLinux::MonitorSignal(const
signal_name);
}
// Tell the thread state coordinator about the stop.
- NotifyThreadStop (thread_sp->GetID ());
+ NotifyThreadStop (thread_sp->GetID (), false);
}
}
@@ -2786,7 +2762,7 @@ NativeProcessLinux::MonitorSignal(const
log->Printf ("NativeProcessLinux::%s() received signal %s", __FUNCTION__, GetUnixSignals ().GetSignalAsCString (signo));
// This thread is stopped.
- NotifyThreadStop (pid);
+ NotifyThreadStop (pid, false);
switch (signo)
{
@@ -2808,8 +2784,7 @@ NativeProcessLinux::MonitorSignal(const
std::static_pointer_cast<NativeThreadLinux> (thread_sp)->SetRunning ();
// Pass this signal number on to the inferior to handle.
return Resume (tid_to_resume, (supress_signal) ? LLDB_INVALID_SIGNAL_NUMBER : signo);
- },
- CoordinatorErrorHandler);
+ });
}
break;
case SIGSEGV:
@@ -3090,8 +3065,7 @@ NativeProcessLinux::Resume (const Resume
if (resume_result.Success())
SetState(eStateRunning, true);
return resume_result;
- },
- CoordinatorErrorHandler);
+ });
break;
}
@@ -3114,8 +3088,7 @@ NativeProcessLinux::Resume (const Resume
if (step_result.Success())
SetState(eStateStepping, true);
return step_result;
- },
- CoordinatorErrorHandler);
+ });
stepping = true;
break;
}
@@ -4206,19 +4179,7 @@ void
NativeProcessLinux::NotifyThreadCreateStopped (lldb::tid_t tid)
{
const bool is_stopped = true;
- NotifyThreadCreate (tid, is_stopped, CoordinatorErrorHandler);
-}
-
-void
-NativeProcessLinux::NotifyThreadDeath (lldb::tid_t tid)
-{
- NotifyThreadDeath (tid, CoordinatorErrorHandler);
-}
-
-void
-NativeProcessLinux::NotifyThreadStop (lldb::tid_t tid)
-{
- NotifyThreadStop (tid, false, CoordinatorErrorHandler);
+ NotifyThreadCreate (tid, is_stopped);
}
void
@@ -4230,8 +4191,7 @@ NativeProcessLinux::StopRunningThreads(l
const lldb::pid_t pid = GetID ();
StopRunningThreads(trigerring_tid,
- [=](lldb::tid_t request_stop_tid) { return RequestThreadStop(pid, request_stop_tid); },
- CoordinatorErrorHandler);
+ [=](lldb::tid_t request_stop_tid) { return RequestThreadStop(pid, request_stop_tid); });
}
void
@@ -4245,8 +4205,7 @@ NativeProcessLinux::StopRunningThreadsWi
const lldb::pid_t pid = GetID ();
StopRunningThreadsWithSkipTID(deferred_signal_tid,
skip_stop_request_tid != LLDB_INVALID_THREAD_ID ? NativeProcessLinux::ThreadIDSet {skip_stop_request_tid} : NativeProcessLinux::ThreadIDSet (),
- [=](lldb::tid_t request_stop_tid) { return RequestThreadStop(pid, request_stop_tid); },
- CoordinatorErrorHandler);
+ [=](lldb::tid_t request_stop_tid) { return RequestThreadStop(pid, request_stop_tid); });
}
Error
@@ -4307,48 +4266,33 @@ NativeProcessLinux::GetLoadedModuleFileS
module_file_spec.GetFilename().AsCString(), GetID());
}
-void
+Error
NativeProcessLinux::DoResume(
lldb::tid_t tid,
ResumeThreadFunction request_thread_resume_function,
- ErrorFunction error_function,
bool error_when_already_running)
{
- // Ensure we know about the thread.
+ Log *const log = GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD);
+
auto find_it = m_tid_map.find (tid);
- if (find_it == m_tid_map.end ())
- {
- // We don't know about this thread. This is an error condition.
- std::ostringstream error_message;
- error_message << "error: tid " << tid << " asked to resume but tid is unknown";
- error_function (error_message.str ());
- return;
- }
+ lldbassert(find_it != m_tid_map.end ()); // Ensure we know about the thread.
+
auto& context = find_it->second;
// Tell the thread to resume if we don't already think it is running.
const bool is_stopped = context.m_state == ThreadState::Stopped;
+
+ lldbassert(!(error_when_already_running && !is_stopped));
+
if (!is_stopped)
{
// It's not an error, just a log, if the error_when_already_running flag is not set.
// This covers cases where, for instance, we're just trying to resume all threads
// from the user side.
- if (!error_when_already_running)
- {
- TSCLog ("NativeProcessLinux::%s tid %" PRIu64 " optional resume skipped since it is already running",
- __FUNCTION__,
- tid);
- }
- else
- {
- // Skip the resume call - we have tracked it to be running. And we unconditionally
- // expected to resume this thread. Flag this as an error.
- std::ostringstream error_message;
- error_message << "error: tid " << tid << " asked to resume but we think it is already running";
- error_function (error_message.str ());
- }
-
- // Error or not, we're done.
- return;
+ if (log)
+ log->Printf("NativeProcessLinux::%s tid %" PRIu64 " optional resume skipped since it is already running",
+ __FUNCTION__,
+ tid);
+ return Error();
}
// Before we do the resume below, first check if we have a pending
@@ -4357,18 +4301,18 @@ NativeProcessLinux::DoResume(
// we're ostensibly waiting for threads to stop before we send out the
// pending notification, and here we are resuming one before we send
// out the pending stop notification.
- if (m_pending_notification_up)
+ if (m_pending_notification_up && log)
{
if (m_pending_notification_up->wait_for_stop_tids.count (tid) > 0)
{
- TSCLog ("NativeProcessLinux::%s about to resume tid %" PRIu64 " per explicit request but we have a pending stop notification (tid %" PRIu64 ") that is actively waiting for this thread to stop. Valid sequence of events?", __FUNCTION__, tid, m_pending_notification_up->triggering_tid);
+ log->Printf("NativeProcessLinux::%s about to resume tid %" PRIu64 " per explicit request but we have a pending stop notification (tid %" PRIu64 ") that is actively waiting for this thread to stop. Valid sequence of events?", __FUNCTION__, tid, m_pending_notification_up->triggering_tid);
}
else if (m_pending_notification_up->original_wait_for_stop_tids.count (tid) > 0)
{
- TSCLog ("NativeProcessLinux::%s about to resume tid %" PRIu64 " per explicit request but we have a pending stop notification (tid %" PRIu64 ") that hasn't fired yet and this is one of the threads we had been waiting on (and already marked satisfied for this tid). Valid sequence of events?", __FUNCTION__, tid, m_pending_notification_up->triggering_tid);
+ log->Printf("NativeProcessLinux::%s about to resume tid %" PRIu64 " per explicit request but we have a pending stop notification (tid %" PRIu64 ") that hasn't fired yet and this is one of the threads we had been waiting on (and already marked satisfied for this tid). Valid sequence of events?", __FUNCTION__, tid, m_pending_notification_up->triggering_tid);
for (auto tid : m_pending_notification_up->wait_for_stop_tids)
{
- TSCLog ("NativeProcessLinux::%s tid %" PRIu64 " deferred stop notification still waiting on tid %" PRIu64,
+ log->Printf("NativeProcessLinux::%s tid %" PRIu64 " deferred stop notification still waiting on tid %" PRIu64,
__FUNCTION__,
m_pending_notification_up->triggering_tid,
tid);
@@ -4385,13 +4329,13 @@ NativeProcessLinux::DoResume(
context.m_state = ThreadState::Running;
context.m_request_resume_function = request_thread_resume_function;
}
- else
+ else if (log)
{
- TSCLog ("NativeProcessLinux::%s failed to resume thread tid %" PRIu64 ": %s",
+ log->Printf("NativeProcessLinux::%s failed to resume thread tid %" PRIu64 ": %s",
__FUNCTION__, tid, error.AsCString ());
}
- return;
+ return error;
}
//===----------------------------------------------------------------------===//
@@ -4399,73 +4343,71 @@ NativeProcessLinux::DoResume(
void
NativeProcessLinux::StopThreads(const lldb::tid_t triggering_tid,
const ThreadIDSet &wait_for_stop_tids,
- const StopThreadFunction &request_thread_stop_function,
- const ErrorFunction &error_function)
+ const StopThreadFunction &request_thread_stop_function)
{
+ Log *const log = GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD);
std::lock_guard<std::mutex> lock(m_event_mutex);
- if (m_log_event_processing)
+ if (log)
{
- TSCLog ("NativeProcessLinux::%s about to process event: (triggering_tid: %" PRIu64 ", wait_for_stop_tids.size(): %zd)",
+ log->Printf("NativeProcessLinux::%s about to process event: (triggering_tid: %" PRIu64 ", wait_for_stop_tids.size(): %zd)",
__FUNCTION__, triggering_tid, wait_for_stop_tids.size());
}
DoStopThreads(PendingNotificationUP(new PendingNotification(
- triggering_tid, wait_for_stop_tids, request_thread_stop_function, error_function)));
+ triggering_tid, wait_for_stop_tids, request_thread_stop_function)));
- if (m_log_event_processing)
+ if (log)
{
- TSCLog ("NativeProcessLinux::%s event processing done", __FUNCTION__);
+ log->Printf("NativeProcessLinux::%s event processing done", __FUNCTION__);
}
}
void
NativeProcessLinux::StopRunningThreads(const lldb::tid_t triggering_tid,
- const StopThreadFunction &request_thread_stop_function,
- const ErrorFunction &error_function)
+ const StopThreadFunction &request_thread_stop_function)
{
+ Log *const log = GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD);
std::lock_guard<std::mutex> lock(m_event_mutex);
- if (m_log_event_processing)
+ if (log)
{
- TSCLog ("NativeProcessLinux::%s about to process event: (triggering_tid: %" PRIu64 ")",
+ log->Printf("NativeProcessLinux::%s about to process event: (triggering_tid: %" PRIu64 ")",
__FUNCTION__, triggering_tid);
}
DoStopThreads(PendingNotificationUP(new PendingNotification(
triggering_tid,
- request_thread_stop_function,
- error_function)));
+ request_thread_stop_function)));
- if (m_log_event_processing)
+ if (log)
{
- TSCLog ("NativeProcessLinux::%s event processing done", __FUNCTION__);
+ log->Printf("NativeProcessLinux::%s event processing done", __FUNCTION__);
}
}
void
NativeProcessLinux::StopRunningThreadsWithSkipTID(lldb::tid_t triggering_tid,
const ThreadIDSet &skip_stop_request_tids,
- const StopThreadFunction &request_thread_stop_function,
- const ErrorFunction &error_function)
+ const StopThreadFunction &request_thread_stop_function)
{
+ Log *const log = GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD);
std::lock_guard<std::mutex> lock(m_event_mutex);
- if (m_log_event_processing)
+ if (log)
{
- TSCLog ("NativeProcessLinux::%s about to process event: (triggering_tid: %" PRIu64 ", skip_stop_request_tids.size(): %zd)",
+ log->Printf("NativeProcessLinux::%s about to process event: (triggering_tid: %" PRIu64 ", skip_stop_request_tids.size(): %zd)",
__FUNCTION__, triggering_tid, skip_stop_request_tids.size());
}
DoStopThreads(PendingNotificationUP(new PendingNotification(
triggering_tid,
request_thread_stop_function,
- skip_stop_request_tids,
- error_function)));
+ skip_stop_request_tids)));
- if (m_log_event_processing)
+ if (log)
{
- TSCLog ("NativeProcessLinux::%s event processing done", __FUNCTION__);
+ log->Printf("NativeProcessLinux::%s event processing done", __FUNCTION__);
}
}
@@ -4493,18 +4435,7 @@ NativeProcessLinux::RequestStopOnAllSpec
// Validate we know about all tids for which we must first receive a stop before
// triggering the deferred stop notification.
auto find_it = m_tid_map.find (tid);
- if (find_it == m_tid_map.end ())
- {
- // This is an error. We shouldn't be asking for waiting pids that aren't known.
- // NOTE: we may be stripping out the specification of wait tids and handle this
- // automatically, in which case this state can never occur.
- std::ostringstream error_message;
- error_message << "error: deferred notification for tid " << m_pending_notification_up->triggering_tid << " specified an unknown/untracked pending stop tid " << m_pending_notification_up->triggering_tid;
- m_pending_notification_up->error_function (error_message.str ());
-
- // Bail out here.
- return false;
- }
+ lldbassert(find_it != m_tid_map.end());
// If the pending stop thread is currently running, we need to send it a stop request.
auto& context = find_it->second;
@@ -4562,25 +4493,20 @@ NativeProcessLinux::RequestThreadStop (l
context.m_stop_requested = true;
else
{
- TSCLog ("NativeProcessLinux::%s failed to request thread stop tid %" PRIu64 ": %s",
+ Log *const log = GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD);
+ if (log)
+ log->Printf("NativeProcessLinux::%s failed to request thread stop tid %" PRIu64 ": %s",
__FUNCTION__, tid, error.AsCString ());
}
}
-void
-NativeProcessLinux::ThreadDidStop (lldb::tid_t tid, bool initiated_by_llgs, const ErrorFunction &error_function)
+Error
+NativeProcessLinux::ThreadDidStop (lldb::tid_t tid, bool initiated_by_llgs)
{
// Ensure we know about the thread.
auto find_it = m_tid_map.find (tid);
- if (find_it == m_tid_map.end ())
- {
- // We don't know about this thread. This is an error condition.
- std::ostringstream error_message;
- error_message << "error: tid " << tid << " asked to stop but tid is unknown";
- error_function (error_message.str ());
- return;
- }
+ lldbassert(find_it != m_tid_map.end());
// Update the global list of known thread states. This one is definitely stopped.
auto& context = find_it->second;
@@ -4597,9 +4523,11 @@ NativeProcessLinux::ThreadDidStop (lldb:
if (initiated_by_llgs && context.m_request_resume_function && !stop_was_requested)
{
+ Log *const log = GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD);
// 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.
- TSCLog ("Resuming thread %" PRIu64 " since stop wasn't requested", tid);
+ if (log)
+ log->Printf("Resuming thread %" PRIu64 " since stop wasn't requested", tid);
const auto error = context.m_request_resume_function (tid, true);
if (error.Success ())
{
@@ -4607,32 +4535,29 @@ NativeProcessLinux::ThreadDidStop (lldb:
}
else
{
- TSCLog ("NativeProcessLinux::%s failed to resume thread tid %" PRIu64 ": %s",
- __FUNCTION__, tid, error.AsCString ());
+ if (log)
+ {
+ log->Printf("NativeProcessLinux::%s failed to resume thread tid %" PRIu64 ": %s",
+ __FUNCTION__, tid, error.AsCString ());
+ }
+ return error;
}
}
+ return Error();
}
void
NativeProcessLinux::DoStopThreads(PendingNotificationUP &¬ification_up)
{
// Validate we know about the deferred trigger thread.
- if (!IsKnownThread (notification_up->triggering_tid))
- {
- // We don't know about this thread. This is an error condition.
- std::ostringstream error_message;
- error_message << "error: deferred notification tid " << notification_up->triggering_tid << " is unknown";
- notification_up->error_function (error_message.str ());
-
- // We bail out here.
- return;
- }
+ lldbassert(IsKnownThread (notification_up->triggering_tid));
- if (m_pending_notification_up)
+ Log *const log = GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD);
+ if (m_pending_notification_up && log)
{
// Yikes - we've already got a pending signal notification in progress.
// Log this info. We lose the pending notification here.
- TSCLog ("NativeProcessLinux::%s dropping existing pending signal notification for tid %" PRIu64 ", to be replaced with signal for tid %" PRIu64,
+ log->Printf("NativeProcessLinux::%s dropping existing pending signal notification for tid %" PRIu64 ", to be replaced with signal for tid %" PRIu64,
__FUNCTION__,
m_pending_notification_up->triggering_tid,
notification_up->triggering_tid);
@@ -4651,18 +4576,10 @@ NativeProcessLinux::DoStopThreads(Pendin
}
void
-NativeProcessLinux::ThreadWasCreated (lldb::tid_t tid, bool is_stopped, const ErrorFunction &error_function)
+NativeProcessLinux::ThreadWasCreated (lldb::tid_t tid, bool is_stopped)
{
// Ensure we don't already know about the thread.
- auto find_it = m_tid_map.find (tid);
- if (find_it != m_tid_map.end ())
- {
- // We already know about this thread. This is an error condition.
- std::ostringstream error_message;
- error_message << "error: notified tid " << tid << " created but we already know about this thread";
- error_function (error_message.str ());
- return;
- }
+ lldbassert(m_tid_map.find(tid) == m_tid_map.end());
// Add the new thread to the stop map.
ThreadContext ctx;
@@ -4679,18 +4596,11 @@ NativeProcessLinux::ThreadWasCreated (ll
}
void
-NativeProcessLinux::ThreadDidDie (lldb::tid_t tid, const ErrorFunction &error_function)
+NativeProcessLinux::ThreadDidDie (lldb::tid_t tid)
{
// Ensure we know about the thread.
auto find_it = m_tid_map.find (tid);
- if (find_it == m_tid_map.end ())
- {
- // We don't know about this thread. This is an error condition.
- std::ostringstream error_message;
- error_message << "error: notified tid " << tid << " died but tid is unknown";
- error_function (error_message.str ());
- return;
- }
+ lldbassert(find_it != m_tid_map.end());
// Update the global list of known thread states. While this one is stopped, it is also dead.
// So stop tracking it. We assume the user of this coordinator will not keep trying to add
@@ -4705,128 +4615,123 @@ NativeProcessLinux::ThreadDidDie (lldb::
}
}
-void
-NativeProcessLinux::TSCLog (const char *format, ...)
-{
- va_list args;
- va_start (args, format);
-
- m_log_function (format, args);
-
- va_end (args);
-}
-
-void
-NativeProcessLinux::NotifyThreadStop (lldb::tid_t tid,
- bool initiated_by_llgs,
- const ErrorFunction &error_function)
+Error
+NativeProcessLinux::NotifyThreadStop (lldb::tid_t tid, bool initiated_by_llgs)
{
+ Log *const log = GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD);
std::lock_guard<std::mutex> lock(m_event_mutex);
- if (m_log_event_processing)
+ if (log)
{
- TSCLog ("NativeProcessLinux::%s about to process event: (tid: %" PRIu64 ", %sinitiated by llgs)",
+ log->Printf("NativeProcessLinux::%s about to process event: (tid: %" PRIu64 ", %sinitiated by llgs)",
__FUNCTION__, tid, initiated_by_llgs?"":"not ");
}
- ThreadDidStop (tid, initiated_by_llgs, error_function);
+ Error error = ThreadDidStop (tid, initiated_by_llgs);
- if (m_log_event_processing)
+ if (log)
{
- TSCLog ("NativeProcessLinux::%s event processing done", __FUNCTION__);
+ log->Printf("NativeProcessLinux::%s event processing done", __FUNCTION__);
}
+
+ return error;
}
-void
+Error
NativeProcessLinux::RequestThreadResume (lldb::tid_t tid,
- const ResumeThreadFunction &request_thread_resume_function,
- const ErrorFunction &error_function)
+ const ResumeThreadFunction &request_thread_resume_function)
{
+ Log *const log = GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD);
std::lock_guard<std::mutex> lock(m_event_mutex);
- if (m_log_event_processing)
+ if (log)
{
- TSCLog ("NativeProcessLinux::%s about to process event: (tid: %" PRIu64 ")",
+ log->Printf("NativeProcessLinux::%s about to process event: (tid: %" PRIu64 ")",
__FUNCTION__, tid);
}
- DoResume(tid, request_thread_resume_function, error_function, true);
+ Error error = DoResume(tid, request_thread_resume_function, true);
- if (m_log_event_processing)
+ if (log)
{
- TSCLog ("NativeProcessLinux::%s event processing done", __FUNCTION__);
+ log->Printf("NativeProcessLinux::%s event processing done", __FUNCTION__);
}
+
+ return error;
}
-void
+Error
NativeProcessLinux::RequestThreadResumeAsNeeded (lldb::tid_t tid,
- const ResumeThreadFunction &request_thread_resume_function,
- const ErrorFunction &error_function)
+ const ResumeThreadFunction &request_thread_resume_function)
{
+ Log *const log = GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD);
std::lock_guard<std::mutex> lock(m_event_mutex);
- if (m_log_event_processing)
+ if (log)
{
- TSCLog ("NativeProcessLinux::%s about to process event: (tid: %" PRIu64 ")",
+ log->Printf("NativeProcessLinux::%s about to process event: (tid: %" PRIu64 ")",
__FUNCTION__, tid);
}
- DoResume (tid, request_thread_resume_function, error_function, false);
+ Error error = DoResume (tid, request_thread_resume_function, false);
- if (m_log_event_processing)
+ if (log)
{
- TSCLog ("NativeProcessLinux::%s event processing done", __FUNCTION__);
+ log->Printf("NativeProcessLinux::%s event processing done", __FUNCTION__);
}
+
+ return error;
}
void
NativeProcessLinux::NotifyThreadCreate (lldb::tid_t tid,
- bool is_stopped,
- const ErrorFunction &error_function)
+ bool is_stopped)
{
+ Log *const log = GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD);
std::lock_guard<std::mutex> lock(m_event_mutex);
- if (m_log_event_processing)
+ if (log)
{
- TSCLog ("NativeProcessLinux::%s about to process event: (tid: %" PRIu64 ", is %sstopped)",
+ log->Printf("NativeProcessLinux::%s about to process event: (tid: %" PRIu64 ", is %sstopped)",
__FUNCTION__, tid, is_stopped?"":"not ");
}
- ThreadWasCreated (tid, is_stopped, error_function);
+ ThreadWasCreated (tid, is_stopped);
- if (m_log_event_processing)
+ if (log)
{
- TSCLog ("NativeProcessLinux::%s event processing done", __FUNCTION__);
+ log->Printf("NativeProcessLinux::%s event processing done", __FUNCTION__);
}
}
void
-NativeProcessLinux::NotifyThreadDeath (lldb::tid_t tid,
- const ErrorFunction &error_function)
+NativeProcessLinux::NotifyThreadDeath (lldb::tid_t tid)
{
+ Log *const log = GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD);
std::lock_guard<std::mutex> lock(m_event_mutex);
- if (m_log_event_processing)
+ if (log)
{
- TSCLog ("NativeProcessLinux::%s about to process event: (tid: %" PRIu64 ")", __FUNCTION__, tid);
+ log->Printf("NativeProcessLinux::%s about to process event: (tid: %" PRIu64 ")", __FUNCTION__, tid);
}
- ThreadDidDie(tid, error_function);
+ ThreadDidDie(tid);
- if (m_log_event_processing)
+ if (log)
{
- TSCLog ("NativeProcessLinux::%s event processing done", __FUNCTION__);
+ log->Printf("NativeProcessLinux::%s event processing done", __FUNCTION__);
}
}
void
NativeProcessLinux::ResetForExec ()
{
+ Log *const log = GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD);
std::lock_guard<std::mutex> lock(m_event_mutex);
- if (m_log_event_processing)
+ if (log)
{
- TSCLog ("NativeProcessLinux::%s about to process event", __FUNCTION__);
+ log->Printf("NativeProcessLinux::%s about to process event", __FUNCTION__);
}
// Clear the pending notification if there was one.
@@ -4838,16 +4743,11 @@ NativeProcessLinux::ResetForExec ()
// stop.
m_tid_map.clear ();
- if (m_log_event_processing)
+ if (log)
{
- TSCLog ("NativeProcessLinux::%s event processing done", __FUNCTION__);
+ log->Printf("NativeProcessLinux::%s event processing done", __FUNCTION__);
}
}
-void
-NativeProcessLinux::LogEnableEventProcessing (bool enabled)
-{
- m_log_event_processing = enabled;
-}
bool
NativeProcessLinux::IsKnownThread (lldb::tid_t tid) const
Modified: lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.h?rev=236707&r1=236706&r2=236707&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.h (original)
+++ lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.h Thu May 7 03:30:31 2015
@@ -356,9 +356,6 @@ namespace process_linux {
NotifyThreadDeath (lldb::tid_t tid);
void
- NotifyThreadStop (lldb::tid_t tid);
-
- void
StopRunningThreads (lldb::tid_t triggering_tid);
void
@@ -377,8 +374,6 @@ namespace process_linux {
typedef std::unordered_set<lldb::tid_t> ThreadIDSet;
// Callback/block definitions.
- typedef std::function<void (const char *format, va_list args)> LogFunction;
- typedef std::function<void (const std::string &error_message)> ErrorFunction;
typedef std::function<Error (lldb::tid_t tid)> StopThreadFunction;
typedef std::function<Error (lldb::tid_t tid, bool supress_signal)> ResumeThreadFunction;
@@ -388,16 +383,7 @@ namespace process_linux {
// otherwise, it should be set false if it is already running. Will
// call the error function if the thread id is already tracked.
void
- NotifyThreadCreate (lldb::tid_t tid,
- bool is_stopped,
- const ErrorFunction &error_function);
-
- // Notify the coordinator when a previously-existing thread should no
- // longer be tracked. The error_function will trigger if the thread
- // is not being tracked.
- void
- NotifyThreadDeath (lldb::tid_t tid,
- const ErrorFunction &error_function);
+ NotifyThreadCreate(lldb::tid_t tid, bool is_stopped);
// Notify the delegate after a given set of threads stops. The triggering_tid will be set
@@ -406,16 +392,14 @@ namespace process_linux {
void
StopThreads(lldb::tid_t triggering_tid,
const ThreadIDSet &wait_for_stop_tids,
- const StopThreadFunction &request_thread_stop_function,
- const ErrorFunction &error_function);
+ const StopThreadFunction &request_thread_stop_function);
// Notify the delegate after all non-stopped threads stop. The triggering_tid will be set
// as the current thread. The error_function will be fired if the triggering tid
// is unknown.
void
StopRunningThreads(lldb::tid_t triggering_tid,
- const StopThreadFunction &request_thread_stop_function,
- const ErrorFunction &error_function);
+ const StopThreadFunction &request_thread_stop_function);
// Notify the delegate after all non-stopped threads stop. The triggering_tid will be set
// as the current thread. The error_function will be fired if either the triggering tid
@@ -424,43 +408,32 @@ namespace process_linux {
void
StopRunningThreadsWithSkipTID(lldb::tid_t triggering_tid,
const ThreadIDSet &skip_stop_request_tids,
- const StopThreadFunction &request_thread_stop_function,
- const ErrorFunction &error_function);
+ const StopThreadFunction &request_thread_stop_function);
// Notify the thread stopped. Will trigger error at time of execution if we
// already think it is stopped.
- void
- NotifyThreadStop (lldb::tid_t tid,
- bool initiated_by_llgs,
- const ErrorFunction &error_function);
+ Error
+ NotifyThreadStop(lldb::tid_t tid, bool initiated_by_llgs);
// Request that the given thread id should have the request_thread_resume_function
- // called. Will trigger the error_function if the thread is thought to be running
- // already at that point. This call signals an error if the thread resume is for
+ // called. This call signals an error if the thread resume is for
// a thread that is already in a running state.
- void
+ Error
RequestThreadResume (lldb::tid_t tid,
- const ResumeThreadFunction &request_thread_resume_function,
- const ErrorFunction &error_function);
+ const ResumeThreadFunction &request_thread_resume_function);
// Request that the given thread id should have the request_thread_resume_function
- // called. Will trigger the error_function if the thread is thought to be running
- // already at that point. This call ignores threads that are already running and
+ // called. This call ignores threads that are already running and
// does not trigger an error in that case.
- void
+ Error
RequestThreadResumeAsNeeded (lldb::tid_t tid,
- const ResumeThreadFunction &request_thread_resume_function,
- const ErrorFunction &error_function);
+ const ResumeThreadFunction &request_thread_resume_function);
// Indicate the calling process did an exec and that the thread state
// should be 100% cleared.
void
ResetForExec ();
- // Enable/disable verbose logging of event processing.
- void
- LogEnableEventProcessing (bool enabled);
-
private:
enum class ThreadState
@@ -481,26 +454,22 @@ namespace process_linux {
{
PendingNotification (lldb::tid_t triggering_tid,
const ThreadIDSet &wait_for_stop_tids,
- const StopThreadFunction &request_thread_stop_function,
- const ErrorFunction &error_function):
+ const StopThreadFunction &request_thread_stop_function):
triggering_tid (triggering_tid),
wait_for_stop_tids (wait_for_stop_tids),
original_wait_for_stop_tids (wait_for_stop_tids),
request_thread_stop_function (request_thread_stop_function),
- error_function (error_function),
request_stop_on_all_unstopped_threads (false),
skip_stop_request_tids ()
{
}
PendingNotification (lldb::tid_t triggering_tid,
- const StopThreadFunction &request_thread_stop_function,
- const ErrorFunction &error_function) :
+ const StopThreadFunction &request_thread_stop_function):
triggering_tid (triggering_tid),
wait_for_stop_tids (),
original_wait_for_stop_tids (),
request_thread_stop_function (request_thread_stop_function),
- error_function (error_function),
request_stop_on_all_unstopped_threads (true),
skip_stop_request_tids ()
{
@@ -508,13 +477,11 @@ namespace process_linux {
PendingNotification (lldb::tid_t triggering_tid,
const StopThreadFunction &request_thread_stop_function,
- const ThreadIDSet &skip_stop_request_tids,
- const ErrorFunction &error_function) :
+ const ThreadIDSet &skip_stop_request_tids):
triggering_tid (triggering_tid),
wait_for_stop_tids (),
original_wait_for_stop_tids (),
request_thread_stop_function (request_thread_stop_function),
- error_function (error_function),
request_stop_on_all_unstopped_threads (true),
skip_stop_request_tids (skip_stop_request_tids)
{
@@ -524,7 +491,6 @@ namespace process_linux {
ThreadIDSet wait_for_stop_tids;
const ThreadIDSet original_wait_for_stop_tids;
StopThreadFunction request_thread_stop_function;
- ErrorFunction error_function;
const bool request_stop_on_all_unstopped_threads;
ThreadIDSet skip_stop_request_tids;
};
@@ -544,36 +510,30 @@ namespace process_linux {
std::mutex m_event_mutex; // Serializes execution of ProcessEvent. XXX
- void
- ThreadDidStop (lldb::tid_t tid, bool initiated_by_llgs, const ErrorFunction &error_function);
+ Error
+ ThreadDidStop(lldb::tid_t tid, bool initiated_by_llgs);
- void
+ Error
DoResume(lldb::tid_t tid, ResumeThreadFunction request_thread_resume_function,
- ErrorFunction error_function, bool error_when_already_running);
+ bool error_when_already_running);
void
DoStopThreads(PendingNotificationUP &¬ification_up);
void
- ThreadWasCreated (lldb::tid_t tid, bool is_stopped, const ErrorFunction &error_function);
+ ThreadWasCreated (lldb::tid_t tid, bool is_stopped);
void
- ThreadDidDie (lldb::tid_t tid, const ErrorFunction &error_function);
+ ThreadDidDie (lldb::tid_t tid);
bool
IsKnownThread(lldb::tid_t tid) const;
- void
- TSCLog (const char *format, ...);
-
// Member variables.
- LogFunction m_log_function;
PendingNotificationUP m_pending_notification_up;
// Maps known TIDs to ThreadContext.
TIDContextMap m_tid_map;
-
- bool m_log_event_processing;
};
} // namespace process_linux
More information about the lldb-commits
mailing list