Index: source/Plugins/Process/Linux/NativeProcessLinux.h =================================================================== --- source/Plugins/Process/Linux/NativeProcessLinux.h +++ source/Plugins/Process/Linux/NativeProcessLinux.h @@ -374,8 +374,6 @@ typedef std::unordered_set ThreadIDSet; // Callback/block definitions. - typedef std::function LogFunction; - typedef std::function ErrorFunction; typedef std::function StopThreadFunction; typedef std::function ResumeThreadFunction; @@ -384,16 +382,7 @@ // 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 @@ -402,16 +391,14 @@ 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 either 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 @@ -420,43 +407,32 @@ 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); + 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 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 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 @@ -478,26 +454,22 @@ public: 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 () { @@ -505,13 +477,11 @@ 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) { @@ -521,7 +491,6 @@ 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; }; @@ -541,35 +510,29 @@ std::mutex m_event_mutex; // Serializes execution of ProcessEvent. XXX void - ThreadDidStop (lldb::tid_t tid, bool initiated_by_llgs, const ErrorFunction &error_function); + ThreadDidStop(lldb::tid_t tid, bool initiated_by_llgs); void 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(std::unique_ptr &¬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; std::unique_ptr m_pending_notification_up; // Maps known TIDs to ThreadContext. TIDContextMap m_tid_map; - - bool m_log_event_processing; }; } // namespace process_linux Index: source/Plugins/Process/Linux/NativeProcessLinux.cpp =================================================================== --- source/Plugins/Process/Linux/NativeProcessLinux.cpp +++ source/Plugins/Process/Linux/NativeProcessLinux.cpp @@ -153,26 +153,6 @@ 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) { @@ -1644,9 +1624,7 @@ 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 () { } @@ -2324,7 +2302,7 @@ new_thread_sp = AddThread(tid); std::static_pointer_cast (new_thread_sp)->SetRunning (); Resume (tid, LLDB_INVALID_SIGNAL_NUMBER); - NotifyThreadCreate (tid, false, CoordinatorErrorHandler); + NotifyThreadCreate (tid, false); } void @@ -2467,8 +2445,7 @@ { std::static_pointer_cast (thread_sp)->SetRunning (); return Resume (tid_to_resume, (supress_signal) ? LLDB_INVALID_SIGNAL_NUMBER : signo); - }, - CoordinatorErrorHandler); + }); break; } @@ -2518,8 +2495,7 @@ { std::static_pointer_cast (thread_sp)->SetRunning (); return Resume (tid_to_resume, LLDB_INVALID_SIGNAL_NUMBER); - }, - CoordinatorErrorHandler); + }); break; default: @@ -2681,7 +2657,7 @@ // We can now resume the newly created thread. std::static_pointer_cast (thread_sp)->SetRunning (); Resume (pid, LLDB_INVALID_SIGNAL_NUMBER); - NotifyThreadCreate (pid, false, CoordinatorErrorHandler); + NotifyThreadCreate (pid, false); // Done handling. return; } @@ -2723,7 +2699,7 @@ linux_thread_sp->SetStoppedBySignal(0); SetCurrentThreadID (thread_sp->GetID ()); - NotifyThreadStop (thread_sp->GetID (), true, CoordinatorErrorHandler); + NotifyThreadStop (thread_sp->GetID (), true); } else { @@ -2779,8 +2755,7 @@ std::static_pointer_cast (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: @@ -3059,8 +3034,7 @@ if (resume_result.Success()) SetState(eStateRunning, true); return resume_result; - }, - CoordinatorErrorHandler); + }); break; } @@ -3083,8 +3057,7 @@ if (step_result.Success()) SetState(eStateStepping, true); return step_result; - }, - CoordinatorErrorHandler); + }); stepping = true; break; } @@ -4187,19 +4160,13 @@ 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); + NotifyThreadCreate (tid, is_stopped); } void NativeProcessLinux::NotifyThreadStop (lldb::tid_t tid) { - NotifyThreadStop (tid, false, CoordinatorErrorHandler); + NotifyThreadStop (tid, false); } void @@ -4211,8 +4178,7 @@ 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 @@ -4226,8 +4192,7 @@ 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 @@ -4292,43 +4257,28 @@ 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; - } + assert(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; + + assert(!(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. + if (log) + log->Printf("NativeProcessLinux::%s tid %" PRIu64 " optional resume skipped since it is already running", + __FUNCTION__, + tid); return; } @@ -4338,18 +4288,18 @@ // 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); @@ -4366,9 +4316,9 @@ 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 ()); } @@ -4380,73 +4330,71 @@ 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 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(std::unique_ptr(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 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(std::unique_ptr(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 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(std::unique_ptr(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__); } } @@ -4474,18 +4422,7 @@ // 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; - } + assert(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; @@ -4543,25 +4480,20 @@ 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) +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; - } + assert(find_it != m_tid_map.end()); // Update the global list of known thread states. This one is definitely stopped. auto& context = find_it->second; @@ -4578,17 +4510,19 @@ 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 ()) { context.m_state = ThreadState::Running; } - 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 ()); } } @@ -4598,22 +4532,14 @@ NativeProcessLinux::DoStopThreads(std::unique_ptr &¬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 ()); + assert(IsKnownThread (notification_up->triggering_tid)); - // We bail out here. - return; - } - - 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); @@ -4632,18 +4558,10 @@ } 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; - } + assert(m_tid_map.find(tid) == m_tid_map.end()); // Add the new thread to the stop map. ThreadContext ctx; @@ -4660,18 +4578,11 @@ } 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; - } + assert(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 @@ -4687,127 +4598,116 @@ } 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) +NativeProcessLinux::NotifyThreadStop (lldb::tid_t tid, bool initiated_by_llgs) { + Log *const log = GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD); std::lock_guard 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); + 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__); } } void 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 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); + 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__); } } void 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 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); + 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__); } } 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 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 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 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. @@ -4819,16 +4719,11 @@ // 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