-
Notifications
You must be signed in to change notification settings - Fork 18
/
dumpjsobjects
executable file
·45 lines (36 loc) · 992 Bytes
/
dumpjsobjects
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
#!/bin/bash
#
# dumpjsobjects CORE_FILE DMOD_FILE OBJ_LIST OBJ_CONTENTS
#
# Dump all JavaScript objects in CORE_FILE using mdb_v8 binary DMOD_FILE. The
# sorted list of all objects is stored into the file OBJ_LIST and the contents
# of all objects is stored into the file OBJ_CONTENTS.
#
set -o pipefail
function usage
{
cat <<EOF >&2
usage: dumpjsobjects CORE_FILE DMOD_FILE OBJ_LIST OBJ_CONTENTS
Dump all JavaScript objects in CORE_FILE using mdb_v8 binary DMOD_FILE. The
sorted list of all objects is stored into the file OBJ_LIST and the contents of
all objects is stored into the file OBJ_CONTENTS.
EOF
exit 2
}
function main
{
local listcmd printcmd
if [[ $# != 4 ]]; then
usage
fi
listcmd="::findjsobjects -l | ::findjsobjects ! sort > $3"
printcmd="::cat $3 | ::jsprint -a -d 2 -N 0t100 ! cat > $4"
set -o xtrace
if ! mdb -e "::load $2; $listcmd" "$1" ||
! mdb -e "::load $2; $printcmd" "$1"; then
echo "FAILED." >&2
exit 1
fi
echo "done."
}
main "$@"