Fix disassembly redirection from stdout into a file.

Pass \n, \r and \t through OStream without escaping.

BUG=
R=svenpanne@chromium.org

Review URL: https://codereview.chromium.org/458533002

Patch from Vyacheslav Egorov <vegorov@google.com>.

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23478 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 0748ee42
......@@ -3500,7 +3500,7 @@ int HGraph::TraceInlinedFunction(
shared->end_position() - shared->start_position() + 1;
for (int i = 0; i < source_len; i++) {
if (stream.HasMore()) {
os << AsUC16(stream.GetNext());
os << AsReversiblyEscapedUC16(stream.GetNext());
}
}
}
......
......@@ -10923,7 +10923,10 @@ void Code::Disassemble(const char* name, OStream& os) { // NOLINT
os << "Instructions (size = " << instruction_size() << ")\n";
// TODO(svenpanne) The Disassembler should use streams, too!
Disassembler::Decode(stdout, this);
{
CodeTracer::Scope trace_scope(GetIsolate()->GetCodeTracer());
Disassembler::Decode(trace_scope.file(), this);
}
os << "\n";
if (kind() == FUNCTION) {
......
......@@ -163,6 +163,16 @@ OFStream& OFStream::flush() {
}
OStream& operator<<(OStream& os, const AsReversiblyEscapedUC16& c) {
char buf[10];
const char* format = (0x20 <= c.value && c.value <= 0x7F) && (c.value != 0x52)
? "%c"
: (c.value <= 0xff) ? "\\x%02x" : "\\u%04x";
snprintf(buf, sizeof(buf), format, c.value);
return os << buf;
}
OStream& operator<<(OStream& os, const AsUC16& c) {
char buf[10];
const char* format = (0x20 <= c.value && c.value <= 0x7F)
......
......@@ -117,13 +117,26 @@ class OFStream: public OStream {
};
// A wrapper to disambiguate uint16_t and uc16.
// Wrappers to disambiguate uint16_t and uc16.
struct AsUC16 {
explicit AsUC16(uint16_t v) : value(v) {}
uint16_t value;
};
struct AsReversiblyEscapedUC16 {
explicit AsReversiblyEscapedUC16(uint16_t v) : value(v) {}
uint16_t value;
};
// Writes the given character to the output escaping everything outside
// of printable ASCII range. Additionally escapes '\' making escaping
// reversible.
OStream& operator<<(OStream& os, const AsReversiblyEscapedUC16& c);
// Writes the given character to the output escaping everything outside
// of printable ASCII range.
OStream& operator<<(OStream& os, const AsUC16& c);
} } // namespace v8::internal
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment