[lldb-dev] starting a process in stop-at-entry-point mode on Linux

Todd R. Fiala todd.fiala at gmail.com
Wed Jul 23 16:44:16 PDT 2014


Hey Greg,

I’m looking into implementing process start-up so I can just follow your flow of launching the exe, then connecting via llgs with reverse connect.  I’d like to take a shot at getting Linux processes to start up in a “stopped at initial entry point” behavior rather than doing something different than MacOSX at this point.

Linux PTRACE doesn’t provide this out of the box.  There is an alternative that could work but is not reliable across Linux kernel versions: detaching from a PTRACE’d exe during a group-stop will leave it stopped.  I think the initial startup signal I get with PTRACE may yield a group stop.  If it’s not, I can immediately turn around and issue a stop, deliver that and get the real group stop.  (Not 100% sure I could do that last part with guaranteed no-execution semantics at the entry point location).  Unfortunately, the detach is not reliable everywhere I need this to run to keep the process in a stopped state at that point for handoff to llgs.

What I could do instead, is fork, and have the child process self-send a SIGSTOP before doing the exec.  And, on Linux (and maybe FreeBSD), when llgs attaches, it just needs to know that it has to wait for one exec signal before the process really starts. (I’m not sure if there is a shell mode for debugging with Linux - if there is, then we need to exec through the shell script too, I think — I don’t remember seeing that on the linux code path so it likely is buggy and/or unsupported at the moment).  In any event, if I do this, I’m pretty sure I can guarantee that I can start a process in debug-ready mode with the caveat that there is an exec that has to be silently ignored when llgs attaches.

How does that sound?  Thoughts?

-Todd



More information about the lldb-dev mailing list