diff options
author | Mark Wielaard <mjw@redhat.com> | 2009-12-08 03:23:20 +0100 |
---|---|---|
committer | Mark Wielaard <mjw@redhat.com> | 2009-12-08 17:27:08 +0100 |
commit | 2d971c6b8835c7e38ce78dd554827f5f96bc7c04 (patch) | |
tree | 72d06f7a1cc47b70dd149162ff3037712b3d0937 | |
parent | b2ea60606801aa9bf243f22318ac4bd8a25094fe (diff) | |
download | systemtap-steved-2d971c6b8835c7e38ce78dd554827f5f96bc7c04.tar.gz systemtap-steved-2d971c6b8835c7e38ce78dd554827f5f96bc7c04.tar.xz systemtap-steved-2d971c6b8835c7e38ce78dd554827f5f96bc7c04.zip |
Add dtrace -I support.
dtrace -I is used to pass through include paths to cpp when run.
Thanks to David Malcolm <dmalcolm@redhat.com> for python coding and testing.
* dtrace.in: Add -I support.
* testsuite/systemtap.base/dtrace.exp: Add testcases for -C -I and -G -I.
-rwxr-xr-x | dtrace.in | 15 | ||||
-rw-r--r-- | testsuite/systemtap.base/dtrace.exp | 72 |
2 files changed, 70 insertions, 17 deletions
@@ -120,13 +120,15 @@ class provider: def usage (): - print "Usage " + sys.argv[0] + " [--help] [-h | -G] -s File.d [-o File]" + print "Usage " + sys.argv[0] + " [--help] [-h | -G] [-C [-I<Path>]] -s File.d [-o <File>]" def help (): usage() print "Where -h builds a systemtap header file from the .d file" + print " -C when used with -h, also run cpp preprocessor" print " -o specifies an explicit output file name," - print " The default for -G is file.o and -h is file.h" + print " the default for -G is file.o and -h is file.h" + print " -I when running cpp pass through this -I include Path" print " -s specifies the name of the .d input file" print " -G builds a stub file.o from file.d," print " which is required by some packages that use dtrace." @@ -159,6 +161,8 @@ keep_temps = False use_cpp = False h_ext = '.h' filename = "" +s_filename = "" +includes = [] while (i < len (sys.argv)): if (sys.argv[i] == "-o"): i += 1 @@ -170,6 +174,8 @@ while (i < len (sys.argv)): use_cpp = True elif (sys.argv[i] == "-h"): build_header = True + elif (sys.argv[i].startswith("-I")): + includes.append(sys.argv[i]) elif (sys.argv[i] == "-G"): build_source = True elif (sys.argv[i] == "-k"): @@ -185,9 +191,10 @@ if (build_header == False and build_source == False): if (s_filename != "" and use_cpp): (d,fn) = mkstemp(suffix=".d") - retcode = call(["cpp", s_filename, fn]) + args = ['cpp'] + includes + [s_filename, fn] + retcode = call(args) if (retcode != 0): - print "\"cpp s_filename\" failed" + print "\"cpp includes s_filename\" failed" usage() sys.exit(1) s_filename = fn diff --git a/testsuite/systemtap.base/dtrace.exp b/testsuite/systemtap.base/dtrace.exp index f4cac5aa..f68af4f5 100644 --- a/testsuite/systemtap.base/dtrace.exp +++ b/testsuite/systemtap.base/dtrace.exp @@ -8,7 +8,7 @@ if {[installtest_p]} { set dtrace ../dtrace } -exec mkdir /tmp/dtrace +exec mkdir -p /tmp/dtrace set dpath "/tmp/dtrace/test.d" set fp [open $dpath "w"] @@ -23,11 +23,34 @@ provider tstsyscall " close $fp +exec mkdir -p /tmp/dtrace_inc +set ipath "/tmp/dtrace_inc/dtest.h" +set $fp [open $ipath "w"] +puts $fp " +#define INT16 short +#define INT32 int +" +close $fp + +set idpath "/tmp/dtrace/itest.d" +set $fp [open $idpath "w"] +puts $fp " +#include <dtest.h> + +provider tstsyscall +{ + probe test(INT16 arg1, INT32 arg2, INT32 arg3, INT32 arg4, struct astruct arg5) +} +" +close $fp + +set incpath "/tmp/dtrace_inc" + # ----------------------------------------------------------------- # test command line option and file handling verbose -log "$dtrace -G -s $dpath -o XXX.o" -exec $dtrace -G -s $dpath -o XXX.o +catch {exec $dtrace -G -s $dpath -o XXX.o} if {[file exists XXX.o]} then { pass "dtrace -G -o XXX.o" } else { @@ -36,7 +59,7 @@ if {[file exists XXX.o]} then { exec rm -f XXX.o verbose -log "$dtrace -G -s $dpath -o XXX" -exec $dtrace -G -s $dpath -o XXX +catch {exec $dtrace -G -s $dpath -o XXX} if {[file exists XXX.o]} then { pass "dtrace -G -o XXX" } else { @@ -45,7 +68,7 @@ if {[file exists XXX.o]} then { exec rm -f XXX.o verbose -log "$dtrace -h -s $dpath -o XXX.h" -exec $dtrace -h -s $dpath -o XXX.h +catch {exec $dtrace -h -s $dpath -o XXX.h} if {[file exists XXX.h]} then { pass "dtrace -h -o XXX.h" } else { @@ -54,7 +77,7 @@ if {[file exists XXX.h]} then { exec rm -f XXX.h verbose -log "$dtrace -h -s $dpath -o XXX" -exec $dtrace -h -s $dpath -o XXX +catch {exec $dtrace -h -s $dpath -o XXX} if {[file exists XXX]} then { pass "dtrace -h -o XXX" } else { @@ -63,7 +86,7 @@ if {[file exists XXX]} then { exec rm -f XXX verbose -log "$dtrace -G -s $dpath -o /tmp/XXX.o" -exec $dtrace -G -s $dpath -o /tmp/XXX.o +catch {exec $dtrace -G -s $dpath -o /tmp/XXX.o} if {[file exists /tmp/XXX.o]} then { pass "dtrace -G -o /tmp/XXX.o" } else { @@ -72,7 +95,7 @@ if {[file exists /tmp/XXX.o]} then { exec rm -f /tmp/XXX.o verbose -log "$dtrace -G -s $dpath -o /tmp/XXX" -exec $dtrace -G -s $dpath -o /tmp/XXX +catch {exec $dtrace -G -s $dpath -o /tmp/XXX} if {[file exists /tmp/XXX.o]} then { pass "dtrace -G -o /tmp/XXX.o" } else { @@ -81,7 +104,7 @@ if {[file exists /tmp/XXX.o]} then { exec rm -f /tmp/XXX.o verbose -log "$dtrace -h -s $dpath -o /tmp/XXX.h" -exec $dtrace -h -s $dpath -o /tmp/XXX.h +catch {exec $dtrace -h -s $dpath -o /tmp/XXX.h} if {[file exists /tmp/XXX.h]} then { pass "dtrace -h -o /tmp/XXX.h" } else { @@ -90,7 +113,7 @@ if {[file exists /tmp/XXX.h]} then { exec rm -f /tmp/XXX.h verbose -log "$dtrace -h -s $dpath -o /tmp/XXX" -exec $dtrace -h -s $dpath -o /tmp/XXX +catch {exec $dtrace -h -s $dpath -o /tmp/XXX} if {[file exists /tmp/XXX]} then { pass "dtrace -h -o /tmp/XXX" } else { @@ -99,7 +122,7 @@ if {[file exists /tmp/XXX]} then { exec rm -f /tmp/XXX verbose -log "$dtrace -G -s $dpath" -exec $dtrace -G -s $dpath +catch {exec $dtrace -G -s $dpath} if {[file exists test.o]} then { pass "dtrace -G" } else { @@ -108,7 +131,7 @@ if {[file exists test.o]} then { exec rm -f test.o verbose -log "$dtrace -h -s $dpath" -exec $dtrace -h -s $dpath +catch {exec $dtrace -h -s $dpath} if {[file exists test.h]} then { pass "dtrace -h" } else { @@ -118,7 +141,7 @@ exec rm -f test.o set ok 0 verbose -log "$dtrace -C -h -s $dpath -o XXX.h" -exec $dtrace -C -h -s $dpath -o XXX.h +catch {exec $dtrace -C -h -s $dpath -o XXX.h} spawn cat XXX.h expect { "short arg1, int arg2, int arg3, int arg4" {incr ok} @@ -130,5 +153,28 @@ if { $ok != 0} { } exec rm -f XXX.h -exec /bin/rm -r /tmp/dtrace +set ok 0 +verbose -log "$dtrace -C -I$incpath -h -s $idpath -o XXX.h" +catch {exec $dtrace -C -I$incpath -h -s $idpath -o XXX.h} +spawn cat XXX.h +expect { + "short arg1, int arg2, int arg3, int arg4" {incr ok} +} +if { $ok != 0} { + pass "dtrace -C -Iincpath -h -o XXX.h" +} else { + fail "dtrace -C -Iincpath -h -o XXX.h" +} +exec rm -f XXX.h + +verbose -log "$dtrace -I$incpath -G -s $idpath" +catch {exec $dtrace -G -s $dpath} +if {[file exists test.o]} then { + pass "dtrace -Iincpath -G" +} else { + fail "dtrace -Iincpath -G" +} +exec rm -f test.o + +exec /bin/rm -r /tmp/dtrace /tmp/dtrace_inc # ----------------------------------------------------------------- |