This is the mail archive of the
gdb-patches@sourceware.cygnus.com
mailing list for the GDB project.
Re: Make threads architecture-independent on Linux
This patch is turning out to be quite helpful for us. Thanks!
Shouldn't gdb/config/sparc/nm-linux.h #include "nm-linux.h", too? If
it does, can't we delete the #inclusion of solib.h?
Also, we don't need to test __STDC__, as config/nm-linux.h does. GDB
only compiles under ANSI C now. Besides, Linux has only ever had ANSI
C compilers. :)
> 1999-11-08 Jim Kingdon <http://developer.redhat.com/>
>
> Enable threads for all linux architectures:
> * config/nm-linux.h: New file.
> * config/{alpha,i386,m68k,sparc}/nm-linux.h: Use it.
> * config/tm-linux.h: New file.
> * config/{i386,m68k,sparc}/tm-linux.h,
> config/alpha/tm-alphalinux.h: Use it.
> * config/{m68k,sparc}/linux.mh, config/alpha/alpha-linux.mh:
> Add linux-thread.o.
>
> --- /dev/null Tue May 5 16:32:27 1998
> +++ gdb/config/nm-linux.h Mon Nov 1 15:33:51 1999
> @@ -0,0 +1,52 @@
> +/* Native support for GNU/Linux, for GDB, the GNU debugger.
> + Copyright (C) 1999
> + Free Software Foundation, Inc.
> +
> + This file is part of GDB.
> +
> + This program is free software; you can redistribute it and/or modify
> + it under the terms of the GNU General Public License as published by
> + the Free Software Foundation; either version 2 of the License, or
> + (at your option) any later version.
> +
> + This program is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + GNU General Public License for more details.
> +
> + You should have received a copy of the GNU General Public License
> + along with this program; if not, write to the Free Software
> + Foundation, Inc., 59 Temple Place - Suite 330,
> + Boston, MA 02111-1307, USA. */
> +
> +/* Linux is svr4ish but not that much */
> +#undef USE_PROC_FS
> +
> +/* Tell gdb that we can attach and detach other processes */
> +#define ATTACH_DETACH
> +
> +/* We define this if link.h is available, because with ELF we use SVR4 style
> + shared libraries. */
> +
> +#ifdef HAVE_LINK_H
> +#define SVR4_SHARED_LIBS
> +#include "solib.h" /* Support for shared libraries. */
> +#endif
> +
> +/* Support for the glibc linuxthreads package. */
> +
> +#ifdef __STDC__
> +struct objfile;
> +#endif
> +
> +extern void
> +linuxthreads_new_objfile PARAMS ((struct objfile *objfile));
> +#define target_new_objfile(OBJFILE) linuxthreads_new_objfile (OBJFILE)
> +
> +extern char *
> +linuxthreads_pid_to_str PARAMS ((int pid));
> +#define target_pid_to_str(PID) linuxthreads_pid_to_str (PID)
> +
> +extern int
> +linuxthreads_prepare_to_proceed PARAMS ((int step));
> +#define PREPARE_TO_PROCEED(select_it) linuxthreads_prepare_to_proceed (1)
> Index: gdb/config/alpha/nm-linux.h
> ===================================================================
> RCS file: /cvs/gdb/gdb/gdb/config/alpha/nm-linux.h,v
> retrieving revision 1.1.1.3
> diff -u -r1.1.1.3 nm-linux.h
> --- gdb/config/alpha/nm-linux.h 1999/07/07 20:11:53 1.1.1.3
> +++ gdb/config/alpha/nm-linux.h 1999/11/08 23:09:59
> @@ -18,6 +18,8 @@
> Foundation, Inc., 59 Temple Place - Suite 330,
> Boston, MA 02111-1307, USA. */
>
> +#include "nm-linux.h"
> +
> /* Figure out where the longjmp will land. We expect that we have just entered
> longjmp and haven't yet setup the stack frame, so the args are still in the
> argument regs. A0_REGNUM points at the jmp_buf structure from which we
> @@ -28,13 +30,12 @@
> extern int
> get_longjmp_target PARAMS ((CORE_ADDR *));
>
> -/* Tell gdb that we can attach and detach other processes */
> -#define ATTACH_DETACH
> -
> /* ptrace register ``addresses'' are absolute. */
>
> #define U_REGS_OFFSET 0
>
> +/* FIXME: This is probably true, or should be, on all Linux ports.
> + IA64? Sparc64? */
> #define PTRACE_ARG3_TYPE long
>
> /* ptrace transfers longs, the ptrace man page is lying. */
> @@ -51,10 +52,7 @@
>
> /* Support for shared libraries. */
>
> -#include "solib.h"
> -
> #ifdef __ELF__
> -#define SVR4_SHARED_LIBS
> #define TARGET_ELF64
> #endif
>
> @@ -65,3 +63,4 @@
> /* Given a pointer to either a gregset_t or fpregset_t, return a
> pointer to the first register. */
> #define ALPHA_REGSET_BASE(regsetp) ((long *) (regsetp))
> +
> Index: gdb/config/i386/nm-linux.h
> ===================================================================
> RCS file: /cvs/gdb/gdb/gdb/config/i386/nm-linux.h,v
> retrieving revision 1.1.1.3
> diff -u -r1.1.1.3 nm-linux.h
> --- gdb/config/i386/nm-linux.h 1999/09/08 23:59:52 1.1.1.3
> +++ gdb/config/i386/nm-linux.h 1999/11/08 23:09:59
> @@ -23,14 +23,12 @@
> #define NM_LINUX_H
>
> #include "i386/nm-i386v.h"
> +#include "nm-linux.h"
>
> /* Return sizeof user struct to callers in less machine dependent routines */
>
> #define KERNEL_U_SIZE kernel_u_size()
> extern int kernel_u_size PARAMS ((void));
> -
> -/* Tell gdb that we can attach and detach other processes */
> -#define ATTACH_DETACH
>
> #define U_REGS_OFFSET 0
>
> Index: gdb/config/m68k/nm-linux.h
> ===================================================================
> RCS file: /cvs/gdb/gdb/gdb/config/m68k/nm-linux.h,v
> retrieving revision 1.1.1.2
> diff -u -r1.1.1.2 nm-linux.h
> --- gdb/config/m68k/nm-linux.h 1999/07/07 20:14:04 1.1.1.2
> +++ gdb/config/m68k/nm-linux.h 1999/11/08 23:10:00
> @@ -21,23 +21,14 @@
> #ifndef NM_LINUX_H
> #define NM_LINUX_H
>
> +#include "nm-linux.h"
> +
> /* Return sizeof user struct to callers in less machine dependent routines */
>
> #define KERNEL_U_SIZE kernel_u_size()
> extern int kernel_u_size PARAMS ((void));
>
> -/* Tell gdb that we can attach and detach other processes */
> -#define ATTACH_DETACH
> -
> #define U_REGS_OFFSET 0
> -
> -/* We define this if link.h is available, because with ELF we use SVR4 style
> - shared libraries. */
> -
> -#ifdef HAVE_LINK_H
> -#define SVR4_SHARED_LIBS
> -#include "solib.h" /* Support for shared libraries. */
> -#endif
>
> #define REGISTER_U_ADDR(addr, blockend, regno) \
> (addr) = m68k_linux_register_u_addr ((blockend),(regno));
> Index: gdb/config/sparc/nm-linux.h
> ===================================================================
> RCS file: /cvs/gdb/gdb/gdb/config/sparc/nm-linux.h,v
> retrieving revision 1.1.1.2
> diff -u -r1.1.1.2 nm-linux.h
> --- gdb/config/sparc/nm-linux.h 1999/07/07 20:17:01 1.1.1.2
> +++ gdb/config/sparc/nm-linux.h 1999/11/08 23:10:00
> @@ -27,6 +27,3 @@
>
> #define KERNEL_U_SIZE kernel_u_size()
> extern int kernel_u_size PARAMS ((void));
> -
> -/* Linux is svr4ish but not that much */
> -#undef USE_PROC_FS
>
>
> Index: sparc/tm-linux.h
> ===================================================================
> RCS file: /cvs/gdb/gdb/gdb/config/sparc/tm-linux.h,v
> retrieving revision 1.1.1.2
> diff -u -r1.1.1.2 tm-linux.h
> --- tm-linux.h 1999/07/07 20:17:06 1.1.1.2
> +++ gdb/config/sparc/tm-linux.h 1999/11/12 13:35:58
> @@ -25,6 +25,6 @@
>
> #define SIGCONTEXT_PC_OFFSET 12
>
> -#include "tm-sysv4.h"
> +#include "tm-linux.h"
>
> #endif /* TM_SPARCLINUX_H */
> Index: m68k/tm-linux.h
> ===================================================================
> RCS file: /cvs/gdb/gdb/gdb/config/m68k/tm-linux.h,v
> retrieving revision 1.1.1.2
> diff -u -r1.1.1.2 tm-linux.h
> --- tm-linux.h 1999/07/07 20:14:22 1.1.1.2
> +++ gdb/config/m68k/tm-linux.h 1999/11/12 13:36:01
> @@ -72,7 +72,7 @@
> } \
> }
>
> -#include "tm-sysv4.h"
> +#include "tm-linux.h"
> #include "m68k/tm-m68k.h"
>
> /* Extract from an array REGBUF containing the (raw) register state
> Index: i386/tm-linux.h
> ===================================================================
> RCS file: /cvs/gdb/gdb/gdb/config/i386/tm-linux.h,v
> retrieving revision 1.1.1.7
> diff -u -r1.1.1.7 tm-linux.h
> --- tm-linux.h 1999/11/02 04:44:22 1.1.1.7
> +++ gdb/config/i386/tm-linux.h 1999/11/12 13:36:03
> @@ -28,6 +28,7 @@
> #endif
>
> #include "i386/tm-i386.h"
> +#include "tm-linux.h"
>
> /* Size of sigcontext, from <asm/sigcontext.h>. */
> #define LINUX_SIGCONTEXT_SIZE (88)
> @@ -38,10 +39,6 @@
> /* Offset to saved SP in sigcontext, from <asm/sigcontext.h>. */
> #define LINUX_SIGCONTEXT_SP_OFFSET (28)
>
> -/* We need this file for the SOLIB_TRAMPOLINE stuff. */
> -
> -#include "tm-sysv4.h"
> -
> #define LOW_RETURN_REGNUM 0 /* holds low four bytes of result */
> #define HIGH_RETURN_REGNUM 2 /* holds high four bytes of result */
>
> @@ -166,18 +163,6 @@
> : read_memory_integer ((FRAME)->frame + 4, 4)))
>
> extern CORE_ADDR i386_linux_sigtramp_saved_sp PARAMS ((struct frame_info *));
> -
> -/* Some versions of Linux have real-time signal support in the C library, and
> - some don't. We have to include this file to find out. */
> -#include <signal.h>
> -
> -#ifdef __SIGRTMIN
> -#define REALTIME_LO __SIGRTMIN
> -#define REALTIME_HI (__SIGRTMAX + 1)
> -#else
> -#define REALTIME_LO 32
> -#define REALTIME_HI 64
> -#endif
>
> /* When we call a function in a shared library, and the PLT sends us
> into the dynamic linker to find the function's real address, we
> Index: alpha/tm-alphalinux.h
> ===================================================================
> RCS file: /cvs/gdb/gdb/gdb/config/alpha/tm-alphalinux.h,v
> retrieving revision 1.1.1.2
> diff -u -r1.1.1.2 tm-alphalinux.h
> --- tm-alphalinux.h 1999/07/07 20:11:59 1.1.1.2
> +++ gdb/config/alpha/tm-alphalinux.h 1999/11/12 13:36:05
> @@ -75,7 +75,6 @@
> #undef FRAME_PAST_SIGTRAMP_FRAME
> #define FRAME_PAST_SIGTRAMP_FRAME(frame, pc) (0)
>
> -/* We need this for the SOLIB_TRAMPOLINE stuff. */
> -#include "tm-sysv4.h"
> +#include "tm-linux.h"
>
> #endif /* TM_LINUXALPHA_H */
> --- /dev/null Tue May 5 16:32:27 1998
> +++ gdb/config/tm-linux.h Thu Nov 11 21:51:21 1999
> @@ -0,0 +1,36 @@
> +/* Native support for GNU/Linux, for GDB, the GNU debugger.
> + Copyright (C) 1999
> + Free Software Foundation, Inc.
> +
> + This file is part of GDB.
> +
> + This program is free software; you can redistribute it and/or modify
> + it under the terms of the GNU General Public License as published by
> + the Free Software Foundation; either version 2 of the License, or
> + (at your option) any later version.
> +
> + This program is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + GNU General Public License for more details.
> +
> + You should have received a copy of the GNU General Public License
> + along with this program; if not, write to the Free Software
> + Foundation, Inc., 59 Temple Place - Suite 330,
> + Boston, MA 02111-1307, USA. */
> +
> +/* Some versions of Linux have real-time signal support in the C library, and
> + some don't. We have to include this file to find out. */
> +#include <signal.h>
> +
> +#ifdef __SIGRTMIN
> +#define REALTIME_LO __SIGRTMIN
> +#define REALTIME_HI (__SIGRTMAX + 1)
> +#else
> +#define REALTIME_LO 32
> +#define REALTIME_HI 64
> +#endif
> +
> +/* We need this file for the SOLIB_TRAMPOLINE stuff. */
> +
> +#include "tm-sysv4.h"
> Index: gdb/config/alpha/alpha-linux.mh
> ===================================================================
> RCS file: /cvs/gdb/gdb/gdb/config/alpha/alpha-linux.mh,v
> retrieving revision 1.1.1.1
> diff -u -r1.1.1.1 alpha-linux.mh
> --- alpha-linux.mh 1999/04/16 01:34:14 1.1.1.1
> +++ gdb/config/alpha/alpha-linux.mh 1999/11/12 17:54:12
> @@ -3,7 +3,7 @@
> XM_FILE= xm-alphalinux.h
> NAT_FILE= nm-linux.h
> NATDEPFILES= infptrace.o inftarg.o corelow.o core-regset.o alpha-nat.o \
> - fork-child.o solib.o
> + fork-child.o solib.o linux-thread.o
>
> MMALLOC =
> MMALLOC_CFLAGS = -DNO_MMALLOC
> Index: gdb/config/sparc/linux.mh
> ===================================================================
> RCS file: /cvs/gdb/gdb/gdb/config/sparc/linux.mh,v
> retrieving revision 1.1.1.1
> diff -u -r1.1.1.1 linux.mh
> --- linux.mh 1999/04/16 01:34:25 1.1.1.1
> +++ gdb/config/sparc/linux.mh 1999/11/12 17:54:12
> @@ -2,6 +2,7 @@
> XDEPFILES= ser-tcp.o
> XM_FILE= xm-linux.h
> NAT_FILE= nm-linux.h
> -NATDEPFILES= fork-child.o infptrace.o inftarg.o corelow.o sparc-nat.o
> +NATDEPFILES= fork-child.o infptrace.o inftarg.o corelow.o sparc-nat.o \
> + linux-thread.o
> HOST_IPC=-DBSD_IPC
> GDBSERVER_DEPFILES= low-sparc.o
> Index: gdb/config/m68k/linux.mh
> ===================================================================
> RCS file: /cvs/gdb/gdb/gdb/config/m68k/linux.mh,v
> retrieving revision 1.1.1.1
> diff -u -r1.1.1.1 linux.mh
> --- linux.mh 1999/04/16 01:34:21 1.1.1.1
> +++ gdb/config/m68k/linux.mh 1999/11/12 17:54:12
> @@ -4,6 +4,7 @@
> XDEPFILES= ser-tcp.o
>
> NAT_FILE= nm-linux.h
> -NATDEPFILES= infptrace.o solib.o inftarg.o fork-child.o corelow.o core-aout.o core-regset.o m68klinux-nat.o
> +NATDEPFILES= infptrace.o solib.o inftarg.o fork-child.o \
> + corelow.o core-aout.o core-regset.o m68klinux-nat.o linux-thread.o
>
> GDBSERVER_DEPFILES= low-linux.o
>