bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug gas/16908] #line directives are ignored inside macros


From: cmetcalf at tilera dot com
Subject: [Bug gas/16908] #line directives are ignored inside macros
Date: Tue, 06 May 2014 20:44:38 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=16908

--- Comment #1 from Chris Metcalf <cmetcalf at tilera dot com> ---
The problem is that gas is paying attention to .linefile directives when it is
expanding the macro, and ignoring them when it is defining the macro.  It
should be the other way around.

To really fix the problem as reported, you might want a way to indicate that a
given macro should be expanded with debug line information referencing the
lines of the body of the macro, rather than the site of the macro expansion. 
But at least with the fix below, the debug information is now correct.

diff --git a/gas/macro.c b/gas/macro.c
index 4589bd8455db..bcd3a3203c32 100644
--- a/gas/macro.c
+++ b/gas/macro.c
@@ -211,6 +211,25 @@ buffer_and_nest (const char *from, const char *to, sb
*ptr,
                  break;
                }
            }
+         /* Apply and discard .linefile directives that appear within
+            the macro.  For long macros, one might want to report the
+            line number information associated with the lines within
+            the macro definition, but we would need more infrastructure
+            to make that happen correctly (e.g. resetting the line
+            number when expanding the macro), and since for short
+            macros we clearly prefer reporting the point of expansion
+            anyway, there's not an obviously better fix here.  */
+         if (strncasecmp (ptr->ptr + i, "linefile", 8) == 0)
+         {
+           char *saved_input_line_pointer = input_line_pointer;
+           char saved_eol_char = ptr->ptr[ptr->len];
+           ptr->ptr[ptr->len] = '\0';
+           input_line_pointer = ptr->ptr + i + 8;
+           s_app_line (0);
+           ptr->ptr[ptr->len] = saved_eol_char;
+           input_line_pointer = saved_input_line_pointer;
+           ptr->len = line_start;
+         }
        }

       /* Add the original end-of-line char to the end and keep running.  */

-- 
You are receiving this mail because:
You are on the CC list for the bug.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]