PATCH: PR gas/11356: "as -alm" returns very long lines

H.J. Lu hjl.tools@gmail.com
Tue Mar 9 01:41:00 GMT 2010


On Mon, Mar 8, 2010 at 4:39 PM, Alan Modra <amodra@gmail.com> wrote:
> On Mon, Mar 08, 2010 at 02:51:39PM -0800, H.J. Lu wrote:
>> My fix for PR 9966 didn't check EOL for `\`.  This patc fixes it.  OK
>> to install?
>
> No, your logic is still incorrect.  A backslash quote always lasts for
> exactly one char so the bug was that seen_slash stayed set.  I think
> the following is right.
>
>        PR gas/11356
>        * listing.c (listing_newline): Correct backslash quote logic.
>

How about this patch?

Thanks.

H.J.
---
gas/

2010-03-08  Alan Modra  <amodra@gmail.com>

	PR gas/11356
	* listing.c (listing_newline): Correct backslash quote logic.

gas/testsuite/

2010-03-08  H.J. Lu  <hongjiu.lu@intel.com>

	PR gas/9966
	PR gas/11356
	* gas/i386/list-1.l: New.
	* gas/i386/list-1.s: Likewise.
	* gas/i386/list-2.l: Likewise.
	* gas/i386/list-2.s: Likewise.
	* gas/i386/list-3.l: Likewise.
	* gas/i386/list-3.s: Likewise.

	* gas/i386/i386.exp: Run list-1, list-2 and list-3.

	* lib/gas-defs.exp (gas_run_stdin): New.
	(run_list_test_stdin): Likewise.
-------------- next part --------------
gas/

2010-03-08  Alan Modra  <amodra@gmail.com>

	PR gas/11356
	* listing.c (listing_newline): Correct backslash quote logic.

gas/testsuite/

2010-03-08  H.J. Lu  <hongjiu.lu@intel.com>

	PR gas/9966
	PR gas/11356
	* gas/i386/list-1.l: New.
	* gas/i386/list-1.s: Likewise.
	* gas/i386/list-2.l: Likewise.
	* gas/i386/list-2.s: Likewise.
	* gas/i386/list-3.l: Likewise.
	* gas/i386/list-3.s: Likewise.

	* gas/i386/i386.exp: Run list-1, list-2 and list-3.

	* lib/gas-defs.exp (gas_run_stdin): New.
	(run_list_test_stdin): Likewise.

diff --git a/gas/listing.c b/gas/listing.c
index 9a71c76..002b3c5 100644
--- a/gas/listing.c
+++ b/gas/listing.c
@@ -347,10 +347,12 @@ listing_newline (char *ps)
 			 || is_end_of_line [(unsigned char) *copy] != 1);
 	       copy++)
 	    {
-	      if (*copy == '\\')
-		seen_slash = ! seen_slash;
-	      else if (*copy == '"' && seen_slash)
-		seen_quote = ! seen_quote;
+	      if (seen_slash)
+		seen_slash = 0;
+	      else if (*copy == '\\')
+		seen_slash = 1;
+	      else if (*copy == '"')
+		seen_quote = !seen_quote;
 	    }
 
 	  len = copy - input_line_pointer + 1;
