mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-08-08 17:19:17 +00:00
memory viewer: Add RegEx instruction searching mode
This commit is contained in:
parent
c21cdb8055
commit
8d54ddf426
3 changed files with 18 additions and 6 deletions
|
@ -12,6 +12,7 @@
|
||||||
|
|
||||||
#include <charconv>
|
#include <charconv>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
#include <regex>
|
||||||
|
|
||||||
#include "util/logs.hpp"
|
#include "util/logs.hpp"
|
||||||
#include "util/sysinfo.hpp"
|
#include "util/sysinfo.hpp"
|
||||||
|
@ -40,7 +41,9 @@ void fmt_class_string<search_mode>::format(std::string& out, u64 arg)
|
||||||
case as_f64: return "Double";
|
case as_f64: return "Double";
|
||||||
case as_f32: return "Float";
|
case as_f32: return "Float";
|
||||||
case as_inst: return "Instruction";
|
case as_inst: return "Instruction";
|
||||||
|
case as_regex_inst: return "Regex-Instruction";
|
||||||
case as_fake_spu_inst: return "SPU Instruction";
|
case as_fake_spu_inst: return "SPU Instruction";
|
||||||
|
case as_regex_fake_spu_inst: return "SPU Regex-Instruction";
|
||||||
default: return "";
|
default: return "";
|
||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
|
@ -82,7 +85,9 @@ u64 memory_viewer_panel::OnSearch(std::string wstr, u32 mode)
|
||||||
{
|
{
|
||||||
case as_inst:
|
case as_inst:
|
||||||
case as_string:
|
case as_string:
|
||||||
|
case as_regex_inst:
|
||||||
case as_fake_spu_inst:
|
case as_fake_spu_inst:
|
||||||
|
case as_regex_fake_spu_inst:
|
||||||
{
|
{
|
||||||
case_insensitive = m_chkbox_case_insensitive->isChecked();
|
case_insensitive = m_chkbox_case_insensitive->isChecked();
|
||||||
|
|
||||||
|
@ -105,7 +110,7 @@ u64 memory_viewer_panel::OnSearch(std::string wstr, u32 mode)
|
||||||
{
|
{
|
||||||
if (part.size() % 2)
|
if (part.size() % 2)
|
||||||
{
|
{
|
||||||
gui_log.warning("Padding string part with '0' at front due to odd hexadeciaml characters count.");
|
gui_log.warning("Padding string part with '0' at front due to odd hexadecimal characters count.");
|
||||||
part.insert(part.begin(), '0');
|
part.insert(part.begin(), '0');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -187,7 +192,7 @@ u64 memory_viewer_panel::OnSearch(std::string wstr, u32 mode)
|
||||||
|
|
||||||
const named_thread_group workers("Memory Searcher "sv, max_threads, [&]()
|
const named_thread_group workers("Memory Searcher "sv, max_threads, [&]()
|
||||||
{
|
{
|
||||||
if (mode == as_inst || mode == as_fake_spu_inst)
|
if (mode == as_inst || mode == as_fake_spu_inst || mode == as_regex_inst || mode == as_regex_fake_spu_inst)
|
||||||
{
|
{
|
||||||
auto disasm = m_disasm->copy_type_erased();
|
auto disasm = m_disasm->copy_type_erased();
|
||||||
disasm->change_mode(cpu_disasm_mode::normal);
|
disasm->change_mode(cpu_disasm_mode::normal);
|
||||||
|
@ -260,7 +265,9 @@ u64 memory_viewer_panel::OnSearch(std::string wstr, u32 mode)
|
||||||
std::transform(last.begin(), last.end(), last.begin(), ::tolower);
|
std::transform(last.begin(), last.end(), last.begin(), ::tolower);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (last.find(wstr) != umax)
|
std::smatch sm;
|
||||||
|
|
||||||
|
if (mode & (as_regex_inst | as_regex_fake_spu_inst) ? std::regex_search(last, sm, std::regex(wstr)) : last.find(wstr) != umax)
|
||||||
{
|
{
|
||||||
gui_log.success("Found instruction at 0x%08x: '%s'", addr + i, last);
|
gui_log.success("Found instruction at 0x%08x: '%s'", addr + i, last);
|
||||||
found++;
|
found++;
|
||||||
|
|
|
@ -304,16 +304,19 @@ memory_viewer_panel::memory_viewer_panel(QWidget* parent, std::shared_ptr<CPUDis
|
||||||
m_cbox_input_mode->addItem(tr("Double"), QVariant::fromValue(+as_f64));
|
m_cbox_input_mode->addItem(tr("Double"), QVariant::fromValue(+as_f64));
|
||||||
m_cbox_input_mode->addItem(tr("Float"), QVariant::fromValue(+as_f32));
|
m_cbox_input_mode->addItem(tr("Float"), QVariant::fromValue(+as_f32));
|
||||||
m_cbox_input_mode->addItem(tr("Instruction"), QVariant::fromValue(+as_inst));
|
m_cbox_input_mode->addItem(tr("Instruction"), QVariant::fromValue(+as_inst));
|
||||||
|
m_cbox_input_mode->addItem(tr("RegEx Instruction"), QVariant::fromValue(+as_regex_inst));
|
||||||
|
|
||||||
QString tooltip = tr("String: search the memory for the specified string."
|
QString tooltip = tr("String: search the memory for the specified string."
|
||||||
"\nHEX bytes/integer: search the memory for hexadecimal values. Spaces, commas, \"0x\", \"0X\", \"\\x\", \"h\", \"H\" ensure separation of bytes but they are not mandatory."
|
"\nHEX bytes/integer: search the memory for hexadecimal values. Spaces, commas, \"0x\", \"0X\", \"\\x\", \"h\", \"H\" ensure separation of bytes but they are not mandatory."
|
||||||
"\nDouble: reinterpret the string as 64-bit precision floating point value. Values are searched for exact representation, meaning -0 != 0."
|
"\nDouble: reinterpret the string as 64-bit precision floating point value. Values are searched for exact representation, meaning -0 != 0."
|
||||||
"\nFloat: reinterpret the string as 32-bit precision floating point value. Values are searched for exact representation, meaning -0 != 0."
|
"\nFloat: reinterpret the string as 32-bit precision floating point value. Values are searched for exact representation, meaning -0 != 0."
|
||||||
"\nInstruction: search an instruction contains the text of the string.");
|
"\nInstruction: search an instruction contains the text of the string."
|
||||||
|
"\nRegEx: search an instruction containing text that matches the regular expression input.");
|
||||||
|
|
||||||
if (m_size != 0x40000/*SPU_LS_SIZE*/)
|
if (m_size != 0x40000/*SPU_LS_SIZE*/)
|
||||||
{
|
{
|
||||||
m_cbox_input_mode->addItem("SPU Instruction", QVariant::fromValue(+as_fake_spu_inst));
|
m_cbox_input_mode->addItem("SPU Instruction", QVariant::fromValue(+as_fake_spu_inst));
|
||||||
|
m_cbox_input_mode->addItem(tr("SPU RegEx-Instruction"), QVariant::fromValue(+as_regex_fake_spu_inst));
|
||||||
tooltip.append(tr("\nSPU Instruction: Search an SPU instruction contains the text of the string. For searching instructions within embedded SPU images.\nTip: SPU floats are commented along forming instructions."));
|
tooltip.append(tr("\nSPU Instruction: Search an SPU instruction contains the text of the string. For searching instructions within embedded SPU images.\nTip: SPU floats are commented along forming instructions."));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,8 +40,10 @@ enum search_mode : unsigned
|
||||||
as_f64 = 16,
|
as_f64 = 16,
|
||||||
as_f32 = 32,
|
as_f32 = 32,
|
||||||
as_inst = 64,
|
as_inst = 64,
|
||||||
as_fake_spu_inst = 128,
|
as_regex_inst = 128,
|
||||||
search_mode_last = 256,
|
as_fake_spu_inst = 256,
|
||||||
|
as_regex_fake_spu_inst = 512,
|
||||||
|
search_mode_last = 1024,
|
||||||
};
|
};
|
||||||
|
|
||||||
class memory_viewer_panel final : public QDialog
|
class memory_viewer_panel final : public QDialog
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue