KDL "mapping" command: Allow specifying a thread ID

... instead of only a team ID.
This commit is contained in:
Ingo Weinhold
2013-12-10 19:13:56 +01:00
parent 5d3978dbe7
commit c259766f94
+27 -28
View File
@@ -3430,7 +3430,7 @@ dump_mapping_info(int argc, char** argv)
} }
} }
// We need at least one argument, the address. Optionally a team ID can be // We need at least one argument, the address. Optionally a thread ID can be
// specified. // specified.
if (argi >= argc || argi + 2 < argc) { if (argi >= argc || argi + 2 < argc) {
print_debugger_command_usage(argv[0]); print_debugger_command_usage(argv[0]);
@@ -3441,11 +3441,19 @@ dump_mapping_info(int argc, char** argv)
if (!evaluate_debug_expression(argv[argi++], &addressValue, false)) if (!evaluate_debug_expression(argv[argi++], &addressValue, false))
return 0; return 0;
uint64 teamID = B_CURRENT_TEAM; Team* team = NULL;
bool teamSpecified = argi < argc; if (argi < argc) {
if (teamSpecified) { uint64 threadID = -1;
if (!evaluate_debug_expression(argv[argi++], &teamID, false)) if (!evaluate_debug_expression(argv[argi++], &threadID, false))
return 0; return 0;
Thread* thread = Thread::GetDebug(threadID);
if (thread == NULL) {
kprintf("Invalid thread/team ID \"%s\"\n", argv[argi - 1]);
return 0;
}
team = thread->team;
} }
if (reverseLookup) { if (reverseLookup) {
@@ -3488,20 +3496,9 @@ dump_mapping_info(int argc, char** argv)
VMAddressSpace* fAddressSpace; VMAddressSpace* fAddressSpace;
} callback; } callback;
if (teamSpecified) { if (team != NULL) {
// team specified -- get its address space // team specified -- get its address space
VMAddressSpace* addressSpace; VMAddressSpace* addressSpace = team->address_space;
if (teamID == B_CURRENT_TEAM) {
Thread* thread = debug_get_debugged_thread();
if (thread == NULL || thread->team == NULL) {
kprintf("Failed to get team!\n");
return 0;
}
addressSpace = thread->team->address_space;
} else
addressSpace = VMAddressSpace::DebugGet(teamID);
if (addressSpace == NULL) { if (addressSpace == NULL) {
kprintf("Failed to get address space!\n"); kprintf("Failed to get address space!\n");
return 0; return 0;
@@ -3527,7 +3524,9 @@ dump_mapping_info(int argc, char** argv)
VMAddressSpace* addressSpace; VMAddressSpace* addressSpace;
if (IS_KERNEL_ADDRESS(virtualAddress)) { if (IS_KERNEL_ADDRESS(virtualAddress)) {
addressSpace = VMAddressSpace::Kernel(); addressSpace = VMAddressSpace::Kernel();
} else if (!teamSpecified || teamID == B_CURRENT_TEAM) { } else if (team != NULL) {
addressSpace = team->address_space;
} else {
Thread* thread = debug_get_debugged_thread(); Thread* thread = debug_get_debugged_thread();
if (thread == NULL || thread->team == NULL) { if (thread == NULL || thread->team == NULL) {
kprintf("Failed to get team!\n"); kprintf("Failed to get team!\n");
@@ -3535,8 +3534,7 @@ dump_mapping_info(int argc, char** argv)
} }
addressSpace = thread->team->address_space; addressSpace = thread->team->address_space;
} else }
addressSpace = VMAddressSpace::DebugGet(teamID);
if (addressSpace == NULL) { if (addressSpace == NULL) {
kprintf("Failed to get address space!\n"); kprintf("Failed to get address space!\n");
@@ -4078,16 +4076,17 @@ vm_init(kernel_args* args)
add_debugger_command_etc("mapping", &dump_mapping_info, add_debugger_command_etc("mapping", &dump_mapping_info,
"Print address mapping information", "Print address mapping information",
"[ \"-r\" | \"-p\" ] <address> [ <team ID> ]\n" "[ \"-r\" | \"-p\" ] <address> [ <thread ID> ]\n"
"Prints low-level page mapping information for a given address. If\n" "Prints low-level page mapping information for a given address. If\n"
"neither \"-r\" nor \"-p\" are specified, <address> is a virtual\n" "neither \"-r\" nor \"-p\" are specified, <address> is a virtual\n"
"address that is looked up in the translation map of the current\n" "address that is looked up in the translation map of the current\n"
"team, respectively the team specified by ID <team ID>. If \"-r\" is\n" "team, respectively the team specified by thread ID <thread ID>. If\n"
"specified, <address> is a physical address that is searched in the\n" "\"-r\" is specified, <address> is a physical address that is\n"
"translation map of all teams, respectively the team specified by ID\n" "searched in the translation map of all teams, respectively the team\n"
" <team ID>. If \"-p\" is specified, <address> is the address of a\n" "specified by thread ID <thread ID>. If \"-p\" is specified,\n"
"vm_page structure. The behavior is equivalent to specifying \"-r\"\n" "<address> is the address of a vm_page structure. The behavior is\n"
"with the physical address of that page.\n", "equivalent to specifying \"-r\" with the physical address of that\n"
"page.\n",
0); 0);
TRACE(("vm_init: exit\n")); TRACE(("vm_init: exit\n"));