diff --git a/rpcs3/Emu/Cell/SPUCommonRecompiler.cpp b/rpcs3/Emu/Cell/SPUCommonRecompiler.cpp index 2874f1ea60..2a8a3c272b 100644 --- a/rpcs3/Emu/Cell/SPUCommonRecompiler.cpp +++ b/rpcs3/Emu/Cell/SPUCommonRecompiler.cpp @@ -5199,3 +5199,25 @@ std::unique_ptr spu_recompiler_base::make_fast_llvm_recompi { return std::make_unique(); } + +extern std::string format_spu_func_info(u32 addr, cpu_thread* spu) +{ + spu_thread* _spu = static_cast(spu); + + std::unique_ptr compiler = spu_recompiler_base::make_asmjit_recompiler(); + compiler->init(); + auto func = compiler->analyse(reinterpret_cast*>(_spu->ls), addr); + + std::string info; + { + sha1_context ctx; + u8 output[20]; + + sha1_starts(&ctx); + sha1_update(&ctx, reinterpret_cast(func.data.data()), func.data.size() * 4); + sha1_finish(&ctx, output); + fmt::append(info, "size=%d, end=0x%x, hash=%s", func.data.size(), addr + func.data.size() * 4, fmt::base57(output)); + } + + return info; +} diff --git a/rpcs3/rpcs3qt/instruction_editor_dialog.cpp b/rpcs3/rpcs3qt/instruction_editor_dialog.cpp index 1a764b7f05..dd13793ab6 100644 --- a/rpcs3/rpcs3qt/instruction_editor_dialog.cpp +++ b/rpcs3/rpcs3qt/instruction_editor_dialog.cpp @@ -15,6 +15,8 @@ constexpr auto qstr = QString::fromStdString; extern bool ppu_patch(u32 addr, u32 value); +extern std::string format_spu_func_info(u32 addr, cpu_thread* spu); + instruction_editor_dialog::instruction_editor_dialog(QWidget *parent, u32 _pc, CPUDisAsm* _disasm, std::function func) : QDialog(parent) , m_pc(_pc) @@ -58,6 +60,16 @@ instruction_editor_dialog::instruction_editor_dialog(QWidget *parent, u32 _pc, C vbox_right_panel->addWidget(m_instr); vbox_right_panel->addWidget(m_preview); + if (cpu && cpu->id_type() == 2) + { + // Print block information as if this instruction is its beginning + vbox_left_panel->addWidget(new QLabel(tr("Block Info: "))); + m_func_info = new QLabel("", this); + vbox_right_panel->addWidget(m_func_info); + + m_func_info->setText(qstr(format_spu_func_info(m_pc, cpu))); + } + if (cpu && cpu->id_type() == 2) { const auto& spu = static_cast(*cpu); diff --git a/rpcs3/rpcs3qt/instruction_editor_dialog.h b/rpcs3/rpcs3qt/instruction_editor_dialog.h index 1bd1d5039e..0b7854d04e 100644 --- a/rpcs3/rpcs3qt/instruction_editor_dialog.h +++ b/rpcs3/rpcs3qt/instruction_editor_dialog.h @@ -20,6 +20,7 @@ private: std::shared_ptr m_disasm; // shared in order to allow an incomplete type QLineEdit* m_instr; QLabel* m_preview; + QLabel* m_func_info = nullptr; QCheckBox* m_apply_for_spu_group = nullptr; const std::function m_get_cpu;