Pass the "-s" (without_core) parameter to the minicoredumper if dump_core is set... 15/215215/5
authorMateusz Moscicki <m.moscicki2@partner.samsung.com>
Mon, 30 Sep 2019 10:55:42 +0000 (12:55 +0200)
committerKarol Lewandowski <k.lewandowsk@samsung.com>
Thu, 10 Oct 2019 12:51:46 +0000 (14:51 +0200)
Change-Id: I04be2a58f72d7dbb2dbfacd4d0c4b6e23c97dcf1

packaging/crash-worker.spec
src/crash-manager/crash-manager.c
src/shared/util.c
src/shared/util.h
tests/system/without_core/without_core.sh.template

index fc64bba..4d8fd96 100644 (file)
@@ -47,7 +47,7 @@ Requires(post): gzip
 Requires: zip
 Requires: libelf
 Requires: libdw
-Requires: %{_sbindir}/minicoredumper
+Requires: minicoredumper >= 2.1.0
 Requires: %{_bindir}/buxton2ctl
 
 %description
index a96342e..86396db 100644 (file)
@@ -571,6 +571,8 @@ static bool execute_minicoredump(struct crash_info *cinfo, int *exit_code)
        SNPRINTF_OR_EXIT(sig, "%d");
        SNPRINTF_OR_EXIT(time, "%ld");
 
+       const char *without_core_str = config.dump_core ? NULL : "-s";
+
        /* Execute minicoredumper */
        char *args[] = {
                        MINICOREDUMPER_BIN_PATH,   // minicoredumper filename path
@@ -588,6 +590,7 @@ static bool execute_minicoredump(struct crash_info *cinfo, int *exit_code)
                        coredump_name,             // coredump filename
                        "-P",
                        prstatus_fd_str,
+                       (char *)without_core_str,  // with or without core
                        NULL
                        };
 
@@ -596,7 +599,7 @@ static bool execute_minicoredump(struct crash_info *cinfo, int *exit_code)
 
        /* Minicoredumper must be executed to dump at least PRSTATUS for
           other tools, coredump, however, might have been disabled. */
-       if (!config.dump_core) {
+       if (!config.dump_core && file_exists_in_dir(cinfo->pfx, coredump_name)) {
                if (remove_file_in_dir(cinfo->pfx, coredump_name) != 0)
                        _E("Saving core disabled - removing coredump %s/%s failed: %m",
                           cinfo->pfx, coredump_name);
index d5917e7..6afc936 100644 (file)
@@ -584,6 +584,21 @@ bool file_exists(const char *path)
        return stat(path, &buf) == 0;
 }
 
+bool file_exists_in_dir(const char *base_dir, const char *file_name)
+{
+       char *path;
+       bool result = false;
+
+       if (asprintf(&path, "%s/%s", base_dir, file_name) == -1) {
+               _E("Failed to asprintf for path: %m");
+       } else {
+               result = file_exists(path);
+               free(path);
+       }
+
+       return result;
+}
+
 bool write_to_file(const char *content, const char *base_dir, const char *file_name)
 {
        char *path;
@@ -608,7 +623,6 @@ bool write_to_file(const char *content, const char *base_dir, const char *file_n
        }
 
        close(fd);
-       result = true;
 exit:
        free(path);
        return result;
index 8e2a82f..f820997 100644 (file)
@@ -70,6 +70,8 @@ bool string_ends_with(const char *string, const char *suffix);
 
 bool file_exists(const char *path);
 
+bool file_exists_in_dir(const char *dir_path, const char *file_name);
+
 bool write_to_file(const char *content, const char *base_dir, const char *file_name);
 
 #ifdef __cplusplus
index ca13adf..d1371e1 100644 (file)
@@ -39,4 +39,18 @@ if ls ${CRASH_DUMP_PATH}/kenny*/kenny*.coredump.tar > /dev/null; then
     fail "coredump file exists"
 fi
 
+RESULT=$(cat ${CRASH_DUMP_PATH}/kenny*/kenny*info)
+check "MemTotal:"
+check "VmExe:"
+check "VmSwap:"
+check '[heap]'
+check '/usr/lib/libm-.*.so'
+check '/usr/lib/libc-.*.so'
+check '/usr/lib/libgcc_s.so'
+check '/usr/lib/libstdc++.*so'
+check '/usr/lib/libpthread-.*.so'
+check '/usr/lib/ld-.*.so'
+check '[stack]'
+check 'main.*kenny'
+
 exit_ok