diff -u -r -N icedtea-orig/hotspot/agent/src/os/linux/libproc_impl.c openjdk/hotspot/agent/src/os/linux/libproc_impl.c --- icedtea-orig/hotspot/agent/src/os/linux/libproc_impl.c 2008-11-22 03:11:18.000000000 +0300 +++ openjdk/hotspot/agent/src/os/linux/libproc_impl.c 2009-07-28 15:29:17.000000000 +0400 @@ -26,7 +26,14 @@ #include #include #include + +#ifndef __LSB_VERSION__ #include +#else +// Use LSB wrapper instead +#include +#endif + #include "libproc_impl.h" static const char* alt_root = NULL; @@ -97,10 +104,15 @@ // initialize libproc bool init_libproc(bool debug) { + char * error; // init debug mode _libsaproc_debug = debug; // initialize the thread_db library + if (error=lsb_debugs_init()){ + print_debug("Failed to open libthread_db library (%s). SA is not available on this system.\n",error); + return false; + } if (td_init() != TD_OK) { print_debug("libthread_db's td_init failed\n"); return false; diff -u -r -N icedtea-orig/hotspot/agent/src/os/linux/libproc_impl.h openjdk/hotspot/agent/src/os/linux/libproc_impl.h --- icedtea-orig/hotspot/agent/src/os/linux/libproc_impl.h 2008-11-22 03:11:18.000000000 +0300 +++ openjdk/hotspot/agent/src/os/linux/libproc_impl.h 2009-07-28 15:29:17.000000000 +0400 @@ -32,7 +32,11 @@ // data structures in this file mimic those of Solaris 8.0 - libproc's Pcontrol.h +#ifndef __LSB_VERSION__ #define BUF_SIZE (PATH_MAX + NAME_MAX + 1) +#else +#define BUF_SIZE (PATH_MAX + 256 + 1) +#endif // list of shared objects typedef struct lib_info { diff -u -r -N icedtea-orig/hotspot/agent/src/os/linux/proc_service.h openjdk/hotspot/agent/src/os/linux/proc_service.h --- icedtea-orig/hotspot/agent/src/os/linux/proc_service.h 2008-11-22 03:11:18.000000000 +0300 +++ openjdk/hotspot/agent/src/os/linux/proc_service.h 2009-07-28 15:29:17.000000000 +0400 @@ -26,7 +26,12 @@ #define _PROC_SERVICE_H_ #include +#ifdef __LSB_VERSION__ +// Use LSB wrapper instead +#include +#else #include +#endif // Linux does not have the proc service library, though it does provide the // thread_db library which can be used to manipulate threads without having diff -u -r -N icedtea-orig/hotspot/agent/src/os/linux/ps_proc.c openjdk/hotspot/agent/src/os/linux/ps_proc.c --- icedtea-orig/hotspot/agent/src/os/linux/ps_proc.c 2008-11-22 03:11:18.000000000 +0300 +++ openjdk/hotspot/agent/src/os/linux/ps_proc.c 2009-07-28 15:29:17.000000000 +0400 @@ -26,7 +26,11 @@ #include #include #include +#ifdef __LSB_VERSION__ +#include +#else #include +#endif #include "libproc_impl.h" #if defined(x86_64) && !defined(amd64) diff -u -r -N icedtea-orig/hotspot/make/linux/makefiles/gcc.make openjdk/hotspot/make/linux/makefiles/gcc.make --- icedtea-orig/hotspot/make/linux/makefiles/gcc.make 2009-07-28 14:31:27.000000000 +0400 +++ openjdk/hotspot/make/linux/makefiles/gcc.make 2009-07-28 17:10:48.000000000 +0400 @@ -25,8 +25,13 @@ #------------------------------------------------------------------------ # CC, CPP & AS +ifndef LSB CPP = g++$(GCC_SUFFIX) CC = gcc$(GCC_SUFFIX) +else +CPP = /opt/lsb/bin/lsbc++ +CC = /opt/lsb/bin/lsbcc +endif AS = $(CC) -c # -dumpversion in gcc-2.91 shows "egcs-2.91.66". In later version, it only @@ -136,6 +141,7 @@ #------------------------------------------------------------------------ # Linker flags +ifndef LSB # statically link libstdc++.so, work with gcc but ignored by g++ STATIC_STDCXX = -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic @@ -143,6 +149,7 @@ ifneq ("${CC_VER_MAJOR}", "2") STATIC_LIBGCC += -static-libgcc endif +endif ifeq ($(BUILDARCH), ia64) LFLAGS += -Wl,-relax diff -u -r -N icedtea-orig/hotspot/make/linux/makefiles/launcher.make openjdk/hotspot/make/linux/makefiles/launcher.make --- icedtea-orig/hotspot/make/linux/makefiles/launcher.make 2008-11-22 03:11:18.000000000 +0300 +++ openjdk/hotspot/make/linux/makefiles/launcher.make 2009-07-28 17:11:40.000000000 +0400 @@ -45,7 +45,11 @@ else LAUNCHER.o = launcher.o LFLAGS_LAUNCHER += -L `pwd` + ifndef LSB LIBS_LAUNCHER += -l$(JVM) $(LIBS) + else + LIBS_LAUNCHER += -l$(JVM) $(LIBS) -lstdc++ -lrt -lgcc_s + endif endif LINK_LAUNCHER = $(LINK.c) diff -u -r -N icedtea-orig/hotspot/make/linux/makefiles/saproc.make openjdk/hotspot/make/linux/makefiles/saproc.make --- icedtea-orig/hotspot/make/linux/makefiles/saproc.make 2009-07-28 14:31:08.000000000 +0400 +++ openjdk/hotspot/make/linux/makefiles/saproc.make 2009-07-28 17:21:58.000000000 +0400 @@ -53,6 +53,13 @@ SA_LFLAGS = $(MAPFLAG:FILENAME=$(SAMAPFILE)) +ifndef LSB +LDEBUGLIBS = -lthread_db +else +LDEBUGLIBS = -I$(GAMMADIR)/src/share/lsb/ -ldl +SASRCFILES+= $(GAMMADIR)/src/share/lsb/lsb_thread_db.c +endif + $(LIBSAPROC): $(SASRCFILES) $(SAMAPFILE) $(QUIETLY) if [ "$(BOOT_JAVA_HOME)" = "" ]; then \ echo "ALT_BOOTDIR, BOOTDIR or JAVA_HOME needs to be defined to build SA"; \ @@ -68,7 +75,7 @@ $(SASRCFILES) \ $(SA_LFLAGS) \ -o $@ \ - -lthread_db + $(LDEBUGLIBS) install_saproc: checkAndBuildSA $(QUIETLY) if [ -e $(LIBSAPROC) ] ; then \ diff -u -r -N icedtea-orig/hotspot/make/linux/makefiles/vm.make openjdk/hotspot/make/linux/makefiles/vm.make --- icedtea-orig/hotspot/make/linux/makefiles/vm.make 2009-07-28 14:31:10.000000000 +0400 +++ openjdk/hotspot/make/linux/makefiles/vm.make 2009-07-28 17:12:03.000000000 +0400 @@ -128,7 +128,9 @@ rm -f $@ cat $^ > $@ +ifndef LSB STATIC_CXX = true +endif ifdef ICEDTEA_SHARK_BUILD STATIC_CXX = false @@ -153,13 +155,17 @@ # JVM is statically linked with libgcc[_s] and libstdc++; this is needed to # get around library dependency and compatibility issues. Must use gcc not # g++ to link. + ifndef LSB ifeq ($(STATIC_CXX), true) LFLAGS_VM += $(STATIC_LIBGCC) LIBS_VM += $(STATIC_STDCXX) else LIBS_VM += -lstdc++ endif - + else + LIBS_VM += -lgcc_s -lstdc++ -lrt + endif + LIBS_VM += $(LIBS) endif ifdef ICEDTEA_ZERO_BUILD diff -u -r -N icedtea-orig/hotspot/make/solaris/makefiles/defs.make openjdk/hotspot/make/solaris/makefiles/defs.make --- icedtea-orig/hotspot/make/solaris/makefiles/defs.make 2008-11-22 03:11:18.000000000 +0300 +++ openjdk/hotspot/make/solaris/makefiles/defs.make 2009-07-28 17:22:09.000000000 +0400 @@ -88,3 +88,6 @@ EXPORT_LIST += $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.so EXPORT_LIST += $(EXPORT_LIB_DIR)/sa-jdi.jar +#ifref LSB +EXPORT_LIST += $(EXPORT_JRE_LIB_ARCH_DIR)/liblsb_debugs.so +#endif diff -u -r -N icedtea-orig/hotspot/make/solaris/makefiles/gcc.make openjdk/hotspot/make/solaris/makefiles/gcc.make --- icedtea-orig/hotspot/make/solaris/makefiles/gcc.make 2009-07-28 14:31:21.000000000 +0400 +++ openjdk/hotspot/make/solaris/makefiles/gcc.make 2009-07-28 17:12:34.000000000 +0400 @@ -136,13 +136,15 @@ # Linker flags # statically link libstdc++.so, work with gcc but ignored by g++ +ifndef LSB STATIC_STDCXX = -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic # statically link libgcc and/or libgcc_s, libgcc does not exist before gcc-3.x. ifneq ("${CC_VER_MAJOR}", "2") STATIC_LIBGCC += -static-libgcc endif - +endif + ifeq ($(BUILDARCH), ia64) # Note: all ia64 setting reflect the ones for linux # No actial testing was performed: there is no Solaris on ia64 presently diff -u -r -N icedtea-orig/hotspot/src/os/linux/vm/hpi_linux.hpp openjdk/hotspot/src/os/linux/vm/hpi_linux.hpp --- icedtea-orig/hotspot/src/os/linux/vm/hpi_linux.hpp 2008-11-22 03:11:18.000000000 +0300 +++ openjdk/hotspot/src/os/linux/vm/hpi_linux.hpp 2009-07-28 15:19:09.000000000 +0400 @@ -28,6 +28,7 @@ // #include +#include #include #include #include diff -u -r -N icedtea-orig/hotspot/src/os/linux/vm/os_linux.cpp openjdk/hotspot/src/os/linux/vm/os_linux.cpp --- icedtea-orig/hotspot/src/os/linux/vm/os_linux.cpp 2009-07-28 14:31:16.000000000 +0400 +++ openjdk/hotspot/src/os/linux/vm/os_linux.cpp 2009-07-28 16:45:00.000000000 +0400 @@ -47,7 +47,9 @@ # include # include # include +#ifndef __LSB_VERSION__ # include +#endif # include # include # include @@ -56,6 +58,11 @@ #define MAX_PATH (2 * K) +#ifdef __LSB_VERSION__ +// LSB does not specify alloca. However, it's just a compile-time stuff. +# define alloca(size) __builtin_alloca (size) +#endif + // for timer info max values which include all bits #define ALL_64_BITS CONST64(0xFFFFFFFFFFFFFFFF) #define SEC_IN_NANOSECS 1000000000LL @@ -202,7 +209,11 @@ // on NPTL, it returns the same pid for all threads, as required by POSIX.) // pid_t os::Linux::gettid() { +#ifndef __LSB_VERSION__ int rslt = syscall(SYS_gettid); +#else + int rslt = pthread_self(); +#endif if (rslt == -1) { // old kernel, no NPTL support return getpid(); @@ -548,9 +559,14 @@ } else { // _CS_GNU_LIBC_VERSION is not supported, try gnu_get_libc_version() static char _gnu_libc_version[32]; +#ifndef __LSB_VERSION__ jio_snprintf(_gnu_libc_version, sizeof(_gnu_libc_version), "glibc %s %s", gnu_get_libc_version(), gnu_get_libc_release()); os::Linux::set_glibc_version(_gnu_libc_version); +#else + jio_snprintf(_gnu_libc_version, sizeof(_gnu_libc_version), + "glibc is provided by LSB"); +#endif } n = confstr(_CS_GNU_LIBPTHREAD_VERSION, NULL, 0); @@ -1339,7 +1355,7 @@ #endif -#define sys_clock_getres(x,y) ::syscall(SYS_clock_getres, x, y) +#define sys_clock_getres(x,y) ::clock_getres(x, y) void os::Linux::fast_thread_clock_init() { if (!UseLinuxPosixThreadCPUClocks) { @@ -1619,6 +1635,7 @@ bool os::dll_address_to_library_name(address addr, char* buf, int buflen, int* offset) { Dl_info dlinfo; +#ifndef __LSB_VERSION__ struct _address_to_library_name data; // There is a bug in old glibc dladdr() implementation that it could resolve @@ -1631,12 +1648,18 @@ data.buflen = buflen; data.base = NULL; int rslt = dl_iterate_phdr(address_to_library_name_callback, (void *)&data); - if (rslt) { // buf already contains library name if (offset) *offset = addr - data.base; return true; - } else if (dladdr((void*)addr, &dlinfo)){ + } else //that's NOT a typo--see below! +#else + // LSB 4.1 compatible distribution shall pass a test that prevents us from + // encountering a bug described above. + int rslt = 0; +#endif + // IF should be the first statement here--see above! + if (dladdr((void*)addr, &dlinfo)){ if (buf) jio_snprintf(buf, buflen, "%s", dlinfo.dli_fname); if (offset) *offset = addr - (address)dlinfo.dli_fbase; return true; @@ -2285,7 +2308,11 @@ if (write(fd, "", 1) == 1) { mmap(base, size, PROT_READ|PROT_WRITE|PROT_EXEC, +#if __LSB_VERSION__>=41 || (!defined __LSB_VERSION__) MAP_PRIVATE|MAP_FIXED|MAP_NORESERVE, fd, 0); +#else + MAP_PRIVATE|MAP_FIXED|0x04000, fd, 0); +#endif } } close(fd); @@ -2424,7 +2451,11 @@ bool os::uncommit_memory(char* addr, size_t size) { return ::mmap(addr, size, PROT_READ|PROT_WRITE|PROT_EXEC, +#if __LSB_VERSION__>=41 || (!defined __LSB_VERSION__) MAP_PRIVATE|MAP_FIXED|MAP_NORESERVE|MAP_ANONYMOUS, -1, 0) +#else + MAP_PRIVATE|MAP_FIXED|0x04000|MAP_ANONYMOUS, -1, 0) +#endif != MAP_FAILED; } @@ -2440,7 +2471,11 @@ char * addr; int flags; +#if __LSB_VERSION__>=41 || (!defined __LSB_VERSION__) flags = MAP_PRIVATE | MAP_NORESERVE | MAP_ANONYMOUS; +#else + flags = MAP_PRIVATE | 0x04000 | MAP_ANONYMOUS; +#endif if (fixed) { assert((uintptr_t)requested_addr % os::Linux::page_size() == 0, "unaligned address"); flags |= MAP_FIXED; @@ -3048,7 +3083,7 @@ /* Get signal number to use for suspend/resume */ if ((s = ::getenv("_JAVA_SR_SIGNUM")) != 0) { int sig = ::strtol(s, 0, 10); - if (sig > 0 || sig < _NSIG) { + if (sig > 0 && sig < NSIG) { SR_signum = sig; } } @@ -4084,7 +4119,11 @@ jlong os::current_thread_cpu_time() { if (os::Linux::supports_fast_thread_cpu_time()) { - return os::Linux::fast_thread_cpu_time(CLOCK_THREAD_CPUTIME_ID); + clockid_t clockid; + if (clock_getcpuclockid(0,&clockid) != 0){ + return -1; + } + return os::Linux::fast_thread_cpu_time(clockid); } else { // return user + sys since the cost is the same return slow_thread_cpu_time(Thread::current(), true /* user + sys */); @@ -4102,7 +4141,11 @@ jlong os::current_thread_cpu_time(bool user_sys_cpu_time) { if (user_sys_cpu_time && os::Linux::supports_fast_thread_cpu_time()) { - return os::Linux::fast_thread_cpu_time(CLOCK_THREAD_CPUTIME_ID); + clockid_t clockid; + if (clock_getcpuclockid(0,&clockid) != 0){ + return -1; + } + return os::Linux::fast_thread_cpu_time(clockid); } else { return slow_thread_cpu_time(Thread::current(), user_sys_cpu_time); } @@ -4735,7 +4778,7 @@ // 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... - pid_t pid = NOT_IA64(syscall(__NR_fork);) + pid_t pid = NOT_IA64(fork();) IA64_ONLY(fork();) if (pid < 0) { @@ -4752,7 +4795,7 @@ // in the new process, so make a system call directly. // IA64 should use normal execve() from glibc to match the glibc fork() // above. - NOT_IA64(syscall(__NR_execve, "/bin/sh", argv, environ);) + NOT_IA64(execve("/bin/sh", (char* const*)argv, environ);) IA64_ONLY(execve("/bin/sh", (char* const*)argv, environ);) // execve failed diff -u -r -N icedtea-orig/hotspot/src/os/linux/vm/os_linux.inline.hpp openjdk/hotspot/src/os/linux/vm/os_linux.inline.hpp --- icedtea-orig/hotspot/src/os/linux/vm/os_linux.inline.hpp 2008-11-22 03:11:18.000000000 +0300 +++ openjdk/hotspot/src/os/linux/vm/os_linux.inline.hpp 2009-07-28 16:45:37.000000000 +0400 @@ -83,7 +83,7 @@ inline int os::readdir_buf_size(const char *path) { - return NAME_MAX + sizeof(dirent) + 1; + return pathconf(path,_PC_NAME_MAX) + sizeof(dirent) + 1; } inline struct dirent* os::readdir(DIR* dirp, dirent *dbuf) diff -u -r -N icedtea-orig/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp openjdk/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp --- icedtea-orig/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp 2008-11-22 03:11:18.000000000 +0300 +++ openjdk/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp 2009-07-28 17:19:08.000000000 +0400 @@ -48,15 +48,27 @@ # include #ifdef AMD64 -#define REG_SP REG_RSP +#if (defined __LSB_VERSION__) +#define REG_SP REF_RSP #define REG_PC REG_RIP #define REG_FP REG_RBP +#else +#define REG_SP 15 +#define REG_PC 16 +#define REG_FP 10 +#endif #define SPELL_REG_SP "rsp" #define SPELL_REG_FP "rbp" #else +#ifndef __LSB_VERSION__ #define REG_SP REG_UESP #define REG_PC REG_EIP #define REG_FP REG_EBP +#else +#define REG_SP 17 +#define REG_PC 14 +#define REG_FP 6 +#endif #define SPELL_REG_SP "esp" #define SPELL_REG_FP "ebp" #endif // AMD64 @@ -396,7 +408,11 @@ // Furthermore, a false-positive should be harmless. if (UnguardOnExecutionViolation > 0 && (sig == SIGSEGV || sig == SIGBUS) && +#ifndef __LSB_VERSION__ uc->uc_mcontext.gregs[REG_TRAPNO] == trap_page_fault) { +#else + uc->uc_mcontext.gregs[20] == trap_page_fault) { +#endif int page_size = os::vm_page_size(); address addr = (address) info->si_addr; address pc = os::Linux::ucontext_get_pc(uc); @@ -717,6 +733,7 @@ ucontext_t *uc = (ucontext_t*)context; st->print_cr("Registers:"); +#ifndef __LSB_VERSION__ #ifdef AMD64 st->print( "RAX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RAX]); st->print(", RBX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RBX]); @@ -759,6 +776,9 @@ st->print(", CR2=" INTPTR_FORMAT, uc->uc_mcontext.cr2); st->print(", EFLAGS=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_EFL]); #endif // AMD64 +#else + st->print_cr("LSB version does not support dumping registers"); +#endif st->cr(); st->cr(); diff -u -r -N icedtea-orig/hotspot/src/share/lsb/lsb_thread_db.c openjdk/hotspot/src/share/lsb/lsb_thread_db.c --- icedtea-orig/hotspot/src/share/lsb/lsb_thread_db.c 1970-01-01 03:00:00.000000000 +0300 +++ openjdk/hotspot/src/share/lsb/lsb_thread_db.c 2009-07-28 17:23:53.000000000 +0400 @@ -0,0 +1,117 @@ + +#include "lsb_thread_db.h" + +#include + +#include +#include + +/* Addresses of dlsym'ed interfaces */ +td_err_e (*td_init_a) (void); +td_err_e (*td_ta_new_a) (struct ps_prochandle *__ps, td_thragent_t **__ta); +td_err_e (*td_ta_delete_a) (td_thragent_t *__ta); +td_err_e (*td_ta_thr_iter_a) (const td_thragent_t *__ta, + td_thr_iter_f *__callback, void *__cbdata_p, + td_thr_state_e __state, int __ti_pri, + sigset_t *__ti_sigmask_p, + unsigned int __ti_user_flags); +td_err_e (*td_thr_get_info_a) (const td_thrhandle_t *__th, + td_thrinfo_t *__infop); + +long (*ptrace_a)(enum __ptrace_request request, pid_t pid, + void *addr, void *data); + + +void * libthread_db_handle; + +#include +char* lsb_debugs_init() +{ + char* error; + // To allow libthread_db to find undefined referenced symbols in libsaproc + // (that's the way libthread_db works), we must reopen it with + // RTLD_GLOBAL flag + dlopen("libsaproc.so",RTLD_NOW | RTLD_GLOBAL); + if (error=dlerror()){ + return error; + } + libthread_db_handle=dlopen("libthread_db.so",RTLD_LAZY | RTLD_GLOBAL); + if (!libthread_db_handle){ + return dlerror(); + } + fprintf(stderr,"dlopen'd\n"); + // Ok, let's dlsym stuff. + *(void**) (&td_init_a) = dlsym(libthread_db_handle, "td_init"); + if ((error = dlerror()) != NULL) { + return error; + } + *(void**) (&td_ta_new_a) = dlsym(libthread_db_handle, "td_ta_new"); + if ((error = dlerror()) != NULL) { + return error; + } + *(void**) (&td_ta_delete_a) = dlsym(libthread_db_handle, "td_ta_delete"); + if ((error = dlerror()) != NULL) { + return error; + } + *(void**) (&td_ta_thr_iter_a) = dlsym(libthread_db_handle, "td_ta_thr_iter"); + if ((error = dlerror()) != NULL) { + return error; + } + *(void**) (&td_thr_get_info_a) = dlsym(libthread_db_handle, "td_thr_get_info"); + if ((error = dlerror()) != NULL) { + return error; + } + + // Now load ptrace. + *(void**) (&ptrace_a) = dlsym(RTLD_DEFAULT, "ptrace"); + if ((error = dlerror()) != NULL) { + return error; + } + + // ok, all loaded well, returning null + fprintf(stderr,"ok\n"); + return NULL; +} + +// Now some wrappers to library functions. + +td_err_e td_init (void) +{ + assert(td_init_a != NULL); + return td_init_a(); +} +td_err_e td_ta_new (struct ps_prochandle *__ps, td_thragent_t **__ta) +{ + assert(td_ta_new_a != NULL); + return td_ta_new_a(__ps,__ta); +} +td_err_e td_ta_delete (td_thragent_t *__ta) +{ + assert(td_ta_delete_a != NULL); + return td_ta_delete_a(__ta); +} +td_err_e td_ta_thr_iter (const td_thragent_t *__ta, + td_thr_iter_f *__callback, void *__cbdata_p, + td_thr_state_e __state, int __ti_pri, + sigset_t *__ti_sigmask_p, + unsigned int __ti_user_flags) +{ + assert(td_ta_thr_iter_a != NULL); + return td_ta_thr_iter_a(__ta, __callback, __cbdata_p, __state, __ti_pri, __ti_sigmask_p, __ti_user_flags); +} +td_err_e td_thr_get_info (const td_thrhandle_t *__th, td_thrinfo_t *__infop) +{ + assert(td_thr_get_info_a != NULL); + return td_thr_get_info_a(__th, __infop); +} + +long ptrace(enum __ptrace_request request, pid_t pid, + void *addr, void *data) +{ + assert(ptrace_a != NULL); + return ptrace_a(request, pid, addr, data); +} + + + + diff -u -r -N icedtea-orig/hotspot/src/share/lsb/lsb_thread_db.h openjdk/hotspot/src/share/lsb/lsb_thread_db.h --- icedtea-orig/hotspot/src/share/lsb/lsb_thread_db.h 1970-01-01 03:00:00.000000000 +0300 +++ openjdk/hotspot/src/share/lsb/lsb_thread_db.h 2009-07-28 17:23:53.000000000 +0400 @@ -0,0 +1,482 @@ + +/* LSB-compliant interface to libthread_db used in Serviceability agent */ + +/* thread_db.h -- interface to libthread_db.so library for debugging -lpthread + Copyright (C) 1999,2001,2002,2003 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 _THREAD_DB_H +#define _THREAD_DB_H 1 + +/* This is the debugger interface for the NPTL library. It is + modelled closely after the interface with same names in Solaris + with the goal to share the same code in the debugger. */ +#include +#include +#include +#include +#include +#include + + +/* Error codes of the library. */ +typedef enum +{ + TD_OK, /* No error. */ + TD_ERR, /* No further specified error. */ + TD_NOTHR, /* No matching thread found. */ + TD_NOSV, /* No matching synchronization handle found. */ + TD_NOLWP, /* No matching light-weighted process found. */ + TD_BADPH, /* Invalid process handle. */ + TD_BADTH, /* Invalid thread handle. */ + TD_BADSH, /* Invalid synchronization handle. */ + TD_BADTA, /* Invalid thread agent. */ + TD_BADKEY, /* Invalid key. */ + TD_NOMSG, /* No event available. */ + TD_NOFPREGS, /* No floating-point register content available. */ + TD_NOLIBTHREAD, /* Application not linked with thread library. */ + TD_NOEVENT, /* Requested event is not supported. */ + TD_NOCAPAB, /* Capability not available. */ + TD_DBERR, /* Internal debug library error. */ + TD_NOAPLIC, /* Operation is not applicable. */ + TD_NOTSD, /* No thread-specific data available. */ + TD_MALLOC, /* Out of memory. */ + TD_PARTIALREG, /* Not entire register set was read or written. */ + TD_NOXREGS, /* X register set not available for given thread. */ + TD_TLSDEFER, /* Thread has not yet allocated TLS for given module. */ + TD_NOTALLOC = TD_TLSDEFER, + TD_VERSION, /* Version if libpthread and libthread_db do not match. */ + TD_NOTLS /* There is no TLS segment in the given module. */ +} td_err_e; + + +/* Possible thread states. TD_THR_ANY_STATE is a pseudo-state used to + select threads regardless of state in td_ta_thr_iter(). */ +typedef enum +{ + TD_THR_ANY_STATE, + TD_THR_UNKNOWN, + TD_THR_STOPPED, + TD_THR_RUN, + TD_THR_ACTIVE, + TD_THR_ZOMBIE, + TD_THR_SLEEP, + TD_THR_STOPPED_ASLEEP +} td_thr_state_e; + +/* Thread type: user or system. TD_THR_ANY_TYPE is a pseudo-type used + to select threads regardless of type in td_ta_thr_iter(). */ +typedef enum +{ + TD_THR_ANY_TYPE, + TD_THR_USER, + TD_THR_SYSTEM +} td_thr_type_e; + + +/* Types of the debugging library. */ + +/* Handle for a process. This type is opaque. */ +typedef struct td_thragent td_thragent_t; + +/* The actual thread handle type. This is also opaque. */ +typedef struct td_thrhandle +{ + td_thragent_t *th_ta_p; + psaddr_t th_unique; +} td_thrhandle_t; + + +/* Forward declaration of a type defined by and for the dynamic linker. */ +struct link_map; + + +/* Flags for `td_ta_thr_iter'. */ +#define TD_THR_ANY_USER_FLAGS 0xffffffff +#define TD_THR_LOWEST_PRIORITY -20 +#define TD_SIGNO_MASK NULL + + +#define TD_EVENTSIZE 2 +#define BT_UISHIFT 5 /* log base 2 of BT_NBIPUI, to extract word index */ +#define BT_NBIPUI (1 << BT_UISHIFT) /* n bits per uint */ +#define BT_UIMASK (BT_NBIPUI - 1) /* to extract bit index */ + +/* Bitmask of enabled events. */ +typedef struct td_thr_events +{ + uint32_t event_bits[TD_EVENTSIZE]; +} td_thr_events_t; + +/* Event set manipulation macros. */ +#define __td_eventmask(n) \ + (UINT32_C (1) << (((n) - 1) & BT_UIMASK)) +#define __td_eventword(n) \ + ((UINT32_C ((n) - 1)) >> BT_UISHIFT) + +#define td_event_emptyset(setp) \ + do { \ + int __i; \ + for (__i = TD_EVENTSIZE; __i > 0; --__i) \ + (setp)->event_bits[__i - 1] = 0; \ + } while (0) + +#define td_event_fillset(setp) \ + do { \ + int __i; \ + for (__i = TD_EVENTSIZE; __i > 0; --__i) \ + (setp)->event_bits[__i - 1] = UINT32_C (0xffffffff); \ + } while (0) + +#define td_event_addset(setp, n) \ + (((setp)->event_bits[__td_eventword (n)]) |= __td_eventmask (n)) +#define td_event_delset(setp, n) \ + (((setp)->event_bits[__td_eventword (n)]) &= ~__td_eventmask (n)) +#define td_eventismember(setp, n) \ + (__td_eventmask (n) & ((setp)->event_bits[__td_eventword (n)])) +#if TD_EVENTSIZE == 2 +# define td_eventisempty(setp) \ + (!((setp)->event_bits[0]) && !((setp)->event_bits[1])) +#else +# error "td_eventisempty must be changed to match TD_EVENTSIZE" +#endif + +/* Events reportable by the thread implementation. */ +typedef enum +{ + TD_ALL_EVENTS, /* Pseudo-event number. */ + TD_EVENT_NONE = TD_ALL_EVENTS, /* Depends on context. */ + TD_READY, /* Is executable now. */ + TD_SLEEP, /* Blocked in a synchronization obj. */ + TD_SWITCHTO, /* Now assigned to a process. */ + TD_SWITCHFROM, /* Not anymore assigned to a process. */ + TD_LOCK_TRY, /* Trying to get an unavailable lock. */ + TD_CATCHSIG, /* Signal posted to the thread. */ + TD_IDLE, /* Process getting idle. */ + TD_CREATE, /* New thread created. */ + TD_DEATH, /* Thread terminated. */ + TD_PREEMPT, /* Preempted. */ + TD_PRI_INHERIT, /* Inherited elevated priority. */ + TD_REAP, /* Reaped. */ + TD_CONCURRENCY, /* Number of processes changing. */ + TD_TIMEOUT, /* Conditional variable wait timed out. */ + TD_MIN_EVENT_NUM = TD_READY, + TD_MAX_EVENT_NUM = TD_TIMEOUT, + TD_EVENTS_ENABLE = 31 /* Event reporting enabled. */ +} td_event_e; + +/* Values representing the different ways events are reported. */ +typedef enum +{ + NOTIFY_BPT, /* User must insert breakpoint at u.bptaddr. */ + NOTIFY_AUTOBPT, /* Breakpoint at u.bptaddr is automatically + inserted. */ + NOTIFY_SYSCALL /* System call u.syscallno will be invoked. */ +} td_notify_e; + +/* Description how event type is reported. */ +typedef struct td_notify +{ + td_notify_e type; /* Way the event is reported. */ + union + { + psaddr_t bptaddr; /* Address of breakpoint. */ + int syscallno; /* Number of system call used. */ + } u; +} td_notify_t; + +/* Structure used to report event. */ +typedef struct td_event_msg +{ + td_event_e event; /* Event type being reported. */ + const td_thrhandle_t *th_p; /* Thread reporting the event. */ + union + { +# if 0 + td_synchandle_t *sh; /* Handle of synchronization object. */ +#endif + uintptr_t data; /* Event specific data. */ + } msg; +} td_event_msg_t; + +/* Structure containing event data available in each thread structure. */ +typedef struct +{ + td_thr_events_t eventmask; /* Mask of enabled events. */ + td_event_e eventnum; /* Number of last event. */ + void *eventdata; /* Data associated with event. */ +} td_eventbuf_t; + + +/* Gathered statistics about the process. */ +typedef struct td_ta_stats +{ + int nthreads; /* Total number of threads in use. */ + int r_concurrency; /* Concurrency level requested by user. */ + int nrunnable_num; /* Average runnable threads, numerator. */ + int nrunnable_den; /* Average runnable threads, denominator. */ + int a_concurrency_num; /* Achieved concurrency level, numerator. */ + int a_concurrency_den; /* Achieved concurrency level, denominator. */ + int nlwps_num; /* Average number of processes in use, + numerator. */ + int nlwps_den; /* Average number of processes in use, + denominator. */ + int nidle_num; /* Average number of idling processes, + numerator. */ + int nidle_den; /* Average number of idling processes, + denominator. */ +} td_ta_stats_t; + + +/* Since Sun's library is based on Solaris threads we have to define a few + types to map them to POSIX threads. */ +typedef pthread_t thread_t; +typedef pthread_key_t thread_key_t; + + +/* Callback for iteration over threads. */ +typedef int td_thr_iter_f (const td_thrhandle_t *, void *); + +/* Callback for iteration over thread local data. */ +typedef int td_key_iter_f (thread_key_t, void (*) (void *), void *); + + + +/* Forward declaration. This has to be defined by the user. */ +struct ps_prochandle; + + +/* Information about the thread. */ +typedef struct td_thrinfo +{ + td_thragent_t *ti_ta_p; /* Process handle. */ + unsigned int ti_user_flags; /* Unused. */ + thread_t ti_tid; /* Thread ID returned by + pthread_create(). */ + char *ti_tls; /* Pointer to thread-local data. */ + psaddr_t ti_startfunc; /* Start function passed to + pthread_create(). */ + psaddr_t ti_stkbase; /* Base of thread's stack. */ + long int ti_stksize; /* Size of thread's stack. */ + psaddr_t ti_ro_area; /* Unused. */ + int ti_ro_size; /* Unused. */ + td_thr_state_e ti_state; /* Thread state. */ + unsigned char ti_db_suspended; /* Nonzero if suspended by debugger. */ + td_thr_type_e ti_type; /* Type of the thread (system vs + user thread). */ + intptr_t ti_pc; /* Unused. */ + intptr_t ti_sp; /* Unused. */ + short int ti_flags; /* Unused. */ + int ti_pri; /* Thread priority. */ + lwpid_t ti_lid; /* Kernel PID for this thread. */ + sigset_t ti_sigmask; /* Signal mask. */ + unsigned char ti_traceme; /* Nonzero if event reporting + enabled. */ + unsigned char ti_preemptflag; /* Unused. */ + unsigned char ti_pirecflag; /* Unused. */ + sigset_t ti_pending; /* Set of pending signals. */ + td_thr_events_t ti_events; /* Set of enabled events. */ +} td_thrinfo_t; + +#endif /* thread_db.h */ + +#ifndef _LSB_LIBTHREAD_DB_H +#define _LSB_LIBTHREAD_DB_H + + +/* Loads thread debugging library (libthread_db.so) and ptrace interface. + Returns dlerr's value after first error encountered or NULL if there was none. */ + +char * lsb_debugs_init(); + +/* Initialize the thread debug support library. */ +extern td_err_e td_init (void); + +/* Generate new thread debug library handle for process PS. */ + +extern td_err_e td_ta_new (struct ps_prochandle *__ps, td_thragent_t **__ta); + +/* Free resources allocated for TA. */ +extern td_err_e td_ta_delete (td_thragent_t *__ta); + +/* Call for each thread in a process associated with TA the callback function + CALLBACK. */ +extern td_err_e td_ta_thr_iter (const td_thragent_t *__ta, + td_thr_iter_f *__callback, void *__cbdata_p, + td_thr_state_e __state, int __ti_pri, + sigset_t *__ti_sigmask_p, + unsigned int __ti_user_flags); + +/* Return information about thread TH. */ +extern td_err_e td_thr_get_info (const td_thrhandle_t *__th, + td_thrinfo_t *__infop); + +// Slight incomplete definition of link_map structure + +struct link_map + { + /* These first few members are part of the protocol with the debugger. + This is the same format used in SVR4. */ + + uint32_t l_addr; /* Base address shared object is loaded at. */ + char *l_name; /* Absolute file name object was found in. */ + struct { + int32_t d_tag; + union { + uint32_t d_val; + uint32_t d_ptr; + } d_un; + } *l_ld; /* Dynamic section of the shared object. */ + struct link_map *l_next, *l_prev; /* Chain of loaded objects. */ + }; + +// complete r_debug +struct r_debug + { + int r_version; /* Version number for this protocol. */ + + struct link_map *r_map; /* Head of the chain of loaded objects. */ + + /* This is the address of a function internal to the run-time linker, + that will always be called when the linker begins to map in a + library or unmap it, and again when the mapping change is complete. + The debugger can set a breakpoint at this address if it wants to + notice shared object mapping changes. */ + uint32_t r_brk; + enum + { + /* This state value describes the mapping change taking place when + the `r_brk' address is called. */ + RT_CONSISTENT, /* Mapping change is complete. */ + RT_ADD, /* Beginning to add a new object. */ + RT_DELETE /* Beginning to remove an object mapping. */ + } r_state; + + uint32_t r_ldbase; /* Base address the linker is loaded at. */ + }; + + +// ptrace consts + +enum __ptrace_request +{ + /* Indicate that the process making this request should be traced. + All signals received by this process can be intercepted by its + parent, and its parent can use the other `ptrace' requests. */ + PTRACE_TRACEME = 0, +#define PT_TRACE_ME PTRACE_TRACEME + + /* Return the word in the process's text space at address ADDR. */ + PTRACE_PEEKTEXT = 1, +#define PT_READ_I PTRACE_PEEKTEXT + + /* Return the word in the process's data space at address ADDR. */ + PTRACE_PEEKDATA = 2, +#define PT_READ_D PTRACE_PEEKDATA + + /* Return the word in the process's user area at offset ADDR. */ + PTRACE_PEEKUSER = 3, +#define PT_READ_U PTRACE_PEEKUSER + + /* Write the word DATA into the process's text space at address ADDR. */ + PTRACE_POKETEXT = 4, +#define PT_WRITE_I PTRACE_POKETEXT + + /* Write the word DATA into the process's data space at address ADDR. */ + PTRACE_POKEDATA = 5, +#define PT_WRITE_D PTRACE_POKEDATA + + /* Write the word DATA into the process's user area at offset ADDR. */ + PTRACE_POKEUSER = 6, +#define PT_WRITE_U PTRACE_POKEUSER + + /* Continue the process. */ + PTRACE_CONT = 7, +#define PT_CONTINUE PTRACE_CONT + + /* Kill the process. */ + PTRACE_KILL = 8, +#define PT_KILL PTRACE_KILL + + /* Single step the process. + This is not supported on all machines. */ + PTRACE_SINGLESTEP = 9, +#define PT_STEP PTRACE_SINGLESTEP + + /* Get all general purpose registers used by a processes. + This is not supported on all machines. */ + PTRACE_GETREGS = 12, +#define PT_GETREGS PTRACE_GETREGS + + /* Set all general purpose registers used by a processes. + This is not supported on all machines. */ + PTRACE_SETREGS = 13, +#define PT_SETREGS PTRACE_SETREGS + + /* Get all floating point registers used by a processes. + This is not supported on all machines. */ + PTRACE_GETFPREGS = 14, +#define PT_GETFPREGS PTRACE_GETFPREGS + + /* Set all floating point registers used by a processes. + This is not supported on all machines. */ + PTRACE_SETFPREGS = 15, +#define PT_SETFPREGS PTRACE_SETFPREGS + + /* Attach to a process that is already running. */ + PTRACE_ATTACH = 16, +#define PT_ATTACH PTRACE_ATTACH + + /* Detach from a process attached to with PTRACE_ATTACH. */ + PTRACE_DETACH = 17, +#define PT_DETACH PTRACE_DETACH + + /* Get all extended floating point registers used by a processes. + This is not supported on all machines. */ + PTRACE_GETFPXREGS = 18, +#define PT_GETFPXREGS PTRACE_GETFPXREGS + + /* Set all extended floating point registers used by a processes. + This is not supported on all machines. */ + PTRACE_SETFPXREGS = 19, +#define PT_SETFPXREGS PTRACE_SETFPXREGS + + /* Continue and stop at the next (return from) syscall. */ + PTRACE_SYSCALL = 24, +#define PT_SYSCALL PTRACE_SYSCALL + + /* Set ptrace filter options. */ + PTRACE_SETOPTIONS = 0x4200, +#define PT_SETOPTIONS PTRACE_SETOPTIONS + + /* Get last ptrace message. */ + PTRACE_GETEVENTMSG = 0x4201, +#define PT_GETEVENTMSG PTRACE_GETEVENTMSG + + /* Get siginfo for process. */ + PTRACE_GETSIGINFO = 0x4202, +#define PT_GETSIGINFO PTRACE_GETSIGINFO + + /* Set new siginfo for process. */ + PTRACE_SETSIGINFO = 0x4203 +#define PT_SETSIGINFO PTRACE_SETSIGINFO +}; + + +#endif + diff -u -r -N icedtea-orig/hotspot/src/share/vm/libadt/dict.cpp openjdk/hotspot/src/share/vm/libadt/dict.cpp --- icedtea-orig/hotspot/src/share/vm/libadt/dict.cpp 2008-11-22 03:11:18.000000000 +0300 +++ openjdk/hotspot/src/share/vm/libadt/dict.cpp 2009-07-28 16:46:00.000000000 +0400 @@ -33,7 +33,8 @@ //IMPLEMENTATION // #include "dict.hpp" -#include +// not used +//#include // The iostream is not needed and it gets confused for gcc by the // define of bool. diff -u -r -N icedtea-orig/hotspot/src/share/vm/utilities/globalDefinitions_gcc.hpp openjdk/hotspot/src/share/vm/utilities/globalDefinitions_gcc.hpp --- icedtea-orig/hotspot/src/share/vm/utilities/globalDefinitions_gcc.hpp 2008-11-22 03:11:18.000000000 +0300 +++ openjdk/hotspot/src/share/vm/utilities/globalDefinitions_gcc.hpp 2009-07-28 16:46:15.000000000 +0400 @@ -227,7 +227,7 @@ #endif inline int g_isnan(double f) { return isnand(f); } #elif LINUX -inline int g_isnan(float f) { return isnanf(f); } +inline int g_isnan(float f) { return isnan(f); } inline int g_isnan(double f) { return isnan(f); } #else #error "missing platform-specific definition here" @@ -235,8 +235,8 @@ // Checking for finiteness -inline int g_isfinite(jfloat f) { return finite(f); } -inline int g_isfinite(jdouble f) { return finite(f); } +inline int g_isfinite(jfloat f) { return isfinite(f); } +inline int g_isfinite(jdouble f) { return isfinite(f); } // Wide characters