crash-worker: Generate core only if /opt/etc/.debugmode file is present 10/128110/1
authorKarol Lewandowski <k.lewandowsk@samsung.com>
Fri, 5 May 2017 13:03:20 +0000 (15:03 +0200)
committerKarol Lewandowski <k.lewandowsk@samsung.com>
Fri, 5 May 2017 13:03:20 +0000 (15:03 +0200)
Additionally, this patch moves actual path definition to one place.

Change-Id: I984ac2c67d8a22ed749f2b1945a1cef237b88ace

data/CMakeLists.txt
data/tizen-debug-off.service [deleted file]
data/tizen-debug-off.service.in [new file with mode: 0644]
data/tizen-debug-on.service [deleted file]
data/tizen-debug-on.service.in [new file with mode: 0644]
packaging/crash-worker.spec
src/crash-manager/crash-manager.c
src/crash-manager/crash-manager.h.in

index 91a31e5a5feca47eed3a78cbe6c164d197cffb13..681894d2d5596afa48f14ee2a59fe108b17958dd 100644 (file)
@@ -1,3 +1,6 @@
+CONFIGURE_FILE(tizen-debug-on.service.in tizen-debug-on.service @ONLY)
+CONFIGURE_FILE(tizen-debug-off.service.in tizen-debug-off.service @ONLY)
+
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/tizen-debug-on.service DESTINATION /usr/lib/systemd/system
         PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
         GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
diff --git a/data/tizen-debug-off.service b/data/tizen-debug-off.service
deleted file mode 100644 (file)
index 870964e..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-[Unit]
-Description=tizen debug off
-DefaultDependencies=no
-After=opt.mount tizen-debug-on.service
-Before=sysinit.target
-
-[Service]
-SmackProcessLabel=System
-Type=oneshot
-RemainAfterExit=yes
-ExecStart=/bin/rm -f /opt/etc/.debugmode
-ExecStart=/sbin/sysctl kernel.core_pattern=/dev/null
-
-[Install]
-WantedBy=sysinit.target
diff --git a/data/tizen-debug-off.service.in b/data/tizen-debug-off.service.in
new file mode 100644 (file)
index 0000000..6d5ee4d
--- /dev/null
@@ -0,0 +1,14 @@
+[Unit]
+Description=tizen debug off
+DefaultDependencies=no
+After=opt.mount tizen-debug-on.service
+Before=sysinit.target
+
+[Service]
+SmackProcessLabel=System
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=/bin/rm -f @DEBUGMODE_PATH@
+
+[Install]
+WantedBy=sysinit.target
diff --git a/data/tizen-debug-on.service b/data/tizen-debug-on.service
deleted file mode 100644 (file)
index 22ae97a..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-[Unit]
-Description=tizen debug on
-DefaultDependencies=no
-After=opt.mount
-Before=sysinit.target
-
-[Service]
-SmackProcessLabel=System
-Type=oneshot
-RemainAfterExit=yes
-ExecStart=/bin/touch -f /opt/etc/.debugmode
-ExecStart=/sbin/sysctl -p /usr/lib/sysctl.d/99-crash-manager.conf
-
-[Install]
-WantedBy=sysinit.target
diff --git a/data/tizen-debug-on.service.in b/data/tizen-debug-on.service.in
new file mode 100644 (file)
index 0000000..da91aac
--- /dev/null
@@ -0,0 +1,14 @@
+[Unit]
+Description=tizen debug on
+DefaultDependencies=no
+After=opt.mount
+Before=sysinit.target
+
+[Service]
+SmackProcessLabel=System
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=/bin/touch -f @DEBUGMODE_PATH@
+
+[Install]
+WantedBy=sysinit.target
index bddd69048275df52b7a8a4aeedbffd086d1af132..5fff3757604a301028fb563d699675ad09c963f4 100644 (file)
@@ -5,7 +5,6 @@
 %define _with_tests on
 %define TIZEN_FEATURE_PTRACE_CALLSTACK on
 %bcond_with doc
