* Added new KDL command "string" that dumps a string given a pointer.
* Use parse_expression() where appropriate. * Removed extraneous white space. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24593 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+87
-57
@@ -2684,19 +2684,21 @@ display_mem(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (argc < i + 1 || argc > i + 2) {
|
if (argc < i + 1 || argc > i + 2) {
|
||||||
kprintf("usage: dl/dw/ds/db [-p|--physical] <address> [num]\n"
|
kprintf("usage: dl/dw/ds/db/string [-p|--physical] <address> [num]\n"
|
||||||
"\tdl - 8 bytes\n"
|
"\tdl - 8 bytes\n"
|
||||||
"\tdw - 4 bytes\n"
|
"\tdw - 4 bytes\n"
|
||||||
"\tds - 2 bytes\n"
|
"\tds - 2 bytes\n"
|
||||||
"\tdb - 1 byte\n"
|
"\tdb - 1 byte\n"
|
||||||
" -p or --physical only allows memory from a single page to be displayed.\n");
|
"\tstring - a whole string\n"
|
||||||
|
" -p or --physical only allows memory from a single page to be "
|
||||||
|
"displayed.\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
address = strtoul(argv[i], NULL, 0);
|
address = parse_expression(argv[i]);
|
||||||
|
|
||||||
if (argc > i + 1)
|
if (argc > i + 1)
|
||||||
num = atoi(argv[i + 1]);
|
num = parse_expression(argv[i + 1]);
|
||||||
|
|
||||||
// build the format string
|
// build the format string
|
||||||
if (strcmp(argv[0], "db") == 0) {
|
if (strcmp(argv[0], "db") == 0) {
|
||||||
@@ -2711,6 +2713,9 @@ display_mem(int argc, char **argv)
|
|||||||
} else if (strcmp(argv[0], "dl") == 0) {
|
} else if (strcmp(argv[0], "dl") == 0) {
|
||||||
itemSize = 8;
|
itemSize = 8;
|
||||||
displayWidth = 2;
|
displayWidth = 2;
|
||||||
|
} else if (strcmp(argv[0], "string") == 0) {
|
||||||
|
itemSize = 1;
|
||||||
|
displayWidth = -1;
|
||||||
} else {
|
} else {
|
||||||
kprintf("display_mem called in an invalid way!\n");
|
kprintf("display_mem called in an invalid way!\n");
|
||||||
return 0;
|
return 0;
|
||||||
@@ -2743,58 +2748,86 @@ display_mem(int argc, char **argv)
|
|||||||
} else
|
} else
|
||||||
copyAddress = address;
|
copyAddress = address;
|
||||||
|
|
||||||
for (i = 0; i < num; i++) {
|
if (!strcmp(argv[0], "string")) {
|
||||||
uint32 value;
|
kprintf("%p \"", (char*)copyAddress);
|
||||||
|
|
||||||
if ((i % displayWidth) == 0) {
|
// string mode
|
||||||
int32 displayed = min_c(displayWidth, (num-i)) * itemSize;
|
for (i = 0; true; i++) {
|
||||||
if (i != 0)
|
char c;
|
||||||
kprintf("\n");
|
if (user_memcpy(&c, (char*)copyAddress + i, 1) != B_OK
|
||||||
|
|| c == '\0')
|
||||||
|
break;
|
||||||
|
|
||||||
kprintf("[0x%lx] ", address + i * itemSize);
|
if (c == '\n')
|
||||||
|
kprintf("\\n");
|
||||||
for (j = 0; j < displayed; j++) {
|
else if (c == '\t')
|
||||||
char c;
|
kprintf("\\t");
|
||||||
if (user_memcpy(&c, (char *)copyAddress + i * itemSize + j, 1) != B_OK) {
|
else {
|
||||||
displayed = j;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!isprint(c))
|
if (!isprint(c))
|
||||||
c = '.';
|
c = '.';
|
||||||
|
|
||||||
kprintf("%c", c);
|
kprintf("%c", c);
|
||||||
}
|
}
|
||||||
if (num > displayWidth) {
|
}
|
||||||
// make sure the spacing in the last line is correct
|
|
||||||
for (j = displayed; j < displayWidth * itemSize; j++)
|
kprintf("\"\n");
|
||||||
kprintf(" ");
|
} else {
|
||||||
|
// number mode
|
||||||
|
for (i = 0; i < num; i++) {
|
||||||
|
uint32 value;
|
||||||
|
|
||||||
|
if ((i % displayWidth) == 0) {
|
||||||
|
int32 displayed = min_c(displayWidth, (num-i)) * itemSize;
|
||||||
|
if (i != 0)
|
||||||
|
kprintf("\n");
|
||||||
|
|
||||||
|
kprintf("[0x%lx] ", address + i * itemSize);
|
||||||
|
|
||||||
|
for (j = 0; j < displayed; j++) {
|
||||||
|
char c;
|
||||||
|
if (user_memcpy(&c, (char*)copyAddress + i * itemSize + j,
|
||||||
|
1) != B_OK) {
|
||||||
|
displayed = j;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!isprint(c))
|
||||||
|
c = '.';
|
||||||
|
|
||||||
|
kprintf("%c", c);
|
||||||
|
}
|
||||||
|
if (num > displayWidth) {
|
||||||
|
// make sure the spacing in the last line is correct
|
||||||
|
for (j = displayed; j < displayWidth * itemSize; j++)
|
||||||
|
kprintf(" ");
|
||||||
|
}
|
||||||
|
kprintf(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (user_memcpy(&value, (uint8*)copyAddress + i * itemSize,
|
||||||
|
itemSize) != B_OK) {
|
||||||
|
kprintf("read fault");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (itemSize) {
|
||||||
|
case 1:
|
||||||
|
kprintf(" %02x", *(uint8 *)&value);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
kprintf(" %04x", *(uint16 *)&value);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
kprintf(" %08lx", *(uint32 *)&value);
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
kprintf(" %016Lx", *(uint64 *)&value);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
kprintf(" ");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user_memcpy(&value, (uint8 *)copyAddress + i * itemSize, itemSize) != B_OK) {
|
kprintf("\n");
|
||||||
kprintf("read fault");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (itemSize) {
|
|
||||||
case 1:
|
|
||||||
kprintf(" %02x", *(uint8 *)&value);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
kprintf(" %04x", *(uint16 *)&value);
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
kprintf(" %08lx", *(uint32 *)&value);
|
|
||||||
break;
|
|
||||||
case 8:
|
|
||||||
kprintf(" %016Lx", *(uint64 *)&value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
kprintf("\n");
|
|
||||||
|
|
||||||
if (physical) {
|
if (physical) {
|
||||||
copyAddress = ROUNDOWN(copyAddress, B_PAGE_SIZE);
|
copyAddress = ROUNDOWN(copyAddress, B_PAGE_SIZE);
|
||||||
kernel_startup = true;
|
kernel_startup = true;
|
||||||
@@ -2829,14 +2862,12 @@ dump_cache_tree_recursively(vm_cache* cache, int level,
|
|||||||
static int
|
static int
|
||||||
dump_cache_tree(int argc, char **argv)
|
dump_cache_tree(int argc, char **argv)
|
||||||
{
|
{
|
||||||
if (argc < 2 || strlen(argv[1]) < 2
|
if (argc != 2 || !strcmp(argv[1], "--help")) {
|
||||||
|| argv[1][0] != '0'
|
kprintf("usage: %s <address>\n", argv[0]);
|
||||||
|| argv[1][1] != 'x') {
|
|
||||||
kprintf("%s: invalid argument, pass address\n", argv[0]);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
addr_t address = strtoul(argv[1], NULL, 0);
|
addr_t address = parse_expression(argv[1]);
|
||||||
if (address == 0)
|
if (address == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -2900,7 +2931,7 @@ dump_cache(int argc, char **argv)
|
|||||||
bool showPages = false;
|
bool showPages = false;
|
||||||
int i = 1;
|
int i = 1;
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2 || !strcmp(argv[1], "--help")) {
|
||||||
kprintf("usage: %s [-ps] <address>\n"
|
kprintf("usage: %s [-ps] <address>\n"
|
||||||
" if -p is specified, all pages are shown, if -s is used\n"
|
" if -p is specified, all pages are shown, if -s is used\n"
|
||||||
" only the cache info is shown respectively.\n", argv[0]);
|
" only the cache info is shown respectively.\n", argv[0]);
|
||||||
@@ -2915,14 +2946,12 @@ dump_cache(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
if (argv[i] == NULL || strlen(argv[i]) < 2
|
if (argv[i] == NULL) {
|
||||||
|| argv[i][0] != '0'
|
|
||||||
|| argv[i][1] != 'x') {
|
|
||||||
kprintf("%s: invalid argument, pass address\n", argv[0]);
|
kprintf("%s: invalid argument, pass address\n", argv[0]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
addr_t address = strtoul(argv[i], NULL, 0);
|
addr_t address = parse_expression(argv[i]);
|
||||||
if (address == 0)
|
if (address == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -3024,7 +3053,7 @@ dump_area(int argc, char **argv)
|
|||||||
vm_area *area;
|
vm_area *area;
|
||||||
addr_t num;
|
addr_t num;
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2 || !strcmp(argv[1], "--help")) {
|
||||||
kprintf("usage: area [-m] <id|address|name>\n");
|
kprintf("usage: area [-m] <id|address|name>\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -3034,7 +3063,7 @@ dump_area(int argc, char **argv)
|
|||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
num = strtoul(argv[index], NULL, 0);
|
num = parse_expression(argv[index]);
|
||||||
|
|
||||||
// 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;
|
||||||
@@ -3065,7 +3094,7 @@ dump_area_list(int argc, char **argv)
|
|||||||
int32 id = 0;
|
int32 id = 0;
|
||||||
|
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
id = strtoul(argv[1], NULL, 0);
|
id = parse_expression(argv[1]);
|
||||||
if (id == 0)
|
if (id == 0)
|
||||||
name = argv[1];
|
name = argv[1];
|
||||||
}
|
}
|
||||||
@@ -3561,6 +3590,7 @@ vm_init(kernel_args *args)
|
|||||||
add_debugger_command("dw", &display_mem, "dump memory words (32-bit)");
|
add_debugger_command("dw", &display_mem, "dump memory words (32-bit)");
|
||||||
add_debugger_command("ds", &display_mem, "dump memory shorts (16-bit)");
|
add_debugger_command("ds", &display_mem, "dump memory shorts (16-bit)");
|
||||||
add_debugger_command("db", &display_mem, "dump memory bytes (8-bit)");
|
add_debugger_command("db", &display_mem, "dump memory bytes (8-bit)");
|
||||||
|
add_debugger_command("string", &display_mem, "dump strings");
|
||||||
|
|
||||||
TRACE(("vm_init: exit\n"));
|
TRACE(("vm_init: exit\n"));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user