| #pragma once |
| #include <compartment-macros.h> |
| #include <stddef.h> |
| #include <stdint.h> |
| |
| /** |
| * The kind of value, for values that have special-cased handling. |
| */ |
| enum DebugFormatArgumentKind : ptraddr_t |
| { |
| /// Boolean, printed as "true" or "false". |
| DebugFormatArgumentBool, |
| /// Single character. |
| DebugFormatArgumentCharacter, |
| /// Signed 32-bit integer, printed as decimal. |
| DebugFormatArgumentSignedNumber32, |
| /// Unsigned 32-bit integer, printed as hexadecimal |
| DebugFormatArgumentUnsignedNumber32, |
| /// Signed 64-bit integer, printed as decimal. |
| DebugFormatArgumentSignedNumber64, |
| /// Unsigned 64-bit integer, printed as hexadecimal. |
| DebugFormatArgumentUnsignedNumber64, |
| /// Pointer, printed as a full capability. |
| DebugFormatArgumentPointer, |
| /// Special case for permission sets, printed as in the capability |
| /// format. |
| DebugFormatArgumentPermissionSet, |
| /// C string, printed as-is. |
| DebugFormatArgumentCString, |
| /// String view, printed as-is. |
| DebugFormatArgumentStringView, |
| }; |
| |
| struct DebugFormatArgument |
| { |
| /** |
| * The value that is being written. |
| */ |
| uintptr_t value; |
| /** |
| * The kind of value that is being written. This is either a pointer |
| * to a `DebugCallback` or one of the `Kind` enumeration, depending on |
| * whether the tag is set or not. |
| */ |
| uintptr_t kind; |
| }; |
| |
| /** |
| * Library function that writes a debug message. This runs with interrupts |
| * disabled (to avoid interleaving) and prints an array of debug messages. This |
| * is intended to allow a single call to print multiple format strings without |
| * requiring the format strings to be copied, so that the debugging APIs can |
| * wrap a user-provided format string. |
| */ |
| __cheri_libcall void |
| debug_log_message_write(const char *context, |
| const char *format, |
| struct DebugFormatArgument *messages, |
| size_t messageCount); |
| |
| /** |
| * Helper to write a debug message reporting an assertion or invariant failure. |
| * This should be used only with the helper macros / templates in `debug.h[h]`. |
| * This takes the kind of failure (for example, assert or invariant), the file, |
| * function, and line number where the failure occurred, a format string, and |
| * an array of arguments to the format string. |
| */ |
| __cheri_libcall void debug_report_failure(const char *kind, |
| const char *file, |
| const char *function, |
| int line, |
| const char *fmt, |
| struct DebugFormatArgument *arguments, |
| size_t argumentCount); |