From: Alain Spineux Date: Fri, 7 Jan 2022 12:27:29 +0000 (+0100) Subject: new gdb_traceback() that does a stack trace of all the thread X-Git-Tag: Beta-15.0.0~688 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=989151590e9906adfac93ff4b6fac33f32da19ec;p=thirdparty%2Fbacula.git new gdb_traceback() that does a stack trace of all the thread --- diff --git a/bacula/src/lib/bsys.c b/bacula/src/lib/bsys.c index e9c796fc1..14f6e161e 100644 --- a/bacula/src/lib/bsys.c +++ b/bacula/src/lib/bsys.c @@ -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]; diff --git a/bacula/src/lib/protos.h b/bacula/src/lib/protos.h index e157fe133..bf664bf29 100644 --- a/bacula/src/lib/protos.h +++ b/bacula/src/lib/protos.h @@ -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);