Disable New Crash Stack
[platform/core/system/crash-worker.git] / src / crash-manager / crash-manager.sh.in
1 #!/bin/sh
2
3 source /etc/tizen-platform.conf
4
5 PATH=/bin:/usr/bin:/sbin:/usr/sbin
6
7 exec >/dev/null 2>&1
8
9 PATH=/bin:/usr/bin
10 CRASH_PATH="@CRASH_PATH@"
11 CRASH_TEMP="@CRASH_TEMP@"
12
13 if [ ! -d "${CRASH_PATH}" ]
14 then
15   mkdir -p "${CRASH_PATH}"
16   /usr/bin/chsmack -a "System::Shared" -t "${CRASH_PATH}"
17 fi
18
19 if [ ! -d "${CRASH_TEMP}" ]
20 then
21   mkdir -p "${CRASH_TEMP}"
22   /usr/bin/chsmack -a "System::Shared" -t "${CRASH_TEMP}"
23 fi
24
25 DEBUG=1
26
27 # Expected invocation from kernel:
28 #
29 #   argv0 PID UID GID SIGNAL TIME CMD
30 pid="$1"
31 time="$5"
32 cmd="$6"
33
34 temp_dir="$(mktemp -d "${CRASH_TEMP}/crash.XXXXXX")"
35
36 name="${cmd}_${pid}_${time}"
37 result_path="${CRASH_PATH}/${name}.tar.gz"
38 pfx="${temp_dir}/${name}"
39 info_path="${pfx}/${name}.info"
40 core_path="${pfx}/${name}.coredump"
41 log_path="${pfx}/${name}.log"
42 tmp_callstack_path="${pfx}/${name}.callstack"
43 sysassert_cs_path="/tmp/crash_stack/${cmd}_${pid}.info"
44
45 mkdir -p "$pfx"
46 if [ "@SYS_ASSERT@" = "on" ]
47 then
48   mv "$sysassert_cs_path" "$pfx/"
49 fi
50
51 if [ $DEBUG -eq 1 ]
52 then
53   @CRASH_PIPE_PATH@ --save-core "$core_path" --report "$@" > "$info_path"
54 #  @CRASH_STACK_PATH@ --pid "$pid" >> "$info_path"
55 else
56   @CRASH_PIPE_PATH@ --report "$@" > "$info_path"
57 #  @CRASH_STACK_PATH@ --pid "$pid" >> "$info_path"
58 fi
59
60 if [ -e $TZ_SYS_ETC/.debugmode ]
61 then
62 #Find the full path of executable. The path is used to find appid in the crash-popup
63         exepath=" "
64         found=0
65         while read line
66         do
67                 if [ $found -eq 1 ]
68                 then
69                         exepath=$(echo $line | sed "s/0: //")
70                         break
71                 fi
72
73                 if [ "$line" = "Cmdline:" ]
74                 then
75                         found=1
76                 fi
77
78         done < $info_path
79
80 #Call dbus method to launch the crash-popup
81         /usr/bin/dbus-send --system --type=method_call --print-reply --reply-timeout=120000 --dest=org.tizen.system.popup /Org/Tizen/System/Popup/Crash org.tizen.system.popup.Crash.PopupLaunch dict:string:string:"_SYSPOPUP_CONTENT_","crash","_PROCESS_NAME_","${cmd}","_EXEPATH_","${exepath}"
82
83 fi
84
85 dump_systemstate -d -k -f "$log_path" || true
86
87 tar czf "${temp_dir}/report.tar.gz" -C "$temp_dir" "$name"
88 mv "${temp_dir}/report.tar.gz" "$result_path"
89
90 [ "$temp_dir" ] && rm -rf "$temp_dir"
91