arm_interface.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #include "common/logging/log.h"
  4. #include "core/arm/arm_interface.h"
  5. #include "core/arm/debug.h"
  6. #include "core/core.h"
  7. #include "core/hle/kernel/k_process.h"
  8. namespace Core {
  9. void ArmInterface::LogBacktrace(Kernel::KProcess* process) const {
  10. Kernel::Svc::ThreadContext ctx;
  11. this->GetContext(ctx);
  12. LOG_ERROR(Core_ARM, "Backtrace, sp={:016X}, pc={:016X}", ctx.sp, ctx.pc);
  13. LOG_ERROR(Core_ARM, "{:20}{:20}{:20}{:20}{}", "Module Name", "Address", "Original Address",
  14. "Offset", "Symbol");
  15. LOG_ERROR(Core_ARM, "");
  16. const auto backtrace = GetBacktraceFromContext(process, ctx);
  17. for (const auto& entry : backtrace) {
  18. LOG_ERROR(Core_ARM, "{:20}{:016X} {:016X} {:016X} {}", entry.module, entry.address,
  19. entry.original_address, entry.offset, entry.name);
  20. }
  21. }
  22. const Kernel::DebugWatchpoint* ArmInterface::MatchingWatchpoint(
  23. u64 addr, u64 size, Kernel::DebugWatchpointType access_type) const {
  24. if (!m_watchpoints) {
  25. return nullptr;
  26. }
  27. const u64 start_address{addr};
  28. const u64 end_address{addr + size};
  29. for (size_t i = 0; i < Core::Hardware::NUM_WATCHPOINTS; i++) {
  30. const auto& watch{(*m_watchpoints)[i]};
  31. if (end_address <= GetInteger(watch.start_address)) {
  32. continue;
  33. }
  34. if (start_address >= GetInteger(watch.end_address)) {
  35. continue;
  36. }
  37. if ((access_type & watch.type) == Kernel::DebugWatchpointType::None) {
  38. continue;
  39. }
  40. return &watch;
  41. }
  42. return nullptr;
  43. }
  44. } // namespace Core