<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">I don't think that any tool currently depends on parsing that syntax and I agree that using the mathematical [x,y) notation makes most sense here. It would be great to wrap this in a formatDWARFrange() function, so we can be consistent everywhere (and in case it really turns out that I need to produce darwin-dwarfdump compatible output at one point, we have one point where this can easily be parameterized).<div class=""><br class=""></div><div class="">-- adrian</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Apr 26, 2017, at 2:26 PM, Robinson, Paul <<a href="mailto:paul.robinson@sony.com" class="">paul.robinson@sony.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="WordSection1" style="page: WordSection1; font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class="">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 class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class="">--paulr<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><a name="_MailEndCompose" class=""><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class=""><o:p class=""> </o:p></span></a></div><div style="border-style: none none none solid; border-left-width: 1.5pt; border-left-color: blue; padding: 0in 0in 0in 4pt;" class=""><div class=""><div style="border-style: solid none none; border-top-width: 1pt; border-top-color: rgb(181, 196, 223); padding: 3pt 0in 0in;" class=""><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><b class=""><span style="font-size: 10pt; font-family: Tahoma, sans-serif;" class="">From:</span></b><span style="font-size: 10pt; font-family: Tahoma, sans-serif;" class=""><span class="Apple-converted-space"> </span>llvm-commits [<a href="mailto:llvm-commits-bounces@lists.llvm.org" class="">mailto:llvm-commits-bounces@lists.llvm.org</a>]<span class="Apple-converted-space"> </span><b class="">On Behalf Of<span class="Apple-converted-space"> </span></b>David Blaikie via llvm-commits<br class=""><b class="">Sent:</b><span class="Apple-converted-space"> </span>Wednesday, April 26, 2017 10:41 AM<br class=""><b class="">To:</b><span class="Apple-converted-space"> </span><a href="mailto:reviews+D32492+public+d04ad76ab213883a@reviews.llvm.org" class="">reviews+D32492+public+d04ad76ab213883a@reviews.llvm.org</a>; <a href="mailto:grimar@accesssoftek.com" class="">grimar@accesssoftek.com</a>; <a href="mailto:dccitaliano@gmail.com" class="">dccitaliano@gmail.com</a>; <a href="mailto:rafael.espindola@gmail.com" class="">rafael.espindola@gmail.com</a>; Adrian Prantl<br class=""><b class="">Cc:</b><span class="Apple-converted-space"> </span><a href="mailto:llvm-commits@lists.llvm.org" class="">llvm-commits@lists.llvm.org</a><br class=""><b class="">Subject:</b><span class="Apple-converted-space"> </span>Re: [PATCH] D32492: [llvm-dwarfdump] - Change format for .gdb_index dump.<o:p class=""></o:p></span></div></div></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><o:p class=""> </o:p></div><div class=""><p class="MsoNormal" style="margin: 0in 0in 12pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><o:p class=""> </o:p></p><div class=""><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class="">On Wed, Apr 26, 2017 at 3:31 AM George Rimar via Phabricator <<a href="mailto:reviews@reviews.llvm.org" style="color: purple; text-decoration: underline;" class="">reviews@reviews.llvm.org</a>> wrote:<o:p class=""></o:p></div></div><blockquote style="border-style: none none none solid; border-left-width: 1pt; border-left-color: rgb(204, 204, 204); padding: 0in 0in 0in 6pt; margin-left: 4.8pt; margin-right: 0in;" class=""><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class="">grimar added inline comments.<br class=""><br class=""><br class="">================<br class="">Comment at: lib/DebugInfo/DWARF/DWARFGdbIndex.cpp:42<br class="">     OS << format(<br class="">-        "    Low address = 0x%llx, High address = 0x%llx, CU index = %d\n",<br class="">-        Addr.LowAddress, Addr.HighAddress, Addr.CuIndex);<br class="">+        "    Low/High address = [0x%llx, 0x%llx] (Size: 0x%llx), CU id = %d\n",<br class="">+        Addr.LowAddress, Addr.HighAddress, Addr.HighAddress - Addr.LowAddress,<br class="">----------------<br class="">dblaikie wrote:<br class="">> 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 class="">I am not sure I understand why it is half open. If I got your idea correctly then probably output would be:<br class="">```<br class="">[a, b) (c, d) (e, f) (g, h]<o:p class=""></o:p></div></blockquote><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><br class="">Nah, more like:<br class=""><br class="">[a, b)<br class="">[c, d)<br class="">[e, f)<br class="">[g, h)<br class=""> <o:p class=""></o:p></div></div><blockquote style="border-style: none none none solid; border-left-width: 1pt; border-left-color: rgb(204, 204, 204); padding: 0in 0in 0in 6pt; margin-left: 4.8pt; margin-right: 0in;" class=""><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class="">```<br class=""><br class="">But I do not think it would be correct.<br class="">.gdb_index format (<a href="https://sourceware.org/gdb/onlinedocs/gdb/Index-Section-Format.html" target="_blank" style="color: purple; text-decoration: underline;" class="">https://sourceware.org/gdb/onlinedocs/gdb/Index-Section-Format.html</a>) defines address area as:<br class="">> The address area. The address area consists of a sequence of address entries. Each address entry has three elements:<br class="">> The low address. This is a 64-bit little-endian value.<br class="">> 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 class=""></o:p></div></blockquote><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><br class="">This bit here ^ "the value is one byte beyond the end" is what I mean by a half open range.<br class=""><br class="">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 class=""><br class="">( <a href="https://en.wikipedia.org/wiki/Interval_(mathematics)" style="color: purple; text-decoration: underline;" class="">https://en.wikipedia.org/wiki/Interval_(mathematics)</a> - "<span style="font-size: 10.5pt; color: rgb(34, 34, 34);" class="">A<span class="inbox-inbox-apple-converted-space"> </span><b class="">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: rgb(34, 34, 34);" class="">(0,1]</span></span><span class="inbox-inbox-apple-converted-space"><span style="font-size: 10.5pt; color: rgb(34, 34, 34);" class=""> </span></span><span style="font-size: 10.5pt; color: rgb(34, 34, 34);" class="">means greater than<span class="inbox-inbox-apple-converted-space"> </span></span><span class="inbox-inbox-texhtml"><span style="font-size: 12.5pt; color: rgb(34, 34, 34);" class="">0</span></span><span class="inbox-inbox-apple-converted-space"><span style="font-size: 10.5pt; color: rgb(34, 34, 34);" class=""> </span></span><span style="font-size: 10.5pt; color: rgb(34, 34, 34);" class="">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: rgb(34, 34, 34);" class="">1</span></span><span style="font-size: 10.5pt; color: rgb(34, 34, 34);" class="">, while<span class="inbox-inbox-apple-converted-space"> </span></span><span class="inbox-inbox-texhtml"><span style="font-size: 12.5pt; color: rgb(34, 34, 34);" class="">[0,1)</span></span><span class="inbox-inbox-apple-converted-space"><span style="font-size: 10.5pt; color: rgb(34, 34, 34);" class=""> </span></span><span style="font-size: 10.5pt; color: rgb(34, 34, 34);" class="">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: rgb(34, 34, 34);" class="">0</span></span><span class="inbox-inbox-apple-converted-space"><span style="font-size: 10.5pt; color: rgb(34, 34, 34);" class=""> </span></span><span style="font-size: 10.5pt; color: rgb(34, 34, 34);" class="">and less than<span class="inbox-inbox-apple-converted-space"> </span></span><span class="inbox-inbox-texhtml"><span style="font-size: 12.5pt; color: rgb(34, 34, 34);" class="">1</span></span><span style="font-size: 10.5pt; color: rgb(34, 34, 34);" class="">.")</span><br class=""> <o:p class=""></o:p></div></div><blockquote style="border-style: none none none solid; border-left-width: 1pt; border-left-color: rgb(204, 204, 204); padding: 0in 0in 0in 6pt; margin-left: 4.8pt; margin-right: 0in;" class=""><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class="">> The CU index. This is an offset_type value.<br class="">><br class=""><br class="">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 class=""><br class="">I was interested how readelf dumps the .gdb_index for the same file used in testcase.<br class="">It was:<br class="">readelf --debug-dump=gdb_index dwarfdump-gdbindex-v7.elf-x86-64<br class="">```<br class="">Contents of the .gdb_index section:<br class="">Version 7<br class=""><br class="">CU table:<br class="">[  0] 0x0 - 0x33<br class="">[  1] 0x34 - 0x67<br class=""><br class="">TU table:<br class=""><br class="">Address table:<br class="">00000000004000e8 00000000004000f3 0<br class="">00000000004000f3 00000000004000fe 1<br class=""><br class="">Symbol table:<br class="">[489] main: 0 [global, function]<br class="">[754] int:<br class="">        0 [static, type]<br class="">        1 [static, type]<br class="">[956] main2: 1 [global, function]<br class="">```<br class=""><br class="">Basing on above I can suggest 2 solutions:<br class="">1) Leave [x, y] as is.<br class="">2) Change dump output to something that avoids use of []() if that can be confusing, for example to:<br class=""><br class="">```<br class="">Address area offset = 0x38, has 2 entries:<br class="">0x4000e8 - 0x4000f3, Size = 0xb, CU id = 0<br class="">0x4000f3 - 0x4000fe, Size = 0xb, CU id = 1<br class="">```<br class=""><br class="">What do you think ?<o:p class=""></o:p></div></blockquote><div class=""><p class="MsoNormal" style="margin: 0in 0in 12pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><br class="">'-' could be ambiguous with the minus sign here.<br class=""><br class="">Indeed llvm-dwarfdump uses the half open range notation [x, y) in the DW_AT_ranges dumping such as here:<o:p class=""></o:p></p><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><span style="font-family: 'Courier New';" class="">  DW_AT_ranges [DW_FORM_sec_offset] (0x00000000</span><o:p class=""></o:p></div></div><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><span style="font-family: 'Courier New';" class="">     [0x00000000004004f0 - 0x00000000004004f6)</span><o:p class=""></o:p></div></div><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><span style="font-family: 'Courier New';" class="">     [0x0000000000400500 - 0x0000000000400508))</span><o:p class=""></o:p></div></div><p class="MsoNormal" style="margin: 0in 0in 12pt; font-size: 12pt; font-family: 'Times New Roman', serif;"> <br class="">though it also uses - rather than ','... which is weird.<br class=""><br class="">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 class=""></o:p></p></div><blockquote style="border-style: none none none solid; border-left-width: 1pt; border-left-color: rgb(204, 204, 204); padding: 0in 0in 0in 6pt; margin-left: 4.8pt; margin-right: 0in;" class=""><p class="MsoNormal" style="margin: 0in 0in 12pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><br class=""><br class=""><a href="https://reviews.llvm.org/D32492" target="_blank" style="color: purple; text-decoration: underline;" class="">https://reviews.llvm.org/D32492</a></p></blockquote></div></div></div></div></div></blockquote></div><br class=""></div></body></html>