Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Introduce new si_code for SIGTRAP: TRAP_CHLD - process c...



details:   https://anonhg.NetBSD.org/src/rev/3c976b40250c
branches:  trunk
changeset: 820432:3c976b40250c
user:      kamil <kamil%NetBSD.org@localhost>
date:      Tue Jan 10 00:48:37 2017 +0000

description:
Introduce new si_code for SIGTRAP: TRAP_CHLD - process child trap

The SIGTRAP signal is thrown from the kernel if EVENT_MASK (ptrace_event)
enables PTRACE_FORK. This new si_code helps debuggers to distinguish the
exact source of signal delivered for a debugger.

Another purpose of TRAP_CHLD is to retain the same behavior inside the
NetBSD kernel for process child traps and have an interface to monitor it.

Retrieving exact event and extended properties of process child trap is
available with PT_GET_PROCESS_STATE.

There is no behavior change for existing software.

This si_code value is NetBSD extension.

Sponsored by <The NetBSD Foundation>

diffstat:

 sys/kern/kern_fork.c |  5 +++--
 sys/sys/siginfo.h    |  3 ++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diffs (43 lines):

diff -r f5bc7f862eab -r 3c976b40250c sys/kern/kern_fork.c
--- a/sys/kern/kern_fork.c      Tue Jan 10 00:25:29 2017 +0000
+++ b/sys/kern/kern_fork.c      Tue Jan 10 00:48:37 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_fork.c,v 1.197 2017/01/09 00:31:30 kamil Exp $    */
+/*     $NetBSD: kern_fork.c,v 1.198 2017/01/10 00:48:37 kamil Exp $    */
 
 /*-
  * Copyright (c) 1999, 2001, 2004, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.197 2017/01/09 00:31:30 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.198 2017/01/10 00:48:37 kamil Exp $");
 
 #include "opt_ktrace.h"
 #include "opt_dtrace.h"
@@ -581,6 +581,7 @@
 
                KSI_INIT_EMPTY(&ksi);
                ksi.ksi_signo = SIGTRAP;
+               ksi.ksi_code = TRAP_CHLD;
                ksi.ksi_lid = l1->l_lid;
                kpsignal(p1, &ksi, NULL);
        }
diff -r f5bc7f862eab -r 3c976b40250c sys/sys/siginfo.h
--- a/sys/sys/siginfo.h Tue Jan 10 00:25:29 2017 +0000
+++ b/sys/sys/siginfo.h Tue Jan 10 00:48:37 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: siginfo.h,v 1.27 2017/01/06 22:42:58 kamil Exp $        */
+/*     $NetBSD: siginfo.h,v 1.28 2017/01/10 00:48:37 kamil Exp $        */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -211,6 +211,7 @@
 #define        TRAP_BRKPT      1       /* Process breakpoint                   */
 #define        TRAP_TRACE      2       /* Process trace trap                   */
 #define        TRAP_EXEC       3       /* Process exec trap                    */
+#define        TRAP_CHLD       4       /* Process child trap                   */
 
 /* SIGCHLD */
 #define        CLD_EXITED      1       /* Child has exited                     */



Home | Main Index | Thread Index | Old Index