[llvm-branch-commits] [lldb] r270117 - Fixed a problem where the DWARF for inline functions was mis-parsed.

Francis Ricci via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu May 19 13:43:26 PDT 2016


Author: fjricci
Date: Thu May 19 15:43:26 2016
New Revision: 270117

URL: http://llvm.org/viewvc/llvm-project?rev=270117&view=rev
Log:
Fixed a problem where the DWARF for inline functions was mis-parsed.

Inline functions in DWARF have AT_abstract_origin set, but we only handled that
if the functions were C++ methods.  Inline functions -- C or C++ -- have this
also, and as a result they got one FunctionDecl for each inlined instance.  When
going to construct the locals, this meant that the arguments (which did properly
have their abstract origins handled) would get associated with the master
FunctionDecl, and the inlined FunctionDecls would all appear to have no locals.

This manifested as not being able to look up local variables when stopped in an
inline fuunction.  We should have had a test for this, but somewhere along the
line the relevant test case lost its .py file (or it never had one).

This patch fixes this problem and restores the .py file.

<rdar://problem/24712434>

Author:    Sean Callanan <scallanan at apple.com>
Date:      Tue Feb 23 00:51:52 2016 +0000

This is a cherry-pick of r261598

Modified:
    lldb/branches/release_38/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

Modified: lldb/branches/release_38/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/release_38/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp?rev=270117&r1=270116&r2=270117&view=diff
==============================================================================
--- lldb/branches/release_38/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp (original)
+++ lldb/branches/release_38/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Thu May 19 15:43:26 2016
@@ -33,6 +33,7 @@
 #include "lldb/Symbol/TypeList.h"
 #include "lldb/Symbol/TypeMap.h"
 #include "lldb/Target/Language.h"
+#include "lldb/Utility/LLDBAssert.h"
 #include "Plugins/Language/ObjC/ObjCLanguage.h"
 
 #include "clang/AST/DeclCXX.h"
@@ -1491,44 +1492,72 @@ DWARFASTParserClang::ParseTypeFromDWARF
 
                         if (!type_handled)
                         {
-                            // We just have a function that isn't part of a class
-                            clang::FunctionDecl *function_decl = m_ast.CreateFunctionDeclaration (ignore_containing_context ? m_ast.GetTranslationUnitDecl() : containing_decl_ctx,
-                                                                                                  type_name_cstr,
-                                                                                                  clang_type,
-                                                                                                  storage,
-                                                                                                  is_inline);
-
-                            //                            if (template_param_infos.GetSize() > 0)
-                            //                            {
-                            //                                clang::FunctionTemplateDecl *func_template_decl = CreateFunctionTemplateDecl (containing_decl_ctx,
-                            //                                                                                                              function_decl,
-                            //                                                                                                              type_name_cstr,
-                            //                                                                                                              template_param_infos);
-                            //
-                            //                                CreateFunctionTemplateSpecializationInfo (function_decl,
-                            //                                                                          func_template_decl,
-                            //                                                                          template_param_infos);
-                            //                            }
-                            // Add the decl to our DIE to decl context map
-                            assert (function_decl);
-                            LinkDeclContextToDIE(function_decl, die);
-                            if (!function_param_decls.empty())
-                                m_ast.SetFunctionParameters (function_decl,
-                                                             &function_param_decls.front(),
-                                                             function_param_decls.size());
-
-                            ClangASTMetadata metadata;
-                            metadata.SetUserID(die.GetID());
+                            clang::FunctionDecl *function_decl = nullptr;
+                            
+                            if (abstract_origin_die_form.IsValid())
+                            {
+                                DWARFDIE abs_die = dwarf->DebugInfo()->GetDIE (DIERef(abstract_origin_die_form));
+
+                                SymbolContext sc;
+                                
+                                if (dwarf->ResolveType (abs_die))
+                                {
+                                    function_decl = llvm::dyn_cast_or_null<clang::FunctionDecl>(GetCachedClangDeclContextForDIE(abs_die));
+                            
+                                    if (function_decl)
+                                    {
+                                        LinkDeclContextToDIE(function_decl, die);
+                                    }
+                                }
+                            }
 
-                            if (!object_pointer_name.empty())
+                            if (!function_decl)
                             {
-                                metadata.SetObjectPtrName(object_pointer_name.c_str());
-                                if (log)
-                                    log->Printf ("Setting object pointer name: %s on function object %p.",
-                                                 object_pointer_name.c_str(),
-                                                 static_cast<void*>(function_decl));
+                                // We just have a function that isn't part of a class
+                                function_decl = m_ast.CreateFunctionDeclaration (ignore_containing_context ? m_ast.GetTranslationUnitDecl() : containing_decl_ctx,
+                                                                                                      type_name_cstr,
+                                                                                                      clang_type,
+                                                                                                      storage,
+                                                                                                      is_inline);
+
+                                //                            if (template_param_infos.GetSize() > 0)
+                                //                            {
+                                //                                clang::FunctionTemplateDecl *func_template_decl = CreateFunctionTemplateDecl (containing_decl_ctx,
+                                //                                                                                                              function_decl,
+                                //                                                                                                              type_name_cstr,
+                                //                                                                                                              template_param_infos);
+                                //
+                                //                                CreateFunctionTemplateSpecializationInfo (function_decl,
+                                //                                                                          func_template_decl,
+                                //                                                                          template_param_infos);
+                                //                            }
+                                // Add the decl to our DIE to decl context map
+                                
+                                lldbassert (function_decl);
+                                
+                                if (function_decl)
+                                {
+                                    LinkDeclContextToDIE(function_decl, die);
+                                    
+                                    if (!function_param_decls.empty())
+                                        m_ast.SetFunctionParameters (function_decl,
+                                                                     &function_param_decls.front(),
+                                                                     function_param_decls.size());
+                                    
+                                    ClangASTMetadata metadata;
+                                    metadata.SetUserID(die.GetID());
+                                    
+                                    if (!object_pointer_name.empty())
+                                    {
+                                        metadata.SetObjectPtrName(object_pointer_name.c_str());
+                                        if (log)
+                                            log->Printf ("Setting object pointer name: %s on function object %p.",
+                                                         object_pointer_name.c_str(),
+                                                         static_cast<void*>(function_decl));
+                                    }
+                                    m_ast.SetMetadata (function_decl, metadata);
+                                }
                             }
-                            m_ast.SetMetadata (function_decl, metadata);
                         }
                     }
                     type_sp.reset( new Type (die.GetID(),




More information about the llvm-branch-commits mailing list