- binary plugs distfile no longer needed

- sync patches with OpenJDK7 bsd-port repository
- install a usable cacerts
- Remove Interruptible IO support
tested by ian@ william@
This commit is contained in:
kurt 2009-06-10 19:01:09 +00:00
parent 1c65670943
commit b834f77498
54 changed files with 3089 additions and 557 deletions

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.29 2009/05/23 03:03:24 kurt Exp $
# $OpenBSD: Makefile,v 1.30 2009/06/10 19:01:09 kurt Exp $
SHARED_ONLY= Yes
ONLY_FOR_ARCHS= i386 amd64
@ -8,11 +8,10 @@ COMMENT-jre= Java2(TM) SE Runtime Environment v${V} Early Access ${B}
V= 1.7.0.00
B= b59
DISTFILES= openjdk-7-ea-src-${B}-14_may_2009.zip \
jdk-7-icedtea-plugs-1.6b.tar.gz:0 \
jibx_1_1_5.zip:1
jibx_1_1_5.zip:0
PKGNAME= jdk-${V}
PKGNAME-main= jdk-${V}${B}
PKGNAME-jre= jre-${V}${B}
PKGNAME-main= jdk-${V}${B}p0
PKGNAME-jre= jre-${V}${B}p0
CATEGORIES= devel/jdk java
@ -25,8 +24,7 @@ FLAVOR?=
HOMEPAGE= http://openjdk.java.net/
MASTER_SITES= http://www.java.net/download/openjdk/jdk7/promoted/${B}/
MASTER_SITES0= http://www.intricatesoftware.com/distfiles/
MASTER_SITES1= ${MASTER_SITE_SOURCEFORGE:=jibx/}
MASTER_SITES0= ${MASTER_SITE_SOURCEFORGE:=jibx/}
MAINTAINER= Kurt Miller <kurt@openbsd.org>
@ -63,7 +61,6 @@ USE_GMAKE= Yes
MAKE_ENV= ALT_BOOTDIR=${ALT_BOOTDIR} \
ALT_FREETYPE_HEADERS_PATH=${X11BASE}/include \
ALT_FREETYPE_LIB_PATH=${X11BASE}/lib \
ALT_BINARY_PLUGS_PATH=${WRKDIR}/jdk-7-icedtea-plugs \
ALT_JIBX_LIBS_PATH=${WRKDIR}/jibx/lib \
ALT_PACKAGE_PATH=${LOCALBASE} \
ALT_X11_PATH=${X11BASE} \
@ -98,7 +95,14 @@ PKG_ARGS+= -Dclient_vm=1
PKG_ARGS+= -Dclient_vm=0
.endif
COPYDIRS= hotspot/src/os/linux/launcher \
COPYDIRS= hotspot/agent/src/os/linux \
hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/linux \
hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/amd64 \
hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/x86 \
hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/linux \
hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/linux_amd64 \
hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/linux_x86 \
hotspot/src/os/linux/launcher \
hotspot/src/os/linux/vm \
hotspot/src/os_cpu/linux_x86/vm \
hotspot/make/linux \
@ -106,7 +110,8 @@ COPYDIRS= hotspot/src/os/linux/launcher \
jdk/src/linux/doc/man \
jdk/src/linux/doc/man/ja
COPYFILES= corba/make/common/Defs-linux.gmk \
COPYFILES= hotspot/agent/src/share/classes/sun/jvm/hotspot/LinuxVtblAccess.java \
corba/make/common/Defs-linux.gmk \
corba/make/common/shared/Defs-linux.gmk \
jdk/make/com/sun/tools/attach/mapfile-linux \
jdk/make/common/Defs-linux.gmk \
@ -120,10 +125,12 @@ COPYFILES= corba/make/common/Defs-linux.gmk \
jdk/src/solaris/classes/sun/nio/fs/LinuxFileSystemProvider.java \
jdk/src/solaris/classes/sun/nio/fs/LinuxFileSystem.java \
jdk/src/solaris/classes/sun/nio/fs/LinuxFileStore.java \
jdk/src/solaris/classes/sun/nio/fs/LinuxNativeDispatcher.java \
jdk/src/solaris/classes/sun/tools/attach/LinuxAttachProvider.java \
jdk/src/solaris/classes/sun/tools/attach/LinuxVirtualMachine.java \
jdk/src/solaris/hpi/include/largefile_linux.h \
jdk/src/solaris/native/java/net/linux_close.c
jdk/src/solaris/native/java/net/linux_close.c \
jdk/src/solaris/native/sun/nio/fs/LinuxNativeDispatcher.c
# create initial bsd src from linux src (except for threads_solaris.c)
post-extract:
@ -132,7 +139,7 @@ post-extract:
cd ${WRKDIST}/$$d; \
for f in *; do \
if [ -f $$f ]; then \
t=`echo ${WRKDIST}/$$d/$$f | sed 's/linux/bsd/g;'`; \
t=`echo ${WRKDIST}/$$d/$$f | sed 's/linux/bsd/g; s/Linux/Bsd/g'`; \
sed 's/linux/bsd/g; s/Linux/Bsd/g' < $$f > $$t; \
fi; \
done; \
@ -146,6 +153,8 @@ post-extract:
> ${WRKDIST}/jdk/src/solaris/hpi/native_threads/src/threads_bsd.c
@cp ${WRKDIST}/jdk/src/share/lib/security/java.security \
${WRKDIST}/jdk/src/share/lib/security/java.security-openbsd
@rm ${WRKDIST}/hotspot/agent/src/os/bsd/proc_service.h
@cp -f ${FILESDIR}/cacerts ${WRKDIST}/jdk/src/share/lib/security
post-build:
@rm -rf ${JDKIMAGEDIR}/man/ja ${JREIMAGEDIR}/man/ja

BIN
devel/jdk/1.7/files/cacerts Normal file

Binary file not shown.

View File

@ -1,6 +1,6 @@
$OpenBSD: patch-corba_make_common_Defs-bsd_gmk,v 1.2 2009/05/23 03:03:24 kurt Exp $
--- corba/make/common/Defs-bsd.gmk.orig Sat May 16 23:21:11 2009
+++ corba/make/common/Defs-bsd.gmk Mon May 18 08:24:28 2009
$OpenBSD: patch-corba_make_common_Defs-bsd_gmk,v 1.3 2009/06/10 19:01:09 kurt Exp $
--- corba/make/common/Defs-bsd.gmk.orig Sat May 30 11:21:13 2009
+++ corba/make/common/Defs-bsd.gmk Tue Jun 2 10:41:33 2009
@@ -40,18 +40,12 @@
# Get shared JDK settings
include $(BUILDDIR)/common/shared/Defs.gmk
@ -112,16 +112,14 @@ $OpenBSD: patch-corba_make_common_Defs-bsd_gmk,v 1.2 2009/05/23 03:03:24 kurt Ex
override LEX_LIBRARY = -lfl
ifeq ($(STATIC_CXX),true)
override LIBCXX = -Wl,-Bstatic -lstdc++ -lgcc -Wl,-Bdynamic
@@ -281,13 +261,9 @@ override LIBPOSIX4 =
override LIBSOCKET =
@@ -282,12 +262,8 @@ override LIBSOCKET =
override LIBTHREAD =
override MOOT_PRIORITIES = true
-override NO_INTERRUPTIBLE_IO = true
override NO_INTERRUPTIBLE_IO = true
-override OPENWIN_HOME = /usr/X11R6
-ifeq ($(ARCH), amd64)
-override OPENWIN_LIB = $(OPENWIN_HOME)/lib64
-else
+override NO_INTERRUPTIBLE_IO = false
+override OPENWIN_HOME = $(X11_PATH)
override OPENWIN_LIB = $(OPENWIN_HOME)/lib
-endif

View File

