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