[Lldb-commits] [PATCH] D11488: Fix bug in expression display when determining if a pointer should be treated as a string

Paul Maybee paulmay at microsoft.com
Fri Jul 24 10:11:08 PDT 2015


paulmaybee created this revision.
paulmaybee added reviewers: abidh, ki.stfu, ChuckR.
paulmaybee added subscribers: lldb-commits, greggm.

Currently if the "first child" of the pointer is a char type then the pointer is displayed as a string. This test succeeds incorrectly when the pointer is to a structured type with a char type as its first field. Fix this by switching the test to retrieve the pointee type and checking that it is a char type.


http://reviews.llvm.org/D11488

Files:
  tools/lldb-mi/MICmnLLDBUtilSBValue.cpp
  tools/lldb-mi/MICmnLLDBUtilSBValue.h

Index: tools/lldb-mi/MICmnLLDBUtilSBValue.h
===================================================================
--- tools/lldb-mi/MICmnLLDBUtilSBValue.h
+++ tools/lldb-mi/MICmnLLDBUtilSBValue.h
@@ -57,7 +57,8 @@
     CMIUtilString GetSimpleValueCStringPointer(void) const;
     CMIUtilString GetSimpleValueCStringArray(void) const;
     bool GetCompositeValue(const bool vbPrintFieldNames, CMICmnMIValueTuple &vwrMiValueTuple, const MIuint vnDepth = 1) const;
-
+    static bool IsCharBasicType(lldb::BasicType eType);
+    
     // Attributes:
   private:
     lldb::SBValue &m_rValue;
Index: tools/lldb-mi/MICmnLLDBUtilSBValue.cpp
===================================================================
--- tools/lldb-mi/MICmnLLDBUtilSBValue.cpp
+++ tools/lldb-mi/MICmnLLDBUtilSBValue.cpp
@@ -136,7 +136,9 @@
     }
     else if (IsPointerType())
     {
-        if (m_bHandleCharType && IsFirstChildCharType())
+        const lldb::BasicType eType = m_rValue.GetType().GetPointeeType().GetBasicType();
+
+        if (m_bHandleCharType && IsCharBasicType(eType))
         {
             vwrValue = GetSimpleValueCStringPointer();
             return MIstatus::success;
@@ -358,17 +360,15 @@
 }
 
 //++ ------------------------------------------------------------------------------------
-// Details: Retrieve the flag stating whether this value object is a char type or some
-//          other type. Char type can be signed or unsigned.
+// Details: Check that basic type is a char type. Char type can be signed or unsigned.
 // Type:    Method.
-// Args:    None.
+// Args:    eType   - type to check
 // Return:  bool    - True = Yes is a char type, false = some other type.
 // Throws:  None.
 //--
 bool
-CMICmnLLDBUtilSBValue::IsCharType(void) const
+CMICmnLLDBUtilSBValue::IsCharBasicType(lldb::BasicType eType)
 {
-    const lldb::BasicType eType = m_rValue.GetType().GetBasicType();
     switch (eType)
     {
         case lldb::eBasicTypeChar:
@@ -383,6 +383,22 @@
 }
 
 //++ ------------------------------------------------------------------------------------
+// Details: Retrieve the flag stating whether this value object is a char type or some
+//          other type. Char type can be signed or unsigned.
+// Type:    Method.
+// Args:    None.
+// Return:  bool    - True = Yes is a char type, false = some other type.
+// Throws:  None.
+//--
+bool
+CMICmnLLDBUtilSBValue::IsCharType(void) const
+{
+    const lldb::BasicType eType = m_rValue.GetType().GetBasicType();
+    return IsCharBasicType(eType);
+}
+
+
+//++ ------------------------------------------------------------------------------------
 // Details: Retrieve the flag stating whether first child value object of *this object is
 //          a char type or some other type. Returns false if there are not children. Char
 //          type can be signed or unsigned.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11488.30581.patch
Type: text/x-patch
Size: 2846 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150724/341b2340/attachment.bin>


More information about the lldb-commits mailing list