|
CX Framework
Cross-platform C utility framework
|
Macros | |
| #define | DBG_CrashInteractive (DBG_CrashExit | DBG_CrashPrompt | DBG_CrashProgressUI) |
| #define | DBG_CrashNonInteractive (DBG_CrashExit | DBG_CrashDump | DBG_CrashUpload | DBG_CrashDelete) |
Typedefs | |
| typedef bool(* | dbgCrashCallback) (bool after) |
Enumerations | |
| enum | DEBUG_CRASH_FLAGS_ENUM { DBG_CrashExit = 0x0001 , DBG_CrashDump = 0x0002 , DBG_CrashFullDump = 0x0004 , DBG_CrashUpload = 0x0008 , DBG_CrashBreakpoint = 0x0010 , DBG_CrashDelete = 0x0020 , DBG_CrashInternal = 0x0040 , DBG_CrashProgressUI = 0x0080 , DBG_CrashDevMode = 0x0100 , DBG_CrashNotify = 0x0200 , DBG_CrashPrompt = 0x1000 , DBG_CrashPromptLocal = 0x3000 } |
Functions | |
| void | dbgCrashSetMode (uint32 mode) |
| uint32 | dbgCrashGetMode () |
| bool | dbgCrashSetPath (strref path) |
| void | dbgCrashAddCallback (dbgCrashCallback cb) |
| void | dbgCrashRemoveCallback (dbgCrashCallback cb) |
| void | dbgCrashIncludeMemory (void *ptr, size_t sz) |
| void | dbgCrashExcludeMemory (void *ptr, size_t sz) |
| void | dbgCrashAddMetaStr (const char *name, const char *val) |
| void | dbgCrashAddMetaInt (const char *name, int val) |
| void | dbgCrashAddVersionStr (const char *name, const char *val) |
| void | dbgCrashAddVersionInt (const char *name, int val) |
| void _no_return | dbgCrashNow (int skipframes) |
Platform-agnostic crash handler with memory dump generation and reporting.
The crash handler system provides:
Typical initialization:
Triggering a controlled crash:
| #define DBG_CrashInteractive (DBG_CrashExit | DBG_CrashPrompt | DBG_CrashProgressUI) |
| #define DBG_CrashNonInteractive (DBG_CrashExit | DBG_CrashDump | DBG_CrashUpload | DBG_CrashDelete) |
| typedef bool(* dbgCrashCallback) (bool after) |
Callback function invoked when a crash occurs
| after | false during initial crash handling (right after exception); true just before process exit |
CRITICAL: Callbacks must be signal-safe. Do NOT perform:
Safe operations:
Callbacks are invoked twice: once during initial exception handling for immediate response, and again just before exit for final cleanup.
Flags controlling crash handler behavior
These flags can be combined with bitwise OR to configure how crashes are handled.
| void dbgCrashAddCallback | ( | dbgCrashCallback | cb | ) |
Register a crash callback function
| cb | Callback to invoke on crash |
Callbacks are deduplicated - adding the same callback multiple times has no effect. All registered callbacks are invoked in registration order.
| void dbgCrashAddMetaInt | ( | const char * | name, |
| int | val | ||
| ) |
Add integer metadata to crash report
| name | Metadata key name |
| val | Integer value |
Like dbgCrashAddMetaStr() but for integer values.
| void dbgCrashAddMetaStr | ( | const char * | name, |
| const char * | val | ||
| ) |
Add string metadata to crash report
| name | Metadata key name |
| val | String value |
Adds crash-specific metadata that appears in the crash report. Should be used for information directly related to the crash condition, called just before triggering a crash.
For runtime metadata that persists across the application lifecycle, use the Black Box system instead.
Metadata is automatically JSON-escaped and included in the crash report payload.
| void dbgCrashAddVersionInt | ( | const char * | name, |
| int | val | ||
| ) |
Add integer version metadata to crash report root
| name | Version field name |
| val | Integer value |
Like dbgCrashAddVersionStr() but for integer values.
| void dbgCrashAddVersionStr | ( | const char * | name, |
| const char * | val | ||
| ) |
Add string version metadata to crash report root
| name | Version field name |
| val | String value |
Adds version information to the root level of crash reports. Typically called during application initialization for version identifiers, build numbers, or configuration that applies to all crashes.
Appears at crash report root level, separate from per-crash metadata.
| void dbgCrashExcludeMemory | ( | void * | ptr, |
| size_t | sz | ||
| ) |
Remove a previously marked memory region from crash dumps
| ptr | Pointer to start of memory region |
| sz | Size of memory region in bytes |
Removes a region previously added with dbgCrashIncludeMemory(). Does NOT exclude automatically selected regions like stacks and data segments.
| uint32 dbgCrashGetMode | ( | ) |
Get current crash handler mode
| void dbgCrashIncludeMemory | ( | void * | ptr, |
| size_t | sz | ||
| ) |
Mark a memory region for inclusion in crash dumps
| ptr | Pointer to start of memory region |
| sz | Size of memory region in bytes |
Ensures the specified memory region is included in minidumps. Useful for capturing circular buffers, shared memory, or other important data structures that might not be automatically included.
Automatically included regions:
| void _no_return dbgCrashNow | ( | int | skipframes | ) |
Trigger crash handler immediately
| skipframes | Number of stack frames to skip in stack trace |
Invokes the crash handler as if a fatal exception occurred. Does not return - process terminates according to configured mode.
Use skipframes to exclude internal error handling frames from the captured stack trace. Pass 0 to include all frames.
Before calling, use dbgCrashAddMetaStr()/dbgCrashAddMetaInt() to add crash-specific context.
| void dbgCrashRemoveCallback | ( | dbgCrashCallback | cb | ) |
Unregister a previously registered crash callback
| cb | Callback to remove |
| void dbgCrashSetMode | ( | uint32 | mode | ) |
Set crash handler behavior mode
| mode | Combination of DEBUG_CRASH_FLAGS_ENUM flags |
Configures how the crash handler behaves when a crash occurs. Thread-safe and can be changed at runtime.
| bool dbgCrashSetPath | ( | strref | path | ) |
Set crash dump output directory
| path | Directory path where crash dumps should be written |
Specifies where crash dump files (.dmp) should be saved. If not set, uses platform-specific default location.