]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
automatically set DEBUGGER_ATTACHED when executing gdb or lldb
authorAlan T. DeKok <aland@freeradius.org>
Mon, 30 Jan 2023 16:34:30 +0000 (11:34 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 30 Jan 2023 16:34:30 +0000 (11:34 -0500)
because the debugger detection on some OS's is broken and doesn't
work.

scripts/jlibtool.c

index 67c6553e8404f74a89481c8dcf802e134362aab7..16f9f7d43b725cb6ac79276dff853c12fa9ec0ad 100644 (file)
@@ -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;
        }