public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
* [binutils-gdb] gas: restore Dwarf info generation after macro diagnostic adjustments
@ 2022-12-16  8:01 Jan Beulich
  0 siblings, 0 replies; only message in thread
From: Jan Beulich @ 2022-12-16  8:01 UTC (permalink / raw)
  To: bfd-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=22a8433e00fd33efcb1fa4961eb826cd97f2cd8b

commit 22a8433e00fd33efcb1fa4961eb826cd97f2cd8b
Author: Jan Beulich <jbeulich@suse.com>
Date:   Fri Dec 16 09:01:14 2022 +0100

    gas: restore Dwarf info generation after macro diagnostic adjustments
    
    While 6fdb723799e2 ("gas: re-work line number tracking for macros and
    their expansions") was meant to leave generated Dwarf as is, it really
    didn't (and the testcase intended to catch that wasn't covering the case
    which broke). Its adjustment to buffer_and_nest() didn't go far enough,
    leading to the "linefile" directive inserted at the top to also be
    processed later in the PR gas/16908 workaround (which clearly isn't
    intended - it's being put there for processing during macro expansion
    only). That unnoticed flaw in turn led me to work around it by a
    (suspicious to me already at the time) conditional in as_where().

Diff:
---
 gas/input-scrub.c                               |  3 ---
 gas/macro.c                                     |  5 +++--
 gas/testsuite/gas/elf/dwarf-5-macro-include.d   | 17 +++++++++++++++++
 gas/testsuite/gas/elf/dwarf-5-macro-include.inc |  3 +++
 gas/testsuite/gas/elf/dwarf-5-macro-include.s   |  5 +++++
 gas/testsuite/gas/elf/elf.exp                   |  1 +
 6 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/gas/input-scrub.c b/gas/input-scrub.c
index 6791ef27749..c967fadc0fc 100644
--- a/gas/input-scrub.c
+++ b/gas/input-scrub.c
@@ -564,9 +564,6 @@ as_where (unsigned int *linep)
 
       do
 	{
-	  if (!saved->is_linefile)
-	    break;
-
 	  if (expansion != expanding_macro)
 	    /* Nothing.  */;
 	  else if (saved->logical_input_file != NULL
diff --git a/gas/macro.c b/gas/macro.c
index c41b9c00421..714fca52270 100644
--- a/gas/macro.c
+++ b/gas/macro.c
@@ -120,8 +120,7 @@ buffer_and_nest (const char *from, const char *to, sb *ptr,
   size_t from_len;
   size_t to_len = strlen (to);
   int depth = 1;
-  size_t line_start = ptr->len;
-  size_t more = get_line (ptr);
+  size_t line_start, more;
 
   if (to_len == 4 && strcasecmp (to, "ENDR") == 0)
     {
@@ -147,6 +146,8 @@ buffer_and_nest (const char *from, const char *to, sb *ptr,
     xfree (linefile);
   }
 
+  line_start = ptr->len;
+  more = get_line (ptr);
   while (more)
     {
       /* Try to find the first pseudo op on the line.  */
diff --git a/gas/testsuite/gas/elf/dwarf-5-macro-include.d b/gas/testsuite/gas/elf/dwarf-5-macro-include.d
new file mode 100644
index 00000000000..32ea6386992
--- /dev/null
+++ b/gas/testsuite/gas/elf/dwarf-5-macro-include.d
@@ -0,0 +1,17 @@
+#as: --gdwarf-5 -I${srcdir}/$subdir
+#name: line number entries for expansions of .macro coming from .include
+#readelf: -W -wl
+# The am33 cr16 crx ft32 mn10* msp430 nds32* and rl78 targets do not evaluate the subtraction of symbols at assembly time.
+# 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: am33*-* cr16-* crx-* d30v-* ft32-* mn10*-* msp430-* nds32*-* riscv*-* rl78-*
+
+Raw dump of debug contents .*
+#...
+ Line Number Statements:
+.*Extended opcode 2: .*
+.*Special opcode .* advance Address by 0 .* and Line by 2 to 3
+.*Special opcode .* and Line by 1 to 4
+.*Special opcode .* and Line by 1 to 5
+.*Advance PC by .*
+.*Extended opcode 1: End of Sequence
diff --git a/gas/testsuite/gas/elf/dwarf-5-macro-include.inc b/gas/testsuite/gas/elf/dwarf-5-macro-include.inc
new file mode 100644
index 00000000000..7322377fac4
--- /dev/null
+++ b/gas/testsuite/gas/elf/dwarf-5-macro-include.inc
@@ -0,0 +1,3 @@
+	.macro m1 args:vararg
+	.nop
+	.endm
diff --git a/gas/testsuite/gas/elf/dwarf-5-macro-include.s b/gas/testsuite/gas/elf/dwarf-5-macro-include.s
new file mode 100644
index 00000000000..6b6832ac61f
--- /dev/null
+++ b/gas/testsuite/gas/elf/dwarf-5-macro-include.s
@@ -0,0 +1,5 @@
+	.include "dwarf-5-macro-include.inc"
+
+	m1 1
+	m1 2
+	m1 3
diff --git a/gas/testsuite/gas/elf/elf.exp b/gas/testsuite/gas/elf/elf.exp
index 145814b62be..105708d4e4d 100644
--- a/gas/testsuite/gas/elf/elf.exp
+++ b/gas/testsuite/gas/elf/elf.exp
@@ -309,6 +309,7 @@ if { [is_elf_format] } then {
     run_dump_test "dwarf-5-nop-for-line-table" $dump_opts
     run_dump_test "dwarf-5-irp" $dump_opts
     run_dump_test "dwarf-5-macro" $dump_opts
+    run_dump_test "dwarf-5-macro-include" $dump_opts
     run_dump_test "dwarf-3-func" $dump_opts
     run_dump_test "dwarf-5-func" $dump_opts
     run_dump_test "dwarf-5-func-global" $dump_opts

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-12-16  8:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-16  8:01 [binutils-gdb] gas: restore Dwarf info generation after macro diagnostic adjustments Jan Beulich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).