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
This commit is contained in:
Axel Dörfler
2004-10-23 17:09:51 +00:00
parent d6105cedfa
commit ddccb72483
+16 -8
View File
@@ -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;
}