summaryrefslogtreecommitdiffstats
path: root/lib/Plugins/CCpp.cpp
diff options
context:
space:
mode:
authorJiri Moskovcak <jmoskovc@redhat.com>2009-02-19 15:23:00 +0100
committerJiri Moskovcak <jmoskovc@redhat.com>2009-02-19 15:23:00 +0100
commit2f907417d37d83cefad7950397bd141c0586b1d5 (patch)
tree12d58967607cac7f300e7dcaee456fdfe9bd95a1 /lib/Plugins/CCpp.cpp
parentb472b75f70c7e9144fb29f9d142e9f52f4caab39 (diff)
parent0c899d52e5e42caf8c5c394ef6c142c08ac38858 (diff)
downloadabrt-2f907417d37d83cefad7950397bd141c0586b1d5.tar.gz
abrt-2f907417d37d83cefad7950397bd141c0586b1d5.tar.xz
abrt-2f907417d37d83cefad7950397bd141c0586b1d5.zip
Merge branch 'master' of git://git.fedorahosted.org/git/crash-catcher
Conflicts: lib/DBus/Makefile.am lib/DBus/dbus-crash-catcher.conf lib/DBus/dbus-crashcatcher.conf src/Daemon/Makefile.am src/Daemon/dbus-crashcatcher.conf
Diffstat (limited to 'lib/Plugins/CCpp.cpp')
-rw-r--r--lib/Plugins/CCpp.cpp42
1 files changed, 41 insertions, 1 deletions
diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp
index 59b2f0e..f2c1723 100644
--- a/lib/Plugins/CCpp.cpp
+++ b/lib/Plugins/CCpp.cpp
@@ -24,14 +24,51 @@
#include <ctype.h>
#include "DebugDump.h"
#include <sstream>
+#include <iostream>
#define CORE_PATTERN_IFACE "/proc/sys/kernel/core_pattern"
#define CORE_PATTERN "|"CCPP_HOOK_PATH" %p %s"
+#define DEBUGINFO_INSTALL "debuginfo-install -y "
+
CLanguageCCpp::CLanguageCCpp() :
m_bMemoryMap(false)
{}
+void CLanguageCCpp::InstallDebugInfos(const std::string& pPackage)
+{
+ char line[1024];
+ std::string command = DEBUGINFO_INSTALL + pPackage;
+ std::string packageName = pPackage.substr(0, pPackage.rfind("-", pPackage.rfind("-") - 1));
+ std::string packageERV = pPackage.substr(packageName.length());
+ std::string installed = "Package "+packageName+"-debuginfo"+packageERV+" already installed and latest version";
+ std::string canNotInstall = "No debuginfo packages available to install";
+ FILE *fp = popen(command.c_str(), "r");
+ if (fp == NULL)
+ {
+ throw "CLanguageCCpp::InstallDebugInfos(): cannot install debuginfos for " + pPackage ;
+ }
+ while (fgets(line, sizeof(line), fp))
+ {
+ std::string text = line;
+ std::cerr << text;
+ if (text.find(installed) != std::string::npos)
+ {
+ pclose(fp);
+ return;
+ }
+ if (text.find(canNotInstall) != std::string::npos)
+ {
+ pclose(fp);
+ throw "CLanguageCCpp::InstallDebugInfos(): cannot install debuginfos for " + pPackage ;
+ }
+ }
+ if (pclose(fp) != 0)
+ {
+ throw "CLanguageCCpp::InstallDebugInfos(): cannot install debuginfos for " + pPackage ;
+ }
+}
+
std::string CLanguageCCpp::GetLocalUUID(const std::string& pDebugDumpDir)
{
std::stringstream ss;
@@ -60,10 +97,13 @@ std::string CLanguageCCpp::GetGlobalUUID(const std::string& pDebugDumpDir)
void CLanguageCCpp::CreateReport(const std::string& pDebugDumpDir)
{
+ std::string package;
CDebugDump dd;
dd.Open(pDebugDumpDir);
+ dd.LoadText(FILENAME_PACKAGE, package);
+
+ InstallDebugInfos(package);
- // TODO: install or mount debug-infos, gun gdb/archer and get backtrace
dd.SaveText(FILENAME_TEXTDATA1, "backtrace of the crashed C/C++ application");
if (m_bMemoryMap)
{