[Lldb-commits] [lldb] r182398 - <rdar://problem/13925432>

Enrico Granata egranata at apple.com
Tue May 21 10:39:05 PDT 2013


Author: enrico
Date: Tue May 21 12:39:04 2013
New Revision: 182398

URL: http://llvm.org/viewvc/llvm-project?rev=182398&view=rev
Log:
<rdar://problem/13925432>

A user request such as: memory read -fc -s10 -c1 *charPtrPtr would cause us to crash upon trying to read 1 char of size 10 from memory
This request is now translated into: memory read -fc -s1 -c10 *charPtrPtr (i.e. read 10 chars of size 1 from memory) which is probably also what the user originally wanted

Modified:
    lldb/trunk/source/Commands/CommandObjectMemory.cpp

Modified: lldb/trunk/source/Commands/CommandObjectMemory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMemory.cpp?rev=182398&r1=182397&r2=182398&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectMemory.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectMemory.cpp Tue May 21 12:39:04 2013
@@ -827,12 +827,25 @@ protected:
         DataExtractor data (data_sp, 
                             target->GetArchitecture().GetByteOrder(), 
                             target->GetArchitecture().GetAddressByteSize());
-
+        
+        Format format = m_format_options.GetFormat();
+        if ( ( (format == eFormatChar) || (format == eFormatCharPrintable) )
+            && (item_byte_size != 1)
+            && (item_count == 1))
+        {
+            // this turns requests such as
+            // memory read -fc -s10 -c1 *charPtrPtr
+            // which make no sense (what is a char of size 10?)
+            // into a request for fetching 10 chars of size 1 from the same memory location
+            format = eFormatCharArray;
+            item_count = item_byte_size;
+            item_byte_size = 1;
+        }
 
         assert (output_stream);
         size_t bytes_dumped = data.Dump (output_stream,
                                          0,
-                                         m_format_options.GetFormat(),
+                                         format,
                                          item_byte_size,
                                          item_count,
                                          num_per_line,





More information about the lldb-commits mailing list