diff options
author | Alan Modra <amodra@gmail.com> | 2021-09-17 09:08:15 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2021-09-18 08:20:11 +0930 |
commit | 51298b330327a568358da069d9808f51c6cb1672 (patch) | |
tree | b908c032df61054658e5a47a4479346f0a0c159f /gas/testsuite | |
parent | 5cdb4f14426a99ec8fcba843fa503efdc55fa078 (diff) | |
download | gdb-51298b330327a568358da069d9808f51c6cb1672.zip gdb-51298b330327a568358da069d9808f51c6cb1672.tar.gz gdb-51298b330327a568358da069d9808f51c6cb1672.tar.bz2 |
PR28149, debug info with wrong file association
gcc-11 and gcc-12 pass -gdwarf-5 to gas, in order to prime gas for
DWARF 5 level debug info. Unfortunately it seems there are cases
where the compiler does not emit a .file or .loc dwarf debug directive
before any machine instructions. (Note that the .file directive
typically emitted as the first line of assembly output doesn't count as
a dwarf debug directive. The dwarf .file has a file number before the
file name string.)
This patch delays allocation of file numbers for gas generated line
debug info until the end of assembly, thus avoiding any clashes with
compiler generated file numbers. Two fixes for test case source are
necessary; A .loc can't use a file number that hasn't already been
specified with .file.
A followup patch will remove all the gas generated line info on
seeing a .file directive.
PR 28149
* dwarf2dbg.c (num_of_auto_assigned): Delete.
(current): Update initialisation.
(set_or_check_view): Replace all accesses to view with u.view.
(dwarf2_consume_line_info): Likewise.
(dwarf2_directive_loc): Likewise. Assert that we aren't generating
line info.
(dwarf2_gen_line_info_1): Don't call set_or_check_view on
gas generated line entries.
(dwarf2_gen_line_info): Set and track filenames for gas generated
line entries. Simplify generation of labels.
(get_directory_table_entry): Use filename_cmp when comparing dirs.
(do_allocate_filenum): New function.
(dwarf2_where): Set u.filename and filenum to -1 for gas generated
line entries.
(dwarf2_directive_filename): Remove num_of_auto_assigned handling.
(process_entries): Update view field access. Call
do_allocate_filenum.
* dwarf2dbg.h (struct dwarf2_line_info): Add filename field in
union aliasing view.
* testsuite/gas/i386/dwarf2-line-3.s: Add .file directive.
* testsuite/gas/i386/dwarf2-line-4.s: Likewise.
* testsuite/gas/i386/dwarf2-line-4.d: Update expected output.
* testsuite/gas/i386/dwarf4-line-1.d: Likewise.
* testsuite/gas/i386/dwarf5-line-1.d: Likewise.
* testsuite/gas/i386/dwarf5-line-2.d: Likewise.
Diffstat (limited to 'gas/testsuite')
-rw-r--r-- | gas/testsuite/gas/i386/dwarf2-line-3.s | 1 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/dwarf2-line-4.d | 5 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/dwarf2-line-4.s | 1 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/dwarf4-line-1.d | 4 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/dwarf5-line-1.d | 4 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/dwarf5-line-2.d | 3 |
6 files changed, 14 insertions, 4 deletions
diff --git a/gas/testsuite/gas/i386/dwarf2-line-3.s b/gas/testsuite/gas/i386/dwarf2-line-3.s index 2085ef9..e933719 100644 --- a/gas/testsuite/gas/i386/dwarf2-line-3.s +++ b/gas/testsuite/gas/i386/dwarf2-line-3.s @@ -7,6 +7,7 @@ main: .cfi_startproc nop + .file 1 "dwarf2-test.c" .loc 1 1 ret .cfi_endproc diff --git a/gas/testsuite/gas/i386/dwarf2-line-4.d b/gas/testsuite/gas/i386/dwarf2-line-4.d index c0c85f4..a01fd05 100644 --- a/gas/testsuite/gas/i386/dwarf2-line-4.d +++ b/gas/testsuite/gas/i386/dwarf2-line-4.d @@ -33,11 +33,14 @@ Raw dump of debug contents of section \.z?debug_line: The File Name Table \(offset 0x.*\): Entry Dir Time Size Name - 1 1 0 0 dwarf2-line-4.s + 1 0 0 0 dwarf2-test.c + 2 1 0 0 dwarf2-line-4.s Line Number Statements: + \[0x.*\] Set File Name to entry 2 in the File Name Table \[0x.*\] Extended opcode 2: set Address to 0x0 \[0x.*\] Special opcode 13: advance Address by 0 to 0x0 and Line by 8 to 9 + \[0x.*\] Set File Name to entry 1 in the File Name Table \[0x.*\] Advance Line by -8 to 1 \[0x.*\] Special opcode 19: advance Address by 1 to 0x1 and Line by 0 to 1 \[0x.*\] Advance PC by 1 to 0x2 diff --git a/gas/testsuite/gas/i386/dwarf2-line-4.s b/gas/testsuite/gas/i386/dwarf2-line-4.s index 89bb62d..7348f4b 100644 --- a/gas/testsuite/gas/i386/dwarf2-line-4.s +++ b/gas/testsuite/gas/i386/dwarf2-line-4.s @@ -7,6 +7,7 @@ main: .cfi_startproc nop + .file 1 "dwarf2-test.c" .loc 1 1 ret .cfi_endproc diff --git a/gas/testsuite/gas/i386/dwarf4-line-1.d b/gas/testsuite/gas/i386/dwarf4-line-1.d index 4f8321e..8199efb 100644 --- a/gas/testsuite/gas/i386/dwarf4-line-1.d +++ b/gas/testsuite/gas/i386/dwarf4-line-1.d @@ -36,12 +36,14 @@ Raw dump of debug contents of section \.z?debug_line: Entry Dir Time Size Name 1 0 0 0 foo.c 2 0 0 0 foo.h + 3 1 0 0 dwarf4-line-1.s Line Number Statements: + \[0x.*\] Set File Name to entry 2 in the File Name Table \[0x.*\] Extended opcode 2: set Address to 0x0 \[0x.*\] Advance Line by 81 to 82 \[0x.*\] Copy - \[0x.*\] Set File Name to entry 2 in the File Name Table + \[0x.*\] Set File Name to entry 3 in the File Name Table \[0x.*\] Advance Line by -73 to 9 \[0x.*\] Special opcode 19: advance Address by 1 to 0x1 and Line by 0 to 9 \[0x.*\] Advance PC by 3 to 0x4 diff --git a/gas/testsuite/gas/i386/dwarf5-line-1.d b/gas/testsuite/gas/i386/dwarf5-line-1.d index f57fc47..2c2cf56 100644 --- a/gas/testsuite/gas/i386/dwarf5-line-1.d +++ b/gas/testsuite/gas/i386/dwarf5-line-1.d @@ -36,12 +36,14 @@ Raw dump of debug contents of section \.z?debug_line: 0 \(indirect line string, offset: 0x.*\): .*/gas/testsuite 1 \(indirect line string, offset: 0x.*\): .*/gas/testsuite/gas/i386 - The File Name Table \(offset 0x.*, lines 2, columns 3\): + The File Name Table \(offset 0x.*, lines 3, columns 3\): Entry Dir MD5 Name 0 0 0xbbd69fc03ce253b2dbaab2522dd519ae \(indirect line string, offset: 0x.*\): core.c 1 0 0x0 \(indirect line string, offset: 0x.*\): types.h + 2 1 0x0 \(indirect line string, offset: 0x.*\): dwarf5-line-1.s Line Number Statements: + \[0x.*\] Set File Name to entry 2 in the File Name Table \[0x.*\] Extended opcode 2: set Address to 0x0 \[0x.*\] Special opcode 8: advance Address by 0 to 0x0 and Line by 3 to 4 \[0x.*\] Advance PC by 1 to 0x1 diff --git a/gas/testsuite/gas/i386/dwarf5-line-2.d b/gas/testsuite/gas/i386/dwarf5-line-2.d index 2f96df5..85f98c8 100644 --- a/gas/testsuite/gas/i386/dwarf5-line-2.d +++ b/gas/testsuite/gas/i386/dwarf5-line-2.d @@ -36,9 +36,10 @@ Raw dump of debug contents of section \.z?debug_line: 0 \(indirect line string, offset: 0x.*\): .*/gas/testsuite 1 \(indirect line string, offset: 0x.*\): .*/gas/testsuite/gas/i386 - The File Name Table \(offset 0x.*, lines 1, columns 3\): + The File Name Table \(offset 0x.*, lines 2, columns 3\): Entry Dir MD5 Name 0 0 0xbbd69fc03ce253b2dbaab2522dd519ae \(indirect line string, offset: 0x.*\): core.c + 1 1 0x0 \(indirect line string, offset: .*\): dwarf5-line-2.s Line Number Statements: \[0x.*\] Extended opcode 2: set Address to 0x0 |