[Lldb-commits] [lldb] r133316 - in /lldb/trunk: include/lldb/lldb-enumerations.h source/Commands/CommandObjectMemory.cpp source/Core/DataExtractor.cpp source/Core/State.cpp source/Core/ValueObject.cpp source/Interpreter/Args.cpp source/Symbol/ClangASTType.cpp
Greg Clayton
gclayton at apple.com
Fri Jun 17 16:50:44 PDT 2011
Author: gclayton
Date: Fri Jun 17 18:50:44 2011
New Revision: 133316
URL: http://llvm.org/viewvc/llvm-project?rev=133316&view=rev
Log:
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.
Modified:
lldb/trunk/include/lldb/lldb-enumerations.h
lldb/trunk/source/Commands/CommandObjectMemory.cpp
lldb/trunk/source/Core/DataExtractor.cpp
lldb/trunk/source/Core/State.cpp
lldb/trunk/source/Core/ValueObject.cpp
lldb/trunk/source/Interpreter/Args.cpp
lldb/trunk/source/Symbol/ClangASTType.cpp
Modified: lldb/trunk/include/lldb/lldb-enumerations.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=133316&r1=133315&r2=133316&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-enumerations.h (original)
+++ lldb/trunk/include/lldb/lldb-enumerations.h Fri Jun 17 18:50:44 2011
@@ -92,6 +92,7 @@
eFormatBytesWithASCII,
eFormatChar,
eFormatCharPrintable, // Only printable characters, space if not printable
+ eFormatCharArray, // Print characters with no single quotes, used for character arrays that can contain non printable characters
eFormatComplex, // Floating point complex type
eFormatComplexFloat = eFormatComplex,
eFormatCString, // NULL terminated C strings
Modified: lldb/trunk/source/Commands/CommandObjectMemory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMemory.cpp?rev=133316&r1=133315&r2=133316&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectMemory.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectMemory.cpp Fri Jun 17 18:50:44 2011
@@ -210,6 +210,7 @@
if (!count_option_set)
m_count = 32;
break;
+ case eFormatCharArray:
case eFormatChar:
case eFormatCharPrintable:
if (!byte_size_option_set)
@@ -1062,6 +1063,7 @@
buffer.PutMaxHex64 (uval64, item_byte_size);
break;
+ case eFormatCharArray:
case eFormatChar:
case eFormatCString:
if (value_str[0])
Modified: lldb/trunk/source/Core/DataExtractor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/DataExtractor.cpp?rev=133316&r1=133315&r2=133316&view=diff
==============================================================================
--- lldb/trunk/source/Core/DataExtractor.cpp (original)
+++ lldb/trunk/source/Core/DataExtractor.cpp Fri Jun 17 18:50:44 2011
@@ -1354,6 +1354,7 @@
else
if (item_format != eFormatChar &&
item_format != eFormatCharPrintable &&
+ item_format != eFormatCharArray &&
count > 0)
{
s->PutChar(' ');
@@ -1397,6 +1398,7 @@
case eFormatChar:
case eFormatCharPrintable:
+ case eFormatCharArray:
{
// If we are only printing one character surround it with single
// quotes
@@ -1406,7 +1408,7 @@
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 @@
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;
Modified: lldb/trunk/source/Core/State.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/State.cpp?rev=133316&r1=133315&r2=133316&view=diff
==============================================================================
--- lldb/trunk/source/Core/State.cpp (original)
+++ lldb/trunk/source/Core/State.cpp Fri Jun 17 18:50:44 2011
@@ -51,6 +51,7 @@
case eFormatBytes: return "bytes";
case eFormatBytesWithASCII: return "bytes with ASCII";
case eFormatChar: return "character";
+ case eFormatCharArray: return "character array";
case eFormatCharPrintable: return "printable character";
case eFormatComplexFloat: return "complet float";
case eFormatCString: return "c-string";
Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=133316&r1=133315&r2=133316&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Fri Jun 17 18:50:44 2011
@@ -505,7 +505,7 @@
sstr << '"';
data.Dump (&sstr,
0, // Start offset in "data"
- eFormatChar, // Print as characters
+ eFormatCharArray, // Print as characters
1, // Size of item (1 byte for a char!)
bytes_read, // How many bytes to print?
UINT32_MAX, // num per line
@@ -535,7 +535,7 @@
data.Dump (&sstr,
0, // Start offset in "data"
- eFormatChar, // Print as characters
+ eFormatCharArray, // Print as characters
1, // Size of item (1 byte for a char!)
len, // How many bytes to print?
UINT32_MAX, // num per line
Modified: lldb/trunk/source/Interpreter/Args.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Args.cpp?rev=133316&r1=133315&r2=133316&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/Args.cpp (original)
+++ lldb/trunk/source/Interpreter/Args.cpp Fri Jun 17 18:50:44 2011
@@ -908,6 +908,7 @@
case 'Y': format = eFormatBytesWithASCII; break;
case 'b': format = eFormatBinary; break;
case 'B': format = eFormatBoolean; break;
+ case 'a': format = eFormatCharArray; break;
case 'c': format = eFormatChar; break;
case 'C': format = eFormatCharPrintable; break;
case 'o': format = eFormatOctal; break;
@@ -930,6 +931,7 @@
}
if (!success)
error.SetErrorStringWithFormat ("Invalid format specification '%s'. Valid values are:\n"
+ " a - char buffer\n"
" b - binary\n"
" B - boolean\n"
" c - char\n"
Modified: lldb/trunk/source/Symbol/ClangASTType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTType.cpp?rev=133316&r1=133315&r2=133316&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTType.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTType.cpp Fri Jun 17 18:50:44 2011
@@ -788,6 +788,7 @@
case eFormatChar:
case eFormatCharPrintable:
+ case eFormatCharArray:
case eFormatBytes:
case eFormatBytesWithASCII:
item_count = (byte_size * item_count);
More information about the lldb-commits
mailing list