From: Alan T. DeKok Date: Tue, 4 Apr 2017 14:49:44 +0000 (-0400) Subject: SET DEBUG STATE WHEN TOLD TO SET THE DEBUG STATE X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8ac16621d06a29cdfe70af9366c0fed09d8e88ee;p=thirdparty%2Ffreeradius-server.git SET DEBUG STATE WHEN TOLD TO SET THE DEBUG STATE Honestly, this one bug has cost me days of time. Why the HELL does setting the debug state NOT WORK. EVER. The MAGIC CODE to figure out whether or not we're in a debugger DOES NOT WORK FOR ME. The environment variable which FORCES the code to believe that the debugger attached sets a variable LOCAL TO THE FUNCTION, and FAILS TO SET THE GLOBAL VARIABLE WHICH SETS THE DEBUG STATE. --- diff --git a/src/lib/debug.c b/src/lib/debug.c index cff85136c87..9b9e0971f98 100644 --- a/src/lib/debug.c +++ b/src/lib/debug.c @@ -947,7 +947,6 @@ int fr_fault_setup(char const *cmd, char const *program) /* Unsure what the side effects of changing the signal handler mid execution might be */ if (!setup) { char *env; - fr_debug_state_t debug_state; /* * Installing signal handlers interferes with some debugging @@ -956,15 +955,16 @@ int fr_fault_setup(char const *cmd, char const *program) */ env = getenv("DEBUGGER_ATTACHED"); if (env && (strcmp(env, "yes") == 0)) { - debug_state = DEBUGGER_STATE_ATTACHED; /* i.e. disable signal handlers */ + fr_debug_state = DEBUGGER_STATE_ATTACHED; /* i.e. disable signal handlers */ + } else if (env && (strcmp(env, "no") == 0)) { - debug_state = DEBUGGER_STATE_NOT_ATTACHED; /* i.e. enable signal handlers */ - /* - * Figure out if we were started under a debugger - */ + fr_debug_state = DEBUGGER_STATE_NOT_ATTACHED; /* i.e. enable signal handlers */ + + /* + * Figure out if we were started under a debugger + */ } else { if (fr_debug_state < 0) fr_debug_state = fr_get_debug_state(); - debug_state = fr_debug_state; } talloc_set_log_fn(_fr_talloc_log); @@ -973,7 +973,7 @@ int fr_fault_setup(char const *cmd, char const *program) * These signals can't be properly dealt with in the debugger * if we set our own signal handlers. */ - switch (debug_state) { + switch (fr_debug_state) { default: /* FALL-THROUGH */