[Lldb-commits] [lldb] r170264 - in /lldb/trunk: include/lldb/Interpreter/OptionGroupFormat.h source/Interpreter/OptionGroupFormat.cpp

Greg Clayton gclayton at apple.com
Fri Dec 14 17:44:52 PST 2012


Author: gclayton
Date: Fri Dec 14 19:44:51 2012
New Revision: 170264

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

x/a print wouldn't always reset the word size to the size of a pointer if a previous memory read using x/<gdb-format> had been used that set it to another width.


Modified:
    lldb/trunk/include/lldb/Interpreter/OptionGroupFormat.h
    lldb/trunk/source/Interpreter/OptionGroupFormat.cpp

Modified: lldb/trunk/include/lldb/Interpreter/OptionGroupFormat.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/OptionGroupFormat.h?rev=170264&r1=170263&r2=170264&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/OptionGroupFormat.h (original)
+++ lldb/trunk/include/lldb/Interpreter/OptionGroupFormat.h Fri Dec 14 19:44:51 2012
@@ -109,7 +109,10 @@
 protected:
 
     bool
-    ParserGDBFormatLetter (char format_letter, lldb::Format &format, uint32_t &byte_size);
+    ParserGDBFormatLetter (CommandInterpreter &interpreter,
+                           char format_letter,
+                           lldb::Format &format,
+                           uint32_t &byte_size);
 
     OptionValueFormat m_format;
     OptionValueUInt64 m_byte_size;

Modified: lldb/trunk/source/Interpreter/OptionGroupFormat.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionGroupFormat.cpp?rev=170264&r1=170263&r2=170264&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/OptionGroupFormat.cpp (original)
+++ lldb/trunk/source/Interpreter/OptionGroupFormat.cpp Fri Dec 14 19:44:51 2012
@@ -13,6 +13,10 @@
 // C++ Includes
 // Other libraries and framework includes
 // Project includes
+#include "lldb/Core/ArchSpec.h"
+#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Target/ExecutionContext.h"
+#include "lldb/Target/Target.h"
 #include "lldb/Utility/Utils.h"
 
 using namespace lldb;
@@ -119,7 +123,7 @@
                 Format format = eFormatDefault;
                 uint32_t byte_size = 0;
                 
-                while (ParserGDBFormatLetter (gdb_format_cstr[0], format, byte_size))
+                while (ParserGDBFormatLetter (interpreter, gdb_format_cstr[0], format, byte_size))
                 {
                     ++gdb_format_cstr;
                 }
@@ -139,7 +143,7 @@
                 // Anything that wasn't set correctly should be set to the
                 // previous default
                 if (format == eFormatInvalid)
-                    ParserGDBFormatLetter (m_prev_gdb_format, format, byte_size);
+                    ParserGDBFormatLetter (interpreter, m_prev_gdb_format, format, byte_size);
                 
                 const bool byte_size_enabled = m_byte_size.GetDefaultValue() < UINT64_MAX;
                 const bool count_enabled = m_count.GetDefaultValue() < UINT64_MAX;
@@ -147,7 +151,7 @@
                 {
                     // Byte size is enabled
                     if (byte_size == 0)
-                        ParserGDBFormatLetter (m_prev_gdb_size, format, byte_size);
+                        ParserGDBFormatLetter (interpreter, m_prev_gdb_size, format, byte_size);
                 }
                 else
                 {
@@ -199,7 +203,7 @@
 }
 
 bool
-OptionGroupFormat::ParserGDBFormatLetter (char format_letter, Format &format, uint32_t &byte_size)
+OptionGroupFormat::ParserGDBFormatLetter (CommandInterpreter &interpreter, char format_letter, Format &format, uint32_t &byte_size)
 {
     switch (format_letter)
     {
@@ -209,7 +213,15 @@
         case 'u': format = eFormatUnsigned;     m_prev_gdb_format = format_letter; return true;
         case 't': format = eFormatBinary;       m_prev_gdb_format = format_letter; return true;
         case 'f': format = eFormatFloat;        m_prev_gdb_format = format_letter; return true;
-        case 'a': format = eFormatAddressInfo;  m_prev_gdb_format = format_letter; return true;
+        case 'a': format = eFormatAddressInfo;
+        {
+            ExecutionContext exe_ctx(interpreter.GetExecutionContext());
+            Target *target = exe_ctx.GetTargetPtr();
+            if (target)
+                byte_size = target->GetArchitecture().GetAddressByteSize();
+            m_prev_gdb_format = format_letter;
+            return true;
+        }
         case 'i': format = eFormatInstruction;  m_prev_gdb_format = format_letter; return true;
         case 'c': format = eFormatChar;         m_prev_gdb_format = format_letter; return true;
         case 's': format = eFormatCString;      m_prev_gdb_format = format_letter; return true;





More information about the lldb-commits mailing list