@ -1,7 +1,7 @@
$OpenBSD: patch-corba_make_common_shared_Platform_gmk,v 1.3 2009/05/23 03:03:24 kurt Exp $
--- corba/make/common/shared/Platform.gmk.orig Fri May 8 03:29:39 2009
+++ corba/make/common/shared/Platform.gmk Mon May 18 08:24:56 2009
@@ -262,6 +262,85 @@ ifeq ($(SYSTEM_UNAME), Linux)
$OpenBSD: patch-corba_make_common_shared_Platform_gmk,v 1.4 2009/06/10 19:01:09 kurt Exp $
--- corba/make/common/shared/Platform.gmk.orig Thu May 14 03:25:58 2009
+++ corba/make/common/shared/Platform.gmk Wed Jun 3 16:07:27 2009
@@ -262,6 +262,89 @@ ifeq ($(SYSTEM_UNAME), Linux)
MB_OF_MEMORY := $(shell free -m | fgrep Mem: | sed -e 's@\ \ *@ @g' | cut -d' ' -f2)
endif
@ -81,13 +81,17 @@ $OpenBSD: patch-corba_make_common_shared_Platform_gmk,v 1.3 2009/05/23 03:03:24
+ # a fully built workspace.
+ REQUIRED_FREE_SPACE=1500000
+ # How much RAM does this machine have:
+ MB_OF_MEMORY=$(shell sysctl -n hw.physmem | awk '{print int($$NF / 1048576); }' )
+ ifeq ($(OS_VENDOR), OpenBSD)
+ MB_OF_MEMORY=$(shell sysctl -n hw.physmem | awk '{print int($$NF / 1048576); }' )
+ else
+ MB_OF_MEMORY=$(shell (sysctl -n hw.physmem64 2> /dev/null || sysctl -n hw.physmem) | awk '{print int($$NF / 1048576); }' )
+ endif
+endif
+
# Windows with and without CYGWIN will be slightly different
ifeq ($(SYSTEM_UNAME), Windows_NT)
PLATFORM = windows
@@ -373,7 +452,14 @@ endif
@@ -373,7 +456,14 @@ endif
# build machines and adjustments will be made to prevent excessing
# system swapping during the build.
# If we don't know, assume 512. Subtract 128 from MB for VM MAX.
@ -103,7 +107,7 @@ $OpenBSD: patch-corba_make_common_shared_Platform_gmk,v 1.3 2009/05/23 03:03:24
ifneq ($(MB_OF_MEMORY),)
LOW_MEMORY_MACHINE := $(shell \
if [ $(MB_OF_MEMORY) -le 512 ] ; then \
@@ -385,7 +471,7 @@ ifneq ($(MB_OF_MEMORY),)
@@ -385,7 +475,7 @@ ifneq ($(MB_OF_MEMORY),)
if [ $(MB_OF_MEMORY) -le 1024 ] ; then \
expr $(MB_OF_MEMORY) '-' 128 ; \
else \

View File

@ -0,0 +1,32 @@
$OpenBSD: patch-hotspot_agent_make_Makefile,v 1.1 2009/06/10 19:01:09 kurt Exp $
--- hotspot/agent/make/Makefile.orig Tue Jun 2 12:31:31 2009
+++ hotspot/agent/make/Makefile Tue Jun 2 12:31:37 2009
@@ -52,6 +52,9 @@ sun.jvm.hotspot.code \
sun.jvm.hotspot.compiler \
sun.jvm.hotspot.debugger \
sun.jvm.hotspot.debugger.amd64 \
+sun.jvm.hotspot.debugger.bsd \
+sun.jvm.hotspot.debugger.bsd.amd64 \
+sun.jvm.hotspot.debugger.bsd.x86 \
sun.jvm.hotspot.debugger.cdbg \
sun.jvm.hotspot.debugger.cdbg.basic \
sun.jvm.hotspot.debugger.cdbg.basic.amd64 \
@@ -94,6 +97,9 @@ sun.jvm.hotspot.memory \
sun.jvm.hotspot.oops \
sun.jvm.hotspot.runtime \
sun.jvm.hotspot.runtime.amd64 \
+sun.jvm.hotspot.runtime.bsd \
+sun.jvm.hotspot.runtime.bsd_amd64 \
+sun.jvm.hotspot.runtime.bsd_x86 \
sun.jvm.hotspot.runtime.ia64 \
sun.jvm.hotspot.runtime.linux \
sun.jvm.hotspot.runtime.linux_amd64 \
@@ -143,6 +149,8 @@ sun/jvm/hotspot/code/*.java \
sun/jvm/hotspot/compiler/*.java \
sun/jvm/hotspot/debugger/*.java \
sun/jvm/hotspot/debugger/amd64/*.java \
+sun/jvm/hotspot/debugger/bsd/*.java \
+sun/jvm/hotspot/debugger/bsd/x86/*.java \
sun/jvm/hotspot/debugger/cdbg/*.java \
sun/jvm/hotspot/debugger/cdbg/basic/*.java \
sun/jvm/hotspot/debugger/cdbg/basic/amd64/*.java \

View File

@ -0,0 +1,142 @@
$OpenBSD: patch-hotspot_agent_src_os_bsd_BsdDebuggerLocal_c,v 1.1 2009/06/10 19:01:09 kurt Exp $
--- hotspot/agent/src/os/bsd/BsdDebuggerLocal.c.orig Tue Jun 2 12:59:31 2009
+++ hotspot/agent/src/os/bsd/BsdDebuggerLocal.c Tue Jun 2 12:59:42 2009
@@ -22,6 +22,7 @@
*
*/
+#include <stdlib.h>
#include <jni.h>
#include "libproc.h"
@@ -73,7 +74,7 @@ JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_b
(JNIEnv *env, jclass cls) {
jclass listClass;
- if (init_libproc(getenv("LIBSAPROC_DEBUG")) != true) {
+ if (init_libproc(getenv("LIBSAPROC_DEBUG") != NULL) != true) {
THROW_NEW_DEBUGGER_EXCEPTION("can't initialize libproc");
}
@@ -275,7 +276,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_jvm_hotspot_debu
bufPtr = (*env)->GetByteArrayElements(env, array, &isCopy);
CHECK_EXCEPTION_(0);
- err = ps_pdread(get_proc_handle(env, this_obj), (psaddr_t) (uintptr_t)addr, bufPtr, numBytes);
+ err = ps_pread(get_proc_handle(env, this_obj), (psaddr_t) (uintptr_t)addr, bufPtr, numBytes);
(*env)->ReleaseByteArrayElements(env, array, bufPtr, 0);
return (err == PS_OK)? array : 0;
}
@@ -283,11 +284,10 @@ JNIEXPORT jbyteArray JNICALL Java_sun_jvm_hotspot_debu
JNIEXPORT jlongArray JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_getThreadIntegerRegisterSet0
(JNIEnv *env, jobject this_obj, jint lwp_id) {
- struct user_regs_struct gregs;
+ struct reg gregs;
jboolean isCopy;
jlongArray array;
jlong *regs;
- int i;
struct ps_prochandle* ph = get_proc_handle(env, this_obj);
if (get_lwp_regs(ph, lwp_id, &gregs) != true) {
@@ -317,26 +317,27 @@ JNIEXPORT jlongArray JNICALL Java_sun_jvm_hotspot_debu
#ifdef i386
#define REG_INDEX(reg) sun_jvm_hotspot_debugger_x86_X86ThreadContext_##reg
- regs[REG_INDEX(GS)] = (uintptr_t) gregs.xgs;
- regs[REG_INDEX(FS)] = (uintptr_t) gregs.xfs;
- regs[REG_INDEX(ES)] = (uintptr_t) gregs.xes;
- regs[REG_INDEX(DS)] = (uintptr_t) gregs.xds;
- regs[REG_INDEX(EDI)] = (uintptr_t) gregs.edi;
- regs[REG_INDEX(ESI)] = (uintptr_t) gregs.esi;
- regs[REG_INDEX(FP)] = (uintptr_t) gregs.ebp;
- regs[REG_INDEX(SP)] = (uintptr_t) gregs.esp;
- regs[REG_INDEX(EBX)] = (uintptr_t) gregs.ebx;
- regs[REG_INDEX(EDX)] = (uintptr_t) gregs.edx;
- regs[REG_INDEX(ECX)] = (uintptr_t) gregs.ecx;
- regs[REG_INDEX(EAX)] = (uintptr_t) gregs.eax;
- regs[REG_INDEX(PC)] = (uintptr_t) gregs.eip;
- regs[REG_INDEX(CS)] = (uintptr_t) gregs.xcs;
- regs[REG_INDEX(SS)] = (uintptr_t) gregs.xss;
+ regs[REG_INDEX(GS)] = (uintptr_t) gregs.r_gs;
+ regs[REG_INDEX(FS)] = (uintptr_t) gregs.r_fs;
+ regs[REG_INDEX(ES)] = (uintptr_t) gregs.r_es;
+ regs[REG_INDEX(DS)] = (uintptr_t) gregs.r_ds;
+ regs[REG_INDEX(EDI)] = (uintptr_t) gregs.r_edi;
+ regs[REG_INDEX(ESI)] = (uintptr_t) gregs.r_esi;
+ regs[REG_INDEX(FP)] = (uintptr_t) gregs.r_ebp;
+ regs[REG_INDEX(SP)] = (uintptr_t) gregs.r_isp;
+ regs[REG_INDEX(EBX)] = (uintptr_t) gregs.r_ebx;
+ regs[REG_INDEX(EDX)] = (uintptr_t) gregs.r_edx;
+ regs[REG_INDEX(ECX)] = (uintptr_t) gregs.r_ecx;
+ regs[REG_INDEX(EAX)] = (uintptr_t) gregs.r_eax;
+ regs[REG_INDEX(PC)] = (uintptr_t) gregs.r_eip;
+ regs[REG_INDEX(CS)] = (uintptr_t) gregs.r_cs;
+ regs[REG_INDEX(SS)] = (uintptr_t) gregs.r_ss;
#endif /* i386 */
#if ia64
regs = (*env)->GetLongArrayElements(env, array, &isCopy);
+ int i;
for (i = 0; i < NPRGREG; i++ ) {
regs[i] = 0xDEADDEAD;
}
@@ -345,31 +346,31 @@ JNIEXPORT jlongArray JNICALL Java_sun_jvm_hotspot_debu
#ifdef amd64
#define REG_INDEX(reg) sun_jvm_hotspot_debugger_amd64_AMD64ThreadContext_##reg
- regs[REG_INDEX(R15)] = gregs.r15;
- regs[REG_INDEX(R14)] = gregs.r14;
- regs[REG_INDEX(R13)] = gregs.r13;
- regs[REG_INDEX(R12)] = gregs.r12;
- regs[REG_INDEX(RBP)] = gregs.rbp;
- regs[REG_INDEX(RBX)] = gregs.rbx;
- regs[REG_INDEX(R11)] = gregs.r11;
- regs[REG_INDEX(R10)] = gregs.r10;
- regs[REG_INDEX(R9)] = gregs.r9;
- regs[REG_INDEX(R8)] = gregs.r8;
- regs[REG_INDEX(RAX)] = gregs.rax;
- regs[REG_INDEX(RCX)] = gregs.rcx;
- regs[REG_INDEX(RDX)] = gregs.rdx;
- regs[REG_INDEX(RSI)] = gregs.rsi;
- regs[REG_INDEX(RDI)] = gregs.rdi;
- regs[REG_INDEX(RIP)] = gregs.rip;
- regs[REG_INDEX(CS)] = gregs.cs;
- regs[REG_INDEX(RSP)] = gregs.rsp;
- regs[REG_INDEX(SS)] = gregs.ss;
- regs[REG_INDEX(FSBASE)] = gregs.fs_base;
- regs[REG_INDEX(GSBASE)] = gregs.gs_base;
- regs[REG_INDEX(DS)] = gregs.ds;
- regs[REG_INDEX(ES)] = gregs.es;
- regs[REG_INDEX(FS)] = gregs.fs;
- regs[REG_INDEX(GS)] = gregs.gs;
+ regs[REG_INDEX(R15)] = gregs.r_r15;
+ regs[REG_INDEX(R14)] = gregs.r_r14;
+ regs[REG_INDEX(R13)] = gregs.r_r13;
+ regs[REG_INDEX(R12)] = gregs.r_r12;
+ regs[REG_INDEX(RBP)] = gregs.r_rbp;
+ regs[REG_INDEX(RBX)] = gregs.r_rbx;
+ regs[REG_INDEX(R11)] = gregs.r_r11;
+ regs[REG_INDEX(R10)] = gregs.r_r10;
+ regs[REG_INDEX(R9)] = gregs.r_r9;
+ regs[REG_INDEX(R8)] = gregs.r_r8;
+ regs[REG_INDEX(RAX)] = gregs.r_rax;
+ regs[REG_INDEX(RCX)] = gregs.r_rcx;
+ regs[REG_INDEX(RDX)] = gregs.r_rdx;
+ regs[REG_INDEX(RSI)] = gregs.r_rsi;
+ regs[REG_INDEX(RDI)] = gregs.r_rdi;
+ regs[REG_INDEX(RIP)] = gregs.r_rip;
+ regs[REG_INDEX(CS)] = gregs.r_cs;
+ regs[REG_INDEX(RSP)] = gregs.r_rsp;
+ regs[REG_INDEX(SS)] = gregs.r_ss;
+// regs[REG_INDEX(FSBASE)] = gregs.fs_base;
+// regs[REG_INDEX(GSBASE)] = gregs.gs_base;
+// regs[REG_INDEX(DS)] = gregs.ds;
+// regs[REG_INDEX(ES)] = gregs.es;
+// regs[REG_INDEX(FS)] = gregs.fs;
+// regs[REG_INDEX(GS)] = gregs.gs;
#endif /* amd64 */

View File

@ -0,0 +1,81 @@
$OpenBSD: patch-hotspot_agent_src_os_bsd_Makefile,v 1.1 2009/06/10 19:01:09 kurt Exp $
--- hotspot/agent/src/os/bsd/Makefile.orig Tue Jun 2 13:00:17 2009
+++ hotspot/agent/src/os/bsd/Makefile Tue Jun 2 13:01:26 2009
@@ -19,10 +19,10 @@
# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.
-#
+#
#
-ARCH := $(shell if ([ `uname -m` = "ia64" ]) ; then echo ia64 ; elif ([ `uname -m` = "x86_64" ]) ; then echo amd64; elif ([ `uname -m` = "sparc64" ]) ; then echo sparc; else echo i386 ; fi )
+ARCH := $(shell if ([ `uname -m` = "ia64" ]) ; then echo ia64 ; elif ([ `uname -m` = "amd64" ]) ; then echo amd64; elif ([ `uname -m` = "sparc64" ]) ; then echo sparc; else echo i386 ; fi )
GCC = gcc
JAVAH = ${JAVA_HOME}/bin/javah
@@ -32,25 +32,25 @@ SOURCES = salibelf.c \
libproc_impl.c \
ps_proc.c \
ps_core.c \
- BsdDebuggerLocal.c
+ hsearch_r.c \
+ BsdDebuggerLocal.c
-INCLUDES = -I${JAVA_HOME}/include -I${JAVA_HOME}/include/bsd
+INCLUDES = -I${JAVA_HOME}/include -I${JAVA_HOME}/include/$(shell uname -s | tr "[:upper:]" "[:lower:]")
OBJS = $(SOURCES:.c=.o)
-LIBS = -lthread_db
+LIBS = -lutil -lthread_db
-CFLAGS = -c -fPIC -g -D_GNU_SOURCE -D$(ARCH) $(INCLUDES)
+CFLAGS = -c -fPIC -g -Wall -D_ALLBSD_SOURCE -D_GNU_SOURCE -D$(ARCH) $(INCLUDES)
LIBSA = $(ARCH)/libsaproc.so
all: $(LIBSA)
BsdDebuggerLocal.o: BsdDebuggerLocal.c
- $(JAVAH) -jni -classpath ../../../build/classes \
+ $(JAVAH) -jni -classpath ../../../../../build/bsd-i586/hotspot/outputdir/bsd_i486_compiler2/generated/saclasses \
sun.jvm.hotspot.debugger.x86.X86ThreadContext \
- sun.jvm.hotspot.debugger.sparc.SPARCThreadContext \
- sun.jvm.hotspot.debugger.amd64.AMD64ThreadContext
+ sun.jvm.hotspot.debugger.amd64.AMD64ThreadContext
$(GCC) $(CFLAGS) $<
.c.obj:
@@ -60,26 +60,19 @@ ifndef LDNOMAP
LFLAGS_LIBSA = -Xlinker --version-script=mapfile
endif
-# If this is a --hash-style=gnu system, use --hash-style=both
-# The gnu .hash section won't work on some Bsd systems like SuSE 10.
-_HAS_HASH_STYLE_GNU:=$(shell $(CC) -dumpspecs | grep -- '--hash-style=gnu')
-ifneq ($(_HAS_HASH_STYLE_GNU),)
- LDFLAGS_HASH_STYLE = -Wl,--hash-style=both
-endif
-LFLAGS_LIBSA += $(LDFLAGS_HASH_STYLE)
-
$(LIBSA): $(OBJS) mapfile
if [ ! -d $(ARCH) ] ; then mkdir $(ARCH) ; fi
$(GCC) -shared $(LFLAGS_LIBSA) -o $(LIBSA) $(OBJS) $(LIBS)
-test.o: test.c
+test.o: $(LIBSA) test.c
$(GCC) -c -o test.o -g -D_GNU_SOURCE -D$(ARCH) $(INCLUDES) test.c
test: test.o
$(GCC) -o test test.o -L$(ARCH) -lsaproc $(LIBS)
clean:
- rm -rf $(LIBSA)
- rm -rf $(OBJS)
- rmdir $(ARCH)
+ rm -f $(LIBSA)
+ rm -f $(OBJS)
+ rm -f test.o
+ -rmdir $(ARCH)

View File

@ -0,0 +1,124 @@
$OpenBSD: patch-hotspot_agent_src_os_bsd_StubDebuggerLocal_c,v 1.1 2009/06/10 19:01:09 kurt Exp $
--- hotspot/agent/src/os/bsd/StubDebuggerLocal.c.orig Tue Jun 2 13:02:17 2009
+++ hotspot/agent/src/os/bsd/StubDebuggerLocal.c Tue Jun 2 13:02:28 2009
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code 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
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+#include <stdlib.h>
+#include <jni.h>
+
+#define CHECK_EXCEPTION_(value) if ((*env)->ExceptionOccurred(env)) { return value; }
+#define CHECK_EXCEPTION if ((*env)->ExceptionOccurred(env)) { return;}
+#define THROW_NEW_DEBUGGER_EXCEPTION_(str, value) { throw_new_debugger_exception(env, str); return value; }
+#define THROW_NEW_DEBUGGER_EXCEPTION(str) { throw_new_debugger_exception(env, str); return;}
+
+static void throw_new_debugger_exception(JNIEnv* env, const char* errMsg) {
+ (*env)->ThrowNew(env, (*env)->FindClass(env, "sun/jvm/hotspot/debugger/DebuggerException"), errMsg);
+}
+
+/*
+ * Class: sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal
+ * Method: init0
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_init0
+ (JNIEnv *env, jclass cls) {
+}
+
+JNIEXPORT jint JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_getAddressSize
+ (JNIEnv *env, jclass cls)
+{
+#ifdef _LP64
+ return 8;
+#else
+ return 4;
+#endif
+
+}
+
+/*
+ * Class: sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal
+ * Method: attach0
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_attach0__I
+ (JNIEnv *env, jobject this_obj, jint jpid) {
+
+ THROW_NEW_DEBUGGER_EXCEPTION("Can't attach to the process");
+}
+
+/*
+ * Class: sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal
+ * Method: attach0
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_attach0__Ljava_lang_String_2Ljava_lang_String_2
+ (JNIEnv *env, jobject this_obj, jstring execName, jstring coreName) {
+ THROW_NEW_DEBUGGER_EXCEPTION("Can't attach to the core file");
+}
+
+/*
+ * Class: sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal
+ * Method: detach0
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_detach0
+ (JNIEnv *env, jobject this_obj) {
+}
+
+/*
+ * Class: sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal
+ * Method: lookupByName0
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)J
+ */
+JNIEXPORT jlong JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_lookupByName0
+ (JNIEnv *env, jobject this_obj, jstring objectName, jstring symbolName) {
+ return 0;
+}
+
+/*
+ * Class: sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal
+ * Method: lookupByAddress0
+ * Signature: (J)Lsun/jvm/hotspot/debugger/cdbg/ClosestSymbol;
+ */
+JNIEXPORT jobject JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_lookupByAddress0
+ (JNIEnv *env, jobject this_obj, jlong addr) {
+ return 0;
+}
+
+/*
+ * Class: sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal
+ * Method: readBytesFromProcess0
+ * Signature: (JJ)Lsun/jvm/hotspot/debugger/ReadResult;
+ */
+JNIEXPORT jbyteArray JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_readBytesFromProcess0
+ (JNIEnv *env, jobject this_obj, jlong addr, jlong numBytes) {
+ return 0;
+}
+
+JNIEXPORT jlongArray JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_getThreadIntegerRegisterSet0
+ (JNIEnv *env, jobject this_obj, jint lwp_id) {
+ return 0;
+}

View File

@ -0,0 +1,38 @@
$OpenBSD: patch-hotspot_agent_src_os_bsd_elfmacros_h,v 1.1 2009/06/10 19:01:09 kurt Exp $
--- hotspot/agent/src/os/bsd/elfmacros.h.orig Tue Jun 2 13:02:46 2009
+++ hotspot/agent/src/os/bsd/elfmacros.h Tue Jun 2 13:02:52 2009
@@ -25,16 +25,19 @@
#ifndef _ELFMACROS_H_
#define _ELFMACROS_H_
+#define ELF_NHDR Elf_Note
+
#if defined(_LP64)
#define ELF_EHDR Elf64_Ehdr
#define ELF_SHDR Elf64_Shdr
#define ELF_PHDR Elf64_Phdr
#define ELF_SYM Elf64_Sym
-#define ELF_NHDR Elf64_Nhdr
#define ELF_DYN Elf64_Dyn
#define ELF_ADDR Elf64_Addr
+#ifndef ELF_ST_TYPE
#define ELF_ST_TYPE ELF64_ST_TYPE
+#endif
#else
@@ -42,11 +45,12 @@
#define ELF_SHDR Elf32_Shdr
#define ELF_PHDR Elf32_Phdr
#define ELF_SYM Elf32_Sym
-#define ELF_NHDR Elf32_Nhdr
#define ELF_DYN Elf32_Dyn
#define ELF_ADDR Elf32_Addr
+#ifndef ELF_ST_TYPE
#define ELF_ST_TYPE ELF32_ST_TYPE
+#endif
#endif

View File

@ -0,0 +1,221 @@
$OpenBSD: patch-hotspot_agent_src_os_bsd_hsearch_r_c,v 1.1 2009/06/10 19:01:09 kurt Exp $
--- hotspot/agent/src/os/bsd/hsearch_r.c.orig Tue Jun 2 13:03:08 2009
+++ hotspot/agent/src/os/bsd/hsearch_r.c Tue Jun 2 13:03:18 2009
@@ -0,0 +1,217 @@
+/* Copyright (C) 1993,1995-1997,2002,2005,2007,2008
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1993.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <search.h>
+
+#include "hsearch_r.h"
+
+#define __set_errno(ERRNO) errno = ERRNO
+
+/* [Aho,Sethi,Ullman] Compilers: Principles, Techniques and Tools, 1986
+ [Knuth] The Art of Computer Programming, part 3 (6.4) */
+
+
+/* The reentrant version has no static variables to maintain the state.
+ Instead the interface of all functions is extended to take an argument
+ which describes the current status. */
+typedef struct _ENTRY
+{
+ unsigned int used;
+ ENTRY entry;
+}
+_ENTRY;
+
+
+/* For the used double hash method the table size has to be a prime. To
+ correct the user given table size we need a prime test. This trivial
+ algorithm is adequate because
+ a) the code is (most probably) called a few times per program run and
+ b) the number is small because the table must fit in the core */
+static int
+isprime (unsigned int number)
+{
+ /* no even number will be passed */
+ unsigned int div = 3;
+
+ while (div * div < number && number % div != 0)
+ div += 2;
+
+ return number % div != 0;
+}
+
+
+/* Before using the hash table we must allocate memory for it.
+ Test for an existing table are done. We allocate one element
+ more as the found prime number says. This is done for more effective
+ indexing as explained in the comment for the hsearch function.
+ The contents of the table is zeroed, especially the field used
+ becomes zero. */
+int
+hcreate_r (size_t nel, struct hsearch_data *htab)
+{
+ /* Test for correct arguments. */
+ if (htab == NULL)
+ {
+ __set_errno (EINVAL);
+ return 0;
+ }
+
+ /* There is still another table active. Return with error. */
+ if (htab->table != NULL)
+ return 0;
+
+ /* Change nel to the first prime number not smaller as nel. */
+ nel |= 1; /* make odd */
+ while (!isprime (nel))
+ nel += 2;
+
+ htab->size = nel;
+ htab->filled = 0;
+
+ /* allocate memory and zero out */
+ htab->table = (_ENTRY *) calloc (htab->size + 1, sizeof (_ENTRY));
+ if (htab->table == NULL)
+ return 0;
+
+ /* everything went alright */
+ return 1;
+}
+
+
+/* After using the hash table it has to be destroyed. The used memory can
+ be freed and the local static variable can be marked as not used. */
+void
+hdestroy_r (struct hsearch_data *htab)
+{
+ /* Test for correct arguments. */
+ if (htab == NULL)
+ {
+ __set_errno (EINVAL);
+ return;
+ }
+
+ /* Free used memory. */
+ free (htab->table);
+
+ /* the sign for an existing table is an value != NULL in htable */
+ htab->table = NULL;
+}
+
+
+/* This is the search function. It uses double hashing with open addressing.
+ The argument item.key has to be a pointer to an zero terminated, most
+ probably strings of chars. The function for generating a number of the
+ strings is simple but fast. It can be replaced by a more complex function
+ like ajw (see [Aho,Sethi,Ullman]) if the needs are shown.
+
+ We use an trick to speed up the lookup. The table is created by hcreate
+ with one more element available. This enables us to use the index zero
+ special. This index will never be used because we store the first hash
+ index in the field used where zero means not used. Every other value
+ means used. The used field can be used as a first fast comparison for
+ equality of the stored and the parameter value. This helps to prevent
+ unnecessary expensive calls of strcmp. */
+int
+hsearch_r (ENTRY item, ACTION action, ENTRY **retval, struct hsearch_data *htab)
+{
+ unsigned int hval;
+ unsigned int count;
+ unsigned int len = strlen (item.key);
+ unsigned int idx;
+
+ /* Compute an value for the given string. Perhaps use a better method. */
+ hval = len;
+ count = len;
+ while (count-- > 0)
+ {
+ hval <<= 4;
+ hval += item.key[count];
+ }
+
+ /* First hash function: simply take the modul but prevent zero. */
+ idx = hval % htab->size + 1;
+
+ if (htab->table[idx].used)
+ {
+ /* Further action might be required according to the action value. */
+ if (htab->table[idx].used == hval
+ && strcmp (item.key, htab->table[idx].entry.key) == 0)
+ {
+ *retval = &htab->table[idx].entry;
+ return 1;
+ }
+
+ /* Second hash function, as suggested in [Knuth] */
+ unsigned int hval2 = 1 + hval % (htab->size - 2);
+ unsigned int first_idx = idx;
+
+ do
+ {
+ /* Because SIZE is prime this guarantees to step through all
+ available indeces. */
+ if (idx <= hval2)
+ idx = htab->size + idx - hval2;
+ else
+ idx -= hval2;
+
+ /* If we visited all entries leave the loop unsuccessfully. */
+ if (idx == first_idx)
+ break;
+
+ /* If entry is found use it. */
+ if (htab->table[idx].used == hval
+ && strcmp (item.key, htab->table[idx].entry.key) == 0)
+ {
+ *retval = &htab->table[idx].entry;
+ return 1;
+ }
+ }
+ while (htab->table[idx].used);
+ }
+
+ /* An empty bucket has been found. */
+ if (action == ENTER)
+ {
+ /* If table is full and another entry should be entered return
+ with error. */
+ if (htab->filled == htab->size)
+ {
+ __set_errno (ENOMEM);
+ *retval = NULL;
+ return 0;
+ }
+
+ htab->table[idx].used = hval;
+ htab->table[idx].entry = item;
+
+ ++htab->filled;
+
+ *retval = &htab->table[idx].entry;
+ return 1;
+ }
+
+ __set_errno (ESRCH);
+ *retval = NULL;
+ return 0;
+}

View File

@ -0,0 +1,46 @@
$OpenBSD: patch-hotspot_agent_src_os_bsd_hsearch_r_h,v 1.1 2009/06/10 19:01:09 kurt Exp $
--- hotspot/agent/src/os/bsd/hsearch_r.h.orig Tue Jun 2 13:03:25 2009
+++ hotspot/agent/src/os/bsd/hsearch_r.h Tue Jun 2 13:03:34 2009
@@ -0,0 +1,42 @@
+/* Declarations for System V style searching functions.
+ Copyright (C) 1995-1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _HSEARCH_R_H_
+#define _HSEARCH_R_H_
+
+#include <search.h>
+
+struct _ENTRY;
+
+/* Data type for reentrant functions. */
+struct hsearch_data
+ {
+ struct _ENTRY *table;
+ unsigned int size;
+ unsigned int filled;
+ };
+
+/* Reentrant versions which can handle multiple hashing tables at the
+ same time. */
+extern int hsearch_r (ENTRY __item, ACTION __action, ENTRY **__retval,
+ struct hsearch_data *__htab);
+extern int hcreate_r (size_t __nel, struct hsearch_data *__htab);
+extern void hdestroy_r (struct hsearch_data *__htab);
+
+#endif /* _HSEARCH_R_H_ */

View File

@ -0,0 +1,63 @@
$OpenBSD: patch-hotspot_agent_src_os_bsd_libproc_h,v 1.1 2009/06/10 19:01:09 kurt Exp $
--- hotspot/agent/src/os/bsd/libproc.h.orig Tue Jun 2 13:03:57 2009
+++ hotspot/agent/src/os/bsd/libproc.h Tue Jun 2 13:04:07 2009
@@ -27,7 +27,8 @@
#include <unistd.h>
#include <stdint.h>
-#include "proc_service.h"
+#include <machine/reg.h>
+#include <proc_service.h>
#if defined(sparc) || defined(sparcv9)
/*
@@ -50,14 +51,11 @@ Please note that the bulk of the functionality is from
adds Pgrab__ and some missing stuff. We hide the difference b/w live process and core
file by this interface.
-1. pthread_id unique in both NPTL & BsdThreads. We store this in
-OSThread::_pthread_id in JVM code.
+1. pthread_id is unique. We store this in OSThread::_pthread_id in JVM code.
-2. All threads see the same pid when they call getpid() under NPTL.
-Threads receive different pid under BsdThreads. We used to save the result of
-::getpid() call in OSThread::_thread_id. This way uniqueness of OSThread::_thread_id
-was lost under NPTL. Now, we store the result of ::gettid() call in
-OSThread::_thread_id. Because gettid returns actual pid of thread (lwp id), this is
+2. All threads see the same pid when they call getpid().
+We used to save the result of ::getpid() call in OSThread::_thread_id.
+Because gettid returns actual pid of thread (lwp id), this is
unique again. We therefore use OSThread::_thread_id as unique identifier.
3. There is a unique LWP id under both thread libraries. libthread_db maps pthread_id
@@ -74,20 +72,7 @@ combination of ptrace and /proc calls.
*************************************************************************************/
-#ifdef ia64
-struct user_regs_struct {
-/* copied from user.h which doesn't define this in a struct */
-
-#define IA64_REG_COUNT (EF_SIZE/8+32) /* integer and fp regs */
-unsigned long regs[IA64_REG_COUNT]; /* integer and fp regs */
-};
-#endif
-
-#if defined(sparc) || defined(sparcv9)
-#define user_regs_struct pt_regs
-#endif
-
-// This C bool type must be int for compatibility with Bsd calls and
+// This C bool type must be int for compatibility with BSD calls and
// it would be a mistake to equivalence it to C++ bool on many platforms
typedef int bool;
@@ -118,7 +103,7 @@ int get_num_threads(struct ps_prochandle* ph);
lwpid_t get_lwp_id(struct ps_prochandle* ph, int index);
// get regs for a given lwp
-bool get_lwp_regs(struct ps_prochandle* ph, lwpid_t lid, struct user_regs_struct* regs);
+bool get_lwp_regs(struct ps_prochandle* ph, lwpid_t lid, struct reg* regs);
// get number of shared objects
int get_num_libs(struct ps_prochandle* ph);

View File

@ -0,0 +1,97 @@
$OpenBSD: patch-hotspot_agent_src_os_bsd_libproc_impl_c,v 1.1 2009/06/10 19:01:09 kurt Exp $
--- hotspot/agent/src/os/bsd/libproc_impl.c.orig Tue Jun 2 13:04:27 2009
+++ hotspot/agent/src/os/bsd/libproc_impl.c Tue Jun 2 13:04:34 2009
@@ -178,6 +178,9 @@ lib_info* add_lib_info_fd(struct ps_prochandle* ph, co
if (newlib->symtab == NULL) {
print_debug("symbol table build failed for %s\n", newlib->name);
}
+ else {
+ print_debug("built symbol table for %s\n", newlib->name);
+ }
// even if symbol table building fails, we add the lib_info.
// This is because we may need to read from the ELF file for core file
@@ -272,7 +275,7 @@ static int thread_db_callback(const td_thrhandle_t *th
print_debug("thread_db : pthread %d (lwp %d)\n", ti.ti_tid, ti.ti_lid);
- if (ptr->callback(ptr->ph, ti.ti_tid, ti.ti_lid) != true)
+ if (ptr->callback(ptr->ph, (pthread_t)ti.ti_tid, ti.ti_lid) != true)
return TD_ERR;
return TD_OK;
@@ -324,7 +327,7 @@ lwpid_t get_lwp_id(struct ps_prochandle* ph, int index
}
// get regs for a given lwp
-bool get_lwp_regs(struct ps_prochandle* ph, lwpid_t lwp_id, struct user_regs_struct* regs) {
+bool get_lwp_regs(struct ps_prochandle* ph, lwpid_t lwp_id, struct reg* regs) {
return ph->ops->get_lwp_regs(ph, lwp_id, regs);
}
@@ -375,11 +378,6 @@ bool find_lib(struct ps_prochandle* ph, const char *li
//--------------------------------------------------------------------------
// proc service functions
-// get process id
-pid_t ps_getpid(struct ps_prochandle *ph) {
- return ph->pid;
-}
-
// ps_pglobal_lookup() looks up the symbol sym_name in the symbol table
// of the load object object_name in the target process identified by ph.
// It returns the symbol's value as an address in the target process in
@@ -392,17 +390,33 @@ ps_err_e ps_pglobal_lookup(struct ps_prochandle *ph, c
}
// read "size" bytes info "buf" from address "addr"
-ps_err_e ps_pdread(struct ps_prochandle *ph, psaddr_t addr,
- void *buf, size_t size) {
+ps_err_e ps_pread(struct ps_prochandle *ph, psaddr_t addr,
+ void *buf, size_t size) {
return ph->ops->p_pread(ph, (uintptr_t) addr, buf, size)? PS_OK: PS_ERR;
}
// write "size" bytes of data to debuggee at address "addr"
-ps_err_e ps_pdwrite(struct ps_prochandle *ph, psaddr_t addr,
- const void *buf, size_t size) {
+ps_err_e ps_pwrite(struct ps_prochandle *ph, psaddr_t addr,
+ const void *buf, size_t size) {
return ph->ops->p_pwrite(ph, (uintptr_t)addr, buf, size)? PS_OK: PS_ERR;
}
+// fill in ptrace_lwpinfo for lid
+ps_err_e ps_linfo(struct ps_prochandle *ph, lwpid_t lwp_id, void *linfo) {
+ return ph->ops->get_lwp_info(ph, lwp_id, linfo)? PS_OK: PS_ERR;
+}
+
+// needed for when libthread_db is compiled with TD_DEBUG defined
+void
+ps_plog (const char *format, ...)
+{
+ va_list alist;
+
+ va_start(alist, format);
+ vfprintf(stderr, format, alist);
+ va_end(alist);
+}
+
// ------------------------------------------------------------------------
// Functions below this point are not yet implemented. They are here only
// to make the linker happy.
@@ -427,8 +441,12 @@ ps_err_e ps_lgetregs(struct ps_prochandle *ph, lwpid_t
return PS_OK;
}
-// new libthread_db of NPTL seem to require this symbol
-ps_err_e ps_get_thread_area() {
- print_debug("ps_get_thread_area not implemented\n");
+ps_err_e ps_lstop(struct ps_prochandle *ph, lwpid_t lid) {
+ print_debug("ps_lstop not implemented\n");
+ return PS_OK;
+}
+
+ps_err_e ps_pcontinue(struct ps_prochandle *ph) {
+ print_debug("ps_pcontinue not implemented\n");
return PS_OK;
}

View File

@ -0,0 +1,32 @@
$OpenBSD: patch-hotspot_agent_src_os_bsd_libproc_impl_h,v 1.1 2009/06/10 19:01:09 kurt Exp $
--- hotspot/agent/src/os/bsd/libproc_impl.h.orig Tue Jun 2 13:04:50 2009
+++ hotspot/agent/src/os/bsd/libproc_impl.h Tue Jun 2 13:04:58 2009
@@ -47,7 +47,7 @@ typedef struct lib_info {
typedef struct thread_info {
lwpid_t lwp_id;
pthread_t pthread_id; // not used cores, always -1
- struct user_regs_struct regs; // not for process, core uses for caching regset
+ struct reg regs; // not for process, core uses for caching regset
struct thread_info* next;
} thread_info;
@@ -71,7 +71,9 @@ typedef struct ps_prochandle_ops {
bool (*p_pwrite)(struct ps_prochandle *ph,
uintptr_t addr, const char *buf , size_t size);
// get integer regset of a thread
- bool (*get_lwp_regs)(struct ps_prochandle* ph, lwpid_t lwp_id, struct user_regs_struct* regs);
+ bool (*get_lwp_regs)(struct ps_prochandle* ph, lwpid_t lwp_id, struct reg* regs);
+ // get info on thread
+ bool (*get_lwp_info)(struct ps_prochandle *ph, lwpid_t lwp_id, void *linfo);
} ps_prochandle_ops;
// the ps_prochandle
@@ -79,7 +81,7 @@ typedef struct ps_prochandle_ops {
struct core_data {
int core_fd; // file descriptor of core file
int exec_fd; // file descriptor of exec file
- int interp_fd; // file descriptor of interpreter (ld-bsd.so.2)
+ int interp_fd; // file descriptor of interpreter (ld-elf.so.1)
// part of the class sharing workaround
int classes_jsa_fd; // file descriptor of class share archive
uintptr_t dynamic_addr; // address of dynamic section of a.out

View File

@ -0,0 +1,24 @@
$OpenBSD: patch-hotspot_agent_src_os_bsd_mapfile,v 1.1 2009/06/10 19:01:09 kurt Exp $
--- hotspot/agent/src/os/bsd/mapfile.orig Tue Jun 2 13:05:13 2009
+++ hotspot/agent/src/os/bsd/mapfile Tue Jun 2 13:05:19 2009
@@ -43,13 +43,17 @@ SUNWprivate_1.1 {
# proc_service.h functions - to be used by libthread_db
ps_getpid;
ps_pglobal_lookup;
- ps_pdread;
- ps_pdwrite;
+ ps_pread;
+ ps_pwrite;
ps_lsetfpregs;
ps_lsetregs;
ps_lgetfpregs;
ps_lgetregs;
- ps_get_thread_area;
+ ps_lcontinue;
+ ps_lgetxmmregs;
+ ps_lsetxmmregs;
+ ps_lstop;
+ ps_linfo;
# used by attach test program
init_libproc;

View File

@ -0,0 +1,300 @@
$OpenBSD: patch-hotspot_agent_src_os_bsd_ps_core_c,v 1.1 2009/06/10 19:01:09 kurt Exp $
--- hotspot/agent/src/os/bsd/ps_core.c.orig Tue Jun 2 13:06:41 2009
+++ hotspot/agent/src/os/bsd/ps_core.c Tue Jun 2 13:21:01 2009
@@ -142,6 +142,7 @@ static map_info* add_class_share_map_info(struct ps_pr
map->next = ph->core->class_share_maps;
ph->core->class_share_maps = map;
+ return map;
}
// Return the map_info for the given virtual address. We keep a sorted
@@ -228,8 +229,8 @@ struct FileMapHeader {
// 4991491 NOTICE These are C++ bool's in filemap.hpp and must match up with
// the C type matching the C++ bool type on any given platform. For
- // Hotspot on Bsd we assume the corresponding C type is char but
- // licensees on Bsd versions may need to adjust the type of these fields.
+ // Hotspot on BSD we assume the corresponding C type is char but
+ // licensees on BSD versions may need to adjust the type of these fields.
char _read_only; // read only space?
char _allow_exec; // executable code in space?
@@ -240,7 +241,7 @@ struct FileMapHeader {
static bool read_jboolean(struct ps_prochandle* ph, uintptr_t addr, jboolean* pvalue) {
jboolean i;
- if (ps_pdread(ph, (psaddr_t) addr, &i, sizeof(i)) == PS_OK) {
+ if (ps_pread(ph, (psaddr_t) addr, &i, sizeof(i)) == PS_OK) {
*pvalue = i;
return true;
} else {
@@ -250,7 +251,7 @@ static bool read_jboolean(struct ps_prochandle* ph, ui
static bool read_pointer(struct ps_prochandle* ph, uintptr_t addr, uintptr_t* pvalue) {
uintptr_t uip;
- if (ps_pdread(ph, (psaddr_t) addr, &uip, sizeof(uip)) == PS_OK) {
+ if (ps_pread(ph, (psaddr_t) addr, &uip, sizeof(uip)) == PS_OK) {
*pvalue = uip;
return true;
} else {
@@ -264,7 +265,7 @@ static bool read_string(struct ps_prochandle* ph, uint
char c = ' ';
while (c != '\0') {
- if (ps_pdread(ph, (psaddr_t) addr, &c, sizeof(char)) != PS_OK)
+ if (ps_pread(ph, (psaddr_t) addr, &c, sizeof(char)) != PS_OK)
return false;
if (i < size - 1)
buf[i] = c;
@@ -296,7 +297,6 @@ static bool init_classsharing_workaround(struct ps_pro
uintptr_t base = 0, useSharedSpacesAddr = 0;
uintptr_t sharedArchivePathAddrAddr = 0, sharedArchivePathAddr = 0;
jboolean useSharedSpaces = 0;
- map_info* mi = 0;
memset(classes_jsa, 0, sizeof(classes_jsa));
jvm_name = lib->name;
@@ -306,9 +306,9 @@ static bool init_classsharing_workaround(struct ps_pro
return false;
}
- // Hotspot vm types are not exported to build this library. So
- // using equivalent type jboolean to read the value of
- // UseSharedSpaces which is same as hotspot type "bool".
+ // Hotspot vm types are not exported to build this library. So
+ // using equivalent type jboolean to read the value of
+ // UseSharedSpaces which is same as hotspot type "bool".
if (read_jboolean(ph, useSharedSpacesAddr, &useSharedSpaces) != true) {
print_debug("can't read the value of 'UseSharedSpaces' flag\n");
return false;
@@ -507,12 +507,12 @@ static bool core_write_data(struct ps_prochandle* ph,
}
static bool core_get_lwp_regs(struct ps_prochandle* ph, lwpid_t lwp_id,
- struct user_regs_struct* regs) {
+ struct reg* regs) {
// for core we have cached the lwp regs from NOTE section
thread_info* thr = ph->threads;
while (thr) {
if (thr->lwp_id == lwp_id) {
- memcpy(regs, &thr->regs, sizeof(struct user_regs_struct));
+ memcpy(regs, &thr->regs, sizeof(struct reg));
return true;
}
thr = thr->next;
@@ -520,11 +520,17 @@ static bool core_get_lwp_regs(struct ps_prochandle* ph
return false;
}
+static bool core_get_lwp_info(struct ps_prochandle *ph, lwpid_t lwp_id, void *linfo) {
+ print_debug("core_get_lwp_info not implemented\n");
+ return false;
+}
+
static ps_prochandle_ops core_ops = {
.release= core_release,
.p_pread= core_read_data,
.p_pwrite= core_write_data,
- .get_lwp_regs= core_get_lwp_regs
+ .get_lwp_regs= core_get_lwp_regs,
+ .get_lwp_info= core_get_lwp_info
};
// read regs and create thread from NT_PRSTATUS entries from core file
@@ -539,52 +545,52 @@ static bool core_handle_prstatus(struct ps_prochandle*
return false;
// copy regs
- memcpy(&newthr->regs, prstat->pr_reg, sizeof(struct user_regs_struct));
+ memcpy(&newthr->regs, &prstat->pr_reg, sizeof(struct reg));
if (is_debug()) {
print_debug("integer regset\n");
#ifdef i386
// print the regset
- print_debug("\teax = 0x%x\n", newthr->regs.eax);
- print_debug("\tebx = 0x%x\n", newthr->regs.ebx);
- print_debug("\tecx = 0x%x\n", newthr->regs.ecx);
- print_debug("\tedx = 0x%x\n", newthr->regs.edx);
- print_debug("\tesp = 0x%x\n", newthr->regs.esp);
- print_debug("\tebp = 0x%x\n", newthr->regs.ebp);
- print_debug("\tesi = 0x%x\n", newthr->regs.esi);
- print_debug("\tedi = 0x%x\n", newthr->regs.edi);
- print_debug("\teip = 0x%x\n", newthr->regs.eip);
+ print_debug("\teax = 0x%x\n", newthr->regs.r_eax);
+ print_debug("\tebx = 0x%x\n", newthr->regs.r_ebx);
+ print_debug("\tecx = 0x%x\n", newthr->regs.r_ecx);
+ print_debug("\tedx = 0x%x\n", newthr->regs.r_edx);
+ print_debug("\tesp = 0x%x\n", newthr->regs.r_esp);
+ print_debug("\tebp = 0x%x\n", newthr->regs.r_ebp);
+ print_debug("\tesi = 0x%x\n", newthr->regs.r_esi);
+ print_debug("\tedi = 0x%x\n", newthr->regs.r_edi);
+ print_debug("\teip = 0x%x\n", newthr->regs.r_eip);
#endif
#if defined(amd64) || defined(x86_64)
// print the regset
- print_debug("\tr15 = 0x%lx\n", newthr->regs.r15);
- print_debug("\tr14 = 0x%lx\n", newthr->regs.r14);
- print_debug("\tr13 = 0x%lx\n", newthr->regs.r13);
- print_debug("\tr12 = 0x%lx\n", newthr->regs.r12);
- print_debug("\trbp = 0x%lx\n", newthr->regs.rbp);
- print_debug("\trbx = 0x%lx\n", newthr->regs.rbx);
- print_debug("\tr11 = 0x%lx\n", newthr->regs.r11);
- print_debug("\tr10 = 0x%lx\n", newthr->regs.r10);
- print_debug("\tr9 = 0x%lx\n", newthr->regs.r9);
- print_debug("\tr8 = 0x%lx\n", newthr->regs.r8);
- print_debug("\trax = 0x%lx\n", newthr->regs.rax);
- print_debug("\trcx = 0x%lx\n", newthr->regs.rcx);
- print_debug("\trdx = 0x%lx\n", newthr->regs.rdx);
- print_debug("\trsi = 0x%lx\n", newthr->regs.rsi);
- print_debug("\trdi = 0x%lx\n", newthr->regs.rdi);
- print_debug("\torig_rax = 0x%lx\n", newthr->regs.orig_rax);
- print_debug("\trip = 0x%lx\n", newthr->regs.rip);
- print_debug("\tcs = 0x%lx\n", newthr->regs.cs);
- print_debug("\teflags = 0x%lx\n", newthr->regs.eflags);
- print_debug("\trsp = 0x%lx\n", newthr->regs.rsp);
- print_debug("\tss = 0x%lx\n", newthr->regs.ss);
- print_debug("\tfs_base = 0x%lx\n", newthr->regs.fs_base);
- print_debug("\tgs_base = 0x%lx\n", newthr->regs.gs_base);
- print_debug("\tds = 0x%lx\n", newthr->regs.ds);
- print_debug("\tes = 0x%lx\n", newthr->regs.es);
- print_debug("\tfs = 0x%lx\n", newthr->regs.fs);
- print_debug("\tgs = 0x%lx\n", newthr->regs.gs);
+ print_debug("\tr15 = 0x%lx\n", newthr->regs.r_r15);
+ print_debug("\tr14 = 0x%lx\n", newthr->regs.r_r14);
+ print_debug("\tr13 = 0x%lx\n", newthr->regs.r_r13);
+ print_debug("\tr12 = 0x%lx\n", newthr->regs.r_r12);
+ print_debug("\trbp = 0x%lx\n", newthr->regs.r_rbp);
+ print_debug("\trbx = 0x%lx\n", newthr->regs.r_rbx);
+ print_debug("\tr11 = 0x%lx\n", newthr->regs.r_r11);
+ print_debug("\tr10 = 0x%lx\n", newthr->regs.r_r10);
+ print_debug("\tr9 = 0x%lx\n", newthr->regs.r_r9);
+ print_debug("\tr8 = 0x%lx\n", newthr->regs.r_r8);
+ print_debug("\trax = 0x%lx\n", newthr->regs.r_rax);
+ print_debug("\trcx = 0x%lx\n", newthr->regs.r_rcx);
+ print_debug("\trdx = 0x%lx\n", newthr->regs.r_rdx);
+ print_debug("\trsi = 0x%lx\n", newthr->regs.r_rsi);
+ print_debug("\trdi = 0x%lx\n", newthr->regs.r_rdi);
+ //print_debug("\torig_rax = 0x%lx\n", newthr->regs.orig_rax);
+ print_debug("\trip = 0x%lx\n", newthr->regs.r_rip);
+ print_debug("\tcs = 0x%lx\n", newthr->regs.r_cs);
+ //print_debug("\teflags = 0x%lx\n", newthr->regs.eflags);
+ print_debug("\trsp = 0x%lx\n", newthr->regs.r_rsp);
+ print_debug("\tss = 0x%lx\n", newthr->regs.r_ss);
+ //print_debug("\tfs_base = 0x%lx\n", newthr->regs.fs_base);
+ //print_debug("\tgs_base = 0x%lx\n", newthr->regs.gs_base);
+ //print_debug("\tds = 0x%lx\n", newthr->regs.ds);
+ //print_debug("\tes = 0x%lx\n", newthr->regs.es);
+ //print_debug("\tfs = 0x%lx\n", newthr->regs.fs);
+ //print_debug("\tgs = 0x%lx\n", newthr->regs.gs);
#endif
}
@@ -656,7 +662,7 @@ static bool read_core_segments(struct ps_prochandle* p
* contains a set of saved /proc structures), and PT_LOAD (which
* represents a memory mapping from the process's address space).
*
- * Difference b/w Solaris PT_NOTE and Bsd PT_NOTE:
+ * Difference b/w Solaris PT_NOTE and BSD PT_NOTE:
*
* In Solaris there are two PT_NOTE segments the first PT_NOTE (if present)
* contains /proc structs in the pre-2.6 unstructured /proc format. the last
@@ -666,10 +672,10 @@ static bool read_core_segments(struct ps_prochandle* p
* integer register set among other stuff. For each LWP, we have one lwpstatus
* entry that has integer regset for that LWP.
*
- * Bsd threads are actually 'clone'd processes. To support core analysis
- * of "multithreaded" process, Bsd creates more than one pstatus (called
+ * Linux threads are actually 'clone'd processes. To support core analysis
+ * of "multithreaded" process, Linux creates more than one pstatus (called
* "prstatus") entry in PT_NOTE. Each prstatus entry has integer regset for one
- * "thread". Please refer to Bsd kernel src file 'fs/binfmt_elf.c', in particular
+ * "thread". Please refer to Linux kernel src file 'fs/binfmt_elf.c', in particular
* function "elf_core_dump".
*/
@@ -725,7 +731,7 @@ err:
return false;
}
-// process segments from interpreter (ld.so or ld-bsd.so)
+// process segments from interpreter (ld-elf.so.1)
static bool read_interp_segments(struct ps_prochandle* ph) {
ELF_EHDR interp_ehdr;
@@ -826,7 +832,7 @@ static bool read_shared_lib_info(struct ps_prochandle*
dyn.d_tag = DT_NULL;
while (dyn.d_tag != DT_DEBUG) {
- if (ps_pdread(ph, (psaddr_t) addr, &dyn, sizeof(ELF_DYN)) != PS_OK) {
+ if (ps_pread(ph, (psaddr_t) addr, &dyn, sizeof(ELF_DYN)) != PS_OK) {
print_debug("can't read debug info from _DYNAMIC\n");
return false;
}
@@ -836,23 +842,27 @@ static bool read_shared_lib_info(struct ps_prochandle*
// we have got Dyn entry with DT_DEBUG
debug_base = dyn.d_un.d_ptr;
// at debug_base we have struct r_debug. This has first link map in r_map field
- if (ps_pdread(ph, (psaddr_t) debug_base + FIRST_LINK_MAP_OFFSET,
+ if (ps_pread(ph, (psaddr_t) debug_base + FIRST_LINK_MAP_OFFSET,
&first_link_map_addr, sizeof(uintptr_t)) != PS_OK) {
print_debug("can't read first link map address\n");
return false;
}
// read ld_base address from struct r_debug
- if (ps_pdread(ph, (psaddr_t) debug_base + LD_BASE_OFFSET, &ld_base_addr,
+ // XXX: There is no r_ldbase member on BSD
+/*
+ if (ps_pread(ph, (psaddr_t) debug_base + LD_BASE_OFFSET, &ld_base_addr,
sizeof(uintptr_t)) != PS_OK) {
print_debug("can't read ld base address\n");
return false;
}
ph->core->ld_base_addr = ld_base_addr;
+*/
+ ph->core->ld_base_addr = 0;
print_debug("interpreter base address is 0x%lx\n", ld_base_addr);
- // now read segments from interp (i.e ld.so or ld-bsd.so)
+ // now read segments from interp (i.e ld-elf.so.1)
if (read_interp_segments(ph) != true)
return false;
@@ -870,14 +880,14 @@ static bool read_shared_lib_info(struct ps_prochandle*
// address mentioned in shared object and the actual virtual base where runtime
// linker loaded it. We use "base diff" in read_lib_segments call below.
- if (ps_pdread(ph, (psaddr_t) link_map_addr + LINK_MAP_ADDR_OFFSET,
+ if (ps_pread(ph, (psaddr_t) link_map_addr + LINK_MAP_ADDR_OFFSET,
&lib_base_diff, sizeof(uintptr_t)) != PS_OK) {
print_debug("can't read shared object base address diff\n");
return false;
}
// read address of the name
- if (ps_pdread(ph, (psaddr_t) link_map_addr + LINK_MAP_NAME_OFFSET,
+ if (ps_pread(ph, (psaddr_t) link_map_addr + LINK_MAP_NAME_OFFSET,
&lib_name_addr, sizeof(uintptr_t)) != PS_OK) {
print_debug("can't read address of shared object name\n");
return false;
@@ -921,7 +931,7 @@ static bool read_shared_lib_info(struct ps_prochandle*
}
// read next link_map address
- if (ps_pdread(ph, (psaddr_t) link_map_addr + LINK_MAP_NEXT_OFFSET,
+ if (ps_pread(ph, (psaddr_t) link_map_addr + LINK_MAP_NEXT_OFFSET,
&link_map_addr, sizeof(uintptr_t)) != PS_OK) {
print_debug("can't read next link in link_map\n");
return false;
@@ -935,7 +945,6 @@ static bool read_shared_lib_info(struct ps_prochandle*
struct ps_prochandle* Pgrab_core(const char* exec_file, const char* core_file) {
ELF_EHDR core_ehdr;
ELF_EHDR exec_ehdr;
- ELF_EHDR lib_ehdr;
struct ps_prochandle* ph = (struct ps_prochandle*) calloc(1, sizeof(struct ps_prochandle));
if (ph == NULL) {

View File

@ -0,0 +1,563 @@
$OpenBSD: patch-hotspot_agent_src_os_bsd_ps_proc_c,v 1.1 2009/06/10 19:01:09 kurt Exp $
--- hotspot/agent/src/os/bsd/ps_proc.c.orig Tue Jun 2 13:07:59 2009
+++ hotspot/agent/src/os/bsd/ps_proc.c Tue Jun 2 13:20:36 2009
@@ -22,21 +22,23 @@
*
*/
+#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
+#include <sys/types.h>
+#include <sys/wait.h>
#include <sys/ptrace.h>
+#include <sys/param.h>
+#include <sys/user.h>
+#include <elf.h>
+#include <sys/elf_common.h>
+#include <sys/link_elf.h>
+#include <libutil.h>
#include "libproc_impl.h"
+#include "elfmacros.h"
-#if defined(x86_64) && !defined(amd64)
-#define amd64 1
-#endif
-
-#ifndef __WALL
-#define __WALL 0x40000000 // Copied from /usr/include/bsd/wait.h
-#endif
-
// This file has the libproc implementation specific to live process
// For core files, refer to ps_core.c
@@ -50,251 +52,359 @@ static inline uintptr_t align(uintptr_t ptr, size_t si
// read "size" bytes of data from "addr" within the target process.
// unlike the standard ptrace() function, process_read_data() can handle
-// unaligned address - alignment check, if required, should be done
+// unaligned address - alignment check, if required, should be done
// before calling process_read_data.
static bool process_read_data(struct ps_prochandle* ph, uintptr_t addr, char *buf, size_t size) {
- long rslt;
+ int rslt;
size_t i, words;
uintptr_t end_addr = addr + size;
- uintptr_t aligned_addr = align(addr, sizeof(long));
+ uintptr_t aligned_addr = align(addr, sizeof(int));
if (aligned_addr != addr) {
char *ptr = (char *)&rslt;
errno = 0;
- rslt = ptrace(PTRACE_PEEKDATA, ph->pid, aligned_addr, 0);
+ rslt = ptrace(PT_READ_D, ph->pid, (caddr_t) aligned_addr, 0);
if (errno) {
- print_debug("ptrace(PTRACE_PEEKDATA, ..) failed for %d bytes @ %lx\n", size, addr);
+ print_debug("ptrace(PT_READ_D, ..) failed for %d bytes @ %lx\n", size, addr);
return false;
}
for (; aligned_addr != addr; aligned_addr++, ptr++);
- for (; ((intptr_t)aligned_addr % sizeof(long)) && aligned_addr < end_addr;
- aligned_addr++)
+ for (; ((intptr_t)aligned_addr % sizeof(int)) && aligned_addr < end_addr;
+ aligned_addr++)
*(buf++) = *(ptr++);
}
- words = (end_addr - aligned_addr) / sizeof(long);
+ words = (end_addr - aligned_addr) / sizeof(int);
- // assert((intptr_t)aligned_addr % sizeof(long) == 0);
+ // assert((intptr_t)aligned_addr % sizeof(int) == 0);
for (i = 0; i < words; i++) {
errno = 0;
- rslt = ptrace(PTRACE_PEEKDATA, ph->pid, aligned_addr, 0);
+ rslt = ptrace(PT_READ_D, ph->pid, (caddr_t) aligned_addr, 0);
if (errno) {
- print_debug("ptrace(PTRACE_PEEKDATA, ..) failed for %d bytes @ %lx\n", size, addr);
+ print_debug("ptrace(PT_READ_D, ..) failed for %d bytes @ %lx\n", size, addr);
return false;
}
- *(long *)buf = rslt;
- buf += sizeof(long);
- aligned_addr += sizeof(long);
+ *(int *)buf = rslt;
+ buf += sizeof(int);
+ aligned_addr += sizeof(int);
}
if (aligned_addr != end_addr) {
char *ptr = (char *)&rslt;
errno = 0;
- rslt = ptrace(PTRACE_PEEKDATA, ph->pid, aligned_addr, 0);
+ rslt = ptrace(PT_READ_D, ph->pid, (caddr_t) aligned_addr, 0);
if (errno) {
- print_debug("ptrace(PTRACE_PEEKDATA, ..) failed for %d bytes @ %lx\n", size, addr);
+ print_debug("ptrace(PT_READ_D, ..) failed for %d bytes @ %lx\n", size, addr);
return false;
}
- for (; aligned_addr != end_addr; aligned_addr++)
+ for (; aligned_addr != end_addr; aligned_addr++)
*(buf++) = *(ptr++);
}
return true;
}
// null implementation for write
-static bool process_write_data(struct ps_prochandle* ph,
+static bool process_write_data(struct ps_prochandle* ph,
uintptr_t addr, const char *buf , size_t size) {
return false;
}
-// "user" should be a pointer to a user_regs_struct
-static bool process_get_lwp_regs(struct ps_prochandle* ph, pid_t pid, struct user_regs_struct *user) {
+// "user" should be a pointer to a reg
+static bool process_get_lwp_regs(struct ps_prochandle* ph, pid_t pid, struct reg *user) {
// we have already attached to all thread 'pid's, just use ptrace call
// to get regset now. Note that we don't cache regset upfront for processes.
-// Bsd on x86 and sparc are different. On x86 ptrace(PTRACE_GETREGS, ...)
-// uses pointer from 4th argument and ignores 3rd argument. On sparc it uses
-// pointer from 3rd argument and ignores 4th argument
-#if defined(sparc) || defined(sparcv9)
-#define ptrace_getregs(request, pid, addr, data) ptrace(request, pid, addr, data)
-#else
-#define ptrace_getregs(request, pid, addr, data) ptrace(request, pid, data, addr)
-#endif
-
-#ifdef _LP64
-#ifdef PTRACE_GETREGS64
-#define PTRACE_GETREGS_REQ PTRACE_GETREGS64
-#endif
-#else
-#if defined(PTRACE_GETREGS) || defined(PT_GETREGS)
-#define PTRACE_GETREGS_REQ PTRACE_GETREGS
-#endif
-#endif /* _LP64 */
-
-#ifdef PTRACE_GETREGS_REQ
- if (ptrace_getregs(PTRACE_GETREGS_REQ, pid, user, NULL) < 0) {
+ if (ptrace(PT_GETREGS, pid, (caddr_t) user, 0) < 0) {
print_debug("ptrace(PTRACE_GETREGS, ...) failed for lwp %d\n", pid);
return false;
}
return true;
-#else
- print_debug("ptrace(PTRACE_GETREGS, ...) not supported\n");
- return false;
-#endif
+}
+// fill in ptrace_lwpinfo for lid
+static bool process_get_lwp_info(struct ps_prochandle *ph, lwpid_t lwp_id, void *linfo) {
+ errno = 0;
+ ptrace(PT_LWPINFO, lwp_id, linfo, sizeof(struct ptrace_lwpinfo));
+
+ return (errno == 0)? true: false;
}
// attach to a process/thread specified by "pid"
static bool ptrace_attach(pid_t pid) {
- if (ptrace(PTRACE_ATTACH, pid, NULL, NULL) < 0) {
+ if (ptrace(PT_ATTACH, pid, NULL, 0) < 0) {
print_debug("ptrace(PTRACE_ATTACH, ..) failed for %d\n", pid);
return false;
} else {
int ret;
int status;
do {
- // Wait for debuggee to stop.
+ // Wait for debuggee to stop.
ret = waitpid(pid, &status, 0);
- if (ret == -1 && errno == ECHILD) {
- // try cloned process.
- ret = waitpid(pid, &status, __WALL);
- }
if (ret >= 0) {
- if (WIFSTOPPED(status)) {
- // Debuggee stopped.
- return true;
+ if (WIFSTOPPED(status)) {
+ // Debuggee stopped.
+ return true;
} else {
- print_debug("waitpid(): Child process exited/terminated (status = 0x%x)\n", status);
- return false;
- }
+ print_debug("waitpid(): Child process exited/terminated (status = 0x%x)\n", status);
+ return false;
+ }
} else {
- switch (errno) {
- case EINTR:
+ switch (errno) {
+ case EINTR:
continue;
- break;
- case ECHILD:
- print_debug("waitpid() failed. Child process pid (%d) does not exist \n", pid);
- break;
- case EINVAL:
- print_debug("waitpid() failed. Invalid options argument.\n");
- break;
- default:
- print_debug("waitpid() failed. Unexpected error %d\n",errno);
+ break;
+ case ECHILD:
+ print_debug("waitpid() failed. Child process pid (%d) does not exist \n", pid);
+ break;
+ case EINVAL:
+ print_debug("waitpid() failed. Invalid options argument.\n");
+ break;
+ default:
+ print_debug("waitpid() failed. Unexpected error %d\n",errno);
}
return false;
- }
+ }
} while(true);
- }
-}
-
+ }
+}
+
// -------------------------------------------------------
// functions for obtaining library information
// -------------------------------------------------------
+// callback for read_thread_info
+static bool add_new_thread(struct ps_prochandle* ph, pthread_t pthread_id, lwpid_t lwp_id) {
+ return add_thread_info(ph, pthread_id, lwp_id) != NULL;
+}
+
+#if defined(__FreeBSD__) && __FreeBSD_version < 701000
/*
- * splits a string _str_ into substrings with delimiter _delim_ by replacing old * delimiters with _new_delim_ (ideally, '\0'). the address of each substring
- * is stored in array _ptrs_ as the return value. the maximum capacity of _ptrs_ * array is specified by parameter _n_.
- * RETURN VALUE: total number of substrings (always <= _n_)
- * NOTE: string _str_ is modified if _delim_!=_new_delim_
+ * TEXT_START_ADDR from binutils/ld/emulparams/<arch_spec>.sh
+ * Not the most robust but good enough.
*/
-static int split_n_str(char * str, int n, char ** ptrs, char delim, char new_delim)
-{
- int i;
- for(i = 0; i < n; i++) ptrs[i] = NULL;
- if (str == NULL || n < 1 ) return 0;
- i = 0;
+#if defined(amd64) || defined(x86_64)
+#define TEXT_START_ADDR 0x400000
+#elif defined(i386)
+#define TEXT_START_ADDR 0x8048000
+#else
+#error TEXT_START_ADDR not defined
+#endif
- // skipping leading blanks
- while(*str&&*str==delim) str++;
+#define BUF_SIZE (PATH_MAX + NAME_MAX + 1)
- while(*str&&i<n){
- ptrs[i++] = str;
- while(*str&&*str!=delim) str++;
- while(*str&&*str==delim) *(str++) = new_delim;
- }
+uintptr_t linkmap_addr(struct ps_prochandle *ph) {
+ uintptr_t ehdr_addr, phdr_addr, dyn_addr, dmap_addr, lmap_addr;
+ ELF_EHDR ehdr;
+ ELF_PHDR *phdrs, *phdr;
+ ELF_DYN *dyns, *dyn;
+ struct r_debug dmap;
+ unsigned long hdrs_size;
+ unsigned int i;
- return i;
-}
+ /* read ELF_EHDR at TEXT_START_ADDR and validate */
-/*
- * fgets without storing '\n' at the end of the string
- */
-static char * fgets_no_cr(char * buf, int n, FILE *fp)
-{
- char * rslt = fgets(buf, n, fp);
- if (rslt && buf && *buf){
- char *p = strchr(buf, '\0');
- if (*--p=='\n') *p='\0';
- }
- return rslt;
-}
+ ehdr_addr = (uintptr_t)TEXT_START_ADDR;
-// callback for read_thread_info
-static bool add_new_thread(struct ps_prochandle* ph, pthread_t pthread_id, lwpid_t lwp_id) {
- return add_thread_info(ph, pthread_id, lwp_id) != NULL;
+ if (process_read_data(ph, ehdr_addr, (char *)&ehdr, sizeof(ehdr)) != true) {
+ print_debug("process_read_data failed for ehdr_addr %p\n", ehdr_addr);
+ return (0);
+ }
+
+ if (!IS_ELF(ehdr) ||
+ ehdr.e_ident[EI_CLASS] != ELF_TARG_CLASS ||
+ ehdr.e_ident[EI_DATA] != ELF_TARG_DATA ||
+ ehdr.e_ident[EI_VERSION] != EV_CURRENT ||
+ ehdr.e_phentsize != sizeof(ELF_PHDR) ||
+ ehdr.e_version != ELF_TARG_VER ||
+ ehdr.e_machine != ELF_TARG_MACH) {
+ print_debug("not an ELF_EHDR at %p\n", ehdr_addr);
+ return (0);
+ }
+
+ /* allocate space for all ELF_PHDR's and read */
+
+ phdr_addr = ehdr_addr + ehdr.e_phoff;
+ hdrs_size = ehdr.e_phnum * sizeof(ELF_PHDR);
+
+ if ((phdrs = malloc(hdrs_size)) == NULL)
+ return (0);
+
+ if (process_read_data(ph, phdr_addr, (char *)phdrs, hdrs_size) != true) {
+ print_debug("process_read_data failed for phdr_addr %p\n", phdr_addr);
+ return (0);
+ }
+
+ /* find PT_DYNAMIC section */
+
+ for (i = 0, phdr = phdrs; i < ehdr.e_phnum; i++, phdr++) {
+ if (phdr->p_type == PT_DYNAMIC)
+ break;
+ }
+
+ if (i >= ehdr.e_phnum) {
+ print_debug("PT_DYNAMIC section not found!\n");
+ free(phdrs);
+ return (0);
+ }
+
+ /* allocate space and read in ELF_DYN headers */
+
+ dyn_addr = phdr->p_vaddr;
+ hdrs_size = phdr->p_memsz;
+ free(phdrs);
+
+ if ((dyns = malloc(hdrs_size)) == NULL)
+ return (0);
+
+ if (process_read_data(ph, dyn_addr, (char *)dyns, hdrs_size) != true) {
+ print_debug("process_read_data failed for dyn_addr %p\n", dyn_addr);
+ free(dyns);
+ return (0);
+ }
+
+ /* find DT_DEBUG */
+
+ dyn = dyns;
+ while (dyn->d_tag != DT_DEBUG && dyn->d_tag != DT_NULL) {
+ dyn++;
+ }
+
+ if (dyn->d_tag != DT_DEBUG) {
+ print_debug("failed to find DT_DEBUG\n");
+ free(dyns);
+ return (0);
+ }
+
+ /* read struct r_debug into dmap */
+
+ dmap_addr = (uintptr_t)dyn->d_un.d_ptr;
+ free(dyns);
+
+ if (process_read_data(ph, dmap_addr, (char *)&dmap, sizeof(dmap)) != true) {
+ print_debug("process_read_data failed for dmap_addr %p\n", dmap_addr);
+ return (0);
+ }
+
+ lmap_addr = (uintptr_t)dmap.r_map;
+
+ return (lmap_addr);
}
+#endif // __FreeBSD__ && __FreeBSD_version < 701000
static bool read_lib_info(struct ps_prochandle* ph) {
- char fname[32];
- char buf[256];
- FILE *fp = NULL;
+#if defined(__FreeBSD__) && __FreeBSD_version >= 701000
+ struct kinfo_vmentry *freep, *kve;
+ int i, cnt;
- sprintf(fname, "/proc/%d/maps", ph->pid);
- fp = fopen(fname, "r");
- if (fp == NULL) {
- print_debug("can't open /proc/%d/maps file\n", ph->pid);
- return false;
+ freep = kinfo_getvmmap(ph->pid, &cnt);
+ if (freep == NULL) {
+ print_debug("can't get vm map for pid\n", ph->pid);
+ return false;
}
- while(fgets_no_cr(buf, 256, fp)){
- char * word[6];
- int nwords = split_n_str(buf, 6, word, ' ', '\0');
- if (nwords > 5 && find_lib(ph, word[5]) == false) {
- intptr_t base;
- lib_info* lib;
- sscanf(word[0], "%lx", &base);
- if ((lib = add_lib_info(ph, word[5], (uintptr_t)base)) == NULL)
+ for (i = 0; i < cnt; i++) {
+ kve = &freep[i];
+ if ((kve->kve_flags & KVME_FLAG_COW) &&
+ kve->kve_path != NULL &&
+ strlen(kve->kve_path) > 0) {
+
+ if (find_lib(ph, kve->kve_path) == false) {
+ lib_info* lib;
+ if ((lib = add_lib_info(ph, kve->kve_path,
+ (uintptr_t) kve->kve_start)) == NULL)
continue; // ignore, add_lib_info prints error
- // we don't need to keep the library open, symtab is already
- // built. Only for core dump we need to keep the fd open.
- close(lib->fd);
- lib->fd = -1;
+ // we don't need to keep the library open, symtab is already
+ // built. Only for core dump we need to keep the fd open.
+ close(lib->fd);
+ lib->fd = -1;
+ }
}
}
- fclose(fp);
+
+ free(freep);
+
return true;
+#else
+ char *l_name;
+ struct link_map *lmap;
+ uintptr_t lmap_addr;
+
+ if ((l_name = malloc(BUF_SIZE)) == NULL)
+ return false;
+
+ if ((lmap = malloc(sizeof(*lmap))) == NULL) {
+ free(l_name);
+ return false;
+ }
+
+ lmap_addr = linkmap_addr(ph);
+
+ if (lmap_addr == 0) {
+ free(l_name);
+ free(lmap);
+ return false;
+ }
+
+ do {
+ if (process_read_data(ph, lmap_addr, (char *)lmap, sizeof(*lmap)) != true) {
+ print_debug("process_read_data failed for lmap_addr %p\n", lmap_addr);
+ free (l_name);
+ free (lmap);
+ return false;
+ }
+
+ if (process_read_data(ph, (uintptr_t)lmap->l_name, l_name,
+ BUF_SIZE) != true) {
+ print_debug("process_read_data failed for lmap->l_name %p\n",
+ lmap->l_name);
+ free (l_name);
+ free (lmap);
+ return false;
+ }
+
+ if (find_lib(ph, l_name) == false) {
+ lib_info* lib;
+ if ((lib = add_lib_info(ph, l_name,
+ (uintptr_t) lmap->l_addr)) == NULL)
+ continue; // ignore, add_lib_info prints error
+
+ // we don't need to keep the library open, symtab is already
+ // built. Only for core dump we need to keep the fd open.
+ close(lib->fd);
+ lib->fd = -1;
+ }
+ lmap_addr = (uintptr_t)lmap->l_next;
+ } while (lmap->l_next != NULL);
+
+ free (l_name);
+ free (lmap);
+
+ return true;
+#endif
}
// detach a given pid
static bool ptrace_detach(pid_t pid) {
- if (pid && ptrace(PTRACE_DETACH, pid, NULL, NULL) < 0) {
+ if (pid && ptrace(PT_DETACH, pid, (caddr_t)1, 0) < 0) {
print_debug("ptrace(PTRACE_DETACH, ..) failed for %d\n", pid);
return false;
} else {
return true;
- }
+ }
}
-// detach all pids of a ps_prochandle
-static void detach_all_pids(struct ps_prochandle* ph) {
- thread_info* thr = ph->threads;
- while (thr) {
- ptrace_detach(thr->lwp_id);
- thr = thr->next;
- }
-}
-
static void process_cleanup(struct ps_prochandle* ph) {
- detach_all_pids(ph);
+ ptrace_detach(ph->pid);
}
static ps_prochandle_ops process_ops = {
.release= process_cleanup,
.p_pread= process_read_data,
.p_pwrite= process_write_data,
- .get_lwp_regs= process_get_lwp_regs
+ .get_lwp_regs= process_get_lwp_regs,
+ .get_lwp_info= process_get_lwp_info
};
// attach to the process. One and only one exposed stuff
@@ -321,21 +431,14 @@ struct ps_prochandle* Pgrab(pid_t pid) {
// read library info and symbol tables, must do this before attaching threads,
// as the symbols in the pthread library will be used to figure out
// the list of threads within the same process.
- read_lib_info(ph);
-
+ if (read_lib_info(ph) != true) {
+ ptrace_detach(pid);
+ free(ph);
+ return NULL;
+ }
+
// read thread info
read_thread_info(ph, add_new_thread);
- // attach to the threads
- thr = ph->threads;
- while (thr) {
- // don't attach to the main thread again
- if (ph->pid != thr->lwp_id && ptrace_attach(thr->lwp_id) != true) {
- // even if one attach fails, we get return NULL
- Prelease(ph);
- return NULL;
- }
- thr = thr->next;
- }
return ph;
}

View File

@ -0,0 +1,11 @@
$OpenBSD: patch-hotspot_agent_src_os_bsd_salibelf_c,v 1.1 2009/06/10 19:01:09 kurt Exp $
--- hotspot/agent/src/os/bsd/salibelf.c.orig Tue Jun 2 13:08:38 2009
+++ hotspot/agent/src/os/bsd/salibelf.c Tue Jun 2 13:08:43 2009
@@ -25,6 +25,7 @@
#include "salibelf.h"
#include <stdlib.h>
#include <unistd.h>
+#include <string.h>
extern void print_debug(const char*,...);

View File

@ -0,0 +1,67 @@
$OpenBSD: patch-hotspot_agent_src_os_bsd_symtab_c,v 1.1 2009/06/10 19:01:09 kurt Exp $
--- hotspot/agent/src/os/bsd/symtab.c.orig Tue Jun 2 13:08:54 2009
+++ hotspot/agent/src/os/bsd/symtab.c Tue Jun 2 13:09:00 2009
@@ -23,10 +23,10 @@
*/
#include <unistd.h>
-#include <sys/procfs.h>
#include <search.h>
#include <stdlib.h>
#include <string.h>
+#include "hsearch_r.h"
#include "symtab.h"
#include "salibelf.h"
@@ -56,7 +56,6 @@ typedef struct symtab {
// read symbol table from given fd.
struct symtab* build_symtab(int fd) {
ELF_EHDR ehdr;
- char *names = NULL;
struct symtab* symtab = NULL;
// Reading of elf header
@@ -65,7 +64,9 @@ struct symtab* build_symtab(int fd) {
ELF_SHDR* shbuf = NULL;
ELF_SHDR* cursct = NULL;
ELF_PHDR* phbuf = NULL;
- ELF_PHDR* phdr = NULL;
+ int symtab_found = 0;
+ int dynsym_found = 0;
+ uint32_t symsection = SHT_SYMTAB;
uintptr_t baseaddr = (uintptr_t)-1;
@@ -90,18 +91,30 @@ struct symtab* build_symtab(int fd) {
for (cursct = shbuf, cnt = 0; cnt < ehdr.e_shnum; cnt++) {
scn_cache[cnt].c_shdr = cursct;
- if (cursct->sh_type == SHT_SYMTAB || cursct->sh_type == SHT_STRTAB) {
+ if (cursct->sh_type == SHT_SYMTAB ||
+ cursct->sh_type == SHT_STRTAB ||
+ cursct->sh_type == SHT_DYNSYM) {
if ( (scn_cache[cnt].c_data = read_section_data(fd, &ehdr, cursct)) == NULL) {
goto quit;
}
}
+
+ if (cursct->sh_type == SHT_SYMTAB)
+ symtab_found++;
+
+ if (cursct->sh_type == SHT_DYNSYM)
+ dynsym_found++;
+
cursct++;
}
+ if (!symtab_found && dynsym_found)
+ symsection = SHT_DYNSYM;
+
for (cnt = 1; cnt < ehdr.e_shnum; cnt++) {
ELF_SHDR *shdr = scn_cache[cnt].c_shdr;
- if (shdr->sh_type == SHT_SYMTAB) {
+ if (shdr->sh_type == symsection) {
ELF_SYM *syms;
int j, n, rslt;
size_t size;

View File

@ -0,0 +1,12 @@
$OpenBSD: patch-hotspot_agent_src_os_bsd_test_c,v 1.1 2009/06/10 19:01:09 kurt Exp $
--- hotspot/agent/src/os/bsd/test.c.orig Tue Jun 2 13:09:43 2009
+++ hotspot/agent/src/os/bsd/test.c Tue Jun 2 13:09:50 2009
@@ -44,7 +44,7 @@ int main(int argc, char** argv) {
}
default: {
- printf("usage %s <pid> or %s <exec file> <core file>\n");
+ fprintf(stderr, "usage %s <pid> or %s <exec file> <core file>\n", argv[0], argv[0]);
return 1;
}
}

View File

@ -0,0 +1,72 @@
$OpenBSD: patch-hotspot_agent_src_share_classes_sun_jvm_hotspot_HotSpotAgent_java,v 1.1 2009/06/10 19:01:09 kurt Exp $
--- hotspot/agent/src/share/classes/sun/jvm/hotspot/HotSpotAgent.java.orig Tue Jun 2 12:33:16 2009
+++ hotspot/agent/src/share/classes/sun/jvm/hotspot/HotSpotAgent.java Tue Jun 2 12:33:28 2009
@@ -28,6 +28,7 @@ import java.io.PrintStream;
import java.net.*;
import java.rmi.*;
import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.debugger.bsd.*;
import sun.jvm.hotspot.debugger.dbx.*;
import sun.jvm.hotspot.debugger.proc.*;
import sun.jvm.hotspot.debugger.remote.*;
@@ -337,6 +338,8 @@ public class HotSpotAgent {
setupDebuggerWin32();
} else if (os.equals("linux")) {
setupDebuggerLinux();
+ } else if (os.equals("bsd")) {
+ setupDebuggerBsd();
} else {
// Add support for more operating systems here
throw new DebuggerException("Operating system " + os + " not yet supported");
@@ -392,6 +395,10 @@ public class HotSpotAgent {
db = new HotSpotTypeDataBase(machDesc,
new LinuxVtblAccess(debugger, jvmLibNames),
debugger, jvmLibNames);
+ } else if (os.equals("bsd")) {
+ db = new HotSpotTypeDataBase(machDesc,
+ new BsdVtblAccess(debugger, jvmLibNames),
+ debugger, jvmLibNames);
} else {
throw new DebuggerException("OS \"" + os + "\" not yet supported (no VtblAccess yet)");
}
@@ -557,6 +564,8 @@ public class HotSpotAgent {
setupJVMLibNamesWin32();
} else if (os.equals("linux")) {
setupJVMLibNamesLinux();
+ } else if (os.equals("bsd")) {
+ setupJVMLibNamesBsd();
} else {
throw new RuntimeException("Unknown OS type");
}
@@ -635,6 +644,31 @@ public class HotSpotAgent {
}
private void setupJVMLibNamesLinux() {
+ jvmLibNames = new String[] { "libjvm.so", "libjvm_g.so" };
+ }
+
+ //
+ // BSD
+ //
+
+ private void setupDebuggerBsd() {
+ setupJVMLibNamesBsd();
+
+ if (cpu.equals("x86")) {
+ machDesc = new MachineDescriptionIntelX86();
+ } else if (cpu.equals("amd64")) {
+ machDesc = new MachineDescriptionAMD64();
+ } else {
+ throw new DebuggerException("BSD only supported on x86/amd64");
+ }
+
+ BsdDebuggerLocal dbg = new BsdDebuggerLocal(machDesc, !isServer);
+ debugger = dbg;
+
+ attachDebugger();
+ }
+
+ private void setupJVMLibNamesBsd() {
jvmLibNames = new String[] { "libjvm.so", "libjvm_g.so" };
}

View File

@ -0,0 +1,74 @@
$OpenBSD: patch-hotspot_agent_src_share_classes_sun_jvm_hotspot_bugspot_BugSpotAgent_java,v 1.1 2009/06/10 19:01:09 kurt Exp $
--- hotspot/agent/src/share/classes/sun/jvm/hotspot/bugspot/BugSpotAgent.java.orig Tue Jun 2 12:34:28 2009
+++ hotspot/agent/src/share/classes/sun/jvm/hotspot/bugspot/BugSpotAgent.java Tue Jun 2 12:34:41 2009
@@ -29,6 +29,7 @@ import java.net.*;
import java.rmi.*;
import sun.jvm.hotspot.*;
import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.debugger.bsd.*;
import sun.jvm.hotspot.debugger.dbx.*;
import sun.jvm.hotspot.debugger.proc.*;
import sun.jvm.hotspot.debugger.cdbg.*;
@@ -516,6 +517,8 @@ public class BugSpotAgent {
setupDebuggerWin32();
} else if (os.equals("linux")) {
setupDebuggerLinux();
+ } else if (os.equals("bsd")) {
+ setupDebuggerBsd();
} else {
// Add support for more operating systems here
throw new DebuggerException("Operating system " + os + " not yet supported");
@@ -567,6 +570,9 @@ public class BugSpotAgent {
} else if (os.equals("linux")) {
db = new HotSpotTypeDataBase(machDesc, new LinuxVtblAccess(debugger, jvmLibNames),
debugger, jvmLibNames);
+ } else if (os.equals("bsd")) {
+ db = new HotSpotTypeDataBase(machDesc, new BsdVtblAccess(debugger, jvmLibNames),
+ debugger, jvmLibNames);
} else {
throw new DebuggerException("OS \"" + os + "\" not yet supported (no VtblAccess implemented yet)");
}
@@ -739,6 +745,8 @@ public class BugSpotAgent {
setupJVMLibNamesWin32();
} else if (os.equals("linux")) {
setupJVMLibNamesLinux();
+ } else if (os.equals("bsd")) {
+ setupJVMLibNamesBsd();
} else {
throw new RuntimeException("Unknown OS type");
}
@@ -818,6 +826,34 @@ public class BugSpotAgent {
}
private void setupJVMLibNamesLinux() {
+ // same as solaris
+ setupJVMLibNamesSolaris();
+ }
+
+ //
+ // BSD
+ //
+
+ private void setupDebuggerBsd() {
+ setupJVMLibNamesBsd();
+
+ if (cpu.equals("x86")) {
+ machDesc = new MachineDescriptionIntelX86();
+ } else if (cpu.equals("amd64")) {
+ machDesc = new MachineDescriptionAMD64();
+ } else {
+ throw new DebuggerException("Bsd only supported on x86/amd64");
+ }
+
+ // Note we do not use a cache for the local debugger in server
+ // mode; it will be taken care of on the client side (once remote
+ // debugging is implemented).
+
+ debugger = new BsdDebuggerLocal(machDesc, !isServer);
+ attachDebugger();
+ }
+
+ private void setupJVMLibNamesBsd() {
// same as solaris
setupJVMLibNamesSolaris();
}

View File

@ -0,0 +1,28 @@
$OpenBSD: patch-hotspot_agent_src_share_classes_sun_jvm_hotspot_debugger_bsd_BsdCDebugger_java,v 1.1 2009/06/10 19:01:09 kurt Exp $
--- hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/BsdCDebugger.java.orig Tue Jun 2 13:10:15 2009
+++ hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/BsdCDebugger.java Tue Jun 2 13:10:31 2009
@@ -30,10 +30,8 @@ import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.debugger.cdbg.*;
import sun.jvm.hotspot.debugger.x86.*;
import sun.jvm.hotspot.debugger.amd64.*;
-import sun.jvm.hotspot.debugger.sparc.*;
import sun.jvm.hotspot.debugger.bsd.x86.*;
import sun.jvm.hotspot.debugger.bsd.amd64.*;
-import sun.jvm.hotspot.debugger.bsd.sparc.*;
import sun.jvm.hotspot.utilities.*;
class BsdCDebugger implements CDebugger {
@@ -99,13 +97,6 @@ class BsdCDebugger implements CDebugger {
Address pc = context.getRegisterAsAddress(AMD64ThreadContext.RIP);
if (pc == null) return null;
return new BsdAMD64CFrame(dbg, rbp, pc);
- } else if (cpu.equals("sparc")) {
- SPARCThreadContext context = (SPARCThreadContext) thread.getContext();
- Address sp = context.getRegisterAsAddress(SPARCThreadContext.R_SP);
- if (sp == null) return null;
- Address pc = context.getRegisterAsAddress(SPARCThreadContext.R_O7);
- if (pc == null) return null;
- return new BsdSPARCCFrame(dbg, sp, pc, BsdDebuggerLocal.getAddressSize());
} else {
throw new DebuggerException(cpu + " is not yet supported");
}

View File

@ -0,0 +1,24 @@
$OpenBSD: patch-hotspot_agent_src_share_classes_sun_jvm_hotspot_debugger_bsd_BsdThreadContextFactory_java,v 1.1 2009/06/10 19:01:09 kurt Exp $
--- hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/BsdThreadContextFactory.java.orig Tue Jun 2 13:10:53 2009
+++ hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/BsdThreadContextFactory.java Tue Jun 2 13:11:11 2009
@@ -26,9 +26,7 @@ package sun.jvm.hotspot.debugger.bsd;
import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.debugger.bsd.amd64.*;
-import sun.jvm.hotspot.debugger.bsd.ia64.*;
import sun.jvm.hotspot.debugger.bsd.x86.*;
-import sun.jvm.hotspot.debugger.bsd.sparc.*;
class BsdThreadContextFactory {
static ThreadContext createThreadContext(BsdDebugger dbg) {
@@ -37,10 +35,6 @@ class BsdThreadContextFactory {
return new BsdX86ThreadContext(dbg);
} else if (cpu.equals("amd64")) {
return new BsdAMD64ThreadContext(dbg);
- } else if (cpu.equals("ia64")) {
- return new BsdIA64ThreadContext(dbg);
- } else if (cpu.equals("sparc")) {
- return new BsdSPARCThreadContext(dbg);
} else {
throw new RuntimeException("cpu " + cpu + " is not yet supported");
}

View File

@ -0,0 +1,26 @@
$OpenBSD: patch-hotspot_agent_src_share_classes_sun_jvm_hotspot_runtime_Threads_java,v 1.1 2009/06/10 19:01:09 kurt Exp $
--- hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/Threads.java.orig Tue Jun 2 12:35:39 2009
+++ hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/Threads.java Tue Jun 2 12:35:52 2009
@@ -37,6 +37,8 @@ import sun.jvm.hotspot.runtime.linux_x86.LinuxX86JavaT
import sun.jvm.hotspot.runtime.linux_ia64.LinuxIA64JavaThreadPDAccess;
import sun.jvm.hotspot.runtime.linux_amd64.LinuxAMD64JavaThreadPDAccess;
import sun.jvm.hotspot.runtime.linux_sparc.LinuxSPARCJavaThreadPDAccess;
+import sun.jvm.hotspot.runtime.bsd_x86.BsdX86JavaThreadPDAccess;
+import sun.jvm.hotspot.runtime.bsd_amd64.BsdAMD64JavaThreadPDAccess;
import sun.jvm.hotspot.utilities.*;
public class Threads {
@@ -90,7 +92,12 @@ public class Threads {
} else if (cpu.equals("sparc")) {
access = new LinuxSPARCJavaThreadPDAccess();
}
-
+ } else if (os.equals("bsd")) {
+ if (cpu.equals("x86")) {
+ access = new BsdX86JavaThreadPDAccess();
+ } else if (cpu.equals("amd64")) {
+ access = new BsdAMD64JavaThreadPDAccess();
+ }
}
if (access == null) {

View File

@ -0,0 +1,63 @@
$OpenBSD: patch-hotspot_agent_src_share_classes_sun_jvm_hotspot_runtime_bsd_BsdSignals_java,v 1.1 2009/06/10 19:01:09 kurt Exp $
--- hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/bsd/BsdSignals.java.orig Tue Jun 2 13:11:43 2009
+++ hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/bsd/BsdSignals.java Tue Jun 2 13:11:54 2009
@@ -28,37 +28,36 @@ public class BsdSignals {
private static String[] signalNames = {
"", /* No signal 0 */
"SIGHUP", /* hangup */
- "SIGINT", /* interrupt (rubout) */
- "SIGQUIT", /* quit (ASCII FS) */
- "SIGILL", /* illegal instruction (not reset when caught) */
+ "SIGINT", /* interrupt */
+ "SIGQUIT", /* quit */
+ "SIGILL", /* illegal instr. (not reset when caught) */
"SIGTRAP", /* trace trap (not reset when caught) */
- "SIGABRT", /* used by abort, replace SIGIOT in the future */
- "SIGIOT",
- "SIGBUS",
+ "SIGABRT", /* abort() */
+ "SIGEMT", /* EMT instruction */
"SIGFPE", /* floating point exception */
"SIGKILL", /* kill (cannot be caught or ignored) */
- "SIGUSR1", /* user defined signal 1 */
+ "SIGBUS", /* bus error */
"SIGSEGV", /* segmentation violation */
- "SIGUSR2", /* user defined signal 2 */
+ "SIGSYS", /* non-existent system call invoked */
"SIGPIPE", /* write on a pipe with no one to read it */
"SIGALRM", /* alarm clock */
"SIGTERM", /* software termination signal from kill */
- "SIGSTKFLT",
- "SIGCHLD", /* child status change alias */
- "SIGCONT", /* stopped process has been continued */
- "SIGSTOP", /* stop (cannot be caught or ignored) */
- "SIGTSTP", /* user stop requested from tty */
- "SIGTTIN", /* background tty read attempted */
- "SIGTTOU", /* background tty write attempted */
- "SIGURG", /* urgent socket condition */
- "SIGXCPU", /* exceeded cpu limit */
+ "SIGURG", /* urgent condition on IO channel */
+ "SIGSTOP", /* sendable stop signal not from tty */
+ "SIGTSTP", /* stop signal from tty */
+ "SIGCONT", /* continue a stopped process */
+ "SIGCHLD", /* to parent on child stop or exit */
+ "SIGTTIN", /* to readers pgrp upon background tty read */
+ "SIGTTOU", /* like TTIN if (tp->t_local&LTOSTOP) */
+ "SIGIO", /* input/output possible signal */
+ "SIGXCPU", /* exceeded CPU time limit */
"SIGXFSZ", /* exceeded file size limit */
- "SIGVTALRM", /* virtual timer expired */
- "SIGPROF", /* profiling timer expired */
- "SIGWINCH", /* window size change */
- "SIGPOLL", /* pollable event occured */
- "SIGPWR", /* power-fail restart */
- "SIGSYS"
+ "SIGVTALRM", /* virtual time alarm */
+ "SIGPROF", /* profiling time alarm */
+ "SIGWINCH", /* window size changes */
+ "SIGINFO", /* information request */
+ "SIGUSR1", /* user defined signal 1 */
+ "SIGUSR2" /* user defined signal 2 */
};
public static String getSignalName(int sigNum) {

View File

@ -0,0 +1,63 @@
$OpenBSD: patch-hotspot_agent_src_share_classes_sun_jvm_hotspot_runtime_bsd_x86_BsdSignals_java,v 1.1 2009/06/10 19:01:09 kurt Exp $
--- hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/bsd_x86/BsdSignals.java.orig Tue Jun 2 13:12:16 2009
+++ hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/bsd_x86/BsdSignals.java Tue Jun 2 13:12:25 2009
@@ -28,37 +28,36 @@ public class BsdSignals {
private static String[] signalNames = {
"", /* No signal 0 */
"SIGHUP", /* hangup */
- "SIGINT", /* interrupt (rubout) */
- "SIGQUIT", /* quit (ASCII FS) */
- "SIGILL", /* illegal instruction (not reset when caught) */
+ "SIGINT", /* interrupt */
+ "SIGQUIT", /* quit */
+ "SIGILL", /* illegal instr. (not reset when caught) */
"SIGTRAP", /* trace trap (not reset when caught) */
- "SIGABRT", /* used by abort, replace SIGIOT in the future */
- "SIGIOT",
- "SIGBUS",
+ "SIGABRT", /* abort() */
+ "SIGEMT", /* EMT instruction */
"SIGFPE", /* floating point exception */
"SIGKILL", /* kill (cannot be caught or ignored) */
- "SIGUSR1", /* user defined signal 1 */
+ "SIGBUS", /* bus error */
"SIGSEGV", /* segmentation violation */
- "SIGUSR2", /* user defined signal 2 */
+ "SIGSYS", /* non-existent system call invoked */
"SIGPIPE", /* write on a pipe with no one to read it */
"SIGALRM", /* alarm clock */
"SIGTERM", /* software termination signal from kill */
- "SIGSTKFLT",
- "SIGCHLD", /* child status change alias */
- "SIGCONT", /* stopped process has been continued */
- "SIGSTOP", /* stop (cannot be caught or ignored) */
- "SIGTSTP", /* user stop requested from tty */
- "SIGTTIN", /* background tty read attempted */
- "SIGTTOU", /* background tty write attempted */
- "SIGURG", /* urgent socket condition */
- "SIGXCPU", /* exceeded cpu limit */
+ "SIGURG", /* urgent condition on IO channel */
+ "SIGSTOP", /* sendable stop signal not from tty */
+ "SIGTSTP", /* stop signal from tty */
+ "SIGCONT", /* continue a stopped process */
+ "SIGCHLD", /* to parent on child stop or exit */
+ "SIGTTIN", /* to readers pgrp upon background tty read */
+ "SIGTTOU", /* like TTIN if (tp->t_local&LTOSTOP) */
+ "SIGIO", /* input/output possible signal */
+ "SIGXCPU", /* exceeded CPU time limit */
"SIGXFSZ", /* exceeded file size limit */
- "SIGVTALRM", /* virtual timer expired */
- "SIGPROF", /* profiling timer expired */
- "SIGWINCH", /* window size change */
- "SIGPOLL", /* pollable event occured */
- "SIGPWR", /* power-fail restart */
- "SIGSYS"
+ "SIGVTALRM", /* virtual time alarm */
+ "SIGPROF", /* profiling time alarm */
+ "SIGWINCH", /* window size changes */
+ "SIGINFO", /* information request */
+ "SIGUSR1", /* user defined signal 1 */
+ "SIGUSR2" /* user defined signal 2 */
};
public static String getSignalName(int sigNum) {

View File

@ -0,0 +1,18 @@
$OpenBSD: patch-hotspot_agent_src_share_classes_sun_jvm_hotspot_utilities_PlatformInfo_java,v 1.1 2009/06/10 19:01:09 kurt Exp $
--- hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/PlatformInfo.java.orig Tue Jun 2 12:36:27 2009
+++ hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/PlatformInfo.java Tue Jun 2 12:36:38 2009
@@ -37,6 +37,14 @@ public class PlatformInfo {
return "solaris";
} else if (os.equals("Linux")) {
return "linux";
+ } else if (os.equals("FreeBSD")) {
+ return "bsd";
+ } else if (os.equals("NetBSD")) {
+ return "bsd";
+ } else if (os.equals("OpenBSD")) {
+ return "bsd";
+ } else if (os.equals("Darwin")) {
+ return "bsd";
} else if (os.startsWith("Windows")) {
return "win32";
} else {

View File

@ -1,6 +1,6 @@
$OpenBSD: patch-hotspot_make_bsd_makefiles_defs_make,v 1.2 2009/05/23 03:03:24 kurt Exp $
--- hotspot/make/bsd/makefiles/defs.make.orig Sat May 16 23:21:09 2009
+++ hotspot/make/bsd/makefiles/defs.make Mon May 18 08:17:30 2009
$OpenBSD: patch-hotspot_make_bsd_makefiles_defs_make,v 1.3 2009/06/10 19:01:09 kurt Exp $
--- hotspot/make/bsd/makefiles/defs.make.orig Sat May 30 11:21:10 2009
+++ hotspot/make/bsd/makefiles/defs.make Tue Jun 2 12:37:10 2009
@@ -28,6 +28,14 @@
SLASH_JAVA ?= /java
@ -63,7 +63,7 @@ $OpenBSD: patch-hotspot_make_bsd_makefiles_defs_make,v 1.2 2009/05/23 03:03:24 k
endif
JDK_INCLUDE_SUBDIR=bsd
@@ -95,19 +113,11 @@ VM_DEBUG=jvmg
@@ -95,19 +113,13 @@ VM_DEBUG=jvmg
EXPORT_LIST += $(EXPORT_DOCS_DIR)/platform/jvmti/jvmti.html
EXPORT_SERVER_DIR = $(EXPORT_JRE_LIB_ARCH_DIR)/server
EXPORT_LIST += $(EXPORT_SERVER_DIR)/Xusage.txt
@ -87,3 +87,5 @@ $OpenBSD: patch-hotspot_make_bsd_makefiles_defs_make,v 1.2 2009/05/23 03:03:24 k
+ EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjsig.$(LIBRARY_SUFFIX)
+ EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.$(LIBRARY_SUFFIX)
endif
+EXPORT_LIST += $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.$(LIBRARY_SUFFIX)
+EXPORT_LIST += $(EXPORT_LIB_DIR)/sa-jdi.jar

View File

@ -0,0 +1,12 @@
$OpenBSD: patch-hotspot_make_bsd_makefiles_launcher_make,v 1.1 2009/06/10 19:01:09 kurt Exp $
--- hotspot/make/bsd/makefiles/launcher.make.orig Tue Jun 2 12:37:33 2009
+++ hotspot/make/bsd/makefiles/launcher.make Tue Jun 2 12:37:40 2009
@@ -44,7 +44,7 @@ ifeq ($(LINK_INTO),AOUT)
LIBS_LAUNCHER += $(STATIC_STDCXX) $(LIBS)
else
LAUNCHER.o = launcher.o
- LFLAGS_LAUNCHER += -L `pwd`
+ LFLAGS_LAUNCHER += -L`pwd`
LIBS_LAUNCHER += -l$(JVM) $(LIBS)
endif

View File

@ -1,7 +1,7 @@
$OpenBSD: patch-hotspot_make_bsd_makefiles_saproc_make,v 1.2 2009/05/23 03:03:24 kurt Exp $
--- hotspot/make/bsd/makefiles/saproc.make.orig Fri May 15 16:25:29 2009
+++ hotspot/make/bsd/makefiles/saproc.make Fri May 15 17:08:59 2009
@@ -26,8 +26,13 @@
$OpenBSD: patch-hotspot_make_bsd_makefiles_saproc_make,v 1.3 2009/06/10 19:01:09 kurt Exp $
--- hotspot/make/bsd/makefiles/saproc.make.orig Sat May 30 11:21:11 2009
+++ hotspot/make/bsd/makefiles/saproc.make Tue Jun 2 12:37:59 2009
@@ -26,18 +26,30 @@
# libsaproc[_g].so: serviceability agent
SAPROC = saproc$(G_SUFFIX)
@ -16,17 +16,46 @@ $OpenBSD: patch-hotspot_make_bsd_makefiles_saproc_make,v 1.2 2009/05/23 03:03:24
AGENT_DIR = $(GAMMADIR)/agent
SASRCDIR = $(AGENT_DIR)/src/os/$(Platform_os_family)
@@ -43,11 +48,11 @@ SAMAPFILE = $(SASRCDIR)/mapfile
DEST_SAPROC = $(JDK_LIBDIR)/$(LIBSAPROC)
+ifeq ($(OS_VENDOR), FreeBSD)
SASRCFILES = $(SASRCDIR)/salibelf.c \
$(SASRCDIR)/symtab.c \
$(SASRCDIR)/libproc_impl.c \
$(SASRCDIR)/ps_proc.c \
$(SASRCDIR)/ps_core.c \
+ $(SASRCDIR)/hsearch_r.c \
$(SASRCDIR)/BsdDebuggerLocal.c
+SALIBS = -lutil -lthread_db
+else
+SASRCFILES = $(SASRCDIR)/StubDebuggerLocal.c
+SALIBS =
+endif
-# if $(AGENT_DIR) does not exist, we don't build SA
+# if $(SASRCDIR) does not exist, we don't build SA
# also, we don't build SA on Itanium.
SAMAPFILE = $(SASRCDIR)/mapfile
checkAndBuildSA:
- $(QUIETLY) if [ -d $(AGENT_DIR) -a "$(SRCARCH)" != "ia64" ] ; then \
+ $(QUIETLY) if [ -d $(SASRCDIR) -a "$(SRCARCH)" != "ia64" ] ; then \
@@ -51,7 +63,10 @@ checkAndBuildSA:
$(MAKE) -f vm.make $(LIBSAPROC); \
fi
-SA_LFLAGS = $(MAPFLAG:FILENAME=$(SAMAPFILE)) $(LDFLAGS_HASH_STYLE)
+ifneq ($(OS_VENDOR), Darwin)
+SA_LFLAGS = $(MAPFLAG:FILENAME=$(SAMAPFILE))
+endif
+SA_LFLAGS += $(LDFLAGS_HASH_STYLE)
$(LIBSAPROC): $(SASRCFILES) $(SAMAPFILE)
$(QUIETLY) if [ "$(BOOT_JAVA_HOME)" = "" ]; then \
@@ -64,11 +79,11 @@ $(LIBSAPROC): $(SASRCFILES) $(SAMAPFILE)
-I$(SASRCDIR) \
-I$(GENERATED) \
-I$(BOOT_JAVA_HOME)/include \
- -I$(BOOT_JAVA_HOME)/include/$(Platform_os_family) \
+ -I$(BOOT_JAVA_HOME)/include/$(shell uname -s | tr "[:upper:]" "[:lower:]") \
$(SASRCFILES) \
$(SA_LFLAGS) \
-o $@ \
- -lthread_db
+ $(SALIBS)
install_saproc: checkAndBuildSA
$(QUIETLY) if [ -e $(LIBSAPROC) ] ; then \

View File

@ -0,0 +1,23 @@
$OpenBSD: patch-hotspot_make_sa_files,v 1.1 2009/06/10 19:01:09 kurt Exp $
--- hotspot/make/sa.files.orig Tue Jun 2 12:38:13 2009
+++ hotspot/make/sa.files Tue Jun 2 12:38:18 2009
@@ -50,6 +50,9 @@ $(AGENT_SRC_DIR)/sun/jvm/hotspot/code/*.java \
$(AGENT_SRC_DIR)/sun/jvm/hotspot/compiler/*.java \
$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/*.java \
$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/amd64/*.java \
+$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/bsd/*.java \
+$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/bsd/amd64/*.java \
+$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/bsd/x86/*.java \
$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/cdbg/*.java \
$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/cdbg/basic/*.java \
$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/cdbg/basic/x86/*.java \
@@ -95,6 +98,9 @@ $(AGENT_SRC_DIR)/sun/jvm/hotspot/oops/*.java
AGENT_FILES2 = \
$(AGENT_SRC_DIR)/sun/jvm/hotspot/runtime/*.java \
$(AGENT_SRC_DIR)/sun/jvm/hotspot/runtime/amd64/*.java \
+$(AGENT_SRC_DIR)/sun/jvm/hotspot/runtime/bsd/*.java \
+$(AGENT_SRC_DIR)/sun/jvm/hotspot/runtime/bsd_amd64/*.java \
+$(AGENT_SRC_DIR)/sun/jvm/hotspot/runtime/bsd_x86/*.java \
$(AGENT_SRC_DIR)/sun/jvm/hotspot/runtime/ia64/*.java \
$(AGENT_SRC_DIR)/sun/jvm/hotspot/runtime/linux/*.java \
$(AGENT_SRC_DIR)/sun/jvm/hotspot/runtime/linux_amd64/*.java \

View File

@ -1,7 +1,7 @@
$OpenBSD: patch-hotspot_src_os_bsd_vm_hpi_bsd_hpp,v 1.3 2009/01/04 23:25:16 kurt Exp $
--- hotspot/src/os/bsd/vm/hpi_bsd.hpp.orig Sat Aug 2 16:12:29 2008
+++ hotspot/src/os/bsd/vm/hpi_bsd.hpp Sat Aug 2 16:12:52 2008
@@ -36,26 +36,22 @@
$OpenBSD: patch-hotspot_src_os_bsd_vm_hpi_bsd_hpp,v 1.4 2009/06/10 19:01:09 kurt Exp $
--- hotspot/src/os/bsd/vm/hpi_bsd.hpp.orig Tue Jun 2 13:44:43 2009
+++ hotspot/src/os/bsd/vm/hpi_bsd.hpp Wed Jun 3 16:06:36 2009
@@ -36,7 +36,7 @@
// HPI_FileInterface
inline int hpi::close(int fd) {
@ -10,20 +10,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_hpi_bsd_hpp,v 1.3 2009/01/04 23:25:16 kurt
}
inline size_t hpi::read(int fd, void *buf, unsigned int nBytes) {
- size_t res;
- RESTARTABLE( (size_t) ::read(fd, buf, (size_t) nBytes), res);
- return res;
+ INTERRUPTIBLE_RETURN_INT(::read(fd, buf, (size_t) nBytes), os::Bsd::clear_interrupted);
}
inline size_t hpi::write(int fd, const void *buf, unsigned int nBytes) {
- size_t res;
- RESTARTABLE((size_t) ::write(fd, buf, (size_t) nBytes), res);
- return res;
+ INTERRUPTIBLE_RETURN_INT(::write(fd, buf, (size_t) nBytes), os::Bsd::clear_interrupted);
}
@@ -55,7 +55,7 @@ inline size_t hpi::write(int fd, const void *buf, unsi
// HPI_SocketInterface
inline int hpi::socket_close(int fd) {
@ -32,82 +19,19 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_hpi_bsd_hpp,v 1.3 2009/01/04 23:25:16 kurt
}
inline int hpi::socket(int domain, int type, int protocol) {
@@ -63,11 +59,11 @@ inline int hpi::socket(int domain, int type, int proto
}
inline int hpi::recv(int fd, char *buf, int nBytes, int flags) {
- RESTARTABLE_RETURN_INT(::recv(fd, buf, nBytes, (unsigned int) flags));
+ INTERRUPTIBLE_RETURN_INT(::recv(fd, buf, nBytes, (unsigned int) flags), os::Bsd::clear_interrupted);
}
inline int hpi::send(int fd, char *buf, int nBytes, int flags) {
- RESTARTABLE_RETURN_INT(::send(fd, buf, nBytes, (unsigned int) flags));
+ INTERRUPTIBLE_RETURN_INT(::send(fd, buf, nBytes, (unsigned int) flags), os::Bsd::clear_interrupted);
}
inline int hpi::raw_send(int fd, char *buf, int nBytes, int flags) {
@@ -83,11 +79,12 @@ inline int hpi::timeout(int fd, long timeout) {
for(;;) {
struct pollfd pfd;
+ int res;
pfd.fd = fd;
pfd.events = POLLIN | POLLERR;
- int res = ::poll(&pfd, 1, timeout);
+ INTERRUPTIBLE_NORESTART(::poll(&pfd, 1, timeout), res, os::Bsd::clear_interrupted);
if (res == OS_ERR && errno == EINTR) {
@@ -111,7 +108,26 @@ inline int hpi::listen(int fd, int count) {
}
inline int hpi::connect(int fd, struct sockaddr *him, int len) {
- RESTARTABLE_RETURN_INT(::connect(fd, him, len));
+ do {
+ int _result;
+ INTERRUPTIBLE_NORESTART(::connect(fd, him, len), _result,
+ os::Bsd::clear_interrupted);
+
+ // Depending on when thread interruption is reset, _result could be
+ // one of two values when errno == EINTR
+
+ if (((_result == OS_INTRPT) || (_result == OS_ERR)) && (errno == EINTR)) {
+ /* restarting a connect() changes its errno semantics */
+ INTERRUPTIBLE(::connect(fd, him, len), _result,
+ os::Bsd::clear_interrupted);
+ /* undo these changes */
+ if (_result == OS_ERR) {
+ if (errno == EALREADY) errno = EINPROGRESS; /* fall through */
+ else if (errno == EISCONN) { errno = 0; return OS_OK; }
+ }
+ }
+ return _result;
+ } while(false);
}
inline int hpi::accept(int fd, struct sockaddr *him, int *len) {
@@ -122,26 +138,32 @@ inline int hpi::accept(int fd, struct sockaddr *him, i
@@ -120,9 +120,9 @@ inline int hpi::accept(int fd, struct sockaddr *him, i
// fetch it's value, this cast is safe for now. The java.net group
// may need and want to change this interface someday if socklen_t goes
// to 64 bits on some platform that we support.
// Bsd doc says this can't return EINTR, unlike accept() on Solaris
- // Bsd doc says this can't return EINTR, unlike accept() on Solaris
+ // At least OpenBSD and FreeBSD can return EINTR from accept.
- return ::accept(fd, him, (socklen_t *)len);
+ if (fd < 0)
+ return OS_ERR;
+ INTERRUPTIBLE_RETURN_INT((int)::accept(fd, him, (socklen_t*) len), os::Bsd::clear_interrupted);
+ RESTARTABLE_RETURN_INT(::accept(fd, him, (socklen_t *)len));
}
inline int hpi::recvfrom(int fd, char *buf, int nBytes, int flags,
sockaddr *from, int *fromlen) {
- RESTARTABLE_RETURN_INT(::recvfrom(fd, buf, nBytes, (unsigned int) flags, from, (socklen_t *)fromlen));
+ INTERRUPTIBLE_RETURN_INT((int)::recvfrom(fd, buf, nBytes, (unsigned int) flags, from, (socklen_t *)fromlen), os::Bsd::clear_interrupted);
}
inline int hpi::sendto(int fd, char *buf, int len, int flags,
struct sockaddr *to, int tolen) {
- RESTARTABLE_RETURN_INT(::sendto(fd, buf, len, (unsigned int) flags, to, tolen));
+ INTERRUPTIBLE_RETURN_INT((int)::sendto(fd, buf, len, (unsigned int) flags, to, tolen),os::Bsd::clear_interrupted);
@@ -136,12 +136,16 @@ inline int hpi::sendto(int fd, char *buf, int len, int
}
inline int hpi::socket_available(int fd, jint *pbytes) {
@ -127,12 +51,3 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_hpi_bsd_hpp,v 1.3 2009/01/04 23:25:16 kurt
}
@@ -168,7 +190,7 @@ HPIDECL(bind, "bind", _socket, Bind,
(fd, him, len));
*/
inline int hpi::bind(int fd, struct sockaddr *him, int len){
- return ::bind(fd, him, len);
+ INTERRUPTIBLE_RETURN_INT_NORESTART(::bind(fd, him, len),os::Bsd::clear_interrupted);
}
/*

View File

@ -1,6 +1,6 @@
$OpenBSD: patch-hotspot_src_os_bsd_vm_osThread_bsd_hpp,v 1.3 2008/03/19 18:05:43 kurt Exp $
--- hotspot/src/os/bsd/vm/osThread_bsd.hpp.orig Wed Nov 7 12:41:29 2007
+++ hotspot/src/os/bsd/vm/osThread_bsd.hpp Wed Nov 7 12:41:35 2007
$OpenBSD: patch-hotspot_src_os_bsd_vm_osThread_bsd_hpp,v 1.4 2009/06/10 19:01:09 kurt Exp $
--- hotspot/src/os/bsd/vm/osThread_bsd.hpp.orig Sat May 30 10:11:57 2009
+++ hotspot/src/os/bsd/vm/osThread_bsd.hpp Sat May 30 10:14:49 2009
@@ -36,6 +36,12 @@
private:
@ -58,24 +58,3 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_osThread_bsd_hpp,v 1.3 2008/03/19 18:05:43
pthread_t pthread_id() const {
return _pthread_id;
}
@@ -120,12 +139,20 @@
private:
Monitor* _startThread_lock; // sync parent and child in thread creation
+#ifdef _ALLBSD_SOURCE
+ JavaThreadState _saved_interrupt_thread_state; // the thread state before a system call -- restored afterward
+#endif
public:
Monitor* startThread_lock() const {
return _startThread_lock;
}
+
+#ifdef _ALLBSD_SOURCE
+ JavaThreadState saved_interrupt_thread_state() { return _saved_interrupt_thread_state; }
+ void set_saved_interrupt_thread_state(JavaThreadState state) { _saved_interrupt_thread_state = state; }
+#endif
// ***************************************************************
// Platform dependent initialization and cleanup

View File

@ -1,6 +1,6 @@
$OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt Exp $
--- hotspot/src/os/bsd/vm/os_bsd.cpp.orig Wed May 20 17:42:24 2009
+++ hotspot/src/os/bsd/vm/os_bsd.cpp Wed May 20 18:24:46 2009
$OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.11 2009/06/10 19:01:09 kurt Exp $
--- hotspot/src/os/bsd/vm/os_bsd.cpp.orig Sat May 30 10:11:57 2009
+++ hotspot/src/os/bsd/vm/os_bsd.cpp Sat May 30 10:15:08 2009
@@ -42,18 +42,40 @@
# include <sys/utsname.h>
# include <sys/socket.h>
@ -68,86 +68,16 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
static jlong initial_time_count=0;
@@ -94,9 +122,76 @@ static pid_t _initial_pid = 0;
@@ -94,8 +122,6 @@ static pid_t _initial_pid = 0;
static int SR_signum = SIGUSR2;
sigset_t SR_sigset;
-/* Used to protect dlsym() calls */
-static pthread_mutex_t dl_mutex;
+#ifdef _ALLBSD_SOURCE
+// XXXBSD: ported from solaris version
+// interruptible infrastructure
+// setup_interruptible saves the thread state before going into an
+// interruptible system call.
+// The saved state is used to restore the thread to
+// its former state whether or not an interrupt is received.
+// Used by classloader os::read
+// hpi calls skip this layer and stay in _thread_in_native
+
+void os::Bsd::setup_interruptible(JavaThread* thread) {
+
+ JavaThreadState thread_state = thread->thread_state();
+
+ assert(thread_state != _thread_blocked, "Coming from the wrong thread");
+ assert(thread_state != _thread_in_native, "Native threads skip setup_interruptible");
+ OSThread* osthread = thread->osthread();
+ osthread->set_saved_interrupt_thread_state(thread_state);
+ thread->frame_anchor()->make_walkable(thread);
+ ThreadStateTransition::transition(thread, thread_state, _thread_blocked);
+}
+
+// Version of setup_interruptible() for threads that are already in
+// _thread_blocked. Used by os_sleep().
+void os::Bsd::setup_interruptible_already_blocked(JavaThread* thread) {
+ thread->frame_anchor()->make_walkable(thread);
+}
+
+JavaThread* os::Bsd::setup_interruptible() {
+ JavaThread* thread = (JavaThread*)ThreadLocalStorage::thread();
+ setup_interruptible(thread);
+ return thread;
+}
+
+#ifdef ASSERT
+
+JavaThread* os::Bsd::setup_interruptible_native() {
+ JavaThread* thread = (JavaThread*)ThreadLocalStorage::thread();
+ JavaThreadState thread_state = thread->thread_state();
+ assert(thread_state == _thread_in_native, "Assumed thread_in_native");
+ return thread;
+}
+
+void os::Bsd::cleanup_interruptible_native(JavaThread* thread) {
+ JavaThreadState thread_state = thread->thread_state();
+ assert(thread_state == _thread_in_native, "Assumed thread_in_native");
+}
+#endif
+
+// cleanup_interruptible reverses the effects of setup_interruptible
+// setup_interruptible_already_blocked() does not need any cleanup.
+
+void os::Bsd::cleanup_interruptible(JavaThread* thread) {
+ OSThread* osthread = thread->osthread();
+
+ ThreadStateTransition::transition(thread, _thread_blocked, osthread->saved_interrupt_thread_state());
+}
+
+// I/O interruption related counters called in _INTERRUPTIBLE
+
+void os::Bsd::bump_interrupted_before_count() {
+ RuntimeService::record_interrupted_before_count();
+}
+
+void os::Bsd::bump_interrupted_during_count() {
+ RuntimeService::record_interrupted_during_count();
+}
+#endif
+
////////////////////////////////////////////////////////////////////////////////
// utility functions
@@ -108,11 +203,16 @@ julong os::available_memory() {
@@ -108,11 +134,16 @@ julong os::available_memory() {
}
julong os::Bsd::available_memory() {
@ -164,7 +94,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
}
julong os::physical_memory() {
@@ -160,6 +260,7 @@ bool os::have_special_privileges() {
@@ -160,6 +191,7 @@ bool os::have_special_privileges() {
}
@ -172,7 +102,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
#ifndef SYS_gettid
// i386: 224, ia64: 1105, amd64: 186, sparc 143
#ifdef __ia64__
@@ -174,6 +275,7 @@ bool os::have_special_privileges() {
@@ -174,6 +206,7 @@ bool os::have_special_privileges() {
#error define gettid for the arch
#endif
#endif
@ -180,7 +110,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
// Cpu architecture string
#if defined(IA64)
@@ -193,6 +295,7 @@ static char cpu_arch[] = "sparc";
@@ -193,6 +226,7 @@ static char cpu_arch[] = "sparc";
#endif
@ -188,7 +118,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
// pid_t gettid()
//
// Returns the kernel thread id of the currently running thread. Kernel
@@ -219,8 +322,48 @@ static bool unsafe_chroot_detected = false;
@@ -219,8 +253,48 @@ static bool unsafe_chroot_detected = false;
static const char *unstable_chroot_error = "/proc file system not found.\n"
"Java may be unstable running multithreaded in a chroot "
"environment on Bsd when /proc filesystem is not mounted.";
@ -237,7 +167,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
_processor_count = sysconf(_SC_NPROCESSORS_CONF);
if (_processor_count == 1) {
pid_t pid = os::Bsd::gettid();
@@ -236,6 +379,7 @@ void os::Bsd::initialize_system_info() {
@@ -236,6 +310,7 @@ void os::Bsd::initialize_system_info() {
_physical_memory = (julong)sysconf(_SC_PHYS_PAGES) * (julong)sysconf(_SC_PAGESIZE);
assert(_processor_count > 0, "bsd error");
}
@ -245,7 +175,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
void os::init_system_properties_values() {
// char arch[12];
@@ -279,9 +423,7 @@ void os::init_system_properties_values() {
@@ -279,9 +354,7 @@ void os::init_system_properties_values() {
* ...
* 7: The default directories, normally /lib and /usr/lib.
*/
@ -256,7 +186,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
#define DEFAULT_LIBPATH "/lib:/usr/lib"
#endif
@@ -360,7 +502,11 @@ void os::init_system_properties_values() {
@@ -360,7 +433,11 @@ void os::init_system_properties_values() {
* should always exist (until the legacy problem cited above is
* addressed).
*/
@ -268,7 +198,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
if (v != NULL) {
char *t = ld_library_path;
/* That's +1 for the colon and +1 for the trailing '\0' */
@@ -519,6 +665,7 @@ void os::Bsd::hotspot_sigmask(Thread* thread) {
@@ -519,6 +596,7 @@ void os::Bsd::hotspot_sigmask(Thread* thread) {
}
}
@ -276,7 +206,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
//////////////////////////////////////////////////////////////////////////////
// detecting pthread library
@@ -682,6 +829,7 @@ bool os::Bsd::manually_expand_stack(JavaThread * t, ad
@@ -682,6 +760,7 @@ bool os::Bsd::manually_expand_stack(JavaThread * t, ad
}
return false;
}
@ -284,7 +214,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
//////////////////////////////////////////////////////////////////////////////
// create new thread
@@ -690,6 +838,9 @@ static address highest_vm_reserved_address();
@@ -690,6 +769,9 @@ static address highest_vm_reserved_address();
// check if it's safe to start a new thread
static bool _thread_safety_check(Thread* thread) {
@ -294,7 +224,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
if (os::Bsd::is_BsdThreads() && !os::Bsd::is_floating_stack()) {
// Fixed stack BsdThreads (SuSE Bsd/x86, and some versions of Redhat)
// Heap is mmap'ed at lower end of memory space. Thread stacks are
@@ -723,6 +874,7 @@ static bool _thread_safety_check(Thread* thread) {
@@ -723,6 +805,7 @@ static bool _thread_safety_check(Thread* thread) {
// here, that means enough space has been reserved for stack.
return true;
}
@ -302,7 +232,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
}
// Thread start routine for all newly created threads
@@ -750,6 +902,10 @@ static void *java_start(Thread *thread) {
@@ -750,6 +833,10 @@ static void *java_start(Thread *thread) {
return NULL;
}
@ -313,7 +243,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
// thread_id is kernel thread id (similar to Solaris LWP id)
osthread->set_thread_id(os::Bsd::gettid());
@@ -759,6 +915,7 @@ static void *java_start(Thread *thread) {
@@ -759,6 +846,7 @@ static void *java_start(Thread *thread) {
thread->set_lgrp_id(lgrp_id);
}
}
@ -321,7 +251,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
// initialize signal mask for this thread
os::Bsd::hotspot_sigmask(thread);
@@ -839,17 +996,22 @@ bool os::create_thread(Thread* thread, ThreadType thr_
@@ -839,17 +927,22 @@ bool os::create_thread(Thread* thread, ThreadType thr_
// let pthread_create() pick the default value.
}
@ -344,7 +274,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
pthread_t tid;
int ret = pthread_create(&tid, &attr, (void* (*)(void*)) java_start, thread);
@@ -863,7 +1025,9 @@ bool os::create_thread(Thread* thread, ThreadType thr_
@@ -863,7 +956,9 @@ bool os::create_thread(Thread* thread, ThreadType thr_
// Need to clean up stuff we've allocated so far
thread->set_osthread(NULL);
delete osthread;
@ -354,7 +284,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
return false;
}
@@ -879,9 +1043,11 @@ bool os::create_thread(Thread* thread, ThreadType thr_
@@ -879,9 +974,11 @@ bool os::create_thread(Thread* thread, ThreadType thr_
}
}
@ -366,7 +296,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
}
// Aborted due to thread limit being reached
@@ -919,7 +1085,11 @@ bool os::create_attached_thread(JavaThread* thread) {
@@ -919,7 +1016,11 @@ bool os::create_attached_thread(JavaThread* thread) {
}
// Store pthread info into the OSThread
@ -378,7 +308,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
osthread->set_pthread_id(::pthread_self());
// initialize floating point control register
@@ -930,6 +1100,7 @@ bool os::create_attached_thread(JavaThread* thread) {
@@ -930,6 +1031,7 @@ bool os::create_attached_thread(JavaThread* thread) {
thread->set_osthread(osthread);
@ -386,7 +316,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
if (UseNUMA) {
int lgrp_id = os::numa_get_group_id();
if (lgrp_id != -1) {
@@ -956,6 +1127,7 @@ bool os::create_attached_thread(JavaThread* thread) {
@@ -956,6 +1058,7 @@ bool os::create_attached_thread(JavaThread* thread) {
os::Bsd::manually_expand_stack(jt, addr);
osthread->clear_expanding_stack();
}
@ -394,7 +324,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
// initialize signal mask for this thread
// and save the caller's signal mask
@@ -1014,6 +1186,7 @@ extern "C" Thread* get_thread() {
@@ -1014,6 +1117,7 @@ extern "C" Thread* get_thread() {
//////////////////////////////////////////////////////////////////////////////
// initial thread
@ -402,7 +332,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
// Check if current thread is the initial thread, similar to Solaris thr_main.
bool os::Bsd::is_initial_thread(void) {
char dummy;
@@ -1247,6 +1420,7 @@ void os::Bsd::capture_initial_stack(size_t max_size) {
@@ -1247,6 +1351,7 @@ void os::Bsd::capture_initial_stack(size_t max_size) {
_initial_thread_stack_size = align_size_down(_initial_thread_stack_size, page_size());
_initial_thread_stack_bottom = (address)stack_top - _initial_thread_stack_size;
}
@ -410,7 +340,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
////////////////////////////////////////////////////////////////////////////////
// time support
@@ -1268,9 +1442,7 @@ jlong os::elapsed_frequency() {
@@ -1268,9 +1373,7 @@ jlong os::elapsed_frequency() {
return (1000 * 1000);
}
@ -421,7 +351,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
bool os::supports_vtime() { return false; }
bool os::enable_vtime() { return false; }
bool os::vtime_enabled() { return false; }
@@ -1290,7 +1462,22 @@ jlong os::javaTimeMillis() {
@@ -1290,7 +1393,22 @@ jlong os::javaTimeMillis() {
#define CLOCK_MONOTONIC (1)
#endif
@ -444,7 +374,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
// we do dlopen's in this particular order due to bug in bsd
// dynamical loader (see 6348968) leading to crash on exit
void* handle = dlopen("librt.so.1", RTLD_LAZY);
@@ -1325,7 +1512,9 @@ void os::Bsd::clock_init() {
@@ -1325,7 +1443,9 @@ void os::Bsd::clock_init() {
}
}
}
@ -454,7 +384,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
#ifndef SYS_clock_getres
#if defined(IA32) || defined(AMD64)
@@ -1364,6 +1553,7 @@ void os::Bsd::fast_thread_clock_init() {
@@ -1364,6 +1484,7 @@ void os::Bsd::fast_thread_clock_init() {
_pthread_getcpuclockid = pthread_getcpuclockid_func;
}
}
@ -462,7 +392,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
jlong os::javaTimeNanos() {
if (Bsd::supports_monotonic_clock()) {
@@ -1514,8 +1704,15 @@ int os::current_process_id() {
@@ -1514,8 +1635,15 @@ int os::current_process_id() {
// DLL functions
@ -479,7 +409,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
const char* os::get_temp_directory() { return "/tmp/"; }
static bool file_exists(const char* filename) {
@@ -1532,13 +1729,13 @@ void os::dll_build_name(char* buffer, size_t buflen,
@@ -1532,13 +1660,13 @@ void os::dll_build_name(char* buffer, size_t buflen,
const size_t pnamelen = pname ? strlen(pname) : 0;
// Quietly truncate on buffer overflow. Should be an error.
@ -495,7 +425,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
} else if (strchr(pname, *os::path_separator()) != NULL) {
int n;
char** pelements = split_path(pname, &n);
@@ -1547,7 +1744,8 @@ void os::dll_build_name(char* buffer, size_t buflen,
@@ -1547,7 +1675,8 @@ void os::dll_build_name(char* buffer, size_t buflen,
if (pelements[i] == NULL || strlen(pelements[i]) == 0) {
continue; // skip the empty path values
}
@ -505,7 +435,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
if (file_exists(buffer)) {
break;
}
@@ -1562,7 +1760,7 @@ void os::dll_build_name(char* buffer, size_t buflen,
@@ -1562,7 +1691,7 @@ void os::dll_build_name(char* buffer, size_t buflen,
FREE_C_HEAP_ARRAY(char*, pelements);
}
} else {
@ -514,7 +444,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
}
}
@@ -1603,6 +1801,23 @@ bool os::dll_address_to_function_name(address addr, ch
@@ -1603,6 +1732,23 @@ bool os::dll_address_to_function_name(address addr, ch
}
}
@ -538,7 +468,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
struct _address_to_library_name {
address addr; // input : memory address
size_t buflen; // size of fname
@@ -1677,11 +1892,27 @@ bool os::dll_address_to_library_name(address addr, cha
@@ -1677,11 +1823,27 @@ bool os::dll_address_to_library_name(address addr, cha
return false;
}
}
@ -566,7 +496,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
void * os::dll_load(const char *filename, char *ebuf, int ebuflen)
{
void * result= ::dlopen(filename, RTLD_LAZY);
@@ -1734,6 +1965,18 @@ void * os::dll_load(const char *filename, char *ebuf,
@@ -1734,6 +1896,18 @@ void * os::dll_load(const char *filename, char *ebuf,
#define EM_486 6 /* Intel 80486 */
#endif
@ -585,7 +515,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
static const arch_t arch_array[]={
{EM_386, EM_386, ELFCLASS32, ELFDATA2LSB, (char*)"IA 32"},
{EM_486, EM_386, ELFCLASS32, ELFDATA2LSB, (char*)"IA 32"},
@@ -1814,17 +2057,11 @@ void * os::dll_load(const char *filename, char *ebuf,
@@ -1814,17 +1988,11 @@ void * os::dll_load(const char *filename, char *ebuf,
return NULL;
}
@ -606,7 +536,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
}
@@ -1847,7 +2084,51 @@ bool _print_ascii_file(const char* filename, outputStr
@@ -1847,7 +2015,51 @@ bool _print_ascii_file(const char* filename, outputStr
void os::print_dll_info(outputStream *st) {
st->print_cr("Dynamic libraries:");
@ -658,7 +588,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
char fname[32];
pid_t pid = os::Bsd::gettid();
@@ -1856,6 +2137,7 @@ void os::print_dll_info(outputStream *st) {
@@ -1856,6 +2068,7 @@ void os::print_dll_info(outputStream *st) {
if (!_print_ascii_file(fname, st)) {
st->print("Can not get library information for pid = %d\n", pid);
}
@ -666,7 +596,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
}
@@ -1888,6 +2170,7 @@ void os::print_os_info(outputStream* st) {
@@ -1888,6 +2101,7 @@ void os::print_os_info(outputStream* st) {
st->print(name.machine);
st->cr();
@ -674,7 +604,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
// Print warning if unsafe chroot environment detected
if (unsafe_chroot_detected) {
st->print("WARNING!! ");
@@ -1902,6 +2185,7 @@ void os::print_os_info(outputStream* st) {
@@ -1902,6 +2116,7 @@ void os::print_os_info(outputStream* st) {
st->print("(%s stack)", os::Bsd::is_floating_stack() ? "floating" : "fixed");
}
st->cr();
@ -682,7 +612,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
// rlimit
st->print("rlimit:");
@@ -1927,6 +2211,7 @@ void os::print_os_info(outputStream* st) {
@@ -1927,6 +2142,7 @@ void os::print_os_info(outputStream* st) {
if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
else st->print("%d", rlim.rlim_cur);
@ -690,7 +620,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
st->print(", AS ");
getrlimit(RLIMIT_AS, &rlim);
if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
@@ -1939,6 +2224,7 @@ void os::print_os_info(outputStream* st) {
@@ -1939,6 +2155,7 @@ void os::print_os_info(outputStream* st) {
os::loadavg(loadavg, 3);
st->print("%0.02f %0.02f %0.02f", loadavg[0], loadavg[1], loadavg[2]);
st->cr();
@ -698,7 +628,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
}
void os::print_memory_info(outputStream* st) {
@@ -1946,18 +2232,22 @@ void os::print_memory_info(outputStream* st) {
@@ -1946,18 +2163,22 @@ void os::print_memory_info(outputStream* st) {
st->print("Memory:");
st->print(" %dk page", os::vm_page_size()>>10);
@ -721,7 +651,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
st->cr();
}
@@ -2184,19 +2474,29 @@ int os::sigexitnum_pd() {
@@ -2184,19 +2405,29 @@ int os::sigexitnum_pd() {
static volatile jint pending_signals[NSIG+1] = { 0 };
// Bsd(POSIX) specific hand shaking semaphore.
@ -753,7 +683,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
}
static int check_pending_signals(bool wait) {
@@ -2218,7 +2518,7 @@ static int check_pending_signals(bool wait) {
@@ -2218,7 +2449,7 @@ static int check_pending_signals(bool wait) {
do {
thread->set_suspend_equivalent();
// cleared by handle_special_suspend_equivalent_condition() or java_suspend_self()
@ -762,7 +692,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
// were we externally suspended while we were waiting?
threadIsSuspended = thread->handle_special_suspend_equivalent_condition();
@@ -2229,7 +2529,7 @@ static int check_pending_signals(bool wait) {
@@ -2229,7 +2460,7 @@ static int check_pending_signals(bool wait) {
// while suspended because that would surprise the thread that
// suspended us.
//
@ -771,7 +701,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
thread->java_suspend_self();
}
@@ -2301,9 +2601,14 @@ void bsd_wrap_code(char* base, size_t size) {
@@ -2301,9 +2532,14 @@ void bsd_wrap_code(char* base, size_t size) {
// problem.
bool os::commit_memory(char* addr, size_t size, bool exec) {
int prot = exec ? PROT_READ|PROT_WRITE|PROT_EXEC : PROT_READ|PROT_WRITE;
@ -786,7 +716,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
}
bool os::commit_memory(char* addr, size_t size, size_t alignment_hint,
@@ -2319,36 +2624,27 @@ void os::free_memory(char *addr, size_t bytes) {
@@ -2319,36 +2555,27 @@ void os::free_memory(char *addr, size_t bytes) {
}
void os::numa_make_global(char *addr, size_t bytes) {
@ -828,7 +758,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
}
bool os::get_page_info(char *start, page_info* info) {
@@ -2359,6 +2655,7 @@ char *os::scan_pages(char *start, char* end, page_info
@@ -2359,6 +2586,7 @@ char *os::scan_pages(char *start, char* end, page_info
return end;
}
@ -836,7 +766,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
extern "C" void numa_warn(int number, char *where, ...) { }
extern "C" void numa_error(char *where) { }
@@ -2460,11 +2757,18 @@ os::Bsd::numa_available_func_t os::Bsd::_numa_availabl
@@ -2460,11 +2688,18 @@ os::Bsd::numa_available_func_t os::Bsd::_numa_availabl
os::Bsd::numa_tonode_memory_func_t os::Bsd::_numa_tonode_memory;
os::Bsd::numa_interleave_memory_func_t os::Bsd::_numa_interleave_memory;
unsigned long* os::Bsd::_numa_all_nodes;
@ -856,7 +786,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
}
static address _highest_vm_reserved_address = NULL;
@@ -2568,6 +2872,9 @@ bool os::unguard_memory(char* addr, size_t size) {
@@ -2568,6 +2803,9 @@ bool os::unguard_memory(char* addr, size_t size) {
static size_t _large_page_size = 0;
bool os::large_page_init() {
@ -866,7 +796,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
if (!UseLargePages) return false;
if (LargePageSizeInBytes) {
@@ -2622,6 +2929,7 @@ bool os::large_page_init() {
@@ -2622,6 +2860,7 @@ bool os::large_page_init() {
// We optimistically assume the support is available. If later it turns out
// not true, VM will automatically switch to use regular page size.
return true;
@ -874,16 +804,16 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
}
#ifndef SHM_HUGETLB
@@ -2798,7 +3106,7 @@ char* os::attempt_reserve_memory_at(size_t bytes, char
@@ -2798,7 +3037,7 @@ char* os::attempt_reserve_memory_at(size_t bytes, char
}
size_t os::read(int fd, void *buf, unsigned int nBytes) {
- return ::read(fd, buf, nBytes);
+ INTERRUPTIBLE_RETURN_INT_VM(::read(fd, buf, nBytes), os::Bsd::clear_interrupted);
+ RESTARTABLE_RETURN_INT(::read(fd, buf, nBytes));
}
// TODO-FIXME: reconcile Solaris' os::sleep with the bsd variation.
@@ -2934,9 +3242,47 @@ void os::loop_breaker(int attempts) {
@@ -2934,9 +3173,47 @@ void os::loop_breaker(int attempts) {
// this reason, the code should not be used as default (ThreadPriorityPolicy=0).
// It is only used when ThreadPriorityPolicy=1 and requires root privilege.
@ -931,7 +861,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
4, // 1 MinPriority
3, // 2
2, // 3
@@ -2951,6 +3297,7 @@ int os::java_to_os_priority[MaxPriority + 1] = {
@@ -2951,6 +3228,7 @@ int os::java_to_os_priority[MaxPriority + 1] = {
-5 // 10 MaxPriority
};
@ -939,7 +869,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
static int prio_init() {
if (ThreadPriorityPolicy == 1) {
@@ -2970,8 +3317,28 @@ static int prio_init() {
@@ -2970,8 +3248,28 @@ static int prio_init() {
OSReturn os::set_native_priority(Thread* thread, int newpri) {
if ( !UseThreadPriorities || ThreadPriorityPolicy == 0 ) return OS_OK;
@ -968,7 +898,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
}
OSReturn os::get_native_priority(const Thread* const thread, int *priority_ptr) {
@@ -2981,7 +3348,17 @@ OSReturn os::get_native_priority(const Thread* const t
@@ -2981,7 +3279,17 @@ OSReturn os::get_native_priority(const Thread* const t
}
errno = 0;
@ -986,7 +916,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
return (*priority_ptr != -1 || errno == 0 ? OS_OK : OS_ERR);
}
@@ -3091,7 +3468,7 @@ static int SR_initialize() {
@@ -3091,7 +3399,7 @@ static int SR_initialize() {
/* Get signal number to use for suspend/resume */
if ((s = ::getenv("_JAVA_SR_SIGNUM")) != 0) {
int sig = ::strtol(s, 0, 10);
@ -995,7 +925,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
SR_signum = sig;
}
}
@@ -3434,6 +3811,28 @@ void os::Bsd::install_signal_handlers() {
@@ -3434,6 +3742,28 @@ void os::Bsd::install_signal_handlers() {
set_signal_handler(SIGFPE, true);
set_signal_handler(SIGXFSZ, true);
@ -1024,7 +954,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
if (libjsig_is_loaded) {
// Tell libjsig jvm finishes setting signal handlers
(*end_signal_setting)();
@@ -3454,6 +3853,7 @@ void os::Bsd::install_signal_handlers() {
@@ -3454,6 +3784,7 @@ void os::Bsd::install_signal_handlers() {
}
}
@ -1032,7 +962,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
// This is the fastest way to get thread cpu time on Bsd.
// Returns cpu time (user+sys) for any thread, not only for current.
// POSIX compliant clocks are implemented in the kernels 2.6.16+.
@@ -3468,6 +3868,7 @@ jlong os::Bsd::fast_thread_cpu_time(clockid_t clockid)
@@ -3468,6 +3799,7 @@ jlong os::Bsd::fast_thread_cpu_time(clockid_t clockid)
return (tp.tv_sec * SEC_IN_NANOSECS) + tp.tv_nsec;
}
@ -1040,7 +970,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
/////
// glibc on Bsd platform uses non-documented flag
@@ -3689,13 +4090,13 @@ void os::init(void) {
@@ -3689,13 +4021,13 @@ void os::init(void) {
_initial_pid = (java_launcher_pid > 0) ? java_launcher_pid : getpid();
@ -1056,7 +986,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
if (Bsd::page_size() == -1) {
fatal1("os_bsd.cpp: os::init: sysconf failed (%s)", strerror(errno));
}
@@ -3708,7 +4109,16 @@ void os::init(void) {
@@ -3708,7 +4040,16 @@ void os::init(void) {
Bsd::clock_init();
initial_time_count = os::elapsed_counter();
@ -1074,7 +1004,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
}
// To install functions for atexit system call
@@ -3721,7 +4131,9 @@ extern "C" {
@@ -3721,7 +4062,9 @@ extern "C" {
// this is called _after_ the global arguments have been parsed
jint os::init_2(void)
{
@ -1084,7 +1014,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
// Allocate a single page and mark it as readable for safepoint polling
address polling_page = (address) ::mmap(NULL, Bsd::page_size(), PROT_READ, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
@@ -3770,6 +4182,7 @@ jint os::init_2(void)
@@ -3770,6 +4113,7 @@ jint os::init_2(void)
JavaThread::set_stack_size_at_create(round_to(threadStackSizeInBytes,
vm_page_size()));
@ -1092,7 +1022,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
Bsd::capture_initial_stack(JavaThread::stack_size_at_create());
Bsd::libpthread_init();
@@ -3792,6 +4205,7 @@ jint os::init_2(void)
@@ -3792,6 +4136,7 @@ jint os::init_2(void)
UseNUMA = true;
}
}
@ -1100,7 +1030,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
if (MaxFDLimit) {
// set the number of file descriptors to max. print out error
@@ -3803,6 +4217,14 @@ jint os::init_2(void)
@@ -3803,6 +4148,14 @@ jint os::init_2(void)
perror("os::init_2 getrlimit failed");
} else {
nbr_files.rlim_cur = nbr_files.rlim_max;
@ -1115,7 +1045,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
status = setrlimit(RLIMIT_NOFILE, &nbr_files);
if (status != 0) {
if (PrintMiscellaneous && (Verbose || WizardMode))
@@ -3811,8 +4233,10 @@ jint os::init_2(void)
@@ -3811,8 +4164,10 @@ jint os::init_2(void)
}
}
@ -1126,7 +1056,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
// Initialize HPI.
jint hpi_result = hpi::initialize();
@@ -3860,11 +4284,15 @@ void os::make_polling_page_readable(void) {
@@ -3860,11 +4215,15 @@ void os::make_polling_page_readable(void) {
};
int os::active_processor_count() {
@ -1142,7 +1072,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
}
bool os::distribute_processes(uint length, uint* distribution) {
@@ -3906,6 +4334,9 @@ ExtendedPC os::get_thread_pc(Thread* thread) {
@@ -3906,6 +4265,9 @@ ExtendedPC os::get_thread_pc(Thread* thread) {
int os::Bsd::safe_cond_timedwait(pthread_cond_t *_cond, pthread_mutex_t *_mutex, const struct timespec *_abstime)
{
@ -1152,7 +1082,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
if (is_NPTL()) {
return pthread_cond_timedwait(_cond, _mutex, _abstime);
} else {
@@ -3921,6 +4352,7 @@ int os::Bsd::safe_cond_timedwait(pthread_cond_t *_cond
@@ -3921,6 +4283,7 @@ int os::Bsd::safe_cond_timedwait(pthread_cond_t *_cond
#endif // IA64
return status;
}
@ -1160,7 +1090,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
}
////////////////////////////////////////////////////////////////////////////////
@@ -4056,17 +4488,17 @@ int os::create_binary_file(const char* path, bool rewr
@@ -4056,17 +4419,17 @@ int os::create_binary_file(const char* path, bool rewr
if (!rewrite_existing) {
oflags |= O_EXCL;
}
@ -1181,7 +1111,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
}
// Map a block of memory.
@@ -4116,6 +4548,7 @@ bool os::unmap_memory(char* addr, size_t bytes) {
@@ -4116,6 +4479,7 @@ bool os::unmap_memory(char* addr, size_t bytes) {
return munmap(addr, bytes) == 0;
}
@ -1189,7 +1119,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
static jlong slow_thread_cpu_time(Thread *thread, bool user_sys_cpu_time);
static clockid_t thread_cpu_clockid(Thread* thread) {
@@ -4127,6 +4560,7 @@ static clockid_t thread_cpu_clockid(Thread* thread) {
@@ -4127,6 +4491,7 @@ static clockid_t thread_cpu_clockid(Thread* thread) {
assert(rc == 0, "pthread_getcpuclockid is expected to return 0 code");
return clockid;
}
@ -1197,7 +1127,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
// current_thread_cpu_time(bool) and thread_cpu_time(Thread*, bool)
// are used by JVM M&M and JVMTI to get user+sys or user CPU time
@@ -4136,39 +4570,71 @@ static clockid_t thread_cpu_clockid(Thread* thread) {
@@ -4136,39 +4501,71 @@ static clockid_t thread_cpu_clockid(Thread* thread) {
// the fast estimate available on the platform.
jlong os::current_thread_cpu_time() {
@ -1269,7 +1199,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
//
// -1 on error.
//
@@ -4257,6 +4723,7 @@ static jlong slow_thread_cpu_time(Thread *thread, bool
@@ -4257,6 +4654,7 @@ static jlong slow_thread_cpu_time(Thread *thread, bool
return (jlong)user_time * (1000000000 / clock_tics_per_sec);
}
}
@ -1277,7 +1207,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
void os::current_thread_cpu_time_info(jvmtiTimerInfo *info_ptr) {
info_ptr->max_value = ALL_64_BITS; // will not wrap in less than 64 bits
@@ -4273,7 +4740,13 @@ void os::thread_cpu_time_info(jvmtiTimerInfo *info_ptr
@@ -4273,7 +4671,13 @@ void os::thread_cpu_time_info(jvmtiTimerInfo *info_ptr
}
bool os::is_thread_cpu_time_supported() {
@ -1291,7 +1221,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
}
// System loadavg support. Returns -1 if load average cannot be obtained.
@@ -4406,7 +4879,7 @@ jdk_pthread_sigmask(int how , const sigset_t* newmask,
@@ -4406,7 +4810,7 @@ jdk_pthread_sigmask(int how , const sigset_t* newmask,
// abstime will be the absolute timeout time
// TODO: replace compute_abstime() with unpackTime()
@ -1300,7 +1230,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
if (millis < 0) millis = 0;
struct timeval now;
int status = gettimeofday(&now, NULL);
@@ -4458,7 +4931,7 @@ void os::PlatformEvent::park() { // AKA "down()"
@@ -4458,7 +4862,7 @@ void os::PlatformEvent::park() { // AKA "down()"
status = pthread_cond_wait(_cond, _mutex);
// for some reason, under 2.7 lwp_cond_wait() may return ETIME ...
// Treat this the same as if the wait was interrupted
@ -1309,7 +1239,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
assert_status(status == 0 || status == EINTR, status, "cond_wait");
}
-- _nParked ;
@@ -4516,10 +4989,10 @@ int os::PlatformEvent::park(jlong millis) {
@@ -4516,10 +4920,10 @@ int os::PlatformEvent::park(jlong millis) {
pthread_cond_init (_cond, NULL) ;
}
assert_status(status == 0 || status == EINTR ||
@ -1322,7 +1252,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
// We consume and ignore EINTR and spurious wakeups.
}
--_nParked ;
@@ -4611,7 +5084,7 @@ void os::PlatformEvent::unpark() {
@@ -4611,7 +5015,7 @@ void os::PlatformEvent::unpark() {
* years from "now".
*/
@ -1331,7 +1261,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
assert (time > 0, "convertTime");
struct timeval now;
@@ -4670,7 +5143,7 @@ void Parker::park(bool isAbsolute, jlong time) {
@@ -4670,7 +5074,7 @@ void Parker::park(bool isAbsolute, jlong time) {
}
// Next, demultiplex/decode time arguments
@ -1340,7 +1270,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
if (time < 0) { // don't wait at all
return;
}
@@ -4723,7 +5196,7 @@ void Parker::park(bool isAbsolute, jlong time) {
@@ -4723,7 +5127,7 @@ void Parker::park(bool isAbsolute, jlong time) {
}
}
assert_status(status == 0 || status == EINTR ||
@ -1349,7 +1279,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
status, "cond_timedwait");
#ifdef ASSERT
@@ -4765,16 +5238,14 @@ void Parker::unpark() {
@@ -4765,16 +5169,14 @@ void Parker::unpark() {
}
@ -1371,7 +1301,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
// Run the specified command in a separate process. Return its exit value,
// or -1 on failure (e.g. can't fork a new process).
// Unlike system(), this function can be called from signal handler. It
@@ -4787,8 +5258,7 @@ int os::fork_and_exec(char* cmd) {
@@ -4787,8 +5189,7 @@ int os::fork_and_exec(char* cmd) {
// separate process to execve. Make a direct syscall to fork process.
// On IA64 there's no fork syscall, we have to use fork() and hope for
// the best...
@ -1381,7 +1311,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.10 2009/05/23 03:03:24 kurt
if (pid < 0) {
// fork failed
@@ -4804,8 +5274,7 @@ int os::fork_and_exec(char* cmd) {
@@ -4804,8 +5205,7 @@ int os::fork_and_exec(char* cmd) {
// in the new process, so make a system call directly.
// IA64 should use normal execve() from glibc to match the glibc fork()
// above.

View File

@ -1,6 +1,6 @@
$OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_hpp,v 1.5 2009/05/23 03:03:24 kurt Exp $
--- hotspot/src/os/bsd/vm/os_bsd.hpp.orig Wed May 20 17:42:24 2009
+++ hotspot/src/os/bsd/vm/os_bsd.hpp Wed May 20 19:02:42 2009
$OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_hpp,v 1.6 2009/06/10 19:01:09 kurt Exp $
--- hotspot/src/os/bsd/vm/os_bsd.hpp.orig Sat May 30 10:11:57 2009
+++ hotspot/src/os/bsd/vm/os_bsd.hpp Sat May 30 10:15:17 2009
@@ -27,6 +27,12 @@
/* pthread_getattr_np comes with BsdThreads-0.9-7 on RedHat 7.1 */
typedef int (*pthread_getattr_func_type) (pthread_t, pthread_attr_t *);
@ -30,7 +30,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_hpp,v 1.5 2009/05/23 03:03:24 kurt
static GrowableArray<int>* _cpu_to_node;
@@ -65,38 +73,73 @@ class Bsd {
@@ -65,38 +73,52 @@ class Bsd {
static julong _physical_memory;
static pthread_t _main_thread;
@ -59,27 +59,6 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_hpp,v 1.5 2009/05/23 03:03:24 kurt
static void rebuild_cpu_to_node_map();
static GrowableArray<int>* cpu_to_node() { return _cpu_to_node; }
public:
+#ifdef _ALLBSD_SOURCE
+//XXXBSD: ported from solaris version
+ enum {
+ clear_interrupted = true
+ };
+ static void setup_interruptible(JavaThread* thread);
+ static void setup_interruptible_already_blocked(JavaThread* thread);
+ static JavaThread* setup_interruptible();
+ static void cleanup_interruptible(JavaThread* thread);
+
+ // perf counter incrementers used by _INTERRUPTIBLE
+
+ static void bump_interrupted_before_count();
+ static void bump_interrupted_during_count();
+
+#ifdef ASSERT
+ static JavaThread* setup_interruptible_native();
+ static void cleanup_interruptible_native(JavaThread* thread);
+#endif
+
+#endif
+
static void init_thread_fpu_state();
+#ifndef _ALLBSD_SOURCE
@ -104,7 +83,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_hpp,v 1.5 2009/05/23 03:03:24 kurt
static bool is_initial_thread(void);
static int page_size(void) { return _page_size; }
@@ -133,6 +176,7 @@ class Bsd {
@@ -133,6 +155,7 @@ class Bsd {
static struct sigaction *get_chained_signal_action(int sig);
static bool chained_handler(int sig, siginfo_t* siginfo, void* context);
@ -112,7 +91,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_hpp,v 1.5 2009/05/23 03:03:24 kurt
// GNU libc and libpthread version strings
static const char *glibc_version() { return _glibc_version; }
static const char *libpthread_version() { return _libpthread_version; }
@@ -148,6 +192,7 @@ class Bsd {
@@ -148,6 +171,7 @@ class Bsd {
static void libpthread_init();
static bool libnuma_init();
static void* libnuma_dlsym(void* handle, const char* name);
@ -120,7 +99,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_hpp,v 1.5 2009/05/23 03:03:24 kurt
// Minimum stack size a thread can be created with (allowing
// the VM to completely create the thread and enter user code)
static size_t min_stack_allowed;
@@ -156,17 +201,21 @@ class Bsd {
@@ -156,17 +180,21 @@ class Bsd {
static size_t default_stack_size(os::ThreadType thr_type);
static size_t default_guard_size(os::ThreadType thr_type);
@ -142,7 +121,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_hpp,v 1.5 2009/05/23 03:03:24 kurt
static bool supports_monotonic_clock() {
return _clock_gettime != NULL;
@@ -176,6 +225,7 @@ class Bsd {
@@ -176,6 +204,7 @@ class Bsd {
return _clock_gettime ? _clock_gettime(clock_id, tp) : -1;
}
@ -150,7 +129,7 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_hpp,v 1.5 2009/05/23 03:03:24 kurt
static int pthread_getcpuclockid(pthread_t tid, clockid_t *clock_id) {
return _pthread_getcpuclockid ? _pthread_getcpuclockid(tid, clock_id) : -1;
}
@@ -185,6 +235,7 @@ class Bsd {
@@ -185,6 +214,7 @@ class Bsd {
}
static jlong fast_thread_cpu_time(clockid_t clockid);

View File

@ -1,6 +1,6 @@
$OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_inline_hpp,v 1.2 2008/03/19 18:05:43 kurt Exp $
--- hotspot/src/os/bsd/vm/os_bsd.inline.hpp.orig Wed Nov 7 12:41:29 2007
+++ hotspot/src/os/bsd/vm/os_bsd.inline.hpp Wed Nov 7 12:41:35 2007
$OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_inline_hpp,v 1.3 2009/06/10 19:01:09 kurt Exp $
--- hotspot/src/os/bsd/vm/os_bsd.inline.hpp.orig Sat May 30 10:11:57 2009
+++ hotspot/src/os/bsd/vm/os_bsd.inline.hpp Sat May 30 10:15:39 2009
@@ -61,7 +61,15 @@ inline bool os::uses_stack_guard_pages() {
inline bool os::allocate_stack_guard_pages() {
@ -17,111 +17,3 @@ $OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_inline_hpp,v 1.2 2008/03/19 18:05:4
}
@@ -108,6 +116,107 @@ inline int os::closedir(DIR *dirp)
assert(dirp != NULL, "just checking");
return ::closedir(dirp);
}
+
+//XXXBSD: ported from solaris version
+//////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
+
+// macros for interruptible io and system calls and system call restarting
+
+#define _INTERRUPTIBLE(_setup, _cmd, _result, _thread, _clear, _before, _after, _int_enable) \
+do { \
+ _setup; \
+ _before; \
+ OSThread* _osthread = _thread->osthread(); \
+ if (_int_enable && _thread->has_last_Java_frame()) { \
+ /* this is java interruptible io stuff */ \
+ if (os::is_interrupted(_thread, _clear)) { \
+ os::Bsd::bump_interrupted_before_count(); \
+ _result = OS_INTRPT; \
+ } else { \
+ /* _cmd always expands to an assignment to _result */ \
+ if ((_cmd) < 0 && errno == EINTR \
+ && os::is_interrupted(_thread, _clear)) { \
+ os::Bsd::bump_interrupted_during_count(); \
+ _result = OS_INTRPT; \
+ } \
+ } \
+ } else { \
+ /* this is normal blocking io stuff */ \
+ _cmd; \
+ } \
+ _after; \
+} while(false)
+
+// Interruptible io support + restarting of interrupted system calls
+
+#ifndef ASSERT
+
+#define INTERRUPTIBLE(_cmd, _result, _clear) do { \
+ _INTERRUPTIBLE( JavaThread* _thread = (JavaThread*)ThreadLocalStorage::thread(),_result = _cmd, _result, _thread, _clear, , , UseVMInterruptibleIO); \
+} while((_result == OS_ERR) && (errno == EINTR))
+
+#else
+
+// This adds an assertion that it is only called from thread_in_native
+// The call overhead is skipped for performance in product mode
+#define INTERRUPTIBLE(_cmd, _result, _clear) do { \
+ _INTERRUPTIBLE(JavaThread* _thread = os::Bsd::setup_interruptible_native(), _result = _cmd, _result, _thread, _clear, , os::Bsd::cleanup_interruptible_native(_thread), UseVMInterruptibleIO ); \
+} while((_result == OS_ERR) && (errno == EINTR))
+
+#endif
+
+// Used for calls from _thread_in_vm, not from _thread_in_native
+#define INTERRUPTIBLE_VM(_cmd, _result, _clear) do { \
+ _INTERRUPTIBLE(JavaThread* _thread = os::Bsd::setup_interruptible(), _result = _cmd, _result, _thread, _clear, , os::Bsd::cleanup_interruptible(_thread), UseVMInterruptibleIO ); \
+} while((_result == OS_ERR) && (errno == EINTR))
+
+/* Use NORESTART when the system call cannot return EINTR, when something other
+ than a system call is being invoked, or when the caller must do EINTR
+ handling. */
+
+#ifndef ASSERT
+
+#define INTERRUPTIBLE_NORESTART(_cmd, _result, _clear) \
+ _INTERRUPTIBLE( JavaThread* _thread = (JavaThread*)ThreadLocalStorage::thread(),_result = _cmd, _result, _thread, _clear, , , UseVMInterruptibleIO)
+
+#else
+
+// This adds an assertion that it is only called from thread_in_native
+// The call overhead is skipped for performance in product mode
+#define INTERRUPTIBLE_NORESTART(_cmd, _result, _clear) \
+ _INTERRUPTIBLE(JavaThread* _thread = os::Bsd::setup_interruptible_native(), _result = _cmd, _result, _thread, _clear, , os::Bsd::cleanup_interruptible_native(_thread), UseVMInterruptibleIO )
+
+#endif
+
+// Don't attend to UseVMInterruptibleIO. Always allow interruption.
+// Also assumes that it is called from the _thread_blocked state.
+// Used by os_sleep().
+
+#define INTERRUPTIBLE_NORESTART_VM_ALWAYS(_cmd, _result, _thread, _clear) \
+ _INTERRUPTIBLE(os::Bsd::setup_interruptible_already_blocked(_thread), _result = _cmd, _result, _thread, _clear, , , true )
+
+#define INTERRUPTIBLE_RETURN_INT(_cmd, _clear) do { \
+ int _result; \
+ do { \
+ INTERRUPTIBLE(_cmd, _result, _clear); \
+ } while((_result == OS_ERR) && (errno == EINTR)); \
+ return _result; \
+} while(false)
+
+#define INTERRUPTIBLE_RETURN_INT_VM(_cmd, _clear) do { \
+ int _result; \
+ do { \
+ INTERRUPTIBLE_VM(_cmd, _result, _clear); \
+ } while((_result == OS_ERR) && (errno == EINTR)); \
+ return _result; \
+} while(false)
+
+#define INTERRUPTIBLE_RETURN_INT_NORESTART(_cmd, _clear) do { \
+ int _result; \
+ INTERRUPTIBLE_NORESTART(_cmd, _result, _clear); \
+ return _result; \
+} while(false)
// macros for restartable system calls

View File

@ -1,6 +1,6 @@
$OpenBSD: patch-jdk_make_common_Defs-bsd_gmk,v 1.4 2009/05/23 03:03:25 kurt Exp $
--- jdk/make/common/Defs-bsd.gmk.orig Mon May 18 10:55:28 2009
+++ jdk/make/common/Defs-bsd.gmk Mon May 18 11:08:55 2009
$OpenBSD: patch-jdk_make_common_Defs-bsd_gmk,v 1.5 2009/06/10 19:01:09 kurt Exp $
--- jdk/make/common/Defs-bsd.gmk.orig Sat May 30 10:12:02 2009
+++ jdk/make/common/Defs-bsd.gmk Sat May 30 10:16:07 2009
@@ -43,12 +43,6 @@
# Get shared JDK settings
include $(JDK_MAKE_SHARED_DIR)/Defs.gmk
@ -125,16 +125,14 @@ $OpenBSD: patch-jdk_make_common_Defs-bsd_gmk,v 1.4 2009/05/23 03:03:25 kurt Exp
override LEX_LIBRARY = -lfl
ifeq ($(STATIC_CXX),true)
override LIBCXX = -Wl,-Bstatic -lstdc++ -lgcc -Wl,-Bdynamic
@@ -296,13 +276,9 @@ override LIBPOSIX4 =
override LIBSOCKET =
@@ -297,12 +277,8 @@ override LIBSOCKET =
override LIBTHREAD =
override MOOT_PRIORITIES = true
-override NO_INTERRUPTIBLE_IO = true
override NO_INTERRUPTIBLE_IO = true
-override OPENWIN_HOME = /usr/X11R6
-ifeq ($(ARCH), amd64)
-override OPENWIN_LIB = $(OPENWIN_HOME)/lib64
-else
+override NO_INTERRUPTIBLE_IO = false
+override OPENWIN_HOME = $(X11_PATH)
override OPENWIN_LIB = $(OPENWIN_HOME)/lib
-endif

View File

@ -1,6 +1,6 @@
$OpenBSD: patch-jdk_make_common_shared_Platform_gmk,v 1.4 2009/05/23 03:03:25 kurt Exp $
--- jdk/make/common/shared/Platform.gmk.orig Fri May 8 03:34:14 2009
+++ jdk/make/common/shared/Platform.gmk Tue May 19 08:31:38 2009
$OpenBSD: patch-jdk_make_common_shared_Platform_gmk,v 1.5 2009/06/10 19:01:09 kurt Exp $
--- jdk/make/common/shared/Platform.gmk.orig Thu May 14 03:29:40 2009
+++ jdk/make/common/shared/Platform.gmk Wed Jun 3 16:15:54 2009
@@ -82,7 +82,7 @@ SYSTEM_UNAME := $(shell uname)
SCM_DIRs = .hg .svn CVS RCS SCCS Codemgr_wsdata deleted_files .hgignore .hgtags
# When changing SCM_DIRs also change SCM_DIRS_rexp and SCM_DIRS_prune:
@ -10,7 +10,7 @@ $OpenBSD: patch-jdk_make_common_shared_Platform_gmk,v 1.4 2009/05/23 03:03:25 ku
# Don't define this unless it's not defined
ifndef VARIANT
@@ -211,6 +211,85 @@ ifeq ($(SYSTEM_UNAME), Linux)
@@ -211,6 +211,89 @@ ifeq ($(SYSTEM_UNAME), Linux)
MB_OF_MEMORY := $(shell free -m | fgrep Mem: | awk '{print $$2;}' )
endif
@ -90,13 +90,17 @@ $OpenBSD: patch-jdk_make_common_shared_Platform_gmk,v 1.4 2009/05/23 03:03:25 ku
+ # a fully built workspace.
+ REQUIRED_FREE_SPACE=1500000
+ # How much RAM does this machine have:
+ MB_OF_MEMORY=$(shell sysctl -n hw.physmem | awk '{print int($$NF / 1048576); }' )
+ ifeq ($(OS_VENDOR), OpenBSD)
+ MB_OF_MEMORY=$(shell sysctl -n hw.physmem | awk '{print int($$NF / 1048576); }' )
+ else
+ MB_OF_MEMORY=$(shell (sysctl -n hw.physmem64 2> /dev/null || sysctl -n hw.physmem) | awk '{print int($$NF / 1048576); }' )
+ endif
+endif
+
# Windows with and without CYGWIN will be slightly different
ifeq ($(SYSTEM_UNAME), Windows_NT)
PLATFORM = windows
@@ -376,11 +455,26 @@ ifneq ($(PLATFORM), windows)
@@ -376,11 +459,26 @@ ifneq ($(PLATFORM), windows)
ARCH_VM_SUBDIR=jre/lib/$(LIBARCH)
endif
@ -123,7 +127,7 @@ $OpenBSD: patch-jdk_make_common_shared_Platform_gmk,v 1.4 2009/05/23 03:03:25 ku
ifeq ($(JDK_HAS_MEM_INFO),)
JDK_HAS_MEM_INFO=true
export JDK_HAS_MEM_INFO
@@ -395,7 +489,7 @@ ifeq ($(JDK_HAS_MEM_INFO),)
@@ -395,7 +493,7 @@ ifeq ($(JDK_HAS_MEM_INFO),)
if [ $(MB_OF_MEMORY) -le 1024 ] ; then \
expr $(MB_OF_MEMORY) '-' 128 2> $(DEV_NULL) ; \
else \

View File

@ -1,7 +1,7 @@
$OpenBSD: patch-jdk_make_java_hpi_native_Makefile,v 1.1 2008/03/19 18:05:45 kurt Exp $
--- jdk/make/java/hpi/native/Makefile.orig Tue Oct 30 05:04:22 2007
+++ jdk/make/java/hpi/native/Makefile Wed Nov 7 18:01:59 2007
@@ -72,11 +72,18 @@ OTHER_CPPFLAGS += -DUSE_PTHREADS
$OpenBSD: patch-jdk_make_java_hpi_native_Makefile,v 1.2 2009/06/10 19:01:09 kurt Exp $
--- jdk/make/java/hpi/native/Makefile.orig Thu May 14 03:29:40 2009
+++ jdk/make/java/hpi/native/Makefile Tue Jun 2 12:12:03 2009
@@ -72,16 +72,25 @@ OTHER_CPPFLAGS += -DUSE_PTHREADS
ifeq ($(MOOT_PRIORITIES),true)
OTHER_CPPFLAGS += -DMOOT_PRIORITIES
endif
@ -20,3 +20,10 @@ $OpenBSD: patch-jdk_make_java_hpi_native_Makefile,v 1.1 2008/03/19 18:05:45 kurt
ifeq ($(HAVE_GETHRVTIME),true)
OTHER_CPPFLAGS += -DHAVE_GETHRVTIME
endif
+ifneq ($(OS_VENDOR), OpenBSD)
HAVE_FILIOH=true
+endif
ifeq ($(HAVE_FILIOH),true)
OTHER_CPPFLAGS += -DHAVE_FILIOH
endif

View File

@ -1,7 +1,7 @@
$OpenBSD: patch-jdk_make_java_nio_Makefile,v 1.4 2009/05/23 03:03:25 kurt Exp $
--- jdk/make/java/nio/Makefile.orig Fri May 8 03:34:15 2009
+++ jdk/make/java/nio/Makefile Tue May 19 11:48:56 2009
@@ -260,6 +260,66 @@ FILES_gen += \
$OpenBSD: patch-jdk_make_java_nio_Makefile,v 1.5 2009/06/10 19:01:09 kurt Exp $
--- jdk/make/java/nio/Makefile.orig Thu May 14 03:29:41 2009
+++ jdk/make/java/nio/Makefile Tue Jun 2 12:12:32 2009
@@ -260,6 +260,69 @@ FILES_gen += \
sun/nio/fs/UnixConstants.java
endif # PLATFORM = linux
@ -20,6 +20,7 @@ $OpenBSD: patch-jdk_make_java_nio_Makefile,v 1.4 2009/05/23 03:03:25 kurt Exp $
+ sun/nio/fs/BsdFileStore.java \
+ sun/nio/fs/BsdFileSystem.java \
+ sun/nio/fs/BsdFileSystemProvider.java \
+ sun/nio/fs/BsdNativeDispatcher.java \
+ sun/nio/fs/PollingWatchService.java \
+ sun/nio/fs/UnixChannelFactory.java \
+ sun/nio/fs/UnixCopyFile.java \
@ -48,6 +49,7 @@ $OpenBSD: patch-jdk_make_java_nio_Makefile,v 1.4 2009/05/23 03:03:25 kurt Exp $
+ UnixAsynchronousSocketChannelImpl.c \
+ \
+ GnomeFileTypeDetector.c \
+ BsdNativeDispatcher.c \
+ UnixCopyFile.c \
+ UnixNativeDispatcher.c
+
@ -58,6 +60,7 @@ $OpenBSD: patch-jdk_make_java_nio_Makefile,v 1.4 2009/05/23 03:03:25 kurt Exp $
+ sun/nio/ch/UnixAsynchronousSocketChannelImpl.java \
+ \
+ sun/nio/fs/GnomeFileTypeDetector.java \
+ sun/nio/fs/BsdNativeDispatcher.java \
+ sun/nio/fs/UnixCopyFile.java \
+ sun/nio/fs/UnixNativeDispatcher.java
+
@ -68,7 +71,7 @@ $OpenBSD: patch-jdk_make_java_nio_Makefile,v 1.4 2009/05/23 03:03:25 kurt Exp $
#
# Find platform-specific C source files
#
@@ -284,6 +344,11 @@ OTHER_INCLUDES += \
@@ -284,6 +347,11 @@ OTHER_INCLUDES += \
-I$(PLATFORM_SRC)/native/java/net \
-I$(CLASSHDRDIR)/../../../java.lang/java/CClassHeaders
@ -80,7 +83,7 @@ $OpenBSD: patch-jdk_make_java_nio_Makefile,v 1.4 2009/05/23 03:03:25 kurt Exp $
ifeq ($(PLATFORM),windows)
OTHER_LDLIBS += $(JVMLIB) ws2_32.lib \
-libpath:$(LIBDIR) java.lib \
@@ -294,6 +359,9 @@ endif
@@ -294,6 +362,9 @@ endif
ifeq ($(PLATFORM), linux)
OTHER_LDLIBS += -L$(LIBDIR)/$(LIBARCH) -ljava -lnet -lpthread -ldl
endif
@ -90,7 +93,7 @@ $OpenBSD: patch-jdk_make_java_nio_Makefile,v 1.4 2009/05/23 03:03:25 kurt Exp $
ifeq ($(PLATFORM), solaris)
OTHER_LDLIBS += $(JVMLIB) $(LIBSOCKET) -lposix4 -ldl \
-L$(LIBDIR)/$(LIBARCH) -ljava -lnet
@@ -315,6 +383,9 @@ FILES_m = mapfile-solaris
@@ -315,6 +386,9 @@ FILES_m = mapfile-solaris
endif
ifeq ($(PLATFORM), linux)
FILES_m = mapfile-linux

View File

@ -0,0 +1,60 @@
$OpenBSD: patch-jdk_make_java_nio_mapfile-bsd,v 1.1 2009/06/10 19:01:09 kurt Exp $
--- jdk/make/java/nio/mapfile-bsd.orig Tue Jun 2 12:13:16 2009
+++ jdk/make/java/nio/mapfile-bsd Tue Jun 2 12:13:24 2009
@@ -36,25 +36,6 @@ SUNWprivate_1.1 {
Java_sun_nio_ch_DatagramDispatcher_readv0;
Java_sun_nio_ch_DatagramDispatcher_write0;
Java_sun_nio_ch_DatagramDispatcher_writev0;
- Java_sun_nio_ch_EPollArrayWrapper_epollCreate;
- Java_sun_nio_ch_EPollArrayWrapper_epollCtl;
- Java_sun_nio_ch_EPollArrayWrapper_epollWait;
- Java_sun_nio_ch_EPollArrayWrapper_fdLimit;
- Java_sun_nio_ch_EPollArrayWrapper_init;
- Java_sun_nio_ch_EPollArrayWrapper_interrupt;
- Java_sun_nio_ch_EPollArrayWrapper_offsetofData;
- Java_sun_nio_ch_EPollArrayWrapper_sizeofEPollEvent;
- Java_sun_nio_ch_EPoll_init;
- Java_sun_nio_ch_EPoll_eventSize;
- Java_sun_nio_ch_EPoll_eventsOffset;
- Java_sun_nio_ch_EPoll_dataOffset;
- Java_sun_nio_ch_EPoll_epollCreate;
- Java_sun_nio_ch_EPoll_epollCtl;
- Java_sun_nio_ch_EPoll_epollWait;
- Java_sun_nio_ch_EPollPort_close0;
- Java_sun_nio_ch_EPollPort_drain1;
- Java_sun_nio_ch_EPollPort_interrupt;
- Java_sun_nio_ch_EPollPort_socketpair;
Java_sun_nio_ch_FileChannelImpl_close0;
Java_sun_nio_ch_FileChannelImpl_initIDs;
Java_sun_nio_ch_FileChannelImpl_map0;
@@ -122,26 +103,14 @@ SUNWprivate_1.1 {
Java_sun_nio_ch_UnixAsynchronousServerSocketChannelImpl_accept0;
Java_sun_nio_ch_UnixAsynchronousServerSocketChannelImpl_initIDs;
Java_sun_nio_ch_UnixAsynchronousSocketChannelImpl_checkConnect;
+ Java_sun_nio_fs_BsdNativeDispatcher_initIDs;
+ Java_sun_nio_fs_BsdNativeDispatcher_getfsstat;
+ Java_sun_nio_fs_BsdNativeDispatcher_fsstatEntry;
+ Java_sun_nio_fs_BsdNativeDispatcher_endfsstat;
Java_sun_nio_fs_GnomeFileTypeDetector_initializeGio;
Java_sun_nio_fs_GnomeFileTypeDetector_probeUsingGio;
Java_sun_nio_fs_GnomeFileTypeDetector_initializeGnomeVfs;
Java_sun_nio_fs_GnomeFileTypeDetector_probeUsingGnomeVfs;
- Java_sun_nio_fs_BsdWatchService_init;
- Java_sun_nio_fs_BsdWatchService_eventSize;
- Java_sun_nio_fs_BsdWatchService_eventOffsets;
- Java_sun_nio_fs_BsdWatchService_inotifyInit;
- Java_sun_nio_fs_BsdWatchService_inotifyAddWatch;
- Java_sun_nio_fs_BsdWatchService_inotifyRmWatch;
- Java_sun_nio_fs_BsdWatchService_configureBlocking;
- Java_sun_nio_fs_BsdWatchService_socketpair;
- Java_sun_nio_fs_BsdWatchService_poll;
- Java_sun_nio_fs_BsdNativeDispatcher_init;
- Java_sun_nio_fs_BsdNativeDispatcher_fgetxattr0;
- Java_sun_nio_fs_BsdNativeDispatcher_flistxattr;
- Java_sun_nio_fs_BsdNativeDispatcher_fsetxattr0;
- Java_sun_nio_fs_BsdNativeDispatcher_fremovexattr0;
- Java_sun_nio_fs_BsdNativeDispatcher_setmntent0;
- Java_sun_nio_fs_BsdNativeDispatcher_endmntent;
Java_sun_nio_fs_UnixNativeDispatcher_initIDs;
Java_sun_nio_fs_UnixNativeDispatcher_getcwd;
Java_sun_nio_fs_UnixNativeDispatcher_strerror;

View File

@ -1,19 +1,7 @@
$OpenBSD: patch-jdk_make_java_redist_Makefile,v 1.3 2009/05/23 03:03:25 kurt Exp $
--- jdk/make/java/redist/Makefile.orig Fri May 8 03:34:15 2009
+++ jdk/make/java/redist/Makefile Mon May 18 13:01:01 2009
@@ -85,6 +85,11 @@ ifeq ($(SA_EXISTS), false)
INCLUDE_SA := false
endif
+# FIXME: Remove when the build of libsaproc is fixed.
+ifeq ($(PLATFORM), bsd)
+ INCLUDE_SA := false
+endif
+
ifeq ($(INCLUDE_SA), true)
IMPORT_LIST += $(LIBDIR)/sa-jdi.jar \
$(LIB_LOCATION)/$(SALIB_NAME)
@@ -311,7 +316,7 @@ $(LIBDIR)/fonts/%.ttf: $(CLOSED_SRC)/share/lib/fonts/%
$OpenBSD: patch-jdk_make_java_redist_Makefile,v 1.4 2009/06/10 19:01:09 kurt Exp $
--- jdk/make/java/redist/Makefile.orig Thu May 14 03:29:41 2009
+++ jdk/make/java/redist/Makefile Tue Jun 2 12:13:48 2009
@@ -311,7 +311,7 @@ $(LIBDIR)/fonts/%.ttf: $(CLOSED_SRC)/share/lib/fonts/%
$(FONTSDIRFILE): $(PLATFORM_SRC)/classes/sun/awt/motif/java.fonts.dir
$(install-file)
@ -22,7 +10,7 @@ $OpenBSD: patch-jdk_make_java_redist_Makefile,v 1.3 2009/05/23 03:03:25 kurt Exp
# The oblique fonts are only needed/wanted on Linux.
@@ -325,7 +330,7 @@ $(LIBDIR)/oblique-fonts/%.ttf: $(CLOSED_SRC)/share/lib
@@ -325,7 +325,7 @@ $(LIBDIR)/oblique-fonts/%.ttf: $(CLOSED_SRC)/share/lib
$(OBLFONTSDIRFILE): $(PLATFORM_SRC)/classes/sun/awt/motif/java.oblique-fonts.dir
$(install-file)

View File

@ -1,6 +1,6 @@
$OpenBSD: patch-jdk_src_share_bin_java_c,v 1.1 2009/05/23 03:03:25 kurt Exp $
--- jdk/src/share/bin/java.c.orig Mon May 18 13:32:27 2009
+++ jdk/src/share/bin/java.c Mon May 18 13:32:35 2009
$OpenBSD: patch-jdk_src_share_bin_java_c,v 1.2 2009/06/10 19:01:09 kurt Exp $
--- jdk/src/share/bin/java.c.orig Thu May 14 03:29:45 2009
+++ jdk/src/share/bin/java.c Tue Jun 2 12:14:00 2009
@@ -68,6 +68,10 @@ static jboolean showVersion = JNI_FALSE; /* print but
static jboolean printUsage = JNI_FALSE; /* print and exit*/
static jboolean printXUsage = JNI_FALSE; /* print and exit*/
@ -42,18 +42,20 @@ $OpenBSD: patch-jdk_src_share_bin_java_c,v 1.1 2009/05/23 03:03:25 kurt Exp $
}
#define CHECK_EXCEPTION_NULL_LEAVE(e) \
@@ -969,6 +984,10 @@ ParseArguments(int *pargc, char ***pargv, char **pjarf
@@ -969,6 +984,12 @@ ParseArguments(int *pargc, char ***pargv, char **pjarf
} else if (JLI_StrCmp(arg, "-X") == 0) {
printXUsage = JNI_TRUE;
return JNI_TRUE;
+#ifdef __APPLE__
+ } else if (JLI_StrCmp(arg, "-XstartOnFirstThread") == 0) {
+ continueInSameThread = JNI_TRUE;
+ } else if (JLI_StrCCmp(arg, "-Xdock:") == 0) {
+ // XXXDARWIN: Apple VM supports configuration of Dock icon and name via -Xdock:
+#endif
/*
* The following case provide backward compatibility with old-style
* command line options.
@@ -1855,6 +1874,44 @@ ContinueInNewThread(InvocationFunctions* ifn, int argc
@@ -1855,6 +1876,44 @@ ContinueInNewThread(InvocationFunctions* ifn, int argc
return (ret != 0) ? ret : rslt;
}
}

View File

@ -1,15 +1,19 @@
$OpenBSD: patch-jdk_src_share_native_com_sun_java_util_jar_pack_main_cpp,v 1.2 2009/01/04 23:25:16 kurt Exp $
--- jdk/src/share/native/com/sun/java/util/jar/pack/main.cpp.orig Thu Nov 20 03:44:48 2008
+++ jdk/src/share/native/com/sun/java/util/jar/pack/main.cpp Tue Dec 23 17:49:46 2008
@@ -22,6 +22,7 @@
$OpenBSD: patch-jdk_src_share_native_com_sun_java_util_jar_pack_main_cpp,v 1.3 2009/06/10 19:01:09 kurt Exp $
--- jdk/src/share/native/com/sun/java/util/jar/pack/main.cpp.orig Thu May 14 03:30:18 2009
+++ jdk/src/share/native/com/sun/java/util/jar/pack/main.cpp Tue Jun 2 12:14:34 2009
@@ -22,6 +22,11 @@
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
+#ifdef _ALLBSD_SOURCE
+#include <stdint.h>
+#else
+#include <sys/stdint.h>
+#endif
#include <sys/types.h>
#include <stdio.h>
@@ -35,7 +36,7 @@
@@ -35,7 +40,7 @@
#if defined(unix) && !defined(PRODUCT)
#include "pthread.h"
@ -18,7 +22,7 @@ $OpenBSD: patch-jdk_src_share_native_com_sun_java_util_jar_pack_main_cpp,v 1.2 2
#endif
#include "defines.h"
@@ -58,9 +59,9 @@ int main(int argc, char **argv) {
@@ -58,9 +63,9 @@ int main(int argc, char **argv) {
// Single-threaded, implementation, not reentrant.
// Includes a weak error check against MT access.
#ifndef THREAD_SELF
@ -30,7 +34,7 @@ $OpenBSD: patch-jdk_src_share_native_com_sun_java_util_jar_pack_main_cpp,v 1.2 2
unpacker* unpacker::non_mt_current = null;
unpacker* unpacker::current() {
@@ -69,7 +70,7 @@ unpacker* unpacker::current() {
@@ -69,7 +74,7 @@ unpacker* unpacker::current() {
}
static void set_current_unpacker(unpacker* u) {
unpacker::non_mt_current = u;

View File

@ -1,12 +1,11 @@
$OpenBSD: patch-jdk_src_solaris_classes_sun_nio_fs_BsdFileSystem_java,v 1.1 2009/05/23 03:03:25 kurt Exp $
--- jdk/src/solaris/classes/sun/nio/fs/BsdFileSystem.java.orig Tue May 19 11:45:57 2009
+++ jdk/src/solaris/classes/sun/nio/fs/BsdFileSystem.java Tue May 19 16:41:08 2009
@@ -31,55 +31,24 @@ import java.io.IOException;
$OpenBSD: patch-jdk_src_solaris_classes_sun_nio_fs_BsdFileSystem_java,v 1.2 2009/06/10 19:01:09 kurt Exp $
--- jdk/src/solaris/classes/sun/nio/fs/BsdFileSystem.java.orig Sat May 30 11:21:14 2009
+++ jdk/src/solaris/classes/sun/nio/fs/BsdFileSystem.java Tue Jun 2 12:15:02 2009
@@ -31,55 +31,23 @@ import java.io.IOException;
import java.util.*;
import java.security.AccessController;
import sun.security.action.GetPropertyAction;
-import static sun.nio.fs.BsdNativeDispatcher.*;
+import static sun.nio.fs.UnixNativeDispatcher.*;
/**
* Bsd implementation of FileSystem
@ -60,7 +59,7 @@ $OpenBSD: patch-jdk_src_solaris_classes_sun_nio_fs_BsdFileSystem_java,v 1.1 2009
}
@Override
@@ -88,10 +57,6 @@ class BsdFileSystem extends UnixFileSystem {
@@ -88,10 +56,6 @@ class BsdFileSystem extends UnixFileSystem {
UnixPath file,
LinkOption... options)
{
@ -71,7 +70,7 @@ $OpenBSD: patch-jdk_src_solaris_classes_sun_nio_fs_BsdFileSystem_java,v 1.1 2009
return super.newFileAttributeView(view, file, options);
}
@@ -101,10 +66,6 @@ class BsdFileSystem extends UnixFileSystem {
@@ -101,10 +65,6 @@ class BsdFileSystem extends UnixFileSystem {
UnixPath file,
LinkOption... options)
{
@ -82,7 +81,7 @@ $OpenBSD: patch-jdk_src_solaris_classes_sun_nio_fs_BsdFileSystem_java,v 1.1 2009
return super.newFileAttributeView(name, file, options);
}
@@ -115,9 +76,6 @@ class BsdFileSystem extends UnixFileSystem {
@@ -115,9 +75,6 @@ class BsdFileSystem extends UnixFileSystem {
private static Set<String> supportedFileAttributeViews() {
Set<String> result = new HashSet<String>();
result.addAll(UnixFileSystem.standardFileAttributeViews());
@ -92,7 +91,7 @@ $OpenBSD: patch-jdk_src_solaris_classes_sun_nio_fs_BsdFileSystem_java,v 1.1 2009
return Collections.unmodifiableSet(result);
}
}
@@ -129,22 +87,22 @@ class BsdFileSystem extends UnixFileSystem {
@@ -129,32 +86,31 @@ class BsdFileSystem extends UnixFileSystem {
@Override
void copyNonPosixAttributes(int ofd, int nfd) {
@ -107,24 +106,26 @@ $OpenBSD: patch-jdk_src_solaris_classes_sun_nio_fs_BsdFileSystem_java,v 1.1 2009
/**
- * Returns object to iterate over entries in /etc/mtab
+ * Returns object to iterate over entries in /etc/fstab
+ * Returns object to iterate over mount entries
*/
@Override
Iterable<UnixMountEntry> getMountEntries() {
ArrayList<UnixMountEntry> entries = new ArrayList<UnixMountEntry>();
try {
- long fp = setmntent("/etc/mtab".getBytes(), "r".getBytes());
+ UnixPath fstab = new UnixPath(this, "/etc/fstab");
+ long fp = fopen(fstab, "r");
+ long iter = BsdNativeDispatcher.getfsstat();
try {
for (;;) {
UnixMountEntry entry = new UnixMountEntry();
@@ -154,7 +112,7 @@ class BsdFileSystem extends UnixFileSystem {
- int res = getextmntent(fp, entry);
+ int res = BsdNativeDispatcher.fsstatEntry(iter, entry);
if (res < 0)
break;
entries.add(entry);
}
} finally {
- endmntent(fp);
+ fclose(fp);
+ BsdNativeDispatcher.endfsstat(iter);
}
} catch (UnixException x) {

View File

@ -0,0 +1,113 @@
$OpenBSD: patch-jdk_src_solaris_classes_sun_nio_fs_BsdNativeDispatcher_java,v 1.1 2009/06/10 19:01:09 kurt Exp $
--- jdk/src/solaris/classes/sun/nio/fs/BsdNativeDispatcher.java.orig Tue Jun 2 13:13:56 2009
+++ jdk/src/solaris/classes/sun/nio/fs/BsdNativeDispatcher.java Tue Jun 2 13:14:02 2009
@@ -1,5 +1,5 @@
/*
- * Copyright 2008-2009 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -36,84 +36,23 @@ class BsdNativeDispatcher extends UnixNativeDispatcher
private BsdNativeDispatcher() { }
/**
- * FILE *setmntent(const char *filename, const char *type);
+ * struct fsstat_iter *getfsstat();
*/
- static long setmntent(byte[] filename, byte[] type) throws UnixException {
- NativeBuffer pathBuffer = NativeBuffers.asNativeBuffer(filename);
- NativeBuffer typeBuffer = NativeBuffers.asNativeBuffer(type);
- try {
- return setmntent0(pathBuffer.address(), typeBuffer.address());
- } finally {
- typeBuffer.release();
- pathBuffer.release();
- }
- }
- private static native long setmntent0(long pathAddress, long typeAddress)
- throws UnixException;
+ static native long getfsstat() throws UnixException;
/**
- * int endmntent(FILE* filep);
+ * int fsstatEntry(struct fsstat_iter * iter, UnixMountEntry entry);
*/
- static native void endmntent(long stream) throws UnixException;
-
- /**
- * ssize_t fgetxattr(int filedes, const char *name, void *value, size_t size);
- */
- static int fgetxattr(int filedes, byte[] name, long valueAddress,
- int valueLen) throws UnixException
- {
- NativeBuffer buffer = NativeBuffers.asNativeBuffer(name);
- try {
- return fgetxattr0(filedes, buffer.address(), valueAddress, valueLen);
- } finally {
- buffer.release();
- }
- }
-
- private static native int fgetxattr0(int filedes, long nameAddress,
- long valueAdddress, int valueLen) throws UnixException;
-
- /**
- * fsetxattr(int filedes, const char *name, const void *value, size_t size, int flags);
- */
- static void fsetxattr(int filedes, byte[] name, long valueAddress,
- int valueLen) throws UnixException
- {
- NativeBuffer buffer = NativeBuffers.asNativeBuffer(name);
- try {
- fsetxattr0(filedes, buffer.address(), valueAddress, valueLen);
- } finally {
- buffer.release();
- }
- }
-
- private static native void fsetxattr0(int filedes, long nameAddress,
- long valueAdddress, int valueLen) throws UnixException;
-
-
- /**
- * fremovexattr(int filedes, const char *name);
- */
- static void fremovexattr(int filedes, byte[] name) throws UnixException {
- NativeBuffer buffer = NativeBuffers.asNativeBuffer(name);
- try {
- fremovexattr0(filedes, buffer.address());
- } finally {
- buffer.release();
- }
- }
-
- private static native void fremovexattr0(int filedes, long nameAddress)
+ static native int fsstatEntry(long iter, UnixMountEntry entry)
throws UnixException;
- /**
- * size_t flistxattr(int filedes, const char *list, size_t size)
- */
- static native int flistxattr(int filedes, long listAddress, int size)
- throws UnixException;
+ /**
+ * void endfsstat(struct fsstat_iter * iter);
+ */
+ static native void endfsstat(long iter) throws UnixException;
- // initialize
- private static native void init();
+ // initialize field IDs
+ private static native void initIDs();
static {
AccessController.doPrivileged(new PrivilegedAction<Void>() {
@@ -121,6 +60,6 @@ class BsdNativeDispatcher extends UnixNativeDispatcher
System.loadLibrary("nio");
return null;
}});
- init();
+ initIDs();
}
}

View File

@ -1,25 +0,0 @@
$OpenBSD: patch-jdk_src_solaris_hpi_native_threads_src_sys_api_td_c,v 1.1 2008/03/19 18:05:46 kurt Exp $
--- jdk/src/solaris/hpi/native_threads/src/sys_api_td.c.orig Tue Oct 30 05:04:03 2007
+++ jdk/src/solaris/hpi/native_threads/src/sys_api_td.c Wed Nov 7 18:16:19 2007
@@ -39,6 +39,10 @@
#include <sys/ioctl.h>
#endif
+#ifdef __OpenBSD__
+#include <sys/ioctl.h>
+#endif
+
#include <sys/socket.h>
#include <setjmp.h>
#include <signal.h>
@@ -54,6 +58,10 @@
#include "mutex_md.h"
#if defined(__solaris__) && defined(NO_INTERRUPTIBLE_IO)
+#error If there was no policy change, this could be a makefile error.
+#endif
+
+#if defined(_ALLBSD_SOURCE) && defined(NO_INTERRUPTIBLE_IO)
#error If there was no policy change, this could be a makefile error.
#endif

View File

@ -0,0 +1,17 @@
$OpenBSD: patch-jdk_src_solaris_native_sun_nio_ch_SctpChannelImpl_c,v 1.1 2009/06/10 19:01:09 kurt Exp $
--- jdk/src/solaris/native/sun/nio/ch/SctpChannelImpl.c.orig Tue Jun 2 12:18:28 2009
+++ jdk/src/solaris/native/sun/nio/ch/SctpChannelImpl.c Tue Jun 2 12:18:37 2009
@@ -338,11 +338,11 @@ void handlePeerAddrChange
break;
case SCTP_ADDR_MADE_PRIM :
event = sun_nio_ch_SctpPeerAddrChange_SCTP_ADDR_MADE_PRIM;
-#ifdef __linux__ /* Solaris currently doesn't support SCTP_ADDR_CONFIRMED */
+#ifndef __solaris__ /* Solaris currently doesn't support SCTP_ADDR_CONFIRMED */
break;
case SCTP_ADDR_CONFIRMED :
event = sun_nio_ch_SctpPeerAddrChange_SCTP_ADDR_CONFIRMED;
-#endif /* __linux__ */
+#endif /* __solaris__ */
}
addressObj = SockAddrToInetSocketAddress(env, (struct sockaddr*)&spc->spc_aaddr);

View File

@ -0,0 +1,19 @@
$OpenBSD: patch-jdk_src_solaris_native_sun_nio_ch_SctpNet_c,v 1.1 2009/06/10 19:01:09 kurt Exp $
--- jdk/src/solaris/native/sun/nio/ch/SctpNet.c.orig Tue Jun 2 12:18:58 2009
+++ jdk/src/solaris/native/sun/nio/ch/SctpNet.c Tue Jun 2 12:19:06 2009
@@ -55,6 +55,7 @@ JNIEXPORT jint JNICALL JNI_OnLoad
*/
jboolean loadSocketExtensionFuncs
(JNIEnv* env) {
+#if !defined(__FreeBSD__) || __FreeBSD__ < 7 /* On FreeBSD 7.x these functions are in libc */
if (dlopen(nativeSctpLib, RTLD_GLOBAL | RTLD_LAZY) == NULL) {
JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
dlerror());
@@ -95,6 +96,7 @@ jboolean loadSocketExtensionFuncs
dlerror());
return JNI_FALSE;
}
+#endif /* __FreeBSD__ */
funcsLoaded = JNI_TRUE;
return JNI_TRUE;

View File

@ -0,0 +1,47 @@
$OpenBSD: patch-jdk_src_solaris_native_sun_nio_ch_Sctp_h,v 1.1 2009/06/10 19:01:09 kurt Exp $
--- jdk/src/solaris/native/sun/nio/ch/Sctp.h.orig Tue Jun 2 12:17:54 2009
+++ jdk/src/solaris/native/sun/nio/ch/Sctp.h Tue Jun 2 12:18:02 2009
@@ -65,7 +65,7 @@ typedef int sctp_freepaddrs_func(void *addrs);
typedef int sctp_bindx_func(int sock, void *addrs, int addrcnt, int flags);
-#else /* __linux__ */
+#elif __linux__
#include <stdint.h>
#include <linux/types.h>
#include <sys/socket.h>
@@ -316,13 +316,34 @@ typedef int sctp_getpaddrs_func(int sd, sctp_assoc_t i
typedef int sctp_freepaddrs_func(struct sockaddr *addrs);
typedef int sctp_bindx_func(int sd, struct sockaddr *addrs, int addrcnt, int flags);
+#elif defined(__FreeBSD__) && __FreeBSD__ >= 7
+
+#include <stdint.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/sctp.h>
+#include <netinet/sctp_uio.h>
+#include "jni.h"
+
#endif /* __linux__ */
+#if !defined(__FreeBSD__) || __FreeBSD__ < 7
+
sctp_getladdrs_func* nio_sctp_getladdrs;
sctp_freeladdrs_func* nio_sctp_freeladdrs;
sctp_getpaddrs_func* nio_sctp_getpaddrs;
sctp_freepaddrs_func* nio_sctp_freepaddrs;
sctp_bindx_func* nio_sctp_bindx;
+
+#else
+
+#define nio_sctp_getladdrs sctp_getladdrs
+#define nio_sctp_freeladdrs sctp_freeladdrs
+#define nio_sctp_getpaddrs sctp_getpaddrs
+#define nio_sctp_freepaddrs sctp_freepaddrs
+#define nio_sctp_bindx sctp_bindx
+
+#endif
jboolean loadSocketExtensionFuncs(JNIEnv* env);

View File

@ -0,0 +1,286 @@
$OpenBSD: patch-jdk_src_solaris_native_sun_nio_fs_BsdNativeDispatcher_c,v 1.1 2009/06/10 19:01:09 kurt Exp $
--- jdk/src/solaris/native/sun/nio/fs/BsdNativeDispatcher.c.orig Tue Jun 2 13:44:48 2009
+++ jdk/src/solaris/native/sun/nio/fs/BsdNativeDispatcher.c Wed Jun 3 16:14:03 2009
@@ -1,5 +1,5 @@
/*
- * Copyright 2008-2009 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,23 +28,35 @@
#include "jvm.h"
#include "jlong.h"
-#include <stdio.h>
-#include <dlfcn.h>
-#include <errno.h>
-#include <mntent.h>
+#include <sys/param.h>
+#include <sys/mount.h>
+#ifdef ST_RDONLY
+#define statfs statvfs
+#define getfsstat getvfsstat
+#define f_flags f_flag
+#define ISREADONLY ST_RDONLY
+#else
+#define ISREADONLY MNT_RDONLY
+#endif
-#include "sun_nio_fs_BsdNativeDispatcher.h"
+#include <stdlib.h>
+#include <string.h>
-typedef size_t fgetxattr_func(int fd, const char* name, void* value, size_t size);
-typedef int fsetxattr_func(int fd, const char* name, void* value, size_t size, int flags);
-typedef int fremovexattr_func(int fd, const char* name);
-typedef int flistxattr_func(int fd, char* list, size_t size);
+static jfieldID entry_name;
+static jfieldID entry_dir;
+static jfieldID entry_fstype;
+static jfieldID entry_options;
+static jfieldID entry_dev;
-fgetxattr_func* my_fgetxattr_func = NULL;
-fsetxattr_func* my_fsetxattr_func = NULL;
-fremovexattr_func* my_fremovexattr_func = NULL;
-flistxattr_func* my_flistxattr_func = NULL;
+struct fsstat_iter {
+ struct statfs *buf;
+ int pos;
+ int nentries;
+};
+
+#include "sun_nio_fs_BsdNativeDispatcher.h"
+
static void throwUnixException(JNIEnv* env, int errnum) {
jobject x = JNU_NewObjectByName(env, "sun/nio/fs/UnixException",
"(I)V", errnum);
@@ -53,108 +65,146 @@ static void throwUnixException(JNIEnv* env, int errnum
}
}
+/**
+ * Initialize jfieldIDs
+ */
JNIEXPORT void JNICALL
-Java_sun_nio_fs_BsdNativeDispatcher_init(JNIEnv *env, jclass clazz)
+Java_sun_nio_fs_BsdNativeDispatcher_initIDs(JNIEnv* env, jclass this)
{
- my_fgetxattr_func = (fgetxattr_func*)dlsym(RTLD_DEFAULT, "fgetxattr");
- my_fsetxattr_func = (fsetxattr_func*)dlsym(RTLD_DEFAULT, "fsetxattr");
- my_fremovexattr_func = (fremovexattr_func*)dlsym(RTLD_DEFAULT, "fremovexattr");
- my_flistxattr_func = (flistxattr_func*)dlsym(RTLD_DEFAULT, "flistxattr");
-}
+ jclass clazz;
-JNIEXPORT jint JNICALL
-Java_sun_nio_fs_BsdNativeDispatcher_fgetxattr0(JNIEnv* env, jclass clazz,
- jint fd, jlong nameAddress, jlong valueAddress, jint valueLen)
-{
- size_t res = -1;
- const char* name = jlong_to_ptr(nameAddress);
- void* value = jlong_to_ptr(valueAddress);
-
- if (my_fgetxattr_func == NULL) {
- errno = ENOTSUP;
- } else {
- /* EINTR not documented */
- res = (*my_fgetxattr_func)(fd, name, value, valueLen);
+ clazz = (*env)->FindClass(env, "sun/nio/fs/UnixMountEntry");
+ if (clazz == NULL) {
+ return;
}
- if (res == (size_t)-1)
- throwUnixException(env, errno);
- return (jint)res;
+ entry_name = (*env)->GetFieldID(env, clazz, "name", "[B");
+ entry_dir = (*env)->GetFieldID(env, clazz, "dir", "[B");
+ entry_fstype = (*env)->GetFieldID(env, clazz, "fstype", "[B");
+ entry_options = (*env)->GetFieldID(env, clazz, "opts", "[B");
+ entry_dev = (*env)->GetFieldID(env, clazz, "dev", "J");
}
-JNIEXPORT void JNICALL
-Java_sun_nio_fs_BsdNativeDispatcher_fsetxattr0(JNIEnv* env, jclass clazz,
- jint fd, jlong nameAddress, jlong valueAddress, jint valueLen)
+JNIEXPORT jlong JNICALL
+Java_sun_nio_fs_BsdNativeDispatcher_getfsstat(JNIEnv* env, jclass this)
{
- int res = -1;
- const char* name = jlong_to_ptr(nameAddress);
- void* value = jlong_to_ptr(valueAddress);
+ int nentries;
+ size_t bufsize;
+ struct fsstat_iter *iter = malloc(sizeof(*iter));
- if (my_fsetxattr_func == NULL) {
- errno = ENOTSUP;
- } else {
- /* EINTR not documented */
- res = (*my_fsetxattr_func)(fd, name, value, valueLen, 0);
+ if (iter == NULL) {
+ JNU_ThrowOutOfMemoryError(env, "native heap");
+ return 0;
}
- if (res == -1)
+
+ iter->pos = 0;
+ iter->nentries = 0;
+ iter->buf = NULL;
+
+ nentries = getfsstat(NULL, 0, MNT_NOWAIT);
+
+ if (nentries <= 0) {
+ free(iter);
throwUnixException(env, errno);
-}
+ return 0;
+ }
-JNIEXPORT void JNICALL
-Java_sun_nio_fs_BsdNativeDispatcher_fremovexattr0(JNIEnv* env, jclass clazz,
- jint fd, jlong nameAddress)
-{
- int res = -1;
- const char* name = jlong_to_ptr(nameAddress);
+ // It's possible that a new filesystem gets mounted between
+ // the first getfsstat and the second so loop until consistant
- if (my_fremovexattr_func == NULL) {
- errno = ENOTSUP;
- } else {
- /* EINTR not documented */
- res = (*my_fremovexattr_func)(fd, name);
+ while (nentries != iter->nentries) {
+ if (iter->buf != NULL)
+ free(iter->buf);
+
+ bufsize = nentries * sizeof(struct statfs);
+ iter->nentries = nentries;
+
+ iter->buf = malloc(bufsize);
+ if (iter->buf == NULL) {
+ free(iter);
+ JNU_ThrowOutOfMemoryError(env, "native heap");
+ return 0;
+ }
+
+ nentries = getfsstat(iter->buf, bufsize, MNT_WAIT);
+ if (nentries <= 0) {
+ free(iter->buf);
+ free(iter);
+ throwUnixException(env, errno);
+ return 0;
+ }
}
- if (res == -1)
- throwUnixException(env, errno);
+
+ return (jlong)iter;
}
JNIEXPORT jint JNICALL
-Java_sun_nio_fs_BsdNativeDispatcher_flistxattr(JNIEnv* env, jclass clazz,
- jint fd, jlong listAddress, jint size)
+Java_sun_nio_fs_BsdNativeDispatcher_fsstatEntry(JNIEnv* env, jclass this,
+ jlong value, jobject entry)
{
- size_t res = -1;
- char* list = jlong_to_ptr(listAddress);
+ struct fsstat_iter *iter = jlong_to_ptr(value);
+ jsize len;
+ jbyteArray bytes;
+ char* name;
+ char* dir;
+ char* fstype;
+ char* options;
+ dev_t dev;
- if (my_flistxattr_func == NULL) {
- errno = ENOTSUP;
- } else {
- /* EINTR not documented */
- res = (*my_flistxattr_func)(fd, list, (size_t)size);
- }
- if (res == (size_t)-1)
- throwUnixException(env, errno);
- return (jint)res;
-}
+ if (iter == NULL || iter->pos >= iter->nentries)
+ return -1;
-JNIEXPORT jlong JNICALL
-Java_sun_nio_fs_BsdNativeDispatcher_setmntent0(JNIEnv* env, jclass this, jlong pathAddress,
- jlong modeAddress)
-{
- FILE* fp = NULL;
- const char* path = (const char*)jlong_to_ptr(pathAddress);
- const char* mode = (const char*)jlong_to_ptr(modeAddress);
+ name = iter->buf[iter->pos].f_mntfromname;
+ dir = iter->buf[iter->pos].f_mntonname;
+ fstype = iter->buf[iter->pos].f_fstypename;
+ if (iter->buf[iter->pos].f_flags & ISREADONLY)
+ options="ro";
+ else
+ options="";
+ dev = 0;
- do {
- fp = setmntent(path, mode);
- } while (fp == NULL && errno == EINTR);
- if (fp == NULL) {
- throwUnixException(env, errno);
- }
- return ptr_to_jlong(fp);
+ iter->pos++;
+
+ len = strlen(name);
+ bytes = (*env)->NewByteArray(env, len);
+ if (bytes == NULL)
+ return -1;
+ (*env)->SetByteArrayRegion(env, bytes, 0, len, (jbyte*)name);
+ (*env)->SetObjectField(env, entry, entry_name, bytes);
+
+ len = strlen(dir);
+ bytes = (*env)->NewByteArray(env, len);
+ if (bytes == NULL)
+ return -1;
+ (*env)->SetByteArrayRegion(env, bytes, 0, len, (jbyte*)dir);
+ (*env)->SetObjectField(env, entry, entry_dir, bytes);
+
+ len = strlen(fstype);
+ bytes = (*env)->NewByteArray(env, len);
+ if (bytes == NULL)
+ return -1;
+ (*env)->SetByteArrayRegion(env, bytes, 0, len, (jbyte*)fstype);
+ (*env)->SetObjectField(env, entry, entry_fstype, bytes);
+
+ len = strlen(options);
+ bytes = (*env)->NewByteArray(env, len);
+ if (bytes == NULL)
+ return -1;
+ (*env)->SetByteArrayRegion(env, bytes, 0, len, (jbyte*)options);
+ (*env)->SetObjectField(env, entry, entry_options, bytes);
+
+ if (dev != 0)
+ (*env)->SetLongField(env, entry, entry_dev, (jlong)dev);
+
+ return 0;
}
JNIEXPORT void JNICALL
-Java_sun_nio_fs_BsdNativeDispatcher_endmntent(JNIEnv* env, jclass this, jlong stream)
+Java_sun_nio_fs_BsdNativeDispatcher_endfsstat(JNIEnv* env, jclass this, jlong value)
{
- FILE* fp = jlong_to_ptr(stream);
- /* FIXME - man page doesn't explain how errors are returned */
- endmntent(fp);
+ struct fsstat_iter *iter = jlong_to_ptr(value);
+
+ if (iter != NULL) {
+ free(iter->buf);
+ free(iter);
+ }
}

View File

@ -0,0 +1,13 @@
$OpenBSD: patch-jdk_src_solaris_native_sun_nio_fs_GnomeFileTypeDetector_c,v 1.1 2009/06/10 19:01:09 kurt Exp $
--- jdk/src/solaris/native/sun/nio/fs/GnomeFileTypeDetector.c.orig Tue Jun 2 12:19:48 2009
+++ jdk/src/solaris/native/sun/nio/fs/GnomeFileTypeDetector.c Tue Jun 2 12:19:56 2009
@@ -30,7 +30,9 @@
#include <stdlib.h>
#include <dlfcn.h>
+#ifndef __APPLE__
#include <link.h>
+#endif
#ifdef __solaris__
#include <strings.h>

View File

@ -1,4 +1,4 @@
@comment $OpenBSD: PLIST-main,v 1.5 2009/05/23 03:03:25 kurt Exp $
@comment $OpenBSD: PLIST-main,v 1.6 2009/06/10 19:01:09 kurt Exp $
@option no-default-conflict
@conflict jdk->=1.7,<1.8
${JDKHOME}/
@ -464,6 +464,7 @@ ${JDKHOME}/jre/lib/${MACHINE_ARCH}/libnet.so
${JDKHOME}/jre/lib/${MACHINE_ARCH}/libnio.so
${JDKHOME}/jre/lib/${MACHINE_ARCH}/libnpt.so
${JDKHOME}/jre/lib/${MACHINE_ARCH}/librmi.so
${JDKHOME}/jre/lib/${MACHINE_ARCH}/libsaproc.so
${JDKHOME}/jre/lib/${MACHINE_ARCH}/libsplashscreen.so
${JDKHOME}/jre/lib/${MACHINE_ARCH}/libunpack.so
${JDKHOME}/jre/lib/${MACHINE_ARCH}/libverify.so
@ -978,6 +979,7 @@ ${JDKHOME}/lib/dt.jar
${JDKHOME}/lib/ir.idl
${JDKHOME}/lib/jconsole.jar
${JDKHOME}/lib/orb.idl
${JDKHOME}/lib/sa-jdi.jar
${JDKHOME}/lib/tools.jar
@mandir ${JDKHOME}/man/
${JDKHOME}/man/man1/