Save livedumper reports in the livedump/ subdirectory 92/210392/6
authorMateusz Moscicki <m.moscicki2@partner.samsung.com>
Tue, 16 Jul 2019 06:16:04 +0000 (08:16 +0200)
committerKarol Lewandowski <k.lewandowsk@samsung.com>
Wed, 24 Jul 2019 10:23:20 +0000 (10:23 +0000)
This change makes possible to distinguish the report created by
the application crash from that created on the request.

Change-Id: Iaafb82522cad40e12366ee06eb6313027937b5b2

src/crash-manager/crash-manager.c
tests/system/livedumper/livedumper.sh.template
tests/system/utils/minicore-utils.sh

index b275dbd..030a1ce 100644 (file)
@@ -59,6 +59,7 @@
 
 #define CRASH_TEMP_SUBDIR    "/temp/"
 #define CRASH_PATH_SUBDIR    "/dump/"
+#define LIVE_PATH_SUBDIR     "/livedump/"
 
 #define WAIT_FOR_OPT_TIMEOUT_SEC 60
 
@@ -199,16 +200,18 @@ out:
        return ret;
 }
 
-static int prepare_paths(void)
+static int prepare_paths(struct crash_info* cinfo)
 {
        int tmp_len;
-       tmp_len = strlen(config.crash_root_path) + strlen(CRASH_PATH_SUBDIR);
+       const char *crash_subdir = cinfo->livedump ? LIVE_PATH_SUBDIR : CRASH_PATH_SUBDIR;
+
+       tmp_len = strlen(config.crash_root_path) + strlen(crash_subdir);
        crash_crash_path = (char*)malloc(tmp_len + 1);
        if (crash_crash_path == NULL) {
                _E("Couldn't allocate memory for crash_crash_path: %m\n");
                return 0;
        }
-       snprintf(crash_crash_path, tmp_len + 1, "%s%s", config.crash_root_path, CRASH_PATH_SUBDIR);
+       snprintf(crash_crash_path, tmp_len + 1, "%s%s", config.crash_root_path, crash_subdir);
 
        tmp_len = strlen(config.crash_root_path) + strlen(CRASH_TEMP_SUBDIR);
        crash_temp_path = (char*)malloc(tmp_len + 1);
@@ -434,22 +437,13 @@ static bool parse_args(struct crash_info *cinfo, int argc, char *argv[])
 #undef GET_NUMBER
 }
 
-static int set_crash_info(struct crash_info *cinfo, int argc, char *argv[])
+static int set_crash_info(struct crash_info *cinfo)
 {
        int ret;
        char *temp_dir_ret = NULL;
        char date[80];
        struct tm loc_tm;
 
-       cinfo->livedump = false;
-       cinfo->kill = false;
-       cinfo->print_result_path = false;
-       cinfo->tid_info = -1;
-       cinfo->time_info = 0;
-
-       if (!parse_args(cinfo, argc, argv))
-               return -1;
-
        if (cinfo->livedump) {
                if (cinfo->kill)
                        cinfo->sig_info = 9;
@@ -1230,15 +1224,27 @@ static void free_crash_info(struct crash_info *cinfo)
 #endif
 }
 
+static void crash_info_init(struct crash_info *cinfo)
+{
+       cinfo->prstatus_fd = -1;
+       cinfo->livedump = false;
+       cinfo->kill = false;
+       cinfo->print_result_path = false;
+       cinfo->tid_info = -1;
+       cinfo->time_info = 0;
+}
+
 int main(int argc, char *argv[])
 {
-       struct crash_info cinfo = {.prstatus_fd = -1};
+       struct crash_info cinfo;
 
        /* Execute processes in parallel */
        static pid_t dump_state_pid = 0, extra_script_pid = 0;
        int debug_mode = access(DEBUGMODE_PATH, F_OK) == 0;
        int res = 0;
 
+       crash_info_init(&cinfo);
+
        /*
         * prctl(PR_SET_DUMPABLE, 0) is not neccessary. Kernel runs the
         * crash-manager and sets RLIMIT_CORE to 1 for the process. This is special
@@ -1250,7 +1256,12 @@ int main(int argc, char *argv[])
                goto exit;
        }
 
-       if (!prepare_paths()) {
+       if (!parse_args(&cinfo, argc, argv)) {
+               res = EXIT_FAILURE;
+               goto exit;
+       }
+
+       if (!prepare_paths(&cinfo)) {
                res = EXIT_FAILURE;
                goto exit;
        }
@@ -1267,7 +1278,7 @@ int main(int argc, char *argv[])
        }
 
        /* Set crash info */
-       if (set_crash_info(&cinfo, argc, argv) < 0) {
+       if (set_crash_info(&cinfo) < 0) {
                res = EXIT_FAILURE;
                goto exit;
        }
index 51c9be1..d22e073 100644 (file)
@@ -29,7 +29,7 @@ REPORT_PATH=`echo ${CRASH_MANAGER_OUTPUT} | cut -c 13-`
 
 wait_for_app crash-manager
 
-pushd ${CRASH_DUMP_PATH}
+pushd ${LIVE_DUMP_PATH}
 
 if [ ! -f ${REPORT_PATH} ]; then
     exit_with_code "Report path does not exist" ${FAIL_CODE}
@@ -37,7 +37,7 @@ fi
 
 if ! unzip ${REPORT_PATH} > /dev/null; then
     popd
-    exit_with_code "FAIL: report not found in ${CRASH_DUMP_PATH}" ${FAIL_CODE}
+    exit_with_code "FAIL: report not found in ${LIVE_DUMP_PATH}" ${FAIL_CODE}
 fi
 
 COREDUMP=`find -name "kenny*coredump*"`
index 94fa8bf..747809a 100644 (file)
@@ -151,6 +151,11 @@ function __export_vars__ {
         exit_with_code "Couldn't get TZ_SYS_CRASH or TZ_SYS_CRASH is empty" ${FAIL_CODE}
     fi
 
+    export LIVE_DUMP_PATH=`tzplatform_var TZ_SYS_CRASH_ROOT`/livedump
+    if [ -z ${LIVE_DUMP_PATH} ]; then
+        exit_with_code "Couldn't get TZ_SYS_CRASH_ROOT or TZ_SYS_CRASH_ROOT is empty" ${FAIL_CODE}
+    fi
+
     export SUCCESS_CODE=0
     export FAIL_CODE=1
     export SKIP_CODE=2