vmError.hpp revision 2085:63d374c54045
11541Srgrimes/* 21541Srgrimes * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. 31541Srgrimes * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 41541Srgrimes * 51541Srgrimes * This code is free software; you can redistribute it and/or modify it 61541Srgrimes * under the terms of the GNU General Public License version 2 only, as 71541Srgrimes * published by the Free Software Foundation. 81541Srgrimes * 91541Srgrimes * This code is distributed in the hope that it will be useful, but WITHOUT 101541Srgrimes * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 111541Srgrimes * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 121541Srgrimes * version 2 for more details (a copy is included in the LICENSE file that 131541Srgrimes * accompanied this code). 141541Srgrimes * 151541Srgrimes * You should have received a copy of the GNU General Public License version 161541Srgrimes * 2 along with this work; if not, write to the Free Software Foundation, 171541Srgrimes * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 181541Srgrimes * 191541Srgrimes * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 201541Srgrimes * or visit www.oracle.com if you need additional information or have any 211541Srgrimes * questions. 221541Srgrimes * 231541Srgrimes */ 241541Srgrimes 251541Srgrimes#ifndef SHARE_VM_UTILITIES_VMERROR_HPP 261541Srgrimes#define SHARE_VM_UTILITIES_VMERROR_HPP 271541Srgrimes 281541Srgrimes#include "utilities/globalDefinitions.hpp" 291541Srgrimes 301541Srgrimes 311541Srgrimesclass VM_ReportJavaOutOfMemory; 321541Srgrimes 331541Srgrimesclass VMError : public StackObj { 341541Srgrimes friend class VM_ReportJavaOutOfMemory; 351541Srgrimes 361541Srgrimes enum ErrorType { 371541Srgrimes internal_error = 0xe0000000, 381541Srgrimes oom_error = 0xe0000001 3913697Sgibbs }; 401541Srgrimes int _id; // Solaris/Linux signals: 0 - SIGRTMAX 411541Srgrimes // Windows exceptions: 0xCxxxxxxx system errors 422165Spaul // 0x8xxxxxxx system warnings 432865Sbde 442165Spaul const char * _message; 451549Srgrimes const char * _detail_msg; 467566Sjoerg 471549Srgrimes Thread * _thread; // NULL if it's native thread 481541Srgrimes 491541Srgrimes 501541Srgrimes // additional info for crashes 511541Srgrimes address _pc; // faulting PC 521541Srgrimes void * _siginfo; // ExceptionRecord on Windows, 531541Srgrimes // siginfo_t on Solaris/Linux 541541Srgrimes void * _context; // ContextRecord on Windows, 551541Srgrimes // ucontext_t on Solaris/Linux 561541Srgrimes 571541Srgrimes // additional info for VM internal errors 581541Srgrimes const char * _filename; 591541Srgrimes int _lineno; 608876Srgrimes 611541Srgrimes // used by fatal error handler 621541Srgrimes int _current_step; 631541Srgrimes const char * _current_step_info; 641541Srgrimes int _verbose; 651541Srgrimes // First error, and its thread id. We must be able to handle native thread, 661541Srgrimes // so use thread id instead of Thread* to identify thread. 671541Srgrimes static VMError* volatile first_error; 681541Srgrimes static volatile jlong first_error_tid; 691541Srgrimes 701858Sdg // Core dump status, false if we have been unable to write a core/minidump for some reason 711541Srgrimes static bool coredump_status; 721541Srgrimes 731541Srgrimes // When coredump_status is set to true this will contain the name/path to the core/minidump, 741541Srgrimes // if coredump_status if false, this will (hopefully) contain a useful error explaining why 751541Srgrimes // no core/minidump has been written to disk 767090Sbde static char coredump_message[O_BUFLEN]; 777090Sbde 781541Srgrimes // used by reporting about OOM 791541Srgrimes size_t _size; 801541Srgrimes 811541Srgrimes // set signal handlers on Solaris/Linux or the default exception filter 821541Srgrimes // on Windows, to handle recursive crashes. 831541Srgrimes void reset_signal_handlers(); 848504Sdg 851541Srgrimes // handle -XX:+ShowMessageBoxOnError. buf is used to format the message string 861541Srgrimes void show_message_box(char* buf, int buflen); 871541Srgrimes 881541Srgrimes // generate an error report 891541Srgrimes void report(outputStream* st); 901541Srgrimes 911541Srgrimes // generate a stack trace 921541Srgrimes static void print_stack_trace(outputStream* st, JavaThread* jt, 931541Srgrimes char* buf, int buflen, bool verbose = false); 941541Srgrimes 951541Srgrimes // accessor 961541Srgrimes const char* message() const { return _message; } 971541Srgrimes const char* detail_msg() const { return _detail_msg; } 981541Srgrimes bool should_report_bug(unsigned int id) { return id != oom_error; } 991541Srgrimes 1001541Srgrimespublic: 1011541Srgrimes // Constructor for crashes 1021541Srgrimes VMError(Thread* thread, unsigned int sig, address pc, void* siginfo, 1031541Srgrimes void* context); 1041541Srgrimes // Constructor for VM internal errors 1051541Srgrimes VMError(Thread* thread, const char* filename, int lineno, 1061541Srgrimes const char* message, const char * detail_msg); 1071541Srgrimes 1081541Srgrimes // Constructor for VM OOM errors 1091541Srgrimes VMError(Thread* thread, const char* filename, int lineno, size_t size, 1101541Srgrimes const char* message); 1113304Sphk // Constructor for non-fatal errors 1121541Srgrimes VMError(const char* message); 1137612Sdg 1141541Srgrimes // return a string to describe the error 1152059Sdg char *error_string(char* buf, int buflen); 1162059Sdg 1171541Srgrimes // Report status of core/minidump 1181541Srgrimes static void report_coredump_status(const char* message, bool status); 11913446Sphk 1201541Srgrimes // main error reporting function 12113697Sgibbs void report_and_die(); 12213446Sphk 1232112Swollman // reporting OutOfMemoryError 12413446Sphk void report_java_out_of_memory(); 1251541Srgrimes 1261541Srgrimes // returns original flags for signal, if it was resetted, or -1 if 1278215Sdg // signal was not changed by error reporter 1288215Sdg static int get_resetted_sigflags(int sig); 12913414Sphk 1301541Srgrimes // returns original handler for signal, if it was resetted, or NULL if 1318215Sdg // signal was not changed by error reporter 1328215Sdg static address get_resetted_sighandler(int sig); 13313456Sbde 13413456Sbde // check to see if fatal error reporting is in progress 13513456Sbde static bool fatal_error_in_progress() { return first_error != NULL; } 13613456Sbde}; 13713456Sbde 13813456Sbde#endif // SHARE_VM_UTILITIES_VMERROR_HPP 1391541Srgrimes