February 18, 2020.

Lets see if we can get a complete picture of the
indexing into the line table header directory/file
names tables.

The conjecture at the end of this suggests that
all places with an actual file/directory number
or index should be 1-origin, reserving 0 to
mean no file named.

The parts of DWARF5 that seem to be a complete picture
of the line table file/directory numbers are;

A) DW_AT_decl_file
A) DW_AT_call_file  /* DWARF5 */
C) DW_LNS_set_file
D) The current compilation file name
E) The current compilation directory name
F) The line table 'file' register.

G) The array of file names in the line table header
   (called the line table prologue in DWARF2).

H) The array of directory names in the line table header.

J) DW_MACRO_start_file (DW5)

============
DWARF5: the first entry in the directory table file names array
   is the name of the current compilation unit directory
   (the same as DW_AT_comp_dir in the CU die)

DWARF2,3,4: the first entry in the directory table file names array
   is the name of some directory, not necessarily
   the same as DW_AT_comp_dir in the CU die

DWARF5: the first entry in the line table file names array
   is the name of the current compilation unit (the same as
   DW_AT_name in the CU die).

DWARF2,3,4
   the first entry in the line table file names array
   does not have the current compilation unit file name,
   that name is only in DW_AT_name in the CU die.

Where DW_AT_decl_file is defined the standard(s)
indicate 0 is reserved to mean no file is specified
(Section 2.14, Declaration Coordinates)
That's the only place where zero is explictly
mentioned .

DW_LNS_set_file is defined to set the 'file' register
in the line state machine.
In all versions of DWARF the default value of the 'file'
register is 1 (not zero).

DW_MACRO_start_file (DW5):
The source file name index is the file number in the line number information
table for the compilation unit.

While the standard sometimes says file number and sometimes says 'index'
this note regards them as the same thing with regard to the line table
header arrays..

In DWARF 2,3,4 1 refers to a directory or file entry but not the
compilation unit
directory/file.

In DWARF 2,3,4 1 refers to a directory or file entry applicable to the
compilation unit.

CONJECTURE:
In all cases the index or array references are intended to be 1-origin.

In DWARF 2,3,4 1 refers to a directory or file entry but not the
compilation unit
directory/file.

In DWARF 2,3,4 1 refers to a directory or file entry applicable to the
compilation unit.

Taking this approach seems to resolve all issues pretty well.
===============

_______________________________________________
Dwarf-Discuss mailing list
Dwarf-Discuss@lists.dwarfstd.org
http://lists.dwarfstd.org/listinfo.cgi/dwarf-discuss-dwarfstd.org

Reply via email to