8164383: jhsdb dumps core on Solaris 12 when loading dumped core
Summary: Add the required extra parameters to Plookup_by_addr() and proc_arg_grab() as per the change to libproc with Solaris 12.
Reviewed-by: dsamersoff, sspitsyn
Contributed-by: jini.george@oracle.com
--- a/hotspot/make/lib/Lib-jdk.hotspot.agent.gmk Fri Oct 21 10:27:32 2016 +0200
+++ b/hotspot/make/lib/Lib-jdk.hotspot.agent.gmk Fri Oct 21 12:30:12 2016 +0300
@@ -61,9 +61,8 @@
else ifeq ($(OPENJDK_TARGET_OS), solaris)
SA_TOOLCHAIN := TOOLCHAIN_LINK_CXX
- COMMON_CFLAGS := -DSOLARIS_11_B159_OR_LATER
- SA_CFLAGS := $(CFLAGS_JDKLIB) $(COMMON_CFLAGS)
- SA_CXXFLAGS := $(CXXFLAGS_JDKLIB) $(COMMON_CFLAGS)
+ SA_CFLAGS := $(CFLAGS_JDKLIB)
+ SA_CXXFLAGS := $(CXXFLAGS_JDKLIB)
SA_LDFLAGS := $(subst -Wl$(COMMA)-z$(COMMA)defs,, $(LDFLAGS_JDKLIB)) \
-mt $(LDFLAGS_CXX_JDK)
SA_LIBS := -ldl -ldemangle -lthread -lc
--- a/hotspot/src/jdk.hotspot.agent/solaris/native/libsaproc/libproc.h Fri Oct 21 10:27:32 2016 +0200
+++ b/hotspot/src/jdk.hotspot.agent/solaris/native/libsaproc/libproc.h Fri Oct 21 12:30:12 2016 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. 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
@@ -420,8 +420,6 @@
/*
* Stack frame iteration interface.
*/
-#ifdef SOLARIS_11_B159_OR_LATER
-/* building on Nevada-B159 or later so define the new callback */
typedef int proc_stack_f(
void *, /* the cookie given to Pstack_iter() */
const prgregset_t, /* the frame's registers */
@@ -432,10 +430,6 @@
#define PR_SIGNAL_FRAME 1 /* called by a signal handler */
#define PR_FOUND_SIGNAL 2 /* we found the corresponding signal number */
-#else
-/* building on Nevada-B158 or earlier so define the old callback */
-typedef int proc_stack_f(void *, const prgregset_t, uint_t, const long *);
-#endif
extern int Pstack_iter(struct ps_prochandle *,
const prgregset_t, proc_stack_f *, void *);
--- a/hotspot/src/jdk.hotspot.agent/solaris/native/libsaproc/salibproc.h Fri Oct 21 10:27:32 2016 +0200
+++ b/hotspot/src/jdk.hotspot.agent/solaris/native/libsaproc/salibproc.h Fri Oct 21 12:30:12 2016 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. 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
@@ -46,6 +46,17 @@
extern "C" {
#endif
+/* extended symbol table information */
+typedef struct {
+ const char *prs_object; /* object name */
+ const char *prs_name; /* symbol name */
+ Lmid_t prs_lmid; /* link map id */
+ uint_t prs_id; /* symbol id */
+ uint_t prs_table; /* symbol table id */
+} prsyminfo_t;
+
+typedef struct ps_prochandle ps_prochandle_t;
+
/*
* 'object_name' is the name of a load object obtained from an
* iteration over the process's address space mappings (Pmapping_iter),
@@ -53,8 +64,10 @@
* or else it is one of the special PR_OBJ_* values above.
*/
-extern int Plookup_by_addr(struct ps_prochandle *,
- uintptr_t, char *, size_t, GElf_Sym *);
+extern int Plookup_by_addr(ps_prochandle_t *, uintptr_t, char *,
+ size_t, GElf_Sym *, prsyminfo_t *);
+extern ps_prochandle_t *proc_arg_grab(const char *, int, int,
+ int *, const char **);
typedef int proc_map_f(void *, const prmap_t *, const char *);
extern int Pobject_iter(struct ps_prochandle *, proc_map_f *, void *);
@@ -88,7 +101,6 @@
#define G_ELF 13 /* Libelf error, elf_errno() is meaningful */
#define G_NOTE 14 /* Required PT_NOTE Phdr not present in core */
-extern struct ps_prochandle *proc_arg_grab(const char *, int, int, int *);
extern const pstatus_t *Pstatus(struct ps_prochandle *);
/* Flags accepted by Prelease (partial) */
@@ -101,8 +113,6 @@
/*
* Stack frame iteration interface.
*/
-#ifdef SOLARIS_11_B159_OR_LATER
-/* building on Nevada-B159 or later so define the new callback */
typedef int proc_stack_f(
void *, /* the cookie given to Pstack_iter() */
const prgregset_t, /* the frame's registers */
@@ -113,10 +123,6 @@
#define PR_SIGNAL_FRAME 1 /* called by a signal handler */
#define PR_FOUND_SIGNAL 2 /* we found the corresponding signal number */
-#else
-/* building on Nevada-B158 or earlier so define the old callback */
-typedef int proc_stack_f(void *, const prgregset_t, uint_t, const long *);
-#endif
extern int Pstack_iter(struct ps_prochandle *,
const prgregset_t, proc_stack_f *, void *);
--- a/hotspot/src/jdk.hotspot.agent/solaris/native/libsaproc/saproc.cpp Fri Oct 21 10:27:32 2016 +0200
+++ b/hotspot/src/jdk.hotspot.agent/solaris/native/libsaproc/saproc.cpp Fri Oct 21 12:30:12 2016 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. 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
@@ -24,9 +24,6 @@
#include "salibproc.h"
#include "sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal.h"
-#ifndef SOLARIS_11_B159_OR_LATER
-#include <sys/utsname.h>
-#endif
#include <thread_db.h>
#include <strings.h>
#include <limits.h>
@@ -45,20 +42,6 @@
// debug modes
static int _libsaproc_debug = 0;
-#ifndef SOLARIS_11_B159_OR_LATER
-static bool _Pstack_iter_debug = false;
-
-static void dprintf_2(const char* format,...) {
- if (_Pstack_iter_debug) {
- va_list alist;
-
- va_start(alist, format);
- fputs("Pstack_iter DEBUG: ", stderr);
- vfprintf(stderr, format, alist);
- va_end(alist);
- }
-}
-#endif // !SOLARIS_11_B159_OR_LATER
static void print_debug(const char* format,...) {
if (_libsaproc_debug) {
@@ -757,7 +740,8 @@
#endif
// connect to process/core
- struct ps_prochandle* ph = proc_arg_grab(cmdLine_cstr, (isProcess? PR_ARG_PIDS : PR_ARG_CORES), PGRAB_FORCE, &gcode);
+ ps_prochandle_t* ph = proc_arg_grab(cmdLine_cstr, (isProcess? PR_ARG_PIDS : PR_ARG_CORES), PGRAB_FORCE, &gcode, NULL);
+
env->ReleaseStringUTFChars(cmdLine, cmdLine_cstr);
if (! ph) {
if (gcode > 0 && gcode < sizeof(proc_arg_grab_errmsgs)/sizeof(const char*)) {
@@ -997,11 +981,6 @@
TD_THR_ANY_STATE, TD_THR_LOWEST_PRIORITY, TD_SIGNO_MASK, TD_THR_ANY_USER_FLAGS);
}
-#ifndef SOLARIS_11_B159_OR_LATER
-// building on Nevada-B158 or earlier so more hoops to jump through
-static bool has_newer_Pstack_iter = false; // older version by default
-#endif
-
/*
* Class: sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal
* Method: fillCFrameList0
@@ -1030,23 +1009,8 @@
env->ReleaseLongArrayElements(regsArray, ptr, JNI_ABORT);
CHECK_EXCEPTION_(0);
-#ifdef SOLARIS_11_B159_OR_LATER
- // building on Nevada-B159 or later so use the new callback
Pstack_iter((struct ps_prochandle*) p_ps_prochandle, gregs,
wrapper_fill_cframe_list, &dbgo2);
-#else
- // building on Nevada-B158 or earlier so figure out which callback to use
-
- if (has_newer_Pstack_iter) {
- // Since we're building on Nevada-B158 or earlier, we have to
- // cast wrapper_fill_cframe_list to make the compiler happy.
- Pstack_iter((struct ps_prochandle*) p_ps_prochandle, gregs,
- (proc_stack_f *)wrapper_fill_cframe_list, &dbgo2);
- } else {
- Pstack_iter((struct ps_prochandle*) p_ps_prochandle, gregs,
- fill_cframe_list, &dbgo2);
- }
-#endif // SOLARIS_11_B159_OR_LATER
return dbgo2.obj;
}
@@ -1236,7 +1200,8 @@
char nameBuf[SYMBOL_BUF_SIZE + 1];
GElf_Sym sym;
int res = Plookup_by_addr((struct ps_prochandle*) p_ps_prochandle, (uintptr_t) address,
- nameBuf, sizeof(nameBuf), &sym);
+ nameBuf, sizeof(nameBuf), &sym, NULL);
+
if (res != 0) { // failed
return 0;
}
@@ -1268,102 +1233,6 @@
return res;
}
-#ifndef SOLARIS_11_B159_OR_LATER
-// Determine if the OS we're running on has the newer version
-// of libproc's Pstack_iter.
-//
-// Set env var PSTACK_ITER_DEBUG=true to debug this logic.
-// Set env var PSTACK_ITER_DEBUG_RELEASE to simulate a 'release' value.
-// Set env var PSTACK_ITER_DEBUG_VERSION to simulate a 'version' value.
-//
-// frankenputer 'uname -r -v': 5.10 Generic_141445-09
-// jurassic 'uname -r -v': 5.11 snv_164
-// lonepeak 'uname -r -v': 5.11 snv_127
-//
-static void set_has_newer_Pstack_iter(JNIEnv *env) {
- static bool done_set = false;
-
- if (done_set) {
- // already set has_newer_Pstack_iter
- return;
- }
-
- struct utsname name;
- if (uname(&name) == -1) {
- THROW_NEW_DEBUGGER_EXCEPTION("uname() failed!");
- }
- dprintf_2("release='%s' version='%s'\n", name.release, name.version);
-
- if (_Pstack_iter_debug) {
- char *override = getenv("PSTACK_ITER_DEBUG_RELEASE");
- if (override != NULL) {
- strncpy(name.release, override, SYS_NMLN - 1);
- name.release[SYS_NMLN - 2] = '\0';
- dprintf_2("overriding with release='%s'\n", name.release);
- }
- override = getenv("PSTACK_ITER_DEBUG_VERSION");
- if (override != NULL) {
- strncpy(name.version, override, SYS_NMLN - 1);
- name.version[SYS_NMLN - 2] = '\0';
- dprintf_2("overriding with version='%s'\n", name.version);
- }
- }
-
- // the major number corresponds to the old SunOS major number
- int major = atoi(name.release);
- if (major >= 6) {
- dprintf_2("release is SunOS 6 or later\n");
- has_newer_Pstack_iter = true;
- done_set = true;
- return;
- }
- if (major < 5) {
- dprintf_2("release is SunOS 4 or earlier\n");
- done_set = true;
- return;
- }
-
- // some SunOS 5.* build so now check for Solaris versions
- char *dot = strchr(name.release, '.');
- int minor = 0;
- if (dot != NULL) {
- // release is major.minor format
- *dot = NULL;
- minor = atoi(dot + 1);
- }
-
- if (minor <= 10) {
- dprintf_2("release is Solaris 10 or earlier\n");
- done_set = true;
- return;
- } else if (minor >= 12) {
- dprintf_2("release is Solaris 12 or later\n");
- has_newer_Pstack_iter = true;
- done_set = true;
- return;
- }
-
- // some Solaris 11 build so now check for internal build numbers
- if (strncmp(name.version, "snv_", 4) != 0) {
- dprintf_2("release is Solaris 11 post-GA or later\n");
- has_newer_Pstack_iter = true;
- done_set = true;
- return;
- }
-
- // version begins with "snv_" so a pre-GA build of Solaris 11
- int build = atoi(&name.version[4]);
- if (build >= 159) {
- dprintf_2("release is Nevada-B159 or later\n");
- has_newer_Pstack_iter = true;
- } else {
- dprintf_2("release is Nevada-B158 or earlier\n");
- }
-
- done_set = true;
-}
-#endif // !SOLARIS_11_B159_OR_LATER
-
/*
* Class: sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal
* Method: initIDs
@@ -1383,14 +1252,6 @@
if (libproc_handle == 0)
THROW_NEW_DEBUGGER_EXCEPTION("can't load libproc.so, if you are using Solaris 5.7 or below, copy libproc.so from 5.8!");
-#ifndef SOLARIS_11_B159_OR_LATER
- _Pstack_iter_debug = getenv("PSTACK_ITER_DEBUG") != NULL;
-
- set_has_newer_Pstack_iter(env);
- CHECK_EXCEPTION;
- dprintf_2("has_newer_Pstack_iter=%d\n", has_newer_Pstack_iter);
-#endif
-
p_ps_prochandle_ID = env->GetFieldID(clazz, "p_ps_prochandle", "J");
CHECK_EXCEPTION;