summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--abrt.spec4
-rw-r--r--lib/MiddleWare/Action.h17
-rw-r--r--lib/MiddleWare/Analyzer.h12
-rw-r--r--lib/MiddleWare/CrashTypes.h1
-rw-r--r--lib/MiddleWare/Makefile.am6
-rw-r--r--lib/MiddleWare/MiddleWare.cpp90
-rw-r--r--lib/MiddleWare/MiddleWare.h18
-rw-r--r--lib/MiddleWare/Plugin.h23
-rw-r--r--lib/MiddleWare/PluginManager.cpp25
-rw-r--r--lib/MiddleWare/PluginManager.h8
-rw-r--r--lib/Plugins/CCpp.cpp42
-rw-r--r--lib/Plugins/CCpp.h19
-rw-r--r--lib/Plugins/Kerneloops.cpp6
-rw-r--r--lib/Plugins/Kerneloops.h14
-rw-r--r--lib/Plugins/KerneloopsDmesg.cpp4
-rw-r--r--lib/Plugins/KerneloopsReporter.cpp10
-rw-r--r--lib/Plugins/KerneloopsReporter.h18
-rw-r--r--lib/Plugins/Logger.cpp14
-rw-r--r--lib/Plugins/Logger.h8
-rw-r--r--lib/Plugins/Mailx.cpp22
-rw-r--r--lib/Plugins/Mailx.h8
-rw-r--r--lib/Plugins/Makefile.am14
-rw-r--r--lib/Plugins/SQLite3.cpp10
-rw-r--r--lib/Plugins/SQLite3.h7
-rw-r--r--lib/Utils/DebugDump.h3
-rw-r--r--lib/Utils/Makefile.am2
-rw-r--r--lib/Utils/Settings.h98
-rw-r--r--src/Hooks/CCpp.cpp2
29 files changed, 277 insertions, 233 deletions
diff --git a/ChangeLog b/ChangeLog
index 1a50eab6..9146129b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+* Thu Mar 19 2009 Zdenek Prikryl <zprikryl@redhat.com>
+- replaced language and application plugins by analyzer plugin
+- added action plugin
+- simplify plugin iface
+
* Mon Feb 2 2009 Jiri Moskovcak <jmoskovc@redhat.com>
- switch from dbus SESSION bus to SYSTEM bus
- send message thru dbus low-level api instead of glib
diff --git a/abrt.spec b/abrt.spec
index f4f9e885..8f9bed53 100644
--- a/abrt.spec
+++ b/abrt.spec
@@ -61,7 +61,7 @@ Requires: %{name} = %{version}-%{release}
%description addon-ccpp
This package contains hook for C/C++ crashed programs and %{name}'s C/C++
-language plugin.
+analyzer plugin.
%package addon-kerneloops
Summary: %{name}'s kerneloops addon
@@ -71,7 +71,7 @@ Requires: %{name} = %{version}-%{release}
%description addon-kerneloops
This package contains hook for kernel crashes information collecting.
-Application plugin.
+analyzer plugin.
%package plugin-kerneloopsreporter
Summary: %{name}'s kerneloops reporter plugin
diff --git a/lib/MiddleWare/Action.h b/lib/MiddleWare/Action.h
index 8b1d7eca..9a2c2f11 100644
--- a/lib/MiddleWare/Action.h
+++ b/lib/MiddleWare/Action.h
@@ -1,5 +1,5 @@
/*
- Application.h - header file for application plugin
+ Action.h - header file for action plugin
Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com)
Copyright (C) 2009 RedHat inc.
@@ -19,19 +19,18 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef APPLICATION_H_
-#define APPLICATION_H_
+#ifndef ACTION_H_
+#define ACTION_H_
#include <string>
#include "Plugin.h"
-class CApplication : public CPlugin
+class CAction : public CPlugin
{
public:
- virtual ~CApplication() {}
- virtual std::string GetLocalUUID(const std::string& pDebugDumpPath) = 0;
- virtual std::string GetGlobalUUID(const std::string& pDebugDumpPath) = 0;
- virtual void CreateReport(const std::string& pDebugDumpPath) = 0;
+ virtual ~CAction() {}
+ virtual void Run(const std::string& pDebugDumpDir,
+ const std::string& pArgs) = 0;
};
-#endif /*APPLICATION_H_*/
+#endif /*ACTION_H_*/
diff --git a/lib/MiddleWare/Analyzer.h b/lib/MiddleWare/Analyzer.h
index 60e82757..dda976ff 100644
--- a/lib/MiddleWare/Analyzer.h
+++ b/lib/MiddleWare/Analyzer.h
@@ -1,5 +1,5 @@
/*
- Language.h - header file for language plugin
+ Analyzer.h - header file for analyzer plugin
Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com)
Copyright (C) 2009 RedHat inc.
@@ -19,19 +19,19 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef LANGUAGE_H_
-#define LANGUAGE_H_
+#ifndef ANALYZER_H_
+#define ANALYZER_H_
#include <string>
#include "Plugin.h"
-class CLanguage : public CPlugin
+class CAnalyzer : public CPlugin
{
public:
- virtual ~CLanguage() {}
+ virtual ~CAnalyzer() {}
virtual std::string GetLocalUUID(const std::string& pDebugDumpPath) = 0;
virtual std::string GetGlobalUUID(const std::string& pDebugDumpPath) = 0;
virtual void CreateReport(const std::string& pDebugDumpPath) = 0;
};
-#endif /*LANGUAGE_H_*/
+#endif /*ANALYZER_H_*/
diff --git a/lib/MiddleWare/CrashTypes.h b/lib/MiddleWare/CrashTypes.h
index 07f1f028..f9fe625c 100644
--- a/lib/MiddleWare/CrashTypes.h
+++ b/lib/MiddleWare/CrashTypes.h
@@ -3,6 +3,7 @@
#include <string>
#include <map>
+#include <vector>
typedef std::map<std::string, std::string> map_crash_t;
diff --git a/lib/MiddleWare/Makefile.am b/lib/MiddleWare/Makefile.am
index 27eda453..0a618a8b 100644
--- a/lib/MiddleWare/Makefile.am
+++ b/lib/MiddleWare/Makefile.am
@@ -2,10 +2,10 @@ lib_LTLIBRARIES = libMiddleWare.la
libMiddleWare_la_SOURCES = MiddleWare.cpp MiddleWare.h PluginManager.cpp \
PluginManager.h ABRTPlugin.cpp \
ABRTPlugin.h DynamicLibrary.cpp \
- DynamicLibrary.h Settings.h Settings.cpp \
+ DynamicLibrary.h \
RPM.cpp RPM.h Plugin.h CrashTypes.h \
- MiddleWareTypes.h Application.h Database.h \
- Reporter.h Language.h
+ MiddleWareTypes.h Action.h Database.h \
+ Reporter.h Analyzer.h
libMiddleWare_la_LIBADD = $(DL_LIBS) ../Utils/libUtils.la $(RPM_LIBS)
libMiddleWare_la_LDFLAGS = -version-info 0:1:0
libMiddleWare_la_CPPFLAGS = -I$(srcdir)/../Utils $(RPM_CFLAGS)
diff --git a/lib/MiddleWare/MiddleWare.cpp b/lib/MiddleWare/MiddleWare.cpp
index 02bfc256..d1ee50f7 100644
--- a/lib/MiddleWare/MiddleWare.cpp
+++ b/lib/MiddleWare/MiddleWare.cpp
@@ -147,46 +147,25 @@ void CMiddleWare::UnRegisterPlugin(const std::string& pName)
}
-std::string CMiddleWare::GetLocalUUIDLanguage(const std::string& pLanguage,
- const std::string& pDebugDumpDir)
+std::string CMiddleWare::GetLocalUUID(const std::string& pAnalyzer,
+ const std::string& pDebugDumpDir)
{
- CLanguage* language = m_pPluginManager->GetLanguage(pLanguage);
- return language->GetLocalUUID(pDebugDumpDir);
+ CAnalyzer* analyzer = m_pPluginManager->GetAnalyzer(pAnalyzer);
+ return analyzer->GetLocalUUID(pDebugDumpDir);
}
-std::string CMiddleWare::GetGlobalUUIDLanguage(const std::string& pLanguage,
- const std::string& pDebugDumpDir)
-{
- CLanguage* language = m_pPluginManager->GetLanguage(pLanguage);
- return language->GetGlobalUUID(pDebugDumpDir);
-}
-
-void CMiddleWare::CreateReportLanguage(const std::string& pLanguage,
+std::string CMiddleWare::GetGlobalUUID(const std::string& pAnalyzer,
const std::string& pDebugDumpDir)
{
- CLanguage* language = m_pPluginManager->GetLanguage(pLanguage);
- return language->CreateReport(pDebugDumpDir);
+ CAnalyzer* analyzer = m_pPluginManager->GetAnalyzer(pAnalyzer);
+ return analyzer->GetGlobalUUID(pDebugDumpDir);
}
-std::string CMiddleWare::GetLocalUUIDApplication(const std::string& pApplication,
- const std::string& pDebugDumpDir)
+void CMiddleWare::CreateReport(const std::string& pAnalyzer,
+ const std::string& pDebugDumpDir)
{
- CApplication* application = m_pPluginManager->GetApplication(pApplication);
- return application->GetLocalUUID(pDebugDumpDir);
-}
-
-std::string CMiddleWare::GetGlobalUUIDApplication(const std::string& pApplication,
- const std::string& pDebugDumpDir)
-{
- CApplication* application = m_pPluginManager->GetApplication(pApplication);
- return application->GetGlobalUUID(pDebugDumpDir);
-}
-
-void CMiddleWare::CreateReportApplication(const std::string& pApplication,
- const std::string& pDebugDumpDir)
-{
- CApplication* application = m_pPluginManager->GetApplication(pApplication);
- return application->CreateReport(pDebugDumpDir);
+ CAnalyzer* analyzer = m_pPluginManager->GetAnalyzer(pAnalyzer);
+ return analyzer->CreateReport(pDebugDumpDir);
}
void CMiddleWare::CreateReport(const std::string& pUUID,
@@ -204,28 +183,21 @@ void CMiddleWare::CreateReport(const std::string& pUUID,
throw std::string("CMiddleWare::CreateReport(): UUID '"+pUUID+"' is not in database.");
}
- std::string appLan;
+ std::string analyzer;
std::string UUID;
CDebugDump dd;
dd.Open(row.m_sDebugDumpDir);
- if (dd.Exist(FILENAME_APPLICATION))
- {
- dd.LoadText(FILENAME_APPLICATION, appLan);
- CreateReportApplication(appLan, row.m_sDebugDumpDir);
- UUID = GetGlobalUUIDApplication(appLan, row.m_sDebugDumpDir);
- }
- if (dd.Exist(FILENAME_LANGUAGE))
- {
- dd.LoadText(FILENAME_LANGUAGE, appLan);
- CreateReportLanguage(appLan, row.m_sDebugDumpDir);
- UUID = GetGlobalUUIDLanguage(appLan, row.m_sDebugDumpDir);
- }
+
+ dd.LoadText(FILENAME_ANALYZER, analyzer);
+ CreateReport(analyzer, row.m_sDebugDumpDir);
+ UUID = GetGlobalUUID(analyzer, row.m_sDebugDumpDir);
+
dd.SaveText(FILENAME_UUID, UUID);
dd.Close();
DebugDump2Report(row.m_sDebugDumpDir, pCrashReport);
- pCrashReport.m_sMWID = appLan + ";" + pUID + ";" + pUUID ;
+ pCrashReport.m_sMWID = analyzer + ";" + pUID + ";" + pUUID ;
}
void CMiddleWare::Report(const crash_report_t& pCrashReport)
@@ -317,8 +289,7 @@ int CMiddleWare::SavePackageDescriptionToDebugDump(const std::string& pDebugDump
dd.LoadText(FILENAME_EXECUTABLE, executable);
if (executable == "kernel")
{
- package = "kernel";
- packageName = package;
+ packageName = package = "kernel";
}
else
{
@@ -354,28 +325,15 @@ int CMiddleWare::SavePackageDescriptionToDebugDump(const std::string& pDebugDump
int CMiddleWare::SaveUUIDToDebugDump(const std::string& pDebugDumpDir)
{
+ std::string analyzer;
std::string UUID;
CDebugDump dd;
dd.Open(pDebugDumpDir);
- if (dd.Exist(FILENAME_APPLICATION))
- {
- std::string application;
- dd.LoadText(FILENAME_APPLICATION, application);
- UUID = GetLocalUUIDApplication(application, pDebugDumpDir);
- }
- if (dd.Exist(FILENAME_LANGUAGE))
- {
- std::string language;
- dd.LoadText(FILENAME_LANGUAGE, language);
- UUID = GetLocalUUIDLanguage(language, pDebugDumpDir);
- }
- if (UUID == "")
- {
- dd.Delete();
- dd.Close();
- return 0;
- }
+
+ dd.LoadText(FILENAME_ANALYZER, analyzer);
+ UUID = GetLocalUUID(analyzer, pDebugDumpDir);
+
dd.SaveText(FILENAME_UUID, UUID);
dd.Close();
diff --git a/lib/MiddleWare/MiddleWare.h b/lib/MiddleWare/MiddleWare.h
index 6c943113..def29ce6 100644
--- a/lib/MiddleWare/MiddleWare.h
+++ b/lib/MiddleWare/MiddleWare.h
@@ -48,18 +48,12 @@ class CMiddleWare
bool m_bOpenGPGCheck;
- std::string GetLocalUUIDLanguage(const std::string& pLanguage,
- const std::string& pDebugDumpDir);
- std::string GetGlobalUUIDLanguage(const std::string& pLanguage,
- const std::string& pDebugDumpDir);
- void CreateReportLanguage(const std::string& pLanguage,
- const std::string& pDebugDumpDir);
- std::string GetLocalUUIDApplication(const std::string& pApplication,
- const std::string& pDebugDumpDir);
- std::string GetGlobalUUIDApplication(const std::string& pApplication,
- const std::string& pDebugDumpDir);
- void CreateReportApplication(const std::string& pApplication,
- const std::string& pDebugDumpDir);
+ std::string GetLocalUUID(const std::string& pAnalyzer,
+ const std::string& pDebugDumpDir);
+ std::string GetGlobalUUID(const std::string& pAnalyzer,
+ const std::string& pDebugDumpDir);
+ void CreateReport(const std::string& pAnalyzer,
+ const std::string& pDebugDumpDir);
void LoadSettings(const std::string& pPath);
diff --git a/lib/MiddleWare/Plugin.h b/lib/MiddleWare/Plugin.h
index 014733d8..e4ebc3cb 100644
--- a/lib/MiddleWare/Plugin.h
+++ b/lib/MiddleWare/Plugin.h
@@ -25,7 +25,6 @@
#include <string>
#include <map>
-#include "Settings.h"
#define PLUGINS_MAGIC_NUMBER 1
@@ -38,13 +37,13 @@ class CPlugin
public:
virtual ~CPlugin() {}
- virtual void Init() = 0;
- virtual void DeInit() = 0;
- virtual void SetSettings(const map_settings_t& pSettings) = 0;
+ virtual void Init() {}
+ virtual void DeInit() {}
+ virtual void LoadSettings(const std::string& pPath) {}
};
-typedef enum { LANGUAGE, REPORTER, APPLICATION, DATABASE } plugin_type_t;
-const char* const plugin_type_str_t[] = {"Language", "Reporter", "Application", "Database"};
+typedef enum { ANALYZER, ACTION, REPORTER, DATABASE } plugin_type_t;
+const char* const plugin_type_str_t[] = {"Analyzer", "Action", "Reporter", "Database"};
typedef struct SPluginInfo
{
@@ -59,19 +58,11 @@ typedef struct SPluginInfo
#define PLUGIN_IFACE extern "C"
-#define PLUGIN_INIT(plugin_class)\
+#define PLUGIN_INFO(type, plugin_class, name, version, description, email, www)\
PLUGIN_IFACE CPlugin* plugin_new()\
{\
- plugin_class* plugin = new plugin_class();\
- if (plugin == NULL)\
- {\
- throw std::string("Not enought memory");\
- }\
- return plugin;\
+ return new plugin_class();\
}\
-
-
-#define PLUGIN_INFO(type, name, version, description, email, www)\
PLUGIN_IFACE const plugin_info_t plugin_info =\
{\
type,\
diff --git a/lib/MiddleWare/PluginManager.cpp b/lib/MiddleWare/PluginManager.cpp
index e0def74a..03e636ca 100644
--- a/lib/MiddleWare/PluginManager.cpp
+++ b/lib/MiddleWare/PluginManager.cpp
@@ -79,7 +79,7 @@ void CPluginManager::LoadPlugin(const std::string& pName)
std::string libPath = m_sPlugisLibDir + "/" + PLUGINS_LIB_PREFIX + pName + "." + PLUGINS_LIB_EXTENSION;
abrtPlugin = new CABRTPlugin(libPath);
if (abrtPlugin->GetMagicNumber() != PLUGINS_MAGIC_NUMBER ||
- (abrtPlugin->GetType() < LANGUAGE && abrtPlugin->GetType() > DATABASE))
+ (abrtPlugin->GetType() < ANALYZER && abrtPlugin->GetType() > DATABASE))
{
throw std::string("non-compatible plugin");
}
@@ -117,10 +117,9 @@ void CPluginManager::RegisterPlugin(const std::string& pName)
{
map_settings_t settings;
std::string path = m_sPlugisConfDir + "/" + pName + "." + PLUGINS_CONF_EXTENSION;
- load_settings(path, settings);
CPlugin* plugin = m_mapABRTPlugins[pName]->PluginNew();
plugin->Init();
- plugin->SetSettings(settings);
+ plugin->LoadSettings(path);
m_mapPlugins[pName] = plugin;
std::cerr << "Registred plugin " << pName << "("
<< plugin_type_str_t[m_mapABRTPlugins[pName]->GetType()]
@@ -145,14 +144,14 @@ void CPluginManager::UnRegisterPlugin(const std::string& pName)
}
}
-CLanguage* CPluginManager::GetLanguage(const std::string& pName)
+CAnalyzer* CPluginManager::GetAnalyzer(const std::string& pName)
{
if (m_mapPlugins.find(pName) == m_mapPlugins.end())
{
- throw std::string("CPluginManager::GetLanguage():"
- "Language plugin: '"+pName+"' is not loaded.");
+ throw std::string("CPluginManager::GetAnalyzer():"
+ "Analyzer plugin: '"+pName+"' is not loaded.");
}
- return (CLanguage*) m_mapPlugins[pName];
+ return dynamic_cast<CAnalyzer*>(m_mapPlugins[pName]);
}
CReporter* CPluginManager::GetReporter(const std::string& pName)
@@ -162,17 +161,17 @@ CReporter* CPluginManager::GetReporter(const std::string& pName)
throw std::string("CPluginManager::GetReporter():"
"Reporter plugin: '"+pName+"' is not loaded.");
}
- return (CReporter*) m_mapPlugins[pName];
+ return dynamic_cast<CReporter*>(m_mapPlugins[pName]);
}
-CApplication* CPluginManager::GetApplication(const std::string& pName)
+CAction* CPluginManager::GetAction(const std::string& pName)
{
if (m_mapPlugins.find(pName) == m_mapPlugins.end())
{
- throw std::string("CPluginManager::GetApplication():"
- "Application plugin: '"+pName+"' is not loaded.");
+ throw std::string("CPluginManager::GetAction():"
+ "Action plugin: '"+pName+"' is not loaded.");
}
- return (CApplication*) m_mapPlugins[pName];
+ return dynamic_cast<CAction*>(m_mapPlugins[pName]);
}
CDatabase* CPluginManager::GetDatabase(const std::string& pName)
@@ -182,6 +181,6 @@ CDatabase* CPluginManager::GetDatabase(const std::string& pName)
throw std::string("CPluginManager::GetDatabase():"
"Database plugin: '"+pName+"' is not loaded.");
}
- return (CDatabase*) m_mapPlugins[pName];
+ return dynamic_cast<CDatabase*>(m_mapPlugins[pName]);
}
diff --git a/lib/MiddleWare/PluginManager.h b/lib/MiddleWare/PluginManager.h
index 9f5979a1..8ef59910 100644
--- a/lib/MiddleWare/PluginManager.h
+++ b/lib/MiddleWare/PluginManager.h
@@ -27,10 +27,10 @@
#include <string>
#include "ABRTPlugin.h"
#include "Plugin.h"
-#include "Language.h"
+#include "Analyzer.h"
#include "Reporter.h"
#include "Database.h"
-#include "Application.h"
+#include "Action.h"
class CPluginManager
{
@@ -59,9 +59,9 @@ class CPluginManager
void RegisterPlugin(const std::string& pName);
void UnRegisterPlugin(const std::string& pName);
- CLanguage* GetLanguage(const std::string& pName);
+ CAnalyzer* GetAnalyzer(const std::string& pName);
CReporter* GetReporter(const std::string& pName);
- CApplication* GetApplication(const std::string& pName);
+ CAction* GetAction(const std::string& pName);
CDatabase* GetDatabase(const std::string& pName);
};
diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp
index a6ca00c0..024ed1b9 100644
--- a/lib/Plugins/CCpp.cpp
+++ b/lib/Plugins/CCpp.cpp
@@ -1,5 +1,5 @@
/*
- DebugDump.cpp
+ CCpp.cpp
Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com)
Copyright (C) 2009 RedHat inc.
@@ -23,6 +23,7 @@
#include <fstream>
#include <ctype.h>
#include "DebugDump.h"
+#include "Settings.h"
#include <sstream>
#include <iostream>
#include <hash_map>
@@ -33,11 +34,11 @@
#define DEBUGINFO_COMMAND "debuginfo-install -y "
#define GDB_COMMAND "gdb -batch -x "
-CLanguageCCpp::CLanguageCCpp() :
+CAnalyzerCCpp::CAnalyzerCCpp() :
m_bMemoryMap(false)
{}
-void CLanguageCCpp::InstallDebugInfos(const std::string& pPackage)
+void CAnalyzerCCpp::InstallDebugInfos(const std::string& pPackage)
{
char line[1024];
std::string command = DEBUGINFO_COMMAND + pPackage;
@@ -50,7 +51,7 @@ void CLanguageCCpp::InstallDebugInfos(const std::string& pPackage)
if (fp == NULL)
{
- throw std::string("CLanguageCCpp::InstallDebugInfos(): cannot execute " + command) ;
+ throw std::string("CAnalyzerCCpp::InstallDebugInfos(): cannot execute " + command) ;
}
while (fgets(line, sizeof(line), fp))
{
@@ -65,16 +66,16 @@ void CLanguageCCpp::InstallDebugInfos(const std::string& pPackage)
if (text.find(canNotInstall) != std::string::npos)
{
pclose(fp);
- throw std::string("CLanguageCCpp::InstallDebugInfos(): cannot install debuginfos for " + pPackage + " (" + canNotInstall + ")") ;
+ throw std::string("CAnalyzerCCpp::InstallDebugInfos(): cannot install debuginfos for " + pPackage + " (" + canNotInstall + ")") ;
}
}
if (pclose(fp) != 0)
{
- throw std::string("CLanguageCCpp::InstallDebugInfos(): cannot install debuginfos for " + pPackage) ;
+ throw std::string("CAnalyzerCCpp::InstallDebugInfos(): cannot install debuginfos for " + pPackage) ;
}
}
-void CLanguageCCpp::GetBacktrace(const std::string& pDebugDumpDir, std::string& pBacktrace)
+void CAnalyzerCCpp::GetBacktrace(const std::string& pDebugDumpDir, std::string& pBacktrace)
{
std::string tmpFile = "/tmp/" + pDebugDumpDir.substr(pDebugDumpDir.rfind("/"));
std::ofstream fTmp;
@@ -94,13 +95,13 @@ void CLanguageCCpp::GetBacktrace(const std::string& pDebugDumpDir, std::string&
}
else
{
- throw "CLanguageCCpp::GetBacktrace(): cannot create gdb script " + tmpFile ;
+ throw "CAnalyzerCCpp::GetBacktrace(): cannot create gdb script " + tmpFile ;
}
std::string command = GDB_COMMAND + tmpFile;
RunCommand(command, pBacktrace);
}
-void CLanguageCCpp::GetIndependentBacktrace(const std::string& pBacktrace, std::string& pIndependentBacktrace)
+void CAnalyzerCCpp::GetIndependentBacktrace(const std::string& pBacktrace, std::string& pIndependentBacktrace)
{
int ii = 0;
while (ii < pBacktrace.length())
@@ -143,14 +144,14 @@ void CLanguageCCpp::GetIndependentBacktrace(const std::string& pBacktrace, std::
}
}
-void CLanguageCCpp::RunCommand(const std::string& pCommand, std::string& pOutput)
+void CAnalyzerCCpp::RunCommand(const std::string& pCommand, std::string& pOutput)
{
char line[1024];
std::string output;
FILE *fp = popen(pCommand.c_str(), "r");
if (fp == NULL)
{
- throw "CLanguageCCpp::GetBacktrace(): cannot execute " + pCommand ;
+ throw "CAnalyzerCCpp::GetBacktrace(): cannot execute " + pCommand ;
}
pOutput = "";
while (fgets(line, 1024, fp) != NULL)
@@ -163,7 +164,7 @@ void CLanguageCCpp::RunCommand(const std::string& pCommand, std::string& pOutput
pclose(fp);
}
-std::string CLanguageCCpp::GetLocalUUID(const std::string& pDebugDumpDir)
+std::string CAnalyzerCCpp::GetLocalUUID(const std::string& pDebugDumpDir)
{
std::stringstream ss;
@@ -181,7 +182,7 @@ std::string CLanguageCCpp::GetLocalUUID(const std::string& pDebugDumpDir)
return ss.str();
}
-std::string CLanguageCCpp::GetGlobalUUID(const std::string& pDebugDumpDir)
+std::string CAnalyzerCCpp::GetGlobalUUID(const std::string& pDebugDumpDir)
{
std::stringstream ss;
std::string backtrace;
@@ -198,7 +199,7 @@ std::string CLanguageCCpp::GetGlobalUUID(const std::string& pDebugDumpDir)
return ss.str();
}
-void CLanguageCCpp::CreateReport(const std::string& pDebugDumpDir)
+void CAnalyzerCCpp::CreateReport(const std::string& pDebugDumpDir)
{
std::string package;
std::string backtrace;
@@ -234,7 +235,7 @@ void CLanguageCCpp::CreateReport(const std::string& pDebugDumpDir)
dd.Close();
}
-void CLanguageCCpp::Init()
+void CAnalyzerCCpp::Init()
{
std::ifstream fInCorePattern;
fInCorePattern.open(CORE_PATTERN_IFACE);
@@ -253,7 +254,7 @@ void CLanguageCCpp::Init()
}
-void CLanguageCCpp::DeInit()
+void CAnalyzerCCpp::DeInit()
{
std::ofstream fOutCorePattern;
fOutCorePattern.open(CORE_PATTERN_IFACE);
@@ -264,10 +265,13 @@ void CLanguageCCpp::DeInit()
}
}
-void CLanguageCCpp::SetSettings(const map_settings_t& pSettings)
+void CAnalyzerCCpp::LoadSettings(const std::string& pPath)
{
- if (pSettings.find("MemoryMap")!= pSettings.end())
+ map_settings_t settings;
+ load_settings(pPath, settings);
+
+ if (settings.find("MemoryMap")!= settings.end())
{
- m_bMemoryMap = pSettings.find("MemoryMap")->second == "yes";
+ m_bMemoryMap = settings["MemoryMap"] == "yes";
}
}
diff --git a/lib/Plugins/CCpp.h b/lib/Plugins/CCpp.h
index 9d169ee4..e89d7000 100644
--- a/lib/Plugins/CCpp.h
+++ b/lib/Plugins/CCpp.h
@@ -1,5 +1,5 @@
/*
- CCpp.h - header file for C/C++ language plugin
+ CCpp.h - header file for C/C++ analyzer plugin
- it can ger UUID and memory maps from core files
Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com)
@@ -25,9 +25,9 @@
#include <string>
#include "Plugin.h"
-#include "Language.h"
+#include "Analyzer.h"
-class CLanguageCCpp : public CLanguage
+class CAnalyzerCCpp : public CAnalyzer
{
private:
bool m_bMemoryMap;
@@ -38,24 +38,23 @@ class CLanguageCCpp : public CLanguage
void RunCommand(const std::string&pCommand, std::string& pOutput);
public:
- CLanguageCCpp();
- virtual ~CLanguageCCpp() {}
+ CAnalyzerCCpp();
+ virtual ~CAnalyzerCCpp() {}
std::string GetLocalUUID(const std::string& pDebugDumpDir);
std::string GetGlobalUUID(const std::string& pDebugDumpDir);
void CreateReport(const std::string& pDebugDumpDir);
void Init();
void DeInit();
- void SetSettings(const map_settings_t& pSettings);
+ void LoadSettings(const std::string& pPath);
};
-PLUGIN_INFO(LANGUAGE,
+PLUGIN_INFO(ANALYZER,
+ CAnalyzerCCpp,
"CCpp",
"0.0.1",
- "Simple C/C++ language plugin.",
+ "Simple C/C++ analuzer plugin.",
"zprikryl@redhat.com",
"https://fedorahosted.org/crash-catcher/wiki");
-PLUGIN_INIT(CLanguageCCpp);
-
#endif /* CCPP */
diff --git a/lib/Plugins/Kerneloops.cpp b/lib/Plugins/Kerneloops.cpp
index 2c0c3e78..07c8e066 100644
--- a/lib/Plugins/Kerneloops.cpp
+++ b/lib/Plugins/Kerneloops.cpp
@@ -31,7 +31,7 @@
#include "Kerneloops.h"
#include "KerneloopsDmesg.h"
-std::string CApplicationKerneloops::GetLocalUUID(const std::string& pDebugDumpDir)
+std::string CAnalyzerKerneloops::GetLocalUUID(const std::string& pDebugDumpDir)
{
std::string m_sOops;
std::stringstream m_sHash;
@@ -53,12 +53,12 @@ std::string CApplicationKerneloops::GetLocalUUID(const std::string& pDebugDumpDi
return m_sHash.str();
}
-std::string CApplicationKerneloops::GetGlobalUUID(const std::string& pDebugDumpDir)
+std::string CAnalyzerKerneloops::GetGlobalUUID(const std::string& pDebugDumpDir)
{
return GetLocalUUID(pDebugDumpDir);
}
-void CApplicationKerneloops::Init()
+void CAnalyzerKerneloops::Init()
{
scan_logs();
}
diff --git a/lib/Plugins/Kerneloops.h b/lib/Plugins/Kerneloops.h
index e8137b63..52cba4e5 100644
--- a/lib/Plugins/Kerneloops.h
+++ b/lib/Plugins/Kerneloops.h
@@ -26,30 +26,26 @@
#define __INCLUDE_GUARD_KERNELOOPS_H_
#include "Plugin.h"
-#include "Application.h"
+#include "Analyzer.h"
#include <string>
-class CApplicationKerneloops : public CApplication
+class CAnalyzerKerneloops : public CAnalyzer
{
public:
- CApplicationKerneloops() {}
- virtual ~CApplicationKerneloops() {}
+ virtual ~CAnalyzerKerneloops() {}
std::string GetLocalUUID(const std::string& pDebugDumpDir);
std::string GetGlobalUUID(const std::string& pDebugDumpDir);
void CreateReport(const std::string& pDebugDumpDir) {}
void Init();
- void DeInit() {}
- void SetSettings(const map_settings_t& pSettings) {}
};
-PLUGIN_INFO(APPLICATION,
+PLUGIN_INFO(ANALYZER,
+ CAnalyzerKerneloops,
"Kerneloops",
"0.0.1",
"Abrt's Kerneloops plugin.",
"anton@redhat.com",
"https://people.redhat.com/aarapov");
-PLUGIN_INIT(CApplicationKerneloops);
-
#endif
diff --git a/lib/Plugins/KerneloopsDmesg.cpp b/lib/Plugins/KerneloopsDmesg.cpp
index 0dea0e62..67f16fc4 100644
--- a/lib/Plugins/KerneloopsDmesg.cpp
+++ b/lib/Plugins/KerneloopsDmesg.cpp
@@ -183,7 +183,7 @@ static void fill_linepointers(char *buffer, int remove_syslog)
static inline int extract_version(char *linepointer, char *version)
{
int ret;
-
+
ret = 0;
if ((strstr(linepointer, "Pid") != NULL) ||
(strstr(linepointer, "comm") != NULL) ||
@@ -526,7 +526,7 @@ int scan_logs()
try
{
dd.Create(path);
- dd.SaveText(FILENAME_APPLICATION, "Kerneloops");
+ dd.SaveText(FILENAME_ANALYZER, "Kerneloops");
dd.SaveText(FILENAME_UID, "0");
dd.SaveText(FILENAME_EXECUTABLE, "kernel");
dd.SaveText(FILENAME_KERNEL, oops->version);
diff --git a/lib/Plugins/KerneloopsReporter.cpp b/lib/Plugins/KerneloopsReporter.cpp
index ef5f56f7..56947f07 100644
--- a/lib/Plugins/KerneloopsReporter.cpp
+++ b/lib/Plugins/KerneloopsReporter.cpp
@@ -25,6 +25,7 @@
*/
#include "DebugDump.h"
+#include "Settings.h"
#include "KerneloopsReporter.h"
#include <sstream>
@@ -87,10 +88,13 @@ void CKerneloopsReporter::Report(const crash_report_t& pReport)
curl_easy_cleanup(handle);
}
-void CKerneloopsReporter::SetSettings(const map_settings_t& pSettings)
+void CKerneloopsReporter::LoadSettings(const std::string& pPath)
{
- if (pSettings.find("SubmitURL") != pSettings.end())
+ map_settings_t settings;
+ load_settings(pPath, settings);
+
+ if (settings.find("SubmitURL") != settings.end())
{
- m_sSubmitURL = pSettings.find("SubmitURL")->second;
+ m_sSubmitURL = settings["SubmitURL"];
}
}
diff --git a/lib/Plugins/KerneloopsReporter.h b/lib/Plugins/KerneloopsReporter.h
index e7a96681..88628077 100644
--- a/lib/Plugins/KerneloopsReporter.h
+++ b/lib/Plugins/KerneloopsReporter.h
@@ -37,19 +37,17 @@ class CKerneloopsReporter : public CReporter
public:
CKerneloopsReporter();
virtual ~CKerneloopsReporter() {}
- void Init() {}
- void DeInit() {}
- void SetSettings(const map_settings_t& pSettings);
+
+ void LoadSettings(const std::string& pPath);
void Report(const crash_report_t& pReport);
};
PLUGIN_INFO(REPORTER,
- "KerneloopsReporter",
- "0.0.1",
- "Sends the Kerneloops crash information to Kerneloopsoops.org",
- "anton@redhat.com",
- "http://people.redhat.com/aarapov");
-
-PLUGIN_INIT(CKerneloopsReporter);
+ CKerneloopsReporter,
+ "KerneloopsReporter",
+ "0.0.1",
+ "Sends the Kerneloops crash information to Kerneloopsoops.org",
+ "anton@redhat.com",
+ "http://people.redhat.com/aarapov");
#endif
diff --git a/lib/Plugins/Logger.cpp b/lib/Plugins/Logger.cpp
index 32f45a35..e7579372 100644
--- a/lib/Plugins/Logger.cpp
+++ b/lib/Plugins/Logger.cpp
@@ -21,21 +21,25 @@
#include "Logger.h"
#include <fstream>
+#include "Settings.h"
CLogger::CLogger() :
m_sLogPath("/var/log/abrt-logger"),
m_bAppendLogs(true)
{}
-void CLogger::SetSettings(const map_settings_t& pSettings)
+void CLogger::LoadSettings(const std::string& pPath)
{
- if (pSettings.find("LogPath")!= pSettings.end())
+ map_settings_t settings;
+ load_settings(pPath, settings);
+
+ if (settings.find("LogPath")!= settings.end())
{
- m_sLogPath = pSettings.find("LogPath")->second;
+ m_sLogPath = settings["LogPath"];
}
- if (pSettings.find("AppendLogs")!= pSettings.end())
+ if (settings.find("AppendLogs")!= settings.end())
{
- m_bAppendLogs = pSettings.find("AppendLogs")->second == "yes";
+ m_bAppendLogs = settings["AppendLogs"] == "yes";
}
}
diff --git a/lib/Plugins/Logger.h b/lib/Plugins/Logger.h
index 9a4e304f..f6dcffd8 100644
--- a/lib/Plugins/Logger.h
+++ b/lib/Plugins/Logger.h
@@ -35,21 +35,17 @@ class CLogger : public CReporter
CLogger();
virtual ~CLogger() {}
- void Init() {}
- void DeInit() {}
- void SetSettings(const map_settings_t& pSettings);
-
+ void LoadSettings(const std::string& pPath);
void Report(const crash_report_t& pReport);
};
PLUGIN_INFO(REPORTER,
+ CLogger,
"Logger",
"0.0.1",
"Write a report to a specific file",
"zprikryl@redhat.com",
"https://fedorahosted.org/crash-catcher/wiki");
-PLUGIN_INIT(CLogger);
-
#endif /* LOGGER_H_ */
diff --git a/lib/Plugins/Mailx.cpp b/lib/Plugins/Mailx.cpp
index 11a9a6c7..1f83cb55 100644
--- a/lib/Plugins/Mailx.cpp
+++ b/lib/Plugins/Mailx.cpp
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <sstream>
#include "DebugDump.h"
+#include "Settings.h"
#define MAILX_COMMAND "/bin/mailx"
#define MAILX_SUBJECT "\"abrt automated bug report\""
@@ -124,22 +125,25 @@ void CMailx::Report(const crash_report_t& pReport)
SendEmail(ss.str());
}
-void CMailx::SetSettings(const map_settings_t& pSettings)
+void CMailx::LoadSettings(const std::string& pPath)
{
- if (pSettings.find("EmailFrom")!= pSettings.end())
+ map_settings_t settings;
+ load_settings(pPath, settings);
+
+ if (settings.find("EmailFrom")!= settings.end())
{
- m_sEmailFrom = pSettings.find("EmailFrom")->second;
+ m_sEmailFrom = settings["EmailFrom"];
}
- if (pSettings.find("EmailTo")!= pSettings.end())
+ if (settings.find("EmailTo")!= settings.end())
{
- m_sEmailTo = pSettings.find("EmailTo")->second;
+ m_sEmailTo = settings["EmailTo"];
}
- if (pSettings.find("Parameters")!= pSettings.end())
+ if (settings.find("Parameters")!= settings.end())
{
- m_sParameters = pSettings.find("Parameters")->second;
+ m_sParameters = settings["Parameters"];
}
- if (pSettings.find("SendBinaryData")!= pSettings.end())
+ if (settings.find("SendBinaryData")!= settings.end())
{
- m_bSendBinaryData = pSettings.find("SendBinaryData")->second == "yes";
+ m_bSendBinaryData = settings["SendBinaryData"] == "yes";
}
}
diff --git a/lib/Plugins/Mailx.h b/lib/Plugins/Mailx.h
index 1a644147..15072632 100644
--- a/lib/Plugins/Mailx.h
+++ b/lib/Plugins/Mailx.h
@@ -41,22 +41,18 @@ class CMailx : public CReporter
public:
CMailx();
virtual ~CMailx() {}
- void Init() {}
- void DeInit() {}
- void SetSettings(const map_settings_t& pSettings);
+ void LoadSettings(const std::string& pPath);
void Report(const crash_report_t& pReport);
};
PLUGIN_INFO(REPORTER,
+ CMailx,
"Mailx",
"0.0.1",
"Sends an email with a report via mailx command",
"zprikryl@redhat.com",
"https://fedorahosted.org/crash-catcher/wiki");
-PLUGIN_INIT(CMailx);
-
-
#endif /* MAILX_H_ */
diff --git a/lib/Plugins/Makefile.am b/lib/Plugins/Makefile.am
index 608b5ddf..ee445c43 100644
--- a/lib/Plugins/Makefile.am
+++ b/lib/Plugins/Makefile.am
@@ -1,7 +1,13 @@
AM_CPPFLAGS = -I$(srcdir)/../MiddleWare -I$(srcdir)/../Utils
pluginslibdir=$(PLUGINS_LIB_DIR)
-pluginslib_LTLIBRARIES = libCCpp.la libMailx.la libSQLite3.la libLogger.la libKerneloopsReporter.la libKerneloops.la
-
+pluginslib_LTLIBRARIES = libCCpp.la \
+ libMailx.la \
+ libSQLite3.la \
+ libLogger.la \
+ libKerneloopsReporter.la\
+ libKerneloops.la \
+ libRunApp.la
+
pluginsconfdir=$(PLUGINS_CONF_DIR)
dist_pluginsconf_DATA = CCpp.conf Mailx.conf SQLite3.conf Logger.conf KerneloopsReporter.conf
@@ -34,3 +40,7 @@ libSQLite3_la_CPPFLAGS = -I$(srcdir)/../MiddleWare -I$(srcdir)/../Utils $(SQLITE
# Logger
libLogger_la_SOURCES = Logger.cpp Logger.h
libLogger_la_LDFLAGS = -avoid-version
+
+# RunApp
+libRunApp_la_SOURCES = RunApp.h RunApp.cpp
+libRunApp_la_LDFLAGS = -avoid-version \ No newline at end of file
diff --git a/lib/Plugins/SQLite3.cpp b/lib/Plugins/SQLite3.cpp
index c886ff01..f48e71b2 100644
--- a/lib/Plugins/SQLite3.cpp
+++ b/lib/Plugins/SQLite3.cpp
@@ -24,6 +24,7 @@
#include "SQLite3.h"
#include <string>
#include <iostream>
+#include "Settings.h"
#define ABRT_TABLE "abrt"
@@ -267,10 +268,13 @@ const database_row_t CSQLite3::GetUUIDData(const std::string& pUUID, const std::
return table[0];
}
-void CSQLite3::SetSettings(const map_settings_t& pSettings)
+void CSQLite3::LoadSettings(const std::string& pPath)
{
- if (pSettings.find("DBPath")!= pSettings.end())
+ map_settings_t settings;
+ load_settings(pPath, settings);
+
+ if (settings.find("DBPath")!= settings.end())
{
- m_sDBPath = pSettings.find("DBPath")->second;
+ m_sDBPath = settings["DBPath"];
}
}
diff --git a/lib/Plugins/SQLite3.h b/lib/Plugins/SQLite3.h
index 4903f6a3..055c059f 100644
--- a/lib/Plugins/SQLite3.h
+++ b/lib/Plugins/SQLite3.h
@@ -58,18 +58,15 @@ class CSQLite3 : public CDatabase
const vector_database_rows_t GetUIDData(const std::string& pUID);
const database_row_t GetUUIDData(const std::string& pUUID, const std::string& pUID);
- void Init() {}
- void DeInit() {}
- void SetSettings(const map_settings_t& pSettings);
+ void LoadSettings(const std::string& pPath);
};
PLUGIN_INFO(DATABASE,
+ CSQLite3,
"SQLite3",
"0.0.1",
"SQLite3 database plugin.",
"zprikryl@redhat.com,jmoskovc@redhat.com",
"https://fedorahosted.org/crash-catcher/wiki");
-PLUGIN_INIT(CSQLite3);
-
#endif /* SQLITE3_H_ */
diff --git a/lib/Utils/DebugDump.h b/lib/Utils/DebugDump.h
index 32e03967..5805a82e 100644
--- a/lib/Utils/DebugDump.h
+++ b/lib/Utils/DebugDump.h
@@ -35,8 +35,7 @@
#define FILENAME_UID "uid"
#define FILENAME_PACKAGE "package"
#define FILENAME_DESCRIPTION "description"
-#define FILENAME_LANGUAGE "language"
-#define FILENAME_APPLICATION "application"
+#define FILENAME_ANALYZER "analyzer"
#define FILENAME_TEXTDATA1 "text_data1"
#define FILENAME_TEXTDATA2 "text_data2"
#define FILENAME_BINARYDATA1 "binary_data1"
diff --git a/lib/Utils/Makefile.am b/lib/Utils/Makefile.am
index 592bdb5b..c9bef6d4 100644
--- a/lib/Utils/Makefile.am
+++ b/lib/Utils/Makefile.am
@@ -1,5 +1,5 @@
lib_LTLIBRARIES = libUtils.la
-libUtils_la_SOURCES = DebugDump.cpp DebugDump.h
+libUtils_la_SOURCES = DebugDump.cpp DebugDump.h Settings.h
libUtils_la_LDFLAGS = -version-info 0:1:0
install-data-local:
diff --git a/lib/Utils/Settings.h b/lib/Utils/Settings.h
index 1629ce9e..31138d05 100644
--- a/lib/Utils/Settings.h
+++ b/lib/Utils/Settings.h
@@ -22,13 +22,99 @@
#ifndef SETTINGSFUNC_H_
#define SETTINGSFUNC_H_
-#include "MiddleWareTypes.h"
+#include <fstream>
+#include <map>
+#include <set>
-typedef map_string_string_t map_settings_t;
-typedef set_strings_t set_settings_t;
+typedef std::map<std::string, std::string> map_settings_t;
+typedef std::set<std::string> set_settings_t;
-void load_settings(const std::string& path, map_settings_t& settings);
-void save_settings(const std::string& path, const map_settings_t& settings);
-void parse_settings(const std::string& pLine, set_settings_t& settings);
+inline void load_settings(const std::string& path, map_settings_t& settings)
+{
+ std::ifstream fIn;
+ fIn.open(path.c_str());
+ if (fIn.is_open())
+ {
+ std::string line;
+ while (!fIn.eof())
+ {
+ getline(fIn, line);
+
+ int ii;
+ bool is_value = false;
+ bool valid = false;
+ std::string key = "";
+ std::string value = "";
+ for (ii = 0; ii < line.length(); ii++)
+ {
+ if (isspace(line[ii]))
+ {
+ continue;
+ }
+ if (line[ii] == '#')
+ {
+ break;
+ }
+ else if (line[ii] == '=')
+ {
+ is_value = true;
+ }
+ else if (line[ii] == '=' && is_value)
+ {
+ key = "";
+ value = "";
+ break;
+ }
+ else if (!is_value)
+ {
+ key += line[ii];
+ }
+ else
+ {
+ valid = true;
+ value += line[ii];
+ }
+ }
+ if (valid)
+ {
+ settings[key] = value;
+ }
+ }
+ fIn.close();
+ }
+}
+
+inline void save_settings(const std::string& path, const map_settings_t& settings)
+{
+ map_settings_t::const_iterator it;
+ std::ofstream fOut;
+ fOut.open(path.c_str());
+ if (fOut.is_open())
+ {
+ fOut << "# !DO NOT EDIT THIS FILE BY HAND. IT IS GENERATED BY ABRT!" << std::endl;
+ for (it = settings.begin(); it != settings.end(); it++)
+ {
+ fOut << it->first << " = " << it->second << std::endl << std::endl;
+ }
+ fOut.close();
+ }
+ else
+ {
+ throw std::string("save_settings(): Cannot write configuration file '"+path+"'.");
+ }
+}
+
+inline void parse_settings(const std::string& pLine, set_settings_t& settings)
+{
+ std::string::size_type ii_old = 0, ii_new = 0;
+ ii_new = pLine.find(",");
+ while (ii_new != std::string::npos)
+ {
+ settings.insert(pLine.substr(ii_old, ii_new - ii_old));
+ ii_old = ii_new + 1;
+ ii_new = pLine.find(",",ii_old);
+ }
+ settings.insert(pLine.substr(ii_old));
+}
#endif /* SETTINGSFUNC_H_ */
diff --git a/src/Hooks/CCpp.cpp b/src/Hooks/CCpp.cpp
index 4a529437..03dfb7b4 100644
--- a/src/Hooks/CCpp.cpp
+++ b/src/Hooks/CCpp.cpp
@@ -75,7 +75,7 @@ int main(int argc, char** argv)
dd.Create(dd_path);
dd.SaveProc(pid);
- dd.SaveText(FILENAME_LANGUAGE, "CCpp");
+ dd.SaveText(FILENAME_ANALYZER, "CCpp");
if ((fp = fopen(cd_path, "w")) == NULL)
{
fprintf(stderr, "%s: Can not open the file %s.\n",