]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb/testsuite: make declare_labels use better default label names
authorSimon Marchi <simon.marchi@efficios.com>
Fri, 4 Dec 2020 20:08:54 +0000 (15:08 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Fri, 4 Dec 2020 20:08:54 +0000 (15:08 -0500)
When using the single-element form of argument to declare_labels, the
generated label (in the assembly file) is of the format ".LlabelN",
where N is a number.

I propose making it use the name of the label by default.  Calling:

    declare_labels foo

will generate the ".LfooN" in the assembly file (again, where N is a
number).  When debugging the output of the DWARF assembler, it makes it
easier to map labels to the source.  Also, when defining the same label
twice by mistake in the Tcl code (like I d id), it's easier to track the
error from the message to the root cause:

    -/home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.dwarf2/implptrpiece/implptrpiece-dw.S:62: Error: symbol `.Llabel5' is already defined
    +/home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.dwarf2/implptrpiece/implptrpiece-dw.S:62: Error: symbol `.Lvar_label5' is already defined

This doesn't change anything for the test cases, it just makes the
assembly output a bit nicer.

gdb/testsuite/ChangeLog:

* lib/dwarf.exp (declare_labels): Use name as text if text is
not provided.

Change-Id: I63856c1fa6390498fd5b9d66f471f817ff0a465c

gdb/testsuite/ChangeLog
gdb/testsuite/lib/dwarf.exp

index 57b7208fe38739b326c43354fa172156620ea1e5..5de67b4fe9a1f4a8a5bb968247c0f03fd9bfe95a 100644 (file)
@@ -1,3 +1,8 @@
+2020-12-04  Simon Marchi  <simon.marchi@efficios.com>
+
+       * lib/dwarf.exp (declare_labels): Use name as text if text is
+       not provided.
+
 2020-12-04  Tom de Vries  <tdevries@suse.de>
 
        PR testsuite/26990
index c1596df58be030fe155667cf7f2dbba60edd22a3..ecd438b205ec0cf8233c0464f0520bb5bacbe088 100644 (file)
@@ -863,13 +863,13 @@ namespace eval Dwarf {
            set name [lindex $arg 0]
            set text [lindex $arg 1]
 
-           upvar $name label_var
-           if {$text == ""} {
-               set label_var [new_label]
-           } else {
-               set label_var [new_label $text]
+           if { $text == "" } {
+               set text $name
            }
 
+           upvar $name label_var
+           set label_var [new_label $text]
+
            proc ${name}: {args} [format {
                define_label %s
                uplevel $args