aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorJan Beulich <jbeulich@suse.com>2022-03-23 08:46:39 +0100
committerJan Beulich <jbeulich@suse.com>2022-03-23 08:46:39 +0100
commit7992631e8c0b0e711fbaba991348ef6f6e583725 (patch)
treee9de3979a5cba919d9903a1e3e7a5789cb8aa26f /gas
parent36e2d65d26622e83fa4c3af8289f6728376b9e89 (diff)
downloadgdb-7992631e8c0b0e711fbaba991348ef6f6e583725.zip
gdb-7992631e8c0b0e711fbaba991348ef6f6e583725.tar.gz
gdb-7992631e8c0b0e711fbaba991348ef6f6e583725.tar.bz2
gas/Dwarf: improve debug info generation from .irp and alike blocks
Tying the bumping of the logical line number to reading from the original source file looks wrong: Upon finishing of the processing of an sb the original values will be restored anyway. Yet without bumping the line counter uses of .line inside e.g. an .irp construct won't have the intended effect: Such uses may be necessary to ensure proper debug info is emitted in particular when switching sections inside the .irp body, as dwarf2_gen_line_info() would bail without doing anything when it finds the line number unchanged from what it saw last.
Diffstat (limited to 'gas')
-rw-r--r--gas/input-scrub.c9
-rw-r--r--gas/testsuite/gas/elf/dwarf-5-irp.d80
-rw-r--r--gas/testsuite/gas/elf/dwarf-5-irp.s31
-rw-r--r--gas/testsuite/gas/elf/elf.exp1
4 files changed, 116 insertions, 5 deletions
diff --git a/gas/input-scrub.c b/gas/input-scrub.c
index 26af4fe..d9f1694 100644
--- a/gas/input-scrub.c
+++ b/gas/input-scrub.c
@@ -429,11 +429,10 @@ void
bump_line_counters (void)
{
if (sb_index == (size_t) -1)
- {
- ++physical_input_line;
- if (logical_input_line != -1u)
- ++logical_input_line;
- }
+ ++physical_input_line;
+
+ if (logical_input_line != -1u)
+ ++logical_input_line;
}
/* Tells us what the new logical line number and file are.
diff --git a/gas/testsuite/gas/elf/dwarf-5-irp.d b/gas/testsuite/gas/elf/dwarf-5-irp.d
new file mode 100644
index 0000000..e7bdda7
--- /dev/null
+++ b/gas/testsuite/gas/elf/dwarf-5-irp.d
@@ -0,0 +1,80 @@
+#as: --gdwarf-5
+#name: line number entries for section changes inside .irp
+#readelf: -W -wlrR
+# The cr16 crx ft32 mn10* msp430 nds32* and rl78 targets do not evaluate the subtraction of symbols at assembly time.
+# The bfin target does not allow .subsection with an equated symbol as operand.
+# The d30v target emits sufficiently different debug info, apparently also covering padding it inserts.
+# The riscv targets do not support the subtraction of symbols.
+#xfail: bfin-* cr16-* crx-* d30v-* ft32-* mn10*-* msp430-* nds32*-* riscv*-* rl78-*
+
+Raw dump of debug contents .*
+#...
+ Line Number Statements:
+.*Extended opcode 2: .*
+.*Special opcode .* and Line by 2 to 3
+.*Set File Name to entry 2 .*
+.*Advance Line by 15 to 18
+.*Special opcode .* and Line by 0 to 18
+.*Special opcode .* and Line by 1 to 19
+.*Special opcode .* and Line by -1 to 18
+.*Special opcode .* and Line by 1 to 19
+.*Special opcode .* and Line by -1 to 18
+.*Special opcode .* and Line by 1 to 19
+.*Set File Name to entry 3 .*
+.*Advance Line by 9 to 28
+.*Special opcode .* and Line by 0 to 28
+.*Special opcode .* and Line by 1 to 29
+.*Special opcode .* and Line by -1 to 28
+.*Special opcode .* and Line by 1 to 29
+.*Special opcode .* and Line by -1 to 28
+.*Special opcode .* and Line by 1 to 29
+.*Advance PC by .*
+.*Extended opcode 1: End of Sequence
+
+.*Set File Name to entry 4 .*
+.*Extended opcode 2: .*
+.*Special opcode .* and Line by 8 to 9
+.*Special opcode .* and Line by 1 to 10
+.*Advance PC by .*
+.*Extended opcode 1: End of Sequence
+
+.*Set File Name to entry 4 .*
+.*Extended opcode 2: .*
+.*Special opcode .* and Line by 8 to 9
+.*Special opcode .* and Line by 1 to 10
+.*Advance PC by .*
+.*Extended opcode 1: End of Sequence
+
+.*Set File Name to entry 4 .*
+.*Extended opcode 2: .*
+.*Special opcode .* and Line by 8 to 9
+.*Special opcode .* and Line by 1 to 10
+.*Advance PC by .*
+.*Extended opcode 1: End of Sequence
+
+
+Contents of the \.debug_aranges section:
+
+ Length: .*
+ Version: +2
+ Offset into \.debug_info: .*
+ Pointer Size: +[248]
+ Segment Size: +0
+
+ Address +Length
+ 0+ [0-9a-f]+ ?
+ 0+ [0-9a-f]+ ?
+ 0+ [0-9a-f]+ ?
+ 0+ [0-9a-f]+ ?
+ 0+ 0+ ?
+
+Contents of the \.debug_rnglists section:
+
+ Offset +Begin +End
+ [0-9a-f]+ 0+ [0-9a-f]+ ?
+ [0-9a-f]+ 0+ [0-9a-f]+ ?
+ [0-9a-f]+ 0+ [0-9a-f]+ ?
+ [0-9a-f]+ 0+ [0-9a-f]+ ?
+ [0-9a-f]+ <End of list>
+
+#pass
diff --git a/gas/testsuite/gas/elf/dwarf-5-irp.s b/gas/testsuite/gas/elf/dwarf-5-irp.s
new file mode 100644
index 0000000..e9e8746
--- /dev/null
+++ b/gas/testsuite/gas/elf/dwarf-5-irp.s
@@ -0,0 +1,31 @@
+ .text
+_start:
+ .nop
+
+ .irp n, ab, ij, xy
+ .file "irp.s"
+ .line 7
+ .section .text.\n, "ax"
+ .nop
+ .nop
+ .endr
+
+ .text
+
+ .irpc n, 123
+ .file "irpc.s"
+ .line 16
+ .subsection \n
+ .nop
+ .nop
+ .endr
+
+ n = 9
+ .rept 3
+ .file "rept.s"
+ .line 26
+ .subsection n
+ .nop
+ .nop
+ n = n - 1
+ .endr
diff --git a/gas/testsuite/gas/elf/elf.exp b/gas/testsuite/gas/elf/elf.exp
index aacecb7..081ab4e 100644
--- a/gas/testsuite/gas/elf/elf.exp
+++ b/gas/testsuite/gas/elf/elf.exp
@@ -306,6 +306,7 @@ if { [is_elf_format] } then {
run_dump_test "dwarf-4-cu" $dump_opts
run_dump_test "dwarf-5-cu" $dump_opts
run_dump_test "dwarf-5-nop-for-line-table" $dump_opts
+ run_dump_test "dwarf-5-irp" $dump_opts
run_dump_test "pr25917"
run_dump_test "bss"
run_dump_test "bad-bss"