0N/A/*
2085N/A * Copyright (c) 2003, 2011, 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
0N/A * published by the Free Software Foundation.
0N/A *
0N/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 *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#ifndef SHARE_VM_UTILITIES_VMERROR_HPP
1879N/A#define SHARE_VM_UTILITIES_VMERROR_HPP
1879N/A
1879N/A#include "utilities/globalDefinitions.hpp"
1879N/A
3206N/Aclass Decoder;
0N/Aclass VM_ReportJavaOutOfMemory;
0N/A
0N/Aclass VMError : public StackObj {
0N/A friend class VM_ReportJavaOutOfMemory;
3206N/A friend class Decoder;
0N/A
0N/A enum ErrorType {
0N/A internal_error = 0xe0000000,
0N/A oom_error = 0xe0000001
0N/A };
0N/A int _id; // Solaris/Linux signals: 0 - SIGRTMAX
0N/A // Windows exceptions: 0xCxxxxxxx system errors
0N/A // 0x8xxxxxxx system warnings
0N/A
0N/A const char * _message;
1410N/A const char * _detail_msg;
0N/A
0N/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;
603N/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;
1601N/A // First error, and its thread id. We must be able to handle native thread,
1601N/A // so use thread id instead of Thread* to identify thread.
1601N/A static VMError* volatile first_error;
1601N/A static volatile jlong first_error_tid;
0N/A
2085N/A // Core dump status, false if we have been unable to write a core/minidump for some reason
2085N/A static bool coredump_status;
2085N/A
2085N/A // When coredump_status is set to true this will contain the name/path to the core/minidump,
2085N/A // if coredump_status if false, this will (hopefully) contain a useful error explaining why
2085N/A // no core/minidump has been written to disk
2085N/A static char coredump_message[O_BUFLEN];
2085N/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);
0N/A
1384N/A // generate a stack trace
1384N/A static void print_stack_trace(outputStream* st, JavaThread* jt,
1384N/A char* buf, int buflen, bool verbose = false);
1384N/A
0N/A // accessor
1410N/A const char* message() const { return _message; }
1410N/A const char* detail_msg() const { return _detail_msg; }
1983N/A bool should_report_bug(unsigned int id) { return id != oom_error; }
0N/A
0N/Apublic:
0N/A // Constructor for crashes
1983N/A VMError(Thread* thread, unsigned int sig, address pc, void* siginfo,
1983N/A void* context);
0N/A // Constructor for VM internal errors
1410N/A VMError(Thread* thread, const char* filename, int lineno,
1410N/A const char* message, const char * detail_msg);
0N/A
1410N/A // Constructor for VM OOM errors
1410N/A VMError(Thread* thread, const char* filename, int lineno, size_t size,
1410N/A const char* message);
0N/A // Constructor for non-fatal errors
0N/A VMError(const char* message);
0N/A
0N/A // return a string to describe the error
0N/A char *error_string(char* buf, int buflen);
0N/A
2085N/A // Report status of core/minidump
2085N/A static void report_coredump_status(const char* message, bool status);
2085N/A
0N/A // main error reporting function
0N/A void report_and_die();
0N/A
0N/A // reporting OutOfMemoryError
0N/A void report_java_out_of_memory();
0N/A
0N/A // returns original flags for signal, if it was resetted, or -1 if
0N/A // signal was not changed by error reporter
0N/A static int get_resetted_sigflags(int sig);
0N/A
0N/A // returns original handler for signal, if it was resetted, or NULL if
0N/A // signal was not changed by error reporter
0N/A static address get_resetted_sighandler(int sig);
1601N/A
1601N/A // check to see if fatal error reporting is in progress
1601N/A static bool fatal_error_in_progress() { return first_error != NULL; }
0N/A};
1879N/A
1879N/A#endif // SHARE_VM_UTILITIES_VMERROR_HPP