diff options
| author | 2023-11-28 14:30:39 -0500 | |
|---|---|---|
| committer | 2023-12-04 10:37:16 -0500 | |
| commit | 45c87c7e6e841c11def43e5ab25160006dab6d77 (patch) | |
| tree | 04a3ea0bd8c07389e17741aa28615e3b32ace2f7 /src/core/debugger/gdbstub_arch.cpp | |
| parent | Merge pull request #12235 from liamwhite/flip-clip (diff) | |
| download | yuzu-45c87c7e6e841c11def43e5ab25160006dab6d77.tar.gz yuzu-45c87c7e6e841c11def43e5ab25160006dab6d77.tar.xz yuzu-45c87c7e6e841c11def43e5ab25160006dab6d77.zip | |
core: refactor emulated cpu core activation
Diffstat (limited to 'src/core/debugger/gdbstub_arch.cpp')
| -rw-r--r-- | src/core/debugger/gdbstub_arch.cpp | 72 |
1 files changed, 32 insertions, 40 deletions
diff --git a/src/core/debugger/gdbstub_arch.cpp b/src/core/debugger/gdbstub_arch.cpp index 75c94a91a..f2a407dc8 100644 --- a/src/core/debugger/gdbstub_arch.cpp +++ b/src/core/debugger/gdbstub_arch.cpp | |||
| @@ -24,21 +24,6 @@ static std::string ValueToHex(const T value) { | |||
| 24 | return Common::HexToString(mem); | 24 | return Common::HexToString(mem); |
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | template <typename T> | ||
| 28 | static T GetSIMDRegister(const std::array<u32, 64>& simd_regs, size_t offset) { | ||
| 29 | static_assert(std::is_trivially_copyable_v<T>); | ||
| 30 | T value{}; | ||
| 31 | std::memcpy(&value, reinterpret_cast<const u8*>(simd_regs.data()) + sizeof(T) * offset, | ||
| 32 | sizeof(T)); | ||
| 33 | return value; | ||
| 34 | } | ||
| 35 | |||
| 36 | template <typename T> | ||
| 37 | static void PutSIMDRegister(std::array<u32, 64>& simd_regs, size_t offset, const T value) { | ||
| 38 | static_assert(std::is_trivially_copyable_v<T>); | ||
| 39 | std::memcpy(reinterpret_cast<u8*>(simd_regs.data()) + sizeof(T) * offset, &value, sizeof(T)); | ||
| 40 | } | ||
| 41 | |||
| 42 | // For sample XML files see the GDB source /gdb/features | 27 | // For sample XML files see the GDB source /gdb/features |
| 43 | // This XML defines what the registers are for this specific ARM device | 28 | // This XML defines what the registers are for this specific ARM device |
| 44 | std::string_view GDBStubA64::GetTargetXML() const { | 29 | std::string_view GDBStubA64::GetTargetXML() const { |
| @@ -184,12 +169,16 @@ std::string GDBStubA64::RegRead(const Kernel::KThread* thread, size_t id) const | |||
| 184 | return ""; | 169 | return ""; |
| 185 | } | 170 | } |
| 186 | 171 | ||
| 187 | const auto& context{thread->GetContext64()}; | 172 | const auto& context{thread->GetContext()}; |
| 188 | const auto& gprs{context.cpu_registers}; | 173 | const auto& gprs{context.r}; |
| 189 | const auto& fprs{context.vector_registers}; | 174 | const auto& fprs{context.v}; |
| 190 | 175 | ||
| 191 | if (id < SP_REGISTER) { | 176 | if (id < FP_REGISTER) { |
| 192 | return ValueToHex(gprs[id]); | 177 | return ValueToHex(gprs[id]); |
| 178 | } else if (id == FP_REGISTER) { | ||
| 179 | return ValueToHex(context.fp); | ||
| 180 | } else if (id == LR_REGISTER) { | ||
| 181 | return ValueToHex(context.lr); | ||
| 193 | } else if (id == SP_REGISTER) { | 182 | } else if (id == SP_REGISTER) { |
| 194 | return ValueToHex(context.sp); | 183 | return ValueToHex(context.sp); |
| 195 | } else if (id == PC_REGISTER) { | 184 | } else if (id == PC_REGISTER) { |
| @@ -212,10 +201,14 @@ void GDBStubA64::RegWrite(Kernel::KThread* thread, size_t id, std::string_view v | |||
| 212 | return; | 201 | return; |
| 213 | } | 202 | } |
| 214 | 203 | ||
| 215 | auto& context{thread->GetContext64()}; | 204 | auto& context{thread->GetContext()}; |
| 216 | 205 | ||
| 217 | if (id < SP_REGISTER) { | 206 | if (id < FP_REGISTER) { |
| 218 | context.cpu_registers[id] = HexToValue<u64>(value); | 207 | context.r[id] = HexToValue<u64>(value); |
| 208 | } else if (id == FP_REGISTER) { | ||
| 209 | context.fp = HexToValue<u64>(value); | ||
| 210 | } else if (id == LR_REGISTER) { | ||
| 211 | context.lr = HexToValue<u64>(value); | ||
| 219 | } else if (id == SP_REGISTER) { | 212 | } else if (id == SP_REGISTER) { |
| 220 | context.sp = HexToValue<u64>(value); | 213 | context.sp = HexToValue<u64>(value); |
| 221 | } else if (id == PC_REGISTER) { | 214 | } else if (id == PC_REGISTER) { |
| @@ -223,7 +216,7 @@ void GDBStubA64::RegWrite(Kernel::KThread* thread, size_t id, std::string_view v | |||
| 223 | } else if (id == PSTATE_REGISTER) { | 216 | } else if (id == PSTATE_REGISTER) { |
| 224 | context.pstate = HexToValue<u32>(value); | 217 | context.pstate = HexToValue<u32>(value); |
| 225 | } else if (id >= Q0_REGISTER && id < FPSR_REGISTER) { | 218 | } else if (id >= Q0_REGISTER && id < FPSR_REGISTER) { |
| 226 | context.vector_registers[id - Q0_REGISTER] = HexToValue<u128>(value); | 219 | context.v[id - Q0_REGISTER] = HexToValue<u128>(value); |
| 227 | } else if (id == FPSR_REGISTER) { | 220 | } else if (id == FPSR_REGISTER) { |
| 228 | context.fpsr = HexToValue<u32>(value); | 221 | context.fpsr = HexToValue<u32>(value); |
| 229 | } else if (id == FPCR_REGISTER) { | 222 | } else if (id == FPCR_REGISTER) { |
| @@ -381,22 +374,20 @@ std::string GDBStubA32::RegRead(const Kernel::KThread* thread, size_t id) const | |||
| 381 | return ""; | 374 | return ""; |
| 382 | } | 375 | } |
| 383 | 376 | ||
| 384 | const auto& context{thread->GetContext32()}; | 377 | const auto& context{thread->GetContext()}; |
| 385 | const auto& gprs{context.cpu_registers}; | 378 | const auto& gprs{context.r}; |
| 386 | const auto& fprs{context.extension_registers}; | 379 | const auto& fprs{context.v}; |
| 387 | 380 | ||
| 388 | if (id <= PC_REGISTER) { | 381 | if (id <= PC_REGISTER) { |
| 389 | return ValueToHex(gprs[id]); | 382 | return ValueToHex(static_cast<u32>(gprs[id])); |
| 390 | } else if (id == CPSR_REGISTER) { | 383 | } else if (id == CPSR_REGISTER) { |
| 391 | return ValueToHex(context.cpsr); | 384 | return ValueToHex(context.pstate); |
| 392 | } else if (id >= D0_REGISTER && id < Q0_REGISTER) { | 385 | } else if (id >= D0_REGISTER && id < Q0_REGISTER) { |
| 393 | const u64 dN{GetSIMDRegister<u64>(fprs, id - D0_REGISTER)}; | 386 | return ValueToHex(fprs[id - D0_REGISTER][0]); |
| 394 | return ValueToHex(dN); | ||
| 395 | } else if (id >= Q0_REGISTER && id < FPSCR_REGISTER) { | 387 | } else if (id >= Q0_REGISTER && id < FPSCR_REGISTER) { |
| 396 | const u128 qN{GetSIMDRegister<u128>(fprs, id - Q0_REGISTER)}; | 388 | return ValueToHex(fprs[id - Q0_REGISTER]); |
| 397 | return ValueToHex(qN); | ||
| 398 | } else if (id == FPSCR_REGISTER) { | 389 | } else if (id == FPSCR_REGISTER) { |
| 399 | return ValueToHex(context.fpscr); | 390 | return ValueToHex(context.fpcr | context.fpsr); |
| 400 | } else { | 391 | } else { |
| 401 | return ""; | 392 | return ""; |
| 402 | } | 393 | } |
| @@ -407,19 +398,20 @@ void GDBStubA32::RegWrite(Kernel::KThread* thread, size_t id, std::string_view v | |||
| 407 | return; | 398 | return; |
| 408 | } | 399 | } |
| 409 | 400 | ||
| 410 | auto& context{thread->GetContext32()}; | 401 | auto& context{thread->GetContext()}; |
| 411 | auto& fprs{context.extension_registers}; | 402 | auto& fprs{context.v}; |
| 412 | 403 | ||
| 413 | if (id <= PC_REGISTER) { | 404 | if (id <= PC_REGISTER) { |
| 414 | context.cpu_registers[id] = HexToValue<u32>(value); | 405 | context.r[id] = HexToValue<u32>(value); |
| 415 | } else if (id == CPSR_REGISTER) { | 406 | } else if (id == CPSR_REGISTER) { |
| 416 | context.cpsr = HexToValue<u32>(value); | 407 | context.pstate = HexToValue<u32>(value); |
| 417 | } else if (id >= D0_REGISTER && id < Q0_REGISTER) { | 408 | } else if (id >= D0_REGISTER && id < Q0_REGISTER) { |
| 418 | PutSIMDRegister(fprs, id - D0_REGISTER, HexToValue<u64>(value)); | 409 | fprs[id - D0_REGISTER] = {HexToValue<u64>(value), 0}; |
| 419 | } else if (id >= Q0_REGISTER && id < FPSCR_REGISTER) { | 410 | } else if (id >= Q0_REGISTER && id < FPSCR_REGISTER) { |
| 420 | PutSIMDRegister(fprs, id - Q0_REGISTER, HexToValue<u128>(value)); | 411 | fprs[id - Q0_REGISTER] = HexToValue<u128>(value); |
| 421 | } else if (id == FPSCR_REGISTER) { | 412 | } else if (id == FPSCR_REGISTER) { |
| 422 | context.fpscr = HexToValue<u32>(value); | 413 | context.fpcr = HexToValue<u32>(value); |
| 414 | context.fpsr = HexToValue<u32>(value); | ||
| 423 | } | 415 | } |
| 424 | } | 416 | } |
| 425 | 417 | ||