|
#define | FR_FAULT_LOG(_fmt, ...) fr_fault_log(_fmt "\n", ## __VA_ARGS__) |
|
#define | FR_FAULT_LOG_HEX(_data, _data_len) fr_fault_log_hex(_data, _data_len) |
|
#define | FR_STRUCT_MEMBER_SIGN(_ptr, _member, _len) _ptr->_signature_##_member = fr_hash(_ptr->_member, _len) |
|
#define | FR_STRUCT_MEMBER_SIGNATURE(_member) uint32_t _signature_##_member; |
|
#define | FR_STRUCT_MEMBER_VERIFY(_ptr, _member, _len) fr_verify_struct_member(_ptr->_member, _len, &(_ptr->_signature_##_member)) |
|
#define | FR_STRUCT_SIGN(_ptr) fr_sign_struct(_ptr, sizeof(__typeof__(*_ptr)), offsetof(__typeof__(*_ptr), _signature)); |
| Manual validation of structures. More...
|
|
#define | FR_STRUCT_SIGNATURE uint32_t _signature; |
|
#define | FR_STRUCT_VERIFY(_ptr) fr_verify_struct(_ptr, sizeof(__typeof__(*_ptr)), offsetof(__typeof__(*_ptr), _signature)) |
|
#define | MEM(x) do { if (!(x)) { fr_cond_assert_msg(0 && (x), "OUT OF MEMORY"); _fr_exit(__FILE__, __LINE__, EXIT_FAILURE, true); } } while (0) |
|
|
void | backtrace_print (fr_fring_t *fring, void *obj) |
|
fr_bt_marker_t * | fr_backtrace_attach (fr_fring_t **fring, TALLOC_CTX *obj) |
|
int | fr_backtrace_do (fr_bt_marker_t *marker) |
|
void | fr_debug_break (bool always) |
| Break in debugger (if were running under a debugger) More...
|
|
void | fr_debug_state_store (void) |
| Should be run before using setuid or setgid to get useful results. More...
|
|
char const * | fr_debug_state_to_msg (fr_debug_state_t state) |
| Return current value of debug_state. More...
|
|
void | fr_disable_null_tracking_on_free (TALLOC_CTX *ctx) |
| Disable the null tracking context when a talloc chunk is freed. More...
|
|
void | fr_fault (int sig) |
| Prints a simple backtrace (if execinfo is available) and calls panic_action if set. More...
|
|
void | fr_fault_backtrace (void) |
| Split out so it can be sprinkled throughout the server and called via a debugger. More...
|
|
void | fr_fault_log (char const *msg,...)) |
| Log output to the fr_fault_log_fd. More...
|
|
void | fr_fault_log_hex (uint8_t const *data, size_t data_len) |
| Print data as a hex block. More...
|
|
void | fr_fault_set_cb (fr_fault_cb_t func) |
| Set a callback to be called before fr_fault() More...
|
|
void | fr_fault_set_log_fd (int fd) |
| Set a file descriptor to log memory reports to. More...
|
|
int | fr_fault_setup (TALLOC_CTX *ctx, char const *cmd, char const *program) |
| Registers signal handlers to execute panic_action on fatal signal. More...
|
|
int | fr_get_debug_state (void) |
|
int | fr_get_lsan_state (void) |
|
int | fr_log_talloc_report (TALLOC_CTX const *ctx) |
| Generate a talloc memory report for a context and print to stderr/stdout. More...
|
|
void | fr_panic_on_free (TALLOC_CTX *ctx) |
| Insert memory into the context of another talloc memory chunk which causes a panic when freed. More...
|
|
int | fr_reset_dumpable (void) |
| Reset dumpable state to previously configured value. More...
|
|
int | fr_set_dumpable (bool allow_core_dumps) |
| Enable or disable core dumps. More...
|
|
int | fr_set_dumpable_init (void) |
| Get the current maximum for core files. More...
|
|
void | fr_sign_struct (void *ptr, size_t size, size_t offset) |
|
void | fr_talloc_fault_setup (void) |
| Register talloc fault handlers. More...
|
|
void | fr_verify_struct (void const *ptr, size_t size, size_t offset) |
|
void | fr_verify_struct_member (void const *ptr, size_t len, uint32_t *signature) |
|
|
#define | fr_assert(_x) if (unlikely(!((bool)(_x)))) _fr_assert_fail(__FILE__, __LINE__, #_x, NULL) |
| Calls panic_action ifndef NDEBUG, else logs error. More...
|
|
#define | fr_assert_fail(_msg, ...) _fr_assert_fail(__FILE__, __LINE__, "false", _msg, ## __VA_ARGS__) |
| Calls panic_action ifndef NDEBUG, else logs error. More...
|
|
#define | fr_assert_msg(_x, _msg, ...) if (unlikely(!((bool)(_x)))) _fr_assert_fail(__FILE__, __LINE__, #_x, _msg, ## __VA_ARGS__) |
| Calls panic_action ifndef NDEBUG, else logs error and causes the server to exit immediately with code 134. More...
|
|
#define | fr_cond_assert(_x) likely((bool)((_x) ? true : (_fr_assert_fail(__FILE__, __LINE__, #_x, NULL) && false))) |
| Calls panic_action ifndef NDEBUG, else logs error and evaluates to value of _x. More...
|
|
#define | fr_cond_assert_msg(_x, _fmt, ...) likely((bool)((_x) ? true : (_fr_assert_fail(__FILE__, __LINE__, #_x, _fmt, ## __VA_ARGS__) && false))) |
| Calls panic_action ifndef NDEBUG, else logs error and evaluates to value of _x. More...
|
|
#define | fr_exit(_x) _fr_exit(__FILE__, __LINE__, (_x), false) |
| Exit, producing a log message in debug builds. More...
|
|
#define | fr_exit_now(_x) _fr_exit(__FILE__, __LINE__, (_x), true) |
| Exit without calling atexit() handlers, producing a log message in debug builds. More...
|
|
#define | fr_fatal_assert(_x) if (unlikely(!((bool)(_x)))) _fr_assert_fatal(__FILE__, __LINE__, #_x, NULL) |
| Calls panic_action ifndef NDEBUG, else logs error and causes the server to exit immediately with code 134. More...
|
|
#define | fr_fatal_assert_fail(_msg, ...) _fr_assert_fatal(__FILE__, __LINE__, "false", _msg, ## __VA_ARGS__) |
| Calls panic_action ifndef NDEBUG, else logs error and causes the server to exit immediately with code 134. More...
|
|
#define | fr_fatal_assert_msg(_x, _fmt, ...) if (unlikely(!((bool)(_x)))) _fr_assert_fatal(__FILE__, __LINE__, #_x, _fmt, ## __VA_ARGS__) |
| Calls panic_action ifndef NDEBUG, else logs error and causes the server to exit immediately with code 134. More...
|
|
|
bool | _fr_assert_fail (char const *file, int line, char const *expr, char const *msg,...)) |
| A soft assertion which triggers the fault handler in debug builds. More...
|
|
NEVER_RETURNS void | _fr_assert_fatal (char const *file, int line, char const *expr, char const *msg,...)) |
| A fatal assertion which triggers the fault handler in debug builds or exits. More...
|
|
NEVER_RETURNS void | _fr_exit (char const *file, int line, int status, bool now) |
| Exit possibly printing a message about why we're exiting. More...
|
|
Debugging function definitions and structures.
- Copyright
- 2015-2017 Arran Cudbard-Bell (a.cud.nosp@m.bard.nosp@m.b@fre.nosp@m.erad.nosp@m.ius.o.nosp@m.rg)
Definition in file debug.h.
Calls panic_action ifndef NDEBUG, else logs error and evaluates to value of _x.
Should be wrapped in a condition, and if false, should cause function to return an error code. This allows control to return to the caller if a precondition is not satisfied and we're not debugging.
Example:
if (!fr_cond_assert(request)) return -1
- Parameters
-
[in] | _x | expression to test (should evaluate to true) |
Definition at line 139 of file debug.h.
Calls panic_action ifndef NDEBUG, else logs error and evaluates to value of _x.
Should be wrapped in a condition, and if false, should cause function to return an error code. This allows control to return to the caller if a precondition is not satisfied and we're not debugging.
Example:
if (!fr_cond_assert_msg(request, "Bad stuff happened: %s", fr_syserror(errno)))) return -1
- Parameters
-
[in] | _x | expression to test (should evaluate to true) |
[in] | _fmt | of message to log. |
[in] | ... | fmt arguments. |
Definition at line 156 of file debug.h.
Calls panic_action ifndef NDEBUG, else logs error and causes the server to exit immediately with code 134.
Should be wrapped in a condition, and if false, should cause function to return an error code. This allows control to return to the caller if a precondition is not satisfied and we're not debugging.
Example:
fr_fatal_assert(<extremely_unlikely_and_fatal_condition>);
- Parameters
-
[in] | _x | expression to test (should evaluate to true) |
[in] | _fmt | of message to log. |
[in] | ... | fmt arguments. |
Definition at line 184 of file debug.h.
#define FR_STRUCT_SIGN |
( |
|
_ptr | ) |
fr_sign_struct(_ptr, sizeof(__typeof__(*_ptr)), offsetof(__typeof__(*_ptr), _signature)); |
Manual validation of structures.
typedef struct {
char *a;
int b;
FR_SIGNATURE // no semicolon!
} foo_t;
and then once the structure is initialized (and will never be changed)
foo_t *ptr;
FR_STRUCT_SIGN(ptr);
and some time later...
foo_t *ptr;
FR_STRUCT_VERIFY(ptr);
Note that the structure can't contain variable elements such as fr_dlist_t. And that we're not verifying the contents of the members which are pointers.
Definition at line 263 of file debug.h.
typedef int(* fr_fault_cb_t) (int signum) |
Optional callback passed to fr_fault_setup.
Allows optional logic to be run before calling the main fault handler.
If the callback returns < 0, the main fault handler will not be called.
- Parameters
-
- Returns
- 0 on success.
- < 0 on failure.
Definition at line 63 of file debug.h.
void fr_debug_break |
( |
bool |
always | ) |
|
Break in debugger (if were running under a debugger)
If the server is running under a debugger this will raise a SIGTRAP which will pause the running process.
If the server is not running under debugger then this will do nothing.
Definition at line 570 of file debug.c.
void fr_fault_log |
( |
char const * |
msg, |
|
|
|
... |
|
) |
| |
Log output to the fr_fault_log_fd.
We used to support a user defined callback, which was set to a radlog function. Unfortunately, when logging to syslog, syslog would alloc memory which would result in a deadlock if fr_fault was triggered from within a allocation call.
Now we just write directly to the FD.
Definition at line 1401 of file debug.c.