From e60c006499ec9a1604f85f84a98145535a7ad0a7 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 31 Jul 2009 15:13:38 +0200 Subject: Move PLUGIN_INFOs to .cpp files: same object must never be defined twice and if structure is defined in a .h file, that happens. Since this particular structure has non-trivial destructor, it was running twice and resulted in double-free. Signed-off-by: Denys Vlasenko --- doc/PLUGINS-HOWTO | 26 +++++++++++++------------- lib/MiddleWare/Plugin.h | 15 ++++++--------- lib/MiddleWare/PluginManager.cpp | 6 ++++++ lib/Plugins/Bugzilla.cpp | 10 ++++++++++ lib/Plugins/Bugzilla.h | 11 ----------- lib/Plugins/CCpp.cpp | 9 +++++++++ lib/Plugins/CCpp.h | 10 ---------- lib/Plugins/FileTransfer.cpp | 12 ++++++++++-- lib/Plugins/FileTransfer.h | 11 ----------- lib/Plugins/Kerneloops.cpp | 9 +++++++++ lib/Plugins/Kerneloops.h | 9 --------- lib/Plugins/KerneloopsReporter.cpp | 9 +++++++++ lib/Plugins/KerneloopsReporter.h | 9 --------- lib/Plugins/KerneloopsScanner.cpp | 9 +++++++++ lib/Plugins/KerneloopsScanner.h | 9 --------- lib/Plugins/Logger.cpp | 9 +++++++++ lib/Plugins/Logger.h | 10 ---------- lib/Plugins/Mailx.cpp | 9 +++++++++ lib/Plugins/Mailx.h | 10 ---------- lib/Plugins/Python.cpp | 9 +++++++++ lib/Plugins/Python.h | 11 ----------- lib/Plugins/RunApp.cpp | 11 ++++++++++- lib/Plugins/RunApp.h | 10 ---------- lib/Plugins/SOSreport.cpp | 9 +++++++++ lib/Plugins/SOSreport.h | 9 --------- lib/Plugins/SQLite3.cpp | 9 +++++++++ lib/Plugins/SQLite3.h | 9 --------- 27 files changed, 136 insertions(+), 143 deletions(-) diff --git a/doc/PLUGINS-HOWTO b/doc/PLUGINS-HOWTO index a8eb4e20..2ca6b8e6 100644 --- a/doc/PLUGINS-HOWTO +++ b/doc/PLUGINS-HOWTO @@ -12,9 +12,9 @@ The subclasses are: Each of them requires you to override a different set of methods. -The pDebugDumpDir parameter is very common: it specifies the directory +The pDebugDumpDir parameter is very common: it specifies the directory that is created to gather information of this specific crash. -The files that were created when the application crashed (such as core dumps) +The files that were created when the application crashed (such as core dumps) are all stored here. In addition, the plugins can write their output files there, if any. @@ -27,8 +27,8 @@ performed when a crash is encountered. you have to override one method: virtual void Run(const std::string& pActiveDir, - const std::string& pArgs) = 0; --This method runs the specified action. + const std::string& pArgs) = 0; +-This method runs the specified action. The first argument is a directory name. It can be either the current debug dump dir or a directory that contains all debug dumps. The second argument is a string with arguments specified for the action. @@ -36,8 +36,8 @@ virtual void Run(const std::string& pActiveDir, Analyzer Plugin --------------- This plugin has to compute the UUID of the crash. Crashes differ, depending on -where they occur, for example crashes in the kernel differ from crashes in -userspace binaries, which differ from crashes in python scripts. Therefore, +where they occur, for example crashes in the kernel differ from crashes in +userspace binaries, which differ from crashes in python scripts. Therefore, you need a plugin for each type of application that you want "abrt" to handle. you have to override these methods: @@ -77,8 +77,8 @@ virtual void Report(const crash_report_t& pCrashReport, Database Plugin --------------- You use this plugin to store the metadata about the crash. The metadata -has to be in a database, to distinguish whether the current crash is or -is not the same as some crash before. The database can be local, or in +has to be in a database, to distinguish whether the current crash is or +is not the same as some crash before. The database can be local, or in some centralized location on the network. you have to override these methods: @@ -90,7 +90,7 @@ virtual void Insert(const std::string& pUUID, const std::string& pUID, const std::string& pDebugDumpPath, const std::string& pTime) = 0; -- insert an entry into the database: you use both UID (user ID) and UUID +- insert an entry into the database: you use both UID (user ID) and UUID (ID of the crash) virtual void Delete(const std::string& pUUID, const std::string& pUID) = 0; @@ -111,13 +111,13 @@ virtual const database_row_t GetUUIDData(const std::string& pUUID, const The macro PLUGIN_INFO --------------------- -Use the macro PLUGIN_INFO in the header file of your plugin so that your -subclass will be properly registered and treated as a plugin. -This sets up all the lower-level and administrative details to fit your +Use the macro PLUGIN_INFO in the *.cpp file of your plugin so that your +subclass will be properly registered and treated as a plugin. +This sets up all the lower-level and administrative details to fit your class into the plugin infrastructure. The syntax is: PLUGIN_INFO(type, plugin_class, name, version, description, email, www) -- "type" is one of ANALYZER, ACTION, REPORTER, or DATABASE +- "type" is one of ANALYZER, ACTION, REPORTER, or DATABASE - "plugin_class" is the identifier of the class - "name" is a string with the name of the plugin - "version" is a string with the version of the plugin diff --git a/lib/MiddleWare/Plugin.h b/lib/MiddleWare/Plugin.h index ef107e3d..c7ae9ce7 100644 --- a/lib/MiddleWare/Plugin.h +++ b/lib/MiddleWare/Plugin.h @@ -60,15 +60,12 @@ class CPlugin /** * An emun of plugin types. */ -typedef enum { ANALYZER, /**< An analyzer plugin*/ - ACTION, /**< An action plugin*/ - REPORTER, /**< A reporter plugin*/ - DATABASE /**< A database plugin*/ - } plugin_type_t; -/** - * Text reprezentation of plugin types. - */ -const char* const plugin_type_str_t[] = {"Analyzer", "Action", "Reporter", "Database"}; +typedef enum { + ANALYZER, /**< An analyzer plugin*/ + ACTION, /**< An action plugin*/ + REPORTER, /**< A reporter plugin*/ + DATABASE /**< A database plugin*/ +} plugin_type_t; /** * A struct contains all needed data about particular plugin. diff --git a/lib/MiddleWare/PluginManager.cpp b/lib/MiddleWare/PluginManager.cpp index 916eabe9..2d110936 100644 --- a/lib/MiddleWare/PluginManager.cpp +++ b/lib/MiddleWare/PluginManager.cpp @@ -27,6 +27,12 @@ #include #include +/** + * Text reprezentation of plugin types. + */ +static const char* const plugin_type_str_t[] = { "Analyzer", "Action", "Reporter", "Database" }; + + CPluginManager::CPluginManager(const std::string& pPlugisConfDir, const std::string& pPlugisLibDir) : m_sPlugisConfDir(pPlugisConfDir), diff --git a/lib/Plugins/Bugzilla.cpp b/lib/Plugins/Bugzilla.cpp index 07398355..864321f2 100644 --- a/lib/Plugins/Bugzilla.cpp +++ b/lib/Plugins/Bugzilla.cpp @@ -342,3 +342,13 @@ void CReporterBugzilla::LoadSettings(const std::string& pPath) m_bNoSSLVerify = settings["NoSSLVerify"] == "yes"; } } + +PLUGIN_INFO(REPORTER, + CReporterBugzilla, + "Bugzilla", + "0.0.2", + "Check if a bug isn't already reported in a bugzilla " + "and if not, report it.", + "zprikryl@redhat.com", + "https://fedorahosted.org/abrt/wiki", + PLUGINS_LIB_DIR"/Bugzilla.GTKBuilder"); diff --git a/lib/Plugins/Bugzilla.h b/lib/Plugins/Bugzilla.h index fe23cdca..6d53defe 100644 --- a/lib/Plugins/Bugzilla.h +++ b/lib/Plugins/Bugzilla.h @@ -43,15 +43,4 @@ class CReporterBugzilla : public CReporter const std::string& pArgs); }; -PLUGIN_INFO(REPORTER, - CReporterBugzilla, - "Bugzilla", - "0.0.2", - "Check if a bug isn't already reported in a bugzilla " - "and if not, report it.", - "zprikryl@redhat.com", - "https://fedorahosted.org/abrt/wiki", - PLUGINS_LIB_DIR"/Bugzilla.GTKBuilder"); - - #endif /* BUGZILLA_H_ */ diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp index c38f19b9..6c2bc444 100644 --- a/lib/Plugins/CCpp.cpp +++ b/lib/Plugins/CCpp.cpp @@ -581,3 +581,12 @@ void CAnalyzerCCpp::LoadSettings(const std::string& pPath) m_bMemoryMap = settings["MemoryMap"] == "yes"; } } + +PLUGIN_INFO(ANALYZER, + CAnalyzerCCpp, + "CCpp", + "0.0.1", + "Simple C/C++ analyzer plugin.", + "zprikryl@redhat.com", + "https://fedorahosted.org/abrt/wiki", + ""); diff --git a/lib/Plugins/CCpp.h b/lib/Plugins/CCpp.h index d79b61ee..27f17cdd 100644 --- a/lib/Plugins/CCpp.h +++ b/lib/Plugins/CCpp.h @@ -50,14 +50,4 @@ class CAnalyzerCCpp : public CAnalyzer virtual void LoadSettings(const std::string& pPath); }; - -PLUGIN_INFO(ANALYZER, - CAnalyzerCCpp, - "CCpp", - "0.0.1", - "Simple C/C++ analyzer plugin.", - "zprikryl@redhat.com", - "https://fedorahosted.org/abrt/wiki", - ""); - #endif /* CCPP */ diff --git a/lib/Plugins/FileTransfer.cpp b/lib/Plugins/FileTransfer.cpp index db289718..3b7b979b 100644 --- a/lib/Plugins/FileTransfer.cpp +++ b/lib/Plugins/FileTransfer.cpp @@ -241,7 +241,7 @@ void CFileTransfer::LoadSettings(const std::string& pPath) { m_nRetryCount = atoi(settings["RetryCount"].c_str()); } - + if (settings.find("RetryDelay")!= settings.end()) { m_nRetryDelay = atoi(settings["RetryDelay"].c_str()); @@ -256,5 +256,13 @@ void CFileTransfer::LoadSettings(const std::string& pPath) m_sArchiveType = "." + m_sArchiveType; } } - } + +PLUGIN_INFO(ACTION, + CFileTransfer, + "FileTransfer", + "0.0.6", + "Sends a report via FTP or SCTP", + "dnovotny@redhat.com", + "https://fedorahosted.org/abrt/wiki", + ""); diff --git a/lib/Plugins/FileTransfer.h b/lib/Plugins/FileTransfer.h index b44aad5c..f044cf7b 100644 --- a/lib/Plugins/FileTransfer.h +++ b/lib/Plugins/FileTransfer.h @@ -55,15 +55,4 @@ class CFileTransfer : public CAction const std::string& pArgs); }; - -PLUGIN_INFO(ACTION, - CFileTransfer, - "FileTransfer", - "0.0.6", - "Sends a report via FTP or SCTP", - "dnovotny@redhat.com", - "https://fedorahosted.org/abrt/wiki", - ""); - - #endif /* FILETRANSFER_H_ */ diff --git a/lib/Plugins/Kerneloops.cpp b/lib/Plugins/Kerneloops.cpp index f4714834..1eabd215 100644 --- a/lib/Plugins/Kerneloops.cpp +++ b/lib/Plugins/Kerneloops.cpp @@ -61,3 +61,12 @@ std::string CAnalyzerKerneloops::GetGlobalUUID(const std::string& pDebugDumpDir) { return GetLocalUUID(pDebugDumpDir); } + +PLUGIN_INFO(ANALYZER, + CAnalyzerKerneloops, + "Kerneloops", + "0.0.2", + "Abrt's Kerneloops plugin.", + "anton@redhat.com", + "https://people.redhat.com/aarapov", + ""); diff --git a/lib/Plugins/Kerneloops.h b/lib/Plugins/Kerneloops.h index 6dc440f9..77d44191 100644 --- a/lib/Plugins/Kerneloops.h +++ b/lib/Plugins/Kerneloops.h @@ -43,13 +43,4 @@ class CAnalyzerKerneloops : public CAnalyzer virtual void CreateReport(const std::string& pDebugDumpDir) {} }; -PLUGIN_INFO(ANALYZER, - CAnalyzerKerneloops, - "Kerneloops", - "0.0.2", - "Abrt's Kerneloops plugin.", - "anton@redhat.com", - "https://people.redhat.com/aarapov", - ""); - #endif diff --git a/lib/Plugins/KerneloopsReporter.cpp b/lib/Plugins/KerneloopsReporter.cpp index 30119809..e3a28956 100644 --- a/lib/Plugins/KerneloopsReporter.cpp +++ b/lib/Plugins/KerneloopsReporter.cpp @@ -118,3 +118,12 @@ void CKerneloopsReporter::LoadSettings(const std::string& pPath) m_sSubmitURL = settings["SubmitURL"]; } } + +PLUGIN_INFO(REPORTER, + CKerneloopsReporter, + "KerneloopsReporter", + "0.0.1", + "Sends the Kerneloops crash information to Kerneloopsoops.org", + "anton@redhat.com", + "http://people.redhat.com/aarapov", + PLUGINS_LIB_DIR"/KerneloopsReporter.GTKBuilder"); diff --git a/lib/Plugins/KerneloopsReporter.h b/lib/Plugins/KerneloopsReporter.h index aea774d8..a5e06836 100644 --- a/lib/Plugins/KerneloopsReporter.h +++ b/lib/Plugins/KerneloopsReporter.h @@ -45,13 +45,4 @@ class CKerneloopsReporter : public CReporter virtual void Report(const map_crash_report_t& pCrashReport, const std::string& pArgs); }; -PLUGIN_INFO(REPORTER, - CKerneloopsReporter, - "KerneloopsReporter", - "0.0.1", - "Sends the Kerneloops crash information to Kerneloopsoops.org", - "anton@redhat.com", - "http://people.redhat.com/aarapov", - PLUGINS_LIB_DIR"/KerneloopsReporter.GTKBuilder"); - #endif diff --git a/lib/Plugins/KerneloopsScanner.cpp b/lib/Plugins/KerneloopsScanner.cpp index 01020e68..96fe1973 100644 --- a/lib/Plugins/KerneloopsScanner.cpp +++ b/lib/Plugins/KerneloopsScanner.cpp @@ -151,3 +151,12 @@ void CKerneloopsScanner::LoadSettings(const std::string& pPath) m_sSysLogFile = settings["SysLogFile"]; } } + +PLUGIN_INFO(ACTION, + CKerneloopsScanner, + "KerneloopsScanner", + "0.0.1", + "Save new Kerneloops crashes into debug dump dir", + "anton@redhat.com", + "http://people.redhat.com/aarapov", + ""); diff --git a/lib/Plugins/KerneloopsScanner.h b/lib/Plugins/KerneloopsScanner.h index ccc2606e..50e8a4d9 100644 --- a/lib/Plugins/KerneloopsScanner.h +++ b/lib/Plugins/KerneloopsScanner.h @@ -29,13 +29,4 @@ class CKerneloopsScanner : public CAction virtual void LoadSettings(const std::string& pPath); }; -PLUGIN_INFO(ACTION, - CKerneloopsScanner, - "KerneloopsScanner", - "0.0.1", - "Save new Kerneloops crashes into debug dump dir", - "anton@redhat.com", - "http://people.redhat.com/aarapov", - ""); - #endif /* KERNELOOPSSCANNER_H_ */ diff --git a/lib/Plugins/Logger.cpp b/lib/Plugins/Logger.cpp index 33ebfa03..5e99cf9d 100644 --- a/lib/Plugins/Logger.cpp +++ b/lib/Plugins/Logger.cpp @@ -125,3 +125,12 @@ void CLogger::Report(const map_crash_report_t& pCrashReport, const std::string& fOut.close(); } } + +PLUGIN_INFO(REPORTER, + CLogger, + "Logger", + "0.0.1", + "Write a report to a specific file", + "zprikryl@redhat.com", + "https://fedorahosted.org/abrt/wiki", + PLUGINS_LIB_DIR"/Logger.GTKBuilder"); diff --git a/lib/Plugins/Logger.h b/lib/Plugins/Logger.h index 07e7576d..5200f0ec 100644 --- a/lib/Plugins/Logger.h +++ b/lib/Plugins/Logger.h @@ -39,14 +39,4 @@ class CLogger : public CReporter virtual void Report(const map_crash_report_t& pCrashReport, const std::string& pArgs); }; - -PLUGIN_INFO(REPORTER, - CLogger, - "Logger", - "0.0.1", - "Write a report to a specific file", - "zprikryl@redhat.com", - "https://fedorahosted.org/abrt/wiki", - PLUGINS_LIB_DIR"/Logger.GTKBuilder"); - #endif /* LOGGER_H_ */ diff --git a/lib/Plugins/Mailx.cpp b/lib/Plugins/Mailx.cpp index d4b44cff..fdc3dcb1 100644 --- a/lib/Plugins/Mailx.cpp +++ b/lib/Plugins/Mailx.cpp @@ -164,3 +164,12 @@ void CMailx::LoadSettings(const std::string& pPath) m_bSendBinaryData = settings["SendBinaryData"] == "yes"; } } + +PLUGIN_INFO(REPORTER, + CMailx, + "Mailx", + "0.0.2", + "Sends an email with a report via mailx command", + "zprikryl@redhat.com", + "https://fedorahosted.org/abrt/wiki", + PLUGINS_LIB_DIR"/Mailx.GTKBuilder"); diff --git a/lib/Plugins/Mailx.h b/lib/Plugins/Mailx.h index 4235764e..e2173ed5 100644 --- a/lib/Plugins/Mailx.h +++ b/lib/Plugins/Mailx.h @@ -47,14 +47,4 @@ class CMailx : public CReporter virtual void Report(const map_crash_report_t& pCrashReport, const std::string& pArgs); }; - -PLUGIN_INFO(REPORTER, - CMailx, - "Mailx", - "0.0.2", - "Sends an email with a report via mailx command", - "zprikryl@redhat.com", - "https://fedorahosted.org/abrt/wiki", - PLUGINS_LIB_DIR"/Mailx.GTKBuilder"); - #endif /* MAILX_H_ */ diff --git a/lib/Plugins/Python.cpp b/lib/Plugins/Python.cpp index f58a6c90..c3677e7b 100644 --- a/lib/Plugins/Python.cpp +++ b/lib/Plugins/Python.cpp @@ -48,3 +48,12 @@ void CAnalyzerPython::DeInit() fOutPySiteCustomize.close(); } } + +PLUGIN_INFO(ANALYZER, + CAnalyzerPython, + "Python", + "0.0.1", + "Simple Python analyzer plugin.", + "zprikryl@redhat.com, jmoskovc@redhat.com", + "https://fedorahosted.org/abrt/wiki", + ""); diff --git a/lib/Plugins/Python.h b/lib/Plugins/Python.h index 62a43222..6eaf1d14 100644 --- a/lib/Plugins/Python.h +++ b/lib/Plugins/Python.h @@ -17,15 +17,4 @@ class CAnalyzerPython : public CAnalyzer virtual std::string CreateHash(const std::string& pInput); }; - -PLUGIN_INFO(ANALYZER, - CAnalyzerPython, - "Python", - "0.0.1", - "Simple Python analyzer plugin.", - "zprikryl@redhat.com, jmoskovc@redhat.com", - "https://fedorahosted.org/abrt/wiki", - ""); - - #endif /* PYTHON_H_ */ diff --git a/lib/Plugins/RunApp.cpp b/lib/Plugins/RunApp.cpp index 9d996eea..8d37f11c 100644 --- a/lib/Plugins/RunApp.cpp +++ b/lib/Plugins/RunApp.cpp @@ -86,5 +86,14 @@ void CActionRunApp::Run(const std::string& pActionDir, dd.SaveText(args[FILENAME], output); dd.Close(); } - } + +PLUGIN_INFO(ACTION, + CActionRunApp, + "RunApp", + "0.0.1", + "Simple action plugin which runs a command " + "and it can save command's output", + "zprikryl@redhat.com", + "https://fedorahosted.org/abrt/wiki", + ""); diff --git a/lib/Plugins/RunApp.h b/lib/Plugins/RunApp.h index 839992b0..65fbe500 100644 --- a/lib/Plugins/RunApp.h +++ b/lib/Plugins/RunApp.h @@ -38,14 +38,4 @@ class CActionRunApp : public CAction const std::string& pArgs); }; -PLUGIN_INFO(ACTION, - CActionRunApp, - "RunApp", - "0.0.1", - "Simple action plugin which runs a command " - "and it can save command's output", - "zprikryl@redhat.com", - "https://fedorahosted.org/abrt/wiki", - ""); - #endif diff --git a/lib/Plugins/SOSreport.cpp b/lib/Plugins/SOSreport.cpp index 2790cd25..5247a5d5 100644 --- a/lib/Plugins/SOSreport.cpp +++ b/lib/Plugins/SOSreport.cpp @@ -114,3 +114,12 @@ void CActionSOSreport::Run(const std::string& pActionDir, CopyFile(sosreport_filename,sosreport_dd_filename); dd.Close(); } + +PLUGIN_INFO(ACTION, + CActionSOSreport , + "SOSreport", + "0.0.2", + "Run sosreport, save the output in the crash dump", + "gavin@redhat.com", + "https://fedorahosted.org/abrt/wiki", + ""); diff --git a/lib/Plugins/SOSreport.h b/lib/Plugins/SOSreport.h index d70494ad..dbddafdb 100644 --- a/lib/Plugins/SOSreport.h +++ b/lib/Plugins/SOSreport.h @@ -38,13 +38,4 @@ class CActionSOSreport : public CAction const std::string& pArgs); }; -PLUGIN_INFO(ACTION, - CActionSOSreport , - "SOSreport", - "0.0.2", - "Run sosreport, save the output in the crash dump", - "gavin@redhat.com", - "https://fedorahosted.org/abrt/wiki", - ""); - #endif diff --git a/lib/Plugins/SQLite3.cpp b/lib/Plugins/SQLite3.cpp index 66c654ef..ada5f507 100644 --- a/lib/Plugins/SQLite3.cpp +++ b/lib/Plugins/SQLite3.cpp @@ -278,3 +278,12 @@ void CSQLite3::LoadSettings(const std::string& pPath) m_sDBPath = settings["DBPath"]; } } + +PLUGIN_INFO(DATABASE, + CSQLite3, + "SQLite3", + "0.0.1", + "SQLite3 database plugin.", + "zprikryl@redhat.com,jmoskovc@redhat.com", + "https://fedorahosted.org/abrt/wiki", + ""); diff --git a/lib/Plugins/SQLite3.h b/lib/Plugins/SQLite3.h index e283e3c0..ce0b81e9 100644 --- a/lib/Plugins/SQLite3.h +++ b/lib/Plugins/SQLite3.h @@ -61,13 +61,4 @@ class CSQLite3 : public CDatabase virtual 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/abrt/wiki", - ""); - #endif /* SQLITE3_H_ */ -- cgit