Module Name: src
Committed By: christos
Date: Sat Jun 23 03:32:48 UTC 2018
Modified Files:
src/sys/kern: sys_ptrace_common.c
Log Message:
Add some debugging in case someone else wants to debug gdb...
To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/kern/sys_ptrace_common.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/kern/sys_ptrace_common.c
diff -u src/sys/kern/sys_ptrace_common.c:1.44 src/sys/kern/sys_ptrace_common.c:1.45
--- src/sys/kern/sys_ptrace_common.c:1.44 Wed May 30 19:54:03 2018
+++ src/sys/kern/sys_ptrace_common.c Fri Jun 22 23:32:48 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: sys_ptrace_common.c,v 1.44 2018/05/30 23:54:03 kamil Exp $ */
+/* $NetBSD: sys_ptrace_common.c,v 1.45 2018/06/23 03:32:48 christos Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -118,7 +118,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.44 2018/05/30 23:54:03 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.45 2018/06/23 03:32:48 christos Exp $");
#ifdef _KERNEL_OPT
#include "opt_ptrace.h"
@@ -154,8 +154,7 @@ __KERNEL_RCSID(0, "$NetBSD: sys_ptrace_c
#include <machine/reg.h>
#ifdef PTRACE
-
-# ifdef DEBUG
+# ifdef PTRACE_DEBUG
# define DPRINTF(a) uprintf a
# else
# define DPRINTF(a)
@@ -573,6 +572,8 @@ ptrace_get_siginfo(struct proc *t, struc
psi.psi_siginfo._info = t->p_sigctx.ps_info;
psi.psi_lwpid = t->p_sigctx.ps_lwp;
+ DPRINTF(("%s: lwp=%d signal=%d\n", __func__, psi.psi_lwpid,
+ psi.psi_siginfo.si_signo));
return ptm->ptm_copyout_siginfo(&psi, addr, data);
}
@@ -597,6 +598,8 @@ ptrace_set_siginfo(struct proc *t, struc
t->p_sigctx.ps_faked = true;
t->p_sigctx.ps_info = psi.psi_siginfo._info;
t->p_sigctx.ps_lwp = psi.psi_lwpid;
+ DPRINTF(("%s: lwp=%d signal=%d\n", __func__, psi.psi_lwpid,
+ psi.psi_siginfo.si_signo));
return 0;
}
@@ -620,6 +623,8 @@ ptrace_get_event_mask(struct proc *t, vo
PTRACE_LWP_CREATE : 0;
pe.pe_set_event |= ISSET(t->p_slflag, PSL_TRACELWP_EXIT) ?
PTRACE_LWP_EXIT : 0;
+ DPRINTF(("%s: lwp=%d event=%#x\n", __func__,
+ t->p_sigctx.ps_lwp, pe.pe_set_event));
return copyout(&pe, addr, sizeof(pe));
}
@@ -636,6 +641,8 @@ ptrace_set_event_mask(struct proc *t, vo
if ((error = copyin(addr, &pe, sizeof(pe))) != 0)
return error;
+ DPRINTF(("%s: lwp=%d event=%#x\n", __func__,
+ t->p_sigctx.ps_lwp, pe.pe_set_event));
if (pe.pe_set_event & PTRACE_FORK)
SET(t->p_slflag, PSL_TRACEFORK);
else
@@ -690,6 +697,9 @@ ptrace_get_process_state(struct proc *t,
ps.pe_report_event = PTRACE_LWP_EXIT;
ps.pe_lwp = t->p_lwp_exited;
}
+ DPRINTF(("%s: lwp=%d event=%#x pid=%d lwp=%d\n", __func__,
+ t->p_sigctx.ps_lwp, ps.pe_report_event,
+ ps.pe_other_pid, ps.pe_lwp));
return copyout(&ps, addr, sizeof(ps));
}
@@ -739,10 +749,16 @@ ptrace_lwpinfo(struct proc *t, struct lw
*/
else if ((*lt)->l_lid == t->p_sigctx.ps_lwp
|| (t->p_sigctx.ps_lwp == 0 &&
- t->p_sigctx.ps_info._signo))
+ t->p_sigctx.ps_info._signo)) {
+ DPRINTF(("%s: lwp=%d siglwp=%d signo %d\n", __func__,
+ pl.pl_lwpid, t->p_sigctx.ps_lwp,
+ t->p_sigctx.ps_info._signo));
pl.pl_event = PL_EVENT_SIGNAL;
+ }
}
mutex_exit(t->p_lock);
+ DPRINTF(("%s: lwp=%d event=%#x\n", __func__,
+ pl.pl_lwpid, pl.pl_event));
return copyout(&pl, addr, sizeof(pl));
}
@@ -756,6 +772,7 @@ ptrace_startstop(struct proc *t, struct
if ((error = ptrace_update_lwp(t, lt, data)) != 0)
return error;
+ DPRINTF(("%s: lwp=%d request=%d\n", __func__, (*lt)->l_lid, rq));
lwp_lock(*lt);
if (rq == PT_SUSPEND)
(*lt)->l_flag |= LW_WSUSPEND;
@@ -798,6 +815,8 @@ ptrace_regs(struct lwp *l, struct lwp **
size_t size;
int (*func)(struct lwp *, struct lwp *, struct uio *);
+ DPRINTF(("%s: lwp=%d request=%d\n", __func__, l->l_lid, rq));
+
switch (rq) {
#if defined(PT_SETREGS) || defined(PT_GETREGS)
case_PT_GETREGS
@@ -899,6 +918,8 @@ ptrace_sendsig(struct proc *t, struct lw
} else {
ksi.ksi_signo = signo;
}
+ DPRINTF(("%s: pid=%d.%d signal=%d resume_all=%d\n", __func__, t->p_pid,
+ t->p_sigctx.ps_lwp, signo, resume_all));
kpsignal2(t, &ksi);
return 0;
@@ -920,6 +941,7 @@ ptrace_dumpcore(struct lwp *lt, char *pa
goto out;
path[len] = '\0';
}
+ DPRINTF(("%s: lwp=%d\n", __func__, lt->l_lid));
error = (*coredump_vec)(lt, path);
out:
if (path)
@@ -943,6 +965,8 @@ ptrace_doio(struct lwp *l, struct proc *
uio.uio_offset = (off_t)(unsigned long)piod->piod_offs;
uio.uio_resid = piod->piod_len;
+ DPRINTF(("%s: lwp=%d request=%d\n", __func__, l->l_lid, piod->piod_op));
+
switch (piod->piod_op) {
case PIOD_READ_D:
case PIOD_READ_I: