[lldb-dev] Why did the process stop?

David Jones djones at xtreme-eda.com
Sun Jun 28 18:16:51 PDT 2015


I am experimenting with the LLDB SB API to add debug capability to a
compiler.

Right now I'd like to print out a backtrace when a program "crashes". Let's
define "crash" as "receive SIGILL or SIGSEGV".

I have a small routine that forks, runs the compiled program as a child,
and has the parent attach to the child.  I get an SBProcess handle, and
then:

                m_Process.Continue();

                state = m_Process.GetState();
                while (state != eStateExited) {
                    if (state == eStateStopped) {
                        dumpBackTrace();
                        m_Process.Detach(false);
                        break;
                    }
                    m_Process.Continue();
                    state = m_Process.GetState();
                }

However, a process may stop for many reasons: it may hit a breakpoint, or
it may get a signal other than one that indicates a crash. In particular,
to synchronize parent and child, I have the child pause(), and the parent
sends SIGUSR1 once it's attached. I do not want the receipt of SIGUSR1 to
cause a backtrace.

So:

1. How do I determine that a process has entered eStateStopped because it
received a signal?
2. How do I determine which signal was received?

The Doxygen docs don't have any detail, and none of the C/Python examples
seem to go into this much detail.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20150628/b92712e4/attachment.html>


More information about the lldb-dev mailing list