[Lldb-commits] [lldb] r147536 - /lldb/trunk/source/Core/DataExtractor.cpp
Sean Callanan
scallanan at apple.com
Wed Jan 4 09:36:30 PST 2012
Author: spyffe
Date: Wed Jan 4 11:36:30 2012
New Revision: 147536
URL: http://llvm.org/viewvc/llvm-project?rev=147536&view=rev
Log:
Instead of blindly printing a string when
eFormatCString is specified, I have made
DataExtractor::Dump properly escape the string.
This prevents LLDB from printing characters
that confuse terminals.
Modified:
lldb/trunk/source/Core/DataExtractor.cpp
Modified: lldb/trunk/source/Core/DataExtractor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/DataExtractor.cpp?rev=147536&r1=147535&r2=147536&view=diff
==============================================================================
--- lldb/trunk/source/Core/DataExtractor.cpp (original)
+++ lldb/trunk/source/Core/DataExtractor.cpp Wed Jan 4 11:36:30 2012
@@ -1577,13 +1577,43 @@
case eFormatCString:
{
const char *cstr = GetCStr(&offset);
- if (cstr)
- s->Printf("\"%s\"", cstr);
- else
+
+ if (!cstr)
{
s->Printf("NULL");
offset = UINT32_MAX;
}
+ else
+ {
+ s->PutChar('\"');
+
+ while (const char c = *cstr)
+ {
+ if (isprint(c))
+ {
+ s->PutChar(c);
+ }
+ else
+ {
+ switch (c)
+ {
+ case '\033': s->Printf ("\\e"); break;
+ case '\a': s->Printf ("\\a"); break;
+ case '\b': s->Printf ("\\b"); break;
+ case '\f': s->Printf ("\\f"); break;
+ case '\n': s->Printf ("\\n"); break;
+ case '\r': s->Printf ("\\r"); break;
+ case '\t': s->Printf ("\\t"); break;
+ case '\v': s->Printf ("\\v"); break;
+ default: s->Printf ("\\x%2.2x", c); break;
+ }
+ }
+
+ ++cstr;
+ }
+
+ s->PutChar('\"');
+ }
}
break;
More information about the lldb-commits
mailing list