ShowAtPC static method

This commit is contained in:
trigger 2025-04-29 15:29:42 -07:00
parent 1565462842
commit 791091ca1f
3 changed files with 27 additions and 21 deletions

View file

@ -55,9 +55,6 @@ extern bool is_using_interpreter(thread_class t_class);
extern std::shared_ptr<CPUDisAsm> make_disasm(const cpu_thread* cpu, shared_ptr<cpu_thread> handle);
class CPUDisAsm;
std::shared_ptr<CPUDisAsm> make_basic_ppu_disasm();
debugger_frame::debugger_frame(std::shared_ptr<gui_settings> gui_settings, QWidget *parent)
: custom_dock_widget(tr("Debugger [Press F1 for Help]"), parent)
, m_gui_settings(std::move(gui_settings))
@ -1749,20 +1746,5 @@ void debugger_frame::RegsShowMemoryViewerAction()
const quint64 value = norm.toULongLong(&ok, 16);
const u32 pc = static_cast<u32>(value);
const u32 id = idm::last_id();
auto handle_ptr = idm::get_unlocked<memory_viewer_handle>(id);
if (!handle_ptr)
{
idm::make<memory_viewer_handle>(this, make_basic_ppu_disasm(), pc);
return;
}
handle_ptr->m_mvp->SetPC(pc);
handle_ptr->m_mvp->raise();
handle_ptr->m_mvp->scroll(0);
if (!handle_ptr->m_mvp->isVisible())
{
handle_ptr->m_mvp->show();
}
memory_viewer_panel::ShowAtPC(pc);
}

View file

@ -28,6 +28,9 @@
LOG_CHANNEL(gui_log, "GUI");
class CPUDisAsm;
std::shared_ptr<CPUDisAsm> make_basic_ppu_disasm();
constexpr auto qstr = QString::fromStdString;
memory_viewer_panel::memory_viewer_panel(QWidget* parent, std::shared_ptr<CPUDisAsm> disasm, u32 addr, std::function<cpu_thread*()> func)
@ -1244,3 +1247,23 @@ void memory_viewer_panel::ShowImage(QWidget* parent, u32 addr, color_format form
f_image_viewer->setFixedSize(f_image_viewer->sizeHint());
});
}
void memory_viewer_panel::ShowAtPC(u32 pc)
{
const u32 id = idm::last_id();
auto handle_ptr = idm::get_unlocked<memory_viewer_handle>(id);
if (!handle_ptr)
{
idm::make<memory_viewer_handle>(nullptr, make_basic_ppu_disasm(), pc);
return;
}
handle_ptr->m_mvp->SetPC(pc);
handle_ptr->m_mvp->raise();
handle_ptr->m_mvp->scroll(0);
if (!handle_ptr->m_mvp->isVisible())
{
handle_ptr->m_mvp->show();
}
}

View file

@ -55,8 +55,7 @@ public:
memory_viewer_panel(QWidget* parent, std::shared_ptr<CPUDisAsm> disasm, u32 addr = 0, std::function<cpu_thread*()> func = []() -> cpu_thread* { return {}; });
~memory_viewer_panel();
void scroll(s32 steps);
void SetPC(const uint pc);
static void ShowAtPC(u32 pc);
enum class color_format : int
{
@ -109,7 +108,9 @@ private:
search_mode m_modes{};
std::string getHeaderAtAddr(u32 addr) const;
void scroll(s32 steps);
void* to_ptr(u32 addr, u32 size = 1) const;
void SetPC(const uint pc);
void ShowMemory();