summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateusz Moscicki <m.moscicki2@partner.samsung.com>2018-07-20 11:00:49 +0200
committerKarol Lewandowski <k.lewandowsk@samsung.com>2018-08-22 07:51:37 +0200
commit091b5a128c21db104c127c3bd2fb146a0649dad3 (patch)
tree755cdc94b5403abb2ba7521585091e92d92244b8
parent3b7eb7087f2106c339972b7ffb0472944a9ceb1b (diff)
downloadcrash-worker-091b5a128c21db104c127c3bd2fb146a0649dad3.tar.gz
crash-worker-091b5a128c21db104c127c3bd2fb146a0649dad3.tar.bz2
crash-worker-091b5a128c21db104c127c3bd2fb146a0649dad3.zip
Add report types
Depending on report type we save all zip archive with coredump, logs, so_info and info file, or just only the *.info file. Report type can be set in crash-manager.conf: [CrashManager] ... ReportType=INFO ... Available report types: * INFO - Save *.info file * FULL - Save coredump, *.log, *.so_info and *info file as a ZIP archive (default) Change-Id: I486049ac8eb928ebdc6ac513bdeac3c98aa4adcc
-rw-r--r--src/crash-manager/crash-manager.c114
-rw-r--r--src/crash-manager/crash-manager.conf3
2 files changed, 101 insertions, 16 deletions
diff --git a/src/crash-manager/crash-manager.c b/src/crash-manager/crash-manager.c
index 80dd82d..6ee58f8 100644
--- a/src/crash-manager/crash-manager.c
+++ b/src/crash-manager/crash-manager.c
@@ -82,6 +82,16 @@ enum {
USAGE_EXCEED
};
+enum {
+ REP_TYPE_INFO = 0,
+ REP_TYPE_FULL
+};
+
+#define REP_DEFAULT_TYPE REP_TYPE_FULL
+
+#define REP_TYPE_FULL_STR "FULL"
+#define REP_TYPE_INFO_STR "INFO"
+
struct file_info {
bool isdir;
int size;
@@ -98,6 +108,7 @@ static bool allow_zip;
static char* crash_root_path;
static char* crash_crash_path;
static char* crash_temp_path;
+static int report_type;
/* Paths and variables */
static struct crash_info {
@@ -231,6 +242,33 @@ static int prepare_paths(void)
return 1;
}
+static const char* report_type_to_str(const int report_type)
+{
+ switch (report_type) {
+ case REP_TYPE_INFO:
+ return REP_TYPE_INFO_STR;
+ break;
+ case REP_TYPE_FULL:
+ return REP_TYPE_FULL_STR;
+ default:
+ return NULL;
+ break;
+ }
+}
+
+static int report_type_from_str(const char* report_type_str)
+{
+ if (report_type_str == NULL)
+ return -1;
+
+ if (strncmp(report_type_str, REP_TYPE_FULL_STR, strlen(REP_TYPE_FULL_STR)) == 0)
+ return REP_TYPE_FULL;
+ else if (strncmp(report_type_str, REP_TYPE_INFO_STR, strlen(REP_TYPE_INFO_STR)) == 0)
+ return REP_TYPE_INFO;
+
+ return -1;
+}
+
static int get_config(void)
{
dictionary *ini = NULL;
@@ -248,6 +286,7 @@ static int get_config(void)
_E("strdup error: %m\n");
return -1;
}
+ report_type = REP_DEFAULT_TYPE;
ini = iniparser_load(CRASH_CONF_FILE);
if (!ini) {
@@ -321,6 +360,22 @@ static int get_config(void)
}
}
+ snprintf(key, sizeof(key), "%s:%s", CRASH_SECTION, "ReportType");
+ value_str = iniparser_getstring(ini, key, NULL);
+ if (value_str == NULL) {
+ _D("Invalid value for ReportType. Use default value [ %s ]",
+ report_type_to_str(report_type));
+ } else {
+ _D("ReportType [ %s ]", value_str);
+ report_type = report_type_from_str(value_str);
+
+ if (report_type < 0) {
+ _E("Unknown ReportType %s. Fallback to default: %s",
+ value_str, report_type_to_str(REP_DEFAULT_TYPE));
+ report_type = REP_DEFAULT_TYPE;
+ }
+ }
+
iniparser_freedict(ini);
return 1;
}
@@ -814,7 +869,8 @@ static void execute_crash_modules(int argc, char *argv[])
_D("Execute crash module: ");
#ifdef TIZEN_ENABLE_COREDUMP
- execute_crash_pipe(argc, argv);
+ if (report_type >= REP_TYPE_FULL)
+ execute_crash_pipe(argc, argv);
#endif
#ifdef TIZEN_ENABLE_MINICOREDUMP
@@ -1118,6 +1174,27 @@ static void move_dump_dir(void)
_E("Failed to delete temp directory");
}
+static void move_info_file(void)
+{
+ int lock_fd;
+
+ if ((lock_fd = lock_dumpdir()) < 0)
+ return;
+
+ char dest_path[PATH_MAX];
+ snprintf(dest_path, sizeof(dest_path), "%s/%s.info",
+ crash_crash_path, crash_info.name);
+ if (!rename(crash_info.info_path, dest_path))
+ clean_dump();
+ else
+ _E("Failed to move %s to %s",
+ crash_info.info_path, dest_path);
+
+ unlock_dumpdir(lock_fd);
+ if (remove_dir(crash_info.temp_dir, 1) < 0)
+ _E("Failed to delete temp directory");
+}
+
static int wait_for_opt(unsigned int timeout)
{
unsigned int count = 0;
@@ -1185,27 +1262,32 @@ int main(int argc, char *argv[])
get_sysassert_cs();
#endif
- /* Exec dump_systemstate */
- dump_state_pid = dump_system_state();
-
- /* Copy maps file to temp dir */
- copy_maps();
+ if (report_type >= REP_TYPE_FULL) {
+ /* Exec dump_systemstate */
+ dump_state_pid = dump_system_state();
+ /* Copy maps file to temp dir */
+ copy_maps();
+ }
/* Exec crash modules */
execute_crash_modules(argc, argv);
- /* Save shared objects info (file names, bulid IDs, rpm package names) */
- save_so_info();
- remove_maps();
+ if (report_type >= REP_TYPE_FULL) {
+ /* Save shared objects info (file names, bulid IDs, rpm package names) */
+ save_so_info();
+ remove_maps();
- /* Wait dump_system_state */
- wait_system_command(dump_state_pid);
+ /* Wait dump_system_state */
+ wait_system_command(dump_state_pid);
- /* Tar compression */
- if (allow_zip)
- compress();
- else
- move_dump_dir();
+ /* Tar compression */
+ if (allow_zip)
+ compress();
+ else
+ move_dump_dir();
+ } else {
+ move_info_file();
+ }
#if defined(TIZEN_ENABLE_COREDUMP) || defined(TIZEN_ENABLE_MINICOREDUMP)
/* launch crash-popup only if the .debugmode file is exist*/
if (debug_mode)
diff --git a/src/crash-manager/crash-manager.conf b/src/crash-manager/crash-manager.conf
index 08131cc..98e8690 100644
--- a/src/crash-manager/crash-manager.conf
+++ b/src/crash-manager/crash-manager.conf
@@ -7,3 +7,6 @@ AllowZip=yes
# Crash report path must exist for the reports to be created
# CrashRootPath=/usr/opt/share/crash/
+
+# Report type can be FULL (.zip) or INFO (.info only)
+# ReportType=FULL