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

Re: accumulated Solaris/x86 patch


Nick Duffek wrote:
> 
> This patch is an accumulation of Solaris/x86 fixes by Michael Snyder, plus
> a fix by me to allow compilation on Solaris 7.
> 
> No regressions are evident on i386-pc-solaris2.7, sparc-sun-solaris2.6, or
> sparc-sun-solaris2.5.1.
> 
> Comments welcome,

Nick, thanks for doing these.
One comment, I think I later found that using 18 bits for the
process ID and 13 for the thread ID caused problems with 
multi-threaded core files.  Probably need to add a testsuite.
But go ahead and check it in this way (modulo comments from 
others), and if we verify that problem we'll back out that
part of the change.

				Michael

> Nick Duffek
> nsd@cygnus.com
> 
> [patch follows, excluding regenerated configure script]
> 
> Index: configure.in
> ===================================================================
> RCS file: /cvs/src/src/gdb/configure.in,v
> retrieving revision 1.15
> diff -u -r1.15 configure.in
> --- configure.in        2000/04/04 02:08:52     1.15
> +++ configure.in        2000/04/04 02:16:53
> @@ -88,6 +88,14 @@
> 
>  AC_HEADER_STDC
> 
> +dnl Solaris 7 needs _MSE_INT_H defined to avoid a clash between <widec.h>
> +dnl and <wchar.h> that causes AC_CHECK_HEADERS to think <curses.h> doesn't
> +dnl exist.
> +
> +case $host_os in solaris2.7) case "$GCC" in yes)
> +    AC_DEFINE(_MSE_INT_H)
> +esac; esac
> +
>  AC_CHECK_HEADERS(ctype.h curses.h endian.h link.h thread_db.h proc_service.h \
>         memory.h objlist.h ptrace.h sgtty.h stddef.h stdlib.h \
>         string.h sys/procfs.h sys/ptrace.h sys/reg.h stdint.h \
> @@ -176,10 +184,7 @@
>    *-*-unixware* | *-*-sysv4.2* | *-*-sysv5*)
>        AC_DEFINE(NEW_PROC_API)
>        ;;
> -  # FIXME: we would like to define NEW_PROC_API for all versions of
> -  # Solaris from 2.6 on... but it isn't quite working yet.  Seems
> -  # to work on sparc 2.6, so let's try it out there.
> -  sparc-sun-solaris2.6)
> +  *-*-solaris2.[678])
>        AC_DEFINE(NEW_PROC_API)
>        ;;
>    esac
> Index: acconfig.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/acconfig.h,v
> retrieving revision 1.3
> diff -u -r1.3 acconfig.h
> --- acconfig.h  2000/03/28 00:03:57     1.3
> +++ acconfig.h  2000/04/04 02:16:53
> @@ -1,3 +1,6 @@
> +/* Define if compiling on Solaris 7. */
> +#undef _MSE_INT_H
> +
>  /* Define if pstatus_t type is available */
>  #undef HAVE_PSTATUS_T
> 
> Index: config.in
> ===================================================================
> RCS file: /cvs/src/src/gdb/config.in,v
> retrieving revision 1.5
> diff -u -r1.5 config.in
> --- config.in   2000/03/28 00:03:57     1.5
> +++ config.in   2000/04/04 02:16:53
> @@ -59,6 +59,9 @@
>  /* Define if you have the ANSI C header files.  */
>  #undef STDC_HEADERS
> 
> +/* Define if compiling on Solaris 7. */
> +#undef _MSE_INT_H
> +
>  /* Define if you want to use new multi-fd /proc interface
>     (replaces HAVE_MULTIPLE_PROC_FDS as well as other macros). */
>  #undef NEW_PROC_API
> Index: procfs.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/procfs.c,v
> retrieving revision 1.4
> diff -u -r1.4 procfs.c
> --- procfs.c    2000/03/28 19:02:47     1.4
> +++ procfs.c    2000/04/04 02:16:59
> @@ -5254,3 +5254,20 @@
>    else
>      return -1;
>  }
> +
> +int
> +procfs_get_pid_fd (pid)
> +     int pid;
> +{
> +  procinfo *pi;
> +
> +  if (pid == -1 && inferior_pid != 0)
> +    pi = find_procinfo (PIDGET (inferior_pid), 0);
> +  else
> +    pi = find_procinfo (PIDGET (pid), 0);
> +
> +  if (pi)
> +    return pi->ctl_fd;
> +  else
> +    return -1;
> +}
> Index: sol-thread.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/sol-thread.c,v
> retrieving revision 1.3
> diff -u -r1.3 sol-thread.c
> --- sol-thread.c        2000/03/23 21:44:50     1.3
> +++ sol-thread.c        2000/04/04 02:17:01
> @@ -122,14 +122,26 @@
>  /* Default definitions: These must be defined in tm.h
>     if they are to be shared with a process module such as procfs.  */
> 
> -#define THREAD_FLAG            0x80000000
> -#define is_thread(ARG)         (((ARG) & THREAD_FLAG) != 0)
> -#define is_lwp(ARG)            (((ARG) & THREAD_FLAG) == 0)
> -#define GET_LWP(PID)           TIDGET (PID)
> -#define GET_THREAD(PID)        (((PID) >> 16) & 0x7fff)
> -#define BUILD_LWP(TID, PID)    ((TID) << 16 | (PID))
> +#ifndef PIDGET
> +#define PIDGET(PID)            (((PID) & 0xffff))
> +#endif
> +
> +#ifndef TIDGET
> +#define TIDGET(PID)            (((PID) & 0x7fffffff) >> 16)
> +#endif
> +
> +#ifndef MERGEPID
> +#define MERGEPID(PID, TID)     (((PID) & 0xffff) | ((TID) << 16))
> +#endif
> +
> +#define THREAD_FLAG            0x80000000
> +#define is_thread(ARG)         (((ARG) & THREAD_FLAG) != 0)
> +#define is_lwp(ARG)            (((ARG) & THREAD_FLAG) == 0)
> +#define GET_LWP(PID)           TIDGET (PID)
> +#define GET_THREAD(PID)                TIDGET (PID)
> +#define BUILD_LWP(TID, PID)    MERGEPID (PID, TID)
> 
> -#define BUILD_THREAD(THREAD_ID, PID) (THREAD_FLAG | BUILD_LWP (THREAD_ID, PID))
> +#define BUILD_THREAD(TID, PID) (MERGEPID (PID, TID) | THREAD_FLAG)
> 
>  /* Pointers to routines from lithread_db resolved by dlopen() */
> 
> @@ -1327,6 +1339,12 @@
>    /* NOTE: only used on Solaris, therefore OK to refer to procfs.c */
>    extern struct ssd *procfs_find_LDT_entry (int);
>    struct ssd *ret;
> +
> +  /* FIXME: can't I get the process ID from the prochandle or something?
> +   */
> +
> +  if (inferior_pid <= 0 || lwpid <= 0)
> +    return PS_BADLID;
> 
>    ret = procfs_find_LDT_entry (BUILD_LWP (lwpid, PIDGET (inferior_pid)));
>    if (ret)
> Index: config/i386/nm-i386sol2.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/config/i386/nm-i386sol2.h,v
> retrieving revision 1.1.1.5
> diff -u -r1.1.1.5 nm-i386sol2.h
> --- nm-i386sol2.h       1999/11/09 01:23:11     1.1.1.5
> +++ nm-i386sol2.h       2000/04/04 02:17:01
> @@ -20,3 +20,31 @@
> 
>  #include "nm-sysv4.h"
> 
> +#ifdef NEW_PROC_API    /* Solaris 6 and above can do HW watchpoints */
> +
> +#define TARGET_HAS_HARDWARE_WATCHPOINTS
> +
> +/* The man page for proc4 on solaris 6 and 7 says that the system
> +   can support "thousands" of hardware watchpoints, but gives no
> +   method for finding out how many.  So just tell GDB 'yes'.  */
> +#define TARGET_CAN_USE_HARDWARE_WATCHPOINT(TYPE, CNT, OT) 1
> +
> +/* When a hardware watchpoint fires off the PC will be left at the
> +   instruction following the one which caused the watchpoint.
> +   It will *NOT* be necessary for GDB to step over the watchpoint. */
> +#define HAVE_CONTINUABLE_WATCHPOINT
> +
> +extern int procfs_stopped_by_watchpoint PARAMS ((int));
> +#define STOPPED_BY_WATCHPOINT(W) \
> +  procfs_stopped_by_watchpoint(inferior_pid)
> +
> +/* Use these macros for watchpoint insertion/deletion.  */
> +/* type can be 0: write watch, 1: read watch, 2: access watch (read/write) */
> +
> +extern int procfs_set_watchpoint PARAMS ((int, CORE_ADDR, int, int, int));
> +#define target_insert_watchpoint(ADDR, LEN, TYPE) \
> +        procfs_set_watchpoint (inferior_pid, ADDR, LEN, TYPE, 1)
> +#define target_remove_watchpoint(ADDR, LEN, TYPE) \
> +        procfs_set_watchpoint (inferior_pid, ADDR, 0, 0, 0)
> +
> +#endif /* NEW_PROC_API */
> Index: config/i386/tm-i386sol2.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/config/i386/tm-i386sol2.h,v
> retrieving revision 1.2
> diff -u -r1.2 tm-i386sol2.h
> --- tm-i386sol2.h       2000/02/29 13:38:55     1.2
> +++ tm-i386sol2.h       2000/04/04 02:17:01
> @@ -42,9 +42,11 @@
> 
>  #define FAULTED_USE_SIGINFO
> 
> -/* Macros to extract process id and thread id from a composite pid/tid */
> -#define PIDGET(pid) ((pid) & 0xffff)
> -#define TIDGET(pid) (((pid) >> 16) & 0xffff)
> -#define MERGEPID(pid, tid) (((tid) << 16) | (pid))
> +/* Macros to extract process id and thread id from a composite pid/tid.
> +   Allocate lower 19 bits for process id, next 12 bits for thread id, and
> +   one bit for a flag to indicate a user thread vs. a kernel thread.  */
> +#define PIDGET(PID)            (((PID) & 0x3ffff))
> +#define TIDGET(PID)            (((PID) & 0x7fffffff) >> 18)
> +#define MERGEPID(PID, TID)     (((PID) & 0x3ffff) | ((TID) << 18))
> 
>  #endif /* ifndef TM_I386SOL2_H */
> Index: config/sparc/nm-sun4sol2.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/config/sparc/nm-sun4sol2.h,v
> retrieving revision 1.1.1.5
> diff -u -r1.1.1.5 nm-sun4sol2.h
> --- nm-sun4sol2.h       1999/11/09 01:23:12     1.1.1.5
> +++ nm-sun4sol2.h       2000/04/04 02:17:01
> @@ -30,3 +30,31 @@
> 
>  #define PRSVADDR_BROKEN
> 
> +#ifdef NEW_PROC_API    /* Solaris 6 and above can do HW watchpoints */
> +
> +#define TARGET_HAS_HARDWARE_WATCHPOINTS
> +
> +/* The man page for proc4 on solaris 6 and 7 says that the system
> +   can support "thousands" of hardware watchpoints, but gives no
> +   method for finding out how many.  So just tell GDB 'yes'.  */
> +#define TARGET_CAN_USE_HARDWARE_WATCHPOINT(TYPE, CNT, OT) 1
> +
> +/* When a hardware watchpoint fires off the PC will be left at the
> +   instruction following the one which caused the watchpoint.
> +   It will *NOT* be necessary for GDB to step over the watchpoint. */
> +#define HAVE_CONTINUABLE_WATCHPOINT
> +
> +extern int procfs_stopped_by_watchpoint PARAMS ((int));
> +#define STOPPED_BY_WATCHPOINT(W) \
> +  procfs_stopped_by_watchpoint(inferior_pid)
> +
> +/* Use these macros for watchpoint insertion/deletion.  */
> +/* type can be 0: write watch, 1: read watch, 2: access watch (read/write) */
> +
> +extern int procfs_set_watchpoint PARAMS ((int, CORE_ADDR, int, int, int));
> +#define target_insert_watchpoint(ADDR, LEN, TYPE) \
> +        procfs_set_watchpoint (inferior_pid, ADDR, LEN, TYPE, 1)
> +#define target_remove_watchpoint(ADDR, LEN, TYPE) \
> +        procfs_set_watchpoint (inferior_pid, ADDR, 0, 0, 0)
> +
> +#endif /* NEW_PROC_API */
> Index: config/sparc/tm-sun4sol2.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/config/sparc/tm-sun4sol2.h,v
> retrieving revision 1.1.1.5
> diff -u -r1.1.1.5 tm-sun4sol2.h
> --- tm-sun4sol2.h       2000/01/18 00:54:35     1.1.1.5
> +++ tm-sun4sol2.h       2000/04/04 02:17:01
> @@ -22,6 +22,11 @@
>  #include "sparc/tm-sparc.h"
>  #include "tm-sysv4.h"
> 
> +/* With Sol2 it is no longer necessary to enable software single-step,
> +   since the /proc interface can take care of it for us in hardware.  */
> +#undef SOFTWARE_SINGLE_STEP
> +#undef SOFTWARE_SINGLE_STEP_P
> +
>  /* There are two different signal handler trampolines in Solaris2.  */
>  #define IN_SIGTRAMP(pc, name) \
>    ((name) \
> @@ -33,7 +38,7 @@
>     ucbsigvechandler.  */
>  #define SIGCONTEXT_PC_OFFSET 44
> 
> -#if 0                          /* FIXME Setjmp/longjmp are not as well doc'd in SunOS 5.x yet */
> +#if 0  /* FIXME Setjmp/longjmp are not as well doc'd in SunOS 5.x yet */
> 
>  /* Offsets into jmp_buf.  Not defined by Sun, but at least documented in a
>     comment in <machine/setjmp.h>! */
> @@ -76,6 +81,6 @@
>  #define HANDLE_SVR4_EXEC_EMULATORS
> 
>  /* Macros to extract process id and thread id from a composite pid/tid */
> -#define PIDGET(pid) ((pid) & 0xffff)
> -#define TIDGET(pid) (((pid) >> 16) & 0xffff)
> -#define MERGEPID(pid, tid) (((tid) << 16) | (pid))
> +#define PIDGET(PID)            (((PID) & 0x3ffff))
> +#define TIDGET(PID)            (((PID) & 0x7fffffff) >> 18)
> +#define MERGEPID(PID, TID)     (((PID) & 0x3ffff) | ((TID) << 18))
> Index: testsuite/gdb.threads/pthreads.exp
> ===================================================================
> RCS file: /cvs/src/src/gdb/testsuite/gdb.threads/pthreads.exp,v
> retrieving revision 1.1.1.2
> diff -u -r1.1.1.2 pthreads.exp
> --- pthreads.exp        2000/01/11 03:07:37     1.1.1.2
> +++ pthreads.exp        2000/04/04 02:17:01
> @@ -113,7 +113,7 @@
>      # been called 15 times.  This should be plenty of time to allow
>      # every thread to run at least once, since each thread sleeps for
>      # one second between calls to common_routine.
> -    gdb_test "tbreak common_routine if hits == 15" ""
> +    gdb_test "tbreak common_routine if hits >= 15" ""
> 
>      # Start all the threads running again and wait for the inferior
>      # to stop.  Since no other breakpoints are set at this time
> @@ -135,9 +135,16 @@
>      # Check that we stopped when we actually expected to stop, by
>      # verifying that there have been 15 previous hits.
> 
> +    # NOTE: Because of synchronization behavior, it is possible for
> +    # more than one thread to increment "hits" between one breakpoint
> +    # trap and the next.  So stopping after 16 or 17 hits should be
> +    # considered acceptable.
> +
>      send_gdb "p common_routine::hits\n"
>      gdb_expect {
>         -re ".*= 15\r\n$gdb_prompt $" {}
> +       -re ".*= 16\r\n$gdb_prompt $" {}
> +       -re ".*= 17\r\n$gdb_prompt $" {}
>         default {
>             fail "stopped before calling common_routine 15 times"
>             return 0

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