From 4e4294bdeee8d41b74f8ddf671aa00952b645c3d Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Fri, 17 Jun 2011 23:50:44 +0000 Subject: Added a new format for displaying an array of characters: eFormatCharArray This us useful because sometomes you have to show a single character as: 'a' (using eFormatChar) and other times you might have an array of single charcters for display as: 'a' 'b' 'c', and other times you might want to show the contents of buffer of characters that can contain non printable chars: "\0\x22\n123". This also fixes an issue that currently happens when you have a single character C string (const char *a = "a"; or char b[1] = { 'b' };) that was being output as "'a'" incorrectly due to the way the eFormatChar format output worked. llvm-svn: 133316 --- lldb/source/Core/DataExtractor.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lldb/source/Core/DataExtractor.cpp') diff --git a/lldb/source/Core/DataExtractor.cpp b/lldb/source/Core/DataExtractor.cpp index bc26c8645e1..9d665735534 100644 --- a/lldb/source/Core/DataExtractor.cpp +++ b/lldb/source/Core/DataExtractor.cpp @@ -1354,6 +1354,7 @@ DataExtractor::Dump else if (item_format != eFormatChar && item_format != eFormatCharPrintable && + item_format != eFormatCharArray && count > 0) { s->PutChar(' '); @@ -1397,6 +1398,7 @@ DataExtractor::Dump case eFormatChar: case eFormatCharPrintable: + case eFormatCharArray: { // If we are only printing one character surround it with single // quotes @@ -1406,7 +1408,7 @@ DataExtractor::Dump uint32_t ch = GetMaxU64(&offset, item_byte_size); if (isprint(ch)) s->Printf ("%c", ch); - else if (item_format == eFormatChar) + else if (item_format != eFormatCharPrintable) { switch (ch) { @@ -1608,7 +1610,7 @@ DataExtractor::Dump case eFormatVectorOfChar: s->PutChar('{'); - offset = Dump (s, start_offset, eFormatChar, 1, item_byte_size, item_byte_size, LLDB_INVALID_ADDRESS, 0, 0); + offset = Dump (s, start_offset, eFormatCharArray, 1, item_byte_size, item_byte_size, LLDB_INVALID_ADDRESS, 0, 0); s->PutChar('}'); break; -- cgit v1.2.3