|
CHERIoT RTOS
A compartmentalised RTOS for CHERIoT hardware
|
Conditional debug class. More...
#include <debug.hh>
Classes | |
| struct | Invariant |
| Function-like class for invariants that is expected to be used via the deduction guide as: More... | |
| struct | Assert |
| Function-like class for assertions that is expected to be used via the deduction guide as: More... | |
Public Member Functions | |
| template<typename T, typename... Ts> | |
| Invariant (T, const char *, Ts &&...) -> Invariant< Ts... > | |
| Deduction guide, allows Invariant to be used as if it were a function. | |
| template<typename... Ts> | |
| Assert (bool, const char *, Ts &&...) -> Assert< Ts... > | |
| Deduction guide, allows Assert to be used as if it were a function. | |
| template<typename... Ts> | |
| Assert (auto, const char *, Ts &&...) -> Assert< Ts... > | |
| Deduction guide, allows Assert to be used as if it were a function with a lambda argument. | |
Static Public Member Functions | |
| template<DebugLevel Level = DebugLevel::Information> | |
| static void | log (const char *fmt, auto... args) |
| Log a message. | |
| template<DebugLevel Level = DebugLevel::Information> | |
| static void | log_if (bool condition, const char *fmt, auto... args) |
| template<DebugLevel Level = DebugLevel::Information, DebugConcepts::LazyAssertion Condition> | |
| static void | log_if (Condition condition, const char *fmt, auto... args) |
| template<typename... Args> | |
| static void | report_failure (const char *kind, const char *file, const char *function, int line, const char *fmt, Args... args) |
| Helper to report failure. | |
| template<typename T, typename... Args> | |
| static void | invariant (T condition, const char *fmt, std::tuple< Args... > args=std::make_tuple(), SourceLocation loc=SourceLocation::current()) |
| Overt wrapper function around Invariant. | |
| template<typename T, typename... Args> | |
| static void | assertion (T condition, const char *fmt, std::tuple< Args... > args=std::make_tuple(), SourceLocation loc=SourceLocation::current()) |
| Overt wrapper function around Assert. | |
Conditional debug class.
Used to control conditional output and assertion checking. The first template parameter is a threshold for reporting. Log messages will be printed if they are at or above this threshold.
By default, assertions will be checked if the threshold is Warning or lower. This can be overridden by passing true or false as the third template argument, to explicitly enable or disable assertions.
Invariants are always checked but, by default, will log a message only if the threshold is warning or lower. This can be overridden by passing true or false as the fourth template argument, to explicitly enable or disable verbose messages on invariant failure.
If you wish to reduce verbosity of log messages but still have verbose error messages for invariant failure, you can pass true as the third template argument. This will unconditionally enable assertions and verbose messages from invariants, even if
Uses Context to print additional detail on debug lines. Each line is prefixed with the context string in magenta to make it easy to see debug output from different subsystems in the same trace.
This class is expected to be used as a type alias, something like:
The xmake build system exposes debugOption and debugLevelOption values to define these macros. If debugOption(foo) is used, the option will be exposed as --debug-foo=[y,n], where setting the option to true defines the threshold as Information and false (the default) as None. If debugLevelOption(foo) is used, the user can specify any level from none to critical on the command line.
|
inlinestatic |
Overt wrapper function around Assert.
Sometimes template deduction guides just don't cut it. At the cost of a std::make_tuple at the call site, we can still take advantage of much of the machinery here.
Definition at line 1038 of file debug.hh.
References anonymous_namespace{debug.hh}::SourceLocation::current().
|
inlinestatic |
Overt wrapper function around Invariant.
Sometimes template deduction guides just don't cut it. At the cost of a std::make_tuple at the call site, we can still take advantage of much of the machinery here.
Definition at line 1003 of file debug.hh.
References anonymous_namespace{debug.hh}::SourceLocation::current().
|
inlinestatic |
Log a message.
This function does nothing if the level is less than the threshold.
Definition at line 796 of file debug.hh.
References debug_log_message_write(), make_debug_arguments_list(), and anonymous_namespace{debug.hh}::None.
Referenced by anonymous_namespace{debug.hh}::StackUsageCheck< Mode, Expected, Fn >::~StackUsageCheck().
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Helper to report failure.
This must not take the SourceLocation directly because doing so prevents the compiler from decomposing and subsequently constant-propagating its fields in the caller, resulting in 24 bytes of stack space consumed for every assert or invariant.
Definition at line 864 of file debug.hh.
References anonymous_namespace{debug.hh}::SourceLocation::line(), and make_debug_arguments_list().
Referenced by anonymous_namespace{debug.hh}::ConditionalDebug< Threshold, Context, EnableAssertions, VerboseInvariants >::Assert< Args >::Assert(), anonymous_namespace{debug.hh}::ConditionalDebug< Threshold, Context, EnableAssertions, VerboseInvariants >::Assert< Args >::Assert(), and anonymous_namespace{debug.hh}::ConditionalDebug< Threshold, Context, EnableAssertions, VerboseInvariants >::Invariant< Args >::Invariant().