<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 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.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" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">Actually .debug_aranges is supposed to cover both code and (static/global) data.  DWARF v5 section 6.1.2, p.148 line 12 clearly says “text or data covered by some entry” so I’d say GCC has a bug there.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">That said… if there’s no DIE with the range, according to spec it can be omitted from .debug_aranges; is that what the gmlt optimization does?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I think our backtrace printer might be assuming that .debug_aranges describes everything covered by .debug_line, which apparently is not the case if DIEs get omitted (or have their address ranges omitted).<o:p></o:p></p>
<p class="MsoNormal">--paulr<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></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 #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> David Blaikie <dblaikie@gmail.com> <br>
<b>Sent:</b> Tuesday, October 26, 2021 7:36 PM<br>
<b>To:</b> llvm-dev <llvm-dev@lists.llvm.org>; Robinson, Paul <paul.robinson@sony.com>; James Henderson <jh7370.2008@my.bristol.ac.uk>; Adrian Prantl <aprantl@apple.com>; Jonas Devlieghere <jdevlieghere@apple.com><br>
<b>Subject:</b> DWARF: Anyone using global variable addresses in .debug_aranges?<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">(I think we had some discussion about this a few years back, but can't seem to find it in my email)<br>
<br>
GCC doesn't put global variables/data into arranges, only functions/code - making arranges basically (entirely? so far as I know) the same as a CU's address range (high/low/ranges).<br>
<br>
Clang does put global variables in aranges. The whole arange content is driven by the emission of address attributes on DIEs.<br>
<br>
There's currently a bug (I introduced, someone else filed recently: <a href="https://urldefense.com/v3/__https:/bugs.llvm.org/show_bug.cgi?id=52187__;!!JmoZiZGBv3RvKRSx!tlBXtnd64BQMB7ocXsK4c4ix406Cn7chqYOkTvysFghb-mks3t0YDpVZj_TBzPTUmg$">
https://bugs.llvm.org/show_bug.cgi?id=52187</a>) in aranges with gmlt caused by the highly minimal form of gmlt I implemented a few years ago that skips subprogram DIEs for subprograms with no inlining (they have enough info in the line table+symbol table to
 do good backtraces, so we can save space by skipping the subprogram description). But this means no address attributes are emitted for these functions, so they don't end up in the aranges table.<br>
<br>
I think it might be simpler to fix this issue by making aranges be identical to CU ranges - this would be consistent with GCC's use of aranges (omitting globals) & reduce the chance of bugs of trying to keep two different lists in LLVM's implementation.<br>
<br>
What do folks think?<br>
<br>
(caveat: aranges are off by default in Clang because they seem redundant with CU ranges - I really don't understand why anyone's using them and we don't use them at Google... but bugs is bugs I guess)<o:p></o:p></p>
</div>
</div>
</div>
</body>
</html>