Page MenuHomePhabricator

DWZ 03/11: Separate Offset also into FileOffset
AbandonedPublic

Authored by jankratochvil on Nov 26 2017, 5:05 AM.

Details

Reviewers
clayborg
labath
Summary

Offset may represent virtual DW_TAG_partial_unit remapping while FileOffset always represents the file data. Units are ordered:

Offset 0FileOffset 0 of DWZ file (if exists)
Offset {DWZ file size}FileOffset 0 of main file
Offset {DWZ file size + main file size}First remapped DW_TAG_partial_unit

All DWZ patches are also applied in: git clone -b dwz git://git.jankratochvil.net/lldb

Diff Detail

Event Timeline

jankratochvil created this revision.Nov 26 2017, 5:05 AM
jankratochvil retitled this revision from DWZ: Separate Offset also into FileOffset to DWZ 04/12: Separate Offset also into FileOffset.
clayborg edited edge metadata.Nov 27 2017, 10:17 AM

It would be much easier to read this patch if there were no renames from "*offset" to "*file_offset". Can we remove these extra renames where it isn't needed?

source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
15

Why is this added here? Doesn't seem to be needed, or it should be moved to .cpp file?

jankratochvil marked an inline comment as done.Nov 29 2017, 12:52 PM
jankratochvil added inline comments.
source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
15

Yes, a patch split up typo, sorry.

jankratochvil marked an inline comment as done.

Removed excessive: #include: <mutex>

clayborg requested changes to this revision.Nov 29 2017, 1:47 PM

Please undo all renaming from offset to file_offset. The "offset" you get from a DIE should always be the absolute .debug_info offset. No need to say file_offset. Patch will be easier to read after spurious renames are removed.

include/lldb/Expression/DWARFExpression.h
221–223

don't rename, revert

source/Expression/DWARFExpression.cpp
92–94

don't rename, revert

source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp
54

Why is this not just done correctly inside DIEOffsetAtIndex? No need to rename the variable.

56

don't rename.

source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
78–97

Not a fan of these names. Can't these just be something like:

dw_offset_t GeCUtRelativeOffset(); // CU relative offset
dw_offset_t GetOffset(); // Always absolute .debug_info offset

ThisCUUniqToFileOffset seems a bit unclear.

This revision now requires changes to proceed.Nov 29 2017, 1:47 PM

Please undo all renaming from offset to file_offset.

I am preparing now a split of this patch for the renaming part + the "real" part, sorry I did not realize it is mostly about the renaming which is not worth your detailed review.

There are two different types of offsets:

UniqOffsetOne DIE from a DW_TAG_partial_unit gets two different UniqOffset depending from which DW_TAG_compile_unit it was included
FileOffsetOne DIE from a DW_TAG_partial_unit has only one FileOffset - where one can read it from get_debug_info_data()

Most of LLDB works with UniqOffset so I kept the original dw_offset_t offset type+name for it. When LLDB works with FileOffset I call it dw_offset_t file_offset. I really discourage calling these two different offset types the same as it is a bug (although affecting only DWZ files) if there is missing a proper conversion function between these two types.

I found overengineered to make a separate type-safe against accidental exchange wrapper class for the `FileOffset' but I can if you prefer that over a simple renaming of all the variables/parameters.

D40474 introduces DWARFFileOffset which makes it type-safe against accidental exchange with dw_offset_t but that type includes also bool is_dwz whether it is in DWZ Common File or in the main symbol file which makes it excessive for the places where currently I used dw_offset_t file_offset because the file itself is known there.

The "offset" you get from a DIE should always be the absolute .debug_info offset. No need to say file_offset.

We never talk about CU-relative offset. I made remapping in DWARFDebugInfoEntry:

dw_offset_t GetOffset() renamed toFileOffset-kind dw_offset_t GetFileOffset()
newUniqOffset-kind dw_offset_t GetOffset(const DWARFCompileUnit *cu)
source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
78–97

What should be dw_offset_t GeCUtRelativeOffset(); // CU relative offset?
This patchset never deals with offsets relative to the CU start (and LLDB never uses such offsets, DWARFCompileUnit::ExtractDIEsIfNeeded stores their .debug_info-relative offsets and DWARFFormValue::Reference() also converts everything into .debug_info-relative offsets.

UniqOffset -> FileOffsetDWARFDebugInfo::GetCompileUnit{,ContainingDIEOffset}slow m_compile_units bisecting
UniqOffset -> FileOffsetDWARFCompileUnit::ThisCUUniqToFileOffsetfast but the CU must match
FileOffset -> UniqOffsetDWARFCompileUnit::ThisCUFileOffsetToUniqfast, this functionality requires to use matching CU

UniqOffset is in the most simple case without using DWZ the same as FileOffset. If DWZ is used then see the mapping in Summary above.
The methods cannot be called `Get' as they convert their parameter value, they are not getters.

jankratochvil retitled this revision from DWZ 04/12: Separate Offset also into FileOffset to DWZ 03/11: Separate Offset also into FileOffset.
jankratochvil planned changes to this revision.Apr 14 2018, 4:21 AM
jankratochvil abandoned this revision.Apr 22 2018, 11:08 AM

Without FileOffset and the remapping to unique DIE offsets for each DW_TAG_partial_unit inclusion by DW_TAG_imported_unit this patch is no longer needed, as discussed in: https://lists.llvm.org/pipermail/lldb-commits/Week-of-Mon-20180409/040324.html