%define _with_tests on
%define TIZEN_FEATURE_PTRACE_CALLSTACK on
+%define TIZEN_FEATURE_MINICOREDUMPER on
%bcond_with doc
%bcond_with sys_assert
%bcond_with tests
Requires: zip
Requires: libelf
Requires: libdw
+
+%if "%{TIZEN_FEATURE_MINICOREDUMPER}" == "on"
+Requires: /sbin/minicoredumper
+%endif
# If you need support for core dump files (see building below),
# you should add this dependency
# Requires: libebl
export CFLAGS+=" -Werror"
export CFLAGS+=" -DTIZEN_ENGINEER_MODE"
-export CFLAGS+=" -DTIZEN_ENABLE_COREDUMP"
%ifarch %{arm} aarch64
%define ARCH arm
-DCRASH_PATH=%{crash_path} \
-DCRASH_TEMP=%{crash_temp} \
-DDEBUGMODE_PATH=%{debugmode_path} \
+%if "%{TIZEN_FEATURE_MINICOREDUMPER}" == "on"
+ -DTIZEN_ENABLE_MINICOREDUMP=on \
+ -DMINICOREDUMPER_PATH=%{_sbindir}/minicoredumper \
+ -DMINICOREDUMPER_CONF_DIR=%{_sysconfdir}/minicoredumper \
+%else
+ -DTIZEN_ENABLE_COREDUMP=on \
-DCRASH_PIPE_PATH=%{_libexecdir}/crash-pipe \
+%endif
%if "%{TIZEN_FEATURE_PTRACE_CALLSTACK}" == "on"
-DCRASH_STACK_PATH=%{_libexecdir}/crash-stack \
%endif
%{_sysconfdir}/tmpfiles.d/sys-assert.conf
%endif
+%if "%{TIZEN_FEATURE_MINICOREDUMPER}" != "on"
%{_libexecdir}/crash-pipe
+%endif
%if "%{TIZEN_FEATURE_PTRACE_CALLSTACK}" == "on"
%{_libexecdir}/crash-stack
%endif
ADD_DEFINITIONS(-DTIZEN_FEATURE_PTRACE_CALLSTACK)
ENDIF()
+IF(TIZEN_ENABLE_COREDUMP STREQUAL on)
+ ADD_DEFINITIONS(-DTIZEN_ENABLE_COREDUMP)
+ENDIF()
+
+IF(TIZEN_ENABLE_MINICOREDUMP STREQUAL on)
+ ADD_DEFINITIONS(-DTIZEN_ENABLE_MINICOREDUMP)
+ENDIF()
+
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src)
SET(CRASH_MANAGER_SRCS
crash-manager.c
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE")
-IF("$ENV{CFLAGS}" MATCHES "-DTIZEN_ENABLE_COREDUMP")
+IF(TIZEN_ENABLE_COREDUMP AND TIZEN_ENABLE_MINICOREDUMP)
+ message(FATAL_ERROR "You can not define TIZEN_ENABLE_COREDUMP and TIZEN_ENABLE_MINICOREDUMP at once.")
+ENDIF()
+
+IF(TIZEN_ENABLE_COREDUMP OR TIZEN_ENABLE_MINICOREDUMP)
OPTION(USE_COREDUMP_CONF "Use COREDUMP CONF" ON)
ENDIF()
/* Parsing */
#define CRASH_CONF_FILE tzplatform_mkpath(TZ_SYS_ETC, "crash-manager.conf")
+#define MINICOREDUMPER_CONF_FILE MINICOREDUMPER_CONF_DIR "/minicoredumper.cfg.json"
#define KEY_MAX 255
#define CRASH_SECTION "CrashManager"
#define CRASH_CHECK_DISK_PATH "/opt/usr"
+#define MINICOREDUMPER_TIMEOUT 12*60
+
enum {
RET_EXCEED = 1,
NUM_EXCEED,
}
#endif
-#ifdef TIZEN_ENABLE_COREDUMP
+#if defined(TIZEN_ENABLE_COREDUMP) || defined(TIZEN_ENABLE_MINICOREDUMP)
static void launch_crash_popup(void)
{
GDBusConnection *conn;
static void execute_crash_modules(int argc, char *argv[])
{
-#if defined(TIZEN_ENABLE_COREDUMP) || defined(TIZEN_FEATURE_PTRACE_CALLSTACK)
+#if defined(TIZEN_ENABLE_COREDUMP) || defined(TIZEN_ENABLE_MINICOREDUMP) || defined(TIZEN_FEATURE_PTRACE_CALLSTACK)
int ret;
char command[PATH_MAX];
#endif
+ _D("Execute crash module: ");
#ifdef TIZEN_ENABLE_COREDUMP
/* Execute crash-pipe */
ret = snprintf(command, sizeof(command),
"%s --save-core %s",
CRASH_PIPE_PATH,
crash_info.core_path);
+
+ _D(" %s", command);
+
if (ret < 0) {
_E("Failed to snprintf for crash-pipe command");
return;
system_command(command);
#endif
+
+#ifdef TIZEN_ENABLE_MINICOREDUMP
+ char *coredump_name = NULL;
+ if (asprintf(&coredump_name, "%s.coredump", crash_info.name) == -1)
+ coredump_name = strdup("core");
+
+ /* Execute minicoredumper */
+ char *args[] = {
+ MINICOREDUMPER_PATH, // minicoredumper filename path
+ crash_info.pid_info, // %p - pid
+ argv[2], // %u - UID
+ argv[3], // %g - GID
+ crash_info.sig_info, // %s - number of signal
+ argv[5], // %t - time of dump
+ "localhost", // %h - hostname
+ "core", // %e - exe name (need for result filename)
+ MINICOREDUMPER_CONF_FILE, // config file
+ "-d",
+ crash_info.pfx, // temp dir
+ "-o",
+ coredump_name, // coredump filename
+ NULL
+ };
+
+ _D(" %s", args[0]);
+
+ run_command_timeout(args[0], args, NULL, MINICOREDUMPER_TIMEOUT);
+
+ free(coredump_name);
+#endif
+
#ifdef TIZEN_FEATURE_PTRACE_CALLSTACK
# ifdef SYS_ASSERT
{
/* Execute dump_systemstate in parallel */
static int dump_state_pid;
-#ifdef TIZEN_ENABLE_COREDUMP
+#if defined(TIZEN_ENABLE_COREDUMP) || defined(TIZEN_ENABLE_MINICOREDUMP)
int debug_mode = access(DEBUGMODE_PATH, F_OK) == 0;
#endif
compress();
else
move_dump_dir();
-#ifdef TIZEN_ENABLE_COREDUMP
+#if defined(TIZEN_ENABLE_COREDUMP) || defined(TIZEN_ENABLE_MINICOREDUMP)
/* launch crash-popup only if the .debugmode file is exist*/
if (debug_mode)
launch_crash_popup();