* [PATCH] Fix a bug in atvar_op::print: we did not output the module arg.
@ 2018-08-06 5:50 Yichun Zhang (agentzh)
2018-08-23 6:09 ` [PATCH v2] " Yichun Zhang (agentzh)
0 siblings, 1 reply; 3+ messages in thread
From: Yichun Zhang (agentzh) @ 2018-08-06 5:50 UTC (permalink / raw)
To: systemtap; +Cc: Yichun Zhang (agentzh)
This was an issue left by commit bd1fcba. My bad.
---
staptree.cxx | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/staptree.cxx b/staptree.cxx
index 8c791675d..d1193e336 100644
--- a/staptree.cxx
+++ b/staptree.cxx
@@ -520,7 +520,10 @@ void atvar_op::print (ostream& o) const
{
if (addressof)
o << "&";
- o << name << "(\"" << target_name << "\")";
+ o << name << "(\"" << target_name << "\"";
+ if (module.length() > 0)
+ o << ", " << lex_cast_qstring (module);
+ o << ')';
for (unsigned i = 0; i < components.size(); ++i)
o << components[i];
}
--
2.11.0.295.gd7dffce
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2] Fix a bug in atvar_op::print: we did not output the module arg
2018-08-06 5:50 [PATCH] Fix a bug in atvar_op::print: we did not output the module arg Yichun Zhang (agentzh)
@ 2018-08-23 6:09 ` Yichun Zhang (agentzh)
2018-08-23 20:49 ` Yichun Zhang (agentzh)
0 siblings, 1 reply; 3+ messages in thread
From: Yichun Zhang (agentzh) @ 2018-08-23 6:09 UTC (permalink / raw)
To: systemtap; +Cc: Yichun Zhang (agentzh)
This was an issue left by commit bd1fcba. My bad.
Also added some tests to cover this fix.
---
staptree.cxx | 5 +-
testsuite/systemtap.base/at_var_print.exp | 74 +++++++++++++++++++++++++++++
testsuite/systemtap.base/at_var_print_1.c | 5 ++
testsuite/systemtap.base/at_var_print_1.stp | 8 ++++
testsuite/systemtap.base/at_var_print_2.stp | 4 ++
5 files changed, 95 insertions(+), 1 deletion(-)
create mode 100644 testsuite/systemtap.base/at_var_print.exp
create mode 100644 testsuite/systemtap.base/at_var_print_1.c
create mode 100644 testsuite/systemtap.base/at_var_print_1.stp
create mode 100644 testsuite/systemtap.base/at_var_print_2.stp
diff --git a/staptree.cxx b/staptree.cxx
index 8c791675d..d1193e336 100644
--- a/staptree.cxx
+++ b/staptree.cxx
@@ -520,7 +520,10 @@ void atvar_op::print (ostream& o) const
{
if (addressof)
o << "&";
- o << name << "(\"" << target_name << "\")";
+ o << name << "(\"" << target_name << "\"";
+ if (module.length() > 0)
+ o << ", " << lex_cast_qstring (module);
+ o << ')';
for (unsigned i = 0; i < components.size(); ++i)
o << components[i];
}
diff --git a/testsuite/systemtap.base/at_var_print.exp b/testsuite/systemtap.base/at_var_print.exp
new file mode 100644
index 000000000..03c686f2f
--- /dev/null
+++ b/testsuite/systemtap.base/at_var_print.exp
@@ -0,0 +1,74 @@
+set test "at_var_print"
+set testpath "$srcdir/$subdir"
+
+# Only run on make installcheck and uprobes present.
+if {! [installtest_p]} { untested "$test"; return }
+if {! [uretprobes_p]} { untested "$test"; return }
+
+# --- TEST 1 ---
+
+set subtest1 "TEST 1: atvar_op::print() output the module arg properly."
+
+set out_pat "\\yreturn \\@var\\(\"v\", \"\[^\\n\"]+/a\\.out\"\\);"
+
+set res [target_compile ${testpath}/${test}_1.c ./a.out executable \
+ "additional_flags=-O additional_flags=-g"]
+if {$res ne ""} {
+ verbose "target_compile failed: $res" 2
+ fail "${subtest1}: unable to compile ${test}_1.c"
+} else {
+ set cmd "stap -p1 -c ./a.out '$srcdir/$subdir/${test}_1.stp'"
+ set pipe [open "| sh -c {$cmd}" r]
+ set out [read $pipe]
+ set is_err 0
+ if {[catch {close $pipe} stderr] != 0} { set is_err 1 }
+
+ if {[regexp -lineanchor -- $out_pat $out]} {
+ pass "${subtest1}: output matches \"$out_pat\""
+ } else {
+ fail "${subtest1}: output fails to match \"$out_pat\": Got \"$out\""
+ }
+
+ if {$is_err} {
+ fail "${subtest1}: exit code not zero"
+ } else {
+ pass "${subtest1}: exit code is zero"
+ }
+ if {$stderr ne ""} {
+ send_log "stderr:\n$stderr"
+ }
+}
+
+# --- TEST 2 ---
+
+set subtest2 "TEST 2: atvar_op::print() does not output the module arg if there is none"
+
+set out_pat "\\yprintln\\(\\@var\\(\"v\"\\)\\);"
+
+set res [target_compile ${testpath}/${test}_1.c ./a.out executable \
+ "additional_flags=-O additional_flags=-g"]
+if {$res ne ""} {
+ verbose "target_compile failed: $res" 2
+ fail "${subtest2}: unable to compile ${test}_1.c"
+} else {
+ set cmd "stap -p1 -c ./a.out '$srcdir/$subdir/${test}_2.stp'"
+ set pipe [open "| sh -c {$cmd}" r]
+ set out [read $pipe]
+ set is_err 0
+ if {[catch {close $pipe} stderr] != 0} { set is_err 1 }
+
+ if {[regexp -lineanchor -- $out_pat $out]} {
+ pass "${subtest2}: output matches \"$out_pat\""
+ } else {
+ fail "${subtest2}: output fails to match \"$out_pat\": Got \"$out\""
+ }
+
+ if {$is_err} {
+ fail "${subtest2}: exit code not zero"
+ } else {
+ pass "${subtest2}: exit code is zero"
+ }
+ if {$stderr ne ""} {
+ send_log "stderr:\n$stderr"
+ }
+}
diff --git a/testsuite/systemtap.base/at_var_print_1.c b/testsuite/systemtap.base/at_var_print_1.c
new file mode 100644
index 000000000..8c3b7bc46
--- /dev/null
+++ b/testsuite/systemtap.base/at_var_print_1.c
@@ -0,0 +1,5 @@
+long v = 0xbeefdead;
+
+int main(void) {
+ return 0;
+}
diff --git a/testsuite/systemtap.base/at_var_print_1.stp b/testsuite/systemtap.base/at_var_print_1.stp
new file mode 100644
index 000000000..423bd7c44
--- /dev/null
+++ b/testsuite/systemtap.base/at_var_print_1.stp
@@ -0,0 +1,8 @@
+function f() {
+ return @var("v", "$^PWD/a.out");
+}
+
+probe process.function("main") {
+ println(f());
+ exit();
+}
diff --git a/testsuite/systemtap.base/at_var_print_2.stp b/testsuite/systemtap.base/at_var_print_2.stp
new file mode 100644
index 000000000..508896770
--- /dev/null
+++ b/testsuite/systemtap.base/at_var_print_2.stp
@@ -0,0 +1,4 @@
+probe process.function("main") {
+ println(@var("v"));
+ exit();
+}
--
2.11.0.295.gd7dffce
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] Fix a bug in atvar_op::print: we did not output the module arg
2018-08-23 6:09 ` [PATCH v2] " Yichun Zhang (agentzh)
@ 2018-08-23 20:49 ` Yichun Zhang (agentzh)
0 siblings, 0 replies; 3+ messages in thread
From: Yichun Zhang (agentzh) @ 2018-08-23 20:49 UTC (permalink / raw)
To: systemtap
Hello!
On Wed, Aug 22, 2018 at 11:09 PM, Yichun Zhang (agentzh)
<agentzh@gmail.com> wrote:
> This was an issue left by commit bd1fcba. My bad.
>
> Also added some tests to cover this fix.
FYI, just committed this patch to master with the greenlight from fche.
Best,
Yichun
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-08-23 20:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-06 5:50 [PATCH] Fix a bug in atvar_op::print: we did not output the module arg Yichun Zhang (agentzh)
2018-08-23 6:09 ` [PATCH v2] " Yichun Zhang (agentzh)
2018-08-23 20:49 ` Yichun Zhang (agentzh)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).