11
11
#include <thread.h>
12
@@ -107,7 +107,7 @@ extern char **environ;
13
13
* A collection of useful strings. One should think of these as #define
14
14
* entries, but actual strings can be more efficient (with many compilers).
18
18
static const char *system_dir = "/usr/java";
19
19
static const char *user_dir = "/java";
20
20
#else /* Solaris */
21
@@ -444,7 +444,7 @@ CreateExecutionEnvironment(int *_argcp,
22
22
runpath = getenv(LD_LIBRARY_PATH);
28
28
* On linux, if a binary is running as sgid or suid, glibc sets
29
29
* LD_LIBRARY_PATH to the empty string for security purposes. (In
30
@@ -834,7 +834,7 @@ error:
32
32
GetApplicationHome(char *buf, jint bufsize)
36
36
char *execname = GetExecname();
38
38
strncpy(buf, execname, bufsize-1);
39
@@ -1003,7 +1003,7 @@ SetExecname(char **argv)
46
46
const char* self = "/proc/self/exe";
47
47
char buf[PATH_MAX+1];
48
@@ -1898,7 +1898,7 @@ jlong_format_specifier() {
50
50
ContinueInNewThread(int (JNICALL *continuation)(void *), jlong stack_size, void * args) {
77
77
// The attach mechanism on Linux uses a UNIX domain socket. An attach listener
78
78
// thread is created at startup or is created on-demand via a signal from
79
79
// the client tool. The attach listener creates a socket and binds it to a file
80
@@ -337,9 +341,15 @@ LinuxAttachOperation* LinuxAttachListene
82
82
// get the credentials of the peer and check the effective uid/guid
83
83
// - check with jeff on this.
108
108
--- openjdk/hotspot/src/os/linux/vm/jvm_linux.cpp.orig
109
109
+++ openjdk/hotspot/src/os/linux/vm/jvm_linux.cpp
110
@@ -169,7 +169,9 @@ struct siglabel siglabels[] = {
111
111
"WINCH", SIGWINCH, /* Window size change (4.3 BSD, Sun). */
112
112
"POLL", SIGPOLL, /* Pollable event occurred (System V). */
113
113
"IO", SIGIO, /* I/O now possible (4.2 BSD). */
169
169
julong os::physical_memory() {
170
@@ -2299,18 +2319,22 @@
170
@@ -2325,18 +2345,22 @@ void os::print_memory_info(outputStream*
171
171
st->print("Memory:");
172
172
st->print(" %dk page", os::vm_page_size()>>10);
193
@@ -6122,6 +6146,7 @@
194
int os::fork_and_exec(char* cmd) {
195
const char * argv[4] = {"sh", "-c", cmd, NULL};
193
@@ -6218,8 +6242,12 @@ int os::fork_and_exec(char* cmd) {
195
sparc_fork(__NR_fork, &pid, &is_child);
197
197
+#ifdef __linux__
198
// fork() in LinuxThreads/NPTL is not async-safe. It needs to run
199
// pthread_atfork handlers and reset pthread library. All we need is a
200
// separate process to execve. Make a direct syscall to fork process.
201
@@ -6130,6 +6155,9 @@
202
pid_t pid = NOT_IA64(NOT_AARCH64(syscall(SYS_fork);))
198
pid = NOT_IA64(syscall(__NR_fork);)
203
199
IA64_ONLY(fork();)
204
AARCH64_ONLY(vfork();)
206
+ pid_t pid = fork();
211
@@ -6138,6 +6166,7 @@
212
} else if (pid == 0) {
204
// set the is_child flag by checking the pid
206
@@ -6236,6 +6264,7 @@ int os::fork_and_exec(char* cmd) {
207
} else if (is_child) {
215
210
+#ifdef __linux__
216
211
// execve() in LinuxThreads will call pthread_kill_other_threads_np()
217
212
// first to kill every thread on the thread list. Because this list is
218
213
// not reset by fork() (see notes above), execve() will instead kill
219
@@ -6147,6 +6176,9 @@
214
@@ -6245,6 +6274,9 @@ int os::fork_and_exec(char* cmd) {
221
NOT_IA64(syscall(SYS_execve, "/bin/sh", argv, environ);)
216
NOT_IA64(syscall(__NR_execve, "/bin/sh", argv, environ);)
222
217
IA64_ONLY(execve("/bin/sh", (char* const*)argv, environ);)
224
219
+ execve("/bin/sh", (char* const*)argv, environ);
339
334
// For Forte Analyzer AsyncGetCallTrace profiling support - thread
340
@@ -277,12 +339,20 @@
335
@@ -277,12 +339,20 @@ JVM_handle_linux_signal(int sig,
341
336
pc = (address) os::Linux::ucontext_get_pc(uc);
343
338
if (pc == (address) Fetch32PFI) {
356
@@ -433,7 +503,11 @@ JVM_handle_linux_signal(int sig,
362
357
// Furthermore, a false-positive should be harmless.
363
358
if (UnguardOnExecutionViolation > 0 &&
364
359
(sig == SIGSEGV || sig == SIGBUS) &&
370
365
int page_size = os::vm_page_size();
371
366
address addr = (address) info->si_addr;
372
367
address pc = os::Linux::ucontext_get_pc(uc);
368
@@ -503,7 +577,11 @@ JVM_handle_linux_signal(int sig,
374
369
// save all thread context in case we need to restore it
375
370
if (thread != NULL) thread->set_saved_exception_pc(pc);
380
@@ -755,6 +833,7 @@ void os::print_context(outputStream *st,
387
382
ucontext_t *uc = (ucontext_t*)context;
388
383
st->print_cr("Registers:");
391
386
st->print( "RAX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RAX]);
392
387
st->print(", RBX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RBX]);
388
@@ -797,6 +876,48 @@ void os::print_context(outputStream *st,
394
389
st->print(", EFLAGS=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_EFL]);
395
390
st->print(", CR2=" INTPTR_FORMAT, uc->uc_mcontext.cr2);
448
443
st->print("RAX="); print_location(st, uc->uc_mcontext.gregs[REG_RAX]);
449
444
st->print("RBX="); print_location(st, uc->uc_mcontext.gregs[REG_RBX]);
445
@@ -854,6 +976,35 @@ void os::print_register_info(outputStrea
451
446
st->print("ESI="); print_location(st, uc->uc_mcontext.gregs[REG_ESI]);
452
447
st->print("EDI="); print_location(st, uc->uc_mcontext.gregs[REG_EDI]);
528
523
#endif // __STDC_LIMIT_MACROS
529
524
--- openjdk/hotspot/make/defs.make.orig
530
525
+++ openjdk/hotspot/make/defs.make
526
@@ -152,9 +152,6 @@ endif
532
527
# Windows should have OS predefined
534
529
OS := $(shell uname -s)
552
547
--- openjdk/hotspot/make/linux/Makefile.orig
553
548
+++ openjdk/hotspot/make/linux/Makefile
555
SUPPORTED_OS_VERSION = 2.4% 2.5% 2.6% 3%
549
@@ -258,6 +258,9 @@ checks: check_os_version check_j2se_vers
550
SUPPORTED_OS_VERSION = 2.4% 2.5% 2.6% 3% 4%
556
551
OS_VERSION := $(shell uname -r)
557
552
EMPTY_IF_NOT_SUPPORTED = $(filter $(SUPPORTED_OS_VERSION),$(OS_VERSION))
558
553
+ifeq ($(shell uname -s), GNU/kFreeBSD)
563
558
ifeq ($(DISABLE_HOTSPOT_OS_VERSION_CHECK)$(EMPTY_IF_NOT_SUPPORTED),)
564
559
--- openjdk/hotspot/make/linux/makefiles/defs.make.orig
565
560
+++ openjdk/hotspot/make/linux/makefiles/defs.make
561
@@ -91,7 +91,7 @@ ifeq ($(ARCH), x86_64)
591
586
// print the regset
592
587
print_debug("\teax = 0x%x\n", newthr->regs.eax);
593
588
print_debug("\tebx = 0x%x\n", newthr->regs.ebx);
589
@@ -554,9 +559,21 @@ static bool core_handle_prstatus(struct
595
590
print_debug("\tesi = 0x%x\n", newthr->regs.esi);
596
591
print_debug("\tedi = 0x%x\n", newthr->regs.edi);
597
592
print_debug("\teip = 0x%x\n", newthr->regs.eip);
613
608
// print the regset
614
609
print_debug("\tr15 = 0x%lx\n", newthr->regs.r15);
615
610
print_debug("\tr14 = 0x%lx\n", newthr->regs.r14);
611
@@ -585,6 +602,27 @@ static bool core_handle_prstatus(struct
617
612
print_debug("\tes = 0x%lx\n", newthr->regs.es);
618
613
print_debug("\tfs = 0x%lx\n", newthr->regs.fs);
619
614
print_debug("\tgs = 0x%lx\n", newthr->regs.gs);
666
661
// This file has the libproc implementation specific to live process
667
662
// For core files, refer to ps_core.c
664
@@ -57,7 +73,11 @@ static inline uintptr_t align(uintptr_t
670
665
// before calling process_read_data.
672
667
static bool process_read_data(struct ps_prochandle* ph, uintptr_t addr, char *buf, size_t size) {
679
674
uintptr_t end_addr = addr + size;
680
675
uintptr_t aligned_addr = align(addr, sizeof(long));
676
@@ -65,36 +85,62 @@ static bool process_read_data(struct ps_
682
677
if (aligned_addr != addr) {
683
678
char *ptr = (char *)&rslt;
742
737
print_debug("ptrace(PTRACE_PEEKDATA, ..) failed for %d bytes @ %lx\n", size, addr);
739
@@ -133,7 +179,11 @@ static bool process_get_lwp_regs(struct
747
742
#ifdef PTRACE_GETREGS_REQ
753
748
print_debug("ptrace(PTRACE_GETREGS, ...) failed for lwp %d\n", pid);
751
@@ -205,7 +255,11 @@ static bool ptrace_waitpid(pid_t pid) {
758
753
// attach to a process/thread specified by "pid"
759
754
static bool ptrace_attach(pid_t pid) {
765
760
print_debug("ptrace(PTRACE_ATTACH, ..) failed for %d\n", pid);
763
@@ -341,7 +395,11 @@ static bool read_lib_info(struct ps_proc
770
765
// detach a given pid
771
766
static bool ptrace_detach(pid_t pid) {
790
785
#include "proc_service.h"
792
787
#if defined(arm) || defined(ppc)
788
@@ -80,6 +84,10 @@ unsigned long regs[IA64_REG_COUNT];
794
789
#define user_regs_struct pt_regs
804
799
--- openjdk/hotspot/agent/src/os/linux/LinuxDebuggerLocal.c.orig
805
800
+++ openjdk/hotspot/agent/src/os/linux/LinuxDebuggerLocal.c
801
@@ -318,7 +318,7 @@ JNIEXPORT jlongArray JNICALL Java_sun_jv
809
804
#define REG_INDEX(reg) sun_jvm_hotspot_debugger_x86_X86ThreadContext_##reg
812
807
regs[REG_INDEX(GS)] = (uintptr_t) gregs.xgs;
813
808
regs[REG_INDEX(FS)] = (uintptr_t) gregs.xfs;
814
809
regs[REG_INDEX(ES)] = (uintptr_t) gregs.xes;
810
@@ -334,7 +334,23 @@ JNIEXPORT jlongArray JNICALL Java_sun_jv
816
811
regs[REG_INDEX(PC)] = (uintptr_t) gregs.eip;
817
812
regs[REG_INDEX(CS)] = (uintptr_t) gregs.xcs;
818
813
regs[REG_INDEX(SS)] = (uintptr_t) gregs.xss;
846
841
regs[REG_INDEX(R15)] = gregs.r15;
847
842
regs[REG_INDEX(R14)] = gregs.r14;
848
843
regs[REG_INDEX(R13)] = gregs.r13;
844
@@ -372,7 +388,27 @@ JNIEXPORT jlongArray JNICALL Java_sun_jv
850
845
regs[REG_INDEX(ES)] = gregs.es;
851
846
regs[REG_INDEX(FS)] = gregs.fs;
852
847
regs[REG_INDEX(GS)] = gregs.gs;
875
870
#endif /* amd64 */
877
872
#if defined(sparc) || defined(sparcv9)
878
--- openjdk/hotspot/agent/src/os/linux/libproc.h.orig
879
+++ openjdk/hotspot/agent/src/os/linux/libproc.h
881
#include "libproc_md.h"
885
#include <linux/ptrace.h>
888
/************************************************************************************