aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Beulich <jbeulich@suse.com>2024-08-05 16:29:54 +0200
committerJan Beulich <jbeulich@suse.com>2024-08-05 16:29:54 +0200
commitb43f37b77fd5d47466c7f35ec9acde68908d7aeb (patch)
treeee4e284a4857064c89f91e716925943e1afb7b43
parent526363dbe4524a5364853276caba3306b813b71c (diff)
downloadgdb-b43f37b77fd5d47466c7f35ec9acde68908d7aeb.zip
gdb-b43f37b77fd5d47466c7f35ec9acde68908d7aeb.tar.gz
gdb-b43f37b77fd5d47466c7f35ec9acde68908d7aeb.tar.bz2
gas: maintain line numbers correctly after #APP / #NO_APP
Maintaining line numbers correctly both inside the region and past it requires special care. The SB produced there is somewhat different from that produced for e.g. macro expansions, and hence also needs treating differently: In particular we aren't doing anything resembling macro expansion here. The new testcase may be a little misplaced in macros/, but that's where all the other #APP / #NO_APP ones are.
-rw-r--r--gas/input-scrub.c31
-rw-r--r--gas/read.c4
-rw-r--r--gas/sb.h1
-rw-r--r--gas/testsuite/gas/macros/app6.l7
-rw-r--r--gas/testsuite/gas/macros/app6.s11
-rw-r--r--gas/testsuite/gas/macros/macros.exp3
6 files changed, 48 insertions, 9 deletions
diff --git a/gas/input-scrub.c b/gas/input-scrub.c
index 776d15e..878edc8 100644
--- a/gas/input-scrub.c
+++ b/gas/input-scrub.c
@@ -194,10 +194,23 @@ input_scrub_pop (struct input_save *saved)
saved_position = saved->saved_position;
buffer_start = saved->buffer_start;
buffer_length = saved->buffer_length;
- physical_input_file = saved->physical_input_file;
+
+ /* When expanding an #APP / #NO_APP block, original lines are re-
+ processed, so whatever they did to physical file/line needs
+ retaining. If logical file/line weren't changed, the logical
+ line number will want bumping by a corresponding value. */
+ if (from_sb_expansion != expanding_app)
+ {
+ if (logical_input_file == 0 && logical_input_line == -1u
+ && saved->logical_input_line != -1u)
+ saved->logical_input_line
+ += physical_input_line - saved->physical_input_line;
+ physical_input_file = saved->physical_input_file;
+ physical_input_line = saved->physical_input_line;
+ }
logical_input_file = saved->logical_input_file;
- physical_input_line = saved->physical_input_line;
logical_input_line = saved->logical_input_line;
+
is_linefile = saved->is_linefile;
sb_index = saved->sb_index;
from_sb = saved->from_sb;
@@ -270,9 +283,12 @@ input_scrub_include_sb (sb *from, char *position, enum expansion expansion)
{
int newline;
- if (macro_nest > max_macro_nest)
- as_fatal (_("macros nested too deeply"));
- ++macro_nest;
+ if (expansion != expanding_app)
+ {
+ if (macro_nest > max_macro_nest)
+ as_fatal (_("macros nested too deeply"));
+ ++macro_nest;
+ }
#ifdef md_macro_start
if (expansion == expanding_macro)
@@ -335,7 +351,8 @@ input_scrub_next_buffer (char **bufp)
md_macro_end ();
#endif
}
- --macro_nest;
+ if (from_sb_expansion != expanding_app)
+ --macro_nest;
partial_where = NULL;
partial_size = 0;
if (next_saved_file != NULL)
@@ -432,7 +449,7 @@ seen_at_least_1_file (void)
void
bump_line_counters (void)
{
- if (sb_index == (size_t) -1)
+ if (sb_index == (size_t) -1 || from_sb_expansion == expanding_app)
++physical_input_line;
if (logical_input_line != -1u)
diff --git a/gas/read.c b/gas/read.c
index 7855193..ba31f8d 100644
--- a/gas/read.c
+++ b/gas/read.c
@@ -998,7 +998,6 @@ read_a_source_file (const char *name)
input_line_pointer = s;
continue;
}
- bump_line_counters ();
s += 4;
ends = find_no_app (s, next_char);
@@ -1023,9 +1022,10 @@ read_a_source_file (const char *name)
}
while (!ends);
}
+ sb_add_char (&sbuf, '\n');
input_line_pointer = ends ? ends + 8 : NULL;
- input_scrub_include_sb (&sbuf, input_line_pointer, expanding_none);
+ input_scrub_include_sb (&sbuf, input_line_pointer, expanding_app);
sb_kill (&sbuf);
buffer_limit = input_scrub_next_buffer (&input_line_pointer);
continue;
diff --git a/gas/sb.h b/gas/sb.h
index 2507d35..9c60f71 100644
--- a/gas/sb.h
+++ b/gas/sb.h
@@ -69,6 +69,7 @@ enum expansion {
expanding_none,
expanding_repeat,
expanding_macro,
+ expanding_app,
};
extern void input_scrub_include_sb (sb *, char *, enum expansion);
diff --git a/gas/testsuite/gas/macros/app6.l b/gas/testsuite/gas/macros/app6.l
new file mode 100644
index 0000000..6541fda
--- /dev/null
+++ b/gas/testsuite/gas/macros/app6.l
@@ -0,0 +1,7 @@
+.*: Assembler messages:
+.*:3: Warning: .*first.*
+.*:5: Warning: .*second.*
+.*:7: Warning: .*third.*
+.*:9: Warning: .*fourth.*
+.*:11: Warning: .*fifth.*
+#pass
diff --git a/gas/testsuite/gas/macros/app6.s b/gas/testsuite/gas/macros/app6.s
new file mode 100644
index 0000000..a88ba43
--- /dev/null
+++ b/gas/testsuite/gas/macros/app6.s
@@ -0,0 +1,11 @@
+#NO_APP
+ .data
+ .warning "first"
+#APP
+ .warning "second"
+ ;#NO_APP
+ .warning "third"
+ ;#APP
+ .warning "fourth"
+#NO_APP
+ .warning "fifth"
diff --git a/gas/testsuite/gas/macros/macros.exp b/gas/testsuite/gas/macros/macros.exp
index 69914f7..bb5d4ab 100644
--- a/gas/testsuite/gas/macros/macros.exp
+++ b/gas/testsuite/gas/macros/macros.exp
@@ -71,6 +71,9 @@ run_dump_test app3
remote_download host "$srcdir/$subdir/app4b.s"
run_dump_test app4
run_dump_test app5
+if { ![istarget tic30-*-*] } {
+ run_list_test app6 ""
+}
run_list_test badarg ""