Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delay GDB server launch until emulator run #4658

Merged
merged 11 commits into from
Jun 8, 2018
Merged

Delay GDB server launch until emulator run #4658

merged 11 commits into from
Jun 8, 2018

Conversation

Daniel-Valentine
Copy link
Contributor

This PR shifts a few lines of code to delay the GDB server from running until the emulator itself actually begins.

As it stands the GDB server starts and awaits connections as soon as RPCS3 is launched but before any emulation. Attempting to attach GDB will cause RPCS3 to segfault by deferencing a nullptr, specifically th in the command parser functions, because select_thread wasn't able to select a thread and left the selected_thread pointer empty, because the CPU isn't running.

Example GDB trace of the segmentation fault:

Thread 5 "GDBDebugger" received signal SIGSEGV, Segmentation fault.
[snip]
0x0000000000df0670 in GDBDebugServer::cmd_read_all_registers(gdb_cmd&) ()
(gdb) backtrace
#0  0x0000000000df0670 in GDBDebugServer::cmd_read_all_registers(gdb_cmd&) ()
#1  0x0000000000df1c54 in GDBDebugServer::on_task() ()
#2  0x0000000000dffbc1 in task_stack::task_type<named_thread::start_thread(std::shared_ptr<void> const&)::{lambda()#1}>::invoke() ()
#3  0x0000000000e02baa in thread_ctrl::start(std::shared_ptr<thread_ctrl> const&, task_stack)::{lambda(void*)#1}::_FUN(void*) ()
[snip]

which corresponds to one of the first invoked commands

bool GDBDebugServer::cmd_read_all_registers(gdb_cmd & cmd)
{
std::string result;
select_thread(general_ops_thread_id);
auto th = selected_thread.lock();
if (th->id_type() == 1) {

@@ -239,8 +239,10 @@ void Emulator::Init()
fs::create_path(dev_usb);

#ifdef WITH_GDB_DEBUGGER
fxm::make<GDBDebugServer>();
// TODO: using legacy call to logger -- should be switched to log::GENERAL.SUCCESS(...)?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using LOG_SUCCESS is fine

@@ -338,6 +338,7 @@ bool GDBDebugServer::select_thread(u64 id)
selected_thread = ppu.ptr;
return true;
}
gdbDebugServer.warning("Unable to select thread! Is the emulator running?" HERE);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need in "HERE"

@AniLeo
Copy link
Member

AniLeo commented Jun 1, 2018

Needs rebasing and squashing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants