From a5bece25051e1d584b27b88d1d11d3c31dab8c32 Mon Sep 17 00:00:00 2001 From: dnovotny Date: Tue, 13 Oct 2009 05:13:40 -0400 Subject: added backtrace rating --- lib/Plugins/CCpp.cpp | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) (limited to 'lib/Plugins/CCpp.cpp') diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp index 0e0eb3b..88634dc 100644 --- a/lib/Plugins/CCpp.cpp +++ b/lib/Plugins/CCpp.cpp @@ -156,6 +156,90 @@ static pid_t ExecVP(char** pArgs, uid_t uid, std::string& pOutput) return 0; } +enum LineRating +{ + /* RATING -- EXAMPLE */ + MissingEverything = 0, // #0 0x0000dead in ?? () + MissingFunction = 1, // #0 0x0000dead in ?? () from /usr/lib/libfoobar.so.4 + MissingLibrary = 2, // #0 0x0000dead in foobar() + MissingSourceFile = 3, // #0 0x0000dead in FooBar::FooBar () from /usr/lib/libfoobar.so.4 + Good = 4, // #0 0x0000dead in FooBar::crash (this=0x0) at /home/user/foobar.cpp:204 + InvalidRating = -1 // (dummy invalid value) +}; + +static const LineRating BestRating = Good; + +LineRating rate_line(std::string line) +{ + bool function = false; + bool library = false; + bool source_file = false; + +#define FOUND(x) (line.find(x) != std::string::npos) + if (FOUND(" in ") && !FOUND(" in ??")) + function = true; + + if (FOUND(" from ")) + library = true; + + if(FOUND(" at ")) + source_file = true; +#undef FOUND + + /* see the "enum LineRating" comments for possible combinations */ + if (function && source_file) + return Good; + if (function && library) + return MissingSourceFile; + if (function) + return MissingLibrary; + if (library) + return MissingFunction; + + return MissingEverything; +} + +/* returns number of "stars" to show*/ +int rate_backtrace(std::string backtrace) +{ + backtrace="#"+backtrace; /*line termination condition*/ + int l = backtrace.length(); + int i; + std::string s = ""; + int multiplier = 0; + int rating = 0; + int best_possible_rating = 0; + + /*we get the lines from the end, b/c of the rating multiplier + which gives weight to the first lines*/ + for (i=l-1; i>=0; i--) + { + if (backtrace[i] == '#') /*this divides frames from each other*/ + { + multiplier++; + rating += rate_line(s) * multiplier; + best_possible_rating += BestRating * multiplier; + + s = ""; /*starting new line*/ + } else + { + s=backtrace[i]+s; + } + } + + /*returning number of "stars" to show*/ + if (rating >= best_possible_rating*0.8) + return 4; + if (rating >= best_possible_rating*0.6) + return 3; + if (rating >= best_possible_rating*0.4) + return 2; + if (rating >= best_possible_rating*0.2) + return 1; + + return 0; +} + static void GetBacktrace(const std::string& pDebugDumpDir, std::string& pBacktrace) { update_client(_("Getting backtrace...")); -- cgit From 828288e948ccc6c5c1525eaf44bc8cb83960e9f1 Mon Sep 17 00:00:00 2001 From: dnovotny Date: Tue, 13 Oct 2009 05:25:11 -0400 Subject: a little change --- lib/Plugins/CCpp.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'lib/Plugins/CCpp.cpp') diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp index 88634dc..f79877e 100644 --- a/lib/Plugins/CCpp.cpp +++ b/lib/Plugins/CCpp.cpp @@ -202,7 +202,6 @@ LineRating rate_line(std::string line) /* returns number of "stars" to show*/ int rate_backtrace(std::string backtrace) { - backtrace="#"+backtrace; /*line termination condition*/ int l = backtrace.length(); int i; std::string s = ""; -- cgit From c87548afdde1d0c4e8b2b70fb69327f62bcfd31d Mon Sep 17 00:00:00 2001 From: dnovotny Date: Tue, 13 Oct 2009 05:36:40 -0400 Subject: parameters passed as const string & --- lib/Plugins/CCpp.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/Plugins/CCpp.cpp') diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp index f79877e..c1725fc 100644 --- a/lib/Plugins/CCpp.cpp +++ b/lib/Plugins/CCpp.cpp @@ -169,7 +169,7 @@ enum LineRating static const LineRating BestRating = Good; -LineRating rate_line(std::string line) +LineRating rate_line(const std::string & line) { bool function = false; bool library = false; @@ -200,7 +200,7 @@ LineRating rate_line(std::string line) } /* returns number of "stars" to show*/ -int rate_backtrace(std::string backtrace) +int rate_backtrace(const std::string & backtrace) { int l = backtrace.length(); int i; -- cgit From 6df7d19ab1b6681f89a0ba5bc2771acaa4db5454 Mon Sep 17 00:00:00 2001 From: dnovotny Date: Tue, 13 Oct 2009 06:46:26 -0400 Subject: backtrace rating saved with crash data --- lib/Plugins/CCpp.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/Plugins/CCpp.cpp') diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp index c1725fc..133811f 100644 --- a/lib/Plugins/CCpp.cpp +++ b/lib/Plugins/CCpp.cpp @@ -227,6 +227,8 @@ int rate_backtrace(const std::string & backtrace) } /*returning number of "stars" to show*/ + if (rating==0) + return 0; if (rating >= best_possible_rating*0.8) return 4; if (rating >= best_possible_rating*0.6) @@ -837,6 +839,8 @@ log("BACKTRACE:'%s'", (build_ids + backtrace).c_str()); { dd.SaveText(FILENAME_MEMORYMAP, "memory map of the crashed C/C++ application, not implemented yet"); } + std::string rating = ssprintf("%d\n", rate_backtrace(backtrace)); + dd.SaveText(FILENAME_RATING, rating); } void CAnalyzerCCpp::Init() -- cgit From 4144647a53c8338da2d958b78fb4b2e6096a3ea2 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 23 Oct 2009 15:29:53 +0200 Subject: removing forgotted debugging printout Signed-off-by: Denys Vlasenko --- lib/Plugins/CCpp.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'lib/Plugins/CCpp.cpp') diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp index 133811f..a2cb86e 100644 --- a/lib/Plugins/CCpp.cpp +++ b/lib/Plugins/CCpp.cpp @@ -834,7 +834,6 @@ void CAnalyzerCCpp::CreateReport(const std::string& pDebugDumpDir, int force) dd.Open(pDebugDumpDir); dd.SaveText(FILENAME_BACKTRACE, build_ids + backtrace); -log("BACKTRACE:'%s'", (build_ids + backtrace).c_str()); if (m_bMemoryMap) { dd.SaveText(FILENAME_MEMORYMAP, "memory map of the crashed C/C++ application, not implemented yet"); -- cgit From b2ef9492881a0713cb8856b146570b261f57689e Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 23 Oct 2009 15:40:00 +0200 Subject: updates to abrt-debuginfo-install (but it is still ifdef'ed out) Signed-off-by: Denys Vlasenko --- lib/Plugins/CCpp.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'lib/Plugins/CCpp.cpp') diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp index a2cb86e..7d6708f 100644 --- a/lib/Plugins/CCpp.cpp +++ b/lib/Plugins/CCpp.cpp @@ -265,7 +265,7 @@ static void GetBacktrace(const std::string& pDebugDumpDir, std::string& pBacktra // when/if gdb supports it: // (https://bugzilla.redhat.com/show_bug.cgi?id=528668): //args[2] = (char*)"-ex"; - //args[3] = "set debug-file-directory /usr/lib/debug/.build-id:/var/cache/abrt-di/usr/lib/debug/.build-id"; + //args[3] = "set debug-file-directory /usr/lib/debug:/var/cache/abrt-di/usr/lib/debug"; /* * Unfortunately, "file BINARY_FILE" doesn't work well if BINARY_FILE * was deleted (as often happens during system updates): @@ -656,23 +656,22 @@ static void InstallDebugInfos(const std::string& pDebugDumpDir, std::string& bui { update_client(_("Searching for debug-info packages...")); - int pipein[2], pipeout[2]; //TODO: get rid of pipein. Can we use ExecVP? - xpipe(pipein); + int pipeout[2]; //TODO: can we use ExecVP? xpipe(pipeout); pid_t child = fork(); if (child < 0) { - /*close(pipein[0]); close(pipeout[0]); - why bother */ - /*close(pipein[1]); close(pipeout[1]); */ + /*close(pipeout[0]); - why bother */ + /*close(pipeout[1]); */ perror_msg_and_die("fork"); } if (child == 0) { - close(pipein[1]); close(pipeout[0]); - xmove_fd(pipein[0], STDIN_FILENO); xmove_fd(pipeout[1], STDOUT_FILENO); + close(STDIN_FILENO); + xopen("/dev/null", O_RDONLY); /* Not a good idea, we won't see any error messages */ /*close(STDERR_FILENO);*/ @@ -686,7 +685,6 @@ static void InstallDebugInfos(const std::string& pDebugDumpDir, std::string& bui exit(1); } - close(pipein[0]); close(pipeout[1]); update_client(_("Downloading and installing debug-info packages...")); -- cgit