[Lldb-commits] [lldb] e98ef0a - [lldb] Fix several LLDB_LOGs with wrong indices in ClangASTSource.cpp

Raphael “Teemperor” Isemann via lldb-commits lldb-commits at lists.llvm.org
Wed Mar 4 10:56:16 PST 2020


Yeah this whole thing is a disaster and it’s puzzling that we don’t test the whole logging but instead just crash on the end user machine. I’m currently writing a test that gives all this code at least coverage and then I guess we have to fix all of these bugs.

> On Mar 4, 2020, at 10:53 AM, Shafik Yaghmour <syaghmour at apple.com> wrote:
> 
> This is a lot of errors, did it the index use to start at one before? 
> 
> There is a type below, noted inline
> 
>> On Mar 4, 2020, at 10:33 AM, Raphael Isemann via lldb-commits <lldb-commits at lists.llvm.org> wrote:
>> 
>> 
>> Author: Raphael Isemann
>> Date: 2020-03-04T10:32:50-08:00
>> New Revision: e98ef0af2c725f12dc60556a039e947ddeeb9f42
>> 
>> URL: https://github.com/llvm/llvm-project/commit/e98ef0af2c725f12dc60556a039e947ddeeb9f42
>> DIFF: https://github.com/llvm/llvm-project/commit/e98ef0af2c725f12dc60556a039e947ddeeb9f42.diff
>> 
>> LOG: [lldb] Fix several LLDB_LOGs with wrong indices in ClangASTSource.cpp
>> 
>> Added: 
>> 
>> 
>> Modified: 
>>   lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
>> 
>> Removed: 
>> 
>> 
>> 
>> ################################################################################
>> diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
>> index 4d98d9cbdda3..6a8c7bd46559 100644
>> --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
>> +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
>> @@ -190,8 +190,8 @@ void ClangASTSource::CompleteType(TagDecl *tag_decl) {
>> 
>>  if (log) {
>>    LLDB_LOG(log,
>> -             "    CompleteTagDecl on (ASTContext*){1} Completing "
>> -             "(TagDecl*){2} named {3}",
>> +             "    CompleteTagDecl on (ASTContext*){0} Completing "
>> +             "(TagDecl*){1} named {2}",
>>             m_clang_ast_context->getDisplayName(), tag_decl,
>>             tag_decl->getName());
>> 
>> @@ -220,7 +220,7 @@ void ClangASTSource::CompleteType(TagDecl *tag_decl) {
>>      ClangASTImporter::NamespaceMapSP namespace_map =
>>          m_ast_importer_sp->GetNamespaceMap(namespace_context);
>> 
>> -      LLDB_LOGV(log, "      CTD Inspecting namespace map{1} ({2} entries)",
>> +      LLDB_LOGV(log, "      CTD Inspecting namespace map{0} ({1} entries)",
>>                namespace_map.get(), namespace_map->size());
>> 
>>      if (!namespace_map)
>> @@ -229,7 +229,7 @@ void ClangASTSource::CompleteType(TagDecl *tag_decl) {
>>      for (ClangASTImporter::NamespaceMap::iterator i = namespace_map->begin(),
>>                                                    e = namespace_map->end();
>>           i != e && !found; ++i) {
>> -        LLDB_LOG(log, "      CTD Searching namespace {1} in module {2}",
>> +        LLDB_LOG(log, "      CTD Searching namespace {0} in module {1}",
>>                 i->second.GetName(), i->first->GetFileSpec().GetFilename());
>> 
>>        TypeList types;
>> @@ -478,12 +478,12 @@ void ClangASTSource::FindExternalLexicalDecls(
>>        std::string ast_dump = ClangUtil::DumpDecl(decl);
>>        if (const NamedDecl *context_named_decl =
>>                dyn_cast<NamedDecl>(context_decl))
>> -          LLDB_LOG(log, "  FELD Adding [to {1}Decl {2}] lexical {3}Decl {4}",
>> +          LLDB_LOG(log, "  FELD Adding [to {0}Decl {1}] lexical {2}Decl 34}”,
> 
> 
> Typo should be {3} not 34}
> 
> 
>>                   context_named_decl->getDeclKindName(),
>>                   context_named_decl->getName(), decl->getDeclKindName(),
>>                   ast_dump);
>>        else
>> -          LLDB_LOG(log, "  FELD Adding lexical {1}Decl {2}",
>> +          LLDB_LOG(log, "  FELD Adding lexical {0}Decl {1}",
>>                   decl->getDeclKindName(), ast_dump);
>>      }
>> 
>> @@ -527,19 +527,19 @@ void ClangASTSource::FindExternalVisibleDecls(NameSearchContext &context) {
>>    if (!context.m_decl_context)
>>      LLDB_LOG(log,
>>               "ClangASTSource::FindExternalVisibleDecls on "
>> -               "(ASTContext*){1} '{2}' for '{3}' in a NULL DeclContext",
>> +               "(ASTContext*){0} '{1}' for '{2}' in a NULL DeclContext",
>>               m_ast_context, m_clang_ast_context->getDisplayName(), name);
>>    else if (const NamedDecl *context_named_decl =
>>                 dyn_cast<NamedDecl>(context.m_decl_context))
>>      LLDB_LOG(log,
>>               "ClangASTSource::FindExternalVisibleDecls on "
>> -               "(ASTContext*){1} '{2}' for '{3}' in '{4}'",
>> +               "(ASTContext*){0} '{1}' for '{2}' in '{3}'",
>>               m_ast_context, m_clang_ast_context->getDisplayName(), name,
>>               context_named_decl->getName());
>>    else
>>      LLDB_LOG(log,
>>               "ClangASTSource::FindExternalVisibleDecls on "
>> -               "(ASTContext*){1} '{2}' for '{3}' in a '{4}'",
>> +               "(ASTContext*){0} '{1}' for '{2}' in a '{3}'",
>>               m_ast_context, m_clang_ast_context->getDisplayName(), name,
>>               context.m_decl_context->getDeclKindName());
>>  }
>> @@ -631,7 +631,7 @@ void ClangASTSource::FindExternalVisibleDecls(
>>      if (log) {
>>        const char *name_string = type_sp->GetName().GetCString();
>> 
>> -        LLDB_LOG(log, "  CAS::FEVD Matching type found for \"{1}\": {2}", name,
>> +        LLDB_LOG(log, "  CAS::FEVD Matching type found for \"{0}\": {1}", name,
>>                 (name_string ? name_string : "<anonymous>"));
>>      }
>> 
>> @@ -682,7 +682,7 @@ void ClangASTSource::FillNamespaceMap(
>>            std::pair<lldb::ModuleSP, CompilerDeclContext>(
>>                module_sp, found_namespace_decl));
>> 
>> -        LLDB_LOG(log, "  CAS::FEVD Found namespace {1} in module {2}", name,
>> +        LLDB_LOG(log, "  CAS::FEVD Found namespace {0} in module {1}", name,
>>                 module_sp->GetFileSpec().GetFilename());
>>      }
>>    }
>> @@ -712,7 +712,7 @@ void ClangASTSource::FillNamespaceMap(
>>          std::pair<lldb::ModuleSP, CompilerDeclContext>(image,
>>                                                         found_namespace_decl));
>> 
>> -      LLDB_LOG(log, "  CAS::FEVD Found namespace {1} in module {2}", name,
>> +      LLDB_LOG(log, "  CAS::FEVD Found namespace {0} in module {1}", name,
>>               image->GetFileSpec().GetFilename());
>>    }
>>  }
>> @@ -841,7 +841,7 @@ bool ClangASTSource::FindObjCMethodDeclsWithOrigin(
>> 
>>    Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
>> 
>> -    LLDB_LOG(log, "  CAS::FOMD found ({1}) {2}", log_info,
>> +    LLDB_LOG(log, "  CAS::FOMD found ({0}) {1}", log_info,
>>             ClangUtil::DumpDecl(copied_method_decl));
>> 
>>    context.AddNamedDecl(copied_method_decl);
>> @@ -866,7 +866,7 @@ void ClangASTSource::FindDeclInModules(NameSearchContext &context,
>>  if (!modules_decl_vendor->FindDecls(name, append, max_matches, decls))
>>    return;
>> 
>> -  LLDB_LOG(log, "  CAS::FEVD Matching entity found for \"{1}\" in the modules",
>> +  LLDB_LOG(log, "  CAS::FEVD Matching entity found for \"{0}\" in the modules",
>>           name);
>> 
>>  clang::NamedDecl *const decl_from_modules = decls[0];
>> @@ -981,8 +981,8 @@ void ClangASTSource::FindObjCMethodDecls(NameSearchContext &context) {
>>  ConstString selector_name(ss.GetString());
>> 
>>  LLDB_LOG(log,
>> -           "ClangASTSource::FindObjCMethodDecls on (ASTContext*){1} '{2}' "
>> -           "for selector [{3} {4}]",
>> +           "ClangASTSource::FindObjCMethodDecls on (ASTContext*){0} '{1}' "
>> +           "for selector [{2} {3}]",
>>           m_ast_context, m_clang_ast_context->getDisplayName(),
>>           interface_decl->getName(), selector_name);
>>  SymbolContextList sc_list;
>> @@ -1104,7 +1104,7 @@ void ClangASTSource::FindObjCMethodDecls(NameSearchContext &context) {
>>        if (!copied_method_decl)
>>          continue;
>> 
>> -        LLDB_LOG(log, "  CAS::FOMD found (in symbols)\n{1}",
>> +        LLDB_LOG(log, "  CAS::FOMD found (in symbols)\n{0}",
>>                 ClangUtil::DumpDecl(copied_method_decl));
>> 
>>        context.AddNamedDecl(copied_method_decl);
>> @@ -1134,7 +1134,7 @@ void ClangASTSource::FindObjCMethodDecls(NameSearchContext &context) {
>> 
>>    LLDB_LOG(log,
>>             "CAS::FOPD trying origin "
>> -             "(ObjCInterfaceDecl*){1}/(ASTContext*){2}...",
>> +             "(ObjCInterfaceDecl*){0}/(ASTContext*){1}...",
>>             complete_interface_decl, &complete_iface_decl->getASTContext());
>> 
>>    FindObjCMethodDeclsWithOrigin(context, complete_interface_decl,
>> @@ -1233,7 +1233,7 @@ static bool FindObjCPropertyAndIvarDeclsWithOrigin(
>>    DeclFromParser<ObjCPropertyDecl> parser_property_decl(
>>        origin_property_decl.Import(source));
>>    if (parser_property_decl.IsValid()) {
>> -      LLDB_LOG(log, "  CAS::FOPD found\n{1}",
>> +      LLDB_LOG(log, "  CAS::FOPD found\n{0}",
>>               ClangUtil::DumpDecl(parser_property_decl.decl));
>> 
>>      context.AddNamedDecl(parser_property_decl.decl);
>> @@ -1248,7 +1248,7 @@ static bool FindObjCPropertyAndIvarDeclsWithOrigin(
>>    DeclFromParser<ObjCIvarDecl> parser_ivar_decl(
>>        origin_ivar_decl.Import(source));
>>    if (parser_ivar_decl.IsValid()) {
>> -      LLDB_LOG(log, "  CAS::FOPD found\n{1}",
>> +      LLDB_LOG(log, "  CAS::FOPD found\n{0}",
>>               ClangUtil::DumpDecl(parser_ivar_decl.decl));
>> 
>>      context.AddNamedDecl(parser_ivar_decl.decl);
>> @@ -1271,7 +1271,7 @@ void ClangASTSource::FindObjCPropertyAndIvarDecls(NameSearchContext &context) {
>> 
>>  LLDB_LOG(log,
>>           "ClangASTSource::FindObjCPropertyAndIvarDecls on "
>> -           "(ASTContext*){1} '{2}' for '{3}.{4}'",
>> +           "(ASTContext*){0} '{1}' for '{2}.{3}'",
>>           m_ast_context, m_clang_ast_context->getDisplayName(),
>>           parser_iface_decl->getName(), context.m_decl_name.getAsString());
>> 
>> @@ -1280,7 +1280,7 @@ void ClangASTSource::FindObjCPropertyAndIvarDecls(NameSearchContext &context) {
>> 
>>  LLDB_LOG(log,
>>           "CAS::FOPD couldn't find the property on origin "
>> -           "(ObjCInterfaceDecl*){1}/(ASTContext*){2}, searching "
>> +           "(ObjCInterfaceDecl*){0}/(ASTContext*){1}, searching "
>>           "elsewhere...",
>>           origin_iface_decl.decl, &origin_iface_decl->getASTContext());
>> 
>> @@ -1305,7 +1305,7 @@ void ClangASTSource::FindObjCPropertyAndIvarDecls(NameSearchContext &context) {
>> 
>>    LLDB_LOG(log,
>>             "CAS::FOPD trying origin "
>> -             "(ObjCInterfaceDecl*){1}/(ASTContext*){2}...",
>> +             "(ObjCInterfaceDecl*){0}/(ASTContext*){1}...",
>>             complete_iface_decl.decl, &complete_iface_decl->getASTContext());
>> 
>>    FindObjCPropertyAndIvarDeclsWithOrigin(context, *this, complete_iface_decl);
>> @@ -1338,7 +1338,7 @@ void ClangASTSource::FindObjCPropertyAndIvarDecls(NameSearchContext &context) {
>> 
>>    LLDB_LOG(log,
>>             "CAS::FOPD[{0}] trying module "
>> -             "(ObjCInterfaceDecl*){1}/(ASTContext*){2}...",
>> +             "(ObjCInterfaceDecl*){0}/(ASTContext*){1}...",
>>             interface_decl_from_modules.decl,
>>             &interface_decl_from_modules->getASTContext());
>> 
>> @@ -1382,7 +1382,7 @@ void ClangASTSource::FindObjCPropertyAndIvarDecls(NameSearchContext &context) {
>> 
>>    LLDB_LOG(log,
>>             "CAS::FOPD[{0}] trying runtime "
>> -             "(ObjCInterfaceDecl*){1}/(ASTContext*){2}...",
>> +             "(ObjCInterfaceDecl*){0}/(ASTContext*){1}...",
>>             interface_decl_from_runtime.decl,
>>             &interface_decl_from_runtime->getASTContext());
>> 
>> @@ -1401,7 +1401,7 @@ void ClangASTSource::LookupInNamespace(NameSearchContext &context) {
>>  ClangASTImporter::NamespaceMapSP namespace_map =
>>      m_ast_importer_sp->GetNamespaceMap(namespace_context);
>> 
>> -  LLDB_LOGV(log, "  CAS::FEVD Inspecting namespace map {1} ({2} entries)",
>> +  LLDB_LOGV(log, "  CAS::FEVD Inspecting namespace map {0} ({1} entries)",
>>            namespace_map.get(), namespace_map->size());
>> 
>>  if (!namespace_map)
>> @@ -1410,7 +1410,7 @@ void ClangASTSource::LookupInNamespace(NameSearchContext &context) {
>>  for (ClangASTImporter::NamespaceMap::iterator i = namespace_map->begin(),
>>                                                e = namespace_map->end();
>>       i != e; ++i) {
>> -    LLDB_LOG(log, "  CAS::FEVD Searching namespace {1} in module {2}",
>> +    LLDB_LOG(log, "  CAS::FEVD Searching namespace {0} in module {1}",
>>             i->second.GetName(), i->first->GetFileSpec().GetFilename());
>> 
>>    FindExternalVisibleDecls(context, i->first, i->second);
>> @@ -1506,7 +1506,7 @@ bool ClangASTSource::layoutRecordType(const RecordDecl *record, uint64_t &size,
>>  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
>> 
>>  LLDB_LOG(log,
>> -           "LayoutRecordType on (ASTContext*){1} '{2}' for (RecordDecl*)"
>> +           "LayoutRecordType on (ASTContext*){0} '{1}' for (RecordDecl*)"
>>           "{3} [name = '{4}']",
>>           m_ast_context, m_clang_ast_context->getDisplayName(), record,
>>           record->getName());
>> @@ -1583,7 +1583,7 @@ bool ClangASTSource::layoutRecordType(const RecordDecl *record, uint64_t &size,
>>                                    fe = record->field_end();
>>         fi != fe; ++fi) {
>>      LLDB_LOG(log,
>> -               "LRT[{0}]     (FieldDecl*){1}, Name = '{2}', Offset = {3} bits",
>> +               "LRT     (FieldDecl*){0}, Name = '{1}', Offset = {2} bits",
>>               *fi, fi->getName(), field_offsets[*fi]);
>>    }
>>    DeclFromParser<const CXXRecordDecl> parser_cxx_record =
>> @@ -1603,8 +1603,8 @@ bool ClangASTSource::layoutRecordType(const RecordDecl *record, uint64_t &size,
>>            DynCast<CXXRecordDecl>(base_record);
>> 
>>        LLDB_LOG(log,
>> -                 "LRT     {1}(CXXRecordDecl*){2}, Name = '{3}', Offset = "
>> -                 "{4} chars",
>> +                 "LRT     {0}(CXXRecordDecl*){1}, Name = '{2}', Offset = "
>> +                 "{3} chars",
>>                 (is_virtual ? "Virtual " : ""), base_cxx_record.decl,
>>                 base_cxx_record.decl->getName(),
>>                 (is_virtual
>> @@ -1628,14 +1628,14 @@ void ClangASTSource::CompleteNamespaceMap(
>>  if (log) {
>>    if (parent_map && parent_map->size())
>>      LLDB_LOG(log,
>> -               "CompleteNamespaceMap on (ASTContext*){1} '{2}' Searching "
>> -               "for namespace {3} in namespace {4}",
>> +               "CompleteNamespaceMap on (ASTContext*){0} '{1}' Searching "
>> +               "for namespace {2} in namespace {3}",
>>               m_ast_context, m_clang_ast_context->getDisplayName(), name,
>>               parent_map->begin()->second.GetName());
>>    else
>>      LLDB_LOG(log,
>> -               "CompleteNamespaceMap on (ASTContext*){1} '{2}' Searching "
>> -               "for namespace {3}",
>> +               "CompleteNamespaceMap on (ASTContext*){0} '{1}' Searching "
>> +               "for namespace {2}",
>>               m_ast_context, m_clang_ast_context->getDisplayName(), name);
>>  }
>> 
>> @@ -1662,7 +1662,7 @@ void ClangASTSource::CompleteNamespaceMap(
>>      namespace_map->push_back(std::pair<lldb::ModuleSP, CompilerDeclContext>(
>>          module_sp, found_namespace_decl));
>> 
>> -      LLDB_LOG(log, "  CMN Found namespace {1} in module {2}", name,
>> +      LLDB_LOG(log, "  CMN Found namespace {0} in module {1}", name,
>>               module_sp->GetFileSpec().GetFilename());
>>    }
>>  } else {
>> @@ -1693,7 +1693,7 @@ void ClangASTSource::CompleteNamespaceMap(
>>      namespace_map->push_back(std::pair<lldb::ModuleSP, CompilerDeclContext>(
>>          image, found_namespace_decl));
>> 
>> -      LLDB_LOG(log, "  CMN[{0}] Found namespace {1} in module {2}", name,
>> +      LLDB_LOG(log, "  CMN[{0}] Found namespace {0} in module {1}", name,
>>               image->GetFileSpec().GetFilename());
>>    }
>>  }
>> 
>> 
>> 
>> _______________________________________________
>> lldb-commits mailing list
>> lldb-commits at lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200304/bcc5979a/attachment-0001.html>


More information about the lldb-commits mailing list