From: Arran Cudbard-Bell Date: Tue, 4 Oct 2022 03:03:18 +0000 (-0400) Subject: Record the file and line for strerror calls X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=48812be7643275a725f8cb90a83a12dcd9d264c4;p=thirdparty%2Ffreeradius-server.git Record the file and line for strerror calls Only accessible via the debugger for now --- diff --git a/src/lib/util/atexit.c b/src/lib/util/atexit.c index 2e032bb174f..ecc77065770 100644 --- a/src/lib/util/atexit.c +++ b/src/lib/util/atexit.c @@ -52,10 +52,8 @@ typedef struct { fr_atexit_t func; //!< Function to call. void *uctx; //!< uctx to pass. -#ifndef NDEBUG char const *file; //!< File where this exit handler was added. int line; //!< Line where this exit handler was added. -#endif } fr_atexit_entry_t; /** Head of a list of exit handlers @@ -100,7 +98,7 @@ static int _atexit_entry_free(fr_atexit_entry_t *e) /** Allocate a new exit handler entry * */ -static fr_atexit_entry_t *atexit_entry_alloc(NDEBUG_LOCATION_ARGS +static fr_atexit_entry_t *atexit_entry_alloc(char const *file, int line, fr_atexit_list_t *list, fr_atexit_t func, void const *uctx) { @@ -112,11 +110,8 @@ static fr_atexit_entry_t *atexit_entry_alloc(NDEBUG_LOCATION_ARGS e->list = list; e->func = func; e->uctx = UNCONST(void *, uctx); - -#ifndef NDEBUG e->file = file; e->line = line; -#endif ATEXIT_DEBUG("%s - Thread %u arming %p/%p func=%p, uctx=%p (alloced %s:%u)", __FUNCTION__, (unsigned int)pthread_self(), @@ -211,12 +206,11 @@ do { \ /** Add a free function to be called when the process exits * */ -int _atexit_global(NDEBUG_LOCATION_ARGS - fr_atexit_t func, void const *uctx) +int _atexit_global(char const *file, int line, fr_atexit_t func, void const *uctx) { CHECK_GLOBAL_SETUP(); - if (unlikely(atexit_entry_alloc(NDEBUG_LOCATION_VALS fr_atexit_global, func, uctx) == NULL)) return -1; + if (unlikely(atexit_entry_alloc(file, line, fr_atexit_global, func, uctx) == NULL)) return -1; return 0; } @@ -308,16 +302,10 @@ int fr_atexit_global_trigger_all(void) e = fr_dlist_remove(&fr_atexit_global->head, e); if (talloc_free(to_free) < 0) { fr_strerror_printf_push("atexit handler failed %p/%p func=%p, uctx=%p" -#ifndef NDEBUG - " (alloced %s:%u)" -#endif - , + " (alloced %s:%u)", fr_atexit_global, to_free, - to_free->func, to_free->uctx -#ifndef NDEBUG - , to_free->file, to_free->line -#endif - ); + to_free->func, to_free->uctx, + to_free->file, to_free->line); return -1; } } @@ -365,16 +353,10 @@ int fr_atexit_trigger(bool uctx_scope, fr_atexit_t func, void const *uctx) e = fr_dlist_remove(&fr_atexit_global->head, e); if (talloc_free(to_free) < 0) { fr_strerror_printf_push("atexit handler failed %p/%p func=%p, uctx=%p" -#ifndef NDEBUG - " (alloced %s:%u)" -#endif - , + " (alloced %s:%u)", fr_atexit_global, to_free, - to_free->func, to_free->uctx -#ifndef NDEBUG - , to_free->file, to_free->line -#endif - ); + to_free->func, to_free->uctx, + to_free->file, to_free->line); return -1; } } @@ -407,16 +389,10 @@ do_threads: ee = fr_dlist_remove(&list->head, ee); if (talloc_free(to_free) < 0) { fr_strerror_printf_push("atexit handler failed %p/%p func=%p, uctx=%p" -#ifndef NDEBUG - " (alloced %s:%u)" -#endif - , + " (alloced %s:%u)", list, to_free, - to_free->func, to_free->uctx -#ifndef NDEBUG - , to_free->file, to_free->line -#endif - ); + to_free->func, to_free->uctx, + to_free->file, to_free->line); return -1; } } @@ -474,7 +450,7 @@ static int _thread_local_free(void *list) * - 0 on success. * - -1 on memory allocation failure; */ -int _fr_atexit_thread_local(NDEBUG_LOCATION_ARGS +int _fr_atexit_thread_local(char const *file, int line, fr_atexit_t func, void const *uctx) { CHECK_GLOBAL_SETUP(); @@ -518,7 +494,7 @@ int _fr_atexit_thread_local(NDEBUG_LOCATION_ARGS * *always* freed one way or another. */ pthread_mutex_lock(&fr_atexit_global_mutex); - list->e = atexit_entry_alloc(NDEBUG_LOCATION_VALS + list->e = atexit_entry_alloc(file, line, fr_atexit_threads, _thread_local_free, list); @@ -531,7 +507,7 @@ int _fr_atexit_thread_local(NDEBUG_LOCATION_ARGS /* * Now allocate the actual atexit handler entry */ - if (atexit_entry_alloc(NDEBUG_LOCATION_VALS fr_atexit_thread_local, func, uctx) == NULL) return -1; + if (atexit_entry_alloc(file, line, fr_atexit_thread_local, func, uctx) == NULL) return -1; return 0; } @@ -634,15 +610,10 @@ int fr_atexit_thread_trigger_all(void) ee = fr_dlist_remove(&list->head, ee); if (talloc_free(to_free) < 0) { fr_strerror_printf_push("atexit handler failed %p/%p func=%p, uctx=%p" -#ifndef NDEBUG - " (alloced %s:%u)" -#endif - , + " (alloced %s:%u)", list, to_free, - to_free->func, to_free->uctx -#ifndef NDEBUG - , to_free->file, to_free->line -#endif + to_free->func, to_free->uctx, + to_free->file, to_free->line ); return -1; } diff --git a/src/lib/util/atexit.h b/src/lib/util/atexit.h index 56d5e22df27..cea40c45119 100644 --- a/src/lib/util/atexit.h +++ b/src/lib/util/atexit.h @@ -45,7 +45,7 @@ typedef int(*fr_atexit_t)(void *uctx); int fr_atexit_global_setup(void); -int _atexit_global(NDEBUG_LOCATION_ARGS fr_atexit_t func, void const *uctx); +int _atexit_global(char const *file, int line, fr_atexit_t func, void const *uctx); /** Add a free function to the global free list * @@ -123,7 +123,7 @@ do { \ _name = _our_uctx; \ } while (0); -int _fr_atexit_thread_local(NDEBUG_LOCATION_ARGS +int _fr_atexit_thread_local(char const *file, int line, fr_atexit_t func, void const *uctx); unsigned int fr_atexit_thread_local_disarm(bool uctx_scope, fr_atexit_t func, void const *uctx); diff --git a/src/lib/util/strerror.c b/src/lib/util/strerror.c index 0afd7dce06a..eef37942aea 100644 --- a/src/lib/util/strerror.c +++ b/src/lib/util/strerror.c @@ -38,6 +38,9 @@ struct fr_log_entry_s { char const *subject; //!< Subject for error markers. size_t offset; //!< Where to place the msg marker relative to the subject. + + char const *file; //!< File where the error was created. + int line; //!< Line where the error occurred. }; /** Holds data used by the logging stack @@ -143,7 +146,7 @@ static inline CC_HINT(always_inline) void pool_alt_free_children(fr_log_buffer_t * * @hidecallergraph */ -static fr_log_entry_t *strerror_vprintf(char const *fmt, va_list ap) +static fr_log_entry_t *strerror_vprintf(char const *file, int line, char const *fmt, va_list ap) { va_list ap_p; fr_log_entry_t *entry; @@ -173,6 +176,8 @@ static fr_log_entry_t *strerror_vprintf(char const *fmt, va_list ap) if (unlikely(!entry->msg)) goto oom; entry->subject = NULL; entry->offset = 0; + entry->file = file; + entry->line = line; pool_alt_free_children(buffer); fr_dlist_clear(&buffer->entries); @@ -183,6 +188,8 @@ static fr_log_entry_t *strerror_vprintf(char const *fmt, va_list ap) /** Add a message to an existing stack of messages * + * @param[in] file the error occurred in. + * @parma[in] line the error occurred on. * @param[in] fmt printf style format string. * @param[in] ap Arguments for the error string. * @@ -190,7 +197,8 @@ static fr_log_entry_t *strerror_vprintf(char const *fmt, va_list ap) * * @hidecallergraph */ -static fr_log_entry_t *strerror_vprintf_push(fr_log_buffer_t *buffer, char const *fmt, va_list ap) +static fr_log_entry_t *strerror_vprintf_push(char const *file, int line, + fr_log_buffer_t *buffer, char const *fmt, va_list ap) { va_list ap_p; fr_log_entry_t *entry; @@ -217,35 +225,41 @@ static fr_log_entry_t *strerror_vprintf_push(fr_log_buffer_t *buffer, char const if (unlikely(!entry->msg)) goto oom; entry->subject = NULL; entry->offset = 0; + entry->file = file; + entry->line = line; return entry; } /** Log to thread local error buffer * + * @param[in] file the error occurred in. + * @parma[in] line the error occurred on. * @param[in] fmt printf style format string. * If NULL clears any existing messages. * @param[in] ap Arguments for the format string. * * @hidecallergraph */ -void fr_strerror_vprintf(char const *fmt, va_list ap) +void _fr_strerror_vprintf(char const *file, int line, char const *fmt, va_list ap) { va_list our_ap; va_copy(our_ap, ap); - strerror_vprintf(fmt, our_ap); + strerror_vprintf(file, line, fmt, our_ap); va_end(our_ap); } /** Add a message to an existing stack of messages at the tail * + * @param[in] file the error occurred in. + * @parma[in] line the error occurred on. * @param[in] fmt printf style format string. * @param[in] ap Arguments for the format string. * * @hidecallergraph */ -void fr_strerror_vprintf_push(char const *fmt, va_list ap) +void _fr_strerror_vprintf_push(char const *file, int line, char const *fmt, va_list ap) { va_list our_ap; fr_log_buffer_t *buffer; @@ -255,7 +269,7 @@ void fr_strerror_vprintf_push(char const *fmt, va_list ap) if (unlikely(!buffer)) return; va_copy(our_ap, ap); - entry = strerror_vprintf_push(buffer, fmt, our_ap); + entry = strerror_vprintf_push(file, line, buffer, fmt, our_ap); va_end(our_ap); if (unlikely(!entry)) return; @@ -265,12 +279,14 @@ void fr_strerror_vprintf_push(char const *fmt, va_list ap) /** Add a message to an existing stack of messages at the head * + * @param[in] file the error occurred in. + * @parma[in] line the error occurred on. * @param[in] fmt printf style format string. * @param[in] ap Arguments for the format string. * * @hidecallergraph */ -void fr_strerror_vprintf_push_head(char const *fmt, va_list ap) +void _fr_strerror_vprintf_push_head(char const *file, int line, char const *fmt, va_list ap) { va_list our_ap; fr_log_buffer_t *buffer; @@ -280,7 +296,7 @@ void fr_strerror_vprintf_push_head(char const *fmt, va_list ap) if (unlikely(!buffer)) return; va_copy(our_ap, ap); - entry = strerror_vprintf_push(buffer, fmt, our_ap); + entry = strerror_vprintf_push(file, line, buffer, fmt, our_ap); va_end(our_ap); if (unlikely(!entry)) return; @@ -290,6 +306,8 @@ void fr_strerror_vprintf_push_head(char const *fmt, va_list ap) /** Add an error marker to an existing stack of messages * + * @param[in] file the error occurred in. + * @parma[in] line the error occurred on. * @param[in] subject to mark up. * @param[in] offset Positive offset to show where the error * should be positioned. @@ -298,13 +316,14 @@ void fr_strerror_vprintf_push_head(char const *fmt, va_list ap) * * @hidecallergraph */ -void fr_strerror_marker_vprintf(char const *subject, size_t offset, char const *fmt, va_list ap) +void _fr_strerror_marker_vprintf(char const *file, int line, + char const *subject, size_t offset, char const *fmt, va_list ap) { va_list our_ap; fr_log_entry_t *entry; va_copy(our_ap, ap); - entry = strerror_vprintf(fmt, our_ap); + entry = strerror_vprintf(file, line, fmt, our_ap); va_end(our_ap); if (unlikely(!entry)) return; @@ -315,6 +334,8 @@ void fr_strerror_marker_vprintf(char const *subject, size_t offset, char const * /** Add an error marker to an existing stack of messages at the tail * + * @param[in] file the error occurred in. + * @parma[in] line the error occurred on. * @param[in] subject to mark up. * @param[in] offset Positive offset to show where the error * should be positioned. @@ -323,7 +344,8 @@ void fr_strerror_marker_vprintf(char const *subject, size_t offset, char const * * * @hidecallergraph */ -void fr_strerror_marker_vprintf_push(char const *subject, size_t offset, char const *fmt, va_list ap) +void _fr_strerror_marker_vprintf_push(char const *file, int line, + char const *subject, size_t offset, char const *fmt, va_list ap) { va_list our_ap; fr_log_entry_t *entry; @@ -333,7 +355,7 @@ void fr_strerror_marker_vprintf_push(char const *subject, size_t offset, char co if (unlikely(!buffer)) return; va_copy(our_ap, ap); - entry = strerror_vprintf_push(buffer, fmt, our_ap); + entry = strerror_vprintf_push(file, line, buffer, fmt, our_ap); va_end(our_ap); if (unlikely(!entry)) return; @@ -346,6 +368,8 @@ void fr_strerror_marker_vprintf_push(char const *subject, size_t offset, char co /** Add an error marker to an existing stack of messages at the head * + * @param[in] file the error occurred in. + * @parma[in] line the error occurred on. * @param[in] subject to mark up. * @param[in] offset Positive offset to show where the error * should be positioned. @@ -354,7 +378,8 @@ void fr_strerror_marker_vprintf_push(char const *subject, size_t offset, char co * * @hidecallergraph */ -void fr_strerror_marker_vprintf_push_head(char const *subject, size_t offset, char const *fmt, va_list ap) +void _fr_strerror_marker_vprintf_push_head(char const *file, int line, + char const *subject, size_t offset, char const *fmt, va_list ap) { va_list our_ap; fr_log_entry_t *entry; @@ -364,7 +389,7 @@ void fr_strerror_marker_vprintf_push_head(char const *subject, size_t offset, ch if (unlikely(!buffer)) return; va_copy(our_ap, ap); - entry = strerror_vprintf_push(buffer, fmt, our_ap); + entry = strerror_vprintf_push(file, line, buffer, fmt, our_ap); va_end(our_ap); if (unlikely(!entry)) return; @@ -379,7 +404,7 @@ void fr_strerror_marker_vprintf_push_head(char const *subject, size_t offset, ch * * @hidecallergraph */ -static inline CC_HINT(always_inline) fr_log_entry_t *strerror_const(char const *msg) +static inline CC_HINT(always_inline) fr_log_entry_t *strerror_const(char const *file, int line, char const *msg) { fr_log_entry_t *entry; fr_log_buffer_t *buffer; @@ -400,6 +425,8 @@ static inline CC_HINT(always_inline) fr_log_entry_t *strerror_const(char const * * assignments result in the same byte * code. */ + entry->file = file; + entry->line = line; entry->msg = msg; entry->subject = NULL; entry->offset = 0; @@ -413,23 +440,29 @@ static inline CC_HINT(always_inline) fr_log_entry_t *strerror_const(char const * /** Log to thread local error buffer * + * @param[in] file the error occurred in. + * @parma[in] line the error occurred on. * @param[in] msg To add to error stack. Must have a * lifetime equal to that of the program. * @hidecallergraph */ -void fr_strerror_const(char const *msg) +void _fr_strerror_const(char const *file, int line, char const *msg) { - (void)strerror_const(msg); + (void)strerror_const(file, line, msg); } /** Add a message to an existing stack of messages * + * @param[in] file the error occurred in. + * @parma[in] line the error occurred on. + * @param[in] buffer to add the message to. * @param[in] msg To add to error stack. Must have a * lifetime equal to that of the program. * * @hidecallergraph */ -static inline CC_HINT(always_inline) fr_log_entry_t *strerror_const_push(fr_log_buffer_t *buffer, char const *msg) +static inline CC_HINT(always_inline) fr_log_entry_t *strerror_const_push(char const *file, int line, + fr_log_buffer_t *buffer, char const *msg) { fr_log_entry_t *entry; @@ -456,18 +489,22 @@ static inline CC_HINT(always_inline) fr_log_entry_t *strerror_const_push(fr_log_ entry->msg = msg; entry->subject = NULL; entry->offset = 0; + entry->file = file; + entry->line = line; return entry; } /** Add a message to an existing stack of messages at the tail * + * @param[in] file the error occurred in. + * @parma[in] line the error occurred on. * @param[in] msg To add to error stack. Must have a * lifetime equal to that of the program. * * @hidecallergraph */ -void fr_strerror_const_push(char const *msg) +void _fr_strerror_const_push(char const *file, int line, char const *msg) { fr_log_buffer_t *buffer; fr_log_entry_t *entry; @@ -475,7 +512,7 @@ void fr_strerror_const_push(char const *msg) buffer = fr_strerror_init(); if (!buffer) return; - entry = strerror_const_push(buffer, msg); + entry = strerror_const_push(file, line, buffer, msg); if (unlikely(!entry)) return; fr_dlist_insert_tail(&buffer->entries, entry); @@ -483,12 +520,14 @@ void fr_strerror_const_push(char const *msg) /** Add a message to an existing stack of messages at the head * + * @param[in] file the error occurred in. + * @parma[in] line the error occurred on. * @param[in] msg To add to error stack. Must have a * lifetime equal to that of the program. * * @hidecallergraph */ -void fr_strerror_const_push_head(char const *msg) +void _fr_strerror_const_push_head(char const *file, int line, char const *msg) { fr_log_buffer_t *buffer; fr_log_entry_t *entry; @@ -496,7 +535,7 @@ void fr_strerror_const_push_head(char const *msg) buffer = fr_strerror_init(); if (!buffer) return; - entry = strerror_const_push(buffer, msg); + entry = strerror_const_push(file, line, buffer, msg); if (unlikely(!entry)) return; fr_dlist_insert_head(&buffer->entries, entry); diff --git a/src/lib/util/strerror.h b/src/lib/util/strerror.h index 38a3edfc552..afd4f63b869 100644 --- a/src/lib/util/strerror.h +++ b/src/lib/util/strerror.h @@ -41,66 +41,76 @@ extern "C" { * * @{ */ - +#define fr_strerror_vprintf(_fmt, _ap) _fr_strerror_vprintf(__FILE__, __LINE__, _fmt, _ap) /** @hidecallergraph */ -void fr_strerror_vprintf(char const *fmt, va_list ap); +void _fr_strerror_vprintf(char const *file, int line, char const *fmt, va_list ap); +#define fr_strerror_vprintf_push(_fmt, _ap) _fr_strerror_vprintf_push(__FILE__, __LINE, _fmt, _ap) /** @hidecallergraph */ -void fr_strerror_vprintf_push(char const *fmt, va_list ap); +void _fr_strerror_vprintf_push(char const *file, int line, char const *fmt, va_list ap); +#define fr_strerror_vprintf_push_head(_fmt, _ap) _fr_strerror_vprintf_push_head(__FILE__, __LINE__, _fmt, _ap) /** @hidecallergraph */ -void fr_strerror_vprintf_push_head(char const *fmt, va_list ap); +void _fr_strerror_vprintf_push_head(char const *file, int line, char const *fmt, va_list ap); /** Log to thread local error buffer * - * @param[in] fmt printf style format string. + * @param[in] _fmt printf style format string. * If NULL clears any existing messages. * @param[in] ... Arguments for the format string. * * @hidecallergraph */ -static inline CC_HINT(nonnull) CC_HINT(format (printf, 1, 2)) -void fr_strerror_printf(char const *fmt, ...) +#define fr_strerror_printf(_fmt, ...) \ + _fr_strerror_printf(__FILE__, __LINE__, _fmt, ##__VA_ARGS__) + +static inline CC_HINT(nonnull) CC_HINT(format (printf, 3, 4)) +void _fr_strerror_printf(char const *file, int line, char const *fmt, ...) { va_list ap; va_start(ap, fmt); - fr_strerror_vprintf(fmt, ap); + _fr_strerror_vprintf(file, line, fmt, ap); va_end(ap); } /** Add a message to an existing stack of messages at the tail * - * @param[in] fmt printf style format string. + * @param[in] _fmt printf style format string. * @param[in] ... Arguments for the format string. * * @hidecallergraph */ +#define fr_strerror_printf_push(_fmt, ...) \ + _fr_strerror_printf_push(__FILE__, __LINE__, _fmt, ##__VA_ARGS__) -static inline CC_HINT(nonnull) CC_HINT(format (printf, 1, 2)) -void fr_strerror_printf_push(char const *fmt, ...) +static inline CC_HINT(nonnull) CC_HINT(format (printf, 3, 4)) +void _fr_strerror_printf_push(char const *file, int line, char const *fmt, ...) { va_list ap; va_start(ap, fmt); - fr_strerror_vprintf_push(fmt, ap); + _fr_strerror_vprintf_push(file, line, fmt, ap); va_end(ap); } /** Add a message to an existing stack of messages at the head * - * @param[in] fmt printf style format string. + * @param[in] _fmt printf style format string. * @param[in] ... Arguments for the format string. * * @hidecallergraph */ -static inline CC_HINT(nonnull) CC_HINT(format (printf, 1, 2)) -void fr_strerror_printf_push_head(char const *fmt, ...) +#define fr_strerror_printf_push_head(_fmt, ...) \ + _fr_strerror_printf_push_head(__FILE__, __LINE__, _fmt, ##__VA_ARGS__) + +static inline CC_HINT(nonnull) CC_HINT(format (printf, 3, 4)) +void _fr_strerror_printf_push_head(char const *file, int line, char const *fmt, ...) { va_list ap; va_start(ap, fmt); - fr_strerror_vprintf_push_head(fmt, ap); + _fr_strerror_vprintf_push_head(file, line, fmt, ap); va_end(ap); } /** @} */ @@ -113,72 +123,93 @@ void fr_strerror_printf_push_head(char const *fmt, ...) * * @{ */ +#define fr_strerror_marker_vprintf(_subject, _offset, _fmt, _ap) \ + _fr_strerror_marker_vprintf(__FILE__, __LINE__, _subject, _offset, _fmt, _ap) /** @hidecallergraph */ -void fr_strerror_marker_vprintf(char const *subject, size_t offset, char const *fmt, va_list ap); +void _fr_strerror_marker_vprintf(char const *file, int line, + char const *subject, size_t offset, char const *fmt, va_list ap); +#define fr_strerror_marker_vprintf_push(_subject, _offset, _fmt, _ap) \ + _fr_strerror_marker_vprintf_push(__FILE__, __LINE__, _subject, _offset, _fmt, _ap) /** @hidecallergraph */ -void fr_strerror_marker_vprintf_push(char const *subject, size_t offset, char const *fmt, va_list ap); +void _fr_strerror_marker_vprintf_push(char const *file, int line, + char const *subject, size_t offset, char const *fmt, va_list ap); +#define fr_strerror_marker_vprintf_push_head(_subject, _offset, _fmt, _ap) \ + _fr_strerror_marker_vprintf_push_head(__FILE__, __LINE__, _subject, _offset, _fmt, _ap) /** @hidecallergraph */ -void fr_strerror_marker_vprintf_push_head(char const *subject, size_t offset, char const *fmt, va_list ap); +void _fr_strerror_marker_vprintf_push_head(char const *file, int line, + char const *subject, size_t offset, char const *fmt, va_list ap); /** Add an error marker to an existing stack of messages * - * @param[in] subject to mark up. - * @param[in] offset Positive offset to show where the error + * @param[in] _subject to mark up. + * @param[in] _offset Positive offset to show where the error * should be positioned. - * @param[in] fmt Error string. + * @param[in] _fmt Error string. * @param[in] ... Arguments for the error string. * * @hidecallergraph */ -static inline CC_HINT(nonnull) CC_HINT(format (printf, 3, 4)) -void fr_strerror_marker_printf(char const *subject, size_t offset, char const *fmt, ...) +#define fr_strerror_marker_printf(_subject, _offset, _fmt, ...) \ + _fr_strerror_marker_printf(__FILE__, __LINE__, _subject, _offset, _fmt, ##__VA_ARGS__) + +static inline CC_HINT(nonnull) CC_HINT(format (printf, 5, 6)) +void _fr_strerror_marker_printf(char const *file, int line, + char const *subject, size_t offset, char const *fmt, ...) { va_list ap; va_start(ap, fmt); - fr_strerror_marker_vprintf(subject, offset, fmt, ap); + _fr_strerror_marker_vprintf(file, line, subject, offset, fmt, ap); va_end(ap); } /** Add an error marker to an existing stack of messages at the tail * - * @param[in] subject to mark up. - * @param[in] offset Positive offset to show where the error + * @param[in] _subject to mark up. + * @param[in] _offset Positive offset to show where the error * should be positioned. - * @param[in] fmt Error string. + * @param[in] _fmt Error string. * @param[in] ... Arguments for the error string. * * @hidecallergraph */ -static inline CC_HINT(nonnull) CC_HINT(format (printf, 3, 4)) -void fr_strerror_marker_printf_push(char const *subject, size_t offset, char const *fmt, ...) +#define fr_strerror_marker_printf_push(_subject, _offset, _fmt, ...) \ + _fr_strerror_marker_printf_push(__FILE__, __LINE__, _subject, _offset, _fmt, ##__VA_ARGS__) + +static inline CC_HINT(nonnull) CC_HINT(format (printf, 5, 6)) +void _fr_strerror_marker_printf_push(char const *file, int line, + char const *subject, size_t offset, char const *fmt, ...) { va_list ap; va_start(ap, fmt); - fr_strerror_marker_vprintf_push(subject, offset, fmt, ap); + _fr_strerror_marker_vprintf_push(file, line, subject, offset, fmt, ap); va_end(ap); } /** Add an error marker to an existing stack of messages at the head * - * @param[in] subject to mark up. - * @param[in] offset Positive offset to show where the error + * @param[in] _subject to mark up. + * @param[in] _offset Positive offset to show where the error * should be positioned. - * @param[in] fmt Error string. + * @param[in] _fmt Error string. * @param[in] ... Arguments for the error string. * * @hidecallergraph */ -static inline CC_HINT(nonnull) CC_HINT(format (printf, 3, 4)) -void fr_strerror_marker_printf_push_head(char const *subject, size_t offset, char const *fmt, ...) +#define fr_strerror_marker_printf_push_head(_subject, _offset, _fmt, ...) \ + _fr_strerror_marker_printf_push_head(__FILE__, __LINE__, _subject, _offset, _fmt, ##__VA_ARGS__) + +static inline CC_HINT(nonnull) CC_HINT(format (printf, 5, 6)) +void _fr_strerror_marker_printf_push_head(char const *file, int line, + char const *subject, size_t offset, char const *fmt, ...) { va_list ap; va_start(ap, fmt); - fr_strerror_marker_vprintf_push_head(subject, offset, fmt, ap); + _fr_strerror_marker_vprintf_push_head(file, line, subject, offset, fmt, ap); va_end(ap); } /** @} */ @@ -189,14 +220,17 @@ void fr_strerror_marker_printf_push_head(char const *subject, size_t offset, ch * * @{ */ +#define fr_strerror_const(_msg) _fr_strerror_const(__FILE__, __LINE__, _msg) /** @hidecallergraph */ -void fr_strerror_const(char const *msg) CC_HINT(nonnull); +void _fr_strerror_const(char const *file, int line, char const *msg) CC_HINT(nonnull); +#define fr_strerror_const_push(_msg) _fr_strerror_const_push(__FILE__, __LINE__, _msg) /** @hidecallergraph */ -void fr_strerror_const_push(char const *msg) CC_HINT(nonnull); +void _fr_strerror_const_push(char const *file, int line, char const *msg) CC_HINT(nonnull); +#define fr_strerror_const_push_head(_msg) _fr_strerror_const_push_head(__FILE__, __LINE__, _msg) /** @hidecallergraph */ -void fr_strerror_const_push_head(char const *msg) CC_HINT(nonnull); +void _fr_strerror_const_push_head(char const *file, int line, char const *msg) CC_HINT(nonnull); /** @} */ /** @name Retrieve errors from the thread local error stack