<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p><br>
    </p>
    3/3/2020 12:48 AM, Greg Clayton via llvm-dev пишет:<br>
    <blockquote type="cite"
      cite="mid:445D4E5F-A0FD-4E35-9DDA-E6CA45385907@gmail.com">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <br class="">
      <div><br class="">
        <blockquote type="cite" class="">
          <div class="">On Feb 28, 2020, at 11:25 PM, Fangrui Song via
            llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org"
              class="" moz-do-not-send="true">llvm-dev@lists.llvm.org</a>>
            wrote:</div>
          <br class="Apple-interchange-newline">
          <div class=""><span style="caret-color: rgb(0, 0, 0);
              font-family: Menlo-Regular; 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;
              text-decoration: none; float: none; display: inline
              !important;" class="">On 2020-02-28, Greg Clayton via
              llvm-dev wrote:</span><br style="caret-color: rgb(0, 0,
              0); font-family: Menlo-Regular; 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; text-decoration: none;"
              class="">
            <blockquote type="cite" style="font-family: Menlo-Regular;
              font-size: 12px; font-style: normal; font-variant-caps:
              normal; font-weight: normal; letter-spacing: normal;
              orphans: auto; text-align: start; text-indent: 0px;
              text-transform: none; white-space: normal; widows: auto;
              word-spacing: 0px; -webkit-text-size-adjust: auto;
              -webkit-text-stroke-width: 0px; text-decoration: none;"
              class="">I am looking to create a tool that can add Apple
              or DWARF5 accelerator tables to fully linked executables
              that contain DWARF. This will help us benchmark how much
              accelerator tables can improve the debugging experience as
              debuggers don't need to manually index all of the debug
              info during debugging.<br class="">
            </blockquote>
            <span style="caret-color: rgb(0, 0, 0); font-family:
              Menlo-Regular; 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;
              text-decoration: none; float: none; display: inline
              !important;" class="">Is it for ELF, Mach-O, wasm, COFF,
              or any of the combinations?</span><br style="caret-color:
              rgb(0, 0, 0); font-family: Menlo-Regular; 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; text-decoration: none;"
              class="">
          </div>
        </blockquote>
        <div><br class="">
        </div>
        Yes, for any object files that LLVM currently supports. But I am
        looking to support ELF first as MachO already has these tables
        available since dsymutil already creates either Apple or DWARF
        accelerator tables. COFF and Wasm can come later.</div>
      <div><br class="">
        <blockquote type="cite" class="">
          <div class=""><br style="caret-color: rgb(0, 0, 0);
              font-family: Menlo-Regular; 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;
              text-decoration: none;" class="">
            <blockquote type="cite" style="font-family: Menlo-Regular;
              font-size: 12px; font-style: normal; font-variant-caps:
              normal; font-weight: normal; letter-spacing: normal;
              orphans: auto; text-align: start; text-indent: 0px;
              text-transform: none; white-space: normal; widows: auto;
              word-spacing: 0px; -webkit-text-size-adjust: auto;
              -webkit-text-stroke-width: 0px; text-decoration: none;"
              class="">Looking at how accelerator tables are currently
              emitted, they seem to be built up as DWARF is being
              created or linked, and then emitted using a subclass of
              DWARFEmitter. The only subclass if this right now that I
              see is one in dsymutil which ends up emitting everything
              using an AsmPrinter by eventually emitAppleAccelTable(...)
              from llvm/include/llvm/CodeGen/AccelTable.h.<br class="">
              <br class="">
              I spoke briefly with Shoaib on this subject and he
              suggested adding code to llvm-objcopy. I briefly looked
              through the code and from what I can tell, llvm-objcopy
              doesn't seem to have any DWARF abilities other than
              compressing DWARF sections. If we do add functionality to
              llvm-objcopy, are we ok pulling in DebugInfoDWARF and the
              LLVM object model? AFAICT the code for this tools has its
              own object file layer which doesn't match the full layer
              inside of LLVM (llvm::ObjectFile and DWARFContext). Also,
              no AsmPrinter objects are used in this codebase either.<br
                class="">
            </blockquote>
            <br style="caret-color: rgb(0, 0, 0); font-family:
              Menlo-Regular; 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;
              text-decoration: none;" class="">
            <span style="caret-color: rgb(0, 0, 0); font-family:
              Menlo-Regular; 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;
              text-decoration: none; float: none; display: inline
              !important;" class="">llvm-objcopy supports various ad-hoc
              binary manipulation features where each feature does a
              very</span><br style="caret-color: rgb(0, 0, 0);
              font-family: Menlo-Regular; 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;
              text-decoration: none;" class="">
            <span style="caret-color: rgb(0, 0, 0); font-family:
              Menlo-Regular; 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;
              text-decoration: none; float: none; display: inline
              !important;" class="">simple task. Neither llvm-objcopy
              nor GNU objcopy knows DWARF. --strip-debug,</span><br
              style="caret-color: rgb(0, 0, 0); font-family:
              Menlo-Regular; 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;
              text-decoration: none;" class="">
            <span style="caret-color: rgb(0, 0, 0); font-family:
              Menlo-Regular; 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;
              text-decoration: none; float: none; display: inline
              !important;" class="">--compress-debug-sections,
              --add-gnu-debuglink and --only-keep-debug have "debug" in
              their names but</span><br style="caret-color: rgb(0, 0,
              0); font-family: Menlo-Regular; 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; text-decoration: none;"
              class="">
            <span style="caret-color: rgb(0, 0, 0); font-family:
              Menlo-Regular; 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;
              text-decoration: none; float: none; display: inline
              !important;" class="">these features don't need to parse
              DWARF. (GNU objcopy has a --debugging but that only works
              for</span><br style="caret-color: rgb(0, 0, 0);
              font-family: Menlo-Regular; 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;
              text-decoration: none;" class="">
            <span style="caret-color: rgb(0, 0, 0); font-family:
              Menlo-Regular; 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;
              text-decoration: none; float: none; display: inline
              !important;" class="">a.out and coff, not elf).</span><br
              style="caret-color: rgb(0, 0, 0); font-family:
              Menlo-Regular; 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;
              text-decoration: none;" class="">
            <br style="caret-color: rgb(0, 0, 0); font-family:
              Menlo-Regular; 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;
              text-decoration: none;" class="">
            <span style="caret-color: rgb(0, 0, 0); font-family:
              Menlo-Regular; 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;
              text-decoration: none; float: none; display: inline
              !important;" class="">Do we have a more suitable tool for
              such debugging functionality? dsymutil for ELF?</span><br
              style="caret-color: rgb(0, 0, 0); font-family:
              Menlo-Regular; 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;
              text-decoration: none;" class="">
          </div>
        </blockquote>
        <div><br class="">
        </div>
        <div>dsymutil is such a tool, but it uses the llvm::ObjectFile
          layer and the llvm targets, so if you open a file that
          contains "armv7" architecture and the ARM target hasn't been
          built into your bistro, it will fail to open this binary with
          an error that says:</div>
        <div><br class="">
        </div>
        <div>No available targets are compatible with triple
          "arm-unknown-unknown"</div>
        <div class=""><br class="">
        </div>
        <div class="">I ran into this with a recent gsym patch that is
          trying to fix the buildbots for testing, but it fails when the
          ARM targets are not enabled and I try to load the DWARF from
          an object file:</div>
        <div class=""><br class="">
        </div>
        <div class=""><a
href="http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/63473/steps/test-check-all/logs/stdio"
            class="" moz-do-not-send="true">http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/63473/steps/test-check-all/logs/stdio</a></div>
        <div class=""><br class="">
        </div>
        <div class="">And this is part of the reason for this email. I
          would love to not require llvm-gsymutil to require all LLVM
          targets to be there. DebugInfoDWARF doesn't need the targets,
          it just needs to know address byte size and endianness and it
          can parse the debug info in the DWARF.</div>
        <div class=""><br class="">
        </div>
      </div>
    </blockquote>
    <p>Hi Greg,  dsymutil code was recently refactored so that it`s
      linking part was moved into lib/DWARFLinker library.</p>
    <p>As an advantage, it allows making DWARFLinker to not depend on
      ObjectFile : <a class="moz-txt-link-freetext" href="https://reviews.llvm.org/D75029">https://reviews.llvm.org/D75029</a> .<br>
    </p>
    <p>It might make sense that your tool uses DWARFLinker
      library(probably extending it with new functionality) to work with
      DWARF.<br>
    </p>
    <p>Alexey.<br>
    </p>
    <blockquote type="cite"
      cite="mid:445D4E5F-A0FD-4E35-9DDA-E6CA45385907@gmail.com">
      <div>
        <div class="">So my main question stands: do we want all tools
          that must manipulate DWARF to require the llvm::ObjectFile
          layer and all of the targets to be enabled just so that the
          object files can be parsed, or do we want to make lighter
          layer available, akin to what llvm-objcopy has, so more tools
          can take advantage of this lighter weight layer.</div>
        <br class="">
        <blockquote type="cite" class="">
          <div class=""><br style="caret-color: rgb(0, 0, 0);
              font-family: Menlo-Regular; 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;
              text-decoration: none;" class="">
            <blockquote type="cite" style="font-family: Menlo-Regular;
              font-size: 12px; font-style: normal; font-variant-caps:
              normal; font-weight: normal; letter-spacing: normal;
              orphans: auto; text-align: start; text-indent: 0px;
              text-transform: none; white-space: normal; widows: auto;
              word-spacing: 0px; -webkit-text-size-adjust: auto;
              -webkit-text-stroke-width: 0px; text-decoration: none;"
              class="">Looking at lld sources, is seems to use the
              DebugInfoDWARF library to some extent already. Not sure if
              this tool uses the standard LLVM object model or has all
              of its own emitters. Does lld use AsmPrinter at all? I
              don't see any mention of it in there.<br class="">
            </blockquote>
            <br style="caret-color: rgb(0, 0, 0); font-family:
              Menlo-Regular; 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;
              text-decoration: none;" class="">
            <span style="caret-color: rgb(0, 0, 0); font-family:
              Menlo-Regular; 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;
              text-decoration: none; float: none; display: inline
              !important;" class="">--gdb-index and diagnostics (line
              tables) use DebugInfoDWARF. I have a plan to implement
              .debug_names, which is similar to --gdb-index.</span><br
              style="caret-color: rgb(0, 0, 0); font-family:
              Menlo-Regular; 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;
              text-decoration: none;" class="">
          </div>
        </blockquote>
        <div><br class="">
        </div>
        <div>That is great, and we will share code for this of course
          between the tool I write and the modifications to lld. Does
          lld use the llvm::ObjectFile layer? or does it have its own
          lighter weight layer?</div>
      </div>
    </blockquote>
    <blockquote type="cite"
      cite="mid:445D4E5F-A0FD-4E35-9DDA-E6CA45385907@gmail.com">
      <div>
        <blockquote type="cite" class="">
          <div class=""><br style="caret-color: rgb(0, 0, 0);
              font-family: Menlo-Regular; 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;
              text-decoration: none;" class="">
            <blockquote type="cite" style="font-family: Menlo-Regular;
              font-size: 12px; font-style: normal; font-variant-caps:
              normal; font-weight: normal; letter-spacing: normal;
              orphans: auto; text-align: start; text-indent: 0px;
              text-transform: none; white-space: normal; widows: auto;
              word-spacing: 0px; -webkit-text-size-adjust: auto;
              -webkit-text-stroke-width: 0px; text-decoration: none;"
              class="">dsymutil has a --update feature which seems to
              load all of the DWARF and pretend to link it all the while
              generating the new accelerator table data, but I fear
              using this would pull it way too much code (AsmPrinter,
              all targets required to load all object files types, the
              standard llvm object file model (not the lld or
              llvm-objcopy versions), targets, etc).<br class="">
              <br class="">
              My initial thoughts are:<br class="">
              1 - load a DWARFContext and iterate through the DWARF and
              build accelerator table data<br class="">
              2 - create the sections for the accelerator tables and
              either keep in memory or save to disk<br class="">
              3 - call functions to add the newly created sections to
              the binary<br class="">
              <br class="">
              #1 should be easy as long as I can use a DWARFContext from
              DebugInfoDWARF.<br class="">
              #2 might need to be re-implemented using something other
              than an AsmPrinter?<br class="">
              #3 can use llvm-objcopy code if needed since it can add
              sections?<br class="">
              <br class="">
              Any advice on how this can or should be implemented would
              be appreciated from anyone with experience.<br class="">
              <br class="">
              Greg Clayton<br class="">
              <br class="">
            </blockquote>
            <br style="caret-color: rgb(0, 0, 0); font-family:
              Menlo-Regular; 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;
              text-decoration: none;" class="">
            <blockquote type="cite" style="font-family: Menlo-Regular;
              font-size: 12px; font-style: normal; font-variant-caps:
              normal; font-weight: normal; letter-spacing: normal;
              orphans: auto; text-align: start; text-indent: 0px;
              text-transform: none; white-space: normal; widows: auto;
              word-spacing: 0px; -webkit-text-size-adjust: auto;
              -webkit-text-stroke-width: 0px; text-decoration: none;"
              class="">_______________________________________________<br
                class="">
              LLVM Developers mailing list<br class="">
              <a href="mailto:llvm-dev@lists.llvm.org" class=""
                moz-do-not-send="true">llvm-dev@lists.llvm.org</a><br
                class="">
              <a
                href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev"
                class="" moz-do-not-send="true">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br
                class="">
            </blockquote>
            <br style="caret-color: rgb(0, 0, 0); font-family:
              Menlo-Regular; 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;
              text-decoration: none;" class="">
            <span style="caret-color: rgb(0, 0, 0); font-family:
              Menlo-Regular; 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;
              text-decoration: none; float: none; display: inline
              !important;" class="">_______________________________________________</span><br
              style="caret-color: rgb(0, 0, 0); font-family:
              Menlo-Regular; 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;
              text-decoration: none;" class="">
            <span style="caret-color: rgb(0, 0, 0); font-family:
              Menlo-Regular; 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;
              text-decoration: none; float: none; display: inline
              !important;" class="">LLVM Developers mailing list</span><br
              style="caret-color: rgb(0, 0, 0); font-family:
              Menlo-Regular; 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;
              text-decoration: none;" class="">
            <a href="mailto:llvm-dev@lists.llvm.org" style="font-family:
              Menlo-Regular; font-size: 12px; font-style: normal;
              font-variant-caps: normal; font-weight: normal;
              letter-spacing: normal; orphans: auto; text-align: start;
              text-indent: 0px; text-transform: none; white-space:
              normal; widows: auto; word-spacing: 0px;
              -webkit-text-size-adjust: auto; -webkit-text-stroke-width:
              0px;" class="" moz-do-not-send="true">llvm-dev@lists.llvm.org</a><br
              style="caret-color: rgb(0, 0, 0); font-family:
              Menlo-Regular; 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;
              text-decoration: none;" class="">
            <a
              href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev"
              style="font-family: Menlo-Regular; font-size: 12px;
              font-style: normal; font-variant-caps: normal;
              font-weight: normal; letter-spacing: normal; orphans:
              auto; text-align: start; text-indent: 0px; text-transform:
              none; white-space: normal; widows: auto; word-spacing:
              0px; -webkit-text-size-adjust: auto;
              -webkit-text-stroke-width: 0px;" class=""
              moz-do-not-send="true">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a></div>
        </blockquote>
      </div>
      <br class="">
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>
<a class="moz-txt-link-freetext" href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
    </blockquote>
  </body>
</html>