[lldb-dev] How to get the 'stop' reason of SBProcess

Eran Ifrah eran.ifrah at gmail.com
Thu Apr 17 14:31:02 PDT 2014


Thanks, this was exactly what I was looking for

Eran


On Thu, Apr 17, 2014 at 10:39 PM, Greg Clayton <gclayton at apple.com> wrote:

> 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);
>
>
>
> On Apr 17, 2014, at 11:49 AM, Eran Ifrah <eran.ifrah at gmail.com> wrote:
>
> > 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?
> >
> > --
> > Eran Ifrah
> > Author of codelite, a cross platform open source C/C++ IDE:
> http://www.codelite.org
> > wxCrafter, a wxWidgets RAD: http://wxcrafter.codelite.org
> > _______________________________________________
> > lldb-dev mailing list
> > lldb-dev at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev
>
>


-- 
Eran Ifrah
Author of codelite, a cross platform open source C/C++ IDE:
http://www.codelite.org
wxCrafter, a wxWidgets RAD: http://wxcrafter.codelite.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20140418/7334515b/attachment.html>


More information about the lldb-dev mailing list