Skip to content

Commit 7030623

Browse files
committed
[lldb][docs] Add strace example to Debugging doc
This has been very useful lately debugging remote connections. In some cases it's probably better than our own logging.
1 parent 9022f40 commit 7030623

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

lldb/docs/resources/debugging.rst

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,26 @@ child processes.
213213
The same goes for ``printf``. If it's called in a child process you won't see
214214
the output.
215215

216-
In these cases consider either interactive debugging ``lldb-server`` or
216+
In these cases consider interactive debugging ``lldb-server`` or
217217
working out a more specific command such that it does not have to spawn a
218218
subprocess. For example if you start with ``platform`` mode, work out what
219219
``gdbserver`` mode process it spawns and run that command instead.
220220

221+
Another option if you have ``strace`` available is to trace the whole process
222+
tree and inspect the logs after the session has ended. ::
223+
224+
$ strace -ff -o log -p $(pidof lldb-server)
225+
226+
This will log all syscalls made by ``lldb-server`` and processes that it forks.
227+
``-ff`` tells ``strace`` to trace child processes and write the results to a
228+
separate file for each process, named using the prefix given by ``-o``.
229+
230+
Search the log files for specific terms to find the process you're interested
231+
in. For example, to find a process that acted as a ``gdbserver`` instance::
232+
233+
$ grep "gdbserver" log.*
234+
log.<N>:execve("<...>/lldb-server", [<...> "gdbserver", <...>) = 0
235+
221236
Remote Debugging
222237
----------------
223238

0 commit comments

Comments
 (0)