1
0
Fork 0

set PTRACE_O_EXITKILL and also cleanup

This commit is contained in:
3rdit 2026-04-16 01:39:33 +01:00
parent 717650d514
commit 78a84772e4
No known key found for this signature in database
GPG Key ID: 7DD8A35AE190E434
4 changed files with 10 additions and 15 deletions

View File

@ -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))

View File

@ -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;

View File

@ -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);

View File

@ -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; }