hotspot/src/share/vm/utilities/vmError.hpp
author ctornqvi
Wed, 09 Feb 2011 11:08:10 +0100
changeset 8119 81eef1b06988
parent 7719 ef138e2849eb
child 11761 bf460b379a6a
permissions -rw-r--r--
7014918: Improve core/minidump handling in Hotspot Summary: Added Minidump support on Windows, enabled large page core dumps when coredump_filter is present and writing out path/rlimit for core dumps. Reviewed-by: poonam, dsamersoff, sla, coleenp
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
8119
81eef1b06988 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents: 7719
diff changeset
     2
 * Copyright (c) 2003, 2011, 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: 6176
diff changeset
    25
#ifndef SHARE_VM_UTILITIES_VMERROR_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    26
#define SHARE_VM_UTILITIES_VMERROR_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    28
#include "utilities/globalDefinitions.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    29
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
class VM_ReportJavaOutOfMemory;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
class VMError : public StackObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
  friend class VM_ReportJavaOutOfMemory;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
  enum ErrorType {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
    internal_error = 0xe0000000,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
    oom_error      = 0xe0000001
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
  int          _id;          // Solaris/Linux signals: 0 - SIGRTMAX
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
                             // Windows exceptions: 0xCxxxxxxx system errors
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
                             //                     0x8xxxxxxx system warnings
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  const char * _message;
5403
6b0dd9c75dde 6888954: argument formatting for assert() and friends
jcoomes
parents: 5340
diff changeset
    45
  const char * _detail_msg;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  Thread *     _thread;      // NULL if it's native thread
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  // additional info for crashes
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  address      _pc;          // faulting PC
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  void *       _siginfo;     // ExceptionRecord on Windows,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
                             // siginfo_t on Solaris/Linux
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  void *       _context;     // ContextRecord on Windows,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
                             // ucontext_t on Solaris/Linux
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  // additional info for VM internal errors
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  const char * _filename;
2129
e810a33b5c67 6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents: 1889
diff changeset
    59
  int          _lineno;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  // used by fatal error handler
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  int          _current_step;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  const char * _current_step_info;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  int          _verbose;
6176
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5547
diff changeset
    65
  // First error, and its thread id. We must be able to handle native thread,
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5547
diff changeset
    66
  // so use thread id instead of Thread* to identify thread.
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5547
diff changeset
    67
  static VMError* volatile first_error;
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5547
diff changeset
    68
  static volatile jlong    first_error_tid;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
8119
81eef1b06988 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents: 7719
diff changeset
    70
  // Core dump status, false if we have been unable to write a core/minidump for some reason
81eef1b06988 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents: 7719
diff changeset
    71
  static bool coredump_status;
81eef1b06988 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents: 7719
diff changeset
    72
81eef1b06988 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents: 7719
diff changeset
    73
  // When coredump_status is set to true this will contain the name/path to the core/minidump,
81eef1b06988 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents: 7719
diff changeset
    74
  // if coredump_status if false, this will (hopefully) contain a useful error explaining why
81eef1b06988 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents: 7719
diff changeset
    75
  // no core/minidump has been written to disk
81eef1b06988 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents: 7719
diff changeset
    76
  static char coredump_message[O_BUFLEN];
81eef1b06988 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents: 7719
diff changeset
    77
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  // used by reporting about OOM
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  size_t       _size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  // set signal handlers on Solaris/Linux or the default exception filter
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  // on Windows, to handle recursive crashes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  void reset_signal_handlers();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  // handle -XX:+ShowMessageBoxOnError. buf is used to format the message string
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  void show_message_box(char* buf, int buflen);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  // generate an error report
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  void report(outputStream* st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
5340
b838d4165c92 6944503: Improved Zero crash dump
twisti
parents: 2154
diff changeset
    91
  // generate a stack trace
b838d4165c92 6944503: Improved Zero crash dump
twisti
parents: 2154
diff changeset
    92
  static void print_stack_trace(outputStream* st, JavaThread* jt,
b838d4165c92 6944503: Improved Zero crash dump
twisti
parents: 2154
diff changeset
    93
                                char* buf, int buflen, bool verbose = false);
b838d4165c92 6944503: Improved Zero crash dump
twisti
parents: 2154
diff changeset
    94
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  // accessor
5403
6b0dd9c75dde 6888954: argument formatting for assert() and friends
jcoomes
parents: 5340
diff changeset
    96
  const char* message() const    { return _message; }
6b0dd9c75dde 6888954: argument formatting for assert() and friends
jcoomes
parents: 5340
diff changeset
    97
  const char* detail_msg() const { return _detail_msg; }
7719
ef138e2849eb 6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents: 7397
diff changeset
    98
  bool should_report_bug(unsigned int id) { return id != oom_error; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  // Constructor for crashes
7719
ef138e2849eb 6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents: 7397
diff changeset
   102
  VMError(Thread* thread, unsigned int sig, address pc, void* siginfo,
ef138e2849eb 6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents: 7397
diff changeset
   103
          void* context);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  // Constructor for VM internal errors
5403
6b0dd9c75dde 6888954: argument formatting for assert() and friends
jcoomes
parents: 5340
diff changeset
   105
  VMError(Thread* thread, const char* filename, int lineno,
6b0dd9c75dde 6888954: argument formatting for assert() and friends
jcoomes
parents: 5340
diff changeset
   106
          const char* message, const char * detail_msg);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
5403
6b0dd9c75dde 6888954: argument formatting for assert() and friends
jcoomes
parents: 5340
diff changeset
   108
  // Constructor for VM OOM errors
6b0dd9c75dde 6888954: argument formatting for assert() and friends
jcoomes
parents: 5340
diff changeset
   109
  VMError(Thread* thread, const char* filename, int lineno, size_t size,
6b0dd9c75dde 6888954: argument formatting for assert() and friends
jcoomes
parents: 5340
diff changeset
   110
          const char* message);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  // Constructor for non-fatal errors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  VMError(const char* message);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  // return a string to describe the error
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  char *error_string(char* buf, int buflen);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
8119
81eef1b06988 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents: 7719
diff changeset
   117
  // Report status of core/minidump
81eef1b06988 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents: 7719
diff changeset
   118
  static void report_coredump_status(const char* message, bool status);
81eef1b06988 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents: 7719
diff changeset
   119
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  // main error reporting function
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  void report_and_die();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  // reporting OutOfMemoryError
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  void report_java_out_of_memory();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  // returns original flags for signal, if it was resetted, or -1 if
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  // signal was not changed by error reporter
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  static int get_resetted_sigflags(int sig);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  // returns original handler for signal, if it was resetted, or NULL if
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  // signal was not changed by error reporter
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  static address get_resetted_sighandler(int sig);
6176
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5547
diff changeset
   133
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5547
diff changeset
   134
  // check to see if fatal error reporting is in progress
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5547
diff changeset
   135
  static bool fatal_error_in_progress() { return first_error != NULL; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
   137
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
   138
#endif // SHARE_VM_UTILITIES_VMERROR_HPP