Optional matching for run_dump_test
authorAlan Modra <amodra@gmail.com>
Sat, 7 Dec 2019 12:02:52 +0000 (22:32 +1030)
committerAlan Modra <amodra@gmail.com>
Sun, 8 Dec 2019 11:33:53 +0000 (22:03 +1030)
This adds an alternative to using #... in dump files, useful where we
only want to allow specific extra output.  DW_CFA_nop in CIEs and FDEs
to pad out to required alignment (larger for 64-bit than 32-bit) is
an example where these optional match patterns are useful.

binutils/
* testsuite/lib/binutils-common.exp (regexp_diff): Support #?REGEXP.
ld/
* testsuite/ld-elf/eh4.d: Match optional padding DW_CFA_nop in FDEs.
* testsuite/ld-elf/eh5.d: Likewise, and extra CIEs emitted on
embedded targets.

binutils/ChangeLog
binutils/testsuite/lib/binutils-common.exp
ld/ChangeLog
ld/testsuite/ld-elf/eh4.d
ld/testsuite/ld-elf/eh5.d

index d91298924cfe196243412a9524c08f76181f57c1..ef72f21be3694a55b0182330509a495d2e4cfa21 100644 (file)
@@ -1,3 +1,7 @@
+2019-12-08  Alan Modra  <amodra@gmail.com>
+
+       * testsuite/lib/binutils-common.exp (regexp_diff): Support #?REGEXP.
+
 2019-11-22  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * dwarf.c (regname_internal_riscv): New function.
index 3b229babeb96d848e6ea74e211c15cd4993d2c96..f2efa236518604d2c737684ae46947df682414c0 100644 (file)
@@ -286,6 +286,10 @@ proc check_shared_lib_support { } {
 #    REGEXP
 #        Skip all lines in FILE_1 until the first that matches REGEXP.
 #
+#    #?REGEXP
+#        Optionally match REGEXP against line from FILE_1.  If the REGEXP
+#        does not match then the next line from FILE_2 is tried.
+#
 # Other # lines are comments.  Regexp lines starting with the `!' character
 # specify inverse matching (use `\!' for literal matching against a leading
 # `!').  Skip empty lines in both files.
@@ -372,6 +376,21 @@ proc regexp_diff { file_1 file_2 args } {
                    }
                }
                break
