summaryrefslogtreecommitdiffstats
path: root/staptree.cxx
diff options
context:
space:
mode:
authorbrolley <brolley>2008-02-27 16:42:35 +0000
committerbrolley <brolley>2008-02-27 16:42:35 +0000
commit34201621cc07339371c8d74ce0fe609d967771d4 (patch)
treef2122e04569f569d2ff848435af6c2f343a2ac63 /staptree.cxx
parent67bae0e3d979d554acaeb2a09cf4f7463ee713da (diff)
downloadsystemtap-steved-34201621cc07339371c8d74ce0fe609d967771d4.tar.gz
systemtap-steved-34201621cc07339371c8d74ce0fe609d967771d4.tar.xz
systemtap-steved-34201621cc07339371c8d74ce0fe609d967771d4.zip
2008-02-21 Dave Brolley <brolley@redhat.com>
PR5189 * staptree.h (print_format::conv_memory): New enumerator. (print_format::width_type): New enumeration. (print_format::precision_type): New enumeration. (format_component::widthtype): New member. (format_component::prectype): New member. (format_component::is_empty): Test widthtype and prectype. (format_component::clear): Clear widthtype and prectype. * staptree.cxx (print_format::components_to_string): Handle dynamic width and precision. Handle conv_memory. (print_format::string_to_components): Parse dynamic width and precision specifiers. Set widthtype and prectype. Parse %m format specifier. * elaborate.h (typeresolution_info::check_arg_type): New method. * elaborate.cxx (typeresolution_info::visit_print_format): Account for dynamic width and precision when computing the expected number of arguments. Check the types of arguments for dynamic width and precision. Use check_arg_type to check the types of all arguments. Handle print_format::conv_memory. (typeresolution_info::check_arg_type): New method. * NEWS: Describe the enhancements above.
Diffstat (limited to 'staptree.cxx')
-rw-r--r--staptree.cxx54
1 files changed, 45 insertions, 9 deletions
diff --git a/staptree.cxx b/staptree.cxx
index 36ef04f5..63c1fcf7 100644
--- a/staptree.cxx
+++ b/staptree.cxx
@@ -442,10 +442,14 @@ print_format::components_to_string(vector<format_component> const & components)
if (i->flags & static_cast<unsigned long>(fmt_flag_special))
oss << '#';
- if (i->width > 0)
+ if (i->widthtype == width_dynamic)
+ oss << '*';
+ else if (i->widthtype != width_unspecified && i->width > 0)
oss << i->width;
- if (i->precision > 0)
+ if (i->prectype == prec_dynamic)
+ oss << ".*";
+ else if (i->prectype != prec_unspecified && i->precision > 0)
oss << '.' << i->precision;
switch (i->type)
@@ -482,6 +486,10 @@ print_format::components_to_string(vector<format_component> const & components)
oss << 's';
break;
+ case conv_memory:
+ oss << 'm';
+ break;
+
case conv_size:
oss << 'n';
break;
@@ -574,14 +582,27 @@ print_format::string_to_components(string const & str)
break;
}
+ if (i == str.end())
+ break;
+
// Parse optional width
-
- while (i != str.end() && isdigit(*i))
+ if (*i == '*')
{
- curr.width *= 10;
- curr.width += (*i - '0');
+ curr.widthtype = width_dynamic;
++i;
}
+ else if (isdigit(*i))
+ {
+ curr.widthtype = width_static;
+ curr.width = 0;
+ do
+ {
+ curr.width *= 10;
+ curr.width += (*i - '0');
+ ++i;
+ }
+ while (i != str.end() && isdigit(*i));
+ }
if (i == str.end())
break;
@@ -592,12 +613,23 @@ print_format::string_to_components(string const & str)
++i;
if (i == str.end())
break;
- while (i != str.end() && isdigit(*i))
+ if (*i == '*')
{
- curr.precision *= 10;
- curr.precision += (*i - '0');
+ curr.prectype = prec_dynamic;
++i;
}
+ else if (isdigit(*i))
+ {
+ curr.prectype = prec_static;
+ curr.precision = 0;
+ do
+ {
+ curr.precision *= 10;
+ curr.precision += (*i - '0');
+ ++i;
+ }
+ while (i != str.end() && isdigit(*i));
+ }
}
if (i == str.end())
@@ -615,6 +647,10 @@ print_format::string_to_components(string const & str)
curr.type = conv_string;
break;
+ case 'm':
+ curr.type = conv_memory;
+ break;
+
case 'd':
case 'i':
curr.type = conv_signed_decimal;