diff options
author | Richard Braun <rbraun@sceen.net> | 2017-06-15 23:31:30 +0200 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2017-06-15 23:31:30 +0200 |
commit | 363d01aa8443bcccab267ff9a1830dcbf67eaba1 (patch) | |
tree | 85cf36149d2324def93150ca1fe0448fde6ed5f0 /kern/thread.c | |
parent | 8a8afe78bdb41850bff003353ba0a3229b0106b4 (diff) |
kern/thread: prevent stack tracing running threads.
Diffstat (limited to 'kern/thread.c')
-rw-r--r-- | kern/thread.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/kern/thread.c b/kern/thread.c index 8111c252..713c28fd 100644 --- a/kern/thread.c +++ b/kern/thread.c @@ -2238,7 +2238,9 @@ static void thread_shell_trace(int argc, char *argv[]) { const char *task_name, *thread_name; + struct thread_runq *runq; struct thread *thread; + unsigned long flags; struct task *task; int error; @@ -2265,7 +2267,16 @@ thread_shell_trace(int argc, char *argv[]) goto error; } - tcb_trace(&thread->tcb); + runq = thread_lock_runq(thread, &flags); + + if (thread == runq->current) { + printf("thread: trace: thread is running\n"); + } else { + tcb_trace(&thread->tcb); + } + + thread_unlock_runq(runq, flags); + thread_unref(thread); return; |