set PTRACE_O_EXITKILL and also cleanup
This commit is contained in:
parent
717650d514
commit
78a84772e4
|
|
@ -53,7 +53,11 @@ struct ElfBugDebugger : ElfBug::Debugger
|
|||
snprintf(path, sizeof(path), "/proc/%d/maps", mProcess->pid);
|
||||
FILE* f = fopen(path, "r");
|
||||
if(!f)
|
||||
{
|
||||
std::lock_guard lock(mapMutex);
|
||||
memoryMap.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
char line[512];
|
||||
while(fgets(line, sizeof(line), f))
|
||||
|
|
|
|||
|
|
@ -74,7 +74,9 @@ namespace ElfBug
|
|||
else
|
||||
{
|
||||
cbExceptionEvent(sig, faultAddr);
|
||||
ptrace(PTRACE_CONT, pid, nullptr, reinterpret_cast<void*>(static_cast<uintptr_t>(sig)));
|
||||
if(ptrace(PTRACE_CONT, pid, nullptr,
|
||||
reinterpret_cast<void*>(static_cast<uintptr_t>(sig))) == -1)
|
||||
cbInternalError("PTRACE_CONT failed: " + std::string(strerror(errno)));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -89,19 +91,6 @@ namespace ElfBug
|
|||
{
|
||||
case PTRACE_EVENT_EXEC:
|
||||
{
|
||||
if(!mSystemBreakpointHit)
|
||||
{
|
||||
mSystemBreakpointHit = true;
|
||||
if(mThread)
|
||||
{
|
||||
mThread->registers.Read();
|
||||
beginPause();
|
||||
cbSystemBreakpoint();
|
||||
if(!pauseAndResume(pid))
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if(ptrace(PTRACE_CONT, pid, nullptr, nullptr) == -1)
|
||||
cbInternalError("PTRACE_CONT failed: " + std::string(strerror(errno)));
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -83,7 +83,8 @@ namespace ElfBug
|
|||
PTRACE_O_TRACESYSGOOD |
|
||||
PTRACE_O_TRACECLONE |
|
||||
PTRACE_O_TRACEEXEC |
|
||||
PTRACE_O_TRACEEXIT) == -1)
|
||||
PTRACE_O_TRACEEXIT |
|
||||
PTRACE_O_EXITKILL) == -1)
|
||||
{
|
||||
cbInternalError("PTRACE_SETOPTIONS failed: " + std::string(strerror(errno)));
|
||||
mIsRunning.store(false, std::memory_order_release);
|
||||
|
|
|
|||
|
|
@ -201,6 +201,7 @@ namespace ElfBug
|
|||
void Debugger::Detach()
|
||||
{
|
||||
// TODO: implement ptrace detach
|
||||
cbInternalError("Detach not implemented");
|
||||
}
|
||||
|
||||
void Debugger::cbCreateProcessEvent(const pid_t pid, const ptr entryPoint) { (void)pid; (void)entryPoint; }
|
||||
|
|
|
|||
Loading…
Reference in New Issue