hotspot/src/share/vm/utilities/vmError.hpp
author twisti
Fri, 27 Feb 2009 03:35:40 -0800
changeset 2129 e810a33b5c67
parent 1889 24b003a6fe46
child 2154 72a9b7284ccf
permissions -rw-r--r--
6778669: Patch from Red Hat -- fixes compilation errors Summary: Some fixes which are required to build on recent GCCs. Reviewed-by: never, kvn Contributed-by: langel@redhat.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
2129
e810a33b5c67 6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents: 1889
diff changeset
     2
 * Copyright 2003-2009 Sun Microsystems, Inc.  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
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
class VM_ReportJavaOutOfMemory;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
class VMError : public StackObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
  friend class VM_ReportJavaOutOfMemory;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
  enum ErrorType {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
    internal_error = 0xe0000000,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
    oom_error      = 0xe0000001
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
  int          _id;          // Solaris/Linux signals: 0 - SIGRTMAX
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
                             // Windows exceptions: 0xCxxxxxxx system errors
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
                             //                     0x8xxxxxxx system warnings
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
  const char * _message;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  Thread *     _thread;      // NULL if it's native thread
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  // additional info for crashes
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  address      _pc;          // faulting PC
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  void *       _siginfo;     // ExceptionRecord on Windows,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
                             // siginfo_t on Solaris/Linux
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  void *       _context;     // ContextRecord on Windows,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
                             // ucontext_t on Solaris/Linux
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  // additional info for VM internal errors
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  const char * _filename;
2129
e810a33b5c67 6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents: 1889
diff changeset
    53
  int          _lineno;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  // used by fatal error handler
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  int          _current_step;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  const char * _current_step_info;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  int          _verbose;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  // used by reporting about OOM
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  size_t       _size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  // set signal handlers on Solaris/Linux or the default exception filter
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  // on Windows, to handle recursive crashes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  void reset_signal_handlers();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  // handle -XX:+ShowMessageBoxOnError. buf is used to format the message string
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  void show_message_box(char* buf, int buflen);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  // generate an error report
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  void report(outputStream* st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  // accessor
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  const char* message()         { return _message; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  // Constructor for crashes
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  VMError(Thread* thread, int sig, address pc, void* siginfo, void* context);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  // Constructor for VM internal errors
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  VMError(Thread* thread, const char* message, const char* filename, int lineno);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  // Constructors for VM OOM errors
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  VMError(Thread* thread, size_t size, const char* message, const char* filename, int lineno);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  // Constructor for non-fatal errors
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  VMError(const char* message);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  // return a string to describe the error
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  char *error_string(char* buf, int buflen);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  // main error reporting function
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  void report_and_die();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  // reporting OutOfMemoryError
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  void report_java_out_of_memory();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  // returns original flags for signal, if it was resetted, or -1 if
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  // signal was not changed by error reporter
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  static int get_resetted_sigflags(int sig);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  // returns original handler for signal, if it was resetted, or NULL if
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  // signal was not changed by error reporter
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  static address get_resetted_sighandler(int sig);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
};