Hi,
How do I obtain the exact reason of the process stop state?
Atm, I have a background thread that calls “m_listener.WaitForEvent(…)” once an event arrives
it extracts the process state from the event using the following method:
lldb::StateType state = m_process.GetStateFromEvent( event );
And I handle it accordingly.
However, if a process state is lldb::eStateStopped
I would like to know the reason why, e.g. ‘Breakpoint Hit’, ‘SIGSEGV’ etc
Any advice?
When doing multi-threaded debugging, you might have more than one thread that is stopped due to a signal, breakpoint, watchpoint etc. You you must ask the threads for their stop reason. A process doesn't stop for a reason, but threads do.
So you need to iterate through the threads:
uint32_t num_threads = process.GetNumThreads();
for (uint32_t i=0; i<num_threads; ++i)
{
SBThread thread = process.GetThreadAtIndex(i);
Then ask each thread for its stop reason:
lldb::StopReason stop_reason = thread.GetStopReason();
Then based on the thread stop reason, you can then query for more detailed info based on what "stop_reason" is:
/// Get the number of words associated with the stop reason.
/// See also GetStopReasonDataAtIndex().
size_t
SBThread::GetStopReasonDataCount();
//--------------------------------------------------------------------------
/// Get information associated with a stop reason.
///
/// Breakpoint stop reasons will have data that consists of pairs of
/// breakpoint IDs followed by the breakpoint location IDs (they always come
/// in pairs).
///
/// Stop Reason Count Data Type
/// ======================== ===== =========================================
/// eStopReasonNone 0
/// eStopReasonTrace 0
/// eStopReasonBreakpoint N duple: {breakpoint id, location id}
/// eStopReasonWatchpoint 1 watchpoint id
/// eStopReasonSignal 1 unix signal number
/// eStopReasonException N exception data
/// eStopReasonExec 0
/// eStopReasonPlanComplete 0
//--------------------------------------------------------------------------
uint64_t
SBThread::GetStopReasonDataAtIndex(uint32_t idx);
Thanks, this was exactly what I was looking for
Eran