src/hotspot/share/utilities/vmError.cpp
author stefank
Mon, 25 Nov 2019 12:33:15 +0100
changeset 59252 623722a6aeb9
parent 59248 e92153ed8bdc
permissions -rw-r--r--
8234740: Harmonize parameter order in Atomic - cmpxchg Reviewed-by: rehn, dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
54031
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents: 53599
diff changeset
     2
 * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5403
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5403
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5403
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    25
#include "precompiled.hpp"
47765
b7c7428eaab9 8189610: Reconcile jvm.h and all jvm_md.h between java.base and hotspot
coleenp
parents: 47687
diff changeset
    26
#include "jvm.h"
25715
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 25351
diff changeset
    27
#include "code/codeCache.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    28
#include "compiler/compileBroker.hpp"
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32583
diff changeset
    29
#include "compiler/disassembler.hpp"
49922
3a64eea72624 8202364: Add GCConfig::hs_err_name() to avoid GC-specific code in error reporting
pliden
parents: 49725
diff changeset
    30
#include "gc/shared/gcConfig.hpp"
37994
1a816b464178 8151526: Print -Xlog configuration in the hs_err_pid file
mockner
parents: 37466
diff changeset
    31
#include "logging/logConfiguration.hpp"
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents: 50015
diff changeset
    32
#include "jfr/jfrEvents.hpp"
49334
aefee96e2b90 8198845: Missing resource mark results disassembling generated code failure in hs error report
zgu
parents: 49176
diff changeset
    33
#include "memory/resourceArea.hpp"
54786
ebf733a324d4 8223624: Cleanup includes of universe.hpp
stefank
parents: 54780
diff changeset
    34
#include "memory/universe.hpp"
54780
f8d182aedc92 8223136: Move compressed oops functions to CompressedOops class
stefank
parents: 54623
diff changeset
    35
#include "oops/compressedOops.hpp"
12095
cc3d6f08a4c4 7148152: Add whitebox testing API to HotSpot
mgerdin
parents: 11636
diff changeset
    36
#include "prims/whitebox.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    37
#include "runtime/arguments.hpp"
40655
9f644073d3a0 8157907: Incorrect inclusion of atomic.hpp instead of atomic.inline.hpp
dholmes
parents: 39626
diff changeset
    38
#include "runtime/atomic.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    39
#include "runtime/frame.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    40
#include "runtime/init.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    41
#include "runtime/os.hpp"
24351
61b33cc6d3cf 8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents: 23204
diff changeset
    42
#include "runtime/thread.inline.hpp"
48105
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47765
diff changeset
    43
#include "runtime/threadSMR.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    44
#include "runtime/vmThread.hpp"
52877
9e041366c764 8214850: Rename vm_operations.?pp files to vmOperations.?pp files
tschatzl
parents: 52585
diff changeset
    45
#include "runtime/vmOperations.hpp"
46284
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
    46
#include "runtime/vm_version.hpp"
50196
85e3ac4fa57b 8203292: Print complete set of flags in the hs_err file
simonis
parents: 50113
diff changeset
    47
#include "runtime/flags/jvmFlag.hpp"
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 12268
diff changeset
    48
#include "services/memTracker.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    49
#include "utilities/debug.hpp"
7447
32c42d627f41 7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents: 7397
diff changeset
    50
#include "utilities/decoder.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    51
#include "utilities/defaultStream.hpp"
11636
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 11483
diff changeset
    52
#include "utilities/events.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    53
#include "utilities/vmError.hpp"
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents: 50015
diff changeset
    54
#include "utilities/macros.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents: 50015
diff changeset
    55
#if INCLUDE_JFR
caf115bb98ad 8199712: Flight Recorder
egahlin
parents: 50015
diff changeset
    56
#include "jfr/jfr.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents: 50015
diff changeset
    57
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
46589
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
    59
#ifndef PRODUCT
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
    60
#include <signal.h>
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
    61
#endif // PRODUCT
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
    62
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
    63
bool VMError::_error_reported = false;
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
    64
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
    65
// call this when the VM is dying--it might loosen some asserts
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
    66
bool VMError::is_error_reported() { return _error_reported; }
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
    67
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
    68
// returns an address which is guaranteed to generate a SIGSEGV on read,
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
    69
// for test purposes, which is not NULL and contains bits in every word
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
    70
