1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:27:44 +00:00

LibDebug: Add ContinueBreakAtSyscall decision

When the user of the DebugSession uses this decision, the debugged
program will be continued until it is either stopped by a singal (e.g
as a reuslt of a breakpoint), or enters a syscall.
This commit is contained in:
Itamar 2020-04-15 21:03:22 +03:00 committed by Andreas Kling
parent f4418361c4
commit af338a34c0
2 changed files with 58 additions and 23 deletions

View file

@ -184,14 +184,26 @@ void DebugSession::set_registers(const PtraceRegisters& regs)
}
}
void DebugSession::continue_debugee()
void DebugSession::continue_debugee(ContinueType type)
{
if (ptrace(PT_CONTINUE, m_debugee_pid, 0, 0) < 0) {
int command = (type == ContinueType::FreeRun) ? PT_CONTINUE : PT_SYSCALL;
if (ptrace(command, m_debugee_pid, 0, 0) < 0) {
perror("continue");
ASSERT_NOT_REACHED();
}
}
int DebugSession::continue_debugee_and_wait(ContinueType type)
{
continue_debugee(type);
int wstatus = 0;
if (waitpid(m_debugee_pid, &wstatus, WSTOPPED | WEXITED) != m_debugee_pid) {
perror("waitpid");
ASSERT_NOT_REACHED();
}
return wstatus;
}
void* DebugSession::single_step()
{
auto regs = get_registers();