[sheepdog] [PATCH] logger: switch to the current thread when backtracing

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Fri Apr 12 03:22:23 CEST 2013


Without this patch, we cannot dump stack frames when we are not in the
main thread.

Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 lib/logger.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/logger.c b/lib/logger.c
index ad5b462..a31cb1f 100644
--- a/lib/logger.c
+++ b/lib/logger.c
@@ -689,7 +689,7 @@ notrace int __sd_dump_variable(const char *var, const void *base_sp)
 
 	snprintf(cmd, sizeof(cmd), "gdb -nw %s %d -batch -ex 'set width 80'"
 		 " -ex 'select-frame %p' -ex 'up 1' -ex 'p %s' 2> /dev/null",
-		 path, getpid(), base_sp, var);
+		 path, gettid(), base_sp, var);
 	f = popen(cmd, "r");
 	if (f == NULL) {
 		sd_eprintf("failed to run gdb");
@@ -745,7 +745,7 @@ static notrace int __dump_stack_frames(const void *base_sp)
 		snprintf(cmd, sizeof(cmd), "gdb -nw %s %d -batch"
 			 " -ex 'set width 80' -ex 'select-frame %p'"
 			 " -ex 'up %d' -ex 'info locals' 2> /dev/null",
-			 path, getpid(), base_sp, i);
+			 path, gettid(), base_sp, i);
 		f = popen(cmd, "r");
 		if (f == NULL)
 			return -1;
-- 
1.8.1.3.566.gaa39828




More information about the sheepdog mailing list