From 05a7818c850e27cf03f95216f6a9f0129f0c7909 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 2 Nov 2005 10:38:28 +0000 Subject: [PATCH] Removed the "list all team" functionality from the debugger command "team", and moved it into the new command "teams". Now also lists the parent team. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14630 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/team.c | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/src/system/kernel/team.c b/src/system/kernel/team.c index c0e7808ebb..fa9264e9dc 100644 --- a/src/system/kernel/team.c +++ b/src/system/kernel/team.c @@ -111,26 +111,16 @@ _dump_team_info(struct team *team) static int dump_team_info(int argc, char **argv) { + struct hash_iterator iterator; struct team *team; team_id id = -1; - struct hash_iterator i; bool found = false; - if (argc > 2) { + if (argc != 2) { kprintf("usage: team [id/address/name]\n"); return 0; } - if (argc < 2) { - // just list the existing teams - hash_open(team_hash, &i); - while ((team = hash_next(team_hash, &i)) != NULL) { - dprintf("%p %5lx %s\n", team, team->id, team->name); - } - hash_close(team_hash, &i, false); - return 0; - } - id = strtoul(argv[1], NULL, 0); if (IS_KERNEL_ADDRESS(id)) { // semi-hack @@ -139,15 +129,15 @@ dump_team_info(int argc, char **argv) } // walk through the thread list, trying to match name or id - hash_open(team_hash, &i); - while ((team = hash_next(team_hash, &i)) != NULL) { + hash_open(team_hash, &iterator); + while ((team = hash_next(team_hash, &iterator)) != NULL) { if ((team->name && strcmp(argv[1], team->name) == 0) || team->id == id) { _dump_team_info(team); found = true; break; } } - hash_close(team_hash, &i, false); + hash_close(team_hash, &iterator, false); if (!found) kprintf("team \"%s\" (%ld) doesn't exist!\n", argv[1], id); @@ -155,6 +145,24 @@ dump_team_info(int argc, char **argv) } +static int +dump_teams(int argc, char **argv) +{ + struct hash_iterator iterator; + struct team *team; + + kprintf("team id parent name\n"); + hash_open(team_hash, &iterator); + + while ((team = hash_next(team_hash, &iterator)) != NULL) { + kprintf("%p%6lx %p %s\n", team, team->id, team->parent, team->name); + } + + hash_close(team_hash, &iterator, false); + return 0; +} + + status_t team_init(kernel_args *args) { @@ -193,6 +201,7 @@ team_init(kernel_args *args) hash_insert(team_hash, kernel_team); add_debugger_command("team", &dump_team_info, "list info about a particular team"); + add_debugger_command("teams", &dump_teams, "list all teams"); return 0; }