]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
new gdb_traceback() that does a stack trace of all the thread
authorAlain Spineux <alain@baculasystems.com>
Fri, 7 Jan 2022 12:27:29 +0000 (13:27 +0100)
committerEric Bollengier <eric@baculasystems.com>
Thu, 14 Sep 2023 11:56:57 +0000 (13:56 +0200)
bacula/src/lib/bsys.c
bacula/src/lib/protos.h

index e9c796fc1ed8616b76c4d07a7164d6c9bf2eb271..14f6e161ec4bc8296cd01dafa4191245e307e643 100644 (file)
@@ -1187,6 +1187,27 @@ void gdb_stack_trace()
    }
 }
 
+void gdb_traceback()
+{
+   char name_buf[512];
+   char syscom[1024];
+   BPIPE *bpipe;
+
+   snprintf(syscom, sizeof(syscom), "gdb --batch -n -ex \"thread apply all bt\" %s %d", name_buf, getpid());
+   bpipe = open_bpipe(syscom, 0, "r");
+   if (bpipe) {
+      bool ok = false;
+      char buf[1000];
+      while (fgets(buf, sizeof(buf), bpipe->rfd)) {
+         Pmsg1(000, "    %s", buf);
+      }
+      if (close_bpipe(bpipe) !=0) {
+         return;
+      }
+   }
+}
+
+
 void gdb_print_local(int level)
 {
    char name_buf[512];
index e157fe133e50d5e09175d2c822319e551e575551..bf664bf296f0297fcbab53b3d97c47cf738fc337 100644 (file)
@@ -127,6 +127,7 @@ int       Zdeflate(char *in, int in_len, char *out, int &out_len);
 int       Zinflate(char *in, int in_len, char *out, int &out_len);
 void      stack_trace();
 void      gdb_stack_trace();
+void      gdb_traceback();
 void      gdb_print_local(int level);
 
 int       safer_unlink(const char *pathname, const char *regex);