1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 02:32:36 +01:00

Optimize RSX Debugger

This commit is contained in:
Eladash 2023-07-31 10:24:16 +03:00 committed by Elad Ashkenazi
parent 53c1da8f94
commit b12edf70bb
7 changed files with 622 additions and 592 deletions

View File

@ -109,6 +109,8 @@ u32 RSXDisAsm::disasm(u32 pc)
pc += 4;
std::string str;
for (u32 i = 0; i < count; i++, pc += 4)
{
if (!try_read_op(pc))
@ -137,7 +139,9 @@ u32 RSXDisAsm::disasm(u32 pc)
continue;
}
std::string str = rsx::get_pretty_printing_function(id)(id, m_op);
str.clear();
rsx::get_pretty_printing_function(id)(str, id, m_op);
Write(str, m_mode == cpu_disasm_mode::list ? i : count, non_inc, id);
}

View File

@ -3198,7 +3198,9 @@ namespace rsx
}
}
fmt::append(result, "[%04x] %s\n", i, ensure(rsx::get_pretty_printing_function(i))(i, method_registers.registers[i]));
fmt::append(result, "[%04x] ", i);
ensure(rsx::get_pretty_printing_function(i))(result, i, method_registers.registers[i]);
result += '\n';
}
}

View File

@ -612,8 +612,21 @@ void fmt_class_string<texture_max_anisotropy>::format(std::string& out, u64 arg)
namespace rsx
{
std::string print_boolean(bool b)
enum class boolean_to_string_t : u8;
}
template <>
void fmt_class_string<boolean_to_string_t>::format(std::string& out, u64 arg)
{
format_enum(out, arg, [](boolean_to_string_t value)
{
return b ? "enabled" : "disabled";
}
} // end namespace rsx
switch (value)
{
case boolean_to_string_t{+true}: return "true";
case boolean_to_string_t{+false}: return "false";
default: break; // TODO: This is technically unreachable but need needs to be reachable when value is not 1 or 0
}
return unknown;
});
}

View File

@ -902,18 +902,20 @@ namespace
#undef KEY_STR
}
std::string rsx::get_method_name(const u32 id)
std::pair<std::string_view, std::string_view> rsx::get_method_name(u32 id, std::string& string_name)
{
const auto found = methods_name.find(id);
if (found != methods_name.end())
{
std::string prefix("CELL_GCM_"sv);
prefix.append(found->second.data(), found->second.size());
return prefix;
constexpr std::string_view prefix = "CELL_GCM_";
return {prefix, found->second};
}
return fmt::format("Unnamed method 0x%04x", id);
string_name.clear();
fmt::append(string_name, "Unnamed method 0x%04x", id);
return {};
}
// Various parameter pretty printing function
@ -984,15 +986,15 @@ namespace
namespace
{
template <u32 Opcode>
std::string register_pretty_function(u32 /*id*/, u32 arg)
void register_pretty_function(std::string& out, u32 /*id*/, u32 arg)
{
return rsx::registers_decoder<Opcode>::dump(arg);
rsx::registers_decoder<Opcode>::dump(out, arg);
}
template <typename T, T... Index>
std::array<std::string(*)(u32, u32), 1 << 14> create_printing_table(std::integer_sequence<T, Index...>)
std::array<void(*)(std::string&, u32, u32), 1 << 14> create_printing_table(std::integer_sequence<T, Index...>)
{
std::array<std::string(*)(u32, u32), 1 << 14> result{};
std::array<void(*)(std::string&, u32, u32), 1 << 14> result{};
((result[opcode_list[Index * 5 + 0]] = &register_pretty_function<opcode_list[Index * 5 + 0]>,
result[opcode_list[Index * 5 + 1]] = &register_pretty_function<opcode_list[Index * 5 + 1]>,
@ -1022,7 +1024,7 @@ namespace
};*/
}
std::add_pointer_t<std::string(u32, u32)> rsx::get_pretty_printing_function(u32 id)
std::add_pointer_t<void(std::string&, u32, u32)> rsx::get_pretty_printing_function(u32 id)
{
const auto found = id < printing_functions.size() ? printing_functions[id] : nullptr;
@ -1031,11 +1033,17 @@ std::add_pointer_t<std::string(u32, u32)> rsx::get_pretty_printing_function(u32
return found;
}
return [](u32 id, u32 v)
return [](std::string& result, u32 id, u32 v)
{
const std::string name = rsx::get_method_name(id);
const std::string_view view = name, prefix = "CELL_GCM_"sv;
std::string string_name;
const auto [name_prefix, name] = rsx::get_method_name(id, string_name);
return fmt::format("%s: 0x%08x", name.starts_with("CELL_GCM_"sv) ? view.substr(prefix.size()) : view, v);
if (!string_name.empty())
{
fmt::append(result, "%s: 0x%08x", string_name, v);
return;
}
fmt::append(result, "%s: 0x%08x", name, v);
};
}

View File

@ -6,7 +6,7 @@
namespace rsx
{
std::string get_method_name(u32 id);
std::pair<std::string_view, std::string_view> get_method_name(u32 id, std::string& result_str);
std::add_pointer_t<std::string(u32, u32)> get_pretty_printing_function(u32 id);
std::add_pointer_t<void(std::string&, u32, u32)> get_pretty_printing_function(u32 id);
}

File diff suppressed because it is too large Load Diff

View File

@ -629,18 +629,21 @@ void rsx_debugger::GetMemory() const
std::string dump;
u32 cmd_i = 0;
std::string str;
for (const auto& command : frame_debug.command_queue)
{
const std::string str = rsx::get_pretty_printing_function(command.first)(command.first, command.second);
str.clear();
rsx::get_pretty_printing_function(command.first)(str, command.first, command.second);
m_list_captured_frame->setItem(cmd_i++, 0, new QTableWidgetItem(qstr(str)));
dump += str;
dump += '\n';
}
if (fs::file file = fs::file(fs::get_cache_dir() + "command_dump.log", fs::rewrite))
if (!dump.empty())
{
file.write(dump);
fs::write_file(fs::get_cache_dir() + "command_dump.log", fs::rewrite, dump);
}
for (u32 i = 0; i < frame_debug.draw_calls.size(); i++)