From owner-p4-projects@FreeBSD.ORG Mon Jun 28 05:09:42 2004 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 9FCD916A4D0; Mon, 28 Jun 2004 05:09:42 +0000 (GMT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7B44A16A4CE for ; Mon, 28 Jun 2004 05:09:42 +0000 (GMT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5BFF543D5A for ; Mon, 28 Jun 2004 05:09:42 +0000 (GMT) (envelope-from marcel@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.11/8.12.11) with ESMTP id i5S59g1h035389 for ; Mon, 28 Jun 2004 05:09:42 GMT (envelope-from marcel@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.11/8.12.11/Submit) id i5S59gTL035386 for perforce@freebsd.org; Mon, 28 Jun 2004 05:09:42 GMT (envelope-from marcel@freebsd.org) Date: Mon, 28 Jun 2004 05:09:42 GMT Message-Id: <200406280509.i5S59gTL035386@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to marcel@freebsd.org using -f From: Marcel Moolenaar To: Perforce Change Reviews Subject: PERFORCE change 55977 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Jun 2004 05:09:43 -0000 http://perforce.freebsd.org/chv.cgi?CH=55977 Change 55977 by marcel@marcel_nfs on 2004/06/28 05:09:21 Drop the backward compatibility logic that I added on HEAD. The problem is simple: For one of the LWPs in the core file we won't have the lwpid and thus have a mismatch between what thread_db.so knows and what the debugger knows. This breaks getting the registers from a core file for one of the LWPs. Yes, if we also save the pid then we can also try that if we are unable to fetch register state for one of the lwpids. This is ugly and does more harm to the future than not having the true PID of the process in the core file. The pid is not important enough and the interface is too specific to debuggers to do much harm, if any. Also note that it's possible, at least in theory, to use different notes and so preserve the original meaning of the NT_PRSTATUS note. For this to work, one needs to dig into BFD (binutils) and find a way to add a note and then have the various ids (pid & lwpid) passed up to GDB. An impossible task, because BFD is severily broken in that respect. I tried and admit defeat... If I come up with another way, this change may not be needed. From the looks of it, I pretty much exchausted all the options. Affected files ... .. //depot/projects/gdb/sys/kern/imgact_elf.c#11 edit Differences ... ==== //depot/projects/gdb/sys/kern/imgact_elf.c#11 (text+ko) ==== @@ -1171,13 +1171,10 @@ sizeof *psinfo); /* - * For backward compatibility, we dump the registers of the current - * thread (as passed to us in td) first and set pr_pid to the PID of - * the process. We then dump the other threads, but with pr_pid set - * to the TID of the thread itself. This has two advantages: - * 1) We preserve the meaning of pr_pid for as much as is possible. - * 2) The debugger will select the current thread as its initial - * "thread", which is likely what we want. + * To have the debugger select the right thread (LWP) as the initial + * thread, we dump the state of the thread passed to us in td first. + * This is the thread that causes the core dump and thus likely to + * be the right thread one wants to have selected in the debugger. */ thr = td; while (thr != NULL) { @@ -1188,7 +1185,7 @@ status->pr_fpregsetsz = sizeof(fpregset_t); status->pr_osreldate = osreldate; status->pr_cursig = p->p_sig; - status->pr_pid = (thr == td) ? p->p_pid : thr->td_tid; + status->pr_pid = thr->td_tid; fill_regs(thr, &status->pr_reg); fill_fpregs(thr, fpregset); }