<div dir="ltr"><div>Hi Jayson,</div><div><br></div><div>This is a conversation that's come up on odd occasions before (for example, it was a topic briefly discussed at the Brussels Euro LLVM meeting a couple of years ago[1]), but to my knowledge, nobody has had a strong need for it until now, with the exception of llvm-symbolizer which already has a JSON output format.</div><div><br></div><div>Why would you need this for both llvm-nm and llvm-readelf? llvm-nm is basically just a way to dump the symbols in a file, but llvm-readelf already has that ability. If you implemented machine-readable output in llvm-readelf, would you need it for llvm-nm too?</div><div><br></div><div>In terms of which other tools might need it:</div><div>* llvm-objdump's feature set broadly overlaps llvm-readelf. The only additional features are really to do with disassembly, but I doubt there are many people who are trying to parse disassembly for this.</div><div>* llvm-dwarfdump: this might be very vaguely useful, but I doubt there are many scripts that actually rely on its output.</div><div>* llvm-strings: this is just a raw dump already, so there's no need for a "machine-readable" format (since it is already trivially parseable).</div><div>* llvm-cxxfilt: same as llvm-strings - the output is simple enough that there's no need for JSON output here.</div><div>* llvm-ar: there are a limited number of output options in this tool, but again, I think the output is broadly trivial. There may be no need for it here either.</div><div>There may be other tools I am not so familiar with, but to summarise, if you do llvm-readelf, I doubt you'll need to implement anything else.</div><div><br></div><div>I'd actually avoid doing it in any tool unless you have an actual concrete need: maintaining an additional output format is a non-trivial task, as every new feature added needs to have an additional implementation for the new output format, increasing development cost as a result.<br></div><div><br></div><div>I have previously given some thought to machine readable output in llvm-readelf. It certainly would seem that a JSONELFDumper would be the way forward, with json just becoming another output option for `--elf-output-style`. I assume that's what you mean by "surface this feature"?<br></div><div><br></div><div>James<br></div><div><br></div><div>[1]<a href="https://lists.llvm.org/pipermail/llvm-dev/2019-April/132032.html">https://lists.llvm.org/pipermail/llvm-dev/2019-April/132032.html</a></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 29 Sept 2021 at 19:25, Jayson Yan via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><span id="gmail-m_7220279758134595864gmail-docs-internal-guid-93cf0d3f-7fff-c8ee-63ea-7d2ef93ae994"><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-variant-numeric:normal;font-variant-east-asian:normal;vertical-align:baseline;white-space:pre-wrap">Hi all,</span></p><br><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-variant-numeric:normal;font-variant-east-asian:normal;vertical-align:baseline;white-space:pre-wrap">We are interested in adding the ability to produce machine readable output to some of the tools that LLVM provides. The goal is to provide easier automation capabilities for future scripting. We wanted to gauge interest as well as discuss how the community would like this to be implemented.</span></p><br><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-variant-numeric:normal;font-variant-east-asian:normal;vertical-align:baseline;white-space:pre-wrap">Currently the plan is to surface this as an optional flag which if set will have the tool output machine readable output. We are planning for the output format to be in JSON, if anyone feels strongly about another format please let us know. The tools we initially hope to tackle are llvm-nm and llvm-readelf but we’d be interested to hear if there are tools that the community feels would benefit from this.</span></p><br><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-variant-numeric:normal;font-variant-east-asian:normal;vertical-align:baseline;white-space:pre-wrap">The high level implementation plan is to provide an abstract interface for output with human-readable output as one concrete implementation of this interface and a new machine-readable output as another implementation. For tools like llvm-readelf, this infrastructure already exists so it would just be a matter of implementing a JSONELFDumper on top of the existing GNUELFDumper and LLVMELFDumper. For tools like llvm-nm this infrastructure doesn’t exist so we’d need to add this abstraction first.</span></p><br><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-variant-numeric:normal;font-variant-east-asian:normal;vertical-align:baseline;white-space:pre-wrap">Interested to hear any thoughts on:</span></p><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="background-color:transparent;font-size:11pt;white-space:pre-wrap;color:rgb(0,0,0);font-family:Arial">- How would we like to surface this feature?</span></p><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="background-color:transparent;font-size:11pt;white-space:pre-wrap;color:rgb(0,0,0);font-family:Arial">- Which tools would be most valuable to provide machine-readable output?</span></p><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="background-color:transparent;font-size:11pt;white-space:pre-wrap;color:rgb(0,0,0);font-family:Arial">- Does the implementation plan make sense?</span></p><br><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-variant-numeric:normal;font-variant-east-asian:normal;vertical-align:baseline;white-space:pre-wrap">Thanks</span></p><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-variant-numeric:normal;font-variant-east-asian:normal;vertical-align:baseline;white-space:pre-wrap">- Jayson</span></p></span><br></div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>