Preserve ignored error snapshots
Some checks failed
libakerror CI Build / coverage (push) Successful in 3m39s
libakerror CI Build / cmake_build (push) Successful in 6m3s
libakerror CI Build / mutation_test (push) Has been cancelled

This commit is contained in:
2026-08-04 10:44:46 -04:00
parent 4fe7571329
commit 55090d2419
5 changed files with 51 additions and 23 deletions

View File

@@ -173,12 +173,12 @@ extern akerr_ErrorContext AKERR_ARRAY_ERROR[AKERR_MAX_ARRAY_ERROR];
extern akerr_ErrorUnhandledErrorHandler akerr_handler_unhandled_error;
extern akerr_ErrorLogFunction akerr_log_method;
/*
* IGNORE()'s per-thread scratch pointer. It is non-NULL only while IGNORE()
* logs the swallowed error; IGNORE() releases the context and clears this
* pointer before returning to its caller. Thread local only when
* AKERR_THREAD_SAFE is 1.
* IGNORE()'s per-thread snapshot. IGNORE() copies the swallowed error here
* before releasing its pool context, so this remains a useful debugging aid
* after the pool slot is reused. The snapshot is read-only and is replaced by
* the next ignored error. Thread local only when AKERR_THREAD_SAFE is 1.
*/
extern AKERR_THREAD_LOCAL akerr_ErrorContext *__akerr_last_ignored;
static AKERR_THREAD_LOCAL akerr_ErrorContext __akerr_last_ignored;
/*
* Drop one reference, returning NULL once the last one is gone so the caller can
@@ -435,11 +435,20 @@ akerr_ErrorContext AKERR_NOIGNORE *__akerr_copy_string(char *destination, int ca
FINISH_LOGIC(__err_context, true);
#define IGNORE(__stmt) \
__akerr_last_ignored = __stmt; \
if ( __akerr_last_ignored != NULL ) { \
LOG_ERROR_WITH_MESSAGE(__akerr_last_ignored, "** IGNORED ERROR **"); \
RELEASE_ERROR(__akerr_last_ignored); \
}
do { \
akerr_ErrorContext *__akerr_ignored = __stmt; \
if ( __akerr_ignored != NULL ) { \
memcpy(&__akerr_last_ignored, __akerr_ignored, \
sizeof(__akerr_last_ignored)); \
__akerr_last_ignored.stacktracebufptr = \
(char *)&__akerr_last_ignored.stacktracebuf; \
akerr_ErrorContext *__akerr_ignored_snapshot = \
&__akerr_last_ignored; \
LOG_ERROR_WITH_MESSAGE(__akerr_ignored_snapshot, \
"** IGNORED ERROR **"); \
RELEASE_ERROR(__akerr_ignored); \
} \
} while ( 0 )
#define CLEANUP \
};