diff --git a/gas/testsuite/gas/i386/i386.exp b/gas/testsuite/gas/i386/i386.exp
index dc0be49..5c3f620 100644
--- a/gas/testsuite/gas/i386/i386.exp
+++ b/gas/testsuite/gas/i386/i386.exp
@@ -223,6 +223,9 @@ if [expr [istarget "i*86-*-*"] || [istarget "x86_64-*-*"]] then {
     run_dump_test "string-ok"
     run_list_test "string-bad" ""
     run_list_test "space1" "-al"
+    run_list_test_stdin "list-1" "-al"
+    run_list_test_stdin "list-2" "-al"
+    run_list_test_stdin "list-3" "-al"
 }
 
 if [expr ([istarget "i*86-*-*"] || [istarget "x86_64-*-*"]) && [gas_64_check]] then {
diff --git a/gas/testsuite/gas/i386/list-1.l b/gas/testsuite/gas/i386/list-1.l
new file mode 100644
index 0000000..158678f
--- /dev/null
+++ b/gas/testsuite/gas/i386/list-1.l
@@ -0,0 +1,14 @@
+GAS LISTING .*
+
+
+[ 	]*1[ 	]+\.section \.rodata
+[ 	]*2[ 	]+\.LC0:
+[ 	]*3[ 	]+0000 68616861 	 \.string "haha %x\\n"
+[ 	]*3[ 	]+2025780A 
+[ 	]*3[ 	]+00
+[ 	]*4[ 	]+\.text
+[ 	]*5[ 	]+\.globl hex
+[ 	]*6[ 	]+\.type hex,@function
+[ 	]*7[ 	]+hex:
+[ 	]*8[ 	]+0000 C9       	 leave
+[ 	]*9[ 	]+0001 C3       	 ret
diff --git a/gas/testsuite/gas/i386/list-1.s b/gas/testsuite/gas/i386/list-1.s
new file mode 100644
index 0000000..5fda484
--- /dev/null
+++ b/gas/testsuite/gas/i386/list-1.s
@@ -0,0 +1,9 @@
+	.section .rodata
+.LC0:
+	.string "haha %x\n"
+	.text
+.globl hex
+	.type hex, @function
+hex:
+	leave
+	ret
diff --git a/gas/testsuite/gas/i386/list-2.l b/gas/testsuite/gas/i386/list-2.l
new file mode 100644
index 0000000..38b529d
--- /dev/null
+++ b/gas/testsuite/gas/i386/list-2.l
@@ -0,0 +1,18 @@
+GAS LISTING .*
+
+
+[ 	]*1[ 	]+
+[ 	]*2[ 	]+\.L1:
+[ 	]*3[ 	]+0000 615C00   	 \.string "a\\\\"
+[ 	]*4[ 	]+0:
+[ 	]*5[ 	]+0003 6200     	 \.string "b"
+[ 	]*6[ 	]+1:
+[ 	]*7[ 	]+2:
+[ 	]*8[ 	]+3:
+[ 	]*9[ 	]+4:
+[ 	]*10[ 	]+5:
+[ 	]*11[ 	]+6:
+[ 	]*12[ 	]+7:
+[ 	]*13[ 	]+8:
+[ 	]*14[ 	]+9:
+[ 	]*15[ 	]+10:
diff --git a/gas/testsuite/gas/i386/list-2.s b/gas/testsuite/gas/i386/list-2.s
new file mode 100644
index 0000000..6bc96a0
--- /dev/null
+++ b/gas/testsuite/gas/i386/list-2.s
@@ -0,0 +1,15 @@
+
+.L1:
+	.string "a\\"
+0:
+	.string "b"
+1:
+2:
+3:
+4:
+5:
+6:
+7:
+8:
+9:
+10:
diff --git a/gas/testsuite/gas/i386/list-3.l b/gas/testsuite/gas/i386/list-3.l
new file mode 100644
index 0000000..9a7c27d
--- /dev/null
+++ b/gas/testsuite/gas/i386/list-3.l
@@ -0,0 +1,18 @@
+GAS LISTING .*
+
+
+[ 	]*1[ 	]+
+[ 	]*2[ 	]+\.L1:
+[ 	]*3[ 	]+0000 612200   	 \.string "a\\""
+[ 	]*4[ 	]+0:
+[ 	]*5[ 	]+0003 6200     	 \.string "b"
+[ 	]*6[ 	]+1:
+[ 	]*7[ 	]+2:
+[ 	]*8[ 	]+3:
+[ 	]*9[ 	]+4:
+[ 	]*10[ 	]+5:
+[ 	]*11[ 	]+6:
+[ 	]*12[ 	]+7:
+[ 	]*13[ 	]+8:
+[ 	]*14[ 	]+9:
+[ 	]*15[ 	]+10:
diff --git a/gas/testsuite/gas/i386/list-3.s b/gas/testsuite/gas/i386/list-3.s
new file mode 100644
index 0000000..847a189
--- /dev/null
+++ b/gas/testsuite/gas/i386/list-3.s
@@ -0,0 +1,15 @@
+
+.L1:
+	.string "a\""
+0:
+	.string "b"
+1:
+2:
+3:
+4:
+5:
+6:
+7:
+8:
+9:
+10:
diff --git a/gas/testsuite/lib/gas-defs.exp b/gas/testsuite/lib/gas-defs.exp
index 06bf04c..0506b94 100644
--- a/gas/testsuite/lib/gas-defs.exp
+++ b/gas/testsuite/lib/gas-defs.exp
@@ -116,6 +116,24 @@ proc gas_run { prog as_opts redir } {
     return [list $comp_output ""]
 }
 
+proc gas_run_stdin { prog as_opts redir } {
+    global AS
+    global ASFLAGS
+    global comp_output
+    global srcdir
+    global subdir
+    global host_triplet
+
+    set status [gas_host_run "$AS $ASFLAGS $as_opts < $srcdir/$subdir/$prog" "$redir"]
+    set comp_output [lindex $status 1]
+    if { [lindex $status 0] != 0 && [regexp "2>.*" $redir] } then {
+	append comp_output "child process exited abnormally"
+    }
+    set comp_output [prune_warnings $comp_output]
+    verbose "output was $comp_output"
+    return [list $comp_output ""]
+}
+
 proc all_ones { args } {
     foreach x $args { if [expr $x!=1] { return 0 } }
     return 1
@@ -990,3 +1008,22 @@ proc run_list_test { name {opts {}} {testname {}} } {
     }
     pass $testname
 }
+
+# run_list_test_stdin NAME (optional): OPTS TESTNAME
+#
+# Similar to run_list_test, but use stdin as input.
+
+proc run_list_test_stdin { name {opts {}} {testname {}} } {
+    global srcdir subdir
+    if { [string length $testname] == 0 } then {
+	set testname "[file tail $subdir] $name"
+    }
+    set file $srcdir/$subdir/$name
+    gas_run_stdin ${name}.s $opts ">&dump.out"
+    if { [regexp_diff "dump.out" "${file}.l"] } then {
+	fail $testname
+	verbose "output is [file_contents "dump.out"]" 2
+	return
+    }
+    pass $testname
+}


More information about the Binutils mailing list