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