diff options
| author | 2018-08-07 03:01:24 +0100 | |
|---|---|---|
| committer | 2018-08-06 22:01:24 -0400 | |
| commit | e2b74f635410891b4ab9c202ecdd83dfe05df239 (patch) | |
| tree | 90cf31b4b0f60d86709bfec1a3c021056bd0a269 /src/core/gdbstub/gdbstub.cpp | |
| parent | Merge pull request #943 from lioncash/decl (diff) | |
| download | yuzu-e2b74f635410891b4ab9c202ecdd83dfe05df239.tar.gz yuzu-e2b74f635410891b4ab9c202ecdd83dfe05df239.tar.xz yuzu-e2b74f635410891b4ab9c202ecdd83dfe05df239.zip | |
GDBStub works with both Unicorn and Dynarmic now (#941)
* GDBStub works with both Unicorn and Dynarmic now
* Tidy up
Diffstat (limited to 'src/core/gdbstub/gdbstub.cpp')
| -rw-r--r-- | src/core/gdbstub/gdbstub.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/core/gdbstub/gdbstub.cpp b/src/core/gdbstub/gdbstub.cpp index 884e64e99..332e5c3d0 100644 --- a/src/core/gdbstub/gdbstub.cpp +++ b/src/core/gdbstub/gdbstub.cpp | |||
| @@ -173,6 +173,7 @@ struct Breakpoint { | |||
| 173 | bool active; | 173 | bool active; |
| 174 | VAddr addr; | 174 | VAddr addr; |
| 175 | u64 len; | 175 | u64 len; |
| 176 | std::array<u8, 4> inst; | ||
| 176 | }; | 177 | }; |
| 177 | 178 | ||
| 178 | using BreakpointMap = std::map<VAddr, Breakpoint>; | 179 | using BreakpointMap = std::map<VAddr, Breakpoint>; |
| @@ -453,6 +454,8 @@ static void RemoveBreakpoint(BreakpointType type, VAddr addr) { | |||
| 453 | 454 | ||
| 454 | LOG_DEBUG(Debug_GDBStub, "gdb: removed a breakpoint: {:016X} bytes at {:016X} of type {}", | 455 | LOG_DEBUG(Debug_GDBStub, "gdb: removed a breakpoint: {:016X} bytes at {:016X} of type {}", |
| 455 | bp->second.len, bp->second.addr, static_cast<int>(type)); | 456 | bp->second.len, bp->second.addr, static_cast<int>(type)); |
| 457 | Memory::WriteBlock(bp->second.addr, bp->second.inst.data(), bp->second.inst.size()); | ||
| 458 | Core::System::GetInstance().InvalidateCpuInstructionCaches(); | ||
| 456 | p.erase(addr); | 459 | p.erase(addr); |
| 457 | } | 460 | } |
| 458 | 461 | ||
| @@ -937,6 +940,7 @@ static void WriteMemory() { | |||
| 937 | 940 | ||
| 938 | GdbHexToMem(data.data(), len_pos + 1, len); | 941 | GdbHexToMem(data.data(), len_pos + 1, len); |
| 939 | Memory::WriteBlock(addr, data.data(), len); | 942 | Memory::WriteBlock(addr, data.data(), len); |
| 943 | Core::System::GetInstance().InvalidateCpuInstructionCaches(); | ||
| 940 | SendReply("OK"); | 944 | SendReply("OK"); |
| 941 | } | 945 | } |
| 942 | 946 | ||
| @@ -956,6 +960,7 @@ static void Step() { | |||
| 956 | step_loop = true; | 960 | step_loop = true; |
| 957 | halt_loop = true; | 961 | halt_loop = true; |
| 958 | send_trap = true; | 962 | send_trap = true; |
| 963 | Core::System::GetInstance().InvalidateCpuInstructionCaches(); | ||
| 959 | } | 964 | } |
| 960 | 965 | ||
| 961 | /// Tell the CPU if we hit a memory breakpoint. | 966 | /// Tell the CPU if we hit a memory breakpoint. |
| @@ -972,6 +977,7 @@ static void Continue() { | |||
| 972 | memory_break = false; | 977 | memory_break = false; |
| 973 | step_loop = false; | 978 | step_loop = false; |
| 974 | halt_loop = false; | 979 | halt_loop = false; |
| 980 | Core::System::GetInstance().InvalidateCpuInstructionCaches(); | ||
| 975 | } | 981 | } |
| 976 | 982 | ||
| 977 | /** | 983 | /** |
| @@ -988,6 +994,10 @@ static bool CommitBreakpoint(BreakpointType type, VAddr addr, u64 len) { | |||
| 988 | breakpoint.active = true; | 994 | breakpoint.active = true; |
| 989 | breakpoint.addr = addr; | 995 | breakpoint.addr = addr; |
| 990 | breakpoint.len = len; | 996 | breakpoint.len = len; |
| 997 | Memory::ReadBlock(addr, breakpoint.inst.data(), breakpoint.inst.size()); | ||
| 998 | static constexpr std::array<u8, 4> btrap{{0xd4, 0x20, 0x7d, 0x0}}; | ||
| 999 | Memory::WriteBlock(addr, btrap.data(), btrap.size()); | ||
| 1000 | Core::System::GetInstance().InvalidateCpuInstructionCaches(); | ||
| 991 | p.insert({addr, breakpoint}); | 1001 | p.insert({addr, breakpoint}); |
| 992 | 1002 | ||
| 993 | LOG_DEBUG(Debug_GDBStub, "gdb: added {} breakpoint: {:016X} bytes at {:016X}", | 1003 | LOG_DEBUG(Debug_GDBStub, "gdb: added {} breakpoint: {:016X} bytes at {:016X}", |