-
Notifications
You must be signed in to change notification settings - Fork 0
/
zdebug
executable file
·148 lines (132 loc) · 3.56 KB
/
zdebug
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/bin/sh
## Readme ##
# * 用于调试xx
## 全局
OTHER_OPER=
## 杀死进程
dt4_killall_proc()
{
## 杀死看门狗
PGREP_RESULT=$(pgrep -f "reboot_server.sh")
if [ -n "$PGREP_RESULT" ]; then
kill $PGREP_RESULT
echo "All matching processes terminated."
fi
## 杀死主程序
PGREP_RESULT=$(pgrep -f "ditoo")
if [ -n "$PGREP_RESULT" ]; then
kill $PGREP_RESULT
# killall ditoo
echo "All matching processes terminated."
fi
}
## 测试主线程维护
dt4_wdogs()
{
while true
do
pgrep_ret=$(pgrep -f "ditoo main")
if [ -z "$pgrep_ret" ]; then
echo restart main
/mnt/nandflash/DT4/ditoo main >> /dev/null 2>&1 &
fi
pgrep_ret=$(pgrep -f "ditoo report")
if [ -z "$pgrep_ret" ]; then
echo restart report
/mnt/nandflash/DT4/ditoo report >> /dev/null 2>&1 &
fi
sleep 1
done
}
show_usage()
{
echo "Usage: $0 [-h] [-c core] [-o opt]"
echo "Options:"
echo " -h, --help Display help message"
# echo " -c core Set target platform architecture(e320, x100, x300, x86)"
echo " -o opt Set operation mode:"
echo " wdog: 运行看门狗"
echo " wdogs: 运行 main && report 看门狗"
echo " kill: 杀死所有进程"
echo " print: 打印调试信息"
exit 0
}
perform_operation() {
echo "-- run $OTHER_OPER"
case "$OTHER_OPER" in
wdog)
/etc/reboot_server.sh
;;
wdogs)
dt4_killall_proc
dt4_wdogs
;;
kill)
dt4_killall_proc
;;
print)
/mnt/nandflash/DT4/tools/print_debug_info.sh
;;
*)
echo "Unknown operation: $OTHER_OPER"
exit 1
;;
esac
exit 0
}
process_options()
{
# 解析命令行参数
while getopts ":hc:o:-:" opt; do
case $opt in
h)
show_usage
;;
c)
# 处理 -c 选项的参数
CORE_APP="$OPTARG"
;;
o)
# 处理 -o 选项的参数
OTHER_OPER="$OPTARG"
perform_operation
;;
-)
case "${OPTARG}" in
help)
# 处理 --help 选项
show_usage
;;
*)
# 其他选项
;;
esac
;;
\?)
# 处理无效选项
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
# 处理缺少参数的选项
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
}
## main ##
RUNDIR=$(pwd)
process_options "$@"
# 配置makefile依赖
if [ "$CORE_APP" == "e320" ];then
COMPILER_PREFIX=arm-openwrt-linux-gnueabi-
# CLOUD_DIR="e320"
elif [ "$CORE_APP" == "x100" ];then
COMPILER_PREFIX=arm-openwrt-linux-muslgnueabi-
elif [ "$CORE_APP" == "x300" ];then
COMPILER_PREFIX=arm-openwrt-linux-muslgnueabi-
elif [ "$CORE_APP" == "x86" ];then
COMPILER_PREFIX=""
fi
echo -e "\033[0;32m--debug done\033[0m"