This is the mail archive of the
gdb-prs@sourceware.org
mailing list for the GDB project.
[Bug server/16255] gdbserver cannot attach to a second inferior that is multi-threaded
- From: "simon.marchi at polymtl dot ca" <sourceware-bugzilla at sourceware dot org>
- To: gdb-prs at sourceware dot org
- Date: Mon, 31 Mar 2014 18:51:18 +0000
- Subject: [Bug server/16255] gdbserver cannot attach to a second inferior that is multi-threaded
- Auto-submitted: auto-generated
- References: <bug-16255-4717 at http dot sourceware dot org/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=16255
--- Comment #1 from Simon Marchi <simon.marchi at polymtl dot ca> ---
Ok, the problem is that a ptid with a wrong value is built when we attach the
subsequent threads.
See:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=gdb/gdbserver/linux-low.c;hb=HEAD#l673
For the pid field, we use the pid of current_inferior. When attaching to the
second inferior, current_inferior is never set to the newly created inferior,
it still points to the first one. Therefore, ptids of the threads of the second
inferior are created with the pid of the first.
One solution is to temporarily switch current_inferior in linux_attach when
attaching the subsequent threads.
Another would be to change the line
ptid = ptid_build (pid, lwpid, 0);
for
ptid = ptid_build (linux_proc_get_tgid (lwpid), lwpid, 0);
which will go read the pid (tgid) in /proc.
--
You are receiving this mail because:
You are on the CC list for the bug.