10

Does lldb have an equivalent to either of these gdb directives? I'm trying to make it follow a child process instead of the parent without having to do this manual process:

  1. break on fork
  2. pgrep for the child process
  3. spin up another lldb process and attach to the child
  4. continue the parent

Some googling did not provide any insight.

Context: I'm using NSTask & injecting a dylib using dyld, and want to set breakpoints in my library without lots of pain. I'm pretty sure NSTask uses fork() internally.

2
  • duplicate of stackoverflow.com/questions/14746315/… Nov 18, 2013 at 1:20
  • 4
    This is not a duplicate of the aforementioned question. There's a difference between attaching to a child process and following both child+parent process. Not to mention, there's a difference between doing it automatically & manually - the answer for the given question does it manually, which I already list as my current workflow.
    – ryanrhee
    Nov 19, 2013 at 1:33

2 Answers 2

9

follow-fork-mode was merged into LLDB's main branch and is available starting in version 14.0.0.

settings set target.process.follow-fork-mode child

If your version of LLDB is based on LLVM 14.0.0 it should be available. Alternately you can build it from source or use brew install llvm. For macOS you would also have to codesign lldb.

Eventually it should make it into Apple's CLI tools too, although I do not know what the timeline on that is likely to be.

4

lldb does not currently support "follow-fork-mode". You can often achieve the same effect using lldb's "attach --wait-for" or in Xcode by choosing the "wait for to be launched manually" option in the Run scheme for the target you are debugging. These will grab the first NEW occurrence of a process with the given name.

1
  • 2
    has follow-fork-mode not been implemented yet? :)
    – Shuzheng
    Oct 29, 2019 at 10:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.