diff options
author | Elliott Baron <ebaron@toriamos.yyz.redhat.com> | 2008-12-19 10:03:35 -0500 |
---|---|---|
committer | Elliott Baron <ebaron@toriamos.yyz.redhat.com> | 2008-12-19 10:03:35 -0500 |
commit | 30c94a80d5f7bef33450bd1a7e090c8e99b6db89 (patch) | |
tree | 17860ed41e259e5c12bc748968ee895d376644cf | |
parent | 0b7f181e1096f8833e24a60a7c0f97ecc063b9f4 (diff) | |
download | systemtap-steved-30c94a80d5f7bef33450bd1a7e090c8e99b6db89.tar.gz systemtap-steved-30c94a80d5f7bef33450bd1a7e090c8e99b6db89.tar.xz systemtap-steved-30c94a80d5f7bef33450bd1a7e090c8e99b6db89.zip |
First attempt at printf kernel memory hex dump
-rw-r--r-- | elaborate.cxx | 1 | ||||
-rw-r--r-- | runtime/vsprintf.c | 7 | ||||
-rw-r--r-- | staptree.cxx | 8 | ||||
-rw-r--r-- | staptree.h | 1 | ||||
-rw-r--r-- | translate.cxx | 6 |
5 files changed, 20 insertions, 3 deletions
diff --git a/elaborate.cxx b/elaborate.cxx index ba1cb79c..db1a4d78 100644 --- a/elaborate.cxx +++ b/elaborate.cxx @@ -3956,6 +3956,7 @@ typeresolution_info::visit_print_format (print_format* e) case print_format::conv_binary: case print_format::conv_char: case print_format::conv_memory: + case print_format::conv_memory_hex: wanted = pe_long; break; diff --git a/runtime/vsprintf.c b/runtime/vsprintf.c index 831b7a2b..fbd90a83 100644 --- a/runtime/vsprintf.c +++ b/runtime/vsprintf.c @@ -283,6 +283,7 @@ int _stp_vsnprintf(char *buf, size_t size, const char *fmt, va_list args) continue; case 's': + case 'M': case 'm': s = va_arg(args, char *); if ((unsigned long)s < PAGE_SIZE) @@ -303,8 +304,12 @@ int _stp_vsnprintf(char *buf, size_t size, const char *fmt, va_list args) } } for (i = 0; i < len; ++i) { - if (str <= end) + if (str <= end) { + if (*fmt == 'M') + str = number(str, str + 2, (uint64_t)(unsigned char) *s, 16, 2, 2, STP_SPACE); + else *str = *s; + } ++str; ++s; } while (len < field_width--) { diff --git a/staptree.cxx b/staptree.cxx index 51992d7a..fafefc4e 100644 --- a/staptree.cxx +++ b/staptree.cxx @@ -494,6 +494,10 @@ print_format::components_to_string(vector<format_component> const & components) oss << 'm'; break; + case conv_memory_hex: + oss << 'M'; + break; + default: break; } @@ -655,6 +659,10 @@ print_format::string_to_components(string const & str) curr.type = conv_memory; break; + case 'M': + curr.type = conv_memory_hex; + break; + case 'd': case 'i': curr.type = conv_signed_decimal; @@ -289,6 +289,7 @@ struct print_format: public expression conv_string, conv_char, conv_memory, + conv_memory_hex, conv_literal, conv_binary }; diff --git a/translate.cxx b/translate.cxx index 27f6a04b..cdc3da84 100644 --- a/translate.cxx +++ b/translate.cxx @@ -4180,7 +4180,8 @@ c_unparser::visit_print_format (print_format* e) prec_ix = arg_ix++; /* Generate a noop call to deref_buffer for %m. */ - if (components[i].type == print_format::conv_memory) { + if (components[i].type == print_format::conv_memory + || components[i].type == print_format::conv_memory_hex) { this->probe_or_function_needs_deref_fault_handler = true; o->newline() << "deref_buffer (0, " << tmp[arg_ix].value() << ", "; if (prec_ix == -1) @@ -4241,7 +4242,8 @@ c_unparser::visit_print_format (print_format* e) o->line() << ", (int)" << tmp[arg_ix++].value(); /* The type of the %m argument is 'char*'. */ - if (components[i].type == print_format::conv_memory) + if (components[i].type == print_format::conv_memory + || components[i].type == print_format::conv_memory_hex) o->line() << ", (char*)(uintptr_t)" << tmp[arg_ix++].value(); /* The type of the %c argument is 'int'. */ else if (components[i].type == print_format::conv_char) |