]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb/testsuite: Move helper function into lib/dwarf.exp
authorAndrew Burgess <andrew.burgess@embecosm.com>
Fri, 3 Apr 2020 19:41:00 +0000 (20:41 +0100)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Tue, 14 Apr 2020 11:13:06 +0000 (12:13 +0100)
Every time I write a test making use of the DWARF assembler I end up
copying in the function get_func_info.  Duplicating code is bad, so
lets put this function into lib/dwarf.exp and remove all of the
duplicates.

There should be no changes in the testsuite behaviour after this
commit.

gdb/testsuite/ChangeLog:

* gdb.dwarf2/dw2-inline-many-frames.exp (get_func_info): Delete.
* gdb.dwarf2/dw2-inline-small-func.exp: Pass options to
get_func_info.
(get_func_info): Delete.
* gdb.dwarf2/dw2-is-stmt-2.exp (get_func_info): Delete.
* gdb.dwarf2/dw2-is-stmt.exp (get_func_info): Delete.
* lib/dwarf.exp (get_func_info): New function.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.dwarf2/dw2-inline-many-frames.exp
gdb/testsuite/gdb.dwarf2/dw2-inline-small-func.exp
gdb/testsuite/gdb.dwarf2/dw2-is-stmt-2.exp
gdb/testsuite/gdb.dwarf2/dw2-is-stmt.exp
gdb/testsuite/lib/dwarf.exp

index c7f80f7bb3df97921e87ecdfb5ccd6226ceb0294..0afe9d0f875343a9dd1337746d1557ab19b96d2d 100644 (file)
@@ -1,3 +1,13 @@
+2020-04-14  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+       * gdb.dwarf2/dw2-inline-many-frames.exp (get_func_info): Delete.
+       * gdb.dwarf2/dw2-inline-small-func.exp: Pass options to
+       get_func_info.
+       (get_func_info): Delete.
+       * gdb.dwarf2/dw2-is-stmt-2.exp (get_func_info): Delete.
+       * gdb.dwarf2/dw2-is-stmt.exp (get_func_info): Delete.
+       * lib/dwarf.exp (get_func_info): New function.
+
 2020-04-13  Tom de Vries  <tdevries@suse.de>
 
        * lib/ada.exp (find_ada_tool): Pass --GCC and -B to gnatlink, similar
index 146af8c6ef70806ded399a62bac7c1336bc31408..0c2c66122657e771c8e9cd5ec99f2ea6814497f8 100644 (file)
@@ -40,20 +40,6 @@ if !$gcc_compiled {
 
 standard_testfile dw2-inline-many-frames.c dw2-inline-many-frames.S
 
-# Extract the start, length, and end for function called NAME and
-# create suitable variables in the callers scope.
-proc get_func_info { name } {
-    global srcdir subdir srcfile
-
-    upvar 1 "${name}_start" func_start
-    upvar 1 "${name}_len" func_len
-    upvar 1 "${name}_end" func_end
-
-    lassign [function_range ${name} [list ${srcdir}/${subdir}/$srcfile]] \
-       func_start func_len
-    set func_end "$func_start + $func_len"
-}
-
 set asm_file [standard_output_file $srcfile2]
 Dwarf::assemble $asm_file {
     global srcdir subdir srcfile srcfile2
index 777db062b37ebd97a2bc613af0d52582742656f5..4fcc3cfeac9a3168d328c56abd3df820095e8d4c 100644 (file)
@@ -42,26 +42,12 @@ if !$gcc_compiled {
 standard_testfile dw2-inline-small-func-lbls.c dw2-inline-small-func.S \
     dw2-inline-small-func.c dw2-inline-small-func.h
 
-# Extract the start, length, and end for function called NAME and
-# create suitable variables in the callers scope.
-proc get_func_info { name } {
-    global srcdir subdir srcfile
-
-    upvar 1 "${name}_start" func_start
-    upvar 1 "${name}_len" func_len
-    upvar 1 "${name}_end" func_end
-
-    lassign [function_range ${name} [list ${srcdir}/${subdir}/$srcfile] {debug optimize=-O1}] \
-       func_start func_len
-    set func_end "$func_start + $func_len"
-}
-
 set asm_file [standard_output_file $srcfile2]
 Dwarf::assemble $asm_file {
     global srcdir subdir srcfile srcfile3 srcfile4
     declare_labels lines_label callee_subprog_label
 
-    get_func_info main
+    get_func_info main {debug optimize=-O1}
 
     cu {} {
        # It is important that the producer here be 'clang' as, at the
index 436c4d010244a6d5526906e21b5cc1c0bc84f354..2fcad93e957f6c3e60f2c6569b4ac65122ba51c7 100644 (file)
@@ -40,20 +40,6 @@ if !$gcc_compiled {
 
 standard_testfile dw2-is-stmt-2.c dw2-is-stmt-2.S
 
-# Extract the start, length, and end for function called NAME and
-# create suitable variables in the callers scope.
-proc get_func_info { name } {
-    global srcdir subdir srcfile
-
-    upvar 1 "${name}_start" func_start
-    upvar 1 "${name}_len" func_len
-    upvar 1 "${name}_end" func_end
-
-    lassign [function_range ${name} [list ${srcdir}/${subdir}/$srcfile]] \
-       func_start func_len
-    set func_end "$func_start + $func_len"
-}
-
 set asm_file [standard_output_file $srcfile2]
 Dwarf::assemble $asm_file {
     global srcdir subdir srcfile
index 1bcf5b0c6982d93f5ae4d326e56e7e79d6930a07..e200e91fd77a6827e25188447551fe439e651e9a 100644 (file)
@@ -40,20 +40,6 @@ if !$gcc_compiled {
 
 standard_testfile dw2-is-stmt.c dw2-is-stmt.S
 
-# Extract the start, length, and end for function called NAME and
-# create suitable variables in the callers scope.
-proc get_func_info { name } {
-    global srcdir subdir srcfile
-
-    upvar 1 "${name}_start" func_start
-    upvar 1 "${name}_len" func_len
-    upvar 1 "${name}_end" func_end
-
-    lassign [function_range ${name} [list ${srcdir}/${subdir}/$srcfile]] \
-       func_start func_len
-    set func_end "$func_start + $func_len"
-}
-
 set asm_file [standard_output_file $srcfile2]
 Dwarf::assemble $asm_file {
     global srcdir subdir srcfile
index 93bde76de35b85e228709a166bb32f8cd972b5ea..a7dbe25fd458411314e03554a968651d21618dd0 100644 (file)
@@ -164,6 +164,22 @@ proc function_range { func src {options {debug}} } {
     return [list "${func}_label - $func_label_offset" $func_length]
 }
 
+# Extract the start, length, and end for function called NAME and
+# create suitable variables in the callers scope.
+proc get_func_info { name {options {debug}} } {
+    global srcdir subdir srcfile
+
+    upvar 1 "${name}_start" func_start
+    upvar 1 "${name}_len" func_len
+    upvar 1 "${name}_end" func_end
+
+    lassign [function_range ${name} \
+                [list ${srcdir}/${subdir}/$srcfile] \
+                ${options}]  \
+       func_start func_len
+    set func_end "$func_start + $func_len"
+}
+
 # A DWARF assembler.
 #
 # All the variables in this namespace are private to the