[PATCH] (v2) read inlining info in an NVIDIA extended line map

Mark Wielaard mark@klomp.org
Wed Nov 10 10:16:31 GMT 2021

Hi John,

On Thu, Nov 04, 2021 at 04:41:58PM -0500, John Mellor-Crummey via Elfutils-devel wrote:
> Here I describe just the improvements to that patch that address Mark’s concerns:
> (1) all of the code for handling NVIDIA DWARF extensions is always
> available; there is no special configuration switch needed.
> (2) all changes are bracketed by comments that mark them NVIDIA
> extensions
> (3) the DWARF extended opcodes have been renamed with names that
> include NVIDIA in them
> (4) the two new API functions to surface the new information have
> been improved to separate the interface result from the internal
> representation (at Mark’s request)
>      (4a) the API for extracting the name of an inlined function in a
>         DWARF line now returns a const char * instead of a string
>         table index
>      (4b) the API for extracting an inline “context” now returns a
>         pointer to a DWARF line where the code is inlined rather
>         than returning an unsigned int (an index into the line table
>         that one could use to compute the pointer)
> (5) there are test cases for readelf and libdw that use a binary
> generated by NVIDIA’s compiler. the test cases include information
> about how the binary was generated

This is really nice. I did make a few tweaks:

- Added your original overview as commit message because it contains
  all the relevant context and pointers to more information.

- Added ChangeLog and NEWS entries, mainly for my own review.

- I removed the bracketed comments, I think they cluttered the code
  and made it seem like we wanted to remove it or disable at some
  point. I think it should just be considered part of the normal code

  version.h. If people want they can have a configure check for the
  new dwarf_linecontext or dwarf_linefunctionname functions or the
  DW_LNE_NVIDIA_inlined_call or DW_LNE_NVIDIA_set_function_name

- I made dwarf_linefunctionname always return NULL on error (not
  the magic string "???", which is still used in readelf).

- Changed the header check to be exactly 4 bytes, so we are sure to be
  able to read the str offset completely (if it is smaller or larger
  we cannot handle it).

- The new dwarf_linecontext and dwarf_linefunctionname get their own
  new ELFUTILS_0.186 section in libdw.map because they are introduced
  with verion 0.186.

- The new run-nvidia-extended-linemap-libdw.sh and
  run-nvidia-extended-linemap-readelf.sh sripts and
  testfile_nvidia_linemap.bz2 testfile were added to EXTRA_DIST so
  they show up in a dist tarball.

Patch as committed attached. Hope you don't mind the cleanups.

We still want to reduce the size of the Dwarf_Line_s and struct
line_state (independent of these extensions). I opened a new bug for
that: https://sourceware.org/bugzilla/show_bug.cgi?id=28574


-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-libdw-readelf-Read-inlining-info-in-NVIDIA-extended-.patch
Type: text/x-diff
Size: 38314 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/elfutils-devel/attachments/20211110/471f0f6f/attachment-0001.bin>

More information about the Elfutils-devel mailing list