I know how to wait and attach to a local process (process attach --name procname --waitfor
).
I also know how to run a remote debugserver
and connect to it.
But how can I wait for a process to start on a remote host and attach to it?
EDIT
I have tried @Jim's suggestion, and it seems like the debug server is actually trying to attach but failing.
I am accepting his answer since it is correct, but I will be happy to know why I can't really debug the process.
FYI I am trying to debug mdmd (mdm daemon service) on a JB iPhone. The process launches for a few seconds to communicate with the mdm server, and then dies.
This is from the target's terminal:
~ root# debugserver *:1234
debugserver-310.2 for arm64.
Listening to port 1234 for a connection from *...
Got a connection, waiting for process information for launching or attaching.
Attach succeeded, ready to debug.
Exiting.
And this is from lldb's:
(lldb) process connect connect://localhost:1234
(lldb) process attach --name mdmd --waitfor
error: attach failed: unable to attach
The main difference between LLDB and GDB is that in LLDB, the programmer can debug programs written in C, Objective C and C++ while, in GDB, the programmer can debug programs written in Ada, C, C++, Objective C, Pascal, FORTRAN and Go.
LLDB supports GDB server that QEMU uses, so you can do the same thing with the previous section, but with some command modification as LLDB has some commands that are different than GDB You can run QEMU to listen for a "GDB connection" before it starts executing any code to debug it.
In lldb you can set breakpoints by typing either break or b followed by information on where you want the program to pause. After the b command, you can put either: a function name (e.g., b my_subroutine ) a line number (e.g., b 12 )
The easiest way to do this is to start up the remote debugserver with only the port to connect to and no other arguments. In that mode it is driven completely by the lldb connected to it. So then just do:
(lldb) process attach --name procname --waitfor
and that will instruct the remote debugserver to wait for that process to show up and then it will attach to it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With