Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

lldb equivalent of gdb's "follow-fork-mode" or "detach-on-fork"

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.

like image 379
ryanrhee Avatar asked Oct 06 '13 01:10

ryanrhee


Video Answer


1 Answers

It looks like follow-fork-mode was just recently merged into LLDB's main branch.

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

This code is newer than the LLVM 13.0.0 release and isn't in the 13.0.1 release, so probably until there's a LLVM 14.0.0 release you would have to build it from source or perhaps use brew install --HEAD llvm. For macOS you would also have to codesign lldb.

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

like image 61
Alexander O'Mara Avatar answered Sep 22 '22 17:09

Alexander O'Mara