Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugger Improvements x999 #8758

Merged
merged 5 commits into from Aug 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
39 changes: 30 additions & 9 deletions rpcs3/Emu/Cell/PPUThread.cpp
Expand Up @@ -333,25 +333,40 @@ extern void ppu_remove_breakpoint(u32 addr)

extern bool ppu_patch(u32 addr, u32 value)
{
if (g_cfg.core.ppu_decoder == ppu_decoder_type::llvm && Emu.GetStatus() != system_state::ready)
if (addr % 4)
{
// TODO: support recompilers
ppu_log.fatal("Patch failed at 0x%x: LLVM recompiler is used.", addr);
ppu_log.fatal("Patch failed at 0x%x: unanligned memory address.", addr);
return false;
}

if (!vm::try_access(addr, &value, sizeof(value), true))
vm::reader_lock rlock;

if (!vm::check_addr(addr, sizeof(value)))
{
ppu_log.fatal("Patch failed at 0x%x: invalid memory address.", addr);
return false;
}

const bool is_exec = vm::check_addr(addr, sizeof(value), vm::page_executable);

if (is_exec && g_cfg.core.ppu_decoder == ppu_decoder_type::llvm && !Emu.IsReady())
{
// TODO: support recompilers
ppu_log.fatal("Patch failed at 0x%x: LLVM recompiler is used.", addr);
return false;
}

*vm::get_super_ptr<u32>(addr) = value;

const u32 _break = ::narrow<u32>(reinterpret_cast<std::uintptr_t>(&ppu_break));
const u32 fallback = ::narrow<u32>(reinterpret_cast<std::uintptr_t>(&ppu_fallback));

if (ppu_ref<u32>(addr) != _break && ppu_ref<u32>(addr) != fallback)
if (is_exec)
{
ppu_ref(addr) = ppu_cache(addr);
if (ppu_ref<u32>(addr) != _break && ppu_ref<u32>(addr) != fallback)
{
ppu_ref(addr) = ppu_cache(addr);
}
}

return true;
Expand Down Expand Up @@ -398,10 +413,9 @@ std::string ppu_thread::dump_regs() const
if (toc % 4 == 0 && vm::check_addr(toc))
{
is_function = true;
reg = reg_ptr;
}
}

reg = reg_ptr;
}
else if (reg % 4 == 0 && vm::check_addr(reg, 4, vm::page_executable))
{
Expand Down Expand Up @@ -486,7 +500,14 @@ std::vector<std::pair<u32, u32>> ppu_thread::dump_callstack_list() const
//std::shared_lock rlock(vm::g_mutex); // Needs optimizations

// Determine stack range
const u32 stack_ptr = static_cast<u32>(gpr[1]);
const u64 r1 = gpr[1];

if (r1 > UINT32_MAX || r1 % 0x10)
{
return {};
}

const u32 stack_ptr = static_cast<u32>(r1);

if (!vm::check_addr(stack_ptr, 1, vm::page_writable))
{
Expand Down
3 changes: 1 addition & 2 deletions rpcs3/rpcs3qt/debugger_frame.cpp
Expand Up @@ -232,8 +232,7 @@ void debugger_frame::keyPressEvent(QKeyEvent* event)
return;
}

const u32 start_pc = m_debugger_list->m_pc - m_debugger_list->m_item_count * 4;
const u32 pc = start_pc + i * 4;
const u32 pc = m_debugger_list->m_pc + i * 4;

if (QApplication::keyboardModifiers() & Qt::ControlModifier)
{
Expand Down
8 changes: 4 additions & 4 deletions rpcs3/rpcs3qt/debugger_list.cpp
Expand Up @@ -153,10 +153,10 @@ void debugger_list::keyPressEvent(QKeyEvent* event)

switch (event->key())
{
case Qt::Key_PageUp: ShowAddress(m_pc - (m_item_count * 2) * 4); return;
case Qt::Key_PageDown: ShowAddress(m_pc); return;
case Qt::Key_Up: ShowAddress(m_pc - (m_item_count + 1) * 4); return;
case Qt::Key_Down: ShowAddress(m_pc - (m_item_count - 1) * 4); return;
case Qt::Key_PageUp: ShowAddress(m_pc - (m_item_count * 4), true); return;
case Qt::Key_PageDown: ShowAddress(m_pc + (m_item_count * 4), true); return;
case Qt::Key_Up: ShowAddress(m_pc - 4, true); return;
case Qt::Key_Down: ShowAddress(m_pc + 4, true); return;
default: break;
}
}
Expand Down