-%bcond_with core_dump
 %bcond_with sys_assert
 %bcond_with tests
 
@@ -73,6 +72,9 @@ This package contains installable tests in Bash.
 %define crash_path      %{TZ_SYS_CRASH}
 %define crash_temp      %{crash_root_path}/temp
 
+#Debug mode path - existence of file at path below mean that core file should be generated
+%define debugmode_path      %{TZ_SYS_ETC}/.debugmode
+
 #Path for log_dump module
 %define crash_all_log   %{TZ_SYS_ALLLOGS}
 %define crash_dump_gen  %{TZ_SYS_DUMPGEN}
@@ -106,6 +108,7 @@ export CFLAGS+=" -Werror"
           -DCRASH_ROOT_PATH=%{crash_root_path} \
           -DCRASH_PATH=%{crash_path} \
           -DCRASH_TEMP=%{crash_temp} \
+          -DDEBUGMODE_PATH=%{debugmode_path} \
           -DCRASH_PIPE_PATH=%{_libexecdir}/crash-pipe \
 %if "%{TIZEN_FEATURE_PTRACE_CALLSTACK}" == "on"
           -DCRASH_STACK_PATH=%{_libexecdir}/crash-stack \
@@ -113,7 +116,6 @@ export CFLAGS+=" -Werror"
           -DCRASH_TESTS_PATH=%{_libdir}/crash-worker-tests \
           -DSYS_ASSERT=%{on_off sys_assert} \
           -DUPGRADE_SCRIPT_PATH=%{upgrade_script_path} \
-          -DWITH_CORE_DUMP=%{on_off core_dump} \
           -DTIZEN_FEATURE_PTRACE_CALLSTACK=%{TIZEN_FEATURE_PTRACE_CALLSTACK}
 
 make %{?jobs:-j%jobs}
index 60b24d409f5449c2ea6331b05186cd862ff0584f..3602596bae70035a5ddf1ecd49018a4bc6482031 100644 (file)
@@ -40,8 +40,6 @@
 #undef LOG_TAG
 #define LOG_TAG "CRASH_MANAGER"
 
-#define DEBUGMODE_FILE       tzplatform_mkpath(TZ_SYS_ETC, ".debugmode")
-
 /* Parsing */
 #define CRASH_CONF_FILE      tzplatform_mkpath(TZ_SYS_ETC, "crash-manager.conf")
 #define KEY_MAX              255
@@ -783,6 +781,7 @@ int main(int argc, char *argv[])
 {
        /* Execute dump_systemstate in parallel */
        static int dump_state_pid;
+       int debug_mode = access(DEBUGMODE_PATH, F_OK) == 0;
 
        prctl(PR_SET_DUMPABLE, 0);
 
@@ -806,7 +805,7 @@ int main(int argc, char *argv[])
        dump_state_pid = dump_system_state();
 
        /* Exec crash modules */
-       execute_crash_modules(argc, argv, DEBUG);
+       execute_crash_modules(argc, argv, debug_mode);
 
        /* Wait dump_system_state */
        wait_system_command(dump_state_pid);
@@ -817,8 +816,8 @@ int main(int argc, char *argv[])
        else
                move_dump_dir();
 
-       /* .dbugmode: launch crash-popup */
-       if (access(DEBUGMODE_FILE, F_OK) == 0)
+       /* launch crash-popup only if core file was saved ("debug mode")*/
+       if (debug_mode)
                launch_crash_popup();
 
        return 0;
index 772177e3cc84b2afc61f5f016583ee9260c147d5..7a4089eb0ad9e9cd2c2513efedaebb0a8915d725 100644 (file)
@@ -27,7 +27,6 @@
 #define CRASH_STACK_PATH "@CRASH_STACK_PATH@"
 #endif
 #define CRASH_PIPE_PATH  "@CRASH_PIPE_PATH@"
-
-#define DEBUG 1
+#define DEBUGMODE_PATH   "@DEBUGMODE_PATH@"
 
 #endif