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:
@@ -475,25 +475,33 @@ _dump_thread_info(struct thread *t)
|
|||||||
static int
|
static int
|
||||||
dump_thread_info(int argc, char **argv)
|
dump_thread_info(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
const char *name = NULL;
|
||||||
struct thread *t;
|
struct thread *t;
|
||||||
int id = -1;
|
int id = -1;
|
||||||
struct hash_iterator i;
|
struct hash_iterator i;
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc > 2) {
|
||||||
dprintf("thread: not enough arguments\n");
|
dprintf("usage: thread [id/name]\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the argument looks like a hex number, treat it as such
|
if (argc == 1) {
|
||||||
if (strlen(argv[1]) > 2 && argv[1][0] == '0' && argv[1][1] == 'x')
|
name = NULL;
|
||||||
id = strtoul(argv[1], NULL, 16);
|
id = thread_get_current_thread()->id;
|
||||||
else
|
} else {
|
||||||
id = atoi(argv[1]);
|
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
|
// walk through the thread list, trying to match name or id
|
||||||
hash_open(sThreadHash, &i);
|
hash_open(sThreadHash, &i);
|
||||||
while ((t = hash_next(sThreadHash, &i)) != NULL) {
|
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);
|
_dump_thread_info(t);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user