[=](lldb::tid_t tid_to_resume, bool supress_signal)
{
reinterpret_cast<NativeThreadLinux*> (new_thread_sp.get ())->SetRunning ();
- Resume (tid_to_resume, LLDB_INVALID_SIGNAL_NUMBER);
+ return Resume (tid_to_resume, LLDB_INVALID_SIGNAL_NUMBER);
},
CoordinatorErrorHandler);
}
[=](lldb::tid_t tid_to_resume, bool supress_signal)
{
reinterpret_cast<NativeThreadLinux*> (thread_sp.get ())->SetRunning ();
- Resume (tid_to_resume, LLDB_INVALID_SIGNAL_NUMBER);
+ return Resume (tid_to_resume, LLDB_INVALID_SIGNAL_NUMBER);
},
CoordinatorErrorHandler);
[=](lldb::tid_t tid_to_resume, bool supress_signal)
{
reinterpret_cast<NativeThreadLinux*> (thread_sp.get ())->SetRunning ();
- Resume (tid_to_resume, (supress_signal) ? LLDB_INVALID_SIGNAL_NUMBER : signo);
+ return Resume (tid_to_resume, (supress_signal) ? LLDB_INVALID_SIGNAL_NUMBER : signo);
},
CoordinatorErrorHandler);
[=](lldb::tid_t tid_to_resume, bool supress_signal)
{
reinterpret_cast<NativeThreadLinux*> (thread_sp.get ())->SetRunning ();
- Resume (tid_to_resume, LLDB_INVALID_SIGNAL_NUMBER);
+ return Resume (tid_to_resume, LLDB_INVALID_SIGNAL_NUMBER);
},
CoordinatorErrorHandler);
break;
[=](lldb::tid_t tid_to_resume, bool supress_signal)
{
reinterpret_cast<NativeThreadLinux*> (thread_sp.get ())->SetRunning ();
- Resume (tid_to_resume, LLDB_INVALID_SIGNAL_NUMBER);
+ return Resume (tid_to_resume, LLDB_INVALID_SIGNAL_NUMBER);
},
CoordinatorErrorHandler);
}
{
reinterpret_cast<NativeThreadLinux*> (thread_sp.get ())->SetRunning ();
// Pass this signal number on to the inferior to handle.
- Resume (tid_to_resume, (supress_signal) ? LLDB_INVALID_SIGNAL_NUMBER : signo);
+ return Resume (tid_to_resume, (supress_signal) ? LLDB_INVALID_SIGNAL_NUMBER : signo);
},
CoordinatorErrorHandler);
}
{
reinterpret_cast<NativeThreadLinux*> (thread_sp.get ())->SetRunning ();
// Pass this signal number on to the inferior to handle.
- Resume (tid_to_resume, (signo > 0 && !supress_signal) ? signo : LLDB_INVALID_SIGNAL_NUMBER);
+ return Resume (tid_to_resume, (signo > 0 && !supress_signal) ? signo : LLDB_INVALID_SIGNAL_NUMBER);
},
CoordinatorErrorHandler);
++resume_count;
[=](lldb::tid_t tid_to_step, bool supress_signal)
{
reinterpret_cast<NativeThreadLinux*> (thread_sp.get ())->SetStepping ();
- auto step_result = SingleStep (tid_to_step,(signo > 0 && !supress_signal) ? signo : LLDB_INVALID_SIGNAL_NUMBER);
- assert (step_result && "SingleStep() failed");
+ const auto step_result = SingleStep (tid_to_step,(signo > 0 && !supress_signal) ? signo : LLDB_INVALID_SIGNAL_NUMBER);
+ assert (step_result.Success() && "SingleStep() failed");
+ return step_result;
},
CoordinatorErrorHandler);
stepping = true;
m_coordinator_up->CallAfterRunningThreadsStop (tid,
[=](lldb::tid_t request_stop_tid)
{
- RequestThreadStop(pid, request_stop_tid);
+ return RequestThreadStop(pid, request_stop_tid);
},
call_after_function,
CoordinatorErrorHandler);
skip_stop_request_tid != LLDB_INVALID_THREAD_ID ? ThreadStateCoordinator::ThreadIDSet {skip_stop_request_tid} : ThreadStateCoordinator::ThreadIDSet (),
[=](lldb::tid_t request_stop_tid)
{
- RequestThreadStop(pid, request_stop_tid);
+ return RequestThreadStop(pid, request_stop_tid);
},
call_after_function,
CoordinatorErrorHandler);
public:
EventCallAfterThreadsStop (lldb::tid_t triggering_tid,
const ThreadIDSet &wait_for_stop_tids,
- const ThreadIDFunction &request_thread_stop_function,
+ const StopThreadFunction &request_thread_stop_function,
const ThreadIDFunction &call_after_function,
const ErrorFunction &error_function):
EventBase (),
}
EventCallAfterThreadsStop (lldb::tid_t triggering_tid,
- const ThreadIDFunction &request_thread_stop_function,
+ const StopThreadFunction &request_thread_stop_function,
const ThreadIDFunction &call_after_function,
const ErrorFunction &error_function) :
EventBase (),
}
EventCallAfterThreadsStop (lldb::tid_t triggering_tid,
- const ThreadIDFunction &request_thread_stop_function,
+ const StopThreadFunction &request_thread_stop_function,
const ThreadIDFunction &call_after_function,
const ThreadIDSet &skip_stop_request_tids,
const ErrorFunction &error_function) :
}
// If the pending stop thread is currently running, we need to send it a stop request.
- if (find_it->second.m_state == ThreadState::Running)
+ auto& context = find_it->second;
+ if (context.m_state == ThreadState::Running)
{
- m_request_thread_stop_function (tid);
- RequestThreadStop (tid, find_it->second);
+ RequestThreadStop (tid, coordinator, context);
sent_tids.insert (tid);
}
}
// Request this thread stop if the tid stop request is not explicitly ignored.
const bool skip_stop_request = m_skip_stop_request_tids.count (tid) > 0;
if (!skip_stop_request)
- RequestThreadStop (tid, it->second);
+ RequestThreadStop (tid, coordinator, it->second);
// Even if we skipped sending the stop request for other reasons (like stepping),
// we still need to wait for that stepping thread to notify completion/stop.
}
void
- RequestThreadStop (lldb::tid_t tid, ThreadContext& context)
+ RequestThreadStop (lldb::tid_t tid, ThreadStateCoordinator &coordinator, ThreadContext& context)
{
- m_request_thread_stop_function (tid);
- context.m_stop_requested = true;
+ const auto error = m_request_thread_stop_function (tid);
+ if (error.Success ())
+ {
+ context.m_stop_requested = true;
+ }
+ else
+ {
+ coordinator.Log ("EventCallAfterThreadsStop::%s failed to request thread stop tid %" PRIu64 ": %s",
+ __FUNCTION__, tid, error.AsCString ());
+ }
}
const lldb::tid_t m_triggering_tid;
ThreadIDSet m_wait_for_stop_tids;
const ThreadIDSet m_original_wait_for_stop_tids;
- ThreadIDFunction m_request_thread_stop_function;
+ StopThreadFunction m_request_thread_stop_function;
ThreadIDFunction m_call_after_function;
ErrorFunction m_error_function;
const bool m_request_stop_on_all_unstopped_threads;
// Request a resume. We expect this to be synchronous and the system
// to reflect it is running after this completes.
- m_request_thread_resume_function (m_tid, false);
-
- // Now mark it is running.
- context.m_state = ThreadState::Running;
- context.m_request_resume_function = m_request_thread_resume_function;
+ const auto error = m_request_thread_resume_function (m_tid, false);
+ if (error.Success ())
+ {
+ // Now mark it is running.
+ context.m_state = ThreadState::Running;
+ context.m_request_resume_function = m_request_thread_resume_function;
+ }
+ else
+ {
+ coordinator.Log ("EventRequestResume::%s failed to resume thread tid %" PRIu64 ": %s",
+ __FUNCTION__, m_tid, error.AsCString ());
+ }
return eventLoopResultContinue;
}
void
ThreadStateCoordinator::CallAfterThreadsStop (const lldb::tid_t triggering_tid,
const ThreadIDSet &wait_for_stop_tids,
- const ThreadIDFunction &request_thread_stop_function,
+ const StopThreadFunction &request_thread_stop_function,
const ThreadIDFunction &call_after_function,
const ErrorFunction &error_function)
{
void
ThreadStateCoordinator::CallAfterRunningThreadsStop (const lldb::tid_t triggering_tid,
- const ThreadIDFunction &request_thread_stop_function,
+ const StopThreadFunction &request_thread_stop_function,
const ThreadIDFunction &call_after_function,
const ErrorFunction &error_function)
{
void
ThreadStateCoordinator::CallAfterRunningThreadsStopWithSkipTIDs (lldb::tid_t triggering_tid,
const ThreadIDSet &skip_stop_request_tids,
- const ThreadIDFunction &request_thread_stop_function,
+ const StopThreadFunction &request_thread_stop_function,
const ThreadIDFunction &call_after_function,
const ErrorFunction &error_function)
{
// 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.
Log ("Resuming thread %" PRIu64 " since stop wasn't requested", tid);
- context.m_request_resume_function (tid, true);
- context.m_state = ThreadState::Running;
+ const auto error = context.m_request_resume_function (tid, true);
+ if (error.Success ())
+ {
+ context.m_state = ThreadState::Running;
+ }
+ else
+ {
+ Log ("ThreadStateCoordinator::%s failed to resume thread tid %" PRIu64 ": %s",
+ __FUNCTION__, tid, error.AsCString ());
+ }
}
}
#include "lldb/lldb-types.h"
+#include "lldb/Core/Error.h"
+
namespace lldb_private
{
class ThreadStateCoordinator
typedef std::function<void (lldb::tid_t tid)> ThreadIDFunction;
typedef std::function<void (const char *format, va_list args)> LogFunction;
typedef std::function<void (const std::string &error_message)> ErrorFunction;
- typedef std::function<void (lldb::tid_t tid, bool supress_signal)> ResumeThreadFunction;
+ typedef std::function<Error (lldb::tid_t tid)> StopThreadFunction;
+ typedef std::function<Error (lldb::tid_t tid, bool supress_signal)> ResumeThreadFunction;
// Constructors.
ThreadStateCoordinator (const LogFunction &log_function);
void
CallAfterThreadsStop (lldb::tid_t triggering_tid,
const ThreadIDSet &wait_for_stop_tids,
- const ThreadIDFunction &request_thread_stop_function,
+ const StopThreadFunction &request_thread_stop_function,
const ThreadIDFunction &call_after_function,
const ErrorFunction &error_function);
// be fired if the triggering tid is unknown at the time of execution.
void
CallAfterRunningThreadsStop (lldb::tid_t triggering_tid,
- const ThreadIDFunction &request_thread_stop_function,
+ const StopThreadFunction &request_thread_stop_function,
const ThreadIDFunction &call_after_function,
const ErrorFunction &error_function);
void
CallAfterRunningThreadsStopWithSkipTIDs (lldb::tid_t triggering_tid,
const ThreadIDSet &skip_stop_request_tids,
- const ThreadIDFunction &request_thread_stop_function,
+ const StopThreadFunction &request_thread_stop_function,
const ThreadIDFunction &call_after_function,
const ErrorFunction &error_function);