void* VMError::get_segfault_address() {
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
    71
  return (void*)
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
    72
#ifdef _LP64
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
    73
    0xABC0000000000ABCULL;
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
    74
#else
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
    75
    0x00000ABC;
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
    76
#endif
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
    77
}
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
    78
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
// List of environment variables that should be reported in error log file.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
const char *env_list[] = {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  // All platforms
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  "JAVA_HOME", "JRE_HOME", "JAVA_TOOL_OPTIONS", "_JAVA_OPTIONS", "CLASSPATH",
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  "JAVA_COMPILER", "PATH", "USERNAME",
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents: 8476
diff changeset
    85
  // Env variables that are defined on Solaris/Linux/BSD
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  "LD_LIBRARY_PATH", "LD_PRELOAD", "SHELL", "DISPLAY",
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  "HOSTTYPE", "OSTYPE", "ARCH", "MACHTYPE",
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
51834
5dd9f3ac52a4 8210961: [aix] enhance list of environment variables reported in error log file on AIX
mbaesken
parents: 51579
diff changeset
    89
  // defined on AIX
5dd9f3ac52a4 8210961: [aix] enhance list of environment variables reported in error log file on AIX
mbaesken
parents: 51579
diff changeset
    90
  "LIBPATH", "LDR_PRELOAD", "LDR_PRELOAD64",
5dd9f3ac52a4 8210961: [aix] enhance list of environment variables reported in error log file on AIX
mbaesken
parents: 51579
diff changeset
    91
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  // defined on Linux
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  "LD_ASSUME_KERNEL", "_JAVA_SR_SIGNUM",
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents: 8476
diff changeset
    95
  // defined on Darwin
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents: 8476
diff changeset
    96
  "DYLD_LIBRARY_PATH", "DYLD_FALLBACK_LIBRARY_PATH",
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents: 8476
diff changeset
    97
  "DYLD_FRAMEWORK_PATH", "DYLD_FALLBACK_FRAMEWORK_PATH",
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents: 8476
diff changeset
    98
  "DYLD_INSERT_LIBRARIES",
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents: 8476
diff changeset
    99
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  // defined on Windows
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  "OS", "PROCESSOR_IDENTIFIER", "_ALT_JAVA_HOME_DIR",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  (const char *)0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
// A simple parser for -XX:OnError, usage:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
//  ptr = OnError;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
//  while ((cmd = next_OnError_command(buffer, sizeof(buffer), &ptr) != NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
//     ... ...
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
static char* next_OnError_command(char* buf, int buflen, const char** ptr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  if (ptr == NULL || *ptr == NULL) return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  const char* cmd = *ptr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  // skip leading blanks or ';'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  while (*cmd == ' ' || *cmd == ';') cmd++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  if (*cmd == '\0') return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  const char * cmdend = cmd;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  while (*cmdend != '\0' && *cmdend != ';') cmdend++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  Arguments::copy_expand_pid(cmd, cmdend - cmd, buf, buflen);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  *ptr = (*cmdend == '\0' ? cmdend : cmdend + 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  return buf;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
static void print_bug_submit_message(outputStream *out, Thread *thread) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  if (out == NULL) return;
58842
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents: 58579
diff changeset
   131
  const char *url = Arguments::java_vendor_url_bug();
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents: 58579
diff changeset
   132
  if (url == NULL || *url == '\0')
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents: 58579
diff changeset
   133
    url = JDK_Version::runtime_vendor_vm_bug_url();
58850
f4290bf1cc21 8233137: runtime/ErrorHandling/VeryEarlyAssertTest.java fails after 8232080
mr
parents: 58842
diff changeset
   134
  if (url != NULL && *url != '\0') {
f4290bf1cc21 8233137: runtime/ErrorHandling/VeryEarlyAssertTest.java fails after 8232080
mr
parents: 58842
diff changeset
   135
    out->print_raw_cr("# If you would like to submit a bug report, please visit:");
f4290bf1cc21 8233137: runtime/ErrorHandling/VeryEarlyAssertTest.java fails after 8232080
mr
parents: 58842
diff changeset
   136
    out->print_raw   ("#   ");
f4290bf1cc21 8233137: runtime/ErrorHandling/VeryEarlyAssertTest.java fails after 8232080
mr
parents: 58842
diff changeset
   137
    out->print_raw_cr(url);
f4290bf1cc21 8233137: runtime/ErrorHandling/VeryEarlyAssertTest.java fails after 8232080
mr
parents: 58842
diff changeset
   138
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  // If the crash is in native code, encourage user to submit a bug to the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  // provider of that code.
229
4fddba548751 6549844: Wording problems in "An unexpected error ..."
coleenp
parents: 1
diff changeset
   141
  if (thread && thread->is_Java_thread() &&
4fddba548751 6549844: Wording problems in "An unexpected error ..."
coleenp
parents: 1
diff changeset
   142
      !thread->is_hidden_from_external_view()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
    JavaThread* jt = (JavaThread*)thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
    if (jt->thread_state() == _thread_in_native) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
      out->print_cr("# The crash happened outside the Java Virtual Machine in native code.\n# See problematic frame for where to report the bug.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  out->print_raw_cr("#");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
8119
81eef1b06988 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents: 8114
diff changeset
   151
bool VMError::coredump_status;
81eef1b06988 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents: 8114
diff changeset
   152
char VMError::coredump_message[O_BUFLEN];
81eef1b06988 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents: 8114
diff changeset
   153
30240
a7ba42fa1df6 8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents: 30125
diff changeset
   154
void VMError::record_coredump_status(const char* message, bool status) {
8119
81eef1b06988 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents: 8114
diff changeset
   155
  coredump_status = status;
81eef1b06988 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents: 8114
diff changeset
   156
  strncpy(coredump_message, message, sizeof(coredump_message));
81eef1b06988 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents: 8114
diff changeset
   157
  coredump_message[sizeof(coredump_message)-1] = 0;
81eef1b06988 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents: 8114
diff changeset
   158
}
81eef1b06988 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents: 8114
diff changeset
   159
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
// Return a string to describe the error
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
char* VMError::error_string(char* buf, int buflen) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  char signame_buf[64];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  const char *signame = os::exception_name(_id, signame_buf, sizeof(signame_buf));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  if (signame) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
    jio_snprintf(buf, buflen,
32583
e95e2cfc9cf5 8133561: linux thread id should be reported in decimal in the error reports now
coleenp
parents: 31963
diff changeset
   167
                 "%s (0x%x) at pc=" PTR_FORMAT ", pid=%d, tid=" UINTX_FORMAT,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
                 signame, _id, _pc,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
                 os::current_process_id(), os::current_thread_id());
5403
6b0dd9c75dde 6888954: argument formatting for assert() and friends
jcoomes
parents: 5340
diff changeset
   170
  } else if (_filename != NULL && _lineno > 0) {
6b0dd9c75dde 6888954: argument formatting for assert() and friends
jcoomes
parents: 5340
diff changeset
   171
    // skip directory names
6b0dd9c75dde 6888954: argument formatting for assert() and friends
jcoomes
parents: 5340
diff changeset
   172
    char separator = os::file_separator()[0];
6b0dd9c75dde 6888954: argument formatting for assert() and friends
jcoomes
parents: 5340
diff changeset
   173
    const char *p = strrchr(_filename, separator);
6b0dd9c75dde 6888954: argument formatting for assert() and friends
jcoomes
parents: 5340
diff changeset
   174
    int n = jio_snprintf(buf, buflen,
32583
e95e2cfc9cf5 8133561: linux thread id should be reported in decimal in the error reports now
coleenp
parents: 31963
diff changeset
   175
                         "Internal Error at %s:%d, pid=%d, tid=" UINTX_FORMAT,
5403
6b0dd9c75dde 6888954: argument formatting for assert() and friends
jcoomes
parents: 5340
diff changeset
   176
                         p ? p + 1 : _filename, _lineno,
6b0dd9c75dde 6888954: argument formatting for assert() and friends
jcoomes
parents: 5340
diff changeset
   177
                         os::current_process_id(), os::current_thread_id());
6b0dd9c75dde 6888954: argument formatting for assert() and friends
jcoomes
parents: 5340
diff changeset
   178
    if (n >= 0 && n < buflen && _message) {
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
   179
      if (strlen(_detail_msg) > 0) {
5403
6b0dd9c75dde 6888954: argument formatting for assert() and friends
jcoomes
parents: 5340
diff changeset
   180
        jio_snprintf(buf + n, buflen - n, "%s%s: %s",
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
   181
        os::line_separator(), _message, _detail_msg);
5403
6b0dd9c75dde 6888954: argument formatting for assert() and friends
jcoomes
parents: 5340
diff changeset
   182
      } else {
6b0dd9c75dde 6888954: argument formatting for assert() and friends
jcoomes
parents: 5340
diff changeset
   183
        jio_snprintf(buf + n, buflen - n, "%sError: %s",
6b0dd9c75dde 6888954: argument formatting for assert() and friends
jcoomes
parents: 5340
diff changeset
   184
                     os::line_separator(), _message);
6b0dd9c75dde 6888954: argument formatting for assert() and friends
jcoomes
parents: 5340
diff changeset
   185
      }
6b0dd9c75dde 6888954: argument formatting for assert() and friends
jcoomes
parents: 5340
diff changeset
   186
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  } else {
5403
6b0dd9c75dde 6888954: argument formatting for assert() and friends
jcoomes
parents: 5340
diff changeset
   188
    jio_snprintf(buf, buflen,
32583
e95e2cfc9cf5 8133561: linux thread id should be reported in decimal in the error reports now
coleenp
parents: 31963
diff changeset
   189
                 "Internal Error (0x%x), pid=%d, tid=" UINTX_FORMAT,
5403
6b0dd9c75dde 6888954: argument formatting for assert() and friends
jcoomes
parents: 5340
diff changeset
   190
                 _id, os::current_process_id(), os::current_thread_id());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  return buf;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
5340
b838d4165c92 6944503: Improved Zero crash dump
twisti
parents: 5237
diff changeset
   196
void VMError::print_stack_trace(outputStream* st, JavaThread* jt,
b838d4165c92 6944503: Improved Zero crash dump
twisti
parents: 5237
diff changeset
   197
                                char* buf, int buflen, bool verbose) {
b838d4165c92 6944503: Improved Zero crash dump
twisti
parents: 5237
diff changeset
   198
#ifdef ZERO
b838d4165c92 6944503: Improved Zero crash dump
twisti
parents: 5237
diff changeset
   199
  if (jt->zero_stack()->sp() && jt->top_zero_frame()) {
b838d4165c92 6944503: Improved Zero crash dump
twisti
parents: 5237
diff changeset
   200
    // StackFrameStream uses the frame anchor, which may not have
b838d4165c92 6944503: Improved Zero crash dump
twisti
parents: 5237
diff changeset
   201
    // been set up.  This can be done at any time in Zero, however,
b838d4165c92 6944503: Improved Zero crash dump
twisti
parents: 5237
diff changeset
   202
    // so if it hasn't been set up then we just set it up now and
b838d4165c92 6944503: Improved Zero crash dump
twisti
parents: 5237
diff changeset
   203
    // clear it again when we're done.
b838d4165c92 6944503: Improved Zero crash dump
twisti
parents: 5237
diff changeset
   204
    bool has_last_Java_frame = jt->has_last_Java_frame();
b838d4165c92 6944503: Improved Zero crash dump
twisti
parents: 5237
diff changeset
   205
    if (!has_last_Java_frame)
b838d4165c92 6944503: Improved Zero crash dump
twisti
parents: 5237
diff changeset
   206
      jt->set_last_Java_frame();
b838d4165c92 6944503: Improved Zero crash dump
twisti
parents: 5237
diff changeset
   207
    st->print("Java frames:");
b838d4165c92 6944503: Improved Zero crash dump
twisti
parents: 5237
diff changeset
   208
    st->cr();
b838d4165c92 6944503: Improved Zero crash dump
twisti
parents: 5237
diff changeset
   209
b838d4165c92 6944503: Improved Zero crash dump
twisti
parents: 5237
diff changeset
   210
    // Print the frames
47687
fb290fd1f9d4 8171853: Remove Shark compiler
rkennke
parents: 47666
diff changeset
   211
    StackFrameStream sfs(jt);
5340
b838d4165c92 6944503: Improved Zero crash dump
twisti
parents: 5237
diff changeset
   212
    for(int i = 0; !sfs.is_done(); sfs.next(), i++) {
b838d4165c92 6944503: Improved Zero crash dump
twisti
parents: 5237
diff changeset
   213
      sfs.current()->zero_print_on_error(i, st, buf, buflen);
b838d4165c92 6944503: Improved Zero crash dump
twisti
parents: 5237
diff changeset
   214
      st->cr();
b838d4165c92 6944503: Improved Zero crash dump
twisti
parents: 5237
diff changeset
   215
    }
b838d4165c92 6944503: Improved Zero crash dump
twisti
parents: 5237
diff changeset
   216
b838d4165c92 6944503: Improved Zero crash dump
twisti
parents: 5237
diff changeset
   217
    // Reset the frame anchor if necessary
b838d4165c92 6944503: Improved Zero crash dump
twisti
parents: 5237
diff changeset
   218
    if (!has_last_Java_frame)
b838d4165c92 6944503: Improved Zero crash dump
twisti
parents: 5237
diff changeset
   219
      jt->reset_last_Java_frame();
b838d4165c92 6944503: Improved Zero crash dump
twisti
parents: 5237
diff changeset
   220
  }
b838d4165c92 6944503: Improved Zero crash dump
twisti
parents: 5237
diff changeset
   221
#else
b838d4165c92 6944503: Improved Zero crash dump
twisti
parents: 5237
diff changeset
   222
  if (jt->has_last_Java_frame()) {
b838d4165c92 6944503: Improved Zero crash dump
twisti
parents: 5237
diff changeset
   223
    st->print_cr("Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)");
b838d4165c92 6944503: Improved Zero crash dump
twisti
parents: 5237
diff changeset
   224
    for(StackFrameStream sfs(jt); !sfs.is_done(); sfs.next()) {
b838d4165c92 6944503: Improved Zero crash dump
twisti
parents: 5237
diff changeset
   225
      sfs.current()->print_on_error(st, buf, buflen, verbose);
b838d4165c92 6944503: Improved Zero crash dump
twisti
parents: 5237
diff changeset
   226
      st->cr();
b838d4165c92 6944503: Improved Zero crash dump
twisti
parents: 5237
diff changeset
   227
    }
b838d4165c92 6944503: Improved Zero crash dump
twisti
parents: 5237
diff changeset
   228
  }
b838d4165c92 6944503: Improved Zero crash dump
twisti
parents: 5237
diff changeset
   229
#endif // ZERO
b838d4165c92 6944503: Improved Zero crash dump
twisti
parents: 5237
diff changeset
   230
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
46560
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46501
diff changeset
   232
void VMError::print_native_stack(outputStream* st, frame fr, Thread* t, char* buf, int buf_size) {
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46501
diff changeset
   233
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46501
diff changeset
   234
  // see if it's a valid frame
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46501
diff changeset
   235
  if (fr.pc()) {
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46501
diff changeset
   236
    st->print_cr("Native frames: (J=compiled Java code, A=aot compiled Java code, j=interpreted, Vv=VM code, C=native code)");
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46501
diff changeset
   237
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46501
diff changeset
   238
    int count = 0;
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46501
diff changeset
   239
    while (count++ < StackPrintLimit) {
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46501
diff changeset
   240
      fr.print_on_error(st, buf, buf_size);
47666
19219ec3f176 8185712: [windows] Improve native symbol decoder
goetz
parents: 47634
diff changeset
   241
      if (fr.pc()) { // print source file and line, if available
19219ec3f176 8185712: [windows] Improve native symbol decoder
goetz
parents: 47634
diff changeset
   242
        char buf[128];
19219ec3f176 8185712: [windows] Improve native symbol decoder
goetz
parents: 47634
diff changeset
   243
        int line_no;
19219ec3f176 8185712: [windows] Improve native symbol decoder
goetz
parents: 47634
diff changeset
   244
        if (Decoder::get_source_info(fr.pc(), buf, sizeof(buf), &line_no)) {
19219ec3f176 8185712: [windows] Improve native symbol decoder
goetz
parents: 47634
diff changeset
   245
          st->print("  (%s:%d)", buf, line_no);
19219ec3f176 8185712: [windows] Improve native symbol decoder
goetz
parents: 47634
diff changeset
   246
        }
19219ec3f176 8185712: [windows] Improve native symbol decoder
goetz
parents: 47634
diff changeset
   247
      }
46560
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46501
diff changeset
   248
      st->cr();
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46501
diff changeset
   249
      // Compiled code may use EBP register on x86 so it looks like
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46501
diff changeset
   250
      // non-walkable C frame. Use frame.sender() for java frames.
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46501
diff changeset
   251
      if (t && t->is_Java_thread()) {
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46501
diff changeset
   252
        // Catch very first native frame by using stack address.
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46501
diff changeset
   253
        // For JavaThread stack_base and stack_size should be set.
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46501
diff changeset
   254
        if (!t->on_local_stack((address)(fr.real_fp() + 1))) {
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46501
diff changeset
   255
          break;
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46501
diff changeset
   256
        }
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46501
diff changeset
   257
        if (fr.is_java_frame() || fr.is_native_frame() || fr.is_runtime_frame()) {
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46501
diff changeset
   258
          RegisterMap map((JavaThread*)t, false); // No update
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46501
diff changeset
   259
          fr = fr.sender(&map);
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46501
diff changeset
   260
        } else {
48617
01b07229a6ad 8194652: VMError::print_native_stack() is missing an os::is_first_C_frame() check
dcubed
parents: 48105
diff changeset
   261
          // is_first_C_frame() does only simple checks for frame pointer,
01b07229a6ad 8194652: VMError::print_native_stack() is missing an os::is_first_C_frame() check
dcubed
parents: 48105
diff changeset
   262
          // it will pass if java compiled code has a pointer in EBP.
01b07229a6ad 8194652: VMError::print_native_stack() is missing an os::is_first_C_frame() check
dcubed
parents: 48105
diff changeset
   263
          if (os::is_first_C_frame(&fr)) break;
46560
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46501
diff changeset
   264
          fr = os::get_sender_for_C_frame(&fr);
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46501
diff changeset
   265
        }
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46501
diff changeset
   266
      } else {
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46501
diff changeset
   267
        if (os::is_first_C_frame(&fr)) break;
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46501
diff changeset
   268
        fr = os::get_sender_for_C_frame(&fr);
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46501
diff changeset
   269
      }
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46501
diff changeset
   270
    }
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46501
diff changeset
   271
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46501
diff changeset
   272
    if (count > StackPrintLimit) {
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46501
diff changeset
   273
      st->print_cr("...<more frames>...");
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46501
diff changeset
   274
    }
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46501
diff changeset
   275
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46501
diff changeset
   276
    st->cr();
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46501
diff changeset
   277
  }
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46501
diff changeset
   278
}
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46501
diff changeset
   279
34139
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
   280
static void print_oom_reasons(outputStream* st) {
31963
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   281
  st->print_cr("# Possible reasons:");
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   282
  st->print_cr("#   The system is out of physical RAM or swap space");
39626
f611156cf276 8064814: Print more helpful error message when getting OOM due to low Java Heap base when running with CompressedOops
poonam
parents: 39401
diff changeset
   283
  if (UseCompressedOops) {
f611156cf276 8064814: Print more helpful error message when getting OOM due to low Java Heap base when running with CompressedOops
poonam
parents: 39401
diff changeset
   284
    st->print_cr("#   The process is running with CompressedOops enabled, and the Java Heap may be blocking the growth of the native heap");
f611156cf276 8064814: Print more helpful error message when getting OOM due to low Java Heap base when running with CompressedOops
poonam
parents: 39401
diff changeset
   285
  }
f611156cf276 8064814: Print more helpful error message when getting OOM due to low Java Heap base when running with CompressedOops
poonam
parents: 39401
diff changeset
   286
  if (LogBytesPerWord == 2) {
f611156cf276 8064814: Print more helpful error message when getting OOM due to low Java Heap base when running with CompressedOops
poonam
parents: 39401
diff changeset
   287
    st->print_cr("#   In 32 bit mode, the process size limit was hit");
f611156cf276 8064814: Print more helpful error message when getting OOM due to low Java Heap base when running with CompressedOops
poonam
parents: 39401
diff changeset
   288
  }
31963
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   289
  st->print_cr("# Possible solutions:");
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   290
  st->print_cr("#   Reduce memory load on the system");
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   291
  st->print_cr("#   Increase physical memory or swap space");
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   292
  st->print_cr("#   Check if swap backing store is full");
39626
f611156cf276 8064814: Print more helpful error message when getting OOM due to low Java Heap base when running with CompressedOops
poonam
parents: 39401
diff changeset
   293
  if (LogBytesPerWord == 2) {
f611156cf276 8064814: Print more helpful error message when getting OOM due to low Java Heap base when running with CompressedOops
poonam
parents: 39401
diff changeset
   294
    st->print_cr("#   Use 64 bit Java on a 64 bit OS");
f611156cf276 8064814: Print more helpful error message when getting OOM due to low Java Heap base when running with CompressedOops
poonam
parents: 39401
diff changeset
   295
  }
31963
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   296
  st->print_cr("#   Decrease Java heap size (-Xmx/-Xms)");
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   297
  st->print_cr("#   Decrease number of Java threads");
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   298
  st->print_cr("#   Decrease Java thread stack sizes (-Xss)");
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   299
  st->print_cr("#   Set larger code cache with -XX:ReservedCodeCacheSize=");
39626
f611156cf276 8064814: Print more helpful error message when getting OOM due to low Java Heap base when running with CompressedOops
poonam
parents: 39401
diff changeset
   300
  if (UseCompressedOops) {
54780
f8d182aedc92 8223136: Move compressed oops functions to CompressedOops class
stefank
parents: 54623
diff changeset
   301
    switch (CompressedOops::mode()) {
f8d182aedc92 8223136: Move compressed oops functions to CompressedOops class
stefank
parents: 54623
diff changeset
   302
      case CompressedOops::UnscaledNarrowOop:
39626
f611156cf276 8064814: Print more helpful error message when getting OOM due to low Java Heap base when running with CompressedOops
poonam
parents: 39401
diff changeset
   303
        st->print_cr("#   JVM is running with Unscaled Compressed Oops mode in which the Java heap is");
f611156cf276 8064814: Print more helpful error message when getting OOM due to low Java Heap base when running with CompressedOops
poonam
parents: 39401
diff changeset
   304
        st->print_cr("#     placed in the first 4GB address space. The Java Heap base address is the");
f611156cf276 8064814: Print more helpful error message when getting OOM due to low Java Heap base when running with CompressedOops
poonam
parents: 39401
diff changeset
   305
        st->print_cr("#     maximum limit for the native heap growth. Please use -XX:HeapBaseMinAddress");
f611156cf276 8064814: Print more helpful error message when getting OOM due to low Java Heap base when running with CompressedOops
poonam
parents: 39401
diff changeset
   306
        st->print_cr("#     to set the Java Heap base and to place the Java Heap above 4GB virtual address.");
f611156cf276 8064814: Print more helpful error message when getting OOM due to low Java Heap base when running with CompressedOops
poonam
parents: 39401
diff changeset
   307
        break;
54780
f8d182aedc92 8223136: Move compressed oops functions to CompressedOops class
stefank
parents: 54623
diff changeset
   308
      case CompressedOops::ZeroBasedNarrowOop:
39626
f611156cf276 8064814: Print more helpful error message when getting OOM due to low Java Heap base when running with CompressedOops
poonam
parents: 39401
diff changeset
   309
        st->print_cr("#   JVM is running with Zero Based Compressed Oops mode in which the Java heap is");
f611156cf276 8064814: Print more helpful error message when getting OOM due to low Java Heap base when running with CompressedOops
poonam
parents: 39401
diff changeset
   310
        st->print_cr("#     placed in the first 32GB address space. The Java Heap base address is the");
f611156cf276 8064814: Print more helpful error message when getting OOM due to low Java Heap base when running with CompressedOops
poonam
parents: 39401
diff changeset
   311
        st->print_cr("#     maximum limit for the native heap growth. Please use -XX:HeapBaseMinAddress");
f611156cf276 8064814: Print more helpful error message when getting OOM due to low Java Heap base when running with CompressedOops
poonam
parents: 39401
diff changeset
   312
        st->print_cr("#     to set the Java Heap base and to place the Java Heap above 32GB virtual address.");
f611156cf276 8064814: Print more helpful error message when getting OOM due to low Java Heap base when running with CompressedOops
poonam
parents: 39401
diff changeset
   313
        break;
46630
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46589
diff changeset
   314
      default:
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46589
diff changeset
   315
        break;
39626
f611156cf276 8064814: Print more helpful error message when getting OOM due to low Java Heap base when running with CompressedOops
poonam
parents: 39401
diff changeset
   316
    }
f611156cf276 8064814: Print more helpful error message when getting OOM due to low Java Heap base when running with CompressedOops
poonam
parents: 39401
diff changeset
   317
  }
31963
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   318
  st->print_cr("# This output file may be truncated or incomplete.");
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   319
}
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   320
34139
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
   321
static void report_vm_version(outputStream* st, char* buf, int buflen) {
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
   322
   // VM version
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
   323
   st->print_cr("#");
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
   324
   JDK_Version::current().to_string(buf, buflen);
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
   325
   const char* runtime_name = JDK_Version::runtime_name() != NULL ?
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
   326
                                JDK_Version::runtime_name() : "";
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
   327
   const char* runtime_version = JDK_Version::runtime_version() != NULL ?
35453
d164ee5260a6 8146653: Debug version missing in hs_err files and on internal version after Verona
amurillo
parents: 35176
diff changeset
   328
                                   JDK_Version::runtime_version() : "";
58842
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents: 58579
diff changeset
   329
   const char* vendor_version = JDK_Version::runtime_vendor_version() != NULL ?
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents: 58579
diff changeset
   330
                                  JDK_Version::runtime_vendor_version() : "";
52148
2d9f8845d0ae 7041262: VM_Version should be called instead of Abstract_VM_Version so that overriding works
hseigel
parents: 52115
diff changeset
   331
   const char* jdk_debug_level = VM_Version::printable_jdk_debug_level() != NULL ?
2d9f8845d0ae 7041262: VM_Version should be called instead of Abstract_VM_Version so that overriding works
hseigel
parents: 52115
diff changeset
   332
                                   VM_Version::printable_jdk_debug_level() : "";
35453
d164ee5260a6 8146653: Debug version missing in hs_err files and on internal version after Verona
amurillo
parents: 35176
diff changeset
   333
58842
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents: 58579
diff changeset
   334
   st->print_cr("# JRE version: %s%s%s (%s) (%sbuild %s)", runtime_name,
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents: 58579
diff changeset
   335
                (*vendor_version != '\0') ? " " : "", vendor_version,
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents: 58579
diff changeset
   336
                buf, jdk_debug_level, runtime_version);
35453
d164ee5260a6 8146653: Debug version missing in hs_err files and on internal version after Verona
amurillo
parents: 35176
diff changeset
   337
34139
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
   338
   // This is the long version with some default settings added
58842
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents: 58579
diff changeset
   339
   st->print_cr("# Java VM: %s%s%s (%s%s, %s%s%s%s%s, %s, %s)",
52148
2d9f8845d0ae 7041262: VM_Version should be called instead of Abstract_VM_Version so that overriding works
hseigel
parents: 52115
diff changeset
   340
                 VM_Version::vm_name(),
58842
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents: 58579
diff changeset
   341
                (*vendor_version != '\0') ? " " : "", vendor_version,
35453
d164ee5260a6 8146653: Debug version missing in hs_err files and on internal version after Verona
amurillo
parents: 35176
diff changeset
   342
                 jdk_debug_level,
52148
2d9f8845d0ae 7041262: VM_Version should be called instead of Abstract_VM_Version so that overriding works
hseigel
parents: 52115
diff changeset
   343
                 VM_Version::vm_release(),
2d9f8845d0ae 7041262: VM_Version should be called instead of Abstract_VM_Version so that overriding works
hseigel
parents: 52115
diff changeset
   344
                 VM_Version::vm_info_string(),
34139
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
   345
                 TieredCompilation ? ", tiered" : "",
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
   346
#if INCLUDE_JVMCI
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
   347
                 EnableJVMCI ? ", jvmci" : "",
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
   348
                 UseJVMCICompiler ? ", jvmci compiler" : "",
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
   349
#else
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
   350
                 "", "",
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
   351
#endif
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
   352
                 UseCompressedOops ? ", compressed oops" : "",
49922
3a64eea72624 8202364: Add GCConfig::hs_err_name() to avoid GC-specific code in error reporting
pliden
parents: 49725
diff changeset
   353
                 GCConfig::hs_err_name(),
52148
2d9f8845d0ae 7041262: VM_Version should be called instead of Abstract_VM_Version so that overriding works
hseigel
parents: 52115
diff changeset
   354
                 VM_Version::vm_platform_string()
34139
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
   355
               );
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
   356
}
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
   357
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
// This is the main function to report a fatal error. Only one thread can
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
// call this function, so we don't need to worry about MT-safety. But it's
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
// possible that the error handler itself may crash or die on an internal
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
// error, for example, when the stack/heap is badly damaged. We must be
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
// able to handle recursive errors that happen inside error handler.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
// Error reporting is done in several steps. If a crash or internal error
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
// occurred when reporting an error, the nested signal/exception handler
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
// can skip steps that are already (or partially) done. Error reporting will
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
// continue from the next step. This allows us to retrieve and print
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
// information that may be unsafe to get after a fatal error. If it happens,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
// you may find nested report_and_die() frames when you look at the stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
// in a debugger.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
// In general, a hang in error handler is much worse than a crash or internal
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
// error, as it's harder to recover from a hang. Deadlock can happen if we
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
// try to grab a lock that is already owned by current thread, or if the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
// owner is blocked forever (e.g. in os::infinite_sleep()). If possible, the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
// error handler and all the functions it called should avoid grabbing any
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
// lock. An important thing to notice is that memory allocation needs a lock.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
// We should avoid using large stack allocated buffers. Many errors happen
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
// when stack space is already low. Making things even worse is that there
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
// could be nested report_and_die() calls on stack (see above). Only one
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
// thread can report error, so large buffers are statically allocated in data
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
// segment.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
   385
int          VMError::_current_step;
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
   386
const char*  VMError::_current_step_info;
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
   387
46284
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
   388
volatile jlong VMError::_reporting_start_time = -1;
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
   389
volatile bool VMError::_reporting_did_timeout = false;
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
   390
volatile jlong VMError::_step_start_time = -1;
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
   391
volatile bool VMError::_step_did_timeout = false;
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
   392
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
   393
// Helper, return current timestamp for timeout handling.
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
   394
jlong VMError::get_current_timestamp() {
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
   395
  return os::javaTimeNanos();
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
   396
}
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
   397
// Factor to translate the timestamp to seconds.
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
   398
#define TIMESTAMP_TO_SECONDS_FACTOR (1000 * 1000 * 1000)
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
   399
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
   400
void VMError::record_reporting_start_time() {
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
   401
  const jlong now = get_current_timestamp();
59248
e92153ed8bdc 8234736: Harmonize parameter order in Atomic - store
stefank
parents: 58850
diff changeset
   402
  Atomic::store(&_reporting_start_time, now);
46284
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
   403
}
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
   404
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
   405
jlong VMError::get_reporting_start_time() {
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
   406
  return Atomic::load(&_reporting_start_time);
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
   407
}
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
   408
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
   409
void VMError::record_step_start_time() {
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
   410
  const jlong now = get_current_timestamp();
59248
e92153ed8bdc 8234736: Harmonize parameter order in Atomic - store
stefank
parents: 58850
diff changeset
   411
  Atomic::store(&_step_start_time, now);
46284
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
   412
}
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
   413
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
   414
jlong VMError::get_step_start_time() {
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
   415
  return Atomic::load(&_step_start_time);
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
   416
}
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
   417
55239
74832e7b5cad 8188872: runtime/ErrorHandling/TimeoutInErrorHandlingTest.java fails intermittently
dcubed
parents: 54897
diff changeset
   418
void VMError::clear_step_start_time() {
59248
e92153ed8bdc 8234736: Harmonize parameter order in Atomic - store
stefank
parents: 58850
diff changeset
   419
  return Atomic::store(&_step_start_time, (jlong)0);
55239
74832e7b5cad 8188872: runtime/ErrorHandling/TimeoutInErrorHandlingTest.java fails intermittently
dcubed
parents: 54897
diff changeset
   420
}
74832e7b5cad 8188872: runtime/ErrorHandling/TimeoutInErrorHandlingTest.java fails intermittently
dcubed
parents: 54897
diff changeset
   421
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
   422
void VMError::report(outputStream* st, bool _verbose) {
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
   423
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
   424
# define BEGIN if (_current_step == 0) { _current_step = __LINE__;
46284
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
   425
# define STEP(s) } if (_current_step < __LINE__) { _current_step = __LINE__; _current_step_info = s; \
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
   426
  record_step_start_time(); _step_did_timeout = false;
55239
74832e7b5cad 8188872: runtime/ErrorHandling/TimeoutInErrorHandlingTest.java fails intermittently
dcubed
parents: 54897
diff changeset
   427
# define END clear_step_start_time(); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
  // don't allocate large buffer on stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
  static char buf[O_BUFLEN];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
  BEGIN
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
   434
  STEP("printing fatal error message")
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
7719
ef138e2849eb 6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents: 7447
diff changeset
   436
    st->print_cr("#");
ef138e2849eb 6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents: 7447
diff changeset
   437
    if (should_report_bug(_id)) {
ef138e2849eb 6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents: 7447
diff changeset
   438
      st->print_cr("# A fatal error has been detected by the Java Runtime Environment:");
ef138e2849eb 6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents: 7447
diff changeset
   439
    } else {
ef138e2849eb 6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents: 7447
diff changeset
   440
      st->print_cr("# There is insufficient memory for the Java "
ef138e2849eb 6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents: 7447
diff changeset
   441
                   "Runtime Environment to continue.");
ef138e2849eb 6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents: 7447
diff changeset
   442
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
28943
679546f0cc1f 8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents: 28513
diff changeset
   444
#ifndef PRODUCT
679546f0cc1f 8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents: 28513
diff changeset
   445
  // Error handler self tests
679546f0cc1f 8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents: 28513
diff changeset
   446
679546f0cc1f 8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents: 28513
diff changeset
   447
  // test secondary error handling. Test it twice, to test that resetting
679546f0cc1f 8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents: 28513
diff changeset
   448
  // error handler after a secondary crash works.
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
   449
  STEP("test secondary crash 1")
29573
2d800e5d575f 8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents: 28943
diff changeset
   450
    if (_verbose && TestCrashInErrorHandler != 0) {
33148
68fa8b6c4340 8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 33131
diff changeset
   451
      st->print_cr("Will crash now (TestCrashInErrorHandler=" UINTX_FORMAT ")...",
29573
2d800e5d575f 8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents: 28943
diff changeset
   452
        TestCrashInErrorHandler);
2d800e5d575f 8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents: 28943
diff changeset
   453
      controlled_crash(TestCrashInErrorHandler);
2d800e5d575f 8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents: 28943
diff changeset
   454
    }
2d800e5d575f 8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents: 28943
diff changeset
   455
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
   456
  STEP("test secondary crash 2")
28943
679546f0cc1f 8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents: 28513
diff changeset
   457
    if (_verbose && TestCrashInErrorHandler != 0) {
33148
68fa8b6c4340 8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 33131
diff changeset
   458
      st->print_cr("Will crash now (TestCrashInErrorHandler=" UINTX_FORMAT ")...",
28943
679546f0cc1f 8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents: 28513
diff changeset
   459
        TestCrashInErrorHandler);
679546f0cc1f 8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents: 28513
diff changeset
   460
      controlled_crash(TestCrashInErrorHandler);
679546f0cc1f 8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents: 28513
diff changeset
   461
    }
679546f0cc1f 8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents: 28513
diff changeset
   462
46284
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
   463
  // TestUnresponsiveErrorHandler: We want to test both step timeouts and global timeout.
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
   464
  // Step to global timeout ratio is 4:1, so in order to be absolutely sure we hit the
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
   465
  // global timeout, let's execute the timeout step five times.
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
   466
  // See corresponding test in test/runtime/ErrorHandling/TimeoutInErrorHandlingTest.java
55239
74832e7b5cad 8188872: runtime/ErrorHandling/TimeoutInErrorHandlingTest.java fails intermittently
dcubed
parents: 54897
diff changeset
   467
  STEP("setup for test unresponsive error reporting step")
74832e7b5cad 8188872: runtime/ErrorHandling/TimeoutInErrorHandlingTest.java fails intermittently
dcubed
parents: 54897
diff changeset
   468
    if (_verbose && TestUnresponsiveErrorHandler) {
74832e7b5cad 8188872: runtime/ErrorHandling/TimeoutInErrorHandlingTest.java fails intermittently
dcubed
parents: 54897
diff changeset
   469
      // We record reporting_start_time for this test here because we
74832e7b5cad 8188872: runtime/ErrorHandling/TimeoutInErrorHandlingTest.java fails intermittently
dcubed
parents: 54897
diff changeset
   470
      // care about the time spent executing TIMEOUT_TEST_STEP and not
74832e7b5cad 8188872: runtime/ErrorHandling/TimeoutInErrorHandlingTest.java fails intermittently
dcubed
parents: 54897
diff changeset
   471
      // about the time it took us to get here.
74832e7b5cad 8188872: runtime/ErrorHandling/TimeoutInErrorHandlingTest.java fails intermittently
dcubed
parents: 54897
diff changeset
   472
      tty->print_cr("Recording reporting_start_time for TestUnresponsiveErrorHandler.");
74832e7b5cad 8188872: runtime/ErrorHandling/TimeoutInErrorHandlingTest.java fails intermittently
dcubed
parents: 54897
diff changeset
   473
      record_reporting_start_time();
74832e7b5cad 8188872: runtime/ErrorHandling/TimeoutInErrorHandlingTest.java fails intermittently
dcubed
parents: 54897
diff changeset
   474
    }
74832e7b5cad 8188872: runtime/ErrorHandling/TimeoutInErrorHandlingTest.java fails intermittently
dcubed
parents: 54897
diff changeset
   475
46284
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
   476
  #define TIMEOUT_TEST_STEP STEP("test unresponsive error reporting step") \
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
   477
    if (_verbose && TestUnresponsiveErrorHandler) { os::infinite_sleep(); }
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
   478
  TIMEOUT_TEST_STEP
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
   479
  TIMEOUT_TEST_STEP
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
   480
  TIMEOUT_TEST_STEP
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
   481
  TIMEOUT_TEST_STEP
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
   482
  TIMEOUT_TEST_STEP
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
   483
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
   484
  STEP("test safefetch in error handler")
29573
2d800e5d575f 8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents: 28943
diff changeset
   485
    // test whether it is safe to use SafeFetch32 in Crash Handler. Test twice
2d800e5d575f 8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents: 28943
diff changeset
   486
    // to test that resetting the signal handler works correctly.
2d800e5d575f 8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents: 28943
diff changeset
   487
    if (_verbose && TestSafeFetchInErrorHandler) {
2d800e5d575f 8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents: 28943
diff changeset
   488
      st->print_cr("Will test SafeFetch...");
2d800e5d575f 8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents: 28943
diff changeset
   489
      if (CanUseSafeFetch32()) {
2d800e5d575f 8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents: 28943
diff changeset
   490
        int* const invalid_pointer = (int*) get_segfault_address();
2d800e5d575f 8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents: 28943
diff changeset
   491
        const int x = 0x76543210;
2d800e5d575f 8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents: 28943
diff changeset
   492
        int i1 = SafeFetch32(invalid_pointer, x);
2d800e5d575f 8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents: 28943
diff changeset
   493
        int i2 = SafeFetch32(invalid_pointer, x);
2d800e5d575f 8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents: 28943
diff changeset
   494
        if (i1 == x && i2 == x) {
2d800e5d575f 8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents: 28943
diff changeset
   495
          st->print_cr("SafeFetch OK."); // Correctly deflected and returned default pattern
2d800e5d575f 8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents: 28943
diff changeset
   496
        } else {
2d800e5d575f 8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents: 28943
diff changeset
   497
          st->print_cr("??");
2d800e5d575f 8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents: 28943
diff changeset
   498
        }
2d800e5d575f 8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents: 28943
diff changeset
   499
      } else {
2d800e5d575f 8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents: 28943
diff changeset
   500
        st->print_cr("not possible; skipped.");
2d800e5d575f 8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents: 28943
diff changeset
   501
      }
28943
679546f0cc1f 8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents: 28513
diff changeset
   502
    }
679546f0cc1f 8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents: 28513
diff changeset
   503
#endif // PRODUCT
679546f0cc1f 8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents: 28513
diff changeset
   504
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
   505
  STEP("printing type of error")
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
48824
e48c4461a8bb 8181503: Can't compile hotspot with c++11
gziemski
parents: 48617
diff changeset
   507
     switch(static_cast<unsigned int>(_id)) {
17087
f0b76c4c93a0 8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents: 16685
diff changeset
   508
       case OOM_MALLOC_ERROR:
f0b76c4c93a0 8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents: 16685
diff changeset
   509
       case OOM_MMAP_ERROR:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
         if (_size) {
17087
f0b76c4c93a0 8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents: 16685
diff changeset
   511
           st->print("# Native memory allocation ");
f0b76c4c93a0 8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents: 16685
diff changeset
   512
           st->print((_id == (int)OOM_MALLOC_ERROR) ? "(malloc) failed to allocate " :
f0b76c4c93a0 8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents: 16685
diff changeset
   513
                                                 "(mmap) failed to map ");
7719
ef138e2849eb 6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents: 7447
diff changeset
   514
           jio_snprintf(buf, sizeof(buf), SIZE_FORMAT, _size);
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 24351
diff changeset
   515
           st->print("%s", buf);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
           st->print(" bytes");
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
   517
           if (strlen(_detail_msg) > 0) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
             st->print(" for ");
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
   519
             st->print("%s", _detail_msg);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
           }
7719
ef138e2849eb 6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents: 7447
diff changeset
   521
           st->cr();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
         } else {
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
   523
           if (strlen(_detail_msg) > 0) {
7719
ef138e2849eb 6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents: 7447
diff changeset
   524
             st->print("# ");
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
   525
             st->print_cr("%s", _detail_msg);
31615
e48d94b97b6c 8130036: Fix problems with imprecise C++ coding.
goetz
parents: 31356
diff changeset
   526
           }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
         }
7719
ef138e2849eb 6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents: 7447
diff changeset
   528
         // In error file give some solutions
ef138e2849eb 6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents: 7447
diff changeset
   529
         if (_verbose) {
31963
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   530
           print_oom_reasons(st);
7719
ef138e2849eb 6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents: 7447
diff changeset
   531
         } else {
ef138e2849eb 6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents: 7447
diff changeset
   532
           return;  // that's enough for the screen
ef138e2849eb 6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents: 7447
diff changeset
   533
         }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
         break;
17087
f0b76c4c93a0 8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents: 16685
diff changeset
   535
       case INTERNAL_ERROR:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
       default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
         break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
   540
  STEP("printing exception/signal name")
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
     st->print_cr("#");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
     st->print("#  ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
     // Is it an OS exception/signal?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
     if (os::exception_name(_id, buf, sizeof(buf))) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
       st->print("%s", buf);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
       st->print(" (0x%x)", _id);                // signal number
33148
68fa8b6c4340 8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 33131
diff changeset
   548
       st->print(" at pc=" PTR_FORMAT, p2i(_pc));
54031
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents: 53599
diff changeset
   549
       if (_siginfo != NULL && os::signal_sent_by_kill(_siginfo)) {
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents: 53599
diff changeset
   550
         st->print(" (sent by kill)");
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents: 53599
diff changeset
   551
       }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
     } else {
7719
ef138e2849eb 6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents: 7447
diff changeset
   553
       if (should_report_bug(_id)) {
ef138e2849eb 6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents: 7447
diff changeset
   554
         st->print("Internal Error");
ef138e2849eb 6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents: 7447
diff changeset
   555
       } else {
ef138e2849eb 6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents: 7447
diff changeset
   556
         st->print("Out of Memory Error");
ef138e2849eb 6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents: 7447
diff changeset
   557
       }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
       if (_filename != NULL && _lineno > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   559
#ifdef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
         // In product mode chop off pathname?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
         char separator = os::file_separator()[0];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
         const char *p = strrchr(_filename, separator);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
         const char *file = p ? p+1 : _filename;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
         const char *file = _filename;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
#endif
30281
b1608535e50f 8076475: Misuses of strncpy/strncat
stuefe
parents: 30241
diff changeset
   567
         st->print(" (%s:%d)", file, _lineno);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
       } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
         st->print(" (0x%x)", _id);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
       }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
   573
  STEP("printing current thread and pid")
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
     // process id, thread id
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
     st->print(", pid=%d", os::current_process_id());
32583
e95e2cfc9cf5 8133561: linux thread id should be reported in decimal in the error reports now
coleenp
parents: 31963
diff changeset
   577
     st->print(", tid=" UINTX_FORMAT, os::current_thread_id());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
     st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   579
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
   580
  STEP("printing error message")
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
7719
ef138e2849eb 6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents: 7447
diff changeset
   582
     if (should_report_bug(_id)) {  // already printed the message.
ef138e2849eb 6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents: 7447
diff changeset
   583
       // error message
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
   584
       if (strlen(_detail_msg) > 0) {
7719
ef138e2849eb 6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents: 7447
diff changeset
   585
         st->print_cr("#  %s: %s", _message ? _message : "Error", _detail_msg);
ef138e2849eb 6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents: 7447
diff changeset
   586
       } else if (_message) {
ef138e2849eb 6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents: 7447
diff changeset
   587
         st->print_cr("#  Error: %s", _message);
ef138e2849eb 6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents: 7447
diff changeset
   588
       }
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
   589
     }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
   591
  STEP("printing Java version string")
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   592
34139
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
   593
     report_vm_version(st, buf, sizeof(buf));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
   595
  STEP("printing problematic frame")
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   596
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
     // Print current frame if we have a context (i.e. it's a crash)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
     if (_context) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
       st->print_cr("# Problematic frame:");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   600
       st->print("# ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   601
       frame fr = os::fetch_frame_from_context(_context);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
       fr.print_on_error(st, buf, sizeof(buf));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
       st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   604
       st->print_cr("#");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
     }
31963
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   606
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
   607
  STEP("printing core file information")
8119
81eef1b06988 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents: 8114
diff changeset
   608
    st->print("# ");
30240
a7ba42fa1df6 8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents: 30125
diff changeset
   609
    if (CreateCoredumpOnCrash) {
a7ba42fa1df6 8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents: 30125
diff changeset
   610
      if (coredump_status) {
30622
648d51c142bd 8078121: Add 'CreateMinidumpOnCrash' (JDK-8074354) caused many tests failed in nightly testing
ctornqvi
parents: 30281
diff changeset
   611
        st->print("Core dump will be written. Default location: %s", coredump_message);
30240
a7ba42fa1df6 8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents: 30125
diff changeset
   612
      } else {
a7ba42fa1df6 8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents: 30125
diff changeset
   613
        st->print("No core dump will be written. %s", coredump_message);
a7ba42fa1df6 8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents: 30125
diff changeset
   614
      }
8119
81eef1b06988 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents: 8114
diff changeset
   615
    } else {
30240
a7ba42fa1df6 8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents: 30125
diff changeset
   616
      st->print("CreateCoredumpOnCrash turned off, no core file dumped");
8119
81eef1b06988 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents: 8114
diff changeset
   617
    }
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 24351
diff changeset
   618
    st->cr();
8119
81eef1b06988 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents: 8114
diff changeset
   619
    st->print_cr("#");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
   621
  STEP("printing bug submit message")
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
7719
ef138e2849eb 6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents: 7447
diff changeset
   623
     if (should_report_bug(_id) && _verbose) {
ef138e2849eb 6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents: 7447
diff changeset
   624
       print_bug_submit_message(st, _thread);
ef138e2849eb 6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents: 7447
diff changeset
   625
     }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   626
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
   627
  STEP("printing summary")
31963
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   628
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   629
     if (_verbose) {
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   630
       st->cr();
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   631
       st->print_cr("---------------  S U M M A R Y ------------");
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   632
       st->cr();
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   633
     }
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   634
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
   635
  STEP("printing VM option summary")
31963
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   636
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   637
     if (_verbose) {
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   638
       // VM options
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   639
       Arguments::print_summary_on(st);
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   640
       st->cr();
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   641
     }
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   642
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
   643
  STEP("printing summary machine and OS info")
31963
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   644
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   645
     if (_verbose) {
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   646
       os::print_summary_info(st, buf, sizeof(buf));
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   647
     }
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   648
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   649
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
   650
  STEP("printing date and time")
31963
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   651
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   652
     if (_verbose) {
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   653
       os::print_date_and_time(st, buf, sizeof(buf));
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   654
     }
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   655
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
   656
  STEP("printing thread")
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   657
489c9b5090e2 Initial load
duke
parents:
diff changeset
   658
     if (_verbose) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   659
       st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   660
       st->print_cr("---------------  T H R E A D  ---------------");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   661
       st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   662
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   663
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
   664
  STEP("printing current thread")
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   665
489c9b5090e2 Initial load
duke
parents:
diff changeset
   666
     // current thread
489c9b5090e2 Initial load
duke
parents:
diff changeset
   667
     if (_verbose) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   668
       if (_thread) {
33148
68fa8b6c4340 8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 33131
diff changeset
   669
         st->print("Current thread (" PTR_FORMAT "):  ", p2i(_thread));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   670
         _thread->print_on_error(st, buf, sizeof(buf));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   671
         st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   672
       } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   673
         st->print_cr("Current thread is native thread");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   674
       }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   675
       st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   676
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   677
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
   678
  STEP("printing current compile task")
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   679
31963
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   680
     if (_verbose && _thread && _thread->is_Compiler_thread()) {
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   681
        CompilerThread* t = (CompilerThread*)_thread;
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   682
        if (t->task()) {
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   683
           st->cr();
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   684
           st->print_cr("Current CompileTask:");
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   685
           t->task()->print_line_on_error(st, buf, sizeof(buf));
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   686
           st->cr();
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   687
        }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   688
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   689
489c9b5090e2 Initial load
duke
parents:
diff changeset
   690
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
   691
  STEP("printing stack bounds")
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   692
489c9b5090e2 Initial load
duke
parents:
diff changeset
   693
     if (_verbose) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   694
       st->print("Stack: ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   695
489c9b5090e2 Initial load
duke
parents:
diff changeset
   696
       address stack_top;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   697
       size_t stack_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   698
489c9b5090e2 Initial load
duke
parents:
diff changeset
   699
       if (_thread) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   700
          stack_top = _thread->stack_base();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   701
          stack_size = _thread->stack_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   702
       } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   703
          stack_top = os::current_stack_base();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   704
          stack_size = os::current_stack_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   705
       }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   706
489c9b5090e2 Initial load
duke
parents:
diff changeset
   707
       address stack_bottom = stack_top - stack_size;
33148
68fa8b6c4340 8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 33131
diff changeset
   708
       st->print("[" PTR_FORMAT "," PTR_FORMAT "]", p2i(stack_bottom), p2i(stack_top));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   709
489c9b5090e2 Initial load
duke
parents:
diff changeset
   710
       frame fr = _context ? os::fetch_frame_from_context(_context)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   711
                           : os::current_frame();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   712
489c9b5090e2 Initial load
duke
parents:
diff changeset
   713
       if (fr.sp()) {
33148
68fa8b6c4340 8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 33131
diff changeset
   714
         st->print(",  sp=" PTR_FORMAT, p2i(fr.sp()));
6179
4846648c4b7b 6973308: Missing zero length check before repne scas in check_klass_subtype_slow_path()
kvn
parents: 5547
diff changeset
   715
         size_t free_stack_size = pointer_delta(fr.sp(), stack_bottom, 1024);
4846648c4b7b 6973308: Missing zero length check before repne scas in check_klass_subtype_slow_path()
kvn
parents: 5547
diff changeset
   716
         st->print(",  free space=" SIZE_FORMAT "k", free_stack_size);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   717
       }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   718
489c9b5090e2 Initial load
duke
parents:
diff changeset
   719
       st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   720
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   721
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
   722
  STEP("printing native stack")
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   723
26821
ce9f82507dc2 8058345: Refactor native stack printing from vmError.cpp to debug.cpp to make it available in gdb as well
simonis
parents: 25946
diff changeset
   724
   if (_verbose) {
19952
bc974e92f881 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 19334
diff changeset
   725
     if (os::platform_print_native_stack(st, _context, buf, sizeof(buf))) {
bc974e92f881 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 19334
diff changeset
   726
       // We have printed the native stack in platform-specific code
bc974e92f881 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 19334
diff changeset
   727
       // Windows/x64 needs special handling.
bc974e92f881 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 19334
diff changeset
   728
     } else {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   729
       frame fr = _context ? os::fetch_frame_from_context(_context)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   730
                           : os::current_frame();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   731
26821
ce9f82507dc2 8058345: Refactor native stack printing from vmError.cpp to debug.cpp to make it available in gdb as well
simonis
parents: 25946
diff changeset
   732
       print_native_stack(st, fr, _thread, buf, sizeof(buf));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   733
     }
19952
bc974e92f881 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 19334
diff changeset
   734
   }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   735
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
   736
  STEP("printing Java stack")
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   737
489c9b5090e2 Initial load
duke
parents:
diff changeset
   738
     if (_verbose && _thread && _thread->is_Java_thread()) {
5340
b838d4165c92 6944503: Improved Zero crash dump
twisti
parents: 5237
diff changeset
   739
       print_stack_trace(st, (JavaThread*)_thread, buf, sizeof(buf));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   740
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   741
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
   742
  STEP("printing target Java thread stack")
4489
514173c9a0c2 6361589: Print out stack trace for target thread of GC crash
minqi
parents: 4013
diff changeset
   743
514173c9a0c2 6361589: Print out stack trace for target thread of GC crash
minqi
parents: 4013
diff changeset
   744
     // printing Java thread stack trace if it is involved in GC crash
7108
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 6184
diff changeset
   745
     if (_verbose && _thread && (_thread->is_Named_thread())) {
4489
514173c9a0c2 6361589: Print out stack trace for target thread of GC crash
minqi
parents: 4013
diff changeset
   746
       JavaThread*  jt = ((NamedThread *)_thread)->processed_thread();
514173c9a0c2 6361589: Print out stack trace for target thread of GC crash
minqi
parents: 4013
diff changeset
   747
       if (jt != NULL) {
33148
68fa8b6c4340 8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 33131
diff changeset
   748
         st->print_cr("JavaThread " PTR_FORMAT " (nid = %d) was being processed", p2i(jt), jt->osthread()->thread_id());
5340
b838d4165c92 6944503: Improved Zero crash dump
twisti
parents: 5237
diff changeset
   749
         print_stack_trace(st, jt, buf, sizeof(buf), true);
4489
514173c9a0c2 6361589: Print out stack trace for target thread of GC crash
minqi
parents: 4013
diff changeset
   750
       }
514173c9a0c2 6361589: Print out stack trace for target thread of GC crash
minqi
parents: 4013
diff changeset
   751
     }
514173c9a0c2 6361589: Print out stack trace for target thread of GC crash
minqi
parents: 4013
diff changeset
   752
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
   753
  STEP("printing siginfo")
31963
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   754
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   755
     // signal no, signal code, address that caused the fault
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   756
     if (_verbose && _siginfo) {
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   757
       st->cr();
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   758
       os::print_siginfo(st, _siginfo);
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   759
       st->cr();
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   760
     }
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   761
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
   762
  STEP("CDS archive access warning")
35176
11a9d4022d9e 8144219: [posix] Remove redundant code around os::print_siginfo()
stuefe
parents: 34305
diff changeset
   763
11a9d4022d9e 8144219: [posix] Remove redundant code around os::print_siginfo()
stuefe
parents: 34305
diff changeset
   764
     // Print an explicit hint if we crashed on access to the CDS archive.
11a9d4022d9e 8144219: [posix] Remove redundant code around os::print_siginfo()
stuefe
parents: 34305
diff changeset
   765
     if (_verbose && _siginfo) {
11a9d4022d9e 8144219: [posix] Remove redundant code around os::print_siginfo()
stuefe
parents: 34305
diff changeset
   766
       check_failing_cds_access(st, _siginfo);
11a9d4022d9e 8144219: [posix] Remove redundant code around os::print_siginfo()
stuefe
parents: 34305
diff changeset
   767
       st->cr();
11a9d4022d9e 8144219: [posix] Remove redundant code around os::print_siginfo()
stuefe
parents: 34305
diff changeset
   768
     }
11a9d4022d9e 8144219: [posix] Remove redundant code around os::print_siginfo()
stuefe
parents: 34305
diff changeset
   769
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
   770
  STEP("printing register info")
31963
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   771
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   772
     // decode register contents if possible
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   773
     if (_verbose && _context && Universe::is_fully_initialized()) {
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   774
       os::print_register_info(st, _context);
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   775
       st->cr();
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   776
     }
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   777
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
   778
  STEP("printing registers, top of stack, instructions near pc")
31963
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   779
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   780
     // registers, top of stack, instructions near pc
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   781
     if (_verbose && _context) {
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   782
       os::print_context(st, _context);
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   783
       st->cr();
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   784
     }
641ed52732ec 8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents: 31615
diff changeset
   785
52115
9e6158f12068 8211852: inspect stack during error reporting
mdoerr
parents: 52109
diff changeset
   786
  STEP("inspecting top of stack")
9e6158f12068 8211852: inspect stack during error reporting
mdoerr
parents: 52109
diff changeset
   787
9e6158f12068 8211852: inspect stack during error reporting
mdoerr
parents: 52109
diff changeset
   788
     // decode stack contents if possible
9e6158f12068 8211852: inspect stack during error reporting
mdoerr
parents: 52109
diff changeset
   789
     if (_verbose && _context && Universe::is_fully_initialized()) {
9e6158f12068 8211852: inspect stack during error reporting
mdoerr
parents: 52109
diff changeset
   790
       frame fr = os::fetch_frame_from_context(_context);
9e6158f12068 8211852: inspect stack during error reporting
mdoerr
parents: 52109
diff changeset
   791
       const int slots = 8;
9e6158f12068 8211852: inspect stack during error reporting
mdoerr
parents: 52109
diff changeset
   792
       const intptr_t *start = fr.sp();
9e6158f12068 8211852: inspect stack during error reporting
mdoerr
parents: 52109
diff changeset
   793
       const intptr_t *end = start + slots;
9e6158f12068 8211852: inspect stack during error reporting
mdoerr
parents: 52109
diff changeset
   794
       if (is_aligned(start, sizeof(intptr_t)) && os::is_readable_range(start, end)) {
9e6158f12068 8211852: inspect stack during error reporting
mdoerr
parents: 52109
diff changeset
   795
         st->print_cr("Stack slot to memory mapping:");
9e6158f12068 8211852: inspect stack during error reporting
mdoerr
parents: 52109
diff changeset
   796
         for (int i = 0; i < slots; ++i) {
9e6158f12068 8211852: inspect stack during error reporting
mdoerr
parents: 52109
diff changeset
   797
           st->print("stack at sp + %d slots: ", i);
9e6158f12068 8211852: inspect stack during error reporting
mdoerr
parents: 52109
diff changeset
   798
           os::print_location(st, *(start + i));
9e6158f12068 8211852: inspect stack during error reporting
mdoerr
parents: 52109
diff changeset
   799
         }
9e6158f12068 8211852: inspect stack during error reporting
mdoerr
parents: 52109
diff changeset
   800
       }
9e6158f12068 8211852: inspect stack during error reporting
mdoerr
parents: 52109
diff changeset
   801
       st->cr();
9e6158f12068 8211852: inspect stack during error reporting
mdoerr
parents: 52109
diff changeset
   802
     }
9e6158f12068 8211852: inspect stack during error reporting
mdoerr
parents: 52109
diff changeset
   803
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
   804
  STEP("printing code blob if possible")
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32583
diff changeset
   805
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32583
diff changeset
   806
     if (_verbose && _context) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32583
diff changeset
   807
       CodeBlob* cb = CodeCache::find_blob(_pc);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32583
diff changeset
   808
       if (cb != NULL) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32583
diff changeset
   809
         if (Interpreter::contains(_pc)) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32583
diff changeset
   810
           // The interpreter CodeBlob is very large so try to print the codelet instead.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32583
diff changeset
   811
           InterpreterCodelet* codelet = Interpreter::codelet_containing(_pc);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32583
diff changeset
   812
           if (codelet != NULL) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32583
diff changeset
   813
             codelet->print_on(st);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32583
diff changeset
   814
             Disassembler::decode(codelet->code_begin(), codelet->code_end(), st);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32583
diff changeset
   815
           }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32583
diff changeset
   816
         } else {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32583
diff changeset
   817
           StubCodeDesc* desc = StubCodeDesc::desc_for(_pc);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32583
diff changeset
   818
           if (desc != NULL) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32583
diff changeset
   819
             desc->print_on(st);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32583
diff changeset
   820
             Disassembler::decode(desc->begin(), desc->end(), st);
49334
aefee96e2b90 8198845: Missing resource mark results disassembling generated code failure in hs error report
zgu
parents: 49176
diff changeset
   821
           } else if (_thread != NULL) {
aefee96e2b90 8198845: Missing resource mark results disassembling generated code failure in hs error report
zgu
parents: 49176
diff changeset
   822
             // Disassembling nmethod will incur resource memory allocation,
aefee96e2b90 8198845: Missing resource mark results disassembling generated code failure in hs error report
zgu
parents: 49176
diff changeset
   823
             // only do so when thread is valid.
aefee96e2b90 8198845: Missing resource mark results disassembling generated code failure in hs error report
zgu
parents: 49176
diff changeset
   824
             ResourceMark rm(_thread);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32583
diff changeset
   825
             Disassembler::decode(cb, st);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32583
diff changeset
   826
             st->cr();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32583
diff changeset
   827
           }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32583
diff changeset
   828
         }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32583
diff changeset
   829
       }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32583
diff changeset
   830
     }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32583
diff changeset
   831
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
   832
  STEP("printing VM operation")
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   833
489c9b5090e2 Initial load
duke
parents:
diff changeset
   834
     if (_verbose && _thread && _thread->is_VM_thread()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   835
        VMThread* t = (VMThread*)_thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   836
        VM_Operation* op = t->vm_operation();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   837
        if (op) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   838
          op->print_on_error(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   839
          st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   840
          st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   841
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   842
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   843
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
   844
  STEP("printing process")
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   845
489c9b5090e2 Initial load
duke
parents:
diff changeset
   846
     if (_verbose) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   847
       st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   848
       st->print_cr("---------------  P R O C E S S  ---------------");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   849
       st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   850
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   851
52585
f7f90fddce02 8211326: add OS user related information to hs_err file
mbaesken
parents: 52356
diff changeset
   852
#ifndef _WIN32
f7f90fddce02 8211326: add OS user related information to hs_err file
mbaesken
parents: 52356
diff changeset
   853
  STEP("printing user info")
f7f90fddce02 8211326: add OS user related information to hs_err file
mbaesken
parents: 52356
diff changeset
   854
f7f90fddce02 8211326: add OS user related information to hs_err file
mbaesken
parents: 52356
diff changeset
   855
     if (ExtensiveErrorReports && _verbose) {
f7f90fddce02 8211326: add OS user related information to hs_err file
mbaesken
parents: 52356
diff changeset
   856
       os::Posix::print_user_info(st);
f7f90fddce02 8211326: add OS user related information to hs_err file
mbaesken
parents: 52356
diff changeset
   857
     }
f7f90fddce02 8211326: add OS user related information to hs_err file
mbaesken
parents: 52356
diff changeset
   858
#endif
f7f90fddce02 8211326: add OS user related information to hs_err file
mbaesken
parents: 52356
diff changeset
   859
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
   860
  STEP("printing all threads")
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   861
489c9b5090e2 Initial load
duke
parents:
diff changeset
   862
     // all threads
489c9b5090e2 Initial load
duke
parents:
diff changeset
   863
     if (_verbose && _thread) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   864
       Threads::print_on_error(st, _thread, buf, sizeof(buf));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   865
       st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   866
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   867
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
   868
  STEP("printing VM state")
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   869
489c9b5090e2 Initial load
duke
parents:
diff changeset
   870
     if (_verbose) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   871
       // Safepoint state
489c9b5090e2 Initial load
duke
parents:
diff changeset
   872
       st->print("VM state:");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   873
489c9b5090e2 Initial load
duke
parents:
diff changeset
   874
       if (SafepointSynchronize::is_synchronizing()) st->print("synchronizing");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   875
       else if (SafepointSynchronize::is_at_safepoint()) st->print("at safepoint");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   876
       else st->print("not at safepoint");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   877
489c9b5090e2 Initial load
duke
parents:
diff changeset
   878
       // Also see if error occurred during initialization or shutdown
489c9b5090e2 Initial load
duke
parents:
diff changeset
   879
       if (!Universe::is_fully_initialized()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   880
         st->print(" (not fully initialized)");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   881
       } else if (VM_Exit::vm_exited()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   882
         st->print(" (shutting down)");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   883
       } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   884
         st->print(" (normal execution)");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   885
       }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   886
       st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   887
       st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   888
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   889
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
   890
  STEP("printing owned locks on error")
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   891
489c9b5090e2 Initial load
duke
parents:
diff changeset
   892
     // mutexes/monitors that currently have an owner
489c9b5090e2 Initial load
duke
parents:
diff changeset
   893
     if (_verbose) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   894
       print_owned_locks_on_error(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   895
       st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   896
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   897
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
   898
  STEP("printing number of OutOfMemoryError and StackOverflow exceptions")
31335
60081f497e75 8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents: 30773
diff changeset
   899
60081f497e75 8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents: 30773
diff changeset
   900
     if (_verbose && Exceptions::has_exception_counts()) {
60081f497e75 8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents: 30773
diff changeset
   901
       st->print_cr("OutOfMemory and StackOverflow Exception counts:");
60081f497e75 8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents: 30773
diff changeset
   902
       Exceptions::print_exception_counts_on_error(st);
60081f497e75 8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents: 30773
diff changeset
   903
       st->cr();
60081f497e75 8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents: 30773
diff changeset
   904
     }
60081f497e75 8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents: 30773
diff changeset
   905
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
   906
  STEP("printing compressed oops mode")
31335
60081f497e75 8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents: 30773
diff changeset
   907
60081f497e75 8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents: 30773
diff changeset
   908
     if (_verbose && UseCompressedOops) {
54780
f8d182aedc92 8223136: Move compressed oops functions to CompressedOops class
stefank
parents: 54623
diff changeset
   909
       CompressedOops::print_mode(st);
31335
60081f497e75 8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents: 30773
diff changeset
   910
       if (UseCompressedClassPointers) {
60081f497e75 8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents: 30773
diff changeset
   911
         Metaspace::print_compressed_class_space(st);
60081f497e75 8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents: 30773
diff changeset
   912
       }
60081f497e75 8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents: 30773
diff changeset
   913
       st->cr();
60081f497e75 8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents: 30773
diff changeset
   914
     }
60081f497e75 8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents: 30773
diff changeset
   915
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
   916
  STEP("printing heap information")
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   917
489c9b5090e2 Initial load
duke
parents:
diff changeset
   918
     if (_verbose && Universe::is_fully_initialized()) {
16685
41c34debcde0 8011872: Include Bit Map addresses in the hs_err files
stefank
parents: 15602
diff changeset
   919
       Universe::heap()->print_on_error(st);
12268
f7897aacb9ce 7157141: crash in 64 bit with corrupted oops
never
parents: 12095
diff changeset
   920
       st->cr();
33148
68fa8b6c4340 8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 33131
diff changeset
   921
       st->print_cr("Polling page: " INTPTR_FORMAT, p2i(os::get_polling_page()));
12268
f7897aacb9ce 7157141: crash in 64 bit with corrupted oops
never
parents: 12095
diff changeset
   922
       st->cr();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   923
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   924
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49922
diff changeset
   925
  STEP("printing metaspace information")
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49922
diff changeset
   926
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49922
diff changeset
   927
     if (_verbose && Universe::is_fully_initialized()) {
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49922
diff changeset
   928
       st->print_cr("Metaspace:");
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49922
diff changeset
   929
       MetaspaceUtils::print_basic_report(st, 0);
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49922
diff changeset
   930
     }
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49922
diff changeset
   931
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
   932
  STEP("printing code cache information")
7108
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 6184
diff changeset
   933
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 6184
diff changeset
   934
     if (_verbose && Universe::is_fully_initialized()) {
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 6184
diff changeset
   935
       // print code cache information before vm abort
15201
f3d755b11424 8005204: Code Cache Reduction: command line options implementation
vladidan
parents: 14477
diff changeset
   936
       CodeCache::print_summary(st);
7108
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 6184
diff changeset
   937
       st->cr();
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 6184
diff changeset
   938
     }
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 6184
diff changeset
   939
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
   940
  STEP("printing ring buffers")
11636
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 11483
diff changeset
   941
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 11483
diff changeset
   942
     if (_verbose) {
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 11483
diff changeset
   943
       Events::print_all(st);
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 11483
diff changeset
   944
       st->cr();
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 11483
diff changeset
   945
     }
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 11483
diff changeset
   946
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
   947
  STEP("printing dynamic libraries")
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   948
489c9b5090e2 Initial load
duke
parents:
diff changeset
   949
     if (_verbose) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   950
       // dynamic libraries, or memory map
489c9b5090e2 Initial load
duke
parents:
diff changeset
   951
       os::print_dll_info(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   952
       st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   953
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   954
47086
2b35673f6297 8186349: [windows] Centralize dbghelp handling code
stuefe
parents: 46630
diff changeset
   955
  STEP("printing native decoder state")
2b35673f6297 8186349: [windows] Centralize dbghelp handling code
stuefe
parents: 46630
diff changeset
   956
2b35673f6297 8186349: [windows] Centralize dbghelp handling code
stuefe
parents: 46630
diff changeset
   957
     if (_verbose) {
2b35673f6297 8186349: [windows] Centralize dbghelp handling code
stuefe
parents: 46630
diff changeset
   958
       Decoder::print_state_on(st);
2b35673f6297 8186349: [windows] Centralize dbghelp handling code
stuefe
parents: 46630
diff changeset
   959
       st->cr();
2b35673f6297 8186349: [windows] Centralize dbghelp handling code
stuefe
parents: 46630
diff changeset
   960
     }
2b35673f6297 8186349: [windows] Centralize dbghelp handling code
stuefe
parents: 46630
diff changeset
   961
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
   962
  STEP("printing VM options")
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   963
489c9b5090e2 Initial load
duke
parents:
diff changeset
   964
     if (_verbose) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   965
       // VM options
489c9b5090e2 Initial load
duke
parents:
diff changeset
   966
       Arguments::print_on(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   967
       st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   968
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   969
50196
85e3ac4fa57b 8203292: Print complete set of flags in the hs_err file
simonis
parents: 50113
diff changeset
   970
  STEP("printing flags")
85e3ac4fa57b 8203292: Print complete set of flags in the hs_err file
simonis
parents: 50113
diff changeset
   971
85e3ac4fa57b 8203292: Print complete set of flags in the hs_err file
simonis
parents: 50113
diff changeset
   972
    if (_verbose) {
85e3ac4fa57b 8203292: Print complete set of flags in the hs_err file
simonis
parents: 50113
diff changeset
   973
      JVMFlag::printFlags(
85e3ac4fa57b 8203292: Print complete set of flags in the hs_err file
simonis
parents: 50113
diff changeset
   974
        st,
85e3ac4fa57b 8203292: Print complete set of flags in the hs_err file
simonis
parents: 50113
diff changeset
   975
        true, // with comments
85e3ac4fa57b 8203292: Print complete set of flags in the hs_err file
simonis
parents: 50113
diff changeset
   976
        false, // no ranges
85e3ac4fa57b 8203292: Print complete set of flags in the hs_err file
simonis
parents: 50113
diff changeset
   977
        true); // skip defaults
85e3ac4fa57b 8203292: Print complete set of flags in the hs_err file
simonis
parents: 50113
diff changeset
   978
      st->cr();
85e3ac4fa57b 8203292: Print complete set of flags in the hs_err file
simonis
parents: 50113
diff changeset
   979
    }
85e3ac4fa57b 8203292: Print complete set of flags in the hs_err file
simonis
parents: 50113
diff changeset
   980
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
   981
  STEP("printing warning if internal testing API used")
12095
cc3d6f08a4c4 7148152: Add whitebox testing API to HotSpot
mgerdin
parents: 11636
diff changeset
   982
cc3d6f08a4c4 7148152: Add whitebox testing API to HotSpot
mgerdin
parents: 11636
diff changeset
   983
     if (WhiteBox::used()) {
cc3d6f08a4c4 7148152: Add whitebox testing API to HotSpot
mgerdin
parents: 11636
diff changeset
   984
       st->print_cr("Unsupported internal testing APIs have been used.");
cc3d6f08a4c4 7148152: Add whitebox testing API to HotSpot
mgerdin
parents: 11636
diff changeset
   985
       st->cr();
cc3d6f08a4c4 7148152: Add whitebox testing API to HotSpot
mgerdin
parents: 11636
diff changeset
   986
     }
cc3d6f08a4c4 7148152: Add whitebox testing API to HotSpot
mgerdin
parents: 11636
diff changeset
   987
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
   988
  STEP("printing log configuration")
37994
1a816b464178 8151526: Print -Xlog configuration in the hs_err_pid file
mockner
parents: 37466
diff changeset
   989
    if (_verbose){
1a816b464178 8151526: Print -Xlog configuration in the hs_err_pid file
mockner
parents: 37466
diff changeset
   990
      st->print_cr("Logging:");
1a816b464178 8151526: Print -Xlog configuration in the hs_err_pid file
mockner
parents: 37466
diff changeset
   991
      LogConfiguration::describe_current_configuration(st);
1a816b464178 8151526: Print -Xlog configuration in the hs_err_pid file
mockner
parents: 37466
diff changeset
   992
      st->cr();
1a816b464178 8151526: Print -Xlog configuration in the hs_err_pid file
mockner
parents: 37466
diff changeset
   993
    }
1a816b464178 8151526: Print -Xlog configuration in the hs_err_pid file
mockner
parents: 37466
diff changeset
   994
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
   995
  STEP("printing all environment variables")
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   996
489c9b5090e2 Initial load
duke
parents:
diff changeset
   997
     if (_verbose) {
30125
8ba6e8e367e9 8074895: os::getenv is inadequate
jmanson
parents: 29573
diff changeset
   998
       os::print_environment_variables(st, env_list);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   999
       st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1000
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1001
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
  1002
  STEP("printing signal handlers")
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1003
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1004
     if (_verbose) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1005
       os::print_signal_handlers(st, buf, sizeof(buf));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1006
       st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1007
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1008
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
  1009
  STEP("Native Memory Tracking")
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 25719
diff changeset
  1010
     if (_verbose) {
27162
0a4a7276949b 8059100: SIGSEGV VirtualMemoryTracker::remove_released_region
coleenp
parents: 26821
diff changeset
  1011
       MemTracker::error_report(st);
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 25719
diff changeset
  1012
     }
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 25719
diff changeset
  1013
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
  1014
  STEP("printing system")
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1015
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1016
     if (_verbose) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1017
       st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1018
       st->print_cr("---------------  S Y S T E M  ---------------");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1019
       st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1020
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1021
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
  1022
  STEP("printing OS information")
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1023
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1024
     if (_verbose) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1025
       os::print_os_info(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1026
       st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1027
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1028
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
  1029
  STEP("printing CPU info")
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1030
     if (_verbose) {
31356
55ee785c49c5 8085865: hs_err improvement: Printing /proc/cpuinfo makes too long hs_err files
coleenp
parents: 31335
diff changeset
  1031
       os::print_cpu_info(st, buf, sizeof(buf));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1032
       st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1033
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1034
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
  1035
  STEP("printing memory info")
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1036
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1037
     if (_verbose) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1038
       os::print_memory_info(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1039
       st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1040
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1041
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
  1042
  STEP("printing internal vm info")
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1043
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1044
     if (_verbose) {
52148
2d9f8845d0ae 7041262: VM_Version should be called instead of Abstract_VM_Version so that overriding works
hseigel
parents: 52115
diff changeset
  1045
       st->print_cr("vm_info: %s", VM_Version::internal_vm_info_string());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1046
       st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1047
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1048
28943
679546f0cc1f 8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents: 28513
diff changeset
  1049
  // print a defined marker to show that error handling finished correctly.
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
  1050
  STEP("printing end marker")
28943
679546f0cc1f 8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents: 28513
diff changeset
  1051
679546f0cc1f 8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents: 28513
diff changeset
  1052
     if (_verbose) {
679546f0cc1f 8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents: 28513
diff changeset
  1053
       st->print_cr("END.");
679546f0cc1f 8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents: 28513
diff changeset
  1054
     }
679546f0cc1f 8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents: 28513
diff changeset
  1055
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1056
  END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1057
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1058
# undef BEGIN
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1059
# undef STEP
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1060
# undef END
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1061
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1062
34139
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1063
// Report for the vm_info_cmd. This prints out the information above omitting
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1064
// crash and thread specific information.  If output is added above, it should be added
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1065
// here also, if it is safe to call during a running process.
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1066
void VMError::print_vm_info(outputStream* st) {
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1067
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1068
  char buf[O_BUFLEN];
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1069
  report_vm_version(st, buf, sizeof(buf));
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1070
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
  1071
  // STEP("printing summary")
34139
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1072
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1073
  st->cr();
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1074
  st->print_cr("---------------  S U M M A R Y ------------");
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1075
  st->cr();
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1076
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
  1077
  // STEP("printing VM option summary")
34139
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1078
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1079
  // VM options
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1080
  Arguments::print_summary_on(st);
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1081
  st->cr();
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1082
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
  1083
  // STEP("printing summary machine and OS info")
34139
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1084
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1085
  os::print_summary_info(st, buf, sizeof(buf));
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1086
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
  1087
  // STEP("printing date and time")
34139
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1088
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1089
  os::print_date_and_time(st, buf, sizeof(buf));
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1090
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
  1091
  // Skip: STEP("printing thread")
34139
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1092
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
  1093
  // STEP("printing process")
34139
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1094
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1095
  st->cr();
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1096
  st->print_cr("---------------  P R O C E S S  ---------------");
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1097
  st->cr();
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1098
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
  1099
  // STEP("printing number of OutOfMemoryError and StackOverflow exceptions")
34139
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1100
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1101
  if (Exceptions::has_exception_counts()) {
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1102
    st->print_cr("OutOfMemory and StackOverflow Exception counts:");
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1103
    Exceptions::print_exception_counts_on_error(st);
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1104
    st->cr();
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1105
  }
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1106
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
  1107
  // STEP("printing compressed oops mode")
34139
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1108
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1109
  if (UseCompressedOops) {
54780
f8d182aedc92 8223136: Move compressed oops functions to CompressedOops class
stefank
parents: 54623
diff changeset
  1110
    CompressedOops::print_mode(st);
34139
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1111
    if (UseCompressedClassPointers) {
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1112
      Metaspace::print_compressed_class_space(st);
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1113
    }
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1114
    st->cr();
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1115
  }
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1116
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
  1117
  // STEP("printing heap information")
34139
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1118
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1119
  if (Universe::is_fully_initialized()) {
39401
318e93828de1 8155730: HeapInfoDCmd should get Heap_lock
ysuenaga
parents: 39274
diff changeset
  1120
    MutexLocker hl(Heap_lock);
34139
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1121
    Universe::heap()->print_on_error(st);
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1122
    st->cr();
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1123
    st->print_cr("Polling page: " INTPTR_FORMAT, p2i(os::get_polling_page()));
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1124
    st->cr();
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1125
  }
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1126
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49922
diff changeset
  1127
  // STEP("printing metaspace information")
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49922
diff changeset
  1128
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49922
diff changeset
  1129
  if (Universe::is_fully_initialized()) {
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49922
diff changeset
  1130
    st->print_cr("Metaspace:");
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49922
diff changeset
  1131
    MetaspaceUtils::print_basic_report(st, 0);
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49922
diff changeset
  1132
  }
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49922
diff changeset
  1133
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
  1134
  // STEP("printing code cache information")
34139
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1135
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1136
  if (Universe::is_fully_initialized()) {
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1137
    // print code cache information before vm abort
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1138
    CodeCache::print_summary(st);
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1139
    st->cr();
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1140
  }
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1141
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
  1142
  // STEP("printing ring buffers")
34139
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1143
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1144
  Events::print_all(st);
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1145
  st->cr();
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1146
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
  1147
  // STEP("printing dynamic libraries")
34139
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1148
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1149
  // dynamic libraries, or memory map
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1150
  os::print_dll_info(st);
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1151
  st->cr();
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1152
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
  1153
  // STEP("printing VM options")
34139
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1154
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1155
  // VM options
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1156
  Arguments::print_on(st);
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1157
  st->cr();
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1158
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
  1159
  // STEP("printing warning if internal testing API used")
34139
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1160
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1161
  if (WhiteBox::used()) {
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1162
    st->print_cr("Unsupported internal testing APIs have been used.");
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1163
    st->cr();
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1164
  }
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1165
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
  1166
  // STEP("printing log configuration")
37994
1a816b464178 8151526: Print -Xlog configuration in the hs_err_pid file
mockner
parents: 37466
diff changeset
  1167
  st->print_cr("Logging:");
1a816b464178 8151526: Print -Xlog configuration in the hs_err_pid file
mockner
parents: 37466
diff changeset
  1168
  LogConfiguration::describe(st);
1a816b464178 8151526: Print -Xlog configuration in the hs_err_pid file
mockner
parents: 37466
diff changeset
  1169
  st->cr();
1a816b464178 8151526: Print -Xlog configuration in the hs_err_pid file
mockner
parents: 37466
diff changeset
  1170
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
  1171
  // STEP("printing all environment variables")
34139
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1172
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1173
  os::print_environment_variables(st, env_list);
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1174
  st->cr();
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1175
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
  1176
  // STEP("printing signal handlers")
34139
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1177
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1178
  os::print_signal_handlers(st, buf, sizeof(buf));
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1179
  st->cr();
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1180
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
  1181
  // STEP("Native Memory Tracking")
34139
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1182
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1183
  MemTracker::error_report(st);
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1184
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
  1185
  // STEP("printing system")
34139
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1186
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1187
  st->cr();
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1188
  st->print_cr("---------------  S Y S T E M  ---------------");
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1189
  st->cr();
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1190
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
  1191
  // STEP("printing OS information")
34139
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1192
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1193
  os::print_os_info(st);
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1194
  st->cr();
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1195
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
  1196
  // STEP("printing CPU info")
34139
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1197
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1198
  os::print_cpu_info(st, buf, sizeof(buf));
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1199
  st->cr();
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1200
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
  1201
  // STEP("printing memory info")
34139
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1202
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1203
  os::print_memory_info(st);
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1204
  st->cr();
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1205
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
  1206
  // STEP("printing internal vm info")
34139
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1207
52148
2d9f8845d0ae 7041262: VM_Version should be called instead of Abstract_VM_Version so that overriding works
hseigel
parents: 52115
diff changeset
  1208
  st->print_cr("vm_info: %s", VM_Version::internal_vm_info_string());
34139
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1209
  st->cr();
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1210
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1211
  // print a defined marker to show that error handling finished correctly.
38215
fe1677e95252 8155639: Remove STEP numbers from error reporting
stuefe
parents: 37994
diff changeset
  1212
  // STEP("printing end marker")
34139
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1213
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1214
  st->print_cr("END.");
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1215
}
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33198
diff changeset
  1216
58579
05dd6144d434 8218543: ThreadsList handling during error reporting can crash
rehn
parents: 57699
diff changeset
  1217
volatile intptr_t VMError::_first_error_tid = -1;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1218
17121
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1219
/** Expand a pattern into a buffer starting at pos and open a file using constructed path */
54897
2e5e9d31a6c5 8224023: Redo the fix for ErrorFile option does not handle pre-existing error files of the same name
stuefe
parents: 54881
diff changeset
  1220
static int expand_and_open(const char* pattern, bool overwrite_existing, char* buf, size_t buflen, size_t pos) {
17121
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1221
  int fd = -1;
54897
2e5e9d31a6c5 8224023: Redo the fix for ErrorFile option does not handle pre-existing error files of the same name
stuefe
parents: 54881
diff changeset
  1222
  int mode = O_RDWR | O_CREAT;
2e5e9d31a6c5 8224023: Redo the fix for ErrorFile option does not handle pre-existing error files of the same name
stuefe
parents: 54881
diff changeset
  1223
  if (overwrite_existing) {
2e5e9d31a6c5 8224023: Redo the fix for ErrorFile option does not handle pre-existing error files of the same name
stuefe
parents: 54881
diff changeset
  1224
    mode |= O_TRUNC;
2e5e9d31a6c5 8224023: Redo the fix for ErrorFile option does not handle pre-existing error files of the same name
stuefe
parents: 54881
diff changeset
  1225
  } else {
2e5e9d31a6c5 8224023: Redo the fix for ErrorFile option does not handle pre-existing error files of the same name
stuefe
parents: 54881
diff changeset
  1226
    mode |= O_EXCL;
2e5e9d31a6c5 8224023: Redo the fix for ErrorFile option does not handle pre-existing error files of the same name
stuefe
parents: 54881
diff changeset
  1227
  }
17121
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1228
  if (Arguments::copy_expand_pid(pattern, strlen(pattern), &buf[pos], buflen - pos)) {
54897
2e5e9d31a6c5 8224023: Redo the fix for ErrorFile option does not handle pre-existing error files of the same name
stuefe
parents: 54881
diff changeset
  1229
    fd = open(buf, mode, 0666);
17121
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1230
  }
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1231
  return fd;
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1232
}
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1233
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1234
/**
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1235
 * Construct file name for a log file and return it's file descriptor.
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1236
 * Name and location depends on pattern, default_pattern params and access
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1237
 * permissions.
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1238
 */
54897
2e5e9d31a6c5 8224023: Redo the fix for ErrorFile option does not handle pre-existing error files of the same name
stuefe
parents: 54881
diff changeset
  1239
static int prepare_log_file(const char* pattern, const char* default_pattern, bool overwrite_existing, char* buf, size_t buflen) {
17121
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1240
  int fd = -1;
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1241
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1242
  // If possible, use specified pattern to construct log file name
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1243
  if (pattern != NULL) {
54897
2e5e9d31a6c5 8224023: Redo the fix for ErrorFile option does not handle pre-existing error files of the same name
stuefe
parents: 54881
diff changeset
  1244
    fd = expand_and_open(pattern, overwrite_existing, buf, buflen, 0);
17121
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1245
  }
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1246
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1247
  // Either user didn't specify, or the user's location failed,
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1248
  // so use the default name in the current directory
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1249
  if (fd == -1) {
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1250
    const char* cwd = os::get_current_directory(buf, buflen);
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1251
    if (cwd != NULL) {
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1252
      size_t pos = strlen(cwd);
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1253
      int fsep_len = jio_snprintf(&buf[pos], buflen-pos, "%s", os::file_separator());
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1254
      pos += fsep_len;
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1255
      if (fsep_len > 0) {
54897
2e5e9d31a6c5 8224023: Redo the fix for ErrorFile option does not handle pre-existing error files of the same name
stuefe
parents: 54881
diff changeset
  1256
        fd = expand_and_open(default_pattern, overwrite_existing, buf, buflen, pos);
17121
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1257
      }
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1258
    }
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1259
  }
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1260
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1261
   // try temp directory if it exists.
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1262
   if (fd == -1) {
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1263
     const char* tmpdir = os::get_temp_directory();
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1264
     if (tmpdir != NULL && strlen(tmpdir) > 0) {
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1265
       int pos = jio_snprintf(buf, buflen, "%s%s", tmpdir, os::file_separator());
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1266
       if (pos > 0) {
54897
2e5e9d31a6c5 8224023: Redo the fix for ErrorFile option does not handle pre-existing error files of the same name
stuefe
parents: 54881
diff changeset
  1267
         fd = expand_and_open(default_pattern, overwrite_existing, buf, buflen, pos);
17121
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1268
       }
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1269
     }
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1270
   }
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1271
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1272
  return fd;
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1273
}
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1274
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1275
int         VMError::_id;
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1276
const char* VMError::_message;
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1277
char        VMError::_detail_msg[1024];
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1278
Thread*     VMError::_thread;
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1279
address     VMError::_pc;
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1280
void*       VMError::_siginfo;
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1281
void*       VMError::_context;
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1282
const char* VMError::_filename;
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1283
int         VMError::_lineno;
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1284
size_t      VMError::_size;
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1285
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1286
void VMError::report_and_die(Thread* thread, unsigned int sig, address pc, void* siginfo,
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1287
                             void* context, const char* detail_fmt, ...)
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1288
{
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1289
  va_list detail_args;
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1290
  va_start(detail_args, detail_fmt);
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1291
  report_and_die(sig, NULL, detail_fmt, detail_args, thread, pc, siginfo, context, NULL, 0, 0);
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1292
  va_end(detail_args);
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1293
}
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1294
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1295
void VMError::report_and_die(Thread* thread, unsigned int sig, address pc, void* siginfo, void* context)
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1296
{
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1297
  report_and_die(thread, sig, pc, siginfo, context, "%s", "");
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1298
}
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1299
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1300
void VMError::report_and_die(const char* message, const char* detail_fmt, ...)
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1301
{
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1302
  va_list detail_args;
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1303
  va_start(detail_args, detail_fmt);
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1304
  report_and_die(INTERNAL_ERROR, message, detail_fmt, detail_args, NULL, NULL, NULL, NULL, NULL, 0, 0);
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1305
  va_end(detail_args);
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1306
}
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1307
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1308
void VMError::report_and_die(const char* message)
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1309
{
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1310
  report_and_die(message, "%s", "");
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1311
}
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1312
49653
a569cb4425f3 8191101: Show register content in hs-err file on assert
stuefe
parents: 49334
diff changeset
  1313
void VMError::report_and_die(Thread* thread, void* context, const char* filename, int lineno, const char* message,
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1314
                             const char* detail_fmt, va_list detail_args)
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1315
{
49653
a569cb4425f3 8191101: Show register content in hs-err file on assert
stuefe
parents: 49334
diff changeset
  1316
  report_and_die(INTERNAL_ERROR, message, detail_fmt, detail_args, thread, NULL, NULL, context, filename, lineno, 0);
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1317
}
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1318
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1319
void VMError::report_and_die(Thread* thread, const char* filename, int lineno, size_t size,
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1320
                             VMErrorType vm_err_type, const char* detail_fmt, va_list detail_args) {
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1321
  report_and_die(vm_err_type, NULL, detail_fmt, detail_args, thread, NULL, NULL, NULL, filename, lineno, size);
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1322
}
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1323
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1324
void VMError::report_and_die(int id, const char* message, const char* detail_fmt, va_list detail_args,
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1325
                             Thread* thread, address pc, void* siginfo, void* context, const char* filename,
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1326
                             int lineno, size_t size)
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1327
{
53599
0de1f006d3c3 8214975: No hs-err file if fatal error is raised during dynamic initialization
stuefe
parents: 52877
diff changeset
  1328
  // A single scratch buffer to be used from here on.
0de1f006d3c3 8214975: No hs-err file if fatal error is raised during dynamic initialization
stuefe
parents: 52877
diff changeset
  1329
  // Do not rely on it being preserved across function calls.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1330
  static char buffer[O_BUFLEN];
53599
0de1f006d3c3 8214975: No hs-err file if fatal error is raised during dynamic initialization
stuefe
parents: 52877
diff changeset
  1331
0de1f006d3c3 8214975: No hs-err file if fatal error is raised during dynamic initialization
stuefe
parents: 52877
diff changeset
  1332
  // File descriptor to tty to print an error summary to.
0de1f006d3c3 8214975: No hs-err file if fatal error is raised during dynamic initialization
stuefe
parents: 52877
diff changeset
  1333
  // Hard wired to stdout; see JDK-8215004 (compatibility concerns).
0de1f006d3c3 8214975: No hs-err file if fatal error is raised during dynamic initialization
stuefe
parents: 52877
diff changeset
  1334
  static const int fd_out = 1; // stdout
0de1f006d3c3 8214975: No hs-err file if fatal error is raised during dynamic initialization
stuefe
parents: 52877
diff changeset
  1335
0de1f006d3c3 8214975: No hs-err file if fatal error is raised during dynamic initialization
stuefe
parents: 52877
diff changeset
  1336
  // File descriptor to the error log file.
0de1f006d3c3 8214975: No hs-err file if fatal error is raised during dynamic initialization
stuefe
parents: 52877
diff changeset
  1337
  static int fd_log = -1;
0de1f006d3c3 8214975: No hs-err file if fatal error is raised during dynamic initialization
stuefe
parents: 52877
diff changeset
  1338
55653
3243c42d737d 8227275: Within native OOM error handling, assertions may hang the process
stuefe
parents: 55652
diff changeset
  1339
#ifdef CAN_SHOW_REGISTERS_ON_ASSERT
3243c42d737d 8227275: Within native OOM error handling, assertions may hang the process
stuefe
parents: 55652
diff changeset
  1340
  // Disarm assertion poison page, since from this point on we do not need this mechanism anymore and it may
3243c42d737d 8227275: Within native OOM error handling, assertions may hang the process
stuefe
parents: 55652
diff changeset
  1341
  // cause problems in error handling during native OOM, see JDK-8227275.
3243c42d737d 8227275: Within native OOM error handling, assertions may hang the process
stuefe
parents: 55652
diff changeset
  1342
  disarm_assert_poison();
3243c42d737d 8227275: Within native OOM error handling, assertions may hang the process
stuefe
parents: 55652
diff changeset
  1343
#endif
3243c42d737d 8227275: Within native OOM error handling, assertions may hang the process
stuefe
parents: 55652
diff changeset
  1344
53599
0de1f006d3c3 8214975: No hs-err file if fatal error is raised during dynamic initialization
stuefe
parents: 52877
diff changeset
  1345
  // Use local fdStream objects only. Do not use global instances whose initialization
0de1f006d3c3 8214975: No hs-err file if fatal error is raised during dynamic initialization
stuefe
parents: 52877
diff changeset
  1346
  // relies on dynamic initialization (see JDK-8214975). Do not rely on these instances
0de1f006d3c3 8214975: No hs-err file if fatal error is raised during dynamic initialization
stuefe
parents: 52877
diff changeset
  1347
  // to carry over into recursions or invocations from other threads.
0de1f006d3c3 8214975: No hs-err file if fatal error is raised during dynamic initialization
stuefe
parents: 52877
diff changeset
  1348
  fdStream out(fd_out);
35869
cd7df4cdaa1a 8146905: cleanup ostream, staticBufferStream
stuefe
parents: 35453
diff changeset
  1349
  out.set_scratch_buffer(buffer, sizeof(buffer));
53599
0de1f006d3c3 8214975: No hs-err file if fatal error is raised during dynamic initialization
stuefe
parents: 52877
diff changeset
  1350
0de1f006d3c3 8214975: No hs-err file if fatal error is raised during dynamic initialization
stuefe
parents: 52877
diff changeset
  1351
  // Depending on the re-entrance depth at this point, fd_log may be -1 or point to an open hs-err file.
0de1f006d3c3 8214975: No hs-err file if fatal error is raised during dynamic initialization
stuefe
parents: 52877
diff changeset
  1352
  fdStream log(fd_log);
35869
cd7df4cdaa1a 8146905: cleanup ostream, staticBufferStream
stuefe
parents: 35453
diff changeset
  1353
  log.set_scratch_buffer(buffer, sizeof(buffer));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1354
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1355
  // How many errors occurred in error handler when reporting first_error.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1356
  static int recursive_error_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1357
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1358
  // We will first print a brief message to standard out (verbose = false),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1359
  // then save detailed information in log file (verbose = true).
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1360
  static bool out_done = false;         // done printing to standard out
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1361
  static bool log_done = false;         // done saving error log
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1362
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1363
  if (SuppressFatalErrorMessage) {
30240
a7ba42fa1df6 8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents: 30125
diff changeset
  1364
      os::abort(CreateCoredumpOnCrash);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1365
  }
33131
a8ad9de9e5a4 8138832: CreateCoredumpOnCrash on linux ARM causes assert message to be repeated.
david
parents: 33105
diff changeset
  1366
  intptr_t mytid = os::current_thread_id();
58579
05dd6144d434 8218543: ThreadsList handling during error reporting can crash
rehn
parents: 57699
diff changeset
  1367
  if (_first_error_tid == -1 &&
59252
623722a6aeb9 8234740: Harmonize parameter order in Atomic - cmpxchg
stefank
parents: 59248
diff changeset
  1368
      Atomic::cmpxchg(&_first_error_tid, (intptr_t)-1, mytid) == -1) {
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1369
36320
3d35d1e1dfde 8150441: CompileTask::print_impl() is broken after JDK-8146905
thartmann
parents: 35913
diff changeset
  1370
    // Initialize time stamps to use the same base.
3d35d1e1dfde 8150441: CompileTask::print_impl() is broken after JDK-8146905
thartmann
parents: 35913
diff changeset
  1371
    out.time_stamp().update_to(1);
3d35d1e1dfde 8150441: CompileTask::print_impl() is broken after JDK-8146905
thartmann
parents: 35913
diff changeset
  1372
    log.time_stamp().update_to(1);
3d35d1e1dfde 8150441: CompileTask::print_impl() is broken after JDK-8146905
thartmann
parents: 35913
diff changeset
  1373
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1374
    _id = id;
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1375
    _message = message;
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1376
    _thread = thread;
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1377
    _pc = pc;
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1378
    _siginfo = siginfo;
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1379
    _context = context;
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1380
    _filename = filename;
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1381
    _lineno = lineno;
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1382
    _size = size;
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1383
    jio_vsnprintf(_detail_msg, sizeof(_detail_msg), detail_fmt, detail_args);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1384
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1385
    // first time
46589
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1386
    _error_reported = true;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1387
46284
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1388
    reporting_started();
55239
74832e7b5cad 8188872: runtime/ErrorHandling/TimeoutInErrorHandlingTest.java fails intermittently
dcubed
parents: 54897
diff changeset
  1389
    if (!TestUnresponsiveErrorHandler) {
74832e7b5cad 8188872: runtime/ErrorHandling/TimeoutInErrorHandlingTest.java fails intermittently
dcubed
parents: 54897
diff changeset
  1390
      // Record reporting_start_time unless we're running the
74832e7b5cad 8188872: runtime/ErrorHandling/TimeoutInErrorHandlingTest.java fails intermittently
dcubed
parents: 54897
diff changeset
  1391
      // TestUnresponsiveErrorHandler test. For that test we record
74832e7b5cad 8188872: runtime/ErrorHandling/TimeoutInErrorHandlingTest.java fails intermittently
dcubed
parents: 54897
diff changeset
  1392
      // reporting_start_time at the beginning of the test.
74832e7b5cad 8188872: runtime/ErrorHandling/TimeoutInErrorHandlingTest.java fails intermittently
dcubed
parents: 54897
diff changeset
  1393
      record_reporting_start_time();
74832e7b5cad 8188872: runtime/ErrorHandling/TimeoutInErrorHandlingTest.java fails intermittently
dcubed
parents: 54897
diff changeset
  1394
    } else {
74832e7b5cad 8188872: runtime/ErrorHandling/TimeoutInErrorHandlingTest.java fails intermittently
dcubed
parents: 54897
diff changeset
  1395
      out.print_raw_cr("Delaying recording reporting_start_time for TestUnresponsiveErrorHandler.");
74832e7b5cad 8188872: runtime/ErrorHandling/TimeoutInErrorHandlingTest.java fails intermittently
dcubed
parents: 54897
diff changeset
  1396
    }
46284
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1397
8476
7e34c2d4cf9b 7022037: Pause when exiting if debugger is attached on windows
sla
parents: 8119
diff changeset
  1398
    if (ShowMessageBoxOnError || PauseAtExit) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1399
      show_message_box(buffer, sizeof(buffer));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1400
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1401
      // User has asked JVM to abort. Reset ShowMessageBoxOnError so the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1402
      // WatcherThread can kill JVM if the error handler hangs.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1403
      ShowMessageBoxOnError = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1404
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1405
30240
a7ba42fa1df6 8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents: 30125
diff changeset
  1406
    os::check_dump_limit(buffer, sizeof(buffer));
8119
81eef1b06988 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents: 8114
diff changeset
  1407
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1408
    // reset signal handlers or exception filter; make sure recursive crashes
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1409
    // are handled properly.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1410
    reset_signal_handlers();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1411
49176
f413e471a6ab 8041626: Shutdown tracing event
rwestberg
parents: 48824
diff changeset
  1412
    EventShutdown e;
f413e471a6ab 8041626: Shutdown tracing event
rwestberg
parents: 48824
diff changeset
  1413
    if (e.should_commit()) {
f413e471a6ab 8041626: Shutdown tracing event
rwestberg
parents: 48824
diff changeset
  1414
      e.set_reason("VM Error");
f413e471a6ab 8041626: Shutdown tracing event
rwestberg
parents: 48824
diff changeset
  1415
      e.commit();
f413e471a6ab 8041626: Shutdown tracing event
rwestberg
parents: 48824
diff changeset
  1416
    }
f413e471a6ab 8041626: Shutdown tracing event
rwestberg
parents: 48824
diff changeset
  1417
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents: 50015
diff changeset
  1418
    JFR_ONLY(Jfr::on_vm_shutdown(true);)
39274
940f0e8e9ec2 8158033: Notify_tracing() misplaced for intended purpose
mgronlun
parents: 38215
diff changeset
  1419
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1420
  } else {
1887
0ed88ac17540 4997835: RFE: crash dump will only be created when running w/ -XX:+ShowMessageBoxOnError
coleenp
parents: 1660
diff changeset
  1421
    // If UseOsErrorReporting we call this for each level of the call stack
0ed88ac17540 4997835: RFE: crash dump will only be created when running w/ -XX:+ShowMessageBoxOnError
coleenp
parents: 1660
diff changeset
  1422
    // while searching for the exception handler.  Only the first level needs
0ed88ac17540 4997835: RFE: crash dump will only be created when running w/ -XX:+ShowMessageBoxOnError
coleenp
parents: 1660
diff changeset
  1423
    // to be reported.
0ed88ac17540 4997835: RFE: crash dump will only be created when running w/ -XX:+ShowMessageBoxOnError
coleenp
parents: 1660
diff changeset
  1424
    if (UseOSErrorReporting && log_done) return;
0ed88ac17540 4997835: RFE: crash dump will only be created when running w/ -XX:+ShowMessageBoxOnError
coleenp
parents: 1660
diff changeset
  1425
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1426
    // This is not the first error, see if it happened in a different thread
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1427
    // or in the same thread during error reporting.
58579
05dd6144d434 8218543: ThreadsList handling during error reporting can crash
rehn
parents: 57699
diff changeset
  1428
    if (_first_error_tid != mytid) {
18684
79e53d93bc13 8016465: The hs_err file gets wrong name
fparain
parents: 18487
diff changeset
  1429
      char msgbuf[64];
79e53d93bc13 8016465: The hs_err file gets wrong name
fparain
parents: 18487
diff changeset
  1430
      jio_snprintf(msgbuf, sizeof(msgbuf),
33131
a8ad9de9e5a4 8138832: CreateCoredumpOnCrash on linux ARM causes assert message to be repeated.
david
parents: 33105
diff changeset
  1431
                   "[thread " INTX_FORMAT " also had an error]",
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1432
                   mytid);
18684
79e53d93bc13 8016465: The hs_err file gets wrong name
fparain
parents: 18487
diff changeset
  1433
      out.print_raw_cr(msgbuf);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1434
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1435
      // error reporting is not MT-safe, block current thread
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1436
      os::infinite_sleep();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1437
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1438
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1439
      if (recursive_error_count++ > 30) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1440
        out.print_raw_cr("[Too many errors, abort]");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1441
        os::die();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1442
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1443
46284
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1444
      outputStream* const st = log.is_open() ? &log : &out;
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1445
      st->cr();
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1446
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1447
      // Timeout handling.
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1448
      if (_step_did_timeout) {
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1449
        // The current step had a timeout. Lets continue reporting with the next step.
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1450
        st->print_raw("[timeout occurred during error reporting in step \"");
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1451
        st->print_raw(_current_step_info);
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1452
        st->print_cr("\"] after " INT64_FORMAT " s.",
46630
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46589
diff changeset
  1453
                     (int64_t)
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46589
diff changeset
  1454
                     ((get_current_timestamp() - _step_start_time) / TIMESTAMP_TO_SECONDS_FACTOR));
46284
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1455
      } else if (_reporting_did_timeout) {
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1456
        // We hit ErrorLogTimeout. Reporting will stop altogether. Let's wrap things
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1457
        // up, the process is about to be stopped by the WatcherThread.
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1458
        st->print_cr("------ Timeout during error reporting after " INT64_FORMAT " s. ------",
46630
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46589
diff changeset
  1459
                     (int64_t)
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46589
diff changeset
  1460
                     ((get_current_timestamp() - _reporting_start_time) / TIMESTAMP_TO_SECONDS_FACTOR));
46284
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1461
        st->flush();
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1462
        // Watcherthread is about to call os::die. Lets just wait.
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1463
        os::infinite_sleep();
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1464
      } else {
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1465
        // Crash or assert during error reporting. Lets continue reporting with the next step.
50872
308410473abe 8205925: Print correct and more information about secondary errors
stuefe
parents: 50798
diff changeset
  1466
        stringStream ss(buffer, sizeof(buffer));
308410473abe 8205925: Print correct and more information about secondary errors
stuefe
parents: 50798
diff changeset
  1467
        // Note: this string does get parsed by a number of jtreg tests,
308410473abe 8205925: Print correct and more information about secondary errors
stuefe
parents: 50798
diff changeset
  1468
        // see hotspot/jtreg/runtime/ErrorHandling.
308410473abe 8205925: Print correct and more information about secondary errors
stuefe
parents: 50798
diff changeset
  1469
        ss.print("[error occurred during error reporting (%s), id 0x%x",
308410473abe 8205925: Print correct and more information about secondary errors
stuefe
parents: 50798
diff changeset
  1470
                   _current_step_info, id);
308410473abe 8205925: Print correct and more information about secondary errors
stuefe
parents: 50798
diff changeset
  1471
        char signal_name[64];
308410473abe 8205925: Print correct and more information about secondary errors
stuefe
parents: 50798
diff changeset
  1472
        if (os::exception_name(id, signal_name, sizeof(signal_name))) {
308410473abe 8205925: Print correct and more information about secondary errors
stuefe
parents: 50798
diff changeset
  1473
          ss.print(", %s (0x%x) at pc=" PTR_FORMAT, signal_name, id, p2i(pc));
308410473abe 8205925: Print correct and more information about secondary errors
stuefe
parents: 50798
diff changeset
  1474
        } else {
308410473abe 8205925: Print correct and more information about secondary errors
stuefe
parents: 50798
diff changeset
  1475
          if (should_report_bug(id)) {
308410473abe 8205925: Print correct and more information about secondary errors
stuefe
parents: 50798
diff changeset
  1476
            ss.print(", Internal Error (%s:%d)",
308410473abe 8205925: Print correct and more information about secondary errors
stuefe
parents: 50798
diff changeset
  1477
              filename == NULL ? "??" : filename, lineno);
308410473abe 8205925: Print correct and more information about secondary errors
stuefe
parents: 50798
diff changeset
  1478
          } else {
308410473abe 8205925: Print correct and more information about secondary errors
stuefe
parents: 50798
diff changeset
  1479
            ss.print(", Out of Memory Error (%s:%d)",
308410473abe 8205925: Print correct and more information about secondary errors
stuefe
parents: 50798
diff changeset
  1480
              filename == NULL ? "??" : filename, lineno);
308410473abe 8205925: Print correct and more information about secondary errors
stuefe
parents: 50798
diff changeset
  1481
          }
308410473abe 8205925: Print correct and more information about secondary errors
stuefe
parents: 50798
diff changeset
  1482
        }
308410473abe 8205925: Print correct and more information about secondary errors
stuefe
parents: 50798
diff changeset
  1483
        ss.print("]");
46284
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1484
        st->print_raw_cr(buffer);
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1485
        st->cr();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1486
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1487
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1488
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1489
54322
cf75ea6af695 8220786: Create new switch to redirect error reporting output to stdout or stderr
stuefe
parents: 54284
diff changeset
  1490
  // Part 1: print an abbreviated version (the '#' section) to stdout.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1491
  if (!out_done) {
54322
cf75ea6af695 8220786: Create new switch to redirect error reporting output to stdout or stderr
stuefe
parents: 54284
diff changeset
  1492
    // Suppress this output if we plan to print Part 2 to stdout too.
cf75ea6af695 8220786: Create new switch to redirect error reporting output to stdout or stderr
stuefe
parents: 54284
diff changeset
  1493
    // No need to have the "#" section twice.
cf75ea6af695 8220786: Create new switch to redirect error reporting output to stdout or stderr
stuefe
parents: 54284
diff changeset
  1494
    if (!(ErrorFileToStdout && out.fd() == 1)) {
cf75ea6af695 8220786: Create new switch to redirect error reporting output to stdout or stderr
stuefe
parents: 54284
diff changeset
  1495
      report(&out, false);
cf75ea6af695 8220786: Create new switch to redirect error reporting output to stdout or stderr
stuefe
parents: 54284
diff changeset
  1496
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1497
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1498
    out_done = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1499
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1500
    _current_step = 0;
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1501
    _current_step_info = "";
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1502
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1503
54322
cf75ea6af695 8220786: Create new switch to redirect error reporting output to stdout or stderr
stuefe
parents: 54284
diff changeset
  1504
  // Part 2: print a full error log file (optionally to stdout or stderr).
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1505
  // print to error log file
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1506
  if (!log_done) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1507
    // see if log file is already open
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1508
    if (!log.is_open()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1509
      // open log file
54322
cf75ea6af695 8220786: Create new switch to redirect error reporting output to stdout or stderr
stuefe
parents: 54284
diff changeset
  1510
      if (ErrorFileToStdout) {
cf75ea6af695 8220786: Create new switch to redirect error reporting output to stdout or stderr
stuefe
parents: 54284
diff changeset
  1511
        fd_log = 1;
cf75ea6af695 8220786: Create new switch to redirect error reporting output to stdout or stderr
stuefe
parents: 54284
diff changeset
  1512
      } else if (ErrorFileToStderr) {
cf75ea6af695 8220786: Create new switch to redirect error reporting output to stdout or stderr
stuefe
parents: 54284
diff changeset
  1513
        fd_log = 2;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1514
      } else {
54897
2e5e9d31a6c5 8224023: Redo the fix for ErrorFile option does not handle pre-existing error files of the same name
stuefe
parents: 54881
diff changeset
  1515
        fd_log = prepare_log_file(ErrorFile, "hs_err_pid%p.log", true,
2e5e9d31a6c5 8224023: Redo the fix for ErrorFile option does not handle pre-existing error files of the same name
stuefe
parents: 54881
diff changeset
  1516
                 buffer, sizeof(buffer));
54322
cf75ea6af695 8220786: Create new switch to redirect error reporting output to stdout or stderr
stuefe
parents: 54284
diff changeset
  1517
        if (fd_log != -1) {
cf75ea6af695 8220786: Create new switch to redirect error reporting output to stdout or stderr
stuefe
parents: 54284
diff changeset
  1518
          out.print_raw("# An error report file with more information is saved as:\n# ");
cf75ea6af695 8220786: Create new switch to redirect error reporting output to stdout or stderr
stuefe
parents: 54284
diff changeset
  1519
          out.print_raw_cr(buffer);
cf75ea6af695 8220786: Create new switch to redirect error reporting output to stdout or stderr
stuefe
parents: 54284
diff changeset
  1520
        } else {
cf75ea6af695 8220786: Create new switch to redirect error reporting output to stdout or stderr
stuefe
parents: 54284
diff changeset
  1521
          out.print_raw_cr("# Can not save log file, dump to screen..");
cf75ea6af695 8220786: Create new switch to redirect error reporting output to stdout or stderr
stuefe
parents: 54284
diff changeset
  1522
          fd_log = 1;
cf75ea6af695 8220786: Create new switch to redirect error reporting output to stdout or stderr
stuefe
parents: 54284
diff changeset
  1523
        }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1524
      }
54322
cf75ea6af695 8220786: Create new switch to redirect error reporting output to stdout or stderr
stuefe
parents: 54284
diff changeset
  1525
      log.set_fd(fd_log);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1526
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1527
35869
cd7df4cdaa1a 8146905: cleanup ostream, staticBufferStream
stuefe
parents: 35453
diff changeset
  1528
    report(&log, true);
46320
a38f07dfcf47 8176140: 8176140-Crashes-or-timeouts-during-error-reporting-may-lead-to-infinitely-repeated-error-logs-until-ErrorLogTimeout-is-hit
stuefe
parents: 46284
diff changeset
  1529
    log_done = true;
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1530
    _current_step = 0;
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1531
    _current_step_info = "";
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1532
54322
cf75ea6af695 8220786: Create new switch to redirect error reporting output to stdout or stderr
stuefe
parents: 54284
diff changeset
  1533
    if (fd_log > 3) {
53599
0de1f006d3c3 8214975: No hs-err file if fatal error is raised during dynamic initialization
stuefe
parents: 52877
diff changeset
  1534
      close(fd_log);
0de1f006d3c3 8214975: No hs-err file if fatal error is raised during dynamic initialization
stuefe
parents: 52877
diff changeset
  1535
      fd_log = -1;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1536
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1537
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1538
    log.set_fd(-1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1539
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1540
55652
2d1acda7555a 8227031: Print NMT statistics on fatal errors
stuefe
parents: 55239
diff changeset
  1541
  if (PrintNMTStatistics) {
2d1acda7555a 8227031: Print NMT statistics on fatal errors
stuefe
parents: 55239
diff changeset
  1542
    fdStream fds(fd_out);
2d1acda7555a 8227031: Print NMT statistics on fatal errors
stuefe
parents: 55239
diff changeset
  1543
    MemTracker::final_report(&fds);
2d1acda7555a 8227031: Print NMT statistics on fatal errors
stuefe
parents: 55239
diff changeset
  1544
  }
2d1acda7555a 8227031: Print NMT statistics on fatal errors
stuefe
parents: 55239
diff changeset
  1545
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20692
diff changeset
  1546
  static bool skip_replay = ReplayCompiles; // Do not overwrite file during replay
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents: 14289
diff changeset
  1547
  if (DumpReplayDataOnError && _thread && _thread->is_Compiler_thread() && !skip_replay) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents: 14289
diff changeset
  1548
    skip_replay = true;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents: 14289
diff changeset
  1549
    ciEnv* env = ciEnv::current();
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents: 14289
diff changeset
  1550
    if (env != NULL) {
54897
2e5e9d31a6c5 8224023: Redo the fix for ErrorFile option does not handle pre-existing error files of the same name
stuefe
parents: 54881
diff changeset
  1551
      const bool overwrite = false; // We do not overwrite an existing replay file.
2e5e9d31a6c5 8224023: Redo the fix for ErrorFile option does not handle pre-existing error files of the same name
stuefe
parents: 54881
diff changeset
  1552
      int fd = prepare_log_file(ReplayDataFile, "replay_pid%p.log", overwrite, buffer, sizeof(buffer));
17121
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1553
      if (fd != -1) {
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1554
        FILE* replay_data_file = os::open(fd, "w");
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1555
        if (replay_data_file != NULL) {
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1556
          fileStream replay_data_stream(replay_data_file, /*need_close=*/true);
20692
65021f70c2fc 8024943: ciReplay: fails to dump replay data during safepointing
vlivanov
parents: 19952
diff changeset
  1557
          env->dump_replay_data_unsafe(&replay_data_stream);
17121
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1558
          out.print_raw("#\n# Compiler replay data is saved as:\n# ");
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1559
          out.print_raw_cr(buffer);
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1560
        } else {
37113
5a33bf5089ac 8148425: strerror() function is not thread-safe
stuefe
parents: 36320
diff changeset
  1561
          int e = errno;
17121
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1562
          out.print_raw("#\n# Can't open file to dump replay data. Error: ");
37113
5a33bf5089ac 8148425: strerror() function is not thread-safe
stuefe
parents: 36320
diff changeset
  1563
          out.print_raw_cr(os::strerror(e));
17121
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1564
        }
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 16685
diff changeset
  1565
      }
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents: 14289
diff changeset
  1566
    }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents: 14289
diff changeset
  1567
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents: 14289
diff changeset
  1568
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1569
  static bool skip_bug_url = !should_report_bug(_id);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1570
  if (!skip_bug_url) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1571
    skip_bug_url = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1572
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1573
    out.print_raw_cr("#");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1574
    print_bug_submit_message(&out, _thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1575
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1576
35568
8dfb205a2886 6985422: flush the output streams before OnError commands
vlivanov
parents: 35176
diff changeset
  1577
  static bool skip_OnError = false;
8dfb205a2886 6985422: flush the output streams before OnError commands
vlivanov
parents: 35176
diff changeset
  1578
  if (!skip_OnError && OnError && OnError[0]) {
8dfb205a2886 6985422: flush the output streams before OnError commands
vlivanov
parents: 35176
diff changeset
  1579
    skip_OnError = true;
8dfb205a2886 6985422: flush the output streams before OnError commands
vlivanov
parents: 35176
diff changeset
  1580
8dfb205a2886 6985422: flush the output streams before OnError commands
vlivanov
parents: 35176
diff changeset
  1581
    // Flush output and finish logs before running OnError commands.
8dfb205a2886 6985422: flush the output streams before OnError commands
vlivanov
parents: 35176
diff changeset
  1582
    ostream_abort();
8dfb205a2886 6985422: flush the output streams before OnError commands
vlivanov
parents: 35176
diff changeset
  1583
8dfb205a2886 6985422: flush the output streams before OnError commands
vlivanov
parents: 35176
diff changeset
  1584
    out.print_raw_cr("#");
8dfb205a2886 6985422: flush the output streams before OnError commands
vlivanov
parents: 35176
diff changeset
  1585
    out.print_raw   ("# -XX:OnError=\"");
8dfb205a2886 6985422: flush the output streams before OnError commands
vlivanov
parents: 35176
diff changeset
  1586
    out.print_raw   (OnError);
8dfb205a2886 6985422: flush the output streams before OnError commands
vlivanov
parents: 35176
diff changeset
  1587
    out.print_raw_cr("\"");
8dfb205a2886 6985422: flush the output streams before OnError commands
vlivanov
parents: 35176
diff changeset
  1588
8dfb205a2886 6985422: flush the output streams before OnError commands
vlivanov
parents: 35176
diff changeset
  1589
    char* cmd;
8dfb205a2886 6985422: flush the output streams before OnError commands
vlivanov
parents: 35176
diff changeset
  1590
    const char* ptr = OnError;
8dfb205a2886 6985422: flush the output streams before OnError commands
vlivanov
parents: 35176
diff changeset
  1591
    while ((cmd = next_OnError_command(buffer, sizeof(buffer), &ptr)) != NULL){
8dfb205a2886 6985422: flush the output streams before OnError commands
vlivanov
parents: 35176
diff changeset
  1592
      out.print_raw   ("#   Executing ");
8dfb205a2886 6985422: flush the output streams before OnError commands
vlivanov
parents: 35176
diff changeset
  1593
#if defined(LINUX) || defined(_ALLBSD_SOURCE)
8dfb205a2886 6985422: flush the output streams before OnError commands
vlivanov
parents: 35176
diff changeset
  1594
      out.print_raw   ("/bin/sh -c ");
8dfb205a2886 6985422: flush the output streams before OnError commands
vlivanov
parents: 35176
diff changeset
  1595
#elif defined(SOLARIS)
8dfb205a2886 6985422: flush the output streams before OnError commands
vlivanov
parents: 35176
diff changeset
  1596
      out.print_raw   ("/usr/bin/sh -c ");
49725
e740e1a38c96 8200550: Xcode 9.3 produce warning -Wexpansion-to-defined
kbarrett
parents: 49653
diff changeset
  1597
#elif defined(_WINDOWS)
46476
8ead62daaa47 8177522: -XX:OnOutOfMemoryError does not work if supplied twice on windows
vkempik
parents: 46320
diff changeset
  1598
      out.print_raw   ("cmd /C ");
35568
8dfb205a2886 6985422: flush the output streams before OnError commands
vlivanov
parents: 35176
diff changeset
  1599
#endif
8dfb205a2886 6985422: flush the output streams before OnError commands
vlivanov
parents: 35176
diff changeset
  1600
      out.print_raw   ("\"");
8dfb205a2886 6985422: flush the output streams before OnError commands
vlivanov
parents: 35176
diff changeset
  1601
      out.print_raw   (cmd);
8dfb205a2886 6985422: flush the output streams before OnError commands
vlivanov
parents: 35176
diff changeset
  1602
      out.print_raw_cr("\" ...");
8dfb205a2886 6985422: flush the output streams before OnError commands
vlivanov
parents: 35176
diff changeset
  1603
8dfb205a2886 6985422: flush the output streams before OnError commands
vlivanov
parents: 35176
diff changeset
  1604
      if (os::fork_and_exec(cmd) < 0) {
37113
5a33bf5089ac 8148425: strerror() function is not thread-safe
stuefe
parents: 36320
diff changeset
  1605
        out.print_cr("os::fork_and_exec failed: %s (%s=%d)",
5a33bf5089ac 8148425: strerror() function is not thread-safe
stuefe
parents: 36320
diff changeset
  1606
                     os::strerror(errno), os::errno_name(errno), errno);
35568
8dfb205a2886 6985422: flush the output streams before OnError commands
vlivanov
parents: 35176
diff changeset
  1607
      }
8dfb205a2886 6985422: flush the output streams before OnError commands
vlivanov
parents: 35176
diff changeset
  1608
    }
8dfb205a2886 6985422: flush the output streams before OnError commands
vlivanov
parents: 35176
diff changeset
  1609
8dfb205a2886 6985422: flush the output streams before OnError commands
vlivanov
parents: 35176
diff changeset
  1610
    // done with OnError
8dfb205a2886 6985422: flush the output streams before OnError commands
vlivanov
parents: 35176
diff changeset
  1611
    OnError = NULL;
8dfb205a2886 6985422: flush the output streams before OnError commands
vlivanov
parents: 35176
diff changeset
  1612
  }
8dfb205a2886 6985422: flush the output streams before OnError commands
vlivanov
parents: 35176
diff changeset
  1613
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1614
  if (!UseOSErrorReporting) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1615
    // os::abort() will call abort hooks, try it first.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1616
    static bool skip_os_abort = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1617
    if (!skip_os_abort) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1618
      skip_os_abort = true;
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1619
      bool dump_core = should_report_bug(_id);
30240
a7ba42fa1df6 8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents: 30125
diff changeset
  1620
      os::abort(dump_core && CreateCoredumpOnCrash, _siginfo, _context);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1621
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1622
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1623
    // if os::abort() doesn't abort, try os::die();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1624
    os::die();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1625
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1626
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1627
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1628
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1629
 * OnOutOfMemoryError scripts/commands executed while VM is a safepoint - this
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1630
 * ensures utilities such as jmap can observe the process is a consistent state.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1631
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1632
class VM_ReportJavaOutOfMemory : public VM_Operation {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1633
 private:
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1634
  const char* _message;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1635
 public:
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1636
  VM_ReportJavaOutOfMemory(const char* message) { _message = message; }
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1637
  VMOp_Type type() const                        { return VMOp_ReportJavaOutOfMemory; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1638
  void doit();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1639
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1640
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1641
void VM_ReportJavaOutOfMemory::doit() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1642
  // Don't allocate large buffer on stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1643
  static char buffer[O_BUFLEN];
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1644
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1645
  tty->print_cr("#");
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1646
  tty->print_cr("# java.lang.OutOfMemoryError: %s", _message);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1647
  tty->print_cr("# -XX:OnOutOfMemoryError=\"%s\"", OnOutOfMemoryError);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1648
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1649
  // make heap parsability
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1650
  Universe::heap()->ensure_parsability(false);  // no need to retire TLABs
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1651
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1652
  char* cmd;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1653
  const char* ptr = OnOutOfMemoryError;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1654
  while ((cmd = next_OnError_command(buffer, sizeof(buffer), &ptr)) != NULL){
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1655
    tty->print("#   Executing ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1656
#if defined(LINUX)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1657
    tty->print  ("/bin/sh -c ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1658
#elif defined(SOLARIS)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1659
    tty->print  ("/usr/bin/sh -c ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1660
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1661
    tty->print_cr("\"%s\"...", cmd);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1662
52109
101c2b6eacbe 8027434: "-XX:OnOutOfMemoryError" uses fork instead of vfork
mchinnathamb
parents: 51834
diff changeset
  1663
    if (os::fork_and_exec(cmd, true) < 0) {
37113
5a33bf5089ac 8148425: strerror() function is not thread-safe
stuefe
parents: 36320
diff changeset
  1664
      tty->print_cr("os::fork_and_exec failed: %s (%s=%d)",
5a33bf5089ac 8148425: strerror() function is not thread-safe
stuefe
parents: 36320
diff changeset
  1665
                     os::strerror(errno), os::errno_name(errno), errno);
30745
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents: 30622
diff changeset
  1666
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1667
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1668
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1669
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1670
void VMError::report_java_out_of_memory(const char* message) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1671
  if (OnOutOfMemoryError && OnOutOfMemoryError[0]) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1672
    MutexLocker ml(Heap_lock);
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32583
diff changeset
  1673
    VM_ReportJavaOutOfMemory op(message);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1674
    VMThread::execute(&op);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1675
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1676
}
34305
e399e6b44631 8136978: Much nearly duplicated code for vmError support
sebastian
parents: 34139
diff changeset
  1677
e399e6b44631 8136978: Much nearly duplicated code for vmError support
sebastian
parents: 34139
diff changeset
  1678
void VMError::show_message_box(char *buf, int buflen) {
e399e6b44631 8136978: Much nearly duplicated code for vmError support
sebastian
parents: 34139
diff changeset
  1679
  bool yes;
e399e6b44631 8136978: Much nearly duplicated code for vmError support
sebastian
parents: 34139
diff changeset
  1680
  do {
e399e6b44631 8136978: Much nearly duplicated code for vmError support
sebastian
parents: 34139
diff changeset
  1681
    error_string(buf, buflen);
e399e6b44631 8136978: Much nearly duplicated code for vmError support
sebastian
parents: 34139
diff changeset
  1682
    yes = os::start_debugging(buf,buflen);
e399e6b44631 8136978: Much nearly duplicated code for vmError support
sebastian
parents: 34139
diff changeset
  1683
  } while (yes);
e399e6b44631 8136978: Much nearly duplicated code for vmError support
sebastian
parents: 34139
diff changeset
  1684
}
46284
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1685
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1686
// Timeout handling: check if a timeout happened (either a single step did
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1687
// timeout or the whole of error reporting hit ErrorLogTimeout). Interrupt
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1688
// the reporting thread if that is the case.
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1689
bool VMError::check_timeout() {
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1690
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1691
  if (ErrorLogTimeout == 0) {
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1692
    return false;
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1693
  }
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1694
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1695
  // Do not check for timeouts if we still have a message box to show to the
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1696
  // user or if there are OnError handlers to be run.
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1697
  if (ShowMessageBoxOnError
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1698
      || (OnError != NULL && OnError[0] != '\0')
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1699
      || Arguments::abort_hook() != NULL) {
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1700
    return false;
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1701
  }
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1702
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1703
  const jlong reporting_start_time_l = get_reporting_start_time();
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1704
  const jlong now = get_current_timestamp();
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1705
  // Timestamp is stored in nanos.
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1706
  if (reporting_start_time_l > 0) {
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1707
    const jlong end = reporting_start_time_l + (jlong)ErrorLogTimeout * TIMESTAMP_TO_SECONDS_FACTOR;
55239
74832e7b5cad 8188872: runtime/ErrorHandling/TimeoutInErrorHandlingTest.java fails intermittently
dcubed
parents: 54897
diff changeset
  1708
    if (end <= now && !_reporting_did_timeout) {
74832e7b5cad 8188872: runtime/ErrorHandling/TimeoutInErrorHandlingTest.java fails intermittently
dcubed
parents: 54897
diff changeset
  1709
      // We hit ErrorLogTimeout and we haven't interrupted the reporting
74832e7b5cad 8188872: runtime/ErrorHandling/TimeoutInErrorHandlingTest.java fails intermittently
dcubed
parents: 54897
diff changeset
  1710
      // thread yet.
46284
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1711
      _reporting_did_timeout = true;
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1712
      interrupt_reporting_thread();
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1713
      return true; // global timeout
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1714
    }
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1715
  }
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1716
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1717
  const jlong step_start_time_l = get_step_start_time();
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1718
  if (step_start_time_l > 0) {
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1719
    // A step times out after a quarter of the total timeout. Steps are mostly fast unless they
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1720
    // hang for some reason, so this simple rule allows for three hanging step and still
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1721
    // hopefully leaves time enough for the rest of the steps to finish.
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1722
    const jlong end = step_start_time_l + (jlong)ErrorLogTimeout * TIMESTAMP_TO_SECONDS_FACTOR / 4;
55239
74832e7b5cad 8188872: runtime/ErrorHandling/TimeoutInErrorHandlingTest.java fails intermittently
dcubed
parents: 54897
diff changeset
  1723
    if (end <= now && !_step_did_timeout) {
74832e7b5cad 8188872: runtime/ErrorHandling/TimeoutInErrorHandlingTest.java fails intermittently
dcubed
parents: 54897
diff changeset
  1724
      // The step timed out and we haven't interrupted the reporting
74832e7b5cad 8188872: runtime/ErrorHandling/TimeoutInErrorHandlingTest.java fails intermittently
dcubed
parents: 54897
diff changeset
  1725
      // thread yet.
46284
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1726
      _step_did_timeout = true;
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1727
      interrupt_reporting_thread();
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1728
      return false; // (Not a global timeout)
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1729
    }
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1730
  }
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1731
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1732
  return false;
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1733
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1734
}
ad578adff5df 8166944: Hanging Error Reporting steps may lead to torn error logs.
stuefe
parents: 40655
diff changeset
  1735
46589
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1736
#ifndef PRODUCT
50015
d0a350777bd1 8202319: Fix compilation warnings in Solaris debug builds for DevStudio 12.6
kbarrett
parents: 49980
diff changeset
  1737
#if defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x5140
d0a350777bd1 8202319: Fix compilation warnings in Solaris debug builds for DevStudio 12.6
kbarrett
parents: 49980
diff changeset
  1738
#pragma error_messages(off, SEC_NULL_PTR_DEREF)
d0a350777bd1 8202319: Fix compilation warnings in Solaris debug builds for DevStudio 12.6
kbarrett
parents: 49980
diff changeset
  1739
#endif
46589
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1740
typedef void (*voidfun_t)();
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1741
// Crash with an authentic sigfpe
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1742
static void crash_with_sigfpe() {
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1743
  // generate a native synchronous SIGFPE where possible;
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1744
  // if that did not cause a signal (e.g. on ppc), just
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1745
  // raise the signal.
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1746
  volatile int x = 0;
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1747
  volatile int y = 1/x;
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1748
#ifndef _WIN32
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1749
  // OSX implements raise(sig) incorrectly so we need to
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1750
  // explicitly target the current thread
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1751
  pthread_kill(pthread_self(), SIGFPE);
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1752
#endif
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1753
} // end: crash_with_sigfpe
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1754
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1755
// crash with sigsegv at non-null address.
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1756
static void crash_with_segfault() {
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1757
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1758
  char* const crash_addr = (char*) VMError::get_segfault_address();
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1759
  *crash_addr = 'X';
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1760
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1761
} // end: crash_with_segfault
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1762
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1763
void VMError::test_error_handler() {
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1764
  controlled_crash(ErrorHandlerTest);
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1765
}
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1766
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1767
// crash in a controlled way:
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1768
// how can be one of:
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1769
// 1,2 - asserts
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1770
// 3,4 - guarantee
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1771
// 5-7 - fatal
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1772
// 8 - vm_exit_out_of_memory
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1773
// 9 - ShouldNotCallThis
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1774
// 10 - ShouldNotReachHere
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1775
// 11 - Unimplemented
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1776
// 12,13 - (not guaranteed) crashes
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1777
// 14 - SIGSEGV
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1778
// 15 - SIGFPE
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1779
void VMError::controlled_crash(int how) {
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1780
  if (how == 0) return;
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1781
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1782
  // If asserts are disabled, use the corresponding guarantee instead.
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1783
  NOT_DEBUG(if (how <= 2) how += 2);
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1784
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1785
  const char* const str = "hello";
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1786
  const size_t      num = (size_t)os::vm_page_size();
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1787
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1788
  const char* const eol = os::line_separator();
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1789
  const char* const msg = "this message should be truncated during formatting";
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1790
  char * const dataPtr = NULL;  // bad data pointer
54284
a2897fb258f1 8221175: Fix bad function case for controlled JVM crash on PPC64 big-endian
gromero
parents: 54031
diff changeset
  1791
  const void (*funcPtr)(void);  // bad function pointer
a2897fb258f1 8221175: Fix bad function case for controlled JVM crash on PPC64 big-endian
gromero
parents: 54031
diff changeset
  1792
a2897fb258f1 8221175: Fix bad function case for controlled JVM crash on PPC64 big-endian
gromero
parents: 54031
diff changeset
  1793
#if defined(PPC64) && !defined(ABI_ELFv2)
a2897fb258f1 8221175: Fix bad function case for controlled JVM crash on PPC64 big-endian
gromero
parents: 54031
diff changeset
  1794
  struct FunctionDescriptor functionDescriptor;
a2897fb258f1 8221175: Fix bad function case for controlled JVM crash on PPC64 big-endian
gromero
parents: 54031
diff changeset
  1795
a2897fb258f1 8221175: Fix bad function case for controlled JVM crash on PPC64 big-endian
gromero
parents: 54031
diff changeset
  1796
  functionDescriptor.set_entry((address) 0xF);
a2897fb258f1 8221175: Fix bad function case for controlled JVM crash on PPC64 big-endian
gromero
parents: 54031
diff changeset
  1797
  funcPtr = (const void(*)()) &functionDescriptor;
a2897fb258f1 8221175: Fix bad function case for controlled JVM crash on PPC64 big-endian
gromero
parents: 54031
diff changeset
  1798
#else
a2897fb258f1 8221175: Fix bad function case for controlled JVM crash on PPC64 big-endian
gromero
parents: 54031
diff changeset
  1799
  funcPtr = (const void(*)()) 0xF;
a2897fb258f1 8221175: Fix bad function case for controlled JVM crash on PPC64 big-endian
gromero
parents: 54031
diff changeset
  1800
#endif
46589
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1801
48105
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47765
diff changeset
  1802
  // Keep this in sync with test/hotspot/jtreg/runtime/ErrorHandling/ErrorHandler.java
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47765
diff changeset
  1803
  // which tests cases 1 thru 13.
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47765
diff changeset
  1804
  // Case 14 is tested by test/hotspot/jtreg/runtime/ErrorHandling/SafeFetchInErrorHandlingTest.java.
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47765
diff changeset
  1805
  // Case 15 is tested by test/hotspot/jtreg/runtime/ErrorHandling/SecondaryErrorTest.java.
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47765
diff changeset
  1806
  // Case 16 is tested by test/hotspot/jtreg/runtime/ErrorHandling/ThreadsListHandleInErrorHandlingTest.java.
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47765
diff changeset
  1807
  // Case 17 is tested by test/hotspot/jtreg/runtime/ErrorHandling/NestedThreadsListHandleInErrorHandlingTest.java.
50718
5698cf4e50f1 8205195: NestedThreadsListHandleInErrorHandlingTest fails because hs_err doesn't contain _nested_thread_list_max
dcubed
parents: 50196
diff changeset
  1808
57699
4aea554692aa 8226228: Make Threads_lock an always safepoint checked lock.
rehn
parents: 55653
diff changeset
  1809
  // We try to grab Threads_lock to keep ThreadsSMRSupport::print_info_on()
50718
5698cf4e50f1 8205195: NestedThreadsListHandleInErrorHandlingTest fails because hs_err doesn't contain _nested_thread_list_max
dcubed
parents: 50196
diff changeset
  1810
  // from racing with Threads::add() or Threads::remove() as we
5698cf4e50f1 8205195: NestedThreadsListHandleInErrorHandlingTest fails because hs_err doesn't contain _nested_thread_list_max
dcubed
parents: 50196
diff changeset
  1811
  // generate the hs_err_pid file. This makes our ErrorHandling tests
5698cf4e50f1 8205195: NestedThreadsListHandleInErrorHandlingTest fails because hs_err doesn't contain _nested_thread_list_max
dcubed
parents: 50196
diff changeset
  1812
  // more stable.
57699
4aea554692aa 8226228: Make Threads_lock an always safepoint checked lock.
rehn
parents: 55653
diff changeset
  1813
  if (!Threads_lock->owned_by_self()) {
4aea554692aa 8226228: Make Threads_lock an always safepoint checked lock.
rehn
parents: 55653
diff changeset
  1814
    Threads_lock->try_lock();
4aea554692aa 8226228: Make Threads_lock an always safepoint checked lock.
rehn
parents: 55653
diff changeset
  1815
    // The VM is going to die so no need to unlock Thread_lock.
4aea554692aa 8226228: Make Threads_lock an always safepoint checked lock.
rehn
parents: 55653
diff changeset
  1816
  }
50718
5698cf4e50f1 8205195: NestedThreadsListHandleInErrorHandlingTest fails because hs_err doesn't contain _nested_thread_list_max
dcubed
parents: 50196
diff changeset
  1817
46589
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1818
  switch (how) {
49653
a569cb4425f3 8191101: Show register content in hs-err file on assert
stuefe
parents: 49334
diff changeset
  1819
    case  1: vmassert(str == NULL, "expected null"); break;
46589
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1820
    case  2: vmassert(num == 1023 && *str == 'X',
49653
a569cb4425f3 8191101: Show register content in hs-err file on assert
stuefe
parents: 49334
diff changeset
  1821
                      "num=" SIZE_FORMAT " str=\"%s\"", num, str); break;
a569cb4425f3 8191101: Show register content in hs-err file on assert
stuefe
parents: 49334
diff changeset
  1822
    case  3: guarantee(str == NULL, "expected null"); break;
46589
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1823
    case  4: guarantee(num == 1023 && *str == 'X',
49653
a569cb4425f3 8191101: Show register content in hs-err file on assert
stuefe
parents: 49334
diff changeset
  1824
                       "num=" SIZE_FORMAT " str=\"%s\"", num, str); break;
a569cb4425f3 8191101: Show register content in hs-err file on assert
stuefe
parents: 49334
diff changeset
  1825
    case  5: fatal("expected null"); break;
a569cb4425f3 8191101: Show register content in hs-err file on assert
stuefe
parents: 49334
diff changeset
  1826
    case  6: fatal("num=" SIZE_FORMAT " str=\"%s\"", num, str); break;
46589
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1827
    case  7: fatal("%s%s#    %s%s#    %s%s#    %s%s#    %s%s#    "
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1828
                   "%s%s#    %s%s#    %s%s#    %s%s#    %s%s#    "
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1829
                   "%s%s#    %s%s#    %s%s#    %s%s#    %s",
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1830
                   msg, eol, msg, eol, msg, eol, msg, eol, msg, eol,
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1831
                   msg, eol, msg, eol, msg, eol, msg, eol, msg, eol,
49653
a569cb4425f3 8191101: Show register content in hs-err file on assert
stuefe
parents: 49334
diff changeset
  1832
                   msg, eol, msg, eol, msg, eol, msg, eol, msg); break;
a569cb4425f3 8191101: Show register content in hs-err file on assert
stuefe
parents: 49334
diff changeset
  1833
    case  8: vm_exit_out_of_memory(num, OOM_MALLOC_ERROR, "ChunkPool::allocate"); break;
a569cb4425f3 8191101: Show register content in hs-err file on assert
stuefe
parents: 49334
diff changeset
  1834
    case  9: ShouldNotCallThis(); break;
a569cb4425f3 8191101: Show register content in hs-err file on assert
stuefe
parents: 49334
diff changeset
  1835
    case 10: ShouldNotReachHere(); break;
a569cb4425f3 8191101: Show register content in hs-err file on assert
stuefe
parents: 49334
diff changeset
  1836
    case 11: Unimplemented(); break;
46589
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1837
    // There's no guarantee the bad data pointer will crash us
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1838
    // so "break" out to the ShouldNotReachHere().
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1839
    case 12: *dataPtr = '\0'; break;
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1840
    // There's no guarantee the bad function pointer will crash us
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1841
    // so "break" out to the ShouldNotReachHere().
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1842
    case 13: (*funcPtr)(); break;
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1843
    case 14: crash_with_segfault(); break;
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1844
    case 15: crash_with_sigfpe(); break;
48105
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47765
diff changeset
  1845
    case 16: {
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47765
diff changeset
  1846
      ThreadsListHandle tlh;
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47765
diff changeset
  1847
      fatal("Force crash with an active ThreadsListHandle.");
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47765
diff changeset
  1848
    }
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47765
diff changeset
  1849
    case 17: {
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47765
diff changeset
  1850
      ThreadsListHandle tlh;
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47765
diff changeset
  1851
      {
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47765
diff changeset
  1852
        ThreadsListHandle tlh2;
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47765
diff changeset
  1853
        fatal("Force crash with a nested ThreadsListHandle.");
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47765
diff changeset
  1854
      }
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47765
diff changeset
  1855
    }
46589
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1856
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1857
    default: tty->print_cr("ERROR: %d: unexpected test_num value.", how);
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1858
  }
49653
a569cb4425f3 8191101: Show register content in hs-err file on assert
stuefe
parents: 49334
diff changeset
  1859
  tty->print_cr("VMError::controlled_crash: survived intentional crash. Did you suppress the assert?");
46589
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1860
  ShouldNotReachHere();
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1861
}
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46560
diff changeset
  1862
#endif // !PRODUCT