Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/os/posix/vm/os_posix.hpp
32285 views
/*1* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef OS_POSIX_VM_OS_POSIX_HPP25#define OS_POSIX_VM_OS_POSIX_HPP26class Posix {27friend class os;2829protected:30static void print_distro_info(outputStream* st);31static void print_rlimit_info(outputStream* st);32static void print_uname_info(outputStream* st);33static void print_libversion_info(outputStream* st);34static void print_load_average(outputStream* st);3536public:3738// Returns true if signal is valid.39static bool is_valid_signal(int sig);4041// Helper function, returns a string (e.g. "SIGILL") for a signal.42// Returned string is a constant. For unknown signals "UNKNOWN" is returned.43static const char* get_signal_name(int sig, char* out, size_t outlen);4445// Returns one-line short description of a signal set in a user provided buffer.46static const char* describe_signal_set_short(const sigset_t* set, char* buffer, size_t size);4748// Prints a short one-line description of a signal set.49static void print_signal_set_short(outputStream* st, const sigset_t* set);5051// Writes a one-line description of a combination of sigaction.sa_flags52// into a user provided buffer. Returns that buffer.53static const char* describe_sa_flags(int flags, char* buffer, size_t size);5455// Prints a one-line description of a combination of sigaction.sa_flags.56static void print_sa_flags(outputStream* st, int flags);5758// A POSIX conform, platform-independend siginfo print routine.59static void print_siginfo_brief(outputStream* os, const siginfo_t* si);6061};6263/*64* Crash protection utility used by JFR. Wrap the callback65* with a sigsetjmp and in case of a SIGSEGV/SIGBUS we siglongjmp66* back.67* To be able to use this - don't take locks, don't rely on destructors,68* don't make OS library calls, don't allocate memory, don't print,69* don't call code that could leave the heap / memory in an inconsistent state,70* or anything else where we are not in control if we suddenly jump out.71*/72class ThreadCrashProtection : public StackObj {73public:74static bool is_crash_protected(Thread* thr) {75return _crash_protection != NULL && _protected_thread == thr;76}7778ThreadCrashProtection();79bool call(os::CrashProtectionCallback& cb);8081static void check_crash_protection(int signal, Thread* thread);82private:83static Thread* _protected_thread;84static ThreadCrashProtection* _crash_protection;85static volatile intptr_t _crash_mux;86void restore();87sigjmp_buf _jmpbuf;88};8990#endif // OS_POSIX_VM_OS_POSIX_HPP919293