-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbloat.sh
executable file
·66 lines (49 loc) · 1.41 KB
/
bloat.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
#!/bin/bash -e
binary_or_lib="$1"
well_known_name="$(basename $binary_or_lib)"
mode="${2-syms}"
prefix="$PREFIX"
where_am_i="$(dirname $(readlink -f "$0"))"
scratchdir=/tmp/$(basename $0).$$
mkdir $scratchdir
nm -C -S -l "$binary_or_lib" > $scratchdir/nm.out
objdump -h "$binary_or_lib" > $scratchdir/objdump.out
${where_am_i}/bloat/bloat.py \
--strip-prefix="$prefix" \
--nm-output=$scratchdir/nm.out \
--objdump-output=$scratchdir/objdump.out \
"$mode" \
> $scratchdir/${well_known_name}-data.json
cat <<-EOF > $scratchdir/${well_known_name}-index.html
<!DOCTYPE html>
<title>webtreemap for ${well_known_name}</title>
<script src="${scratchdir}/${well_known_name}-data.json"></script>
<link rel=stylesheet href="${where_am_i}/webtreemap/webtreemap.css">
<style>
body {
font-family: sans-serif;
font-size: 0.8em;
margin: 2ex 4ex;
}
h1 {
font-weight: normal;
}
#map {
width: 1024px;
height: 800px;
position: relative;
cursor: pointer;
-webkit-user-select: none;
}
</style>
<h1>webtreemap for ${well_known_name}</h1>
<p>Click on a box to zoom in. Click on the outermost box to zoom out.</p>
<div id='map'></div>
<script src="${where_am_i}/webtreemap/webtreemap.js"></script>
<script>
var map = document.getElementById('map');
appendTreemap(map, kTree);
</script>
EOF
echo "Generating webpage: ${scratchdir}/${well_known_name}-index.html"
gnome-open ${scratchdir}/${well_known_name}-index.html