vmError.hpp revision 1879
0N/A/*
553N/A * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
553N/A * published by the Free Software Foundation.
0N/A *
553N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
0N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0N/A * or visit www.oracle.com if you need additional information or have any
553N/A * questions.
553N/A *
553N/A */
0N/A
0N/A#ifndef SHARE_VM_UTILITIES_VMERROR_HPP
0N/A#define SHARE_VM_UTILITIES_VMERROR_HPP
0N/A
0N/A#include "utilities/globalDefinitions.hpp"
0N/A
0N/A
0N/Aclass VM_ReportJavaOutOfMemory;
0N/A
0N/Aclass VMError : public StackObj {
0N/A friend class VM_ReportJavaOutOfMemory;
0N/A
0N/A enum ErrorType {
0N/A internal_error = 0xe0000000,
0N/A oom_error = 0xe0000001
580N/A };
0N/A int _id; // Solaris/Linux signals: 0 - SIGRTMAX
0N/A // Windows exceptions: 0xCxxxxxxx system errors
0N/A // 0x8xxxxxxx system warnings
0N/A
110N/A const char * _message;
0N/A const char * _detail_msg;
110N/A
110N/A Thread * _thread; // NULL if it's native thread
0N/A
0N/A
0N/A // additional info for crashes
0N/A address _pc; // faulting PC
0N/A void * _siginfo; // ExceptionRecord on Windows,
0N/A // siginfo_t on Solaris/Linux
0N/A void * _context; // ContextRecord on Windows,
0N/A // ucontext_t on Solaris/Linux
0N/A
0N/A // additional info for VM internal errors
0N/A const char * _filename;
0N/A int _lineno;
0N/A
0N/A // used by fatal error handler
0N/A int _current_step;
0N/A const char * _current_step_info;
0N/A int _verbose;
0N/A // First error, and its thread id. We must be able to handle native thread,
0N/A // so use thread id instead of Thread* to identify thread.
0N/A static VMError* volatile first_error;
0N/A static volatile jlong first_error_tid;
0N/A
0N/A // used by reporting about OOM
0N/A size_t _size;
0N/A
0N/A // set signal handlers on Solaris/Linux or the default exception filter
0N/A // on Windows, to handle recursive crashes.
0N/A void reset_signal_handlers();
0N/A
0N/A // handle -XX:+ShowMessageBoxOnError. buf is used to format the message string
0N/A void show_message_box(char* buf, int buflen);
0N/A
0N/A // generate an error report
0N/A void report(outputStream* st);
110N/A
110N/A // generate a stack trace
0N/A static void print_stack_trace(outputStream* st, JavaThread* jt,
0N/A char* buf, int buflen, bool verbose = false);
0N/A
0N/A // accessor
0N/A const char* message() const { return _message; }
0N/A const char* detail_msg() const { return _detail_msg; }
0N/A
0N/Apublic:
0N/A // Constructor for crashes
0N/A VMError(Thread* thread, int sig, address pc, void* siginfo, void* context);
0N/A // Constructor for VM internal errors
0N/A VMError(Thread* thread, const char* filename, int lineno,
0N/A const char* message, const char * detail_msg);
0N/A
0N/A // Constructor for VM OOM errors
0N/A VMError(Thread* thread, const char* filename, int lineno, size_t size,
0N/A const char* message);
0N/A // Constructor for non-fatal errors
0N/A VMError(const char* message);
// return a string to describe the error
char *error_string(char* buf, int buflen);
// main error reporting function
void report_and_die();
// reporting OutOfMemoryError
void report_java_out_of_memory();
// returns original flags for signal, if it was resetted, or -1 if
// signal was not changed by error reporter
static int get_resetted_sigflags(int sig);
// returns original handler for signal, if it was resetted, or NULL if
// signal was not changed by error reporter
static address get_resetted_sighandler(int sig);
// check to see if fatal error reporting is in progress
static bool fatal_error_in_progress() { return first_error != NULL; }
};
#endif // SHARE_VM_UTILITIES_VMERROR_HPP