SPU debugger: Implement blocking functions dumping

This commit is contained in:
Eladash 2020-04-13 21:53:19 +03:00 committed by Ivan
parent 2e397e38a4
commit ec1e82bc9d
2 changed files with 51 additions and 1 deletions

View File

@ -999,6 +999,8 @@ std::string spu_thread::dump_regs() const
fmt::append(ret, "\nEvent Stat: 0x%x\n", +ch_event_stat);
fmt::append(ret, "Event Mask: 0x%x\n", +ch_event_mask);
fmt::append(ret, "Stall Mask: 0x%x\n", ch_stall_mask);
fmt::append(ret, "Tag Stat: %s\n", ch_tag_stat);
if (const u32 addr = raddr)
fmt::append(ret, "Reservation Addr: 0x%x\n", addr);
@ -1045,10 +1047,31 @@ std::string spu_thread::dump_misc() const
// Print chunk address from lowest 16 bits
fmt::append(ret, "...chunk-0x%05x", (name & 0xffff) * 4);
}
fmt::append(ret, "\n[%s]", ch_mfc_cmd);
fmt::append(ret, "\nLocal Storage: 0x%08x..0x%08x", offset, offset + 0x3ffff);
if (const u64 _time = start_time)
{
if (const auto func = current_func)
{
ret += "\nCurrent function: ";
ret += func;
}
else
{
ret += '\n';
}
fmt::append(ret, "\nWaiting: %fs", (get_system_time() - _time) / 1000000.);
}
else
{
ret += "\n\n";
}
fmt::append(ret, "\nTag Mask: 0x%08x", ch_tag_mask);
fmt::append(ret, "\nMFC Stall: 0x%08x", ch_stall_mask);
fmt::append(ret, "\nMFC Queue Size: %u", mfc_size);
for (u32 i = 0; i < 16; i++)
@ -2482,6 +2505,8 @@ s64 spu_thread::get_ch_value(u32 ch)
return res;
}
spu_function_logger logger(*this, "MFC Events read");
const u32 mask1 = ch_event_mask;
if (mask1 & SPU_EVENT_LR && raddr)
@ -2968,6 +2993,8 @@ bool spu_thread::stop_and_signal(u32 code)
state += cpu_flag::wait;
spu_function_logger logger(*this, "sys_spu_thread_receive_event");
while (true)
{
queue.reset();
@ -3265,6 +3292,13 @@ void spu_thread::fast_call(u32 ls_addr)
gpr[1]._u32[3] = old_stack;
}
spu_function_logger::spu_function_logger(spu_thread& spu, const char* func)
: spu(spu)
{
spu.current_func = func;
spu.start_time = get_system_time();
}
template <>
void fmt_class_string<spu_channel>::format(std::string& out, u64 arg)
{

View File

@ -619,6 +619,9 @@ public:
std::array<v128, 0x4000> stack_mirror; // Return address information
const char* current_func{}; // Current STOP or RDCH blocking function
u64 start_time{}; // Starting time of STOP or RDCH bloking function
void push_snr(u32 number, u32 value);
void do_dma_transfer(const spu_mfc_cmd& args);
bool do_dma_check(const spu_mfc_cmd& args);
@ -669,3 +672,16 @@ public:
return -1;
}
};
class spu_function_logger
{
spu_thread& spu;
public:
spu_function_logger(spu_thread& spu, const char* func);
~spu_function_logger()
{
spu.start_time = 0;
}
};