nloodin@3783: /* mikael@6198: * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. nloodin@3783: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. nloodin@3783: * nloodin@3783: * This code is free software; you can redistribute it and/or modify it nloodin@3783: * under the terms of the GNU General Public License version 2 only, as nloodin@3783: * published by the Free Software Foundation. nloodin@3783: * nloodin@3783: * This code is distributed in the hope that it will be useful, but WITHOUT nloodin@3783: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or nloodin@3783: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License nloodin@3783: * version 2 for more details (a copy is included in the LICENSE file that nloodin@3783: * accompanied this code). nloodin@3783: * nloodin@3783: * You should have received a copy of the GNU General Public License version nloodin@3783: * 2 along with this work; if not, write to the Free Software Foundation, nloodin@3783: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. nloodin@3783: * nloodin@3783: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA nloodin@3783: * or visit www.oracle.com if you need additional information or have any nloodin@3783: * questions. nloodin@3783: * nloodin@3783: */ nloodin@3783: nloodin@3783: #ifndef OS_POSIX_VM_OS_POSIX_HPP nloodin@3783: #define OS_POSIX_VM_OS_POSIX_HPP nloodin@3783: class Posix { nloodin@3783: friend class os; nloodin@3783: nloodin@3783: protected: nloodin@3783: static void print_distro_info(outputStream* st); nloodin@3783: static void print_rlimit_info(outputStream* st); nloodin@3783: static void print_uname_info(outputStream* st); nloodin@3783: static void print_libversion_info(outputStream* st); nloodin@3783: static void print_load_average(outputStream* st); nloodin@3783: goetz@6460: public: goetz@6460: goetz@6460: // Returns true if signal is valid. goetz@6460: static bool is_valid_signal(int sig); goetz@6460: goetz@6460: // Helper function, returns a string (e.g. "SIGILL") for a signal. goetz@6460: // Returned string is a constant. For unknown signals "UNKNOWN" is returned. goetz@6460: static const char* get_signal_name(int sig, char* out, size_t outlen); goetz@6460: goetz@6460: // Returns one-line short description of a signal set in a user provided buffer. goetz@6460: static const char* describe_signal_set_short(const sigset_t* set, char* buffer, size_t size); goetz@6460: goetz@6460: // Prints a short one-line description of a signal set. goetz@6460: static void print_signal_set_short(outputStream* st, const sigset_t* set); goetz@6460: goetz@6460: // Writes a one-line description of a combination of sigaction.sa_flags goetz@6460: // into a user provided buffer. Returns that buffer. goetz@6460: static const char* describe_sa_flags(int flags, char* buffer, size_t size); goetz@6460: goetz@6460: // Prints a one-line description of a combination of sigaction.sa_flags. goetz@6460: static void print_sa_flags(outputStream* st, int flags); goetz@6460: goetz@6460: // A POSIX conform, platform-independend siginfo print routine. goetz@6460: static void print_siginfo_brief(outputStream* os, const siginfo_t* si); nloodin@3783: nloodin@3783: }; nloodin@3783: rbackman@5424: /* rbackman@5424: * Crash protection for the watcher thread. Wrap the callback rbackman@5424: * with a sigsetjmp and in case of a SIGSEGV/SIGBUS we siglongjmp rbackman@5424: * back. rbackman@5424: * To be able to use this - don't take locks, don't rely on destructors, rbackman@5424: * don't make OS library calls, don't allocate memory, don't print, rbackman@5424: * don't call code that could leave the heap / memory in an inconsistent state, rbackman@5424: * or anything else where we are not in control if we suddenly jump out. rbackman@5424: */ rbackman@5424: class WatcherThreadCrashProtection : public StackObj { rbackman@5424: public: rbackman@5424: WatcherThreadCrashProtection(); rbackman@5424: bool call(os::CrashProtectionCallback& cb); rbackman@5424: rbackman@5424: static void check_crash_protection(int signal, Thread* thread); rbackman@5424: private: rbackman@5424: void restore(); rbackman@5424: sigjmp_buf _jmpbuf; rbackman@5424: }; nloodin@3783: goetz@6460: #endif // OS_POSIX_VM_OS_POSIX_HPP