mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-12 09:48:37 +12:00
Add SPU usage for program dump
This commit is contained in:
parent
b639599ade
commit
faabb9e111
4 changed files with 243 additions and 16 deletions
|
@ -102,6 +102,8 @@ thread_local std::string_view g_tls_serialize_name;
|
|||
|
||||
extern thread_local std::string(*g_tls_log_prefix)();
|
||||
|
||||
extern f64 get_cpu_program_usage_percent(u64 hash);
|
||||
|
||||
// Report error and call std::abort(), defined in main.cpp
|
||||
[[noreturn]] void report_fatal_error(std::string_view text, bool is_html = false, bool include_help_text = true);
|
||||
|
||||
|
@ -3501,9 +3503,54 @@ void Emulator::Kill(bool allow_autoexit, bool savestate, savestate_stage* save_s
|
|||
to_log = to_log.substr(0, utils::add_saturate<usz>(to_log.rfind("\n========== SPU BLOCK"sv), 1));
|
||||
to_remove = to_log.size();
|
||||
|
||||
std::string new_log(to_log);
|
||||
|
||||
for (usz iter = 0, out_added = 0; iter < to_log.size();)
|
||||
{
|
||||
const usz index = to_log.find(") ==========", iter);
|
||||
|
||||
if (index == umax)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
const std::string_view until = to_log.substr(0, index);
|
||||
const usz seperator = until.rfind(", ");
|
||||
|
||||
if (seperator == umax)
|
||||
{
|
||||
iter = index + 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
const std::string_view prog_hash = until.substr(seperator + 2);
|
||||
|
||||
if (prog_hash.empty())
|
||||
{
|
||||
iter = index + 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
const fmt::base57_result result = fmt::base57_result::from_string(prog_hash);
|
||||
|
||||
if (result.size < sizeof(be_t<u64>))
|
||||
{
|
||||
iter = index + 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
const u64 hash_val = read_from_ptr<be_t<u64>>(result.data) & -65536;
|
||||
const f64 usage = get_cpu_program_usage_percent(hash_val);
|
||||
const std::string text_append = fmt::format("usage %%%g, ", usage);
|
||||
new_log.insert(new_log.begin() + seperator + out_added + 2, text_append.begin(), text_append.end());
|
||||
|
||||
out_added += text_append.size();
|
||||
iter = index + 1;
|
||||
}
|
||||
|
||||
// Cannot log it all at once due to technical reasons, split it to 8MB at maximum of whole functions
|
||||
// Assume the block prefix exists because it is created by RPCS3 (or log it in an ugly manner if it does not exist)
|
||||
sys_log.notice("Logging spu.log #%u:\n\n%s\n", part_ctr, to_log);
|
||||
sys_log.notice("Logging spu.log #%u:\n\n%s\n", part_ctr, new_log);
|
||||
}
|
||||
|
||||
sys_log.notice("End spu.log (%u bytes)", total_size);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue