This is an archive of the discontinued LLVM Phabricator instance.

[llvm-dwarfdump] - Change format for .gdb_index dump.
ClosedPublic

Authored by grimar on Apr 25 2017, 8:34 AM.

Details

Summary

During investigation of PR32319,
I found that it is useful to output size when address ranges
are dumped. It is useful when comparing outputs produced
by different linkers.

In that case address ranges can look very different, when they are the same at fact.
Difference comes from different low address because of different address of .text.
Examples below.

Dumped gold output of llc binary (with patch):

Low/High address = [0x120c576, 0x1215df8] (Size: 0x9882), CU id = 0
Low/High address = [0x1215df8, 0x1215e0a] (Size: 0x12), CU id = 0
Low/High address = [0x1215e0a, 0x1215e45] (Size: 0x3b), CU id = 0

Dumped LLD output for the same place (with patch):

Low/High address = [0x31f80f6, 0x3201978] (Size: 0x9882), CU id = 0
Low/High address = [0x3201978, 0x320198a] (Size: 0x12), CU id = 0
Low/High address = [0x320198a, 0x32019c5] (Size: 0x3b), CU id = 0

And without this patch output does not allow to find out that ranges are the same in a fast way:

Low address = 0x120c576, High address = 0x1215df8, CU index = 0
Low address = 0x1215df8, High address = 0x1215e0a, CU index = 0
Low address = 0x1215e0a, High address = 0x1215e45, CU index = 0

vs

Low address = 0x31f80f6, High address = 0x3201978, CU index = 0
Low address = 0x3201978, High address = 0x320198a, CU index = 0
Low address = 0x320198a, High address = 0x32019c5, CU index = 0

Diff Detail

Repository
rL LLVM

Event Timeline

grimar created this revision.Apr 25 2017, 8:34 AM
dblaikie accepted this revision.Apr 25 2017, 11:04 AM
dblaikie added inline comments.
lib/DebugInfo/DWARF/DWARFGdbIndex.cpp
42 ↗(On Diff #96570)

While you're here, probably makes sense to fix the range to render as [x, y) rather than [x, y] ? (since it's a half open range, if I recall correctly)

This revision is now accepted and ready to land.Apr 25 2017, 11:04 AM
grimar added inline comments.Apr 26 2017, 3:31 AM
lib/DebugInfo/DWARF/DWARFGdbIndex.cpp
42 ↗(On Diff #96570)

I am not sure I understand why it is half open. If I got your idea correctly then probably output would be:

[a, b) (c, d) (e, f) (g, h]

But I do not think it would be correct.
.gdb_index format (https://sourceware.org/gdb/onlinedocs/gdb/Index-Section-Format.html) defines address area as:

The address area. The address area consists of a sequence of address entries. Each address entry has three elements:
The low address. This is a 64-bit little-endian value.
The high address. This is a 64-bit little-endian value. Like DW_AT_high_pc, the value is one byte beyond the end.
The CU index. This is an offset_type value.

So we have set of elements that have begining and end marks. It looks to be set of closed segments/snippets, if I am not missing something, so I think [x, y] is more appropriate then.

I was interested how readelf dumps the .gdb_index for the same file used in testcase.
It was:
readelf --debug-dump=gdb_index dwarfdump-gdbindex-v7.elf-x86-64

Contents of the .gdb_index section:
Version 7

CU table:
[  0] 0x0 - 0x33
[  1] 0x34 - 0x67

TU table:

Address table:
00000000004000e8 00000000004000f3 0
00000000004000f3 00000000004000fe 1

Symbol table:
[489] main: 0 [global, function]
[754] int:
	0 [static, type]
	1 [static, type]
[956] main2: 1 [global, function]

Basing on above I can suggest 2 solutions:

  1. Leave [x, y] as is.
  2. Change dump output to something that avoids use of []() if that can be confusing, for example to:
Address area offset = 0x38, has 2 entries:
0x4000e8 - 0x4000f3, Size = 0xb, CU id = 0
0x4000f3 - 0x4000fe, Size = 0xb, CU id = 1

What do you think ?

This revision was automatically updated to reflect the committed changes.