This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA 4/5] Darwin: fix thread ptid started by fork_inferior


On 2018-08-22 12:10, Pedro Alves wrote:
On 08/22/2018 11:11 AM, Xavier Roirand wrote:


diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
index 96f70cf..9ad4a87 100644
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -344,8 +344,22 @@ darwin_check_new_threads (struct inferior *inf)
 	  pti->gdb_port = new_id;
 	  pti->msg_state = DARWIN_RUNNING;

-	  /* Add the new thread.  */
-	  add_thread_with_info (ptid_t (inf->pid, 0, new_id), pti);
+	  if (old_nbr == 0 && new_ix == 0)
+            {
+	      /* A ptid is created when the inferior is started (see
+                 fork-child.c) with lwp=tid=0.

It looks like this patch was written against an older gdb,
because fork-child.c doesn't add a thread nowadays. For GNU/Linux, it's
inf-ptrace.c that adds the initial thread, but only after
fork_inferior returns (inf_ptrace_target::create_inferior).

But were is that equivalent code in darwin-nat.c?

/me looks.

Answer: it's nowhere.  It does not exist.

So, when then shared fork-child.c was created a while ago,
the add_thread call was moved to darwin-nat.c's target_create_inferior
implementation. But, later on, Simon removed that add_thread call with:

 commit db665f427ca781d631d9e29b1bb744fb11ffcbba
 Author:     Simon Marchi <simon.marchi@ericsson.com>
 AuthorDate: Tue Jun 27 10:55:36 2017 +0200
 Commit:     Simon Marchi <simon.marchi@ericsson.com>
 CommitDate: Tue Jun 27 10:56:53 2017 +0200

    darwin: Do not add a dummy thread

(Weird, I can't find that patch on the list's archives, even
though I received a local copy.)

It sounds to me like you need to reevaluate the patch from
scratch, because its premise is invalid.

Hmm I had not considered that, I did that a while ago and had completely forgotten about it. I'll try to take a look tomorrow, when I have access to the Mac machine. Maybe the spurious SIGTRAP I saw when running was caused by the bug fixed by patch 5/5.

Simon


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]