From ddccb72483f8314f51666f6df65866791a693c35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Sat, 23 Oct 2004 17:09:51 +0000 Subject: [PATCH] Improved the kernel debugger's "thread" command: it will now dump the current thread if no arguments were given. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9462 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/core/thread.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/kernel/core/thread.c b/src/kernel/core/thread.c index cacf801ca7..5a1ccf79be 100644 --- a/src/kernel/core/thread.c +++ b/src/kernel/core/thread.c @@ -475,25 +475,33 @@ _dump_thread_info(struct thread *t) static int dump_thread_info(int argc, char **argv) { + const char *name = NULL; struct thread *t; int id = -1; struct hash_iterator i; - if (argc < 2) { - dprintf("thread: not enough arguments\n"); + if (argc > 2) { + dprintf("usage: thread [id/name]\n"); return 0; } - // if the argument looks like a hex number, treat it as such - if (strlen(argv[1]) > 2 && argv[1][0] == '0' && argv[1][1] == 'x') - id = strtoul(argv[1], NULL, 16); - else - id = atoi(argv[1]); + if (argc == 1) { + name = NULL; + id = thread_get_current_thread()->id; + } else { + name = argv[1]; + + // if the argument looks like a hex number, treat it as such + if (strlen(argv[1]) > 2 && argv[1][0] == '0' && argv[1][1] == 'x') + id = strtoul(argv[1], NULL, 16); + else + id = atoi(argv[1]); + } // walk through the thread list, trying to match name or id hash_open(sThreadHash, &i); while ((t = hash_next(sThreadHash, &i)) != NULL) { - if ((t->name && strcmp(argv[1], t->name) == 0) || t->id == id) { + if ((t->name && strcmp(name, t->name) == 0) || t->id == id) { _dump_thread_info(t); break; }