mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-25 14:05:15 +00:00
LibDebug: Fix crash when debugging short lived programs
This commit is contained in:
parent
1851da9c93
commit
66f9a2d9ec
Notes:
sideshowbarker
2024-07-19 00:55:27 +09:00
Author: https://github.com/ccapitalK Commit: https://github.com/SerenityOS/serenity/commit/66f9a2d9ecb Pull-request: https://github.com/SerenityOS/serenity/pull/4374 Issue: https://github.com/SerenityOS/serenity/issues/4327 Reviewed-by: https://github.com/BenWiederhake
1 changed files with 5 additions and 10 deletions
|
@ -64,6 +64,11 @@ OwnPtr<DebugSession> DebugSession::exec_and_attach(const String& command)
|
||||||
{
|
{
|
||||||
int pid = fork();
|
int pid = fork();
|
||||||
|
|
||||||
|
if (pid < 0) {
|
||||||
|
perror("fork");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
if (!pid) {
|
if (!pid) {
|
||||||
if (ptrace(PT_TRACE_ME, 0, 0, 0) < 0) {
|
if (ptrace(PT_TRACE_ME, 0, 0, 0) < 0) {
|
||||||
perror("PT_TRACE_ME");
|
perror("PT_TRACE_ME");
|
||||||
|
@ -93,16 +98,6 @@ OwnPtr<DebugSession> DebugSession::exec_and_attach(const String& command)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (waitpid(pid, nullptr, WSTOPPED) != pid) {
|
|
||||||
perror("waitpid");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ptrace(PT_CONTINUE, pid, 0, 0) < 0) {
|
|
||||||
perror("continue");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We want to continue until the exit from the 'execve' sycsall.
|
// We want to continue until the exit from the 'execve' sycsall.
|
||||||
// This ensures that when we start debugging the process
|
// This ensures that when we start debugging the process
|
||||||
// it executes the target image, and not the forked image of the tracing process.
|
// it executes the target image, and not the forked image of the tracing process.
|
||||||
|
|
Loading…
Add table
Reference in a new issue