1 From c486eff3f809b5ce544d5a032198e7680f2b7f2b Mon Sep 17 00:00:00 2001
2 From: Stan Cox <scox@redhat.com>
3 Date: Tue, 9 Sep 2014 15:07:44 -0400
4 Subject: [PATCH 1/3] Add -fpic -fPIC to the list of accepted but ignored
7 * dtrace.in (main): Add ignore_options.
10 testsuite/systemtap.base/dtrace.exp | 8 ++++----
11 2 files changed, 7 insertions(+), 5 deletions(-)
13 diff --git a/dtrace.in b/dtrace.in
14 index d5f189d4fc9e..2f9fb6307e28 100644
17 @@ -305,6 +305,8 @@ def main():
21 + ignore_options = ["-64", "-32", "-fpic", "-fPIC"]
23 while i < len(sys.argv):
24 if sys.argv[i] == "-o":
26 @@ -330,7 +332,7 @@ def main():
28 elif sys.argv[i] == "--types":
29 print sys.argv[0] + ": note: obsolete option --types used"
30 - elif sys.argv[i] == "-64" or sys.argv[i] == "-32":
31 + elif sys.argv[i] in ignore_options:
32 pass # dtrace users sometimes pass these flags
33 elif sys.argv[i] == "--help":
35 diff --git a/testsuite/systemtap.base/dtrace.exp b/testsuite/systemtap.base/dtrace.exp
36 index 252dad90ede5..e029748100d6 100644
37 --- a/testsuite/systemtap.base/dtrace.exp
38 +++ b/testsuite/systemtap.base/dtrace.exp
39 @@ -53,12 +53,12 @@ set incpath "/tmp/dtrace_inc"
40 # -----------------------------------------------------------------
41 # test command line option and file handling
43 -verbose -log "$dtrace -G -s $dpath -o XXX.o"
44 -catch {exec $dtrace -G -s $dpath -o XXX.o}
45 +verbose -log "$dtrace -G -64 -fPIC -s $dpath -o XXX.o"
46 +catch {exec $dtrace -G -64 -fPIC -s $dpath -o XXX.o}
47 if {[file exists XXX.o]} then {
48 - pass "dtrace -G -o XXX.o"
49 + pass "dtrace -G -64 -fPIC -o XXX.o"
51 - fail "dtrace -G -o XXX.o"
52 + fail "dtrace -G -64 -fPIC -o XXX.o"
60 From 52cac9d8159a399b824201f4d2c98abe89a01767 Mon Sep 17 00:00:00 2001
61 From: Stan Cox <scox@redhat.com>
62 Date: Tue, 23 Sep 2014 13:42:54 -0400
63 Subject: [PATCH 2/3] Ignore C declarations in .d file and use string pattern
64 matching as a fallback mechanism.
66 * dtrace.in (_PypProvider): SkipTo the provider{...}
67 (main): If pyparsing fails, then fallback to pattern matching.
69 * dtrace.exp: Add a fallback test.
71 dtrace.in | 39 +++++++++++++++++++++++++++---------
72 testsuite/systemtap.base/dtrace.exp | 40 +++++++++++++++++++++++++++++++++++++
73 2 files changed, 70 insertions(+), 9 deletions(-)
75 diff --git a/dtrace.in b/dtrace.in
76 index 2f9fb6307e28..04ace92181d9 100644
79 @@ -29,13 +29,13 @@ try:
80 from pyparsing import alphas, cStyleComment, delimitedList, Group, \
81 Keyword, lineno, Literal, nestedExpr, nums, oneOf, OneOrMore, \
82 Optional, ParseException, ParserElement, restOfLine, restOfLine, \
83 - Suppress, Word, ZeroOrMore
84 + Suppress, SkipTo, Word, ZeroOrMore
90 -# Common file creation methods for pyparsing and regexparsing
91 +# Common file creation methods for pyparsing and string pattern matching
93 class _HeaderCreator(object):
94 def init_semaphores(self, fdesc):
95 @@ -149,7 +149,7 @@ class _PypProvider(_HeaderCreator):
97 provider_decl = (PROVIDER + Optional(ident)
98 + lbrace + Group(probe_decls) + rbrace + Optional(semi))
99 - dtrace_statement = Group(decls | provider_decl)
100 + dtrace_statement = Group (SkipTo("provider", include=False) + provider_decl)
101 self.dtrace_statements = ZeroOrMore(dtrace_statement)
103 cplusplus_linecomment = Literal("//") + restOfLine
104 @@ -167,7 +167,10 @@ class _PypProvider(_HeaderCreator):
105 for asti in self.ast:
108 - elif asti[0] == "provider":
109 + # ignore SkipTo token
110 + if asti[0] != "provider":
112 + if asti[0] == "provider":
115 semaphores_def += self.add_semaphore(asti[1], prb[1])
116 @@ -186,15 +189,18 @@ class _PypProvider(_HeaderCreator):
117 self.ast = self.bnf.parseFile(provider).asList()
118 except ParseException, err:
119 if len(self.current_probe):
120 - print "%s:%s:%d: syntax error near:\nprobe %s\n" % (sys.argv[0],provider, self.current_lineno, self.current_probe)
121 + print "Warning: %s:%s:%d: syntax error near:\nprobe %s\n" % (sys.argv[0],provider, self.current_lineno, self.current_probe)
123 - print "%s:%s:%d syntax error near:\n%s\n" % (sys.argv[0],provider,err.lineno, err.line)
125 + print "Warning: %s:%s:%d syntax error near:\n%s\n" % (sys.argv[0],provider,err.lineno, err.line)
126 + raise ParseException, err
129 for asti in self.ast:
132 + # ignore SkipTo token
133 + if asti[0] != "provider":
135 if asti[0] == "provider":
138 @@ -369,14 +375,29 @@ def main():
139 providers = _PypProvider()
141 providers = _ReProvider()
142 - providers.probe_write(s_filename, filename + suffix)
145 + providers.probe_write(s_filename, filename + suffix)
147 + # complex C declarations can fool the pyparsing grammar.
148 + # we could increase the complexity of the grammar
149 + # instead we fall back to string pattern matching
150 + except ParseException, err:
151 + print "Warning: Proceeding as if --no-pyparsing was given.\n"
152 + providers = _ReProvider()
155 providers = _PypProvider()
157 providers = _ReProvider()
158 (ignore, fname) = mkstemp(suffix=".h")
159 - providers.probe_write(s_filename, fname)
162 + providers.probe_write(s_filename, fname)
164 + except ParseException, err:
165 + print "Warning: Proceeding as if --no-pyparsing was given.\n"
166 + providers = _ReProvider()
170 diff --git a/testsuite/systemtap.base/dtrace.exp b/testsuite/systemtap.base/dtrace.exp
171 index e029748100d6..60cab3f5abf2 100644
172 --- a/testsuite/systemtap.base/dtrace.exp
173 +++ b/testsuite/systemtap.base/dtrace.exp
174 @@ -207,6 +207,46 @@ if { $ok == 4} {
179 +set pypath "/tmp/pypath.d"
180 +set $fp [open $pypath "w"]
182 +#include <sys/types.h>
185 + probe request__start(string, uint8_t, uint16_t, int, void *);
186 + probe request__one(string, uint8_t, uint32_t, int, int);
187 + probe client__two(int, int);
188 + probe client__three(int, string, pid_t, zoneid_t);
189 + probe input__stop(int, int, uint32_t, uint32_t, int8_t, uint8_t*, double*);
192 +#ifdef DCL_AFTER_PROVIDER
193 +typedef unsigned short int __u_short;
194 +typedef const static unsigned short __u_c_short;
197 +#pragma D attributes Unknown provider alpha provider
200 +verbose -log "$dtrace -C -h -s $pypath -o XXX.h"
201 +spawn $dtrace -C -DDCL_AFTER_PROVIDER -h -s $pypath -o XXX.h
203 + -re {Warning.*syntax error} {incr ok; exp_continue}
204 + -re {Warning.*--no-pyparsing} {incr ok; exp_continue}
207 +catch {close}; catch {wait}
208 +if {[file exists XXX.h]} then {
212 + pass "dtrace parser check"
214 + fail "dtrace parser check $ok"
218 verbose -log "$dtrace -I$incpath -G -s $idpath"
219 catch {exec $dtrace -G -s $dpath}
220 if {[file exists test.o]} then {
225 From 3525152408f15e23dcffe2371bbd575f1646d691 Mon Sep 17 00:00:00 2001
226 From: Stan Cox <scox@redhat.com>
227 Date: Thu, 25 Sep 2014 13:47:04 -0400
228 Subject: [PATCH 3/3] Add pyparsing / no-parsing compatibility test.
230 * dtrace.exp: Add pyparsing compatibility test.
232 testsuite/systemtap.base/dtrace.exp | 93 ++++++++++++++++++++++++++++---------
233 1 file changed, 72 insertions(+), 21 deletions(-)
235 diff --git a/testsuite/systemtap.base/dtrace.exp b/testsuite/systemtap.base/dtrace.exp
236 index 60cab3f5abf2..e455c298737a 100644
237 --- a/testsuite/systemtap.base/dtrace.exp
238 +++ b/testsuite/systemtap.base/dtrace.exp
239 @@ -8,6 +8,8 @@ if {[installtest_p]} {
243 +# Create the test .d files
245 exec mkdir -p /tmp/dtrace
247 set dpath "/tmp/dtrace/test.d"
248 @@ -48,6 +50,29 @@ provider tstsyscall
252 +set pypath "/tmp/pypath.d"
253 +set $fp [open $pypath "w"]
255 +#include <sys/types.h>
258 + probe request__start(string, uint8_t, uint16_t, int, void *);
259 + probe request__one(string, uint8_t, uint32_t, int, int);
260 + probe client__two(int, int);
261 + probe client__three(int, string, pid_t, zoneid_t);
262 + probe input__stop(int, int, uint32_t, uint32_t, int8_t, uint8_t*, double*);
265 +#ifdef DCL_AFTER_PROVIDER
266 +typedef unsigned short int __u_short;
267 +typedef const static unsigned short __u_c_short;
270 +#pragma D attributes Unknown provider alpha provider
275 set incpath "/tmp/dtrace_inc"
277 # -----------------------------------------------------------------
278 @@ -156,6 +181,9 @@ if { $ok != 0} {
279 fail "dtrace CFLAGS= CC="
282 +# -----------------------------------------------------------------
283 +# test -h header file creation
286 verbose -log "$dtrace -C -h -s $dpath -o XXX.h"
287 catch {exec $dtrace -C -h -s $dpath -o XXX.h}
288 @@ -189,6 +217,9 @@ if { $ok == 4} {
292 +# -----------------------------------------------------------------
293 +# test --no-pyparsing
296 verbose -log "$dtrace -C --no-pyparsing -I$incpath -h -s $idpath -o XXX.h"
297 catch {exec $dtrace -C --no-pyparsing -I$incpath -h -s $idpath -o XXX.h}
298 @@ -207,28 +238,10 @@ if { $ok == 4} {
303 -set pypath "/tmp/pypath.d"
304 -set $fp [open $pypath "w"]
306 -#include <sys/types.h>
309 - probe request__start(string, uint8_t, uint16_t, int, void *);
310 - probe request__one(string, uint8_t, uint32_t, int, int);
311 - probe client__two(int, int);
312 - probe client__three(int, string, pid_t, zoneid_t);
313 - probe input__stop(int, int, uint32_t, uint32_t, int8_t, uint8_t*, double*);
316 -#ifdef DCL_AFTER_PROVIDER
317 -typedef unsigned short int __u_short;
318 -typedef const static unsigned short __u_c_short;
320 +# -----------------------------------------------------------------
321 +# test fallback to --no-pyparsing
323 -#pragma D attributes Unknown provider alpha provider
327 verbose -log "$dtrace -C -h -s $pypath -o XXX.h"
328 spawn $dtrace -C -DDCL_AFTER_PROVIDER -h -s $pypath -o XXX.h
330 @@ -247,6 +260,9 @@ if { $ok == 3} {
334 +# -----------------------------------------------------------------
335 +# test -G object file creation
337 verbose -log "$dtrace -I$incpath -G -s $idpath"
338 catch {exec $dtrace -G -s $dpath}
339 if {[file exists test.o]} then {
340 @@ -256,5 +272,40 @@ if {[file exists test.o]} then {
344 +# -----------------------------------------------------------------
345 +# test dtrace for pyparsing / --no-pyparsing compatibility
350 + verbose -log "$dtrace $srcdir/$subdir/$i.d"
351 + catch {exec $dtrace -C -h -s $srcdir/$subdir/$i.d -o $i-1.h}
352 + catch {exec $dtrace -C -h --no-pyparsing -s $srcdir/$subdir/$i.d -o $i-2.h}
353 + spawn diff -wqs $i-1.h $i-2.h
355 + -re {Files.*identical} {incr ok; exp_continue}
358 + catch {exec $dtrace -C -G -s $srcdir/$subdir/$i.d -o $i-1.o}
359 + catch {exec $dtrace -C -G --no-pyparsing -s $srcdir/$subdir/$i.d -o $i-2.o}
360 + verbose -log "exec nm $i-1.o > $i-1.od"
361 + catch {exec nm $i-1.o > $i-1.od}
362 + catch {exec nm $i-2.o > $i-2.od}
363 + spawn diff -qs $i-1.od $i-2.od
365 + -re {Files.*identical} {incr ok; exp_continue}
368 + catch {exec /bin/rm $i-1.h $i-2.h $i-1.o $i-2.o}
371 + pass "dtrace known uses"
373 + fail "dtrace known uses ${ok}"
376 +# -----------------------------------------------------------------
379 exec /bin/rm -r /tmp/dtrace /tmp/dtrace_inc
380 # -----------------------------------------------------------------