summaryrefslogtreecommitdiffstats
path: root/translate.cxx
diff options
context:
space:
mode:
authorTim Moore <timoore@redhat.com>2009-12-23 09:14:02 +0100
committerTim Moore <timoore@redhat.com>2009-12-23 09:14:02 +0100
commit69ce6c79dbcb2cec2d1245935ef20bf832ffe70a (patch)
tree0b6aea71ef4f3ca5c797494d062819bfba63e7f7 /translate.cxx
parent72195f6b17c0ed2e508c58bf3cadd5b9dc4e28ac (diff)
parent0ee3adb42f2f6d8bffe177e77a415b3a74f3a777 (diff)
downloadsystemtap-steved-69ce6c79dbcb2cec2d1245935ef20bf832ffe70a.tar.gz
systemtap-steved-69ce6c79dbcb2cec2d1245935ef20bf832ffe70a.tar.xz
systemtap-steved-69ce6c79dbcb2cec2d1245935ef20bf832ffe70a.zip
Merge remote branch 'origin/master'
Diffstat (limited to 'translate.cxx')
-rw-r--r--translate.cxx40
1 files changed, 26 insertions, 14 deletions
diff --git a/translate.cxx b/translate.cxx
index 8c624a2f..88e69a66 100644
--- a/translate.cxx
+++ b/translate.cxx
@@ -4264,20 +4264,33 @@ c_unparser::visit_print_format (print_format* e)
if (components[i].prectype == print_format::prec_dynamic)
prec_ix = arg_ix++;
- /* Generate a noop call to deref_buffer for %m. */
+ /* %m and %M need special care for digging into 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)
- if (width_ix != -1)
- prec_ix = width_ix;
- if (prec_ix != -1)
- o->line() << tmp[prec_ix].value();
- else
- o->line() << "1";
- o->line() << ");";
- }
+ || components[i].type == print_format::conv_memory_hex)
+ {
+ string mem_size;
+ if (prec_ix != -1)
+ mem_size = tmp[prec_ix].value();
+ else if (components[i].prectype == print_format::prec_static &&
+ components[i].precision > 0)
+ mem_size = lex_cast(components[i].precision) + "LL";
+ else
+ mem_size = "1LL";
+
+ /* Limit how much can be printed at a time. (see also PR10490) */
+ o->newline() << "if (" << mem_size << " > 1024) {";
+ o->newline(1) << "snprintf(c->error_buffer, sizeof(c->error_buffer), "
+ << "\"%lld is too many bytes for a memory dump\", "
+ << mem_size << ");";
+ o->newline() << "c->last_error = c->error_buffer;";
+ o->newline() << "goto out;";
+ o->newline(-1) << "}";
+
+ /* Generate a noop call to deref_buffer. */
+ this->probe_or_function_needs_deref_fault_handler = true;
+ o->newline() << "deref_buffer (0, " << tmp[arg_ix].value() << ", "
+ << mem_size << " ?: 1LL);";
+ }
++arg_ix;
}
@@ -5225,7 +5238,6 @@ translate_pass (systemtap_session& s)
s.op->newline() << "#include <linux/version.h>";
// s.op->newline() << "#include <linux/compile.h>";
s.op->newline() << "#include \"loc2c-runtime.h\" ";
- s.op->newline() << "#include \"access_process_vm.h\" ";
s.up->emit_common_header (); // context etc.