+           } elseif { [string match "#\\?*" $line_b] } {
+               if { ! $end_1 } {
+                   set line_b [string replace $line_b 0 1]
+                   set negated [expr { [string index $line_b 0] == "!" }]
+                   set line_bx [string range $line_b $negated end]
+                   set n [expr { $negated ? "! " : "" }]
+                   # Substitute on the reference.
+                   foreach {name value} $ref_subst {
+                       regsub -- $name $line_bx $value line_bx
+                   }
+                   verbose "optional match for $n\"^$line_bx$\"" 3
+                   if { [expr [regexp "^$line_bx$" "$line_a"] != $negated] } {
+                       break
+                   }
+               }
            }
            if { [gets $file_b line_b] == $eof } {
                set end_2 1
index 8c07ff6bc701cf0ddfeb304d32bf5cf1d058a669..a70421478bf6f44ce5fb41ba2de3235338376bbb 100644 (file)
@@ -1,3 +1,9 @@
+2019-12-08  Alan Modra  <amodra@gmail.com>
+
+       * testsuite/ld-elf/eh4.d: Match optional padding DW_CFA_nop in FDEs.
+       * testsuite/ld-elf/eh5.d: Likewise, and extra CIEs emitted on
+       embedded targets.
+
 2019-12-06  Alan Modra  <amodra@gmail.com>
 
        * testsuite/ld-mips-elf/eh-frame1-n32.d: Pass --eh-frame-hdr to ld.
index 391efb8cd2a85c548418924d4a82a17aa72b63f4..f33431a8b7fed3285b8a6f438934e969f9a21f32 100644 (file)
@@ -34,6 +34,10 @@ Contents of the .eh_frame section:
   DW_CFA_def_cfa_offset: 24
   DW_CFA_advance_loc: [0-9a-f]+ to [0-9a-f]+
   DW_CFA_def_cfa_expression \(DW_OP_breg7 \(rsp\): 8; DW_OP_breg16 \(rip\): 0;.*
-#...
+#?  DW_CFA_nop
+#?  DW_CFA_nop
+#?  DW_CFA_nop
+#?  DW_CFA_nop
+
 [0-9a-f]+ ZERO terminator
 #pass
index e61db610a4129305c60be4a9640bbb3fbbd02a3c..4a69748235587f5484aeec6f2d56eaa59f2e64bb 100644 (file)
@@ -19,7 +19,11 @@ Contents of the .eh_frame section:
   DW_CFA_nop
   DW_CFA_nop
   DW_CFA_nop
-#...
+#?  DW_CFA_nop
+#?  DW_CFA_nop
+#?  DW_CFA_nop
+#?  DW_CFA_nop
+
 0+001[48] 0+0014 0+001[8c] FDE cie=0+0000 pc=.*
   DW_CFA_advance_loc: 4 to .*
   DW_CFA_def_cfa: r0(.*) ofs 16
@@ -62,7 +66,11 @@ Contents of the .eh_frame section:
   DW_CFA_nop
   DW_CFA_nop
   DW_CFA_nop
-#...
+#?  DW_CFA_nop
+#?  DW_CFA_nop
+#?  DW_CFA_nop
+#?  DW_CFA_nop
+
 0+009[08] 0+001c 0+002[04] FDE cie=0+007[48] pc=.*
   Augmentation data:     (ef be ad de 00 00 00 00|00 00 00 00 de ad be ef)
 
@@ -81,12 +89,20 @@ Contents of the .eh_frame section:
   Augmentation data:     (0b|1b)
 
   DW_CFA_def_cfa: r0(.*) ofs 16
-#...
+#?  DW_CFA_nop
+#?  DW_CFA_nop
+#?  DW_CFA_nop
+#?  DW_CFA_nop
+
 0+00(c4|d0) 0+001[04] 0+001[8c] FDE cie=0+00b[08] pc=.*
   DW_CFA_nop
   DW_CFA_nop
   DW_CFA_nop
-#...
+#?  DW_CFA_nop
+#?  DW_CFA_nop
+#?  DW_CFA_nop
+#?  DW_CFA_nop
+
 0+00[de]8 0+0014 0+0000 CIE
   Version:               [13]
   Augmentation:          "zPR"
@@ -108,7 +124,11 @@ Contents of the .eh_frame section:
   DW_CFA_nop
   DW_CFA_nop
   DW_CFA_nop
-#...
+#?  DW_CFA_nop
+#?  DW_CFA_nop
+#?  DW_CFA_nop
+#?  DW_CFA_nop
+
 0+01(1c|30) 0+001[8c] 0+0000 CIE
   Version:               [13]
   Augmentation:          "zPLR"
@@ -120,7 +140,11 @@ Contents of the .eh_frame section:
   DW_CFA_nop
   DW_CFA_nop
   DW_CFA_nop
-#...
+#?  DW_CFA_nop
+#?  DW_CFA_nop
+#?  DW_CFA_nop
+#?  DW_CFA_nop
+
 0+01(38|50) 0+001c 0+002[04] FDE cie=0+01(1c|30) pc=.*
   Augmentation data:     (ef be ad de 00 00 00 00|00 00 00 00 de ad be ef)
 
@@ -136,7 +160,16 @@ Contents of the .eh_frame section:
   DW_CFA_nop
   DW_CFA_nop
   DW_CFA_nop
-#...
+
+#?0+0170 0+0014 0+ CIE
+#?  Version:               1
+#?  Augmentation:          "zPR"
+#?  Code alignment factor: .*
+#?  Data alignment factor: .*
+#?  Return address column: .*
+#?  Augmentation data:     03 .. .. .. .. 1b
+#?  DW_CFA_nop
+
 0+01(70|88) 0+0014 0+0(01c|148|15c) FDE cie=0+0(02c|030|170) pc=.*
   DW_CFA_advance_loc: 4 to .*
   DW_CFA_def_cfa: r0(.*) ofs 16
@@ -150,7 +183,18 @@ Contents of the .eh_frame section:
   DW_CFA_nop
   DW_CFA_nop
   DW_CFA_nop
-#...
+
+#?0+01b8 0+0018 0+ CIE
+#?  Version:               1
+#?  Augmentation:          "zPLR"
+#?  Code alignment factor: .*
+#?  Data alignment factor: .*
+#?  Return address column: .*
+#?  Augmentation data:     03 .. .. .. .. 0c 1b
+#?  DW_CFA_nop
+#?  DW_CFA_nop
+#?  DW_CFA_nop
+
 0+01(a0|b8|d4) 0+001c 0+0(020|130|144) FDE cie=0+0(074|078|1b8) pc=.*
   Augmentation data:     (ef be ad de 00 00 00 00|00 00 00 00 de ad be ef)
 
This page took 0.028552 seconds and 4 git commands to generate.