[Lldb-commits] [PATCH] Fixed parsing of the .debug_aranges section.

Greg Clayton gclayton at apple.com
Mon Sep 9 15:37:29 PDT 2013


I would change the std::set to use the dw_offset_t instead of the "DWARFCompileUnit *" and that way you can skip the compile unit lookup every time for each address range. Then the first loop becomes:

std::set<dw_offset_t> cus_with_data;
for (size_t n=0;n<m_cu_aranges_ap.get()->GetNumRanges();n++)
    cus_with_data.insert(m_cu_aranges_ap.get()->OffsetAtIndex(n));


Then inside the second loop which was this:


            if (cu && cus_with_data.find(cu) == cus_with_data.end())

becomes:

            if (cu && cus_with_data.find(cu->GetOffset()) == cus_with_data.end())



On Sep 5, 2013, at 11:15 AM, Richard Mitton <richard at codersnotes.com> wrote:

> Fixed parsing of the .debug_aranges section so that LLDB will still work correctly even if arange data is not available for every object file in the program.
> 
> This fixes the bug where a program built using a mix of gcc and clang would not be able to debug the clang parts.
> 
> http://llvm-reviews.chandlerc.com/D1609
> 
> Files:
>  source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
>  source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp
> 
> Index: source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
> ===================================================================
> --- source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
> +++ source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
> @@ -66,18 +66,37 @@
>             m_cu_aranges_ap->Extract (debug_aranges_data);
> 
>         }
> -        else
> +
> +        // Make a list of all CUs represented by the arange data in the file.
> +        std::set<DWARFCompileUnit *> cus_with_data;
> +        for (size_t n=0;n<m_cu_aranges_ap.get()->GetNumRanges();n++)
>         {
> -            if (log)
> -                log->Printf ("DWARFDebugInfo::GetCompileUnitAranges() for \"%s\" by parsing", 
> -                             m_dwarf2Data->GetObjectFile()->GetFileSpec().GetPath().c_str());
> -            const size_t num_compile_units = GetNumCompileUnits();
> -            const bool clear_dies_if_already_not_parsed = true;
> -            for (size_t idx = 0; idx < num_compile_units; ++idx)
> +            dw_offset_t offset = m_cu_aranges_ap.get()->OffsetAtIndex(n);
> +            if (offset != DW_INVALID_OFFSET)
>             {
> -                DWARFCompileUnit* cu = GetCompileUnitAtIndex(idx);
> -                if (cu)
> -                    cu->BuildAddressRangeTable (m_dwarf2Data, m_cu_aranges_ap.get(), clear_dies_if_already_not_parsed);
> +                DWARFCompileUnitSP cu = GetCompileUnit (offset);
> +                if (cu.get())
> +                    cus_with_data.insert (cu.get());
> +            }
> +        }
> +
> +        // Manually build arange data for everything that wasn't in the .debug_aranges table.
> +        bool printed = false;
> +        const size_t num_compile_units = GetNumCompileUnits();
> +        const bool clear_dies_if_already_not_parsed = true;
> +        for (size_t idx = 0; idx < num_compile_units; ++idx)
> +        {
> +            DWARFCompileUnit* cu = GetCompileUnitAtIndex(idx);
> +            if (cu && cus_with_data.find(cu) == cus_with_data.end())
> +            {
> +                if (log)
> +                {
> +                    if (!printed)
> +                        log->Printf ("DWARFDebugInfo::GetCompileUnitAranges() for \"%s\" by parsing",
> +                                     m_dwarf2Data->GetObjectFile()->GetFileSpec().GetPath().c_str());
> +                    printed = true;
> +                }
> +                cu->BuildAddressRangeTable (m_dwarf2Data, m_cu_aranges_ap.get(), clear_dies_if_already_not_parsed);
>             }
>         }
> 
> Index: source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp
> ===================================================================
> --- source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp
> +++ source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp
> @@ -174,10 +174,11 @@
> {
>     strm->Printf ("Logging categories for '%s':\n"
>                   "  all - turn on all available logging categories\n"
> -                  "  info - log the parsing if .debug_info\n"
> -                  "  line - log the parsing if .debug_line\n"
> -                  "  pubnames - log the parsing if .debug_pubnames\n"
> -                  "  pubtypes - log the parsing if .debug_pubtypes\n"
> +                  "  info - log the parsing of .debug_info\n"
> +                  "  line - log the parsing of .debug_line\n"
> +                  "  pubnames - log the parsing of .debug_pubnames\n"
> +                  "  pubtypes - log the parsing of .debug_pubtypes\n"
> +                  "  aranges - log the parsing of .debug_aranges\n"
>                   "  lookups - log any lookups that happen by name, regex, or address\n"
>                   "  completion - log struct/unions/class type completions\n"
>                   "  map - log insertions of object files into DWARF debug maps\n",
> <D1609.1.patch>_______________________________________________
> lldb-commits mailing list
> lldb-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits




More information about the lldb-commits mailing list