mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-28 21:38:01 +03:00
Introducing RSX debugger entry (main debugger)
This commit is contained in:
parent
62cb532460
commit
dbecf0fa50
14 changed files with 1685 additions and 1220 deletions
|
@ -5,6 +5,7 @@
|
|||
#include "Emu/Cell/RawSPUThread.h"
|
||||
#include "Emu/Cell/lv2/sys_mmapper.h"
|
||||
#include "Emu/Cell/lv2/sys_event.h"
|
||||
#include "Emu/RSX/RSXThread.h"
|
||||
#include "Thread.h"
|
||||
#include "Utilities/JIT.h"
|
||||
#include <typeinfo>
|
||||
|
@ -104,6 +105,32 @@ void fmt_class_string<std::thread::id>::format(std::string& out, u64 arg)
|
|||
out += ss.str();
|
||||
}
|
||||
|
||||
std::string dump_useful_thread_info()
|
||||
{
|
||||
thread_local volatile bool guard = false;
|
||||
|
||||
std::string result;
|
||||
|
||||
// In case the dumping function was the cause for the exception/access violation
|
||||
// Avoid recursion
|
||||
if (std::exchange(guard, true))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
if (auto cpu = get_current_cpu_thread())
|
||||
{
|
||||
result = cpu->dump_all();
|
||||
}
|
||||
else if (auto render = rsx::get_current_renderer(); render && render->is_current_thread())
|
||||
{
|
||||
result = render->dump_regs();
|
||||
}
|
||||
|
||||
guard = false;
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
bool IsDebuggerPresent()
|
||||
{
|
||||
|
@ -1531,7 +1558,7 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context) no
|
|||
{
|
||||
if (!g_tls_access_violation_recovered)
|
||||
{
|
||||
vm_log.notice("\n%s", cpu->dump_all());
|
||||
vm_log.notice("\n%s", dump_useful_thread_info());
|
||||
vm_log.error("Access violation %s location 0x%x (%s) [type=u%u]", is_writing ? "writing" : "reading", addr, (is_writing && vm::check_addr(addr)) ? "read-only memory" : "unmapped memory", d_size * 8);
|
||||
}
|
||||
|
||||
|
@ -1560,9 +1587,9 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context) no
|
|||
|
||||
Emu.Pause();
|
||||
|
||||
if (cpu && !g_tls_access_violation_recovered)
|
||||
if (!g_tls_access_violation_recovered)
|
||||
{
|
||||
vm_log.notice("\n%s", cpu->dump_all());
|
||||
vm_log.notice("\n%s", dump_useful_thread_info());
|
||||
}
|
||||
|
||||
// Note: a thread may access violate more than once after hack_alloc recovery
|
||||
|
@ -1647,10 +1674,7 @@ static LONG exception_filter(PEXCEPTION_POINTERS pExp) noexcept
|
|||
{
|
||||
fmt::append(msg, "Emu Thread Name: '%s'.\n", thread_ctrl::get_name());
|
||||
|
||||
if (const auto cpu = get_current_cpu_thread())
|
||||
{
|
||||
sys_log.notice("\n%s", cpu->dump_all());
|
||||
}
|
||||
sys_log.notice("\n%s", dump_useful_thread_info());
|
||||
}
|
||||
|
||||
// TODO: Report full thread name if not an emu thread
|
||||
|
@ -1775,16 +1799,12 @@ static void signal_handler(int sig, siginfo_t* info, void* uct) noexcept
|
|||
}
|
||||
}
|
||||
|
||||
if (const auto cpu = get_current_cpu_thread())
|
||||
{
|
||||
sys_log.notice("\n%s", cpu->dump_all());
|
||||
}
|
||||
|
||||
std::string msg = fmt::format("Segfault %s location %p at %p.\n", cause, info->si_addr, RIP(context));
|
||||
|
||||
if (thread_ctrl::get_current())
|
||||
{
|
||||
fmt::append(msg, "Emu Thread Name: '%s'.\n", thread_ctrl::get_name());
|
||||
sys_log.notice("\n%s", dump_useful_thread_info());
|
||||
}
|
||||
|
||||
// TODO: Report full thread name if not an emu thread
|
||||
|
@ -2391,6 +2411,11 @@ u64 thread_base::get_cycles()
|
|||
|
||||
[[noreturn]] void thread_ctrl::emergency_exit(std::string_view reason)
|
||||
{
|
||||
if (std::string info = dump_useful_thread_info(); !info.empty())
|
||||
{
|
||||
sys_log.notice("\%s", info);
|
||||
}
|
||||
|
||||
sig_log.fatal("Thread terminated due to fatal error: %s", reason);
|
||||
|
||||
std::fprintf(stderr, "Thread '%s' terminated due to fatal error: %s\n", g_tls_log_prefix().c_str(), std::string(reason).c_str());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue