[Lldb-commits] [lldb] r134716 - in /lldb/tags/lldb-69/source: Expression/ClangExpressionDeclMap.cpp Symbol/ClangASTContext.cpp

Greg Clayton gclayton at apple.com
Fri Jul 8 11:29:48 PDT 2011


Author: gclayton
Date: Fri Jul  8 13:29:48 2011
New Revision: 134716

URL: http://llvm.org/viewvc/llvm-project?rev=134716&view=rev
Log:
Fixed for crashing during ASTImport due to bad pointers.


Modified:
    lldb/tags/lldb-69/source/Expression/ClangExpressionDeclMap.cpp
    lldb/tags/lldb-69/source/Symbol/ClangASTContext.cpp

Modified: lldb/tags/lldb-69/source/Expression/ClangExpressionDeclMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/tags/lldb-69/source/Expression/ClangExpressionDeclMap.cpp?rev=134716&r1=134715&r2=134716&view=diff
==============================================================================
--- lldb/tags/lldb-69/source/Expression/ClangExpressionDeclMap.cpp (original)
+++ lldb/tags/lldb-69/source/Expression/ClangExpressionDeclMap.cpp Fri Jul  8 13:29:48 2011
@@ -552,6 +552,9 @@
     else
         return false;
     
+    if (!func_so_addr || !func_so_addr->IsValid())
+        return false;
+    
     func_addr = func_so_addr->GetCallableLoadAddress (m_parser_vars->m_exe_ctx->target);
 
     return true;
@@ -573,6 +576,10 @@
         sc_list.GetContextAtIndex(i, sym_ctx);
     
         const Address *sym_address = &sym_ctx.symbol->GetAddressRangeRef().GetBaseAddress();
+        
+        if (!sym_address || !sym_address->IsValid())
+            return LLDB_INVALID_ADDRESS;
+        
         if (sym_address)
         {
             switch (sym_ctx.symbol->GetType())
@@ -1261,7 +1268,7 @@
                                               NULL));
     }
     else if (sym)
-    {
+    {        
         location_value.reset(new Value);
         
         addr_t location_load_addr = GetSymbolAddress(*exe_ctx.target, name);
@@ -1591,6 +1598,11 @@
                 var_sp = program_globals.GetVariableAtIndex (0);
         }
     }
+    
+    if (!var_sp ||
+        !var_sp->IsInScope(&frame) ||
+        !var_sp->LocationIsValidForFrame (&frame))
+        return lldb::VariableSP();
 
     if (var_sp && type)
     {
@@ -1672,8 +1684,8 @@
         
         if (const NamespaceDecl *namespace_decl = dyn_cast<NamespaceDecl>(context_decl))
         {
-            Decl *original_decl;
-            ASTContext *original_ctx;
+            Decl *original_decl = NULL;
+            ASTContext *original_ctx = NULL;
             
             if (log)
                 log->Printf("Resolving the containing context's origin...");
@@ -1705,7 +1717,7 @@
                 
             DeclContextLookupConstResult original_lookup_result = original_ctx->getExternalSource()->FindExternalVisibleDeclsByName(original_decl_context, context.m_decl_name);
                         
-            NamedDecl *const *iter;
+            NamedDecl *const *iter = NULL;
             
             for (iter = original_lookup_result.first;
                  iter != original_lookup_result.second;
@@ -1854,7 +1866,7 @@
             
             m_struct_vars->m_object_pointer_type = this_user_type;
             
-            void *pointer_target_type;
+            void *pointer_target_type = NULL;
             
             if (!ClangASTContext::IsPointerType(this_user_type.GetOpaqueQualType(),
                                                 &pointer_target_type))
@@ -1903,10 +1915,11 @@
             
             m_struct_vars->m_object_pointer_type = self_user_type;
 
-            void *pointer_target_type;
+            void *pointer_target_type = NULL;
         
             if (!ClangASTContext::IsPointerType(self_user_type.GetOpaqueQualType(),
                                                 &pointer_target_type))
+                || pointer_target_type == NULL)
                 return;
         
             TypeFromUser class_user_type(pointer_target_type,
@@ -2063,7 +2076,7 @@
         return NULL;
     }
         
-    void *type_to_use;
+    void *type_to_use = NULL;
     
     if (parser_ast_context)
     {
@@ -2383,9 +2396,9 @@
     
     lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
     
-    NamedDecl *fun_decl;
+    NamedDecl *fun_decl = NULL;
     std::auto_ptr<Value> fun_location(new Value);
-    const Address *fun_address;
+    const Address *fun_address = NULL;
     
     // only valid for Functions, not for Symbols
     void *fun_opaque_type = NULL;

Modified: lldb/tags/lldb-69/source/Symbol/ClangASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/tags/lldb-69/source/Symbol/ClangASTContext.cpp?rev=134716&r1=134715&r2=134716&view=diff
==============================================================================
--- lldb/tags/lldb-69/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/tags/lldb-69/source/Symbol/ClangASTContext.cpp Fri Jul  8 13:29:48 2011
@@ -4087,7 +4087,7 @@
                 break;
                 
             case clang::Type::Typedef:
-                return ClangASTContext::IsPossibleCPlusPlusDynamicType (ast, cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(), dynamic_pointee_type);
+                return ClangASTContext::IsPossibleDynamicType (ast, cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(), dynamic_pointee_type);
                 
             default:
                 break;
@@ -4382,8 +4382,11 @@
 }
 
 bool
-ClangASTContext::IsPointerType (clang_type_t clang_type, clang_type_t*target_type)
+ClangASTContext::IsPointerType (clang_type_t clang_type, clang_type_t *target_type)
 {
+    if (target_type)
+        *target_type = NULL;
+
     if (clang_type)
     {
         QualType qual_type (QualType::getFromOpaquePtr(clang_type));
@@ -4417,7 +4420,7 @@
                 *target_type = cast<MemberPointerType>(qual_type)->getPointeeType().getAsOpaquePtr();
             return true;
         case clang::Type::Typedef:
-            return ClangASTContext::IsPointerOrReferenceType (cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(), target_type);
+            return ClangASTContext::IsPointerType (cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(), target_type);
         default:
             break;
         }





More information about the lldb-commits mailing list