* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <sys/vfs.h>
#include <fcntl.h>
#include <gio/gio.h>
+#include <dirent.h>
#include <iniparser.h>
#include <tzplatform_config.h>
#include <pkgmgr-info.h>
get_and_save_so_info(maps_path, so_info_path);
}
+/* remove a file whose name begins with 'beggining_of_name'. This is needed
+ * when we don't want to include coredump in report, but we only know the
+ * beginning of the coredump file name. */
+static int remove_file_in_dir(const char *directory, const char *beginning_of_name)
+{
+ int ret = -1;
+ int errno_unlink = 0;
+
+ DIR *dir = opendir(directory);
+ if (dir == NULL)
+ goto end;
+
+ int dir_fd = dirfd(dir);
+ if (dir_fd == -1) {
+ closedir(dir);
+ goto end;
+ }
+
+ struct dirent* file_info;
+ while ((file_info = readdir(dir)) != NULL) {
+ if (strstr(file_info->d_name, beginning_of_name) == file_info->d_name) {
+ ret = unlinkat(dir_fd, file_info->d_name, 0);
+ errno_unlink = errno;
+ break;
+ }
+ }
+ closedir(dir);
+ errno = errno_unlink; /* for %m */
+end:
+ return ret;
+}
+
// These macros are used in execute_minicoredump() and execute_crash_stack()
#define SNPRINTF_OR_EXIT_W(name, format, member) if (snprintf(name##_str, sizeof(name##_str), format, cinfo->member) < 0) goto out;
#define SNPRINTF_OR_EXIT(name, format) SNPRINTF_OR_EXIT_W(name, format, name##_info)
/* Minicoredumper must be executed to dump at least PRSTATUS for
other tools, coredump, however, might have been disabled. */
if (!dump_core) {
- int ret = -1;
- int errno_unlink = 0;
- int dirfd = open(cinfo->pfx, O_DIRECTORY);
- if (dirfd != -1) {
- ret = unlinkat(dirfd, coredump_name, 0);
- errno_unlink = errno;
- close(dirfd);
- errno = errno_unlink; /* for %m below */
- }
-
+ ret = remove_file_in_dir(cinfo->pfx, coredump_name);
if (ret != 0)
_E("Saving core disabled - removing coredump %s/%s failed: %m",
cinfo->pfx, coredump_name);
save_core_pattern
echo "|${CRASH_WORKER_SYSTEM_TESTS}/check_minicore_mem/cp.sh %p %u %g %s %t %h %e ${BASE_DIR} ${CORE_MINI} ${MEM_LIMIT}" > /proc/sys/kernel/core_pattern
-rm -f ${BASE_DIR}/${CORE_MINI}
+rm -f ${BASE_DIR}/${CORE_MINI}*
{
${CRASH_WORKER_SYSTEM_TESTS}/utils/kenny &
restore_core_pattern
-wait_for_file ${BASE_DIR}/${CORE_MINI}
+wait_for_file ${BASE_DIR}/${CORE_MINI}.tar
+untar_file ${BASE_DIR} ${CORE_MINI}.tar
RESULT=`gdb ${CRASH_WORKER_SYSTEM_TESTS}/utils/kenny ${BASE_DIR}/${CORE_MINI} --batch -ex "thread apply all bt"`
check "MAGICNAME.*id=.*kenny.cpp:31"
echo "|${CRASH_WORKER_SYSTEM_TESTS}/cmp_backtraces/cp.sh %p %u %g %s %t %h %e ${BASE_DIR} ${CORE_ORIG} ${CORE_MINI}" > /proc/sys/kernel/core_pattern
-rm -f ${BASE_DIR}/${CORE_MINI}
+rm -f ${BASE_DIR}/${CORE_MINI}*
rm -f ${BASE_DIR}/${CORE_ORIG}
rm -f ${BASE_DIR}/${THREADS_MINI}
rm -f ${BASE_DIR}/${THREADS_ORIG}
restore_core_pattern
wait_for_file ${BASE_DIR}/${CORE_ORIG}
-wait_for_file ${BASE_DIR}/${CORE_MINI}
+wait_for_file ${BASE_DIR}/${CORE_MINI}.tar
wait_for_app minicoredumper
+untar_file ${BASE_DIR} ${CORE_MINI}.tar
+
gdb ${CRASH_WORKER_SYSTEM_TESTS}/utils/kenny ${BASE_DIR}/${CORE_ORIG} -ex "thread apply all bt" -ex "q" 2> /dev/null | grep -e '^#' > ${BASE_DIR}/${THREADS_ORIG}
gdb ${CRASH_WORKER_SYSTEM_TESTS}/utils/kenny ${BASE_DIR}/${CORE_MINI} -ex "thread apply all bt" -ex "q" 2> /dev/null | grep -e '^#' > ${BASE_DIR}/${THREADS_MINI}