|
|
@ -261,9 +261,9 @@ void GDBStub::ExecuteCommand(std::string_view packet, std::vector<DebuggerAction |
|
|
const size_t addr{static_cast<size_t>(strtoll(command.data(), nullptr, 16))}; |
|
|
const size_t addr{static_cast<size_t>(strtoll(command.data(), nullptr, 16))}; |
|
|
const size_t size{static_cast<size_t>(strtoll(command.data() + sep, nullptr, 16))}; |
|
|
const size_t size{static_cast<size_t>(strtoll(command.data() + sep, nullptr, 16))}; |
|
|
|
|
|
|
|
|
if (system.Memory().IsValidVirtualAddressRange(addr, size)) { |
|
|
|
|
|
|
|
|
if (system.ApplicationMemory().IsValidVirtualAddressRange(addr, size)) { |
|
|
std::vector<u8> mem(size); |
|
|
std::vector<u8> mem(size); |
|
|
system.Memory().ReadBlock(addr, mem.data(), size); |
|
|
|
|
|
|
|
|
system.ApplicationMemory().ReadBlock(addr, mem.data(), size); |
|
|
|
|
|
|
|
|
SendReply(Common::HexToString(mem)); |
|
|
SendReply(Common::HexToString(mem)); |
|
|
} else { |
|
|
} else { |
|
|
@ -281,8 +281,8 @@ void GDBStub::ExecuteCommand(std::string_view packet, std::vector<DebuggerAction |
|
|
const auto mem_substr{std::string_view(command).substr(mem_sep)}; |
|
|
const auto mem_substr{std::string_view(command).substr(mem_sep)}; |
|
|
const auto mem{Common::HexStringToVector(mem_substr, false)}; |
|
|
const auto mem{Common::HexStringToVector(mem_substr, false)}; |
|
|
|
|
|
|
|
|
if (system.Memory().IsValidVirtualAddressRange(addr, size)) { |
|
|
|
|
|
system.Memory().WriteBlock(addr, mem.data(), size); |
|
|
|
|
|
|
|
|
if (system.ApplicationMemory().IsValidVirtualAddressRange(addr, size)) { |
|
|
|
|
|
system.ApplicationMemory().WriteBlock(addr, mem.data(), size); |
|
|
system.InvalidateCpuInstructionCacheRange(addr, size); |
|
|
system.InvalidateCpuInstructionCacheRange(addr, size); |
|
|
SendReply(GDB_STUB_REPLY_OK); |
|
|
SendReply(GDB_STUB_REPLY_OK); |
|
|
} else { |
|
|
} else { |
|
|
@ -325,7 +325,7 @@ void GDBStub::HandleBreakpointInsert(std::string_view command) { |
|
|
const size_t addr{static_cast<size_t>(strtoll(command.data() + addr_sep, nullptr, 16))}; |
|
|
const size_t addr{static_cast<size_t>(strtoll(command.data() + addr_sep, nullptr, 16))}; |
|
|
const size_t size{static_cast<size_t>(strtoll(command.data() + size_sep, nullptr, 16))}; |
|
|
const size_t size{static_cast<size_t>(strtoll(command.data() + size_sep, nullptr, 16))}; |
|
|
|
|
|
|
|
|
if (!system.Memory().IsValidVirtualAddressRange(addr, size)) { |
|
|
|
|
|
|
|
|
if (!system.ApplicationMemory().IsValidVirtualAddressRange(addr, size)) { |
|
|
SendReply(GDB_STUB_REPLY_ERR); |
|
|
SendReply(GDB_STUB_REPLY_ERR); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
@ -334,22 +334,22 @@ void GDBStub::HandleBreakpointInsert(std::string_view command) { |
|
|
|
|
|
|
|
|
switch (type) { |
|
|
switch (type) { |
|
|
case BreakpointType::Software: |
|
|
case BreakpointType::Software: |
|
|
replaced_instructions[addr] = system.Memory().Read32(addr); |
|
|
|
|
|
system.Memory().Write32(addr, arch->BreakpointInstruction()); |
|
|
|
|
|
|
|
|
replaced_instructions[addr] = system.ApplicationMemory().Read32(addr); |
|
|
|
|
|
system.ApplicationMemory().Write32(addr, arch->BreakpointInstruction()); |
|
|
system.InvalidateCpuInstructionCacheRange(addr, sizeof(u32)); |
|
|
system.InvalidateCpuInstructionCacheRange(addr, sizeof(u32)); |
|
|
success = true; |
|
|
success = true; |
|
|
break; |
|
|
break; |
|
|
case BreakpointType::WriteWatch: |
|
|
case BreakpointType::WriteWatch: |
|
|
success = system.ApplicationProcess()->InsertWatchpoint(system, addr, size, |
|
|
|
|
|
|
|
|
success = system.ApplicationProcess()->InsertWatchpoint(addr, size, |
|
|
Kernel::DebugWatchpointType::Write); |
|
|
Kernel::DebugWatchpointType::Write); |
|
|
break; |
|
|
break; |
|
|
case BreakpointType::ReadWatch: |
|
|
case BreakpointType::ReadWatch: |
|
|
success = system.ApplicationProcess()->InsertWatchpoint(system, addr, size, |
|
|
|
|
|
|
|
|
success = system.ApplicationProcess()->InsertWatchpoint(addr, size, |
|
|
Kernel::DebugWatchpointType::Read); |
|
|
Kernel::DebugWatchpointType::Read); |
|
|
break; |
|
|
break; |
|
|
case BreakpointType::AccessWatch: |
|
|
case BreakpointType::AccessWatch: |
|
|
success = system.ApplicationProcess()->InsertWatchpoint( |
|
|
success = system.ApplicationProcess()->InsertWatchpoint( |
|
|
system, addr, size, Kernel::DebugWatchpointType::ReadOrWrite); |
|
|
|
|
|
|
|
|
addr, size, Kernel::DebugWatchpointType::ReadOrWrite); |
|
|
break; |
|
|
break; |
|
|
case BreakpointType::Hardware: |
|
|
case BreakpointType::Hardware: |
|
|
default: |
|
|
default: |
|
|
@ -372,7 +372,7 @@ void GDBStub::HandleBreakpointRemove(std::string_view command) { |
|
|
const size_t addr{static_cast<size_t>(strtoll(command.data() + addr_sep, nullptr, 16))}; |
|
|
const size_t addr{static_cast<size_t>(strtoll(command.data() + addr_sep, nullptr, 16))}; |
|
|
const size_t size{static_cast<size_t>(strtoll(command.data() + size_sep, nullptr, 16))}; |
|
|
const size_t size{static_cast<size_t>(strtoll(command.data() + size_sep, nullptr, 16))}; |
|
|
|
|
|
|
|
|
if (!system.Memory().IsValidVirtualAddressRange(addr, size)) { |
|
|
|
|
|
|
|
|
if (!system.ApplicationMemory().IsValidVirtualAddressRange(addr, size)) { |
|
|
SendReply(GDB_STUB_REPLY_ERR); |
|
|
SendReply(GDB_STUB_REPLY_ERR); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
@ -383,7 +383,7 @@ void GDBStub::HandleBreakpointRemove(std::string_view command) { |
|
|
case BreakpointType::Software: { |
|
|
case BreakpointType::Software: { |
|
|
const auto orig_insn{replaced_instructions.find(addr)}; |
|
|
const auto orig_insn{replaced_instructions.find(addr)}; |
|
|
if (orig_insn != replaced_instructions.end()) { |
|
|
if (orig_insn != replaced_instructions.end()) { |
|
|
system.Memory().Write32(addr, orig_insn->second); |
|
|
|
|
|
|
|
|
system.ApplicationMemory().Write32(addr, orig_insn->second); |
|
|
system.InvalidateCpuInstructionCacheRange(addr, sizeof(u32)); |
|
|
system.InvalidateCpuInstructionCacheRange(addr, sizeof(u32)); |
|
|
replaced_instructions.erase(addr); |
|
|
replaced_instructions.erase(addr); |
|
|
success = true; |
|
|
success = true; |
|
|
@ -391,16 +391,16 @@ void GDBStub::HandleBreakpointRemove(std::string_view command) { |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
case BreakpointType::WriteWatch: |
|
|
case BreakpointType::WriteWatch: |
|
|
success = system.ApplicationProcess()->RemoveWatchpoint(system, addr, size, |
|
|
|
|
|
|
|
|
success = system.ApplicationProcess()->RemoveWatchpoint(addr, size, |
|
|
Kernel::DebugWatchpointType::Write); |
|
|
Kernel::DebugWatchpointType::Write); |
|
|
break; |
|
|
break; |
|
|
case BreakpointType::ReadWatch: |
|
|
case BreakpointType::ReadWatch: |
|
|
success = system.ApplicationProcess()->RemoveWatchpoint(system, addr, size, |
|
|
|
|
|
|
|
|
success = system.ApplicationProcess()->RemoveWatchpoint(addr, size, |
|
|
Kernel::DebugWatchpointType::Read); |
|
|
Kernel::DebugWatchpointType::Read); |
|
|
break; |
|
|
break; |
|
|
case BreakpointType::AccessWatch: |
|
|
case BreakpointType::AccessWatch: |
|
|
success = system.ApplicationProcess()->RemoveWatchpoint( |
|
|
success = system.ApplicationProcess()->RemoveWatchpoint( |
|
|
system, addr, size, Kernel::DebugWatchpointType::ReadOrWrite); |
|
|
|
|
|
|
|
|
addr, size, Kernel::DebugWatchpointType::ReadOrWrite); |
|
|
break; |
|
|
break; |
|
|
case BreakpointType::Hardware: |
|
|
case BreakpointType::Hardware: |
|
|
default: |
|
|
default: |
|
|
@ -483,9 +483,9 @@ static std::optional<std::string> GetNameFromThreadType64(Core::Memory::Memory& |
|
|
static std::optional<std::string> GetThreadName(Core::System& system, |
|
|
static std::optional<std::string> GetThreadName(Core::System& system, |
|
|
const Kernel::KThread* thread) { |
|
|
const Kernel::KThread* thread) { |
|
|
if (system.ApplicationProcess()->Is64BitProcess()) { |
|
|
if (system.ApplicationProcess()->Is64BitProcess()) { |
|
|
return GetNameFromThreadType64(system.Memory(), thread); |
|
|
|
|
|
|
|
|
return GetNameFromThreadType64(system.ApplicationMemory(), thread); |
|
|
} else { |
|
|
} else { |
|
|
return GetNameFromThreadType32(system.Memory(), thread); |
|
|
|
|
|
|
|
|
return GetNameFromThreadType32(system.ApplicationMemory(), thread); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|