diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2020-10-26 06:16:08 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2020-10-26 06:16:21 -0700 |
commit | ae9d2233e61a98ff8dba56be10219aa5306ffc9a (patch) | |
tree | 660106b67bb2843a8828b283acc6e759fc6235ea /gas | |
parent | 93cf38c095afbee84ed580c431d001f20442f73e (diff) | |
download | gdb-ae9d2233e61a98ff8dba56be10219aa5306ffc9a.zip gdb-ae9d2233e61a98ff8dba56be10219aa5306ffc9a.tar.gz gdb-ae9d2233e61a98ff8dba56be10219aa5306ffc9a.tar.bz2 |
gas: Clear all auto-assigned file slots
Since a file slot is auto-assigned for the #APP marker appeared before
the first .file <NUMBER> directive has been seen, clear all auto-assigned
file slots when seeing the first .file <NUMBER> directive.
PR gas/26778
* * dwarf2dbg.c (num_of_auto_assigned): New.
(allocate_filenum): Increment num_of_auto_assigned.
(dwarf2_directive_filename): Clear the slots auto-assigned
before the first .file <NUMBER> directive was seen.
* testsuite/gas/i386/dwarf4-line-1.d: New file.
* testsuite/gas/i386/dwarf4-line-1.s: Likewise.
* testsuite/gas/i386/i386.exp: Run dwarf4-line-1.
Diffstat (limited to 'gas')
-rw-r--r-- | gas/ChangeLog | 11 | ||||
-rw-r--r-- | gas/dwarf2dbg.c | 24 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/dwarf4-line-1.d | 50 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/dwarf4-line-1.s | 14 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/i386.exp | 1 |
5 files changed, 89 insertions, 11 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog index 20929b5..a52eb2b 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,14 @@ +2020-10-26 H.J. Lu <hongjiu.lu@intel.com> + + PR gas/26778 + * * dwarf2dbg.c (num_of_auto_assigned): New. + (allocate_filenum): Increment num_of_auto_assigned. + (dwarf2_directive_filename): Clear the slots auto-assigned + before the first .file <NUMBER> directive was seen. + * testsuite/gas/i386/dwarf4-line-1.d: New file. + * testsuite/gas/i386/dwarf4-line-1.s: Likewise. + * testsuite/gas/i386/i386.exp: Run dwarf4-line-1. + 2020-10-26 Cooper Qu <cooper.qu@linux.alibaba.com> * config/tc-csky.c (dump_literals): Fix the literal dump diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c index 75ef7c4..4e03c63 100644 --- a/gas/dwarf2dbg.c +++ b/gas/dwarf2dbg.c @@ -218,6 +218,7 @@ struct file_entry static struct file_entry *files; static unsigned int files_in_use; static unsigned int files_allocated; +static unsigned int num_of_auto_assigned; /* Table of directories used by .debug_line. */ static char ** dirs = NULL; @@ -718,6 +719,8 @@ allocate_filenum (const char * pathname) if (!assign_file_to_slot (i, file, dir)) return -1; + num_of_auto_assigned++; + last_used = i; last_used_dir_len = dir_len; @@ -1013,6 +1016,7 @@ dwarf2_directive_filename (void) char *filename; const char * dirname = NULL; int filename_len; + unsigned int i; /* Continue to accept a bare string and pass it off. */ SKIP_WHITESPACE (); @@ -1079,18 +1083,16 @@ dwarf2_directive_filename (void) return NULL; } - if (files_in_use == 2) + if (num_of_auto_assigned) { - /* Clear the slot 1 if it was assigned to the input file before - the first .file <NUMBER> directive was seen. */ - unsigned int lineno; - const char *file = as_where (&lineno); - file = get_basename (file); - if (filename_cmp (file, files[1].filename) == 0) - { - files[1].filename = NULL; - files_in_use = 0; - } + /* Clear slots auto-assigned before the first .file <NUMBER> + directive was seen. */ + if (files_in_use != (num_of_auto_assigned + 1)) + abort (); + for (i = 1; i < files_in_use; i++) + files[i].filename = NULL; + files_in_use = 0; + num_of_auto_assigned = 0; } if (! allocate_filename_to_slot (dirname, filename, (unsigned int) num, diff --git a/gas/testsuite/gas/i386/dwarf4-line-1.d b/gas/testsuite/gas/i386/dwarf4-line-1.d new file mode 100644 index 0000000..4f8321e --- /dev/null +++ b/gas/testsuite/gas/i386/dwarf4-line-1.d @@ -0,0 +1,50 @@ +#as: -gdwarf-4 +#readelf: -wl +#name: DWARF4 .debug_line 1 + +Raw dump of debug contents of section \.z?debug_line: + + Offset: 0x0 + Length: .* + DWARF Version: 4 + Prologue Length: .* + Minimum Instruction Length: 1 + Maximum Ops per Instruction: 1 + Initial value of 'is_stmt': 1 + Line Base: -5 + Line Range: 14 + Opcode Base: 13 + + Opcodes: + Opcode 1 has 0 args + Opcode 2 has 1 arg + Opcode 3 has 1 arg + Opcode 4 has 1 arg + Opcode 5 has 1 arg + Opcode 6 has 0 args + Opcode 7 has 0 args + Opcode 8 has 0 args + Opcode 9 has 1 arg + Opcode 10 has 0 args + Opcode 11 has 0 args + Opcode 12 has 1 arg + + The Directory Table \(offset 0x.*\): + 1 .*/gas/testsuite/gas/i386 + + The File Name Table \(offset 0x.*\): + Entry Dir Time Size Name + 1 0 0 0 foo.c + 2 0 0 0 foo.h + + Line Number Statements: + \[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.*\] 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 + \[0x.*\] Extended opcode 1: End of Sequence + + diff --git a/gas/testsuite/gas/i386/dwarf4-line-1.s b/gas/testsuite/gas/i386/dwarf4-line-1.s new file mode 100644 index 0000000..e558fdc --- /dev/null +++ b/gas/testsuite/gas/i386/dwarf4-line-1.s @@ -0,0 +1,14 @@ + .file "foo.c" + .text +bar: +#APP +# 82 "foo.h" 1 + nop +# 0 "" 2 +#NO_APP + ret +foo: + .file 1 "foo.c" + nop + .file 2 "foo.h" + ret diff --git a/gas/testsuite/gas/i386/i386.exp b/gas/testsuite/gas/i386/i386.exp index 1e761e9..c85ced1 100644 --- a/gas/testsuite/gas/i386/i386.exp +++ b/gas/testsuite/gas/i386/i386.exp @@ -619,6 +619,7 @@ if [gas_32_check] then { run_dump_test "dwarf2-line-2" run_dump_test "dwarf2-line-3" run_dump_test "dwarf2-line-4" + run_dump_test "dwarf4-line-1" run_dump_test "dwarf5-line-1" run_dump_test "dwarf5-line-2" run_dump_test "dwarf5-line-3" |