From: Tom de Vries Date: Sat, 30 Jun 2018 08:07:01 +0000 (+0000) Subject: [testsuite/guality] Use relative line numbers in gdb-test X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f269206b1b9d10401e7afc99e37050892d26d014;p=gcc.git [testsuite/guality] Use relative line numbers in gdb-test 2018-06-30 Tom de Vries * gcc.dg/guality/pr45882.c (foo): Use relative line numbers. * lib/gcc-dg.exp (dg-final): New proc. * lib/gcc-gdb-test.exp (gdb-test): Add and handle additional line number argument. From-SVN: r262269 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 063b271cd93..da2abc1937e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2018-06-30 Tom de Vries + + * gcc.dg/guality/pr45882.c (foo): Use relative line numbers. + * lib/gcc-dg.exp (dg-final): New proc. + * lib/gcc-gdb-test.exp (gdb-test): Add and handle additional line number + argument. + 2018-06-29 Martin Sebor * gcc.dg/strlenopt-46.c: Define strnlen for targets like Solaris 10 diff --git a/gcc/testsuite/gcc.dg/guality/pr45882.c b/gcc/testsuite/gcc.dg/guality/pr45882.c index da9e2755590..02d74389ea0 100644 --- a/gcc/testsuite/gcc.dg/guality/pr45882.c +++ b/gcc/testsuite/gcc.dg/guality/pr45882.c @@ -9,11 +9,11 @@ volatile short int v; __attribute__((noinline,noclone,used)) int foo (int i, int j) { - int b = i; /* { dg-final { gdb-test bpline "b" "7" } } */ - int c = i + 4; /* { dg-final { gdb-test bpline "c" "11" } } */ - int d = a[i]; /* { dg-final { gdb-test bpline "d" "112" } } */ - int e = a[i + 6]; /* { dg-final { gdb-test bpline "e" "142" } } */ - ++v; /* { dg-line bpline } */ + int b = i; /* { dg-final { gdb-test .+4 "b" "7" } } */ + int c = i + 4; /* { dg-final { gdb-test .+3 "c" "11" } } */ + int d = a[i]; /* { dg-final { gdb-test .+2 "d" "112" } } */ + int e = a[i + 6]; /* { dg-final { gdb-test .+1 "e" "142" } } */ + ++v; return ++j; } diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp index 22065c7e3fe..6f88ce2213e 100644 --- a/gcc/testsuite/lib/gcc-dg.exp +++ b/gcc/testsuite/lib/gcc-dg.exp @@ -114,6 +114,26 @@ if [info exists ADDITIONAL_TORTURE_OPTIONS] { [concat $DG_TORTURE_OPTIONS $ADDITIONAL_TORTURE_OPTIONS] } +proc dg-final { args } { + upvar dg-final-code final-code + + if { [llength $args] > 2 } { + error "[lindex $args 0]: too many arguments" + } + set line [lindex $args 0] + set code [lindex $args 1] + set directive [lindex $code 0] + set withline \ + [switch $directive { + gdb-test {expr {1}} + default {expr {0}} + }] + if { $withline == 1 } { + set code [linsert $code 1 $line] + } + append final-code "$code\n" +} + global orig_environment_saved # Deduce generated files from tool flags, return finalcode string diff --git a/gcc/testsuite/lib/gcc-gdb-test.exp b/gcc/testsuite/lib/gcc-gdb-test.exp index 5457e7a793e..c446f5b122d 100644 --- a/gcc/testsuite/lib/gcc-gdb-test.exp +++ b/gcc/testsuite/lib/gcc-gdb-test.exp @@ -26,7 +26,7 @@ # calling print on it in gdb. When asking for the type it is # the literal string with extra whitespace removed. # Argument 3 handles expected failures and the like -proc gdb-test { args } { +proc gdb-test { useline args } { if { ![isnative] || [is_remote target] } { return } if { [llength $args] >= 4 } { @@ -60,7 +60,7 @@ proc gdb-test { args } { set cmd_file "[file rootname [file tail $prog]].gdb" set fd [open $cmd_file "w"] - set line [get-absolute-line "" [lindex $args 0]] + set line [get-absolute-line $useline [lindex $args 0]] puts $fd "break $line" puts $fd "run" puts $fd "$command $var"