gdb/testsuite: make DWARF assembler's ranges' "base" and "range" procs
authorSimon Marchi <simon.marchi@efficios.com>
Fri, 6 Nov 2020 18:09:58 +0000 (13:09 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Fri, 6 Nov 2020 18:10:29 +0000 (13:10 -0500)
When creating a .debug_ranges section using the testsuite's DWARF
assembler, it currently looks like this:

  ranges {
    sequence {
      {base ...}
      {range ...}
      {range ...}
    }
  }

The sub-tree of sequence is manually traversed as a list of lists.  I
think it would be nicer if `base` and `range` where procedure, just like
the other levels:

  ranges {
    sequence {
      base ...
      range ...
      range ...
    }
  }

That makes the implementation more robust, and the usage a bit nicer
(less special characters).  It also allows having comments in between
the range list entries:

  ranges {
    sequence {
      base ...
      range ...

      # Hello world.
      range ...
    }
  }

... which doesn't work with the current approach.

gdb/testsuite/ChangeLog:

* lib/dwarf.exp (ranges): Handle "base" and "range" as
proceduresu.
* gdb.dwarf/dw2-bad-elf.exp: Adjust.
* gdb.dwarf2/dw2-inline-many-frames.exp: Adjust.
* gdb.dwarf2/dw2-inline-stepping.exp: Adjust.
* gdb.dwarf2/dw2-ranges-base.exp: Adjust.
* gdb.dwarf2/dw2-ranges-func.exp: Adjust.
* gdb.dwarf2/dw2-ranges-overlap.exp: Adjust.
* gdb.dwarf2/dw2-ranges-psym.exp: Adjust.
* gdb.dwarf2/enqueued-cu-base-addr.exp: Adjust.

Change-Id: I0b2af480faff54d0fd4214e0cc8d042d9583a865

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.dwarf2/dw2-bad-elf.exp
gdb/testsuite/gdb.dwarf2/dw2-inline-many-frames.exp
gdb/testsuite/gdb.dwarf2/dw2-inline-stepping.exp
gdb/testsuite/gdb.dwarf2/dw2-ranges-base.exp
gdb/testsuite/gdb.dwarf2/dw2-ranges-func.exp
gdb/testsuite/gdb.dwarf2/dw2-ranges-overlap.exp
gdb/testsuite/gdb.dwarf2/dw2-ranges-psym.exp
gdb/testsuite/gdb.dwarf2/enqueued-cu-base-addr.exp
gdb/testsuite/lib/dwarf.exp

index 06ca3e7137412d3d8a40a1ffd5ae9061e14fee6e..42c317a053c047ae2cc83c334962aaa22cb8ce23 100644 (file)
@@ -1,3 +1,16 @@
+2020-11-06  Simon Marchi  <simon.marchi@efficios.com>
+
+       * lib/dwarf.exp (ranges): Handle "base" and "range" as
+       proceduresu.
+       * gdb.dwarf/dw2-bad-elf.exp: Adjust.
+       * gdb.dwarf2/dw2-inline-many-frames.exp: Adjust.
+       * gdb.dwarf2/dw2-inline-stepping.exp: Adjust.
+       * gdb.dwarf2/dw2-ranges-base.exp: Adjust.
+       * gdb.dwarf2/dw2-ranges-func.exp: Adjust.
+       * gdb.dwarf2/dw2-ranges-overlap.exp: Adjust.
+       * gdb.dwarf2/dw2-ranges-psym.exp: Adjust.
+       * gdb.dwarf2/enqueued-cu-base-addr.exp: Adjust.
+
 2020-11-04  Tom Tromey  <tromey@adacore.com>
 
        * gdb.ada/funcall_ref.exp: Update.
index e939046e9613e95b45e4fc3e92f11cfb0e5bea3c..20ecd68e7f12b243eb4257d076c3e2330a1313dd 100644 (file)
@@ -107,12 +107,12 @@ Dwarf::assemble $asm_file {
 
     ranges {is_64 [is_64_target]} {
        ranges_label_1: sequence {
-           {base [lindex $main_result 0]}
-           {range 0 [lindex $main_result 1]}
+           base [lindex $main_result 0]
+           range 0 [lindex $main_result 1]
        }
        ranges_label_2: sequence {
-           {base some_func}
-           {range 0 64}
+           base some_func
+           range 0 64
        }
     }
 
index 935d519934cc3058600c8650c6ce0769afaab798..591a92765775871d0b3bc5e7eaf2ac463c0d1d70 100644 (file)
@@ -281,12 +281,12 @@ Dwarf::assemble $asm_file {
 
     ranges {is_64 [is_64_target]} {
        ranges_label: sequence {
-           {range {${main_start}} ${main_end}}
-           {range {${ddd_start}} ${ddd_end}}
-           {range {${eee_start}} ${eee_end}}
-           {range {${fff_start}} ${fff_end}}
-           {range {${jjj_start}} ${jjj_end}}
-           {range {${kkk_start}} ${kkk_end}}
+           range ${main_start} ${main_end}
+           range ${ddd_start} ${ddd_end}
+           range ${eee_start} ${eee_end}
+           range ${fff_start} ${fff_end}
+           range ${jjj_start} ${jjj_end}
+           range ${kkk_start} ${kkk_end}
        }
     }
 }
index 24fbb717b2280c1b99fcf56a148bf174dbcb4c2c..a5853242dc516677d9bfe3783b0a14fd4c53bb12 100644 (file)
@@ -122,8 +122,8 @@ Dwarf::assemble $asm_file {
 
     ranges {is_64 [is_64_target]} {
        ranges_label: sequence {
-           {range {${main_start}} ${main_end}}
-           {range {${bar_start}} ${bar_end}}
+           range ${main_start} ${main_end}
+           range ${bar_start} ${bar_end}
        }
     }
 }
index 3f03fa6f7ec26f73e87c7be55428bc96c6db1c16..3164a908e70eff02c4cb0fa5b24e71de2d254d8e 100644 (file)
@@ -115,12 +115,12 @@ Dwarf::assemble $asm_file {
     # base for each function.
     ranges {is_64 [is_64_target]} {
        ranges_label: sequence {
-           {base [lindex $main_func 0]}
-           {range 0 [lindex $main_func 1]}
-           {base [lindex $frame2_func 0]}
-           {range 0 [lindex $frame2_func 1]}
-           {base [lindex $frame3_func 0]}
-           {range 0 [lindex $frame3_func 1]}
+           base [lindex $main_func 0]
+           range 0 [lindex $main_func 1]
+           base [lindex $frame2_func 0]
+           range 0 [lindex $frame2_func 1]
+           base [lindex $frame3_func 0]
+           range 0 [lindex $frame3_func 1]
        }
     }
 }
index ac37b24285a138a8442a90ad5b461b42e92b483b..504b4049c2f2c0590a98c78bf3286fb3ca8be74c 100644 (file)
@@ -199,15 +199,15 @@ proc do_test {suffix} {
        # Generate ranges data.
        ranges {is_64 [is_64_target]} {
            func_ranges_label: sequence {
-               {range {$foo_start } $foo_end}
-               {range {$foo_cold_start} $foo_cold_end}
+               range $foo_start $foo_end
+               range $foo_cold_start $foo_cold_end
            }
            cu_ranges_label: sequence {
-               {range {$foo_start } $foo_end}
-               {range {$foo_cold_start} $foo_cold_end}
-               {range {$main_start} $main_end}
-               {range {$bar_start} $bar_end}
-               {range {$baz_start} $baz_end}
+               range $foo_start $foo_end
+               range $foo_cold_start $foo_cold_end
+               range $main_start $main_end
+               range $bar_start $bar_end
+               range $baz_start $baz_end
            }
        }
     }
index 59c10c8ae249a4bec937d5b2fb4a34e4121f19f0..485f5c04f1f8c4544a739869e64a88f5c1106b58 100644 (file)
@@ -66,10 +66,10 @@ Dwarf::assemble $asm_file {
 
     ranges {is_64 [is_64_target]} {
        ranges_label: sequence {
-           {base [lindex $main_func 0]}
-           {range 0 [lindex $main_func 1]}
-           {base [lindex $bar_func 0]}
-           {range 0 [lindex $bar_func 1]}
+           base [lindex $main_func 0]
+           range 0 [lindex $main_func 1]
+           base [lindex $bar_func 0]
+           range 0 [lindex $bar_func 1]
        }
     }
 }
index 4ced125cd18a025d224146af979367fb233905ec..1be27c2622bc5d77c848eace42bd139d26d0314f 100644 (file)
@@ -108,14 +108,14 @@ Dwarf::assemble $asm_file {
     # Generate ranges data.
     ranges {is_64 [is_64_target]} {
        func_ranges_label: sequence {
-           {range {$foo_start } $foo_end}
-           {range {$foo_low_start} $foo_low_end}
+           range $foo_start $foo_end
+           range $foo_low_start $foo_low_end
        }
        cu_ranges_label: sequence {
-           {range {$foo_start } $foo_end}
-           {range {$foo_low_start} $foo_low_end}
-           {range {$bar_start} $bar_end}
-           {range {$baz_start} $baz_end}
+           range $foo_start $foo_end
+           range $foo_low_start $foo_low_end
+           range $bar_start $bar_end
+           range $baz_start $baz_end
        }
     }
 }
index 77fe6ff5e941313d9727dd7d2f4f1fcc169243af..e4ac1c9851ec44b6e742ec71519a7c43757c3473 100644 (file)
@@ -73,7 +73,7 @@ Dwarf::assemble $asm_file {
 
     ranges {is_64 [is_64_target]} {
        ranges_label: sequence {
-           {range 0 [lindex $main_func 1]}
+           range 0 [lindex $main_func 1]
        }
     }
 }
index c585621ac48a5ebee382dc837c5c47468d8783b4..c1596df58be030fe155667cf7f2dbba60edd22a3 100644 (file)
@@ -1247,42 +1247,37 @@ namespace eval Dwarf {
        set section ".debug_ranges"
        _section $section
 
-       proc sequence {{ranges {}}} {
+       proc sequence { body } {
            variable _debug_ranges_64_bit
 
            # Emit the sequence of addresses.
-           set base ""
-           foreach range $ranges {
-               set range [uplevel 1 "subst \"$range\""]
-               set type [lindex $range 0]
-               switch -exact -- $type {
-                   base {
-                       set base [lrange $range 1 end]
-
-                       if { $_debug_ranges_64_bit } then {
-                           _op .8byte 0xffffffffffffffff "Base Marker"
-                           _op .8byte $base "Base Address"
-                       } else {
-                           _op .4byte 0xffffffff "Base Marker"
-                           _op .4byte $base "Base Address"
-                       }
-                   }
-                   range {
-                       set start [lindex $range 1]
-                       set end [lrange $range 2 end]
-
-                       if { $_debug_ranges_64_bit } then {
-                           _op .8byte $start "Start Address"
-                           _op .8byte $end "End Address"
-                       } else {
-                           _op .4byte $start "Start Address"
-                           _op .4byte $end "End Address"
-                       }
-                   }
-                   default { error "unknown range type: $type " }
+
+           proc base { addr } {
+               variable _debug_ranges_64_bit
+
+               if { $_debug_ranges_64_bit } then {
+                   _op .8byte 0xffffffffffffffff "Base Marker"
+                   _op .8byte $addr "Base Address"
+               } else {
+                   _op .4byte 0xffffffff "Base Marker"
+                   _op .4byte $addr "Base Address"
                }
            }
 
+           proc range { start end } {
+               variable _debug_ranges_64_bit
+
+               if { $_debug_ranges_64_bit } then {
+                   _op .8byte $start "Start Address"
+                   _op .8byte $end "End Address"
+               } else {
+                   _op .4byte $start "Start Address"
+                   _op .4byte $end "End Address"
+               }
+           }
+
+           uplevel $body
+
            # End of the sequence.
            if { $_debug_ranges_64_bit } then {
                _op .8byte 0x0 "End of Sequence Marker (Part 1)"