<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.inbox-inbox-apple-converted-space
        {mso-style-name:inbox-inbox-apple-converted-space;}
span.inbox-inbox-texhtml
        {mso-style-name:inbox-inbox-texhtml;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">I'd have a mild preference for [x, y) and also okay with x – y without the [) around the pair.  The [x – y) does just look funny. Although of course in context
 it's clear what's intended, so it's just a mild preference.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">--paulr<o:p></o:p></span></p>
<p class="MsoNormal"><a name="_MailEndCompose"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></a></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> llvm-commits [mailto:llvm-commits-bounces@lists.llvm.org]
<b>On Behalf Of </b>David Blaikie via llvm-commits<br>
<b>Sent:</b> Wednesday, April 26, 2017 10:41 AM<br>
<b>To:</b> reviews+D32492+public+d04ad76ab213883a@reviews.llvm.org; grimar@accesssoftek.com; dccitaliano@gmail.com; rafael.espindola@gmail.com; Adrian Prantl<br>
<b>Cc:</b> llvm-commits@lists.llvm.org<br>
<b>Subject:</b> Re: [PATCH] D32492: [llvm-dwarfdump] - Change format for .gdb_index dump.<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">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:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal">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]<o:p></o:p></p>
</blockquote>
<div>
<p class="MsoNormal"><br>
Nah, more like:<br>
<br>
[a, b)<br>
[c, d)<br>
[e, f)<br>
[g, h)<br>
 <o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal">```<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" 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.<o:p></o:p></p>
</blockquote>
<div>
<p class="MsoNormal"><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="font-size:10.5pt;color:#222222">A<span class="inbox-inbox-apple-converted-space"> </span><b>half-open interval</b><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"><span style="font-size:12.5pt;color:#222222">(0,1]</span></span><span class="inbox-inbox-apple-converted-space"><span style="font-size:10.5pt;color:#222222"> </span></span><span style="font-size:10.5pt;color:#222222">means
 greater than<span class="inbox-inbox-apple-converted-space"> </span></span><span class="inbox-inbox-texhtml"><span style="font-size:12.5pt;color:#222222">0</span></span><span class="inbox-inbox-apple-converted-space"><span style="font-size:10.5pt;color:#222222"> </span></span><span style="font-size:10.5pt;color:#222222">and
 less than or equal to<span class="inbox-inbox-apple-converted-space"> </span></span><span class="inbox-inbox-texhtml"><span style="font-size:12.5pt;color:#222222">1</span></span><span style="font-size:10.5pt;color:#222222">, while<span class="inbox-inbox-apple-converted-space"> </span></span><span class="inbox-inbox-texhtml"><span style="font-size:12.5pt;color:#222222">[0,1)</span></span><span class="inbox-inbox-apple-converted-space"><span style="font-size:10.5pt;color:#222222"> </span></span><span style="font-size:10.5pt;color:#222222">means
 greater than or equal to<span class="inbox-inbox-apple-converted-space"> </span></span><span class="inbox-inbox-texhtml"><span style="font-size:12.5pt;color:#222222">0</span></span><span class="inbox-inbox-apple-converted-space"><span style="font-size:10.5pt;color:#222222"> </span></span><span style="font-size:10.5pt;color:#222222">and
 less than<span class="inbox-inbox-apple-converted-space"> </span></span><span class="inbox-inbox-texhtml"><span style="font-size:12.5pt;color:#222222">1</span></span><span style="font-size:10.5pt;color:#222222">.")</span><br>
 <o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal">> 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 ?<o:p></o:p></p>
</blockquote>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><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:<o:p></o:p></p>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">  DW_AT_ranges [DW_FORM_sec_offset] (0x00000000</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">     [0x00000000004004f0 - 0x00000000004004f6)</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">     [0x0000000000400500 - 0x0000000000400508))</span><o:p></o:p></p>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt"> <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)<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
<br>
<a href="https://reviews.llvm.org/D32492" target="_blank">https://reviews.llvm.org/D32492</a><br>
<br>
<br>
<o:p></o:p></p>
</blockquote>
</div>
</div>
</div>
</div>
</body>
</html>