Your message dated Tue, 25 Jul 2017 15:19:19 +0000
with message-id <[email protected]>
and subject line Bug#869672: fixed in openjdk-8 8u141-b15-3
has caused the Debian Bug report #869672,
regarding openjdk-8: Please update patch kfreebsd-support-hotspot.diff
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
869672: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=869672
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Source: openjdk-8
Version: 8u131-b11-2
Severity: normal
Tags: patch

Hi!

In order to get Hotspot to compile on kfreebsd-*, I had to patch os_linux.cpp
not to use the SHM_REMAP flag on kFreeBSD as SHM_REMAP is Linux-specific:

--- a/hotspot/src/os/linux/vm/os_linux.cpp      2017-07-12 08:27:13.000000000 
+0200
+++ b/hotspot/src/os/linux/vm/os_linux.cpp      2017-07-25 13:13:21.333303596 
+0200
@@ -3422,8 +3422,12 @@
     return NULL;
   }
 
+#ifndef __FreeBSD_kernel__
   // SHM_REMAP is needed to allow shmat to map over an existing mapping.
   char* addr = (char*)shmat(shmid, pre_reserved_addr, SHM_REMAP);
+#else
+  char* addr = (char*)shmat(shmid, pre_reserved_addr, 0);
+#endif
 
   if ((intptr_t)addr == -1) {
     int err = errno;

Without this change, the build fails when trying to compile os_linux.cpp for
obvious reasons. The attached patch is an updated version of the patch
kfreebsd-support-hotspot.diff which fixes this problem.

Adrian

--
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - [email protected]
`. `'   Freie Universitaet Berlin - [email protected]
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
Index: b/hotspot/src/os/linux/vm/decoder_linux.cpp
===================================================================
--- a/hotspot/src/os/linux/vm/decoder_linux.cpp
+++ b/hotspot/src/os/linux/vm/decoder_linux.cpp
@@ -22,6 +22,7 @@
  *
  */
 
+#include "utilities/globalDefinitions.hpp"
 #include "prims/jvm.h"
 #include "utilities/decoder_elf.hpp"
 
Index: b/hotspot/src/os/linux/vm/attachListener_linux.cpp
===================================================================
--- a/hotspot/src/os/linux/vm/attachListener_linux.cpp
+++ b/hotspot/src/os/linux/vm/attachListener_linux.cpp
@@ -39,6 +39,10 @@
 #define UNIX_PATH_MAX   sizeof(((struct sockaddr_un *)0)->sun_path)
 #endif
 
+#if defined(__FreeBSD_kernel__)
+#include <sys/ucred.h>
+#endif
+
 // The attach mechanism on Linux uses a UNIX domain socket. An attach listener
 // thread is created at startup or is created on-demand via a signal from
 // the client tool. The attach listener creates a socket and binds it to a file
@@ -337,16 +341,26 @@ LinuxAttachOperation* LinuxAttachListene
 
     // get the credentials of the peer and check the effective uid/guid
     // - check with jeff on this.
+#if defined(LOCAL_PEERCRED) /* GNU/kFreeBSD */
+    struct xucred cred_info;
+    socklen_t optlen = sizeof(cred_info);
+    if (::getsockopt(s, SOL_SOCKET, LOCAL_PEERCRED, (void*)&cred_info, 
&optlen) == -1) {
+#else
     struct ucred cred_info;
     socklen_t optlen = sizeof(cred_info);
     if (::getsockopt(s, SOL_SOCKET, SO_PEERCRED, (void*)&cred_info, &optlen) 
== -1) {
+#endif
       ::close(s);
       continue;
     }
     uid_t euid = geteuid();
     gid_t egid = getegid();
 
+#if defined(LOCAL_PEERCRED) /* GNU/kFreeBSD */
+    if (cred_info.cr_uid != euid || cred_info.cr_gid != egid) {
+#else
     if (cred_info.uid != euid || cred_info.gid != egid) {
+#endif
       ::close(s);
       continue;
     }
Index: b/hotspot/src/os/linux/vm/jvm_linux.cpp
===================================================================
--- a/hotspot/src/os/linux/vm/jvm_linux.cpp
+++ b/hotspot/src/os/linux/vm/jvm_linux.cpp
@@ -169,7 +169,9 @@ struct siglabel siglabels[] = {
   "WINCH",      SIGWINCH,       /* Window size change (4.3 BSD, Sun).  */
   "POLL",       SIGPOLL,        /* Pollable event occurred (System V).  */
   "IO",         SIGIO,          /* I/O now possible (4.2 BSD).  */
+#ifdef SIGPWR
   "PWR",        SIGPWR,         /* Power failure restart (System V).  */
+#endif
 #ifdef SIGSYS
   "SYS",        SIGSYS          /* Bad system call. Only on some Linuxen! */
 #endif
Index: b/hotspot/src/os/linux/vm/os_linux.cpp
===================================================================
--- a/hotspot/src/os/linux/vm/os_linux.cpp
+++ b/hotspot/src/os/linux/vm/os_linux.cpp
@@ -22,6 +22,7 @@
  *
  */
 
+#include "utilities/globalDefinitions.hpp"
 // no precompiled headers
 #include "classfile/classLoader.hpp"
 #include "classfile/systemDictionary.hpp"
@@ -92,8 +93,16 @@
 # include <semaphore.h>
 # include <fcntl.h>
 # include <string.h>
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+# include <sys/param.h>
+# include <sys/sysctl.h>
+#ifndef ETIME
+# define ETIME ETIMEDOUT
+#endif
+#else
 # include <syscall.h>
 # include <sys/sysinfo.h>
+#endif
 # include <gnu/libc-version.h>
 # include <sys/ipc.h>
 # include <sys/shm.h>
@@ -169,11 +178,22 @@ julong os::available_memory() {
 }
 
 julong os::Linux::available_memory() {
+#ifndef __FreeBSD_kernel__
   // values in struct sysinfo are "unsigned long"
   struct sysinfo si;
   sysinfo(&si);
 
   return (julong)si.freeram * si.mem_unit;
+#else
+  int mib[2] = {CTL_HW, HW_USERMEM}, mem;
+  size_t len;
+  len = sizeof(mem);
+  if (sysctl(mib, 2, &mem, &len, NULL, 0) == 0) {
+    return (julong) mem;
+  } else {
+    return 0;
+  }
+#endif
 }
 
 julong os::physical_memory() {
@@ -2174,18 +2194,22 @@ void os::print_memory_info(outputStream*
   st->print("Memory:");
   st->print(" %dk page", os::vm_page_size()>>10);
 
+#ifndef __FreeBSD_kernel__
   // values in struct sysinfo are "unsigned long"
   struct sysinfo si;
   sysinfo(&si);
+#endif
 
   st->print(", physical " UINT64_FORMAT "k",
             os::physical_memory() >> 10);
   st->print("(" UINT64_FORMAT "k free)",
             os::available_memory() >> 10);
+#ifndef __FreeBSD_kernel__
   st->print(", swap " UINT64_FORMAT "k",
             ((jlong)si.totalswap * si.mem_unit) >> 10);
   st->print("(" UINT64_FORMAT "k free)",
             ((jlong)si.freeswap * si.mem_unit) >> 10);
+#endif
   st->cr();
 }

--- a/hotspot/src/os/linux/vm/os_linux.cpp      2017-07-12 08:27:13.000000000 
+0200
+++ b/hotspot/src/os/linux/vm/os_linux.cpp      2017-07-25 13:13:21.333303596 
+0200
@@ -3422,8 +3422,12 @@
     return NULL;
   }
 
+#ifndef __FreeBSD_kernel__
   // SHM_REMAP is needed to allow shmat to map over an existing mapping.
   char* addr = (char*)shmat(shmid, pre_reserved_addr, SHM_REMAP);
+#else
+  char* addr = (char*)shmat(shmid, pre_reserved_addr, 0);
+#endif
 
   if ((intptr_t)addr == -1) {
     int err = errno;

Index: b/hotspot/src/os/linux/vm/osThread_linux.cpp
===================================================================
--- a/hotspot/src/os/linux/vm/osThread_linux.cpp
+++ b/hotspot/src/os/linux/vm/osThread_linux.cpp
@@ -22,6 +22,7 @@
  *
  */
 
+#include "utilities/globalDefinitions.hpp"
 // no precompiled headers
 #include "runtime/mutex.hpp"
 #include "runtime/osThread.hpp"
Index: b/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp
===================================================================
--- a/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp
+++ b/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp
@@ -22,6 +22,7 @@
  *
  */
 
+#include "utilities/globalDefinitions.hpp"
 // no precompiled headers
 #include "asm/macroAssembler.hpp"
 #include "classfile/classLoader.hpp"
@@ -74,6 +75,7 @@
 # include <ucontext.h>
 # include <fpu_control.h>
 
+#ifdef __linux__
 #ifdef AMD64
 #define REG_SP REG_RSP
 #define REG_PC REG_RIP
@@ -87,6 +89,54 @@
 #define SPELL_REG_SP "esp"
 #define SPELL_REG_FP "ebp"
 #endif // AMD64
+#endif
+
+#if defined(__FreeBSD_kernel__)
+#define context_trapno uc_mcontext.mc_trapno
+#ifdef AMD64
+#define SPELL_REG_SP "rsp"
+#define SPELL_REG_FP "rbp"
+#define context_sp uc_mcontext.mc_rsp
+#define context_pc uc_mcontext.mc_rip
+#define context_fp uc_mcontext.mc_rbp
+#define context_rip uc_mcontext.mc_rip
+#define context_rsp uc_mcontext.mc_rsp
+#define context_rbp uc_mcontext.mc_rbp
+#define context_flags uc_mcontext.mc_flags
+#define context_err uc_mcontext.mc_err
+#define context_rax uc_mcontext.mc_rax
+#define context_rbx uc_mcontext.mc_rbx
+#define context_rcx uc_mcontext.mc_rcx
+#define context_rdx uc_mcontext.mc_rdx
+#define context_rsi uc_mcontext.mc_rsi
+#define context_rdi uc_mcontext.mc_rdi
+#define context_r8 uc_mcontext.mc_r8
+#define context_r9 uc_mcontext.mc_r9
+#define context_r10 uc_mcontext.mc_r10
+#define context_r11 uc_mcontext.mc_r11
+#define context_r12 uc_mcontext.mc_r12
+#define context_r13 uc_mcontext.mc_r13
+#define context_r14 uc_mcontext.mc_r14
+#define context_r15 uc_mcontext.mc_r15
+#else
+#define SPELL_REG_SP "esp"
+#define SPELL_REG_FP "ebp"
+#define context_sp uc_mcontext.mc_esp
+#define context_pc uc_mcontext.mc_eip
+#define context_fp uc_mcontext.mc_ebp
+#define context_eip uc_mcontext.mc_eip
+#define context_esp uc_mcontext.mc_esp
+#define context_eax uc_mcontext.mc_eax
+#define context_ebx uc_mcontext.mc_ebx
+#define context_ecx uc_mcontext.mc_ecx
+#define context_edx uc_mcontext.mc_edx
+#define context_ebp uc_mcontext.mc_ebp
+#define context_esi uc_mcontext.mc_esi
+#define context_edi uc_mcontext.mc_edi
+#define context_eflags uc_mcontext.mc_eflags
+#define context_trapno uc_mcontext.mc_trapno
+#endif // AMD64
+#endif
 
 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
 
@@ -118,15 +168,27 @@ void os::initialize_thread(Thread* thr)
 }
 
 address os::Linux::ucontext_get_pc(ucontext_t * uc) {
+#if defined(__FreeBSD_kernel__)
+  return (address)uc->context_pc;
+#else
   return (address)uc->uc_mcontext.gregs[REG_PC];
+#endif
 }
 
 intptr_t* os::Linux::ucontext_get_sp(ucontext_t * uc) {
+#if defined(__FreeBSD_kernel__)
+  return (intptr_t*)uc->context_sp;
+#else
   return (intptr_t*)uc->uc_mcontext.gregs[REG_SP];
+#endif
 }
 
 intptr_t* os::Linux::ucontext_get_fp(ucontext_t * uc) {
+#if defined(__FreeBSD_kernel__)
+  return (intptr_t*)uc->context_fp;
+#else
   return (intptr_t*)uc->uc_mcontext.gregs[REG_FP];
+#endif
 }
 
 // For Forte Analyzer AsyncGetCallTrace profiling support - thread
@@ -278,7 +340,11 @@ JVM_handle_linux_signal(int sig,
     pc = (address) os::Linux::ucontext_get_pc(uc);
 
     if (StubRoutines::is_safefetch_fault(pc)) {
+#if defined(__FreeBSD_kernel__)
+      uc->context_pc = 
intptr_t(StubRoutines::continuation_for_safefetch_fault(pc));
+#else
       uc->uc_mcontext.gregs[REG_PC] = 
intptr_t(StubRoutines::continuation_for_safefetch_fault(pc));
+#endif
       return 1;
     }
 
@@ -443,7 +509,11 @@ JVM_handle_linux_signal(int sig,
   // Furthermore, a false-positive should be harmless.
   if (UnguardOnExecutionViolation > 0 &&
       (sig == SIGSEGV || sig == SIGBUS) &&
+#if defined(__FreeBSD_kernel__)
+      uc->context_trapno == trap_page_fault) {
+#else
       uc->uc_mcontext.gregs[REG_TRAPNO] == 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);
@@ -513,7 +583,11 @@ JVM_handle_linux_signal(int sig,
     // save all thread context in case we need to restore it
     if (thread != NULL) thread->set_saved_exception_pc(pc);
 
+#if defined(__FreeBSD_kernel__)
+    uc->context_pc = (intptr_t)stub;
+#else
     uc->uc_mcontext.gregs[REG_PC] = (greg_t)stub;
+#endif
     return true;
   }
 
@@ -765,6 +839,7 @@ void os::print_context(outputStream *st,
 
   ucontext_t *uc = (ucontext_t*)context;
   st->print_cr("Registers:");
+#ifdef __linux__
 #ifdef AMD64
   st->print(  "RAX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RAX]);
   st->print(", RBX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RBX]);
@@ -807,6 +882,48 @@ void os::print_context(outputStream *st,
   st->print(", EFLAGS=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_EFL]);
   st->print(", CR2=" INTPTR_FORMAT, uc->uc_mcontext.cr2);
 #endif // AMD64
+#elif defined(__FreeBSD_kernel__)
+#ifdef AMD64
+  st->print(  "RAX=" INTPTR_FORMAT, uc->context_rax);
+  st->print(", RBX=" INTPTR_FORMAT, uc->context_rbx);
+  st->print(", RCX=" INTPTR_FORMAT, uc->context_rcx);
+  st->print(", RDX=" INTPTR_FORMAT, uc->context_rdx);
+  st->cr();
+  st->print(  "RSP=" INTPTR_FORMAT, uc->context_rsp);
+  st->print(", RBP=" INTPTR_FORMAT, uc->context_rbp);
+  st->print(", RSI=" INTPTR_FORMAT, uc->context_rsi);
+  st->print(", RDI=" INTPTR_FORMAT, uc->context_rdi);
+  st->cr();
+  st->print(  "R8 =" INTPTR_FORMAT, uc->context_r8);
+  st->print(", R9 =" INTPTR_FORMAT, uc->context_r9);
+  st->print(", R10=" INTPTR_FORMAT, uc->context_r10);
+  st->print(", R11=" INTPTR_FORMAT, uc->context_r11);
+  st->cr();
+  st->print(  "R12=" INTPTR_FORMAT, uc->context_r12);
+  st->print(", R13=" INTPTR_FORMAT, uc->context_r13);
+  st->print(", R14=" INTPTR_FORMAT, uc->context_r14);
+  st->print(", R15=" INTPTR_FORMAT, uc->context_r15);
+  st->cr();
+  st->print(  "RIP=" INTPTR_FORMAT, uc->context_rip);
+  st->print(", EFLAGS=" INTPTR_FORMAT, uc->context_flags);
+  st->print(", ERR=" INTPTR_FORMAT, uc->context_err);
+  st->cr();
+  st->print("  TRAPNO=" INTPTR_FORMAT, uc->context_trapno);
+#else
+  st->print(  "EAX=" INTPTR_FORMAT, uc->context_eax);
+  st->print(", EBX=" INTPTR_FORMAT, uc->context_ebx);
+  st->print(", ECX=" INTPTR_FORMAT, uc->context_ecx);
+  st->print(", EDX=" INTPTR_FORMAT, uc->context_edx);
+  st->cr();
+  st->print(  "ESP=" INTPTR_FORMAT, uc->context_esp);
+  st->print(", EBP=" INTPTR_FORMAT, uc->context_ebp);
+  st->print(", ESI=" INTPTR_FORMAT, uc->context_esi);
+  st->print(", EDI=" INTPTR_FORMAT, uc->context_edi);
+  st->cr();
+  st->print(  "EIP=" INTPTR_FORMAT, uc->context_eip);
+  st->print(", EFLAGS=" INTPTR_FORMAT, uc->context_eflags);
+#endif // AMD64
+#endif
   st->cr();
   st->cr();
 
@@ -837,6 +954,7 @@ void os::print_register_info(outputStrea
 
   // this is only for the "general purpose" registers
 
+#ifdef __linux__
 #ifdef AMD64
   st->print("RAX="); print_location(st, uc->uc_mcontext.gregs[REG_RAX]);
   st->print("RBX="); print_location(st, uc->uc_mcontext.gregs[REG_RBX]);
@@ -864,6 +982,35 @@ void os::print_register_info(outputStrea
   st->print("ESI="); print_location(st, uc->uc_mcontext.gregs[REG_ESI]);
   st->print("EDI="); print_location(st, uc->uc_mcontext.gregs[REG_EDI]);
 #endif // AMD64
+#elif defined(__FreeBSD_kernel__)
+#ifdef AMD64
+  st->print("RAX="); print_location(st, uc->context_rax);
+  st->print("RBX="); print_location(st, uc->context_rbx);
+  st->print("RCX="); print_location(st, uc->context_rcx);
+  st->print("RDX="); print_location(st, uc->context_rdx);
+  st->print("RSP="); print_location(st, uc->context_rsp);
+  st->print("RBP="); print_location(st, uc->context_rbp);
+  st->print("RSI="); print_location(st, uc->context_rsi);
+  st->print("RDI="); print_location(st, uc->context_rdi);
+  st->print("R8 ="); print_location(st, uc->context_r8);
+  st->print("R9 ="); print_location(st, uc->context_r9);
+  st->print("R10="); print_location(st, uc->context_r10);
+  st->print("R11="); print_location(st, uc->context_r11);
+  st->print("R12="); print_location(st, uc->context_r12);
+  st->print("R13="); print_location(st, uc->context_r13);
+  st->print("R14="); print_location(st, uc->context_r14);
+  st->print("R15="); print_location(st, uc->context_r15);
+#else
+  st->print("EAX="); print_location(st, uc->context_eax);
+  st->print("EBX="); print_location(st, uc->context_ebx);
+  st->print("ECX="); print_location(st, uc->context_ecx);
+  st->print("EDX="); print_location(st, uc->context_edx);
+  st->print("ESP="); print_location(st, uc->context_esp);
+  st->print("EBP="); print_location(st, uc->context_ebp);
+  st->print("ESI="); print_location(st, uc->context_esi);
+  st->print("EDI="); print_location(st, uc->context_edi);
+#endif // AMD64
+#endif
 
   st->cr();
 }
Index: b/hotspot/src/share/vm/memory/allocation.hpp
===================================================================
--- a/hotspot/src/share/vm/memory/allocation.hpp
+++ b/hotspot/src/share/vm/memory/allocation.hpp
@@ -25,8 +25,8 @@
 #ifndef SHARE_VM_MEMORY_ALLOCATION_HPP
 #define SHARE_VM_MEMORY_ALLOCATION_HPP
 
-#include "runtime/globals.hpp"
 #include "utilities/globalDefinitions.hpp"
+#include "runtime/globals.hpp"
 #include "utilities/macros.hpp"
 #ifdef COMPILER1
 #include "c1/c1_globals.hpp"
Index: b/hotspot/src/share/vm/ci/ciObject.hpp
===================================================================
--- a/hotspot/src/share/vm/ci/ciObject.hpp
+++ b/hotspot/src/share/vm/ci/ciObject.hpp
@@ -25,6 +25,7 @@
 #ifndef SHARE_VM_CI_CIOBJECT_HPP
 #define SHARE_VM_CI_CIOBJECT_HPP
 
+#include "utilities/globalDefinitions.hpp"
 #include "ci/ciBaseObject.hpp"
 #include "ci/ciClassList.hpp"
 #include "memory/allocation.hpp"
Index: b/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp
===================================================================
--- a/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp
+++ b/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp
@@ -22,6 +22,7 @@
  *
  */
 
+#include "utilities/globalDefinitions.hpp"
 // no precompiled headers
 #include "classfile/vmSymbols.hpp"
 #include "gc_interface/collectedHeap.hpp"
Index: b/hotspot/src/share/vm/utilities/globalDefinitions_gcc.hpp
===================================================================
--- a/hotspot/src/share/vm/utilities/globalDefinitions_gcc.hpp
+++ b/hotspot/src/share/vm/utilities/globalDefinitions_gcc.hpp
@@ -68,7 +68,7 @@
 # include <sys/procfs.h>
 # endif
 
-#if defined(LINUX) || defined(_ALLBSD_SOURCE)
+#if defined(LINUX) || defined(_ALLBSD_SOURCE) || defined(__FreeBSD_kernel__)
 #ifndef __STDC_LIMIT_MACROS
 #define __STDC_LIMIT_MACROS
 #endif // __STDC_LIMIT_MACROS
Index: b/hotspot/make/defs.make
===================================================================
--- a/hotspot/make/defs.make
+++ b/hotspot/make/defs.make
@@ -179,9 +179,6 @@ endif
 # Windows should have OS predefined
 ifeq ($(OS),)
   OS   := $(shell uname -s)
-  ifneq ($(findstring BSD,$(OS)),)
-    OS=bsd
-  endif
   ifeq ($(OS), Darwin)
     OS=bsd
   endif
@@ -207,6 +204,10 @@ else
   OSNAME=linux
 endif
 
+ifeq ($(OS), GNU/kFreeBSD)
+  OSNAME=linux
+endif
+
 # Determinations of default make arguments and platform specific settings
 MAKE_ARGS=
 
Index: b/hotspot/make/linux/Makefile
===================================================================
--- a/hotspot/make/linux/Makefile
+++ b/hotspot/make/linux/Makefile
@@ -236,6 +236,9 @@ checks: check_os_version check_j2se_vers
 SUPPORTED_OS_VERSION = 2.4% 2.5% 2.6% 3% 4%
 OS_VERSION := $(shell uname -r)
 EMPTY_IF_NOT_SUPPORTED = $(filter $(SUPPORTED_OS_VERSION),$(OS_VERSION))
+ifeq ($(shell uname -s), GNU/kFreeBSD)
+EMPTY_IF_NOT_SUPPORTED = supported
+endif
 
 check_os_version:
 ifeq ($(DISABLE_HOTSPOT_OS_VERSION_CHECK)$(EMPTY_IF_NOT_SUPPORTED),)
Index: b/hotspot/make/linux/makefiles/defs.make
===================================================================
--- a/hotspot/make/linux/makefiles/defs.make
+++ b/hotspot/make/linux/makefiles/defs.make
@@ -84,7 +84,7 @@ ifneq (,$(findstring $(ARCH), sparc))
 endif
 
 # i686/i586 and amd64/x86_64
-ifneq (,$(findstring $(ARCH), amd64 x86_64 i686 i586))
+ifneq (,$(findstring $(ARCH), amd64 x86_64 i686 i586 i486 i386))
   ifeq ($(ARCH_DATA_MODEL), 64)
     ARCH_DATA_MODEL = 64
     MAKE_ARGS       += LP64=1
@@ -92,7 +92,7 @@ ifneq (,$(findstring $(ARCH), amd64 x86_
     VM_PLATFORM     = linux_amd64
   else
     ARCH_DATA_MODEL = 32
-    PLATFORM        = linux-i586
+    PLATFORM        = linux_i486
     VM_PLATFORM     = linux_i486
   endif
   HS_ARCH           = x86
Index: b/hotspot/agent/src/os/linux/ps_core.c
===================================================================
--- a/hotspot/agent/src/os/linux/ps_core.c
+++ b/hotspot/agent/src/os/linux/ps_core.c
@@ -551,11 +551,16 @@ static bool core_handle_prstatus(struct
       return false;
 
    // copy regs
+#if defined(__FreeBSD_kernel__)
+   memcpy(&newthr->regs, &prstat->pr_reg, sizeof(struct user_regs_struct));
+#else
    memcpy(&newthr->regs, prstat->pr_reg, sizeof(struct user_regs_struct));
+#endif
 
    if (is_debug()) {
       print_debug("integer regset\n");
 #ifdef i386
+#ifdef __linux__
       // print the regset
       print_debug("\teax = 0x%x\n", newthr->regs.eax);
       print_debug("\tebx = 0x%x\n", newthr->regs.ebx);
@@ -566,9 +571,21 @@ static bool core_handle_prstatus(struct
       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);
+#elif defined(__FreeBSD_kernel__)
+      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
 #endif
 
 #if defined(amd64) || defined(x86_64)
+#ifdef __linux__
       // print the regset
       print_debug("\tr15 = 0x%lx\n", newthr->regs.r15);
       print_debug("\tr14 = 0x%lx\n", newthr->regs.r14);
@@ -597,6 +614,27 @@ static bool core_handle_prstatus(struct
       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);
+#elif defined(__FreeBSD_kernel__)
+      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("\trip = 0x%lx\n", newthr->regs.r_rip);
+      print_debug("\tcs = 0x%lx\n", newthr->regs.r_cs);
+      print_debug("\trsp = 0x%lx\n", newthr->regs.r_rsp);
+      print_debug("\tss = 0x%lx\n", newthr->regs.r_ss);
+#endif
 #endif
    }
 
Index: b/hotspot/agent/src/os/linux/ps_proc.c
===================================================================
--- a/hotspot/agent/src/os/linux/ps_proc.c
+++ b/hotspot/agent/src/os/linux/ps_proc.c
@@ -42,6 +42,22 @@
 #define __WALL          0x40000000  // Copied from /usr/include/linux/wait.h
 #endif
 
+#ifndef PTRACE_PEEKDATA
+#define PTRACE_PEEKDATA PT_READ_D
+#endif
+
+#ifndef PTRACE_ATTACH
+#define PTRACE_ATTACH PT_ATTACH
+#endif
+
+#ifndef PTRACE_DETACH
+#define PTRACE_DETACH PT_DETACH
+#endif
+
+#ifndef PTRACE_CONT
+#define PTRACE_CONT PT_CONTINUE
+#endif
+
 // This file has the libproc implementation specific to live process
 // For core files, refer to ps_core.c
 
@@ -59,7 +75,11 @@ static inline uintptr_t align(uintptr_t
 // before calling process_read_data.
 
 static bool process_read_data(struct ps_prochandle* ph, uintptr_t addr, char 
*buf, size_t size) {
+#if defined(__FreeBSD_kernel__)
+  int rslt;
+#else
   long rslt;
+#endif
   size_t i, words;
   uintptr_t end_addr = addr + size;
   uintptr_t aligned_addr = align(addr, sizeof(long));
@@ -67,36 +87,62 @@ static bool process_read_data(struct ps_
   if (aligned_addr != addr) {
     char *ptr = (char *)&rslt;
     errno = 0;
+#if defined(__FreeBSD_kernel__)
+    rslt = ptrace(PTRACE_PEEKDATA, ph->pid, (caddr_t) aligned_addr, 0);
+#else
     rslt = ptrace(PTRACE_PEEKDATA, ph->pid, aligned_addr, 0);
+#endif
     if (errno) {
       print_debug("ptrace(PTRACE_PEEKDATA, ..) failed for %d bytes @ %lx\n", 
size, addr);
       return false;
     }
     for (; aligned_addr != addr; aligned_addr++, ptr++);
+#if defined(__FreeBSD_kernel__)
+    for (; ((intptr_t)aligned_addr % sizeof(int)) && aligned_addr < end_addr;
+#else
     for (; ((intptr_t)aligned_addr % sizeof(long)) && aligned_addr < end_addr;
+#endif
         aligned_addr++)
        *(buf++) = *(ptr++);
   }
 
+#if defined(__FreeBSD_kernel__)
+  words = (end_addr - aligned_addr) / sizeof(int);
+#else
   words = (end_addr - aligned_addr) / sizeof(long);
+#endif
 
   // assert((intptr_t)aligned_addr % sizeof(long) == 0);
   for (i = 0; i < words; i++) {
     errno = 0;
+#if defined(__FreeBSD_kernel__)
+    rslt = ptrace(PTRACE_PEEKDATA, ph->pid, (caddr_t) aligned_addr, 0);
+#else
     rslt = ptrace(PTRACE_PEEKDATA, ph->pid, aligned_addr, 0);
+#endif
     if (errno) {
       print_debug("ptrace(PTRACE_PEEKDATA, ..) failed for %d bytes @ %lx\n", 
size, addr);
       return false;
     }
+#if defined(__FreeBSD_kernel__)
+    *(int *)buf = rslt;
+    buf += sizeof(int);
+    aligned_addr += sizeof(int);
+#else
     *(long *)buf = rslt;
     buf += sizeof(long);
     aligned_addr += sizeof(long);
+#endif
   }
 
   if (aligned_addr != end_addr) {
     char *ptr = (char *)&rslt;
     errno = 0;
+#if defined(__FreeBSD_kernel__)
+    rslt = ptrace(PTRACE_PEEKDATA, ph->pid, (caddr_t) aligned_addr, 0);
+#else
     rslt = ptrace(PTRACE_PEEKDATA, ph->pid, aligned_addr, 0);
+#endif
     if (errno) {
       print_debug("ptrace(PTRACE_PEEKDATA, ..) failed for %d bytes @ %lx\n", 
size, addr);
       return false;
@@ -135,7 +181,11 @@ static bool process_get_lwp_regs(struct
 #endif
 
 #ifdef PTRACE_GETREGS_REQ
+#if defined(__FreeBSD_kernel__)
+ if (ptrace_getregs(PTRACE_GETREGS_REQ, pid, (caddr_t) user, 0) < 0) {
+#else
  if (ptrace_getregs(PTRACE_GETREGS_REQ, pid, user, NULL) < 0) {
+#endif
    print_debug("ptrace(PTRACE_GETREGS, ...) failed for lwp %d\n", pid);
    return false;
  }
@@ -216,7 +266,11 @@ static bool ptrace_waitpid(pid_t pid) {
 
 // attach to a process/thread specified by "pid"
 static bool ptrace_attach(pid_t pid, char* err_buf, size_t err_buf_len) {
+#if defined(__FreeBSD_kernel__)
+  if (ptrace(PTRACE_ATTACH, pid, NULL, 0) < 0) {
+#else
   if (ptrace(PTRACE_ATTACH, pid, NULL, NULL) < 0) {
+#endif
     char buf[200];
     char* msg = strerror_r(errno, buf, sizeof(buf));
     snprintf(err_buf, err_buf_len, "ptrace(PTRACE_ATTACH, ..) failed for %d: 
%s", pid, msg);
@@ -313,7 +367,11 @@ static bool read_lib_info(struct ps_proc
 
 // detach a given pid
 static bool ptrace_detach(pid_t pid) {
+#if defined(__FreeBSD_kernel__)
+  if (pid && ptrace(PTRACE_DETACH, pid, NULL, 0) < 0) {
+#else
   if (pid && ptrace(PTRACE_DETACH, pid, NULL, NULL) < 0) {
+#endif
     print_debug("ptrace(PTRACE_DETACH, ..) failed for %d\n", pid);
     return false;
   } else {
Index: b/hotspot/agent/src/os/linux/libproc.h
===================================================================
--- a/hotspot/agent/src/os/linux/libproc.h
+++ b/hotspot/agent/src/os/linux/libproc.h
@@ -28,6 +28,10 @@
 #include <jni.h>
 #include <unistd.h>
 #include <stdint.h>
+#if defined(__FreeBSD_kernel__)
+#include <sys/types.h>
+#include <machine/reg.h>
+#endif
 #include "proc_service.h"
 
 #ifdef ALT_SASRCDIR
@@ -73,6 +77,10 @@ combination of ptrace and /proc calls.
 #define user_regs_struct  pt_regs
 #endif
 
+#if defined(__FreeBSD_kernel__)
+#define user_regs_struct reg
+#endif
+
 // This C bool type must be int for compatibility with Linux calls and
 // it would be a mistake to equivalence it to C++ bool on many platforms
 
Index: b/hotspot/agent/src/os/linux/LinuxDebuggerLocal.c
===================================================================
--- a/hotspot/agent/src/os/linux/LinuxDebuggerLocal.c
+++ b/hotspot/agent/src/os/linux/LinuxDebuggerLocal.c
@@ -367,7 +367,7 @@ JNIEXPORT jlongArray JNICALL Java_sun_jv
 
 #ifdef i386
 #define REG_INDEX(reg) sun_jvm_hotspot_debugger_x86_X86ThreadContext_##reg
-
+#ifdef __linux__
   regs[REG_INDEX(GS)]  = (uintptr_t) gregs.xgs;
   regs[REG_INDEX(FS)]  = (uintptr_t) gregs.xfs;
   regs[REG_INDEX(ES)]  = (uintptr_t) gregs.xes;
@@ -383,12 +383,28 @@ JNIEXPORT jlongArray JNICALL Java_sun_jv
   regs[REG_INDEX(PC)] = (uintptr_t) gregs.eip;
   regs[REG_INDEX(CS)]  = (uintptr_t) gregs.xcs;
   regs[REG_INDEX(SS)]  = (uintptr_t) gregs.xss;
-
+#elif defined(__FreeBSD_kernel__)
+  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
 #endif /* i386 */
 
 #ifdef amd64
 #define REG_INDEX(reg) sun_jvm_hotspot_debugger_amd64_AMD64ThreadContext_##reg
-
+#ifdef __linux__
   regs[REG_INDEX(R15)] = gregs.r15;
   regs[REG_INDEX(R14)] = gregs.r14;
   regs[REG_INDEX(R13)] = gregs.r13;
@@ -414,7 +430,27 @@ JNIEXPORT jlongArray JNICALL Java_sun_jv
   regs[REG_INDEX(ES)] = gregs.es;
   regs[REG_INDEX(FS)] = gregs.fs;
   regs[REG_INDEX(GS)] = gregs.gs;
-
+#elif defined(__FreeBSD_kernel__)
+  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;
+#endif
 #endif /* amd64 */
 
 #if defined(sparc) || defined(sparcv9)
Index: b/hotspot/make/linux/makefiles/saproc.make
===================================================================
--- a/hotspot/make/linux/makefiles/saproc.make
+++ b/hotspot/make/linux/makefiles/saproc.make
@@ -90,6 +90,7 @@ $(LIBSAPROC): $(SASRCFILES) $(SAMAPFILE)
                   -I$(GENERATED)                                       \
                   -I$(BOOT_JAVA_HOME)/include                          \
                   -I$(BOOT_JAVA_HOME)/include/$(Platform_os_family)    \
+                  -I$(BOOT_JAVA_HOME)/include/bsd                      \
                           $(ALT_SAINCDIR)                                      
                                        \
                   $(SASRCFILES)                                        \
                   $(SA_LFLAGS)                                         \

--- End Message ---
--- Begin Message ---
Source: openjdk-8
Source-Version: 8u141-b15-3

We believe that the bug you reported is fixed in the latest version of
openjdk-8, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to [email protected],
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Matthias Klose <[email protected]> (supplier of updated openjdk-8 package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [email protected])


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Format: 1.8
Date: Tue, 25 Jul 2017 17:03:27 +0200
Source: openjdk-8
Binary: openjdk-8-jdk-headless openjdk-8-jre-headless openjdk-8-jdk 
openjdk-8-jre openjdk-8-demo openjdk-8-source openjdk-8-doc openjdk-8-dbg 
openjdk-8-jre-zero
Architecture: source
Version: 8u141-b15-3
Distribution: unstable
Urgency: high
Maintainer: OpenJDK Team <[email protected]>
Changed-By: Matthias Klose <[email protected]>
Description:
 openjdk-8-dbg - Java runtime based on OpenJDK (debugging symbols)
 openjdk-8-demo - Java runtime based on OpenJDK (demos and examples)
 openjdk-8-doc - OpenJDK Development Kit (JDK) documentation
 openjdk-8-jdk - OpenJDK Development Kit (JDK)
 openjdk-8-jdk-headless - OpenJDK Development Kit (JDK) (headless)
 openjdk-8-jre - OpenJDK Java runtime, using ${vm:Name}
 openjdk-8-jre-headless - OpenJDK Java runtime, using ${vm:Name} (headless)
 openjdk-8-jre-zero - Alternative JVM for OpenJDK, using Zero/Shark
 openjdk-8-source - OpenJDK Development Kit (JDK) source files
Closes: 869643 869672
Changes:
 openjdk-8 (8u141-b15-3) unstable; urgency=high
 .
   * Fix building the javadocs, build error introduced by the m68k changes.
   * Update the kfreebsd patches (Adrian Glaubitz). Closes: #869643, #869672.
Checksums-Sha1:
 b96e9e6857d2a48b44d68c1da0ebed21258520a1 4483 openjdk-8_8u141-b15-3.dsc
 dd273c9e2ae6aad1c2cb496dca4e00a401338799 245988 
openjdk-8_8u141-b15-3.debian.tar.xz
 f53bd33b32f63d659805c647e1cee9a6c82a1cc6 16334 
openjdk-8_8u141-b15-3_source.buildinfo
Checksums-Sha256:
 33afe45c0bb31d2eca8c0836c1efdcaf20ca16a07df6a3b2bba007191ff0c0bf 4483 
openjdk-8_8u141-b15-3.dsc
 0ce757bc7262a4d31762fb30b12ab9f6b5a0ecadae36d80e9200a5cbdbbb39a3 245988 
openjdk-8_8u141-b15-3.debian.tar.xz
 f261b0a4ff9cec4588f399d319d8ad5fa0886d82a5a0083041a9df27b4b1eb61 16334 
openjdk-8_8u141-b15-3_source.buildinfo
Files:
 4dbe6a5e69ebbb0f0462cad9380f4cd7 4483 java optional openjdk-8_8u141-b15-3.dsc
 4cb60f795f9ce5dc2fc375a023a3bce6 245988 java optional 
openjdk-8_8u141-b15-3.debian.tar.xz
 4e1d605bb896f139a4a0cccc4f98ee85 16334 java optional 
openjdk-8_8u141-b15-3_source.buildinfo

-----BEGIN PGP SIGNATURE-----

iQJEBAEBCAAuFiEE1WVxuIqLuvFAv2PWvX6qYHePpvUFAll3XycQHGRva29AdWJ1
bnR1LmNvbQAKCRC9fqpgd4+m9UG8D/4jwgfnCF+zrZIlUXF/3OE4rGOgFKmNw0Tj
NnpXsjqCTiSxRDN+rsrdyCYBTF4e9iuZDxX+GehCR0LZncUbPStWIvv0fL96w5ij
W5UsOCbQJvsz2CAi8T5mpA5dT78qHQ2kZBgvzepx0Bfv2r2dGy74HlWwo2qOb4Zw
n9cQcaabrUTx0LxU6X6T79kXyK16mnhvg+8Wz9Sqk49hQ8GfJ4hq6uPXEjIIe1Lt
3DyaFAPhtw/GZrmSDW1dvgsHtr8lvhwjiShjcZxkCU/k6cPGr2VDku/kTHd60yXO
O2BhEVUyyzQyB9ljC84ZMi4I4Iw73BUGCZwGLBBibB+kNrj45vDr3H4Zk8K55BTZ
GcJMe+vV671jm37oSxQf7g1CdnMZ0+5jn7HGj6lM52LTQTbAED5PP83clHJ01zQi
mjKxYxxSnomTX6gAo/Q6xbL+cEkX2YMrgFibAauaMRSjkGgQAKaWpPB5t1E6dyEP
/rHHqMHrrk4zlEq0wBxEgFDPKuuhxZT8oeQo0nX8xrHznOS4zznmy5Dy/CBcC2Tw
JaFZaazJ2YRpqhsDYXVzOjE6PUOo6lDJcEoRiYqAUqE3Nsraw6K671Mnny7BGEtP
Tf6+nF1xL8bNrjKPUPFpgfOAFSsCvZGXtcn8XwWyQ8CZo1tgG2k7gsDRrHMj/kNq
9l2Xgk7nkw==
=1bDF
-----END PGP SIGNATURE-----

--- End Message ---

Reply via email to