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