Newer
Older
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#!/bin/bash
if [ "$#" -ne 2 ]; then
echo "Usage: ${0} /path/to/pdf /path/to/libhammer.so"
echo "WARNING: For now, parameters are passed unchecked to perf probe"
exit 1
fi
PDFPATH=$1
HAMMERPATH=$2
perf probe -x $PDFPATH pdf.c:1223 'pdf tail xr_td dict dict_ dopen body header objdef indobj obj array array_ lbrack rbrack elemd elemd_ elemr elemr_ robj dobj name npair string hexstr rangle langle litstr stream xrstm xstream xrefs xrsub xrhead xrent xrgen xroff a85string ahexstream k_v'
perf probe -x $HAMMERPATH h_arena_malloc_raw '$params'
perf probe -x $PDFPATH init_runlengthdecode_parser '$vars'
perf probe -x $PDFPATH kstream '$params'
perf probe -x $PDFPATH kxstream '$params'
perf probe -x $PDFPATH FlateDecode '$params'
perf probe -x $PDFPATH LZWDecode '$params'
perf probe -x $PDFPATH RunLengthDecode '$params'
perf probe -x $PDFPATH ASCII85Decode '$params'
perf probe -x $PDFPATH ASCIIHexDecode '$params'
# virtual functions to be called by h_parse
# parse_choice (tracepoint inside loop)
# originally we'd have pushed/popped parsers here in the processing script, but you can't use locals in an array subscript at tracepoint definition
perf probe -x $HAMMERPATH choice.c:28 '$params' 's' 'i' 's->p_array'
# perf probe -n -x $HAMMERPATH choice.c:28 '$params' 's' 'i' 's->p_array + i * 8'
# parse_sequence
#perf probe -x $HAMMERPATH sequence.c:16 '$params' 's' 'i' 's->p_array'
perf probe -x $HAMMERPATH parse_sequence '$params' 's' 's->p_array'
#perf probe -n -x $HAMMERPATH sequence.c:16 '$params' 's' 'i' 's->p_array'
# parse_difference
# HTwoParsers
perf probe -x $HAMMERPATH difference.c:14 '$params' 'parsers' 'parsers->p1' 'parsers->p2'
# parse_many
# HRepeat
perf probe -x $HAMMERPATH many.c:16 '$params' 'env_' 'env_->p' 'env_->sep' 'env_->count'
# parse_action
# not sure what to do with this
perf probe -x $HAMMERPATH action.c:15 '$params' 'a' 'a->p' 'a->action'
# env is just the HParser with this. we probably want to see them in the trace buta we don't care about the parameters
# env is again the HParser
perf probe -x $HAMMERPATH parse_and '$params'
# TODO: parse_attr_bool
perf probe -x $HAMMERPATH parse_attr_bool '$params'
# parse_bind
# BindEnv
perf probe -x $HAMMERPATH bind.c:34 '$params' 'be->p' 'be->k'
perf probe -x $HAMMERPATH parse_bits '$params'
# parse_butnot
# HTwoParsers
perf probe -x $HAMMERPATH butnot.c:12 '$params' 'parsers' 'parsers->p1' 'parsers->p2'
# HCharset is just an int
perf probe -x $HAMMERPATH parse_charset '$params'
# parse_ch
# env is uintptr_t
perf probe -x $HAMMERPATH ch.c:8 '$params' 'c'
# parse_end
# we don't care about the parameters here either
perf probe -x $HAMMERPATH parse_end '$params'
# parse_endianness
# HParseEndianness
perf probe -x $HAMMERPATH endianness.c:22 '$params' 'e->endianness'
# parse_epsilon
perf probe -x $HAMMERPATH parse_epsilon '$params'
# parse_ignore
perf probe -x $HAMMERPATH parse_ignore '$params'
# parse_ignoreseq
# TODO: HParseIgnoreSeq locals
perf probe -x $HAMMERPATH parse_ignoreseq '$params'
# parse_indirect
# env is HParseIndirectEnv, but since it's never cast and saved as a local, can't really capture env->parser
perf probe -x $HAMMERPATH parse_indirect '$params'
# parse_int_range
# HRange
perf probe -x $HAMMERPATH int_range.c:12 '$params' 'r_env->p' 'r_env->lower' 'r_env->upper'
# parse_not
# HParser
perf probe -x $HAMMERPATH parse_not '$params'
perf probe -x $HAMMERPATH parse_nothing '$params'
perf probe -x $HAMMERPATH parse_optional '$params'
# HSequence
perf probe -x $HAMMERPATH permutation.c:76 '$params' 's' 's_len=s->len' 's->p_array'
# parse_skip
# size_t
perf probe -x $HAMMERPATH seek.c:12 '$params' 'n'
# parse_seek
# HSeek (TODO)
perf probe -x $HAMMERPATH seek.c:19 '$params' 's'
# parse_tell
perf probe -x $HAMMERPATH parse_tell '$params'
# parse_token
# HToken (TODO)
perf probe -x $HAMMERPATH parse_token '$params'
perf probe -x $HAMMERPATH parse_unimplemented '$params'
perf probe -x $HAMMERPATH parse_put '$params'
perf probe -x $HAMMERPATH parse_get '$params'
perf probe -x $HAMMERPATH parse_whitespace '$params'
# parse_xor
# HTwoParsers
perf probe -x $HAMMERPATH xor.c:12 '$params' 'parsers' 'parsers->p1' 'parsers->p2'
# Packrat backend
perf probe -x $HAMMERPATH h_do_parse '$params' 'state->arena:x'
perf probe -x $HAMMERPATH perform_lowlevel_parse '$params' 'state->arena:x' 'parser->env:x'
#perf probe -x $HAMMERPATH recall '$params' 'k->parser'
perf probe -x $HAMMERPATH h_packrat_parse '$params'
# return tracepoints don't play well with locals, so $params is superfluous here
# the values you get may or may not be bogus
#perf probe -x $HAMMERPATH h_do_parse%return '$params' '$retval'
perf probe -x $HAMMERPATH perform_lowlevel_parse%return '$retval'
#perf probe -x $HAMMERPATH recall%return '$retval'
perf probe -x $HAMMERPATH h_packrat_parse%return '$retval'
#perf probe -x $HAMMERPATH parse_choice%return
#perf probe -x $HAMMERPATH parse_sequence%return
#perf probe -x $HAMMERPATH parse_difference%return
#perf probe -x $HAMMERPATH parse_many%return
#perf probe -x $HAMMERPATH parse_action%return
#perf probe -x $HAMMERPATH parse_and%return
#perf probe -x $HAMMERPATH parse_attr_bool%return
#perf probe -x $HAMMERPATH parse_bind%return
#perf probe -x $HAMMERPATH parse_bits%return
#perf probe -x $HAMMERPATH parse_butnot%return
#perf probe -x $HAMMERPATH parse_charset%return
#perf probe -x $HAMMERPATH parse_ch%return
#perf probe -x $HAMMERPATH parse_end%return
#perf probe -x $HAMMERPATH parse_endianness%return
#perf probe -x $HAMMERPATH parse_epsilon%return
#perf probe -x $HAMMERPATH parse_ignore%return
#perf probe -x $HAMMERPATH parse_ignoreseq%return
#perf probe -x $HAMMERPATH parse_indirect%return
#perf probe -x $HAMMERPATH parse_int_range%return
#perf probe -x $HAMMERPATH parse_not%return
#perf probe -x $HAMMERPATH parse_nothing%return
#perf probe -x $HAMMERPATH parse_optional%return
#perf probe -x $HAMMERPATH parse_permutation%return
#perf probe -x $HAMMERPATH parse_skip%return
#perf probe -x $HAMMERPATH parse_seek%return
#perf probe -x $HAMMERPATH parse_tell%return
#perf probe -x $HAMMERPATH parse_token%return
#perf probe -x $HAMMERPATH parse_unimplemented%return
#perf probe -x $HAMMERPATH parse_put%return
#perf probe -x $HAMMERPATH parse_get%return
#perf probe -x $HAMMERPATH parse_whitespace%return
#perf probe -x $HAMMERPATH parse_xor%return