forked from hatem-mahmoud/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sql_resolver2.sh
111 lines (76 loc) · 2.26 KB
/
sql_resolver2.sh
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
var=`echo $1 | cut -d"|" -f4`
state=`echo $1 | cut -d"|" -f1 `
offset_var=0x`echo $1 | cut -d"|" -f3`
kglhd_var=0x`echo $1 | cut -d"|" -f4`
time=`echo $1 | cut -d"|" -f2`
depth=`echo $1 | cut -d"|" -f5`
p_obj_var=""
cur_depth=`cat current_depth`
if [ -z $depth ]
then
depth=0
fi
if [ $var != 0 ]
then
cache_test=`grep "$kglhd_var $offset_var" cache_resolver`
if [ -z "$cache_test" ]
then
# ARGUMENT 1 and 3 of funtion pfrln0lookup have to be investigated in more detail for now i just put any address that s mapped to VAS of the target process
line_var=`sqlplus / as sysdba <<EOF 2>&1 | grep -i function | cut -d' ' -f4
oradebug setmypid
oradebug call pfrln0lookup 0x7ffff3c6bc38 $kglhd_var 0x7ffff3c6bc38 $offset_var
exit;
EOF`
obj_var=`sqlplus / as sysdba <<EOF 2>&1 | grep "O:" | tail -1 | tr -d ';'
SELECT 'O:'||KGLNAOWN||'.'||KGLNAOBJ as name FROM "X\\$KGLOB" where to_number(KGLHDADR,'XXXXXXXXXXXXXXXX') = to_number(substr('$kglhd_var', instr(lower('$kglhd_var'), 'x')+1) ,'XXXXXXXXXXXXXXXX') ;
exit;
EOF`
if [ $cur_depth -gt 0 ]
then
for (( c=1; c<=$cur_depth; c++ ))
do
p_obj_var="$p_obj_var"`cat current_depth_s.$c`";"
done
fi
if [ $depth -eq 99999 ]
then
echo $(($cur_depth - 1 )) > current_depth
elif [ $depth -gt 1 ]
then
echo $obj_var`echo "("$((16#$line_var))`")" > current_depth_s.`echo $(($cur_depth + 1 ))`
echo $(($cur_depth + 1 )) > current_depth
fi
if [ $cur_depth -gt 0 ]
then
echo "Line Tracker|"$time"|"$p_obj_var""$obj_var"("`echo $((16#$line_var))`")"
else
echo "Line Tracker|"$time"|"$obj_var"("`echo $((16#$line_var))`")"
fi
echo $kglhd_var $offset_var "/"$obj_var"("`echo $((16#$line_var))`")" >> cache_resolver
else
if [ $cur_depth -gt 0 ]
then
for (( c=1; c<=$cur_depth; c++ ))
do
p_obj_var="$p_obj_var"`cat current_depth_s.$c`";"
done
fi
if [ $depth = 99999 ]
then
echo $(($cur_depth - 1 )) > current_depth
elif [ $depth -gt 1 ]
then
echo `echo $cache_test | cut -d"/" -f2` > current_depth_s.`echo $(($cur_depth + 1 ))`
echo $(($cur_depth + 1 )) > current_depth
fi
if [ $cur_depth -gt 0 ]
then
echo "Line Tracker|"$time"|"$p_obj_var`echo $cache_test | cut -d"/" -f2`
else
echo "Line Tracker|"$time"|"`echo $cache_test | cut -d"/" -f2`
fi
fi
elif [ "$state" != "Line Tracker" ]
then
echo $state"|"$time"|0|0"
fi