[PATCH] Limit the switch_to_thread() calls in startup_inferior()
Simon Marchi
simark@simark.ca
Mon Nov 2 00:34:44 GMT 2020
On 2020-10-14 4:49 a.m., Kamil Rytarowski wrote:
> Do not jump over the threads during the startup unless we encounter
> TARGET_WAITKIND_STOPPED with SIGTRAP or TARGET_WAITKIND_EXECD.
>
> Otherwise whenever a startup-with-shell processes signals on the
> startup stage, it might indicate to switch to a non-existing
> thread or a special-thread number (target lwp=0 on NetBSD means
> that a signal was directed to all threads within a process).
>
> This caused a crash with tcsh on NetBSD, where the tcsh shell
> runs startup detection of the hostname. This action involves
> spwaning a new process through fork.
Kamil, one last question: out of curiosity, could you please share
what's the list of target events reported by your target_wait, while in
startup_inferior, in the problematic case?
You can for apply this hack that will print them:
diff --git a/gdb/nat/fork-inferior.c b/gdb/nat/fork-inferior.c
index 7ba0126871dd..b8fc14ab83ac 100644
--- a/gdb/nat/fork-inferior.c
+++ b/gdb/nat/fork-inferior.c
@@ -485,6 +485,10 @@ startup_inferior (process_stratum_target *proc_target, pid_t pid, int ntraps,
memset (&ws, 0, sizeof (ws));
event_ptid = target_wait (resume_ptid, &ws, 0);
+ void print_target_wait_results (ptid_t waiton_ptid, ptid_t result_ptid,
+ const struct target_waitstatus *ws);
+ print_target_wait_results (resume_ptid, event_ptid, &ws);
+
if (last_waitstatus != NULL)
*last_waitstatus = ws;
if (last_ptid != NULL)
Simon
More information about the Gdb-patches
mailing list