From 764b562f42c6ac7f02e0911cab47f87c827bf3bd Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Mon, 20 Apr 2009 12:56:51 +0200 Subject: fix a bug with %% in format strings * translate.cxx (c_unparser::visit_print_format): Always use _stp_printf if a format string contains "%%". Previously a format string with no arguments would always be printed with _stp_print. * testsuite/systemtap.printf/basic6.stp: New test for %% in format strings. * testsuite/systemtap.printf/basic6.exp: test driver * testsuite/systemtap.examples/grapher.stp: Remove workaround for "%%" literal problem. --- testsuite/systemtap.printf/basic6.exp | 3 +++ testsuite/systemtap.printf/basic6.stp | 5 +++++ 2 files changed, 8 insertions(+) create mode 100644 testsuite/systemtap.printf/basic6.exp create mode 100644 testsuite/systemtap.printf/basic6.stp (limited to 'testsuite/systemtap.printf') diff --git a/testsuite/systemtap.printf/basic6.exp b/testsuite/systemtap.printf/basic6.exp new file mode 100644 index 00000000..72bf8f57 --- /dev/null +++ b/testsuite/systemtap.printf/basic6.exp @@ -0,0 +1,3 @@ +set test "basic6" +set ::result_string {Hello%World} +stap_run2 $srcdir/$subdir/$test.stp diff --git a/testsuite/systemtap.printf/basic6.stp b/testsuite/systemtap.printf/basic6.stp new file mode 100644 index 00000000..69721188 --- /dev/null +++ b/testsuite/systemtap.printf/basic6.stp @@ -0,0 +1,5 @@ +probe begin +{ + printf("Hello%%World"); + exit() +} -- cgit From 40fc3e43cea224623400ac07b6f03c700d209dec Mon Sep 17 00:00:00 2001 From: Wenji Huang Date: Mon, 27 Apr 2009 04:34:42 -0400 Subject: Add function of returning the char in given position of string * tapset/string.stp: New function stringat. * testsuite/systemtap.printf/char1.exp: Update test case. * testsuite/systemtap.printf/char1.stp: Ditto. --- testsuite/systemtap.printf/char1.exp | 2 +- testsuite/systemtap.printf/char1.stp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'testsuite/systemtap.printf') diff --git a/testsuite/systemtap.printf/char1.exp b/testsuite/systemtap.printf/char1.exp index 35aa479f..f9343c0e 100644 --- a/testsuite/systemtap.printf/char1.exp +++ b/testsuite/systemtap.printf/char1.exp @@ -1,3 +1,3 @@ set test "char1" -set ::result_string {stap} +set ::result_string {stapok} stap_run2 $srcdir/$subdir/$test.stp diff --git a/testsuite/systemtap.printf/char1.stp b/testsuite/systemtap.printf/char1.stp index 207d1bc5..564c416b 100644 --- a/testsuite/systemtap.printf/char1.stp +++ b/testsuite/systemtap.printf/char1.stp @@ -3,6 +3,7 @@ probe begin printf("%c", 115) printf("%c", 116) printf("%c%c", 97, 112) + printf("%c%c", stringat("ok", 0), stringat("ok", 1)) print("\n") exit() } -- cgit From c4f51a54acff992cf19902ffd56e8338158c5811 Mon Sep 17 00:00:00 2001 From: Wenji Huang Date: Mon, 27 Apr 2009 05:38:18 -0400 Subject: PR10099: Extend %M directive to support hexdumping large buffers This patch will make %M directive dump the variable width buffer in hex format instead of returning uint64_t number as before. * runtime/vsprintf.c: Modify %M directive. * stap.1.in: Update description. * testsuite/systemtap.printf/memory1.stp: Add test case. --- testsuite/systemtap.printf/memory1.stp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'testsuite/systemtap.printf') diff --git a/testsuite/systemtap.printf/memory1.stp b/testsuite/systemtap.printf/memory1.stp index f9cbf60b..15aa565b 100644 --- a/testsuite/systemtap.printf/memory1.stp +++ b/testsuite/systemtap.printf/memory1.stp @@ -113,6 +113,20 @@ probe syscall.open { success = 0; } + expected_16_actual = sprintf (" %02x%02x%02x%02x%02x%02x", + stringat(filename, 0), + stringat(filename, 1), + stringat(filename, 2), + stringat(filename, 3), + stringat(filename, 4), + stringat(filename, 5)); + testName = "%M dynamic width larger than dynamic precision"; + result = sprintf ("%*.*M", 14, 6, $filename); + if (result != expected_16_actual) { + printf ("Test %s failed\n", testName); + success = 0; + } + if (success) print ("Test passed\n"); -- cgit From 9f27bd8143604a815b11b48ca054e03f78bdf69e Mon Sep 17 00:00:00 2001 From: Eugeniy Meshcheryakov Date: Tue, 5 May 2009 21:27:10 +0200 Subject: Fix arguments to mktemp with less than 6 X's --- testsuite/systemtap.printf/end1.exp | 2 +- testsuite/systemtap.printf/end1b.exp | 2 +- testsuite/systemtap.printf/mixed_out.exp | 2 +- testsuite/systemtap.printf/mixed_outb.exp | 2 +- testsuite/systemtap.printf/out1.exp | 2 +- testsuite/systemtap.printf/out1b.exp | 2 +- testsuite/systemtap.printf/out2.exp | 2 +- testsuite/systemtap.printf/out2b.exp | 2 +- testsuite/systemtap.printf/out3.exp | 2 +- testsuite/systemtap.printf/out3b.exp | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) (limited to 'testsuite/systemtap.printf') diff --git a/testsuite/systemtap.printf/end1.exp b/testsuite/systemtap.printf/end1.exp index 0a4dd32e..590340d3 100644 --- a/testsuite/systemtap.printf/end1.exp +++ b/testsuite/systemtap.printf/end1.exp @@ -4,7 +4,7 @@ set TEST_NAME "$subdir/$test" if {![installtest_p]} { untested $TEST_NAME; return } -if {[catch {exec mktemp -t staptestXXXXX} tmpfile]} { +if {[catch {exec mktemp -t staptestXXXXXX} tmpfile]} { puts stderr "Failed to create temporary file: $tmpfile" untested $TEST_NAME return diff --git a/testsuite/systemtap.printf/end1b.exp b/testsuite/systemtap.printf/end1b.exp index 1764a383..bea5736e 100644 --- a/testsuite/systemtap.printf/end1b.exp +++ b/testsuite/systemtap.printf/end1b.exp @@ -9,7 +9,7 @@ if (![file executable $stap_merge_path]) { return } -if {[catch {exec mktemp -t staptestXXXXX} tmpfile]} { +if {[catch {exec mktemp -t staptestXXXXXX} tmpfile]} { puts stderr "Failed to create temporary file: $tmpfile" untested "$TEST_NAME : failed to create temporary file" return diff --git a/testsuite/systemtap.printf/mixed_out.exp b/testsuite/systemtap.printf/mixed_out.exp index 093a8ca1..3b66e7c0 100644 --- a/testsuite/systemtap.printf/mixed_out.exp +++ b/testsuite/systemtap.printf/mixed_out.exp @@ -4,7 +4,7 @@ set TEST_NAME "$subdir/$test" if {![installtest_p]} { untested $TEST_NAME; return } -if {[catch {exec mktemp -t staptestXXXXX} tmpfile]} { +if {[catch {exec mktemp -t staptestXXXXXX} tmpfile]} { puts stderr "Failed to create temporary file: $tmpfile" untested $TEST_NAME return diff --git a/testsuite/systemtap.printf/mixed_outb.exp b/testsuite/systemtap.printf/mixed_outb.exp index cbf7b920..db82cc79 100644 --- a/testsuite/systemtap.printf/mixed_outb.exp +++ b/testsuite/systemtap.printf/mixed_outb.exp @@ -9,7 +9,7 @@ if (![file executable $stap_merge_path]) { return } -if {[catch {exec mktemp -t staptestXXXXX} tmpfile]} { +if {[catch {exec mktemp -t staptestXXXXXX} tmpfile]} { puts stderr "Failed to create temporary file: $tmpfile" untested "$TEST_NAME : failed to create temporary file" return diff --git a/testsuite/systemtap.printf/out1.exp b/testsuite/systemtap.printf/out1.exp index f89d39bf..7577a54d 100644 --- a/testsuite/systemtap.printf/out1.exp +++ b/testsuite/systemtap.printf/out1.exp @@ -4,7 +4,7 @@ set TEST_NAME "$subdir/$test" if {![installtest_p]} { untested $TEST_NAME; return } -if {[catch {exec mktemp -t staptestXXXXX} tmpfile]} { +if {[catch {exec mktemp -t staptestXXXXXX} tmpfile]} { puts stderr "Failed to create temporary file: $tmpfile" untested $TEST_NAME return diff --git a/testsuite/systemtap.printf/out1b.exp b/testsuite/systemtap.printf/out1b.exp index 378ea5cd..c3e21ba9 100644 --- a/testsuite/systemtap.printf/out1b.exp +++ b/testsuite/systemtap.printf/out1b.exp @@ -9,7 +9,7 @@ if (![file executable $stap_merge_path]) { return } -if {[catch {exec mktemp -t staptestXXXXX} tmpfile]} { +if {[catch {exec mktemp -t staptestXXXXXX} tmpfile]} { puts stderr "Failed to create temporary file: $tmpfile" untested "$TEST_NAME : failed to create temporary file" return diff --git a/testsuite/systemtap.printf/out2.exp b/testsuite/systemtap.printf/out2.exp index 7b312b11..ce1f7c6e 100644 --- a/testsuite/systemtap.printf/out2.exp +++ b/testsuite/systemtap.printf/out2.exp @@ -4,7 +4,7 @@ set TEST_NAME "$subdir/$test" if {![installtest_p]} { untested $TEST_NAME; return } -if {[catch {exec mktemp -t staptestXXXXX} tmpfile]} { +if {[catch {exec mktemp -t staptestXXXXXX} tmpfile]} { puts stderr "Failed to create temporary file: $tmpfile" untested $TEST_NAME return diff --git a/testsuite/systemtap.printf/out2b.exp b/testsuite/systemtap.printf/out2b.exp index f7fdef6b..fcc12f63 100644 --- a/testsuite/systemtap.printf/out2b.exp +++ b/testsuite/systemtap.printf/out2b.exp @@ -9,7 +9,7 @@ if (![file executable $stap_merge_path]) { return } -if {[catch {exec mktemp -t staptestXXXXX} tmpfile]} { +if {[catch {exec mktemp -t staptestXXXXXX} tmpfile]} { puts stderr "Failed to create temporary file: $tmpfile" untested "$TEST_NAME : failed to create temporary file" return diff --git a/testsuite/systemtap.printf/out3.exp b/testsuite/systemtap.printf/out3.exp index c16db391..51124757 100644 --- a/testsuite/systemtap.printf/out3.exp +++ b/testsuite/systemtap.printf/out3.exp @@ -4,7 +4,7 @@ set TEST_NAME "$subdir/$test" if {![installtest_p]} { untested $TEST_NAME; return } -if {[catch {exec mktemp -t staptestXXXXX} tmpfile]} { +if {[catch {exec mktemp -t staptestXXXXXX} tmpfile]} { puts stderr "Failed to create temporary file: $tmpfile" untested $TEST_NAME return diff --git a/testsuite/systemtap.printf/out3b.exp b/testsuite/systemtap.printf/out3b.exp index 16ee2182..740a8b68 100644 --- a/testsuite/systemtap.printf/out3b.exp +++ b/testsuite/systemtap.printf/out3b.exp @@ -9,7 +9,7 @@ if (![file executable $stap_merge_path]) { return } -if {[catch {exec mktemp -t staptestXXXXX} tmpfile]} { +if {[catch {exec mktemp -t staptestXXXXXX} tmpfile]} { puts stderr "Failed to create temporary file: $tmpfile" untested "$TEST_NAME : failed to create temporary file" return -- cgit