Extension: read inlining info in an NVIDIA extended line map

John Mellor-Crummey johnmc@rice.edu
Mon Sep 6 00:07:45 GMT 2021


As of CUDA 11.2, NVIDIA added extensions to the line map section
of CUDA binaries to represent inlined functions. These extensions
include

 - two new fields in a line table row to represent inline 
   information: context, and functionname,

 - two new DWARF extended opcodes: DW_LNE_inlined_call, 
   DW_LNE_set_function_name,

 - an additional word in the line table header that indicates 
   the offset in the .debug_str function where the function 
   names for this line table begin, and

 - two new functions in the libdw API: dwarf_linecontext and 
   dwarf_linefunctionname, which return the new line table fields.

A line table row for an inlined function contains a non-zero
"context" value. The “context” field indicates the index of the
line table row that serves as the call site for an inlined
context.

The "functionname" field in a line table row is only meaningful
if the "context" field of the row is non-zero. A meaningful
"functionname" field contains an index into the .debug_str
section relative to the base offset established in the line table
header; the position in the .debug_str section indicates the name
of the inlined function.

These extensions resemble the proposed DWARF extensions
(http://dwarfstd.org/ShowIssue.php?issue=140906.1) by Cary
Coutant, but are not identical.

This patch adds integrates support for handling NVIDIA's extended
line maps into elfutil's libdw library and the readelf command
line utility.

Since this support is a non-standard extension to DWARF, all code
that implements the extensions is implemented between markers  
/* Begin NVIDIA_LINEMAP_INLINING_EXTENSIONS */ and 
/* End NVIDIA_LINEMAP_INLINING_EXTENSIONS */.

The definition below

 #define NVIDIA_LINEMAP_INLINING_EXTENSIONS 1

is added to elfutils/version.h, which enables a client of elfutils 
to test whether the NVIDIA line map extensions are present. 

Note: The support for NVIDIA extended line maps adds two integer
fields (context and functionname) to struct Dwarf_Line_s, which
makes the structure about 30% larger.

The patch includes a binary testfile_nvidia_linemap.bz2 that
contains an NVIDIA extended linemap along with two tests that
read the line map.

 - A test script run-nvidia-extended-linemap-readelf.sh 
   checks the output of readelf on the new test binary to 
   validate its dump of the line op codes containing context 
   and functionname entries.

 - A test program tests/nvidia_extended_linemap_libdw.c reads 
   the extended line map with dwarf_next_lines and dumps the 
   context and functionname fields of the line map where they 
   are relevant, i.e. the value of context is non-zero. A test 
   script run-nvidia-extended-linemap-libdw.sh runs this test 
   and validates its output.

A patch with the new functionality described above is attached.
--
John Mellor-Crummey		Professor
Dept of Computer Science	Rice University
email: johnmc@rice.edu		phone: 713-348-5179

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Read-inlining-info-in-NVIDIA-extended-line-map.patch
Type: application/octet-stream
Size: 31678 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/elfutils-devel/attachments/20210905/2c10bb74/attachment-0001.obj>
-------------- next part --------------





More information about the Elfutils-devel mailing list