Author: spyffe Date: Mon Feb 22 18:51:52 2016 New Revision: 261598 URL: http://llvm.org/viewvc/llvm-project?rev=261598&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> Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp?rev=261598&r1=261597&r2=261598&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Mon Feb 22 18:51:52 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" @@ -1515,44 +1516,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(), _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits