2 * Copyright (c) 2001-2005, Haiku.
4 * This software is part of the Haiku distribution and is covered
7 * Author: Daniel Reinhold (danielre@users.sf.net)
10 /** Lists area info for all currently running teams */
20 static void list_areas_for_id(team_id team
);
21 static void list_areas_for_name(const char *teamName
);
22 static void show_memory_totals(void);
26 show_memory_totals(void)
28 int32 max
= 0, used
= 0;
31 if (get_system_info(&info
) == B_OK
) {
33 max
= info
.max_pages
* 4;
34 used
= info
.used_pages
* 4;
37 printf("memory: total: %4" B_PRId32
"KB, used: %4" B_PRId32
"KB, left: %4"
38 B_PRId32
"KB\n", max
, used
, max
- used
);
43 list_areas_for_id(team_id id
)
49 if (id
!= 1 && get_team_info(id
, &teamInfo
) == B_BAD_TEAM_ID
) {
50 printf("\nteam %" B_PRId32
" unknown\n", id
);
53 strcpy(teamInfo
.args
, "KERNEL SPACE");
55 printf("\n%s (team %" B_PRId32
")\n", teamInfo
.args
, id
);
56 printf(" ID name address size alloc."
57 " #-cow #-in #-out\n");
58 printf("------------------------------------------------------------------"
59 "------------------\n");
61 while (get_next_area_info(id
, &cookie
, &areaInfo
) == B_OK
) {
62 printf("%5" B_PRId32
" %32s %p %8" B_PRIxSIZE
" %8" B_PRIx32
" %5"
63 B_PRId32
" %5" B_PRId32
" %5" B_PRId32
"\n",
77 list_areas_for_name(const char *name
)
81 while (get_next_team_info(&cookie
, &info
) >= B_OK
) {
82 if (strstr(info
.args
, name
) != NULL
)
83 list_areas_for_id(info
.team
);
89 main(int argc
, char **argv
)
94 // list areas of all teams
98 while (get_next_team_info(&cookie
, &info
) >= B_OK
)
99 list_areas_for_id(info
.team
);
101 // list areas for each team ID/name on the command line
103 const char *arg
= *++argv
;
104 team_id team
= atoi(arg
);
106 // if atoi returns >0 it's likely it's a number, else take it as string
108 list_areas_for_id(team
);
110 list_areas_for_name(arg
);