[lldb-dev] RFC: siginfo reading/writing support

Michał Górny via lldb-dev lldb-dev at lists.llvm.org
Tue Jan 11 04:38:07 PST 2022


Hello,

TL;DR: I'd like to implement at least partial support for
reading/writing siginfo via LLDB.  I can't think of a better approach
than copying the GDB's idea of "magical" $_siginfo variable that works
through the expression evaluator.  I'd like to know your opinion/ideas.


POSIX defines a siginfo_t structure that is used to pass additional
signal information -- such as more detailed signal code, faulting memory
address in case of SIGSEGV or PID of the child process in case of
SIGCHLD.  LLDB already uses ptrace(2) to obtain this information and use
it internally but it doesn't expose it to the user.

The GDB Remote Serial protocol provides the ability to read/write
siginfo via qXfer:siginfo:... packets [1].  GDB exposes this information
to the user via a special $_siginfo variable [2].

A few things to note:

1. Some targets (e.g. Linux, NetBSD) support overwriting siginfo, some
(e.g. FreeBSD) only reading.

2. Siginfo is generally associated with a single thread, so the packets
should be combined with respective thread selection (Hg or Hc?).

3. The exact type of siginfo_t differs per platform (POSIX specifies
a minimal subset).


My rough idea right now is to follow GDB here.  While using "$_siginfo"
may seem hacky, it has the nice advantage that it can easily support all
different siginfo_t structures used by various platforms.

The plan would be to:

1. Implement the qXfer:siginfo:... packets in lldb-server, and add tests
to them.

2. Implement support for "$_siginfo" in the client (I suppose this means
hacking on expression evaluator).

3. (Optionally) implement hardcoded siginfo_t definitions for common
platforms to make things work without debug info.

WDYT?


[1]
https://www.sourceware.org/gdb/onlinedocs/gdb/General-Query-Packets.html#qXfer-siginfo-read
[2] https://sourceware.org/gdb/current/onlinedocs/gdb.html#Signals


-- 
Best regards,
Michał Górny




More information about the lldb-dev mailing list