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


> Date: Mon, 27 Feb 2006 14:28:07 -0500
> From: Daniel Jacobowitz <drow@false.org>
> 
> 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.

What does this mean for running GDB on older Linux kernels?  (Dropping
support for older kernels isn't necessarily bad, as long as we still
support Linux 2.4, but we should document it somehow).

> 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.

Cool!

> 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.

That isn't necessarily a bad thing; inf_ttrace() is also inherently
multi-threaded.  I think the single-threaded/multi-threaded dichotomy
really isn't the right way to view this.  It's more a
kernel-threads/user-level-threads dichotomy.  Of course Linux is
somewhere halfway between this, since it is (still) impossible to ask
the kernel what LWP's belong to a particular process.

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

I have one request; could you rename set_linux_target() to
linux_nat_add_target().  I think that better expresses the fact that
this function actually is the Linux native specific version of
add_target.

> 2006-02-27  Daniel Jacobowitz  <dan@codesourcery.com>
> 
> 	* linux-nat.c (linux_ops_saved): New.
> 	(super_mourn_inferior, kill_inferior, threaded, linux_nat_ops)
> 	(child_mourn_inferior, child_wait, linux_nat_create_inferior)
> 	(linux_nat_fetch_registers, linux_nat_store_registers)
> 	(linux_nat_child_post_startup_inferior, init_linux_nat_ops): Delete.
> 	(init_lwp_list): Don't set threaded.
> 	(add_lwp): Don't modify threaded.
> 	(delete_lwp): Don't mention non-threaded mode.
> 	(linux_nat_switch_fork): New.
> 	(linux_nat_attach): Update inferior_ptid.
> 	(linux_nat_wait): Handle num_lwps == 0 at entry.  Don't check
> 	threaded flag.
> 	(linux_nat_kill): Handle pending forks and saved forks.
> 	(linux_nat_mourn_inferior): Handle saved forks.
> 	(linux_nat_pid_to_str): Don't use the LWP form when there is
> 	only one thread.
> 	(linux_target): Don't set to_wait, to_kill, or to_mourn_inferior.
> 	(set_linux_target): New.
> 	(_initialize_linux_nat): Don't initialize the linux native target
> 	here.
> 	* linux-nat.h (set_linux_target, linux_nat_switch_fork): New
> 	prototypes.
> 	* linux-fork.c: Include "linux-nat.h".
> 	(add_fork): Update initial PID.
> 	(fork_load_infrun_state): Call linux_nat_switch_fork.
> 	* Makefile.in (linux-fork.o): Update.
> 
> 	* alpha-linux-nat.c (_initialize_alpha_linux_nat): Use
> 	set_linux_target instead of add_target.
> 	* amd64-linux-nat.c (_initialize_amd64_linux_nat): Likewise.
> 	* arm-linux-nat.c (_initialize_arm_linux_nat): Likewise.
> 	* hppa-linux-nat.c (_initialize_hppa_linux_nat): Likewise.
> 	* ia64-linux-nat.c (_initialize_ia64_linux_nat): Likewise.
> 	* i386-linux-nat.c (_initialize_i386_linux_nat): Likewise.
> 	* m32r-linux-nat.c (_initialize_m32r_linux_nat): Likewise.
> 	* m68klinux-nat.c (_initialize_m68k_linux_nat): Likewise.
> 	* mips-linux-nat.c (_initialize_mips_linux_nat): Likewise.
> 	* ppc-linux-nat.c (_initialize_ppc_linux_nat): Likewise.
> 	* s390-nat.c (_initialize_s390_nat): Likewise.
> 	* sparc-linux-nat.c (_initialize_sparc_linux_nat): Likewise.
> 	* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Likewise.


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