PERFORCE change 102756 for review
Howard Su
howardsu at FreeBSD.org
Sun Jul 30 00:51:11 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=102756
Change 102756 by howardsu at su_vm on 2006/07/30 00:50:21
extend the ptrace(2) kernel part. Now the PT_LWPINFO will
give more information about why child is stoped.
TODO: update man page
Affected files ...
.. //depot/projects/dtrace/src/sys/kern/kern_exec.c#7 edit
.. //depot/projects/dtrace/src/sys/kern/kern_exit.c#6 edit
.. //depot/projects/dtrace/src/sys/kern/kern_sig.c#6 edit
.. //depot/projects/dtrace/src/sys/kern/sys_process.c#3 edit
.. //depot/projects/dtrace/src/sys/sys/proc.h#10 edit
.. //depot/projects/dtrace/src/sys/sys/ptrace.h#3 edit
Differences ...
==== //depot/projects/dtrace/src/sys/kern/kern_exec.c#7 (text+ko) ====
@@ -667,7 +667,6 @@
*/
if (p->p_flag & P_TRACED)
{
-printf("%s:%s(%d): SIGTRAP to debugger\n",__FUNCTION__,__FILE__,__LINE__);
tdsignal(p, td, SIGTRAP, NULL);
}
==== //depot/projects/dtrace/src/sys/kern/kern_exit.c#6 (text+ko) ====
@@ -433,7 +433,6 @@
* since their existence means someone is screwing up.
*/
if (q->p_flag & P_TRACED) {
-printf("%s:%s(%d): Kill a traced process\n",__FUNCTION__,__FILE__,__LINE__);
q->p_flag &= ~(P_TRACED | P_STOPPED_TRACE);
psignal(q, SIGKILL);
}
@@ -834,7 +833,6 @@
(p->p_suspcount == p->p_numthreads) &&
(p->p_flag & P_WAITED) == 0 &&
(p->p_flag & P_TRACED || options & WUNTRACED)) {
-printf("%s:%s(%d): \n",__FUNCTION__,__FILE__,__LINE__);
mtx_unlock_spin(&sched_lock);
p->p_flag |= P_WAITED;
sx_xunlock(&proctree_lock);
==== //depot/projects/dtrace/src/sys/kern/kern_sig.c#6 (text+ko) ====
@@ -58,6 +58,7 @@
#include <sys/namei.h>
#include <sys/proc.h>
#include <sys/pioctl.h>
+#include <sys/ptrace.h>
#include <sys/resourcevar.h>
#include <sys/sched.h>
#include <sys/sleepqueue.h>
@@ -2133,7 +2134,6 @@
* either winding down or already on the suspended queue.
*/
if (p->p_flag & P_TRACED) {
-printf("%s:%s(%d): the traced process is already stopped\n",__FUNCTION__,__FILE__,__LINE__);
/*
* The traced process is already stopped,
* so no further action is necessary.
@@ -2380,7 +2380,6 @@
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK,
&p->p_mtx.mtx_object, "Stopping for traced signal");
-printf("%s:%s(%d): stopping for a traced signal %d\n",__FUNCTION__,__FILE__,__LINE__,sig);
mtx_lock_spin(&sched_lock);
td->td_flags |= TDF_XSIG;
mtx_unlock_spin(&sched_lock);
@@ -2412,7 +2411,6 @@
PROC_LOCK(p);
if (!(p->p_flag & P_TRACED))
break;
-printf("%s:%s(%d): \n",__FUNCTION__,__FILE__,__LINE__);
if (td->td_flags & TDF_DBSUSPEND) {
if (p->p_flag & P_SINGLE_EXIT)
break;
@@ -2478,8 +2476,8 @@
/*
* If traced, always stop.
*/
-printf("%s:%s(%d): \n",__FUNCTION__,__FILE__,__LINE__);
mtx_unlock(&ps->ps_mtx);
+ td->td_xsig_why = PL_EVENT_SIGNAL;
newsig = ptracestop(td, sig);
mtx_lock(&ps->ps_mtx);
@@ -2559,7 +2557,6 @@
mtx_unlock(&ps->ps_mtx);
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK,
&p->p_mtx.mtx_object, "Catching SIGSTOP");
-printf("%s:%s(%d): catching SIGSTOP\n",__FUNCTION__,__FILE__,__LINE__);
p->p_flag |= P_STOPPED_SIG;
p->p_xstat = sig;
mtx_lock_spin(&sched_lock);
==== //depot/projects/dtrace/src/sys/kern/sys_process.c#3 (text+ko) ====
@@ -48,7 +48,7 @@
#include <sys/signalvar.h>
#include <machine/reg.h>
-
+#include <machine/frame.h>
#include <security/audit/audit.h>
#include <vm/vm.h>
@@ -939,13 +939,23 @@
}
pl = addr;
pl->pl_lwpid = td2->td_tid;
- if (td2->td_flags & TDF_XSIG)
- pl->pl_event = PL_EVENT_SIGNAL;
- else
- pl->pl_event = 0;
+ pl->pl_event = td2->td_xsig_why;
pl->pl_flags = 0;
pl->pl_sigmask = td2->td_sigmask;
pl->pl_siglist = td2->td_siglist;
+ if (data > (int)&((struct ptrace_lwpinfo *)NULL)->pl_sysnum) {
+ switch(td2->td_xsig_why){
+ case PL_EVENT_SYSENTER:
+ case PL_EVENT_SYSEXIT:
+ pl->pl_sysnum = td2->td_frame->tf_eax;
+ break;
+ case PL_EVENT_SIGNAL:
+ pl->pl_signal = td2->td_xsig;
+ break;
+ }
+ }
+
+
break;
case PT_GETNUMLWPS:
==== //depot/projects/dtrace/src/sys/sys/proc.h#10 (text+ko) ====
@@ -217,6 +217,7 @@
volatile u_int td_generation; /* (k) For detection of preemption */
stack_t td_sigstk; /* (k) Stack ptr and on-stack flag. */
int td_xsig; /* (c) Signal for ptrace */
+ int td_xsig_why; /* (c) reason for ptrace signal PL_EVENT_* */
u_long td_profil_addr; /* (k) Temporary addr until AST. */
u_int td_profil_ticks; /* (k) Temporary ticks until AST. */
char td_name[MAXCOMLEN + 1]; /* (*) Thread name. */
==== //depot/projects/dtrace/src/sys/sys/ptrace.h#3 (text+ko) ====
@@ -91,18 +91,29 @@
int pl_event; /* Event that stopped the LWP. */
#define PL_EVENT_NONE 0
#define PL_EVENT_SIGNAL 1
+#define PL_EVENT_SYSENTER 2
+#define PL_EVENT_SYSEXIT 3
int pl_flags; /* LWP flags. */
#define PL_FLAG_SA 0x01 /* M:N thread */
#define PL_FLAG_BOUND 0x02 /* M:N bound thread */
sigset_t pl_sigmask; /* LWP signal mask */
sigset_t pl_siglist; /* LWP pending signal */
+
+ union {
+ int _pl_sysnum;
+ int _pl_signal;
+ }pl_data;
};
+#define pl_sysnum pl_data._pl_sysnum
+#define pl_signal pl_data._pl_signal
+
#ifdef _KERNEL
#define PTRACESTOP_SC(p, td, flag) \
if ((p)->p_flag & P_TRACED && (p)->p_stops & (flag)) { \
PROC_LOCK(p); \
+ td->td_xsig_why = (flag==S_PT_SCE)?PL_EVENT_SYSENTER:PL_EVENT_SYSEXIT; \
ptracestop((td), SIGTRAP); \
PROC_UNLOCK(p); \
}
More information about the p4-projects
mailing list