From: Alan T. DeKok Date: Mon, 30 Jan 2023 16:34:30 +0000 (-0500) Subject: automatically set DEBUGGER_ATTACHED when executing gdb or lldb X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=230a8daff3aef2e91ac9265d80d7768a2868f222;p=thirdparty%2Ffreeradius-server.git automatically set DEBUGGER_ATTACHED when executing gdb or lldb because the debugger detection on some OS's is broken and doesn't work. --- diff --git a/scripts/jlibtool.c b/scripts/jlibtool.c index 67c6553e840..16f9f7d43b7 100644 --- a/scripts/jlibtool.c +++ b/scripts/jlibtool.c @@ -2719,6 +2719,7 @@ static int run_mode(command_t *cmd) { char libpath[PATH_MAX]; char *p = libpath, *end = p + (sizeof(libpath) - 1); + char const *q; if (!cmd->arglist->num) { ERROR("No command to execute.\n"); @@ -2747,6 +2748,18 @@ static int run_mode(command_t *cmd) setenv(target->ld_library_path_local, libpath, 1); setenv("FR_LIBRARY_PATH", libpath, 1); + /* + * Work around stupid crap on Linux, where the + * debug code can't detect that a debugger is + * attached. + */ + q = strrchr(cmd->arglist->vals[0], '/'); + if (!q) q = cmd->arglist->vals[0]; + + if ((strcmp(q, "gdb") == 0) || (strcmp(q, "lldb") == 0)) { + setenv("DEBUGGER_ATTACHED", "yes", 1); + } + rv = run_command(cmd, cmd->arglist); if (rv) goto finish; }