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

Re: RFC: Unify the GNU/Linux native targets


Daniel Jacobowitz wrote:
A wart I've been meaning to come back to for ages; I have some fixes for
thread debugging in static binaries that would have been quite ugly
without this, so I took a day to do it.

There are two target vectors in the current incarnation of linux-nat.c.  The
one returned by linux_target () and inherited by target-specific files is
used for non-threaded applications; it handles basic operations including
target-specific extensions to them.  The one built in linux_nat_ops
handles clone and can be used with libthread_db, and delegates to the
single-threaded variant for basic tasks.

This is a bit silly :-)  We still need the separation between single and
multi-threaded vectors for the moment, because targets want to override
the single-threaded primitives rather than the complex multi-threaded
layer.  However, that's all we need the single-threaded vector for.  We
don't ever need to _use_ it.

This patch kills most of the single-threaded vector and arranges to
use the multi-threaded version in all cases.  Some duplicated code
goes away, and it is suddenly much easier to switch back and forth
between "threaded" and "non-threaded" debugging.

One oddity: the Linux native target remains at process_stratum even
though it supports threads.  I think this is right; the thread_stratum
gets used for linux-thread-db.c support which delegates to the process
stratum.  If we had arbitrary stacking instead of strata I might
stack the linux multithreaded bits above the linux single-threaded
bits, but I think this is more natural.

Tested on x86_64-pc-linux-gnu. Any comments? Seems like progress?

Depends on my previous linux-fork.c patch, but only trivially.


Daniel, this seems fairly sane, at least with respect to forks. It does touch code that is also touched by my recent patch, though, so merge carefully. ;-)

This, for instance,

+
+  /* First cut -- let's crudely do everything inline.  */
+  if (forks_exist_p ())
+    {
+      linux_fork_killall ();
+      pop_target ();
+      generic_mourn_inferior ();
+      return;
+    }
+
   /* Kill all LWP's ...  */

would want to be modified so as to read something like:

	linux_fork_killall ();
	target_mourn_inferior ();
	return;

(I think...)


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