This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
[PATCH] Fix print_char() bug on translate to C
- From: Zhaolei <zhaolei at cn dot fujitsu dot com>
- To: "systemtap at sourceware dot org" <systemtap at sourceware dot org>
- Date: Fri, 06 Feb 2009 17:08:21 +0800
- Subject: [PATCH] Fix print_char() bug on translate to C
When we run:
stap -e 'probe begin {print_char("a")}'
stap failed on:
Pass 4: compilation failed. Try again with another '--vp 0001' option.
It is because we can't give char* argument to _stp_print_char() function.
This can be fixed by this patch.
Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
---
translate.cxx | 21 ++++++++++++++++++---
1 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/translate.cxx b/translate.cxx
index 0d430ea..136983d 100644
--- a/translate.cxx
+++ b/translate.cxx
@@ -4200,14 +4200,29 @@ c_unparser::visit_print_format (print_format* e)
}
if (e->print_to_stream)
- {
+ {
if (e->print_char)
{
o->newline() << "_stp_print_char (";
if (tmp.size())
- o->line() << tmp[0].value() << ");";
+ switch (e->args[0]->type)
+ {
+ case pe_long:
+ // print asc value of number
+ o->line() << tmp[0].value() << ");";
+ break;
+ case pe_string:
+ // print first char of string or '-' if string is blank
+ o->line() << "*" << tmp[0].value() << "?:'-'" << ");";
+ break;
+ default:
+ // print '-' if type unknown(should not run to here)
+ o->line() << "'-');";
+ break;
+ }
else
- o->line() << '"' << format_string << "\");";
+ // print '-' if no args(should not run to here because args are checked previously)
+ o->line() << "'-');";
return;
}
if (use_print)
--
1.5.5.3