Wed, 22 Jan 2014 17:42:23 -0800
Merge
nloodin@3783 | 1 | /* |
mikael@6198 | 2 | * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. |
nloodin@3783 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
nloodin@3783 | 4 | * |
nloodin@3783 | 5 | * This code is free software; you can redistribute it and/or modify it |
nloodin@3783 | 6 | * under the terms of the GNU General Public License version 2 only, as |
nloodin@3783 | 7 | * published by the Free Software Foundation. |
nloodin@3783 | 8 | * |
nloodin@3783 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
nloodin@3783 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
nloodin@3783 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
nloodin@3783 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
nloodin@3783 | 13 | * accompanied this code). |
nloodin@3783 | 14 | * |
nloodin@3783 | 15 | * You should have received a copy of the GNU General Public License version |
nloodin@3783 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
nloodin@3783 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
nloodin@3783 | 18 | * |
nloodin@3783 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
nloodin@3783 | 20 | * or visit www.oracle.com if you need additional information or have any |
nloodin@3783 | 21 | * questions. |
nloodin@3783 | 22 | * |
nloodin@3783 | 23 | */ |
nloodin@3783 | 24 | |
nloodin@3783 | 25 | #ifndef OS_POSIX_VM_OS_POSIX_HPP |
nloodin@3783 | 26 | #define OS_POSIX_VM_OS_POSIX_HPP |
nloodin@3783 | 27 | class Posix { |
nloodin@3783 | 28 | friend class os; |
nloodin@3783 | 29 | |
nloodin@3783 | 30 | protected: |
nloodin@3783 | 31 | static void print_distro_info(outputStream* st); |
nloodin@3783 | 32 | static void print_rlimit_info(outputStream* st); |
nloodin@3783 | 33 | static void print_uname_info(outputStream* st); |
nloodin@3783 | 34 | static void print_libversion_info(outputStream* st); |
nloodin@3783 | 35 | static void print_load_average(outputStream* st); |
nloodin@3783 | 36 | |
goetz@6460 | 37 | public: |
goetz@6460 | 38 | |
goetz@6460 | 39 | // Returns true if signal is valid. |
goetz@6460 | 40 | static bool is_valid_signal(int sig); |
goetz@6460 | 41 | |
goetz@6460 | 42 | // Helper function, returns a string (e.g. "SIGILL") for a signal. |
goetz@6460 | 43 | // Returned string is a constant. For unknown signals "UNKNOWN" is returned. |
goetz@6460 | 44 | static const char* get_signal_name(int sig, char* out, size_t outlen); |
goetz@6460 | 45 | |
goetz@6460 | 46 | // Returns one-line short description of a signal set in a user provided buffer. |
goetz@6460 | 47 | static const char* describe_signal_set_short(const sigset_t* set, char* buffer, size_t size); |
goetz@6460 | 48 | |
goetz@6460 | 49 | // Prints a short one-line description of a signal set. |
goetz@6460 | 50 | static void print_signal_set_short(outputStream* st, const sigset_t* set); |
goetz@6460 | 51 | |
goetz@6460 | 52 | // Writes a one-line description of a combination of sigaction.sa_flags |
goetz@6460 | 53 | // into a user provided buffer. Returns that buffer. |
goetz@6460 | 54 | static const char* describe_sa_flags(int flags, char* buffer, size_t size); |
goetz@6460 | 55 | |
goetz@6460 | 56 | // Prints a one-line description of a combination of sigaction.sa_flags. |
goetz@6460 | 57 | static void print_sa_flags(outputStream* st, int flags); |
goetz@6460 | 58 | |
goetz@6460 | 59 | // A POSIX conform, platform-independend siginfo print routine. |
goetz@6460 | 60 | static void print_siginfo_brief(outputStream* os, const siginfo_t* si); |
nloodin@3783 | 61 | |
nloodin@3783 | 62 | }; |
nloodin@3783 | 63 | |
rbackman@5424 | 64 | /* |
rbackman@5424 | 65 | * Crash protection for the watcher thread. Wrap the callback |
rbackman@5424 | 66 | * with a sigsetjmp and in case of a SIGSEGV/SIGBUS we siglongjmp |
rbackman@5424 | 67 | * back. |
rbackman@5424 | 68 | * To be able to use this - don't take locks, don't rely on destructors, |
rbackman@5424 | 69 | * don't make OS library calls, don't allocate memory, don't print, |
rbackman@5424 | 70 | * don't call code that could leave the heap / memory in an inconsistent state, |
rbackman@5424 | 71 | * or anything else where we are not in control if we suddenly jump out. |
rbackman@5424 | 72 | */ |
rbackman@5424 | 73 | class WatcherThreadCrashProtection : public StackObj { |
rbackman@5424 | 74 | public: |
rbackman@5424 | 75 | WatcherThreadCrashProtection(); |
rbackman@5424 | 76 | bool call(os::CrashProtectionCallback& cb); |
rbackman@5424 | 77 | |
rbackman@5424 | 78 | static void check_crash_protection(int signal, Thread* thread); |
rbackman@5424 | 79 | private: |
rbackman@5424 | 80 | void restore(); |
rbackman@5424 | 81 | sigjmp_buf _jmpbuf; |
rbackman@5424 | 82 | }; |
nloodin@3783 | 83 | |
goetz@6460 | 84 | #endif // OS_POSIX_VM_OS_POSIX_HPP |