On Friday 15 August 2008 18:37:31, Daniel Jacobowitz wrote: > On Fri, Aug 08, 2008 at 02:37:57AM +0100, Pedro Alves wrote: > > This patch adjusts the procfs target, so that it registers the main > > thread in GDB's thread table. > > This looks OK to me (took me a couple of tries to convince myself it > was right, but I'm convinced now). I'm sorry to had convinced you wrong. :-( I noticed that before, when we went multi-threaded, we would keep the main process listed with proc->tid == 0, and we would just create a new procinfo for the main lwp, which is a little redundant, but indeed simplifies things. procfs_wait: /* In addition, it's possible that this is the first * new thread we've seen, in which case we may not * have created entries for inferior_ptid yet. */ if (TIDGET (inferior_ptid) != 0) { if (!in_thread_list (inferior_ptid)) add_thread (inferior_ptid); if (find_procinfo (PIDGET (inferior_ptid), TIDGET (inferior_ptid)) == NULL) create_procinfo (PIDGET (inferior_ptid), TIDGET (inferior_ptid)); } If I instead do that right on target_create_inferior and target_attach, we're done -- there's always a thread, and there's always a procinfo for it too. You asked me on IRC if the main lwp is also available in the /proc tree, and although I somehow missed it, indeed it is there. Here, 5642 is a single-threaded app: pedro@opensolaris:~/orlando/gdb/baseline/build-solaris/gdb$ ls /proc/5642/lwp/ 1 Here, 5613 is a multi-threaded app: pedro@opensolaris:~/orlando/gdb/baseline/build-solaris/gdb$ ls /proc/5613/lwp/ 1 2 3 We still have to use the main process procinfo entry, to get at /proc//map /proc//as, because as expected, those are not found under the lwp/1 directory: pedro@opensolaris:~/orlando/gdb/baseline/build-solaris/gdb$ ls /proc/5613/lwp/1/ lwpctl lwpsinfo lwpstatus lwpusage templates xregs My previous path had broken creating core dumps in multi-threaded apps, as iterating over thread procinfo's would miss the main process. Please find attached a new patch. This one's much simpler. Only procfs.c changed. -- Pedro Alves