ladybird/Kernel/Syscalls
Brian Gianforcaro 70f3fa2dd2 Kernel: Set new process name in do_exec before waiting for the tracer
While investigating why gdb is failing when it calls `PT_CONTINUE`
against Serenity I noticed that the names of the programs in the
System Monitor didn't make sense. They were seemingly stale.

After inspecting the kernel code, it became apparent that the sequence
occurs as follows:

    1. Debugger calls `fork()`
    2. The forked child calls `PT_TRACE_ME`
    3. The `PT_TRACE_ME` instructs the forked process to block in the
       kernel waiting for a signal from the tracer on the next call
       to `execve(..)`.
    4. Debugger waits for forked child to spawn and stop, and then it
       calls `PT_ATTACH` followed by `PT_CONTINUE` on the child.
    5. Currently the `PT_CONTINUE` fails because of some other yet to
       be found bug.
    6. The process name is set immediately AFTER we are woken up by
       the `PT_CONTINUE` which never happens in the case I'm debugging.

This chain of events leaves the process suspended, with the name  of
the original (forked) process instead of the name we inherit from
the `execve(..)` call.

To avoid such confusion in the future, we set the new name before we
block waiting for the tracer.
2022-02-19 18:04:32 -08:00
..
access.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
alarm.cpp Kernel: Remove unnecessary includes from Thread.h 2022-01-30 16:21:59 +01:00
anon_create.cpp Kernel: Switch process file descriptor table from spinlock to mutex 2022-01-29 02:17:09 +01:00
beep.cpp Kernel: Add CommandLine option to disable or enable the PC speaker 2022-01-23 00:40:54 +00:00
chdir.cpp Kernel: Convert process file descriptor table to a SpinlockProtected 2022-01-29 02:17:06 +01:00
chmod.cpp Kernel: Convert process file descriptor table to a SpinlockProtected 2022-01-29 02:17:06 +01:00
chown.cpp Kernel: Convert process file descriptor table to a SpinlockProtected 2022-01-29 02:17:06 +01:00
clock.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
debug.cpp Kernel+UE+LibC: Remove unused dbgputch syscall 2021-11-24 22:56:39 +01:00
disown.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
dup2.cpp Kernel: Switch process file descriptor table from spinlock to mutex 2022-01-29 02:17:09 +01:00
emuctl.cpp Kernel: Replace KResult and KResultOr<T> with Error and ErrorOr<T> 2021-11-08 01:10:53 +01:00
execve.cpp Kernel: Set new process name in do_exec before waiting for the tracer 2022-02-19 18:04:32 -08:00
exit.cpp Kernel: Fix a few typos 2021-10-01 00:51:49 +01:00
fcntl.cpp Kernel: Switch process file descriptor table from spinlock to mutex 2022-01-29 02:17:09 +01:00
fork.cpp AK+Kernel: OOM-harden most parts of Trie 2022-02-15 18:03:02 +02:00
fsync.cpp Kernel: Convert process file descriptor table to a SpinlockProtected 2022-01-29 02:17:06 +01:00
ftruncate.cpp Kernel: Convert process file descriptor table to a SpinlockProtected 2022-01-29 02:17:06 +01:00
futex.cpp Kernel: Fix futex syscall return values 2021-11-24 19:44:57 +01:00
get_dir_entries.cpp Kernel: Convert process file descriptor table to a SpinlockProtected 2022-01-29 02:17:06 +01:00
get_stack_bounds.cpp Kernel: Replace KResult and KResultOr<T> with Error and ErrorOr<T> 2021-11-08 01:10:53 +01:00
getrandom.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
getuid.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
hostname.cpp Kernel: Convert hostname to KString 2022-01-13 00:20:08 -08:00
inode_watcher.cpp Kernel: Switch process file descriptor table from spinlock to mutex 2022-01-29 02:17:09 +01:00
ioctl.cpp Kernel: Convert process file descriptor table to a SpinlockProtected 2022-01-29 02:17:06 +01:00
keymap.cpp Kernel: Replace String with NonnullOwnPtr<KString> in sys$getkeymap 2022-01-25 08:06:02 +01:00
kill.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
link.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
lseek.cpp Kernel: Convert process file descriptor table to a SpinlockProtected 2022-01-29 02:17:06 +01:00
mkdir.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
mknod.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
mmap.cpp Kernel: Use try_make_weak_ptr() instead of make_weak_ptr() 2022-02-13 23:02:57 +01:00
mount.cpp Kernel: Convert process file descriptor table to a SpinlockProtected 2022-01-29 02:17:06 +01:00
open.cpp Kernel: Robustify and rename Inode bound socket API 2022-02-07 13:02:34 +01:00
perf_event.cpp Kernel: Replace KResult and KResultOr<T> with Error and ErrorOr<T> 2021-11-08 01:10:53 +01:00
pipe.cpp Kernel: Switch process file descriptor table from spinlock to mutex 2022-01-29 02:17:09 +01:00
pledge.cpp Kernel: Use StringView::for_each_split_view() in sys$pledge 2022-02-14 11:35:20 +01:00
poll.cpp Kernel: Only lock process file descriptor table once in sys$poll() 2022-01-29 02:17:12 +01:00
prctl.cpp Kernel: Replace KResult and KResultOr<T> with Error and ErrorOr<T> 2021-11-08 01:10:53 +01:00
process.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
profiling.cpp Kernel: Fixed argument passing for profiling_enable syscall 2022-02-19 11:37:02 +01:00
ptrace.cpp Kernel: Remove unnecessary includes from Thread.h 2022-01-30 16:21:59 +01:00
purge.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
read.cpp Kernel/Profiling: Add profiling to read syscall 2022-02-14 11:38:13 +01:00
readlink.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
realpath.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
rename.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
rmdir.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
sched.cpp Kernel: Remove unnecessary includes from Thread.h 2022-01-30 16:21:59 +01:00
sendfd.cpp Kernel: Switch process file descriptor table from spinlock to mutex 2022-01-29 02:17:09 +01:00
setpgid.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
setuid.cpp Kernel: Fail gracefully due to OOM on HashTable set in sys$setgroups 2022-01-26 02:37:03 +02:00
sigaction.cpp Kernel: Make AddressSpace::find_regions_intersecting OOM-fallible 2022-01-26 02:37:03 +02:00
socket.cpp Kernel: Ensure socket is suitable for writing in sys$sendmsg 2022-02-07 12:21:45 +01:00
stat.cpp Kernel: Convert process file descriptor table to a SpinlockProtected 2022-01-29 02:17:06 +01:00
statvfs.cpp Kernel: Convert process file descriptor table to a SpinlockProtected 2022-01-29 02:17:06 +01:00
sync.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
sysconf.cpp Kernel: Expose maximum argument limit in sysconf 2022-02-13 22:06:54 +02:00
thread.cpp Kernel: Remove unnecessary includes from Thread.h 2022-01-30 16:21:59 +01:00
times.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
ttyname.cpp Kernel: Convert process file descriptor table to a SpinlockProtected 2022-01-29 02:17:06 +01:00
umask.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
uname.cpp Kernel: Fix OOB write in sys$uname 2022-01-13 00:20:08 -08:00
unlink.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
unveil.cpp AK+Kernel: OOM-harden most parts of Trie 2022-02-15 18:03:02 +02:00
utime.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
waitid.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
write.cpp Kernel: Convert process file descriptor table to a SpinlockProtected 2022-01-29 02:17:06 +01:00