1) Change log_dump dbus path and interface.
2) Add delete_dump option to log_dump's dbus interface.
3) Move log_dump's result from CRASH_ROOT to LOG_DUMP_RESULT.
4) tizen-debug on/off services are added.
Change-Id: I0257537ad69b524714370c1ecfa11cc9d942a560
Signed-off-by: Sunmin Lee <sunm.lee@samsung.com>
mkdir -p %{buildroot}%{crash_all_log}
mkdir -p %{buildroot}%{crash_dump_gen}
cp dump_scripts/* %{buildroot}%{crash_dump_gen}
+chmod 755 %{buildroot}%{crash_dump_gen}/*
%if "%{eng_mode}" == "on"
install -m 644 src/crash-manager/debugmode %{buildroot}%{eng_mode_path}/.debugmode
%endif
-%if "%{?sys_assert}" == "on"
-
%post
+%if "%{?sys_assert}" == "on"
if [ ! -d /.build ]; then
orig="%{_libdir}/libsys-assert.so"
pattern=$(echo $orig | sed -e 's|/|\\/|g')
chmod 644 %{_sysconfdir}/ld.so.preload
fi
+/sbin/ldconfig
+%endif
+
/usr/bin/chsmack -a "System::Shared" -t %{crash_path}
/usr/bin/chsmack -a "System::Shared" -t %{crash_temp}
-
-/sbin/ldconfig
+/usr/bin/chsmack -a "System::Shared" -t %{crash_dump_gen}
+/usr/bin/chsmack -a "System::Shared" -t %{crash_dump_gen}/module.d
+/usr/bin/chsmack -d %{crash_dump_gen}/module.d/*
%postun
+%if "%{?sys_assert}" == "on"
orig="%{_libdir}/libsys-assert.so"
pattern=$(echo $orig | sed -e 's|/|\\/|g')
sed -i "/${pattern}/D" %{_sysconfdir}/ld.so.preload
/sbin/ldconfig
-
%endif
%files
%attr(0755,system,system) %{_bindir}/dump_systemstate
%attr(0755,system,system) %{_bindir}/crash-manager.sh
%attr(0755,system,system) %{_bindir}/log_dump
+%attr(0644,root,system) %{_unitdir}/tizen-debug-on.service
+%attr(0644,root,system) %{_unitdir}/tizen-debug-off.service
%{_prefix}/lib/sysctl.d/99-crash-manager.conf
%{_datadir}/dbus-1/system-services/org.tizen.system.crash.service
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE")
+CONFIGURE_FILE(log_dump.h.in log_dump.h @ONLY)
ADD_EXECUTABLE(${PROJECT_NAME} ${LOG_DUMP_SRCS})
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${log_dump_pkgs_LDFLAGS} -pie)
#include "dbus-handler.h"
#define CRASH_BUS_NAME "org.tizen.system.crash"
-#define CRASH_BUS_PATH "/Org/Tizen/System/Crash"
+#define CRASH_BUS_PATH "/Org/Tizen/System/Crash/Crash"
#define TIMEOUT_INTERVAL 30
static GDBusNodeInfo *introspection_data;
static const gchar introspection_xml[] =
"<node>"
-" <interface name='org.tizen.system.crash'>"
-" <method name='normal_dump'>"
+" <interface name='org.tizen.system.crash.Crash'>"
+" <method name='dump_log'>"
+" <arg type='s' name='arg' direction='in'/>"
" <arg type='i' name='response' direction='out'/>"
" </method>"
-" <method name='short_dump'>"
+" <method name='delete_dump'>"
" <arg type='i' name='response' direction='out'/>"
" </method>"
" </interface>"
gpointer user_data)
{
int ret = -1;
- int option = -1;
+ const gchar *arg;
remove_timeout();
- if (g_strcmp0(method_name, "normal_dump") == 0)
- option = OPT_NORMAL;
- else if (g_strcmp0(method_name, "short_dump") == 0)
- option = OPT_SHORT;
+ if (g_strcmp0(method_name, "dump_log") == 0) {
+ g_variant_get(parameters, "(&s)", &arg);
+ if (g_strcmp0(arg, "normal") == 0)
+ ret = log_dump(OPT_NORMAL);
+ else if (g_strcmp0(arg, "short") == 0)
+ ret = log_dump(OPT_SHORT);
+ else
+ LOGE("Wrong option for log_dump");
+ } else if (g_strcmp0(method_name, "delete_dump") == 0) {
+ ret = delete_dump();
+ }
- if (option >= 0)
- ret = log_dump(option);
g_dbus_method_invocation_return_value(invocation,
g_variant_new("(i)", ret));
#include <dirent.h>
#include <libgen.h>
#include <system_info.h>
-#include <tzplatform_config.h>
#include "shared/util.h"
#include "log_dump.h"
#include "dbus-handler.h"
#undef LOG_TAG
#define LOG_TAG "LOG_DUMP"
-#define LOG_DUMP_ROOT tzplatform_getenv(TZ_SYS_CRASH_ROOT)
-#define LOG_DUMP_DIR tzplatform_getenv(TZ_SYS_ALLLOGS)
-#define CRASH_DUMP_DIR tzplatform_getenv(TZ_SYS_CRASH)
-#define DUMP_SCRIPTS_DIR tzplatform_getenv(TZ_SYS_DUMPGEN)
#define SYSTEM_INFO_KEY_BUILD_STRING "http://tizen.org/system/build.string"
static const struct option opts[] = {
script_num = scandir(DUMP_SCRIPTS_DIR, &dir_list, NULL, NULL);
if (script_num < 0) {
- LOGE("Failed to scandir");
+ LOGE("Failed to scandir %s",DUMP_SCRIPTS_DIR);
return -1;
}
system_command(command);
}
+ /* Make result directory */
+ if (access(LOG_DUMP_RESULT, F_OK) != 0) {
+ ret = snprintf(command, sizeof(command),
+ "/usr/bin/mkdir -p %s", LOG_DUMP_RESULT);
+ if (ret < 0) {
+ LOGE("Failed to mkdir");
+ return -1;
+ }
+ system_command(command);
+ }
+
/* Get timestamp */
cur_time = time(NULL);
localtime_r(&cur_time, &loc_tm);
ret = snprintf(command, sizeof(command),
"/bin/tar -zcf %s/%s%s.tar.gz -C %s %s %s",
- LOG_DUMP_ROOT, dump_filename, timestr,
+ LOG_DUMP_RESULT, dump_filename, timestr,
LOG_DUMP_ROOT, basename(dump_dirname),
basename(crash_dirname));
if (ret < 0) {
} else {
ret = snprintf(command, sizeof(command),
"/bin/tar -zcf %s/%s%s.tar.gz -C %s %s",
- LOG_DUMP_ROOT, dump_filename, timestr,
+ LOG_DUMP_RESULT, dump_filename, timestr,
LOG_DUMP_ROOT, basename(dump_dirname));
if (ret < 0) {
LOGE("Failed to snprintf for command");
return ret;
}
+int delete_dump(void)
+{
+ LOGI("delete_dump!");
+
+ remove_dir(LOG_DUMP_DIR, 0);
+ remove_dir(LOG_DUMP_RESULT, 1);
+ remove_dir(CRASH_DUMP_DIR, 0);
+ remove_dir(CRASH_TEMP_DIR, 0);
+
+ return 0;
+}
+
int main(int argc, char *argv[])
{
int c, ret;
#ifndef __LOGDUMP_H__
#define __LOGDUMP_H__
+#include <tzplatform_config.h>
#include <dlog.h>
#undef LOG_TAG
#define LOG_TAG "LOG_DUMP"
+#define LOG_DUMP_ROOT tzplatform_getenv(TZ_SYS_CRASH_ROOT)
+#define LOG_DUMP_DIR tzplatform_getenv(TZ_SYS_ALLLOGS)
+#define LOG_DUMP_RESULT tzplatform_mkpath(TZ_SYS_CRASH_ROOT, "debug")
+#define CRASH_DUMP_DIR "@CRASH_PATH@"
+#define CRASH_TEMP_DIR "@CRASH_TEMP@"
+#define DUMP_SCRIPTS_DIR tzplatform_getenv(TZ_SYS_DUMPGEN)
+
enum {
OPT_NORMAL,
OPT_SHORT,
};
int log_dump(int option);
+int delete_dump(void);
#endif
CONFIGURE_FILE(sys-assert.conf.in sys-assert.conf)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/sys-assert.conf DESTINATION ${TMP_FILES_DIR})
+
+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)
+
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/tizen-debug-off.service DESTINATION /usr/lib/systemd/system
+ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
+ GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
\ No newline at end of file
--- /dev/null
+[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
--- /dev/null
+[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