* Worked over the "area" KDL command to make it more useful, and easier to use.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29503 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2009-03-13 21:48:03 +00:00
parent b5db6bb7ea
commit 24ace12957
+32 -5
View File
@@ -3696,7 +3696,11 @@ dump_area(int argc, char** argv)
addr_t num; addr_t num;
if (argc < 2 || !strcmp(argv[1], "--help")) { if (argc < 2 || !strcmp(argv[1], "--help")) {
kprintf("usage: area [-m] <id|address|name>\n"); kprintf("usage: area [-m] [id|contains|address|name] <id|address|name>\n"
"All areas matching either id/address/name are listed. You can\n"
"force to check only a specific item by prefixing the specifier\n"
"with the id/contains/address/name keywords.\n"
"-m shows the area's mappings as well.\n");
return 0; return 0;
} }
@@ -3705,17 +3709,38 @@ dump_area(int argc, char** argv)
index++; index++;
} }
int32 mode = 0xf;
if (!strcmp(argv[index], "id"))
mode = 1;
else if (!strcmp(argv[index], "contains"))
mode = 2;
else if (!strcmp(argv[index], "name"))
mode = 4;
else if (!strcmp(argv[index], "address"))
mode = 0;
if (mode != 0xf)
index++;
if (index >= argc) {
kprintf("No area specifier given.\n");
return 0;
}
num = parse_expression(argv[index]); num = parse_expression(argv[index]);
if (mode == 0) {
dump_area_struct((struct vm_area*)num, mappings);
} else {
// walk through the area list, looking for the arguments as a name // walk through the area list, looking for the arguments as a name
struct hash_iterator iter; struct hash_iterator iter;
hash_open(sAreaHash, &iter); hash_open(sAreaHash, &iter);
while ((area = (vm_area*)hash_next(sAreaHash, &iter)) != NULL) { while ((area = (vm_area*)hash_next(sAreaHash, &iter)) != NULL) {
if ((area->name != NULL && !strcmp(argv[index], area->name)) if (((mode & 4) != 0 && area->name != NULL
|| (num != 0 && !strcmp(argv[index], area->name))
&& ((addr_t)area->id == num || (num != 0 && (((mode & 1) != 0 && (addr_t)area->id == num)
|| (area->base <= num && area->base + area->size > num)))) { || (((mode & 2) != 0 && area->base <= num
&& area->base + area->size > num))))) {
dump_area_struct(area, mappings); dump_area_struct(area, mappings);
found = true; found = true;
} }
@@ -3723,6 +3748,8 @@ dump_area(int argc, char** argv)
if (!found) if (!found)
kprintf("could not find area %s (%ld)\n", argv[index], num); kprintf("could not find area %s (%ld)\n", argv[index], num);
}
return 0; return 0;
} }