简化gdb脚本
时间:2021-07-01 10:21:17
帮助过:1人阅读
#!/bin/
bash
2
3 #check num of argv
4
5 if [[ $# -ne
1 ]];
then
6 echo ‘err: argv num!‘
7 exit
8 fi
9
10 #deal
string
11 var_argv=$
1
12 var_name=`
echo $var_argv|
tr -d
"/"`
13 var_pid_name=${var_argv}
‘IM‘${var_name}
14
15 ret_var=`
ps -x |
grep $var_pid_name |
grep -v
grep |
awk ‘{print $1}‘`
16
17 #
string to array
18 arr_out=
()
19 arr=(${ret_var/
‘ ‘/
})
20
21 for i
in ${arr[@]}
22 do
23 arr_out[${#arr_out[@]}]=
$i
24 done
25
26
27 #Determines that the
string length
28
29 len_arr=
${#arr_out[@]}
30
31 if [[ $len_arr -ne
1 ]];
then
32 echo ‘Too manay pid!‘
33 for pid
in ${arr_out[*
]}
34 do
35 echo $pid
36 done
37 exit
38 fi
39
40 echo ‘curpid:‘ $ret_var
41 gdb attach $ret_var
View Code
简化gdb脚本
标签: