From d1cee441d3f71f0bc0032642c7b424b870edec18 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 16 Sep 2010 14:44:40 +0200 Subject: CCpp: better handling of uid and exit condition on bt generation Signed-off-by: Denys Vlasenko --- lib/plugins/CCpp.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'lib/plugins') diff --git a/lib/plugins/CCpp.cpp b/lib/plugins/CCpp.cpp index 6d11c4dc..0fad8f44 100644 --- a/lib/plugins/CCpp.cpp +++ b/lib/plugins/CCpp.cpp @@ -161,7 +161,9 @@ static char *get_backtrace(const char *pDebugDumpDir, const char *pDebugInfoDirs return NULL; } - char *uid = dd_load_text(dd, CD_UID); + char *uid_str = dd_load_text(dd, CD_UID); + uid_t uid = xatoi_u(uid_str); + free(uid_str); char *executable = dd_load_text(dd, FILENAME_EXECUTABLE); dd_close(dd); @@ -176,7 +178,7 @@ static char *get_backtrace(const char *pDebugDumpDir, const char *pDebugInfoDirs args[0] = (char*)"gdb"; args[1] = (char*)"-batch"; - // when/if gdb supports it: + // when/if gdb supports "set debug-file-directory DIR1:DIR2": // (https://bugzilla.redhat.com/show_bug.cgi?id=528668): args[2] = (char*)"-ex"; string dfd = "set debug-file-directory /usr/lib/debug"; @@ -244,9 +246,9 @@ static char *get_backtrace(const char *pDebugDumpDir, const char *pDebugInfoDirs while (1) { args[9] = xasprintf("%s backtrace %u%s", thread_apply_all, bt_depth, full); - bt = exec_vp(args, xatoi_u(uid), /*redirect_stderr:*/ 1, timeout_sec, NULL); + bt = exec_vp(args, uid, /*redirect_stderr:*/ 1, timeout_sec, NULL); free(args[9]); - if (bt && (bt_depth <= 64 || strlen(bt) < 256*1024)) + if ((bt && strnlen(bt, 256*1024) < 256*1024) || bt_depth <= 32) { break; } @@ -266,7 +268,6 @@ static char *get_backtrace(const char *pDebugDumpDir, const char *pDebugInfoDirs full = ""; } } - free(uid); free(args[5]); free(args[7]); return bt; -- cgit