tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
PT_[GS]ET_SIGINFO in ptrace(2)
The current implementation of ptrace(2) has missing interface to
retrieve and fake a value of siginfo_t of a signal that was interjected
by a tracer. The former is required to help to determine exact event
that happened in the code and the latter to programmatically fake routed
signal to tracee in terms of si_code and other values as described in
siginfo(5). Both accessors make use in debuggers.
Code:
http://netbsd.org/~kamil/patch-00026-pl_siginfo.5.txt
The PT_GET_SIGINFO call is destinated to be used now in LLDB
(pkgsrc-wip/lldb-netbsd) in the NetBSD Process Plugin. The functionality
of PT_SET_SIGINFO is planned to be used (by myself) long-term.
I've added two new dedicated ptrace(2) calls for this
#define PT_SET_SIGINFO 19 /* set signal state, defined below */
#define PT_GET_SIGINFO 20 /* get signal state, defined below */
I've added new structure ptrace_siginfo to be used to communicate
user-space and kernel-space with the following shape:
/*
* Signal Information structure
*/
typedef struct ptrace_siginfo {
siginfo_t psi_siginfo; /* signal information structure */
lwpid_t psi_lwpid; /* destination LWP of the signal
* value 0 means the whole process
* (route signal to all LWPs) */
} ptrace_siginfo_t;
This interface is close to the Linux one:
PTRACE_GETSIGINFO (since Linux 2.3.99-pre6)
Retrieve information about the signal that caused the stop. Copy a
siginfo_t structure (see sigaction(2)) from the tracee to the
address data in the tracer. (addr is ignored.)
PTRACE_SETSIGINFO (since Linux 2.3.99-pre6)
Set signal information: copy a siginfo_t structure from the
address data in the tracer to the tracee. This will affect only
signals that would normally be delivered to the tracee and were
caught by the tracer. It may be difficult to tell these normal
signals from synthetic signals generated by ptrace() itself.
(addr is ignored.)
On FreeBSD there exists only an interface to retrieve siginfo_t in
per-thread manner as a member pl_siginfo of the ptrace_lwpinfo
structure. This approach isn't applicable to the current NetBSD design
as PT_LWPINFO is used to iterate over all threads - not just to retrieve
the one that caused process to be interrupted. Also it has no interface
to inject new faked signal.
I'm attaching three basic ATF tests:
- siginfo1 - test PT_GET_SIGINFO
- siginfo2 - test PT_GET_SIGINFO and PT_SET_SIGINFO without changing
signal's information
- siginfo3 - test PT_GET_SIGINFO and PT_SET_SIGINFO with faking
signal's information
All the ATF tests are passing correctly.
Home |
Main Index |
Thread Index |
Old Index