Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 28 Jun 2004 05:09:42 GMT
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 55977 for review
Message-ID:  <200406280509.i5S59gTL035386@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);
 		}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200406280509.i5S59gTL035386>