diff options
-rw-r--r-- | ChangeLog | 17 | ||||
-rw-r--r-- | elaborate.cxx | 6 | ||||
-rw-r--r-- | staptree.cxx | 26 | ||||
-rw-r--r-- | staptree.h | 4 | ||||
-rw-r--r-- | systemtap.spec.in | 2 | ||||
-rw-r--r-- | translate.cxx | 16 |
6 files changed, 47 insertions, 24 deletions
@@ -1,3 +1,20 @@ +2006-04-09 Martin Hunt <hunt@redhat.com> + Add binary printf support. + + * elaborate.cxx (visit_print_format): Don't include + conv_literal or conv_size in components vector. + Add conv_binary to switch statement. + + * translate.cxx (visit_print_format): Eliminate + special cast to (long long) for pe_long because new + vsnprintf uses int64_t. + + * staptree.h (struct print_format): Add conv_binary and conv_size. + + * staptree.cxx (components_to_string): Add conv_binary case. + Add conv_size case. + (string_to_components): Add cases for 'b' and 'n' + 2006-04-08 Frank Ch. Eigler <fche@elastic.org> * tapsets.cxx (resolve_prologue_endings): Rewrote. diff --git a/elaborate.cxx b/elaborate.cxx index 6dc0ecd8..ea394f94 100644 --- a/elaborate.cxx +++ b/elaborate.cxx @@ -2247,7 +2247,8 @@ typeresolution_info::visit_print_format (print_format* e) if (e->components[i].type == print_format::conv_unspecified) throw semantic_error ("Unspecified conversion in print operator format string", e->tok); - else if (e->components[i].type == print_format::conv_literal) + else if (e->components[i].type == print_format::conv_literal + || e->components[i].type == print_format::conv_size) continue; components.push_back(e->components[i]); } @@ -2267,9 +2268,9 @@ typeresolution_info::visit_print_format (print_format* e) switch (components[i].type) { - case print_format::conv_unspecified: case print_format::conv_literal: + case print_format::conv_size: assert (false); break; @@ -2279,6 +2280,7 @@ typeresolution_info::visit_print_format (print_format* e) case print_format::conv_unsigned_ptr: case print_format::conv_unsigned_uppercase_hex: case print_format::conv_unsigned_lowercase_hex: + case print_format::conv_binary: wanted = pe_long; break; diff --git a/staptree.cxx b/staptree.cxx index 708d7b87..2f62198f 100644 --- a/staptree.cxx +++ b/staptree.cxx @@ -1,5 +1,5 @@ // parse tree functions -// Copyright (C) 2005 Red Hat Inc. +// Copyright (C) 2005, 2006 Red Hat Inc. // // This file is part of systemtap, and is free software. You can // redistribute it and/or modify it under the terms of the GNU General @@ -388,7 +388,11 @@ print_format::components_to_string(vector<format_component> const & components) oss << '.' << i->precision; switch (i->type) - { + { + case conv_binary: + oss << "b"; + break; + case conv_signed_decimal: oss << "lld"; break; @@ -417,6 +421,10 @@ print_format::components_to_string(vector<format_component> const & components) oss << 's'; break; + case conv_size: + oss << 'n'; + break; + default: break; } @@ -441,7 +449,7 @@ print_format::string_to_components(string const & str) { assert (curr.type == conv_unspecified || curr.type == conv_literal); curr.type = conv_literal; - curr.literal_string += *i; + curr.literal_string += *i; ++i; continue; } @@ -500,7 +508,7 @@ print_format::string_to_components(string const & str) curr.flags |= static_cast<unsigned long>(fmt_flag_special); ++i; break; - + default: break; } @@ -538,6 +546,10 @@ print_format::string_to_components(string const & str) switch (*i) { // Valid conversion types + case 'b': + curr.type = conv_binary; + break; + case 's': curr.type = conv_string; break; @@ -566,6 +578,10 @@ print_format::string_to_components(string const & str) case 'x': curr.type = conv_unsigned_lowercase_hex; break; + + case 'n': + curr.type = conv_size; + break; default: break; @@ -575,7 +591,7 @@ print_format::string_to_components(string const & str) throw parse_error("invalid or missing conversion specifier"); ++i; - res.push_back(curr); + res.push_back(curr); curr.clear(); } @@ -281,7 +281,9 @@ struct print_format: public expression conv_unsigned_uppercase_hex, conv_unsigned_lowercase_hex, conv_string, - conv_literal + conv_literal, + conv_binary, + conv_size }; struct format_component diff --git a/systemtap.spec.in b/systemtap.spec.in index 702f8dd4..a2a72c5a 100644 --- a/systemtap.spec.in +++ b/systemtap.spec.in @@ -1,4 +1,4 @@ -%define bundled_elfutils 1 +%define bundled_elfutils 0 %define elfutils_version 0.120 Name: systemtap diff --git a/translate.cxx b/translate.cxx index 35a17c23..d1f4ca6a 100644 --- a/translate.cxx +++ b/translate.cxx @@ -3516,21 +3516,7 @@ c_unparser::visit_print_format (print_format* e) o->line() << lex_cast_qstring(print_format::components_to_string(components)); for (unsigned i = 0; i < tmp.size(); ++i) - { - // We must cast our pe_long type (which is int64_t) to "long - // long" here, because the format string type we are using - // is %ll. We use this format string because, at the back - // end of vsnprintf, linux actually implements it using the - // "long long" type as well, not a particular 32 or 64 bit - // width, and it *also* fails to provide any inttype.h-like - // macro machinery to figure out how many bits exist in a - // long long. Using %ll and always casting the argument is - // the most portable target-sensitive solution. - if (tmp[i].type() == pe_long) - o->line() << ", ((long long)(" << tmp[i].qname() << "))"; - else - o->line() << ", " << tmp[i].qname(); - } + o->line() << ", " << tmp[i].qname(); o->line() << ");"; o->newline() << res.qname() << ";"; } |