Change to rely on PIDGET etc.
* config/i386/nm-i386sol2.h (TARGET_HAS_WATCHPOINTS,
TARGET_CAN_USE_HARDWARE_WATCHPOINT, HAVE_CONTINUABLE_WATCHPOINT,
STOPPED_BY_WATCHPOINT, target_[insert/remove]_watchpoint):
define. Allow target to use procfs hardware watchpoints.
* config/sparc/nm-sun4sol2.h: ditto.
* config/i386/tm-i386sol2.h (PIDGET, TIDGET, MERGEPID): modify
definitions to use 16 bits for the pid, 15 bits for the tid, and
1 bit for the flag.
* config/sparc/tm-sun4sol2.h: ditto.
(SOFTWARE_SINGLE_STEP, SOFTWARE_SINGLE_STEP_P): undefine.
* testsuite/gdb.threads/pthreads.exp (all_threads_running): Allow
for more than 15 thread increments.
+2000-04-06 Michael Snyder <msnyder@cygnus.com>
+
+ * sol-thread.c (GET_LWP, GET_THREAD, BUILD_LWP, BUILD_THREAD):
+ Change to rely on PIDGET etc.
+ * config/i386/nm-i386sol2.h (TARGET_HAS_WATCHPOINTS,
+ TARGET_CAN_USE_HARDWARE_WATCHPOINT, HAVE_CONTINUABLE_WATCHPOINT,
+ STOPPED_BY_WATCHPOINT, target_[insert/remove]_watchpoint):
+ define. Allow target to use procfs hardware watchpoints.
+ * config/sparc/nm-sun4sol2.h: ditto.
+ * config/i386/tm-i386sol2.h (PIDGET, TIDGET, MERGEPID): modify
+ definitions to use 16 bits for the pid, 15 bits for the tid, and
+ 1 bit for the flag.
+ * config/sparc/tm-sun4sol2.h: ditto.
+ (SOFTWARE_SINGLE_STEP, SOFTWARE_SINGLE_STEP_P): undefine.
+ * testsuite/gdb.threads/pthreads.exp (all_threads_running): Allow
+ for more than 15 thread increments.
+
2000-04-06 Eli Zaretskii <eliz@is.elta.co.il>
* top.c (filename_completer): Set subsequent_name to 1 early on,
/* Native support for i386 running Solaris 2.
Copyright 1998 Free Software Foundation, Inc.
-This file is part of GDB.
+ 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 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.
+ 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. */
+ 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. */
#include "nm-sysv4.h"
-#ifdef HAVE_THREAD_DB_LIB
+#ifdef NEW_PROC_API /* Solaris 6 and above can do HW watchpoints */
-#ifdef __STDC__
-struct objfile;
-#endif
+#define TARGET_HAS_HARDWARE_WATCHPOINTS
-#define target_new_objfile(OBJFILE) sol_thread_new_objfile (OBJFILE)
+/* 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
-void sol_thread_new_objfile PARAMS ((struct objfile *objfile));
+/* 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
-#define FIND_NEW_THREADS sol_find_new_threads
-void sol_find_new_threads PARAMS ((void));
+extern int procfs_stopped_by_watchpoint PARAMS ((int));
+#define STOPPED_BY_WATCHPOINT(W) \
+ procfs_stopped_by_watchpoint(inferior_pid)
-#endif
+/* 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 */
#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 16 bits for process id, next 15 bits for thread id, and
+ one bit for a flag to indicate a user thread vs. a kernel thread. */
+#define PIDGET(PID) (((PID) & 0xffff))
+#define TIDGET(PID) (((PID) & 0x7fffffff) >> 16)
+#define MERGEPID(PID, TID) (((PID) & 0xffff) | ((TID) << 16))
#endif /* ifndef TM_I386SOL2_H */
/* Native-dependent definitions for Sparc running SVR4.
Copyright 1994 Free Software Foundation, Inc.
-This file is part of GDB.
+ 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 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.
+ 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. */
+ 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. */
/* Include the generic SVR4 definitions. */
#define PRSVADDR_BROKEN
-#ifdef HAVE_THREAD_DB_LIB
+#ifdef NEW_PROC_API /* Solaris 6 and above can do HW watchpoints */
-#ifdef __STDC__
-struct objfile;
-#endif
+#define TARGET_HAS_HARDWARE_WATCHPOINTS
-#define target_new_objfile(OBJFILE) sol_thread_new_objfile (OBJFILE)
+/* 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
-void sol_thread_new_objfile PARAMS ((struct objfile *objfile));
+/* 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
-#define FIND_NEW_THREADS sol_find_new_threads
-void sol_find_new_threads PARAMS ((void));
+extern int procfs_stopped_by_watchpoint PARAMS ((int));
+#define STOPPED_BY_WATCHPOINT(W) \
+ procfs_stopped_by_watchpoint(inferior_pid)
-#endif
+/* 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 */
Copyright 1989, 1992, 1993, 1994, 1995, 1997, 1998
Free Software Foundation, Inc.
-This file is part of GDB.
+ 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 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.
+ 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. */
+ 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. */
#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) \
&& (STREQ ("sigacthandler", name) || STREQ ("ucbsigvechandler", name)))
-
+
/* The signal handler gets a pointer to an ucontext as third argument
if it is called from sigacthandler. This is the offset to the saved
PC within it. sparc_frame_saved_pc knows how to deal with
- ucbsigvechandler. */
+ ucbsigvechandler. */
#define SIGCONTEXT_PC_OFFSET 44
#if 0 /* FIXME Setjmp/longjmp are not as well doc'd in SunOS 5.x yet */
get_longjmp_target PARAMS ((CORE_ADDR *));
#define GET_LONGJMP_TARGET(ADDR) get_longjmp_target(ADDR)
-#endif /* 0 */
+#endif /* 0 */
/* The SunPRO compiler puts out 0 instead of the address in N_SO symbols,
and for SunPRO 3.0, N_FUN symbols too. */
#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)
-
-/* Macro to extract carry from given regset. */
-#define PROCFS_GET_CARRY(regset) ((regset)[R_PSR] & PS_FLAG_CARRY)
-
-#ifdef HAVE_THREAD_DB_LIB
-
-extern char *solaris_pid_to_str PARAMS ((int pid));
-#define target_pid_to_str(PID) solaris_pid_to_str (PID)
-
-#else
-
-extern char *procfs_pid_to_str PARAMS ((int pid));
-#define target_pid_to_str(PID) procfs_pid_to_str (PID)
-
-#endif
+#define PIDGET(PID) (((PID) & 0xffff))
+#define TIDGET(PID) (((PID) & 0x7fffffff) >> 16)
+#define MERGEPID(PID, TID) (((PID) & 0xffff) | ((TID) << 16))
/* 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))
+#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() */
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)
{
set target_cflags ""
}
set why_msg "unrecognized error"
-foreach lib {-lpthreads -lpthread} {
+foreach lib {-lpthreads -lpthread -lthread} {
set options "debug"
lappend options "incdir=${objdir}/${subdir}"
lappend options "libs=$lib"
# 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
# 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