diff --git a/src/system/kernel/vm/vm.cpp b/src/system/kernel/vm/vm.cpp index f342e1933a..d4a01cc641 100644 --- a/src/system/kernel/vm/vm.cpp +++ b/src/system/kernel/vm/vm.cpp @@ -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. if (argi >= argc || argi + 2 < argc) { 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)) return 0; - uint64 teamID = B_CURRENT_TEAM; - bool teamSpecified = argi < argc; - if (teamSpecified) { - if (!evaluate_debug_expression(argv[argi++], &teamID, false)) + Team* team = NULL; + if (argi < argc) { + uint64 threadID = -1; + if (!evaluate_debug_expression(argv[argi++], &threadID, false)) 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) { @@ -3488,20 +3496,9 @@ dump_mapping_info(int argc, char** argv) VMAddressSpace* fAddressSpace; } callback; - if (teamSpecified) { + if (team != NULL) { // team specified -- get its address space - VMAddressSpace* addressSpace; - 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); - + VMAddressSpace* addressSpace = team->address_space; if (addressSpace == NULL) { kprintf("Failed to get address space!\n"); return 0; @@ -3527,7 +3524,9 @@ dump_mapping_info(int argc, char** argv) VMAddressSpace* addressSpace; if (IS_KERNEL_ADDRESS(virtualAddress)) { 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(); if (thread == NULL || thread->team == NULL) { kprintf("Failed to get team!\n"); @@ -3535,8 +3534,7 @@ dump_mapping_info(int argc, char** argv) } addressSpace = thread->team->address_space; - } else - addressSpace = VMAddressSpace::DebugGet(teamID); + } if (addressSpace == NULL) { kprintf("Failed to get address space!\n"); @@ -4078,16 +4076,17 @@ vm_init(kernel_args* args) add_debugger_command_etc("mapping", &dump_mapping_info, "Print address mapping information", - "[ \"-r\" | \"-p\" ]
[