-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
cache-symfiles.sh
executable file
·62 lines (51 loc) · 1.42 KB
/
cache-symfiles.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
#!/bin/sh
# This script is old; not sure if it still works...
if [ "$(id -u)" != "0" ]; then
echo "This program must be run as root."
exit 1
fi
dir=/usr/libexec/gdb/symfiles
gdb=/usr/bin/gdb
echo "Removing current cache ... "
rm -rf "$dir"
mkdir -p "$dir"
echo "done"
echo "Finding libraries ... "
libs="/usr/lib/dyld"
for i in \
/System/Library/Frameworks/*.framework \
/System/Library/PrivateFrameworks/*.framework \
/System/Library/Frameworks/*.framework/Frameworks/*.framework \
/System/Library/PrivateFrameworks/*.framework/Frameworks/*.framework \
; do
name=$(basename "${i}" .framework)
if [ -f "${i}/${name}" ]; then
if nm "${i}/${name}" >/dev/null 2>&1
then
libs="${libs} ${i}/${name}"
fi
fi
done
for i in \
$(find /usr/lib -name lib\*.dylib -type f) \
/System/Library/Frameworks/*.framework/Libraries/*.dylib \
; do
name=$(basename "${i}" .dylib)
name=$(echo "${name}" | sed -e 's/\.[ABC]$//' -e 's/^lib//')
if nm "${i}" >/dev/null 2>&1
then
libs="${libs} ${i}"
fi
done
echo "done"
for i in $libs; do
if [ "$(basename "${i}")" = "dyld" ]; then
echo "sharedlibrary cache-symfile $i $dir __dyld_" >> /tmp/syms_$$.gdb
else
echo "sharedlibrary cache-symfile $i $dir" >> /tmp/syms_$$.gdb
fi
done
echo "Processing libraries ... "
$gdb -nx --batch --command=/tmp/syms_$$.gdb
echo "done"
rm "/tmp/syms_$$.gdb"