diff options
author | Mateusz Moscicki <m.moscicki2@partner.samsung.com> | 2019-09-30 12:55:42 +0200 |
---|---|---|
committer | Karol Lewandowski <k.lewandowsk@samsung.com> | 2019-10-10 14:51:46 +0200 |
commit | 82076809edf56498798d2a1190414fbe1bd6cfbc (patch) | |
tree | e54e8db67d9e8fab8f3de4323c0a90eb18cedc76 | |
parent | 4611af50d6db1dd8ee089cb3d3846c82d8fffd90 (diff) | |
download | crash-worker-82076809edf56498798d2a1190414fbe1bd6cfbc.tar.gz crash-worker-82076809edf56498798d2a1190414fbe1bd6cfbc.tar.bz2 crash-worker-82076809edf56498798d2a1190414fbe1bd6cfbc.zip |
Pass the "-s" (without_core) parameter to the minicoredumper if dump_core is set to 0
Change-Id: I04be2a58f72d7dbb2dbfacd4d0c4b6e23c97dcf1
-rw-r--r-- | packaging/crash-worker.spec | 2 | ||||
-rw-r--r-- | src/crash-manager/crash-manager.c | 5 | ||||
-rw-r--r-- | src/shared/util.c | 16 | ||||
-rw-r--r-- | src/shared/util.h | 2 | ||||
-rw-r--r-- | tests/system/without_core/without_core.sh.template | 14 |
5 files changed, 36 insertions, 3 deletions
diff --git a/packaging/crash-worker.spec b/packaging/crash-worker.spec index fc64bba..4d8fd96 100644 --- a/packaging/crash-worker.spec +++ b/packaging/crash-worker.spec @@ -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 diff --git a/src/crash-manager/crash-manager.c b/src/crash-manager/crash-manager.c index a96342e..86396db 100644 --- a/src/crash-manager/crash-manager.c +++ b/src/crash-manager/crash-manager.c @@ -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); diff --git a/src/shared/util.c b/src/shared/util.c index d5917e7..6afc936 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -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; diff --git a/src/shared/util.h b/src/shared/util.h index 8e2a82f..f820997 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -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 diff --git a/tests/system/without_core/without_core.sh.template b/tests/system/without_core/without_core.sh.template index ca13adf..d1371e1 100644 --- a/tests/system/without_core/without_core.sh.template +++ b/tests/system/without_core/without_core.sh.template @@ -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 |