From 1f2b4425c4c3b77a65bc1e70fb664d9a92e7ed0d Mon Sep 17 00:00:00 2001 From: Trung Nguyen Date: Fri, 21 Jun 2024 12:09:05 +1000 Subject: [PATCH] kernel/debug: Report new team before resuming it Ensures that the new team has been reported to the debugger before the main thread gets resumed. This allows the debugger to attach to child teams as early as possible. `fork` and `load_image` without `B_WAIT_TILL_LOADED` have always been working as desired. This commit fixes the remaining case of `B_WAIT_TILL_LOADED` by reporting before resuming the thread of `runtime_loader`. Change-Id: I7fd74606801c6ca5335d91c92f3157e6c6e66308 Reviewed-on: https://review.haiku-os.org/c/haiku/+/7797 Haiku-Format: Haiku-format Bot Tested-by: Commit checker robot Reviewed-by: waddlesplash --- src/system/kernel/team.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/system/kernel/team.cpp b/src/system/kernel/team.cpp index 3b2cd0a7dd..9e6584d232 100644 --- a/src/system/kernel/team.cpp +++ b/src/system/kernel/team.cpp @@ -1886,6 +1886,10 @@ load_image_internal(char**& _flatArgs, size_t flatArgsSize, int32 argCount, // more precisely: It's owned by the team's main thread, now. teamReference.Detach(); + // notify the debugger while the main thread is still suspended so that it + // has a chance to attach early to the child. + user_debug_team_created(teamID); + // wait for the loader of the new team to finish its work if ((flags & B_WAIT_TILL_LOADED) != 0) { if (mainThread != NULL) { @@ -1911,9 +1915,6 @@ load_image_internal(char**& _flatArgs, size_t flatArgsSize, int32 argCount, return loadingInfo.result; } - // notify the debugger - user_debug_team_created(teamID); - return thread; err6: