<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Wed, Apr 26, 2017 at 3:31 AM George Rimar via Phabricator <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">grimar added inline comments.<br>
<br>
<br>
================<br>
Comment at: lib/DebugInfo/DWARF/DWARFGdbIndex.cpp:42<br>
     OS << format(<br>
-        "    Low address = 0x%llx, High address = 0x%llx, CU index = %d\n",<br>
-        Addr.LowAddress, Addr.HighAddress, Addr.CuIndex);<br>
+        "    Low/High address = [0x%llx, 0x%llx] (Size: 0x%llx), CU id = %d\n",<br>
+        Addr.LowAddress, Addr.HighAddress, Addr.HighAddress - Addr.LowAddress,<br>
----------------<br>
dblaikie wrote:<br>
> 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)<br>
I am not sure I understand why it is half open. If I got your idea correctly then probably output would be:<br>
```<br>
[a, b) (c, d) (e, f) (g, h]<br></blockquote><div><br>Nah, more like:<br><br>[a, b)<br>[c, d)<br>[e, f)<br>[g, h)<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
```<br>
<br>
But I do not think it would be correct.<br>
.gdb_index format (<a href="https://sourceware.org/gdb/onlinedocs/gdb/Index-Section-Format.html" rel="noreferrer" target="_blank">https://sourceware.org/gdb/onlinedocs/gdb/Index-Section-Format.html</a>) defines address area as:<br>
> The address area. The address area consists of a sequence of address entries. Each address entry has three elements:<br>
> The low address. This is a 64-bit little-endian value.<br>
> The high address. This is a 64-bit little-endian value. Like DW_AT_high_pc, the value is one byte beyond the end.<br></blockquote><div><br>This bit here ^ "the value is one byte beyond the end" is what I mean by a half open range.<br><br>If a range in a range list includes bytes at offset/address 5, 6, 7, and 8. Then the range would be emitted as "5, 9" which is half open or written mathematically [5, 9)<br><br>( <a href="https://en.wikipedia.org/wiki/Interval_(mathematics)">https://en.wikipedia.org/wiki/Interval_(mathematics)</a> - "<span style="color:rgb(34,34,34);font-size:14px">A<span class="inbox-inbox-Apple-converted-space"> </span></span><b style="color:rgb(34,34,34);font-size:14px">half-open interval</b><span style="color:rgb(34,34,34);font-size:14px"><span class="inbox-inbox-Apple-converted-space"> </span>includes only one of its endpoints, and is denoted by mixing the notations for open and closed intervals.<span class="inbox-inbox-Apple-converted-space"> </span></span><span class="inbox-inbox-texhtml" style="font-feature-settings:'lnum' 1,'tnum' 1,'kern' 0;font-variant-numeric:lining-nums tabular-nums;font-kerning:none;font-family:"nimbus roman no9 l","times new roman",times,serif;font-size:16.52px;line-height:1;white-space:nowrap;color:rgb(34,34,34)">(0,1]</span><span style="color:rgb(34,34,34);font-size:14px"><span class="inbox-inbox-Apple-converted-space"> </span>means greater than<span class="inbox-inbox-Apple-converted-space"> </span></span><span class="inbox-inbox-texhtml" style="font-feature-settings:'lnum' 1,'tnum' 1,'kern' 0;font-variant-numeric:lining-nums tabular-nums;font-kerning:none;font-family:"nimbus roman no9 l","times new roman",times,serif;font-size:16.52px;line-height:1;white-space:nowrap;color:rgb(34,34,34)">0</span><span style="color:rgb(34,34,34);font-size:14px"><span class="inbox-inbox-Apple-converted-space"> </span>and less than or equal to<span class="inbox-inbox-Apple-converted-space"> </span></span><span class="inbox-inbox-texhtml" style="font-feature-settings:'lnum' 1,'tnum' 1,'kern' 0;font-variant-numeric:lining-nums tabular-nums;font-kerning:none;font-family:"nimbus roman no9 l","times new roman",times,serif;font-size:16.52px;line-height:1;white-space:nowrap;color:rgb(34,34,34)">1</span><span style="color:rgb(34,34,34);font-size:14px">, while<span class="inbox-inbox-Apple-converted-space"> </span></span><span class="inbox-inbox-texhtml" style="font-feature-settings:'lnum' 1,'tnum' 1,'kern' 0;font-variant-numeric:lining-nums tabular-nums;font-kerning:none;font-family:"nimbus roman no9 l","times new roman",times,serif;font-size:16.52px;line-height:1;white-space:nowrap;color:rgb(34,34,34)">[0,1)</span><span style="color:rgb(34,34,34);font-size:14px"><span class="inbox-inbox-Apple-converted-space"> </span>means greater than or equal to<span class="inbox-inbox-Apple-converted-space"> </span></span><span class="inbox-inbox-texhtml" style="font-feature-settings:'lnum' 1,'tnum' 1,'kern' 0;font-variant-numeric:lining-nums tabular-nums;font-kerning:none;font-family:"nimbus roman no9 l","times new roman",times,serif;font-size:16.52px;line-height:1;white-space:nowrap;color:rgb(34,34,34)">0</span><span style="color:rgb(34,34,34);font-size:14px"><span class="inbox-inbox-Apple-converted-space"> </span>and less than<span class="inbox-inbox-Apple-converted-space"> </span></span><span class="inbox-inbox-texhtml" style="font-feature-settings:'lnum' 1,'tnum' 1,'kern' 0;font-variant-numeric:lining-nums tabular-nums;font-kerning:none;font-family:"nimbus roman no9 l","times new roman",times,serif;font-size:16.52px;line-height:1;white-space:nowrap;color:rgb(34,34,34)">1</span><span style="color:rgb(34,34,34);font-size:14px">.")</span><br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
> The CU index. This is an offset_type value.<br>
><br>
<br>
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.<br>
<br>
I was interested how readelf dumps the .gdb_index for the same file used in testcase.<br>
It was:<br>
readelf --debug-dump=gdb_index dwarfdump-gdbindex-v7.elf-x86-64<br>
```<br>
Contents of the .gdb_index section:<br>
Version 7<br>
<br>
CU table:<br>
[  0] 0x0 - 0x33<br>
[  1] 0x34 - 0x67<br>
<br>
TU table:<br>
<br>
Address table:<br>
00000000004000e8 00000000004000f3 0<br>
00000000004000f3 00000000004000fe 1<br>
<br>
Symbol table:<br>
[489] main: 0 [global, function]<br>
[754] int:<br>
        0 [static, type]<br>
        1 [static, type]<br>
[956] main2: 1 [global, function]<br>
```<br>
<br>
Basing on above I can suggest 2 solutions:<br>
1) Leave [x, y] as is.<br>
2) Change dump output to something that avoids use of []() if that can be confusing, for example to:<br>
<br>
```<br>
Address area offset = 0x38, has 2 entries:<br>
0x4000e8 - 0x4000f3, Size = 0xb, CU id = 0<br>
0x4000f3 - 0x4000fe, Size = 0xb, CU id = 1<br>
```<br>
<br>
What do you think ?<br></blockquote><div><br>'-' could be ambiguous with the minus sign here.<br><br>Indeed llvm-dwarfdump uses the half open range notation [x, y) in the DW_AT_ranges dumping such as here:<br><br><div><font face="monospace">  DW_AT_ranges [DW_FORM_sec_offset] (0x00000000</font></div><div><font face="monospace">     [0x00000000004004f0 - 0x00000000004004f6)</font></div><div><font face="monospace">     [0x0000000000400500 - 0x0000000000400508))<br></font></div> <br>though it also uses - rather than ','... which is weird.<br><br>Adrian - what do you reckon we should standardize on here? I do sort of get the x - y syntax, but it seems a bit awkward when combined with the [x, y) syntax (which I also like, for clarity about the boundaries). I'd tend to lean towards [x, y)? But I could live with sticking with the [x - y)<br><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
<a href="https://reviews.llvm.org/D32492" rel="noreferrer" target="_blank">https://reviews.llvm.org/D32492</a><br>
<br>
<br>
<br>
</blockquote></div></div>