[Lldb-commits] [lldb] r123509 - in /lldb/trunk: include/lldb/lldb-enumerations.h source/Core/DataExtractor.cpp source/Symbol/ClangASTContext.cpp source/Symbol/ClangASTType.cpp

Greg Clayton gclayton at apple.com
Fri Jan 14 18:52:14 PST 2011


Author: gclayton
Date: Fri Jan 14 20:52:14 2011
New Revision: 123509

URL: http://llvm.org/viewvc/llvm-project?rev=123509&view=rev
Log:
Added complete complex support for displaying and parsing complex types.


Modified:
    lldb/trunk/include/lldb/lldb-enumerations.h
    lldb/trunk/source/Core/DataExtractor.cpp
    lldb/trunk/source/Symbol/ClangASTContext.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=123509&r1=123508&r2=123509&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-enumerations.h (original)
+++ lldb/trunk/include/lldb/lldb-enumerations.h Fri Jan 14 20:52:14 2011
@@ -148,7 +148,8 @@
     eFormatBytesWithASCII,
     eFormatChar,
     eFormatCharPrintable,   // Only printable characters, space if not printable
-    eFormatComplex,
+    eFormatComplex,         // Floating point complex type
+    eFormatComplexFloat = eFormatComplex,
     eFormatCString,         // NULL terminated C strings
     eFormatDecimal,
     eFormatEnum,
@@ -171,7 +172,8 @@
     eFormatVectorOfUInt64,
     eFormatVectorOfFloat32,
     eFormatVectorOfFloat64,
-    eFormatVectorOfUInt128
+    eFormatVectorOfUInt128,
+    eFormatComplexInteger,  // Integer complex type
 
 } Format;
 

Modified: lldb/trunk/source/Core/DataExtractor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/DataExtractor.cpp?rev=123509&r1=123508&r2=123509&view=diff
==============================================================================
--- lldb/trunk/source/Core/DataExtractor.cpp (original)
+++ lldb/trunk/source/Core/DataExtractor.cpp Fri Jan 14 20:52:14 2011
@@ -1390,6 +1390,19 @@
             s->Address(GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size, item_bit_offset), sizeof (addr_t));
             break;
 
+
+        case eFormatComplexInteger:
+            {
+                uint32_t complex_int_byte_size = item_byte_size / 2;
+                
+                if (complex_int_byte_size <= 8)
+                {
+                    s->Printf("%llu", GetMaxU64Bitfield(&offset, complex_int_byte_size, 0, 0));
+                    s->Printf(" + %llui", GetMaxU64Bitfield(&offset, complex_int_byte_size, 0, 0));
+                }
+            }
+            break;
+
         case eFormatComplex:
             if (sizeof(float) * 2 == item_byte_size)
             {
@@ -1414,9 +1427,12 @@
                 s->Printf ("%Lg + %Lgi", ld64_1, ld64_2);
                 break;
             }
-            
-            // Fall through to hex for any other sizes
-            item_format = eFormatHex;
+            else
+            {
+                s->Printf ("unsupported complex float byte size %u", item_byte_size);
+                return start_offset;
+            }
+            break;
 
         default:
         case eFormatDefault:

Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=123509&r1=123508&r2=123509&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Fri Jan 14 20:52:14 2011
@@ -548,13 +548,27 @@
                 return ast_context->UnsignedIntTy.getAsOpaquePtr();
             break;
 
+        case DW_ATE_lo_user:
+            // This has been seen to mean DW_AT_complex_integer
+            if (strcmp(type_name, "complex") == 0)
+            {
+                clang_type_t complex_int_clang_type = GetBuiltinTypeForDWARFEncodingAndBitSize ("int", DW_ATE_signed, bit_size/2);
+                return ast_context->getComplexType (QualType::getFromOpaquePtr(complex_int_clang_type)).getAsOpaquePtr();
+            }
+            break;
+            
         case DW_ATE_complex_float:
             if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->FloatComplexTy))
                 return ast_context->FloatComplexTy.getAsOpaquePtr();
-            if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->DoubleComplexTy))
+            else if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->DoubleComplexTy))
                 return ast_context->DoubleComplexTy.getAsOpaquePtr();
-            if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->LongDoubleComplexTy))
+            else if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->LongDoubleComplexTy))
                 return ast_context->LongDoubleComplexTy.getAsOpaquePtr();
+            else 
+            {
+                clang_type_t complex_float_clang_type = GetBuiltinTypeForDWARFEncodingAndBitSize ("float", DW_ATE_float, bit_size/2);
+                return ast_context->getComplexType (QualType::getFromOpaquePtr(complex_float_clang_type)).getAsOpaquePtr();
+            }
             break;
 
         case DW_ATE_float:
@@ -1773,7 +1787,7 @@
             *pointee_or_element_clang_type = qual_type->getPointeeType().getAsOpaquePtr();
         return eTypeIsPointer | eTypeHasChildren | eTypeIsBlock;
 
-    case clang::Type::Complex:                          return eTypeHasChildren | eTypeIsBuiltIn | eTypeHasValue;
+    case clang::Type::Complex:                          return eTypeIsBuiltIn | eTypeHasValue;
 
     case clang::Type::ConstantArray:
     case clang::Type::DependentSizedArray:
@@ -1902,8 +1916,7 @@
         }
         break;
 
-    case clang::Type::Complex:
-        return 2;
+    case clang::Type::Complex: return 0;
 
     case clang::Type::Record:
         if (ClangASTType::IsDefined (clang_qual_type))
@@ -2090,7 +2103,7 @@
         }
         break;
 
-    case clang::Type::Complex:                  return 2;
+    case clang::Type::Complex:                  return 1;
     case clang::Type::Pointer:                  return 1;
     case clang::Type::BlockPointer:             return 0;   // If block pointers don't have debug info, then no children for them
     case clang::Type::LValueReference:          return 1;

Modified: lldb/trunk/source/Symbol/ClangASTType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTType.cpp?rev=123509&r1=123508&r2=123509&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTType.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTType.cpp Fri Jan 14 20:52:14 2011
@@ -177,10 +177,22 @@
     case clang::Type::LValueReference:
     case clang::Type::RValueReference:
     case clang::Type::MemberPointer:            return lldb::eEncodingUint;
-    // Complex numbers are made up of floats
     case clang::Type::Complex:
-        count = 2;
-        return lldb::eEncodingIEEE754;
+        {
+            lldb::Encoding encoding = lldb::eEncodingIEEE754;
+            if (qual_type->isComplexType())
+                encoding = lldb::eEncodingIEEE754;
+            else
+            {
+                const clang::ComplexType *complex_type = qual_type->getAsComplexIntegerType();
+                if (complex_type)
+                    encoding = GetEncoding (complex_type->getElementType().getAsOpaquePtr(), count);
+                else 
+                    encoding = lldb::eEncodingSint;
+            }
+            count = 2;
+            return encoding;
+        }
 
     case clang::Type::ObjCInterface:            break;
     case clang::Type::Record:                   break;
@@ -270,7 +282,13 @@
     case clang::Type::LValueReference:
     case clang::Type::RValueReference:          return lldb::eFormatHex;
     case clang::Type::MemberPointer:            break;
-    case clang::Type::Complex:                  return lldb::eFormatComplex;
+    case clang::Type::Complex:
+        {
+            if (qual_type->isComplexType())
+                return lldb::eFormatComplex;
+            else
+                return lldb::eFormatComplexInteger;
+        }
     case clang::Type::ObjCInterface:            break;
     case clang::Type::Record:                   break;
     case clang::Type::Enum:                     return lldb::eFormatEnum;





More information about the lldb-commits mailing list