This is the mail archive of the gdb-prs@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]

[Bug server/16255] gdbserver cannot attach to a second inferior that is multi-threaded


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.


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