STX
1.0.0
|
Go to the source code of this file.
Namespaces | |
stx | |
stx::this_thread | |
Typedefs | |
using | stx::PanicHook = decltype(panic_handler) * |
using | stx::AtomicPanicHook = std::atomic< PanicHook > |
Functions | |
STX_EXPORT bool | stx::this_thread::is_panicking () noexcept |
STX_EXPORT bool | stx::panic_hook_visible () noexcept |
STX_LOCAL bool | stx::attach_panic_hook (PanicHook hook) noexcept |
STX_LOCAL bool | stx::take_panic_hook (PanicHook *hook) noexcept |
Variables | |
constexpr bool | stx::kPanicHookVisible = false |
Copyright (c) 2020 Basit Ayantunde
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Hooks are useful for writing device drivers where you load the drivers at runtime as a DLL. As the default behaviour is to log to stderr and abort, In drivers and safety-critical software, You often don't want a driver failure to cause the whole program to immediately cause the whole program to abort due to a panic from the drivers. Hooks allow you to control the panic behaviour at runtime.
You might have to do some extra demangling as it is not exposed via a C ABI for consistency and internal reasons.
Process:
has_panic_hook()
attach_panic_hook(my_handler)
or reset the exisiting panic hook back to the default: take_panic_hook(&installed_handler)