Make tracing easier by allowing us to start via /proc/pid/ctl
authorRonald G. Minnich <rminnich@gmail.com>
Tue, 23 Sep 2014 23:25:27 +0000 (23:25 +0000)
committerRonald G. Minnich <rminnich@gmail.com>
Tue, 23 Sep 2014 23:25:53 +0000 (23:25 +0000)
echo trace > /proc/pid/ctl

starts tracing.

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
kern/drivers/dev/proc.c
kern/include/syscall.h
kern/src/syscall.c

index d3102b2..99c08cd 100644 (file)
@@ -1447,7 +1447,9 @@ static void procctlreq(struct proc *p, char *va, int n)
                default:
                        error("nope\n");
                        break;
-
+               case CMtrace:
+                       systrace_trace_pid(p);
+                       break;
                case CMclose:
                        procctlclosefiles(p, 0, atoi(cb->f[1]));
                        break;
index c5ec9d4..223133f 100644 (file)
@@ -68,6 +68,7 @@ void __signal_syscall(struct syscall *sysc, struct proc *p);
 
 /* Tracing functions */
 void systrace_start(bool silent);
+int systrace_trace_pid(struct proc *p);
 void systrace_stop(void);
 int systrace_reg(bool all, struct proc *p);
 int systrace_dereg(bool all, struct proc *p);
index 6cf286a..2b4c58f 100644 (file)
@@ -2410,6 +2410,14 @@ int systrace_reg(bool all, struct proc *p)
        return retval;
 }
 
+int systrace_trace_pid(struct proc *p)
+{
+       if (systrace_reg(false, p))
+               error("no more processes");
+       systrace_start(true);
+       return 0;
+}
+
 void systrace_stop(void)
 {
        spin_lock_irqsave(&systrace_lock);