Improved output, now also accepts team 1 under BeOS (KERNEL SPACE).

Fixed warnings and style issues.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8274 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2004-07-02 15:35:16 +00:00
parent a82a66749c
commit 7bb4bc0ca9
+34 -34
View File
@@ -1,9 +1,9 @@
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
// //
// Copyright (c) 2001-2003, OpenBeOS // Copyright (c) 2001-2004, Haiku
// //
// This software is part of the OpenBeOS distribution and is covered // This software is part of the Haiku distribution and is covered
// by the OpenBeOS license. // by the Haiku license.
// //
// //
// File: listarea.c // File: listarea.c
@@ -12,14 +12,15 @@
// //
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
#include <stdio.h>
#include <stdlib.h>
#include <OS.h> #include <OS.h>
#include <stdio.h>
#include <stdlib.h>
void list_area_info (team_id id);
void show_memory_totals (void);
void list_area_info(team_id id);
void show_memory_totals(void);
int int
@@ -34,11 +35,11 @@ main(int argc, char **argv)
// list for all teams // list for all teams
while (get_next_team_info(&cookie, &info) >= B_OK) while (get_next_team_info(&cookie, &info) >= B_OK)
list_area_info(info.team); list_area_info(info.team);
} } else {
else
// list for each team_id on the command line // list for each team_id on the command line
while (--argc) while (--argc)
list_area_info(atoi(*++argv)); list_area_info(atoi(*++argv));
}
return 0; return 0;
} }
@@ -47,18 +48,16 @@ main(int argc, char **argv)
void void
show_memory_totals() show_memory_totals()
{ {
int32 max = 0, used = 0, left; int32 max = 0, used = 0;
system_info sys;
if (get_system_info(&sys) == B_OK) { system_info info;
if (get_system_info(&info) == B_OK) {
// pages are 4KB // pages are 4KB
max = sys.max_pages * 4; max = info.max_pages * 4;
used = sys.used_pages * 4; used = info.used_pages * 4;
} }
left = max - used; printf("memory: total: %4ldKB, used: %4ldKB, left: %4ldKB\n", max, used, max - used);
printf("memory: total: %4dKB, used: %4dKB, left: %4dKB\n", max, used, left);
} }
@@ -66,28 +65,29 @@ void
list_area_info(team_id id) list_area_info(team_id id)
{ {
int32 cookie = 0; int32 cookie = 0;
team_info this_team; team_info teamInfo;
area_info this_area; area_info areaInfo;
if (get_team_info(id, &this_team) == B_BAD_TEAM_ID) { if (id != 1 && get_team_info(id, &teamInfo) == B_BAD_TEAM_ID) {
printf("\nteam %d unknown\n", id); printf("\nteam %ld unknown\n", id);
return; return;
} } else if (id == 1)
strcpy(teamInfo.args, "KERNEL SPACE");
printf("\nTEAM %4d (%s):\n", id, this_team.args); printf("\n%s (team %ld)\n", teamInfo.args, id);
printf(" ID name address size alloc. #-cow #-in #-out\n"); printf(" ID name address size alloc. #-cow #-in #-out\n");
printf("--------------------------------------------------------------------------------\n"); printf("------------------------------------------------------------------------------------\n");
while (get_next_area_info(id, &cookie, &this_area) == B_OK) { while (get_next_area_info(id, &cookie, &areaInfo) == B_OK) {
printf("%5d %29s %.8x %8x %8x %5d %5d %5d\n", printf("%5ld %32s %08lx %8lx %8lx %5ld %5ld %5ld\n",
this_area.area, areaInfo.area,
this_area.name, areaInfo.name,
this_area.address, (addr_t)areaInfo.address,
this_area.size, areaInfo.size,
this_area.ram_size, areaInfo.ram_size,
this_area.copy_count, areaInfo.copy_count,
this_area.in_count, areaInfo.in_count,
this_area.out_count); areaInfo.out_count);
} }
} }