<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=koi8-r">
<style type="text/css" style="display:none"><!-- p { margin-top: 0px; margin-bottom: 0px; }--></style>
</head>
<body dir="ltr" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p><span style="color: rgb(33, 33, 33); font-size: 12pt;">>Too much/slow? I'd be surprised if it was very expensive to do a single loop over the sections (~hundreds of sections in an object file? Fewer in a linked executable), >maybe lazily (when the first
range is rendered) - it'd only happen once for the whole dump run (& add a lookup in the resulting map for each range entry dumping - >which, yeah, that's something, but still). dwarfdump's an interactive/user-focussed tool, it probably takes longer to print
things to the terminal than most of this >computation. (& longer still for the user to read it, etc)</span><br>
</p>
<p><span style="color: rgb(33, 33, 33); font-size: 12pt;"><br>
</span></p>
<p><span style="color: rgb(33, 33, 33); font-size: 12pt;">May be. What I was mean by "too much" is that I have feeling that scaning over all sections</span></p>
<p><font color="#212121">anyways should be not neccessary for printing nice output here. I don't see the reasons for additional code compliction.</font></p>
<p><font color="#212121">There are probably 2 possible cases:</font></p>
<p><font color="#212121">Print ".section.name [index]" or "[index] .section.name". For latter case we do not need to scan over all sections to</font></p>
<p><font color="#212121">columnize the "[index]" as we can just use total amount of sections to calculate padding. So why not to use this form ?</font></p>
<div style="color: rgb(33, 33, 33);">
<div>
<div dir="ltr">
<div class="gmail_quote">
<div> </div>
<div><span style="font-size: 12pt;">>>I would not omit something dependent on third conditions too, because it makes logic of output unclear for</span><span style="font-size: 12pt;">people that are not familar with tool. ("Why it prints >>section index for
"foo" and does not for "bar" ? BUUUG !")</span></div>
<div>><br>
>Not sure it'd be particulary bug-like if the section numbers were only shown when the section names were ambiguous. Given two examples it would seem fairly >clear to me, I think, that the numbers were added to disambiguate two sections with the same name.<br>
<br>
</div>
<div>If somebody going to parse tool's output then it is easier to have <span style="color: rgb(33, 33, 33); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">consistent</span> format.<br>
</div>
<div>Also (I'll show below) it can be not convinent or impossible to search for a section by name in a section table, </div>
<div>so if we are going to print <span style="font-size: 12pt;">section index at least </span><span style="font-size: 12pt;">in some cases, I think it worth then to print it in all cases</span><span style="font-size: 12pt;">.</span></div>
<div><br>
</div>
</div>
<div class="gmail_quote">>>Also I think often I am looking for section number in readelf/objdump/other tools,
<div>><br>
>Really? That surprises me - why are the section numbers of interest to you? For myself I'm usually interested in the section name.</div>
<div><br>
</div>
<div>Ah, section name is often a final point of interest for sure, but numbers are very important to have. See:</div>
<div><br>
</div>
<div>When I do readelf -a for some file and look at symbol table, I see section index "1" for "main",<br>
</div>
<div>using it's index then I can look into section table.<br>
</div>
<div>
<div>Symbol table '.symtab' contains 16 entries:</div>
<div> Num: Value Size Type Bind Vis Ndx Name</div>
<div> 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND </div>
<div> 1: 0000000000000000 0 FILE LOCAL DEFAULT ABS main.c<br>
</div>
<div>....<br>
</div>
<div> 13: 0000000000000000 21 FUNC GLOBAL DEFAULT 1 main<br>
</div>
<div><br>
<span style="color: rgb(33, 33, 33); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">But if we would have only name here, like:</span><br>
</div>
<div><span style="color: rgb(33, 33, 33); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);"><span style="color: rgb(33, 33, 33); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">13:
0000000000000000 21 FUNC GLOBAL DEFAULT ".text.foobar" main</span><br>
</span></div>
<div><br>
</div>
It would be harder or impossible to find it by name in section table.</div>
<div>For example, below is output of following:<br>
</div>
<div>ar -x libclangAnalysis.a <br>
readelf -a ReachableCode.cpp.o<br>
</div>
<div><br>
</div>
<div>
<div>Section Headers:</div>
<div> [Nr] Name Type Address Offset</div>
<div> Size EntSize Flags Link Info Align</div>
<div> [ 0] NULL 0000000000000000 00000000</div>
<div> 0000000000000000 0000000000000000 0 0 0</div>
<div> [ 1] .strtab STRTAB 0000000000000000 003e8080</div>
<div> 00000000000094e9 0000000000000000 0 0 1</div>
<div> [ 2] .text PROGBITS 0000000000000000 00000040</div>
<div> 0000000000002c96 0000000000000000 AX 0 0 16</div>
<div> [ 3] .rela.text RELA 0000000000000000 002a7818</div>
<div> 0000000000001c38 0000000000000018 1486 2 8</div>
<div> [ 4] .group GROUP 0000000000000000 0029ede0</div>
<div> 0000000000000008 0000000000000004 1486 1136 4</div>
<div> [ 5] .text PROGBITS 0000000000000000 00002ce0</div>
<div> 0000000000000011 0000000000000000 AXG 0 0 16</div>
<div> [ 6] .group GROUP 0000000000000000 0029ede8</div>
<div> 000000000000000c 0000000000000004 1486 968 4</div>
<div> [ 7] .text PROGBITS 0000000000000000 00002d00</div>
<div> 00000000000000a7 0000000000000000 AXG 0 0 16<br>
</div>
<div><~1500 the same sections here skpped.><br>
</div>
.....</div>
<div><br>
</div>
<div>As you can see section name can be not enough.<br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>>I'd skip printing it entirely if it's empty. 'Section: ""' doesn't seem helpful.<br>
><br>
</div>
<div>>I think printing it on the same line without the "Section: " prefix, as it was in your first version, is probably better when it is per-line.<br>
><br>
</div>
<div>>I guess maybe you're optimizing this for the case where some set of ranges share the same section (so it prints a "Section: "x"" header and then all the ranges in >that section? (or all the ranges in that section that are contiguous until another section
change?)? Though I don't see a test case for that (multiple sections, some >ranges next to each other in the same section).<br>
></div>
<div><br>
</div>
<div>You earlier wrote: "<span style="color: rgb(70, 76, 92); font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);">& what about omitting the
name or putting it somewhere else (like at the start on a separate line) if every entry is in the same section? (which will be the case for all ranges except the compile_unit ranges, most likely)</span>", so that is what I tried to implement.<br>
</div>
<div><br>
>But I don't think that's a scenario we realy need to optimize for - it's going to be pretty rare that a list contains both multiple sections and distinct ranges in the >same section. (function/scope ranges will contain ranegs all from the same section and
CU ranges will /mostly/ contain all ranges from distinct sections - except in >cases of nodebug functions putting holes in the range)<br>
<br>
</div>
George.<br>
</div>
</div>
</div>
</div>
</body>
</html>