This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[testsuite/guality, committed] Use @main as bp loc instead of line nrs in const-volatile.c


Hi,

this patch replaces the absolute line numbers used in gdb-test in guality
testcase const-volatile.c.

First there's line number 50, which used to point at the start of main:
...
    47  int
    48  main (int argc, char **argv)
    49  {
    50    score as = argc;
...
but has drifted in time to before f:
...
    48  score s;
    49  const score cs;
    50
    51  static __attribute__((noclone, noinline)) int
    52  f (const char *progname, volatile struct foo *dummy, const score s)
    53  {
...

Then there's line number 58, which already failed to set a breakpoint at the
initial commit, so I'm classifying that as a typo.

I could have used a dg-line at the start of main to introduce variable bp,
and then use that variable everywhere, but I've added a mechanism that allows
us to set breakpoints at function addresses, which means we don't need the
dg-line, and can just use '@main'.

Committed as obvious.

Thanks,
- Tom

[testsuite/guality] Use @main as bp loc instead of line nrs in const-volatile.c

2018-07-01  Tom de Vries  <tdevries@suse.de>

	* lib/gcc-gdb-test.exp (gdb-test): Handle '@' prefix in line number
	argument.
	* gcc.dg/guality/const-volatile.c: Replace gdb-test line nrs 50 and 58
	with @main.

---
 gcc/testsuite/gcc.dg/guality/const-volatile.c | 44 +++++++++++++--------------
 gcc/testsuite/lib/gcc-gdb-test.exp            |  7 ++++-
 2 files changed, 28 insertions(+), 23 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/guality/const-volatile.c b/gcc/testsuite/gcc.dg/guality/const-volatile.c
index d657f48079c..3bfca0d14d3 100644
--- a/gcc/testsuite/gcc.dg/guality/const-volatile.c
+++ b/gcc/testsuite/gcc.dg/guality/const-volatile.c
@@ -62,33 +62,33 @@ main (int argc, char **argv)
   return f (argv[0], &dummy, as) - 1;
 }
 
-/* { dg-final { gdb-test 50 "type:main" "int (int, char **)" } } */
+/* { dg-final { gdb-test "@main" "type:main" "int (int, char **)" } } */
 
-/* { dg-final { gdb-test 50 "type:i" "int" } } */
-/* { dg-final { gdb-test 50 "type:ci" "const int" } } */
-/* { dg-final { gdb-test 50 "type:vi" "volatile int" } } */
-/* { dg-final { gdb-test 50 "type:cvi" "const volatile int" } } */
+/* { dg-final { gdb-test "@main" "type:i" "int" } } */
+/* { dg-final { gdb-test "@main" "type:ci" "const int" } } */
+/* { dg-final { gdb-test "@main" "type:vi" "volatile int" } } */
+/* { dg-final { gdb-test "@main" "type:cvi" "const volatile int" } } */
 
-/* { dg-final { gdb-test 50 "type:pi" "int *" } } */
-/* { dg-final { gdb-test 50 "type:pci" "const int *" } } */
-/* { dg-final { gdb-test 50 "type:pvi" "volatile int *" } } */
-/* { dg-final { gdb-test 50 "type:pcvi" "const volatile int *" } } */
+/* { dg-final { gdb-test "@main" "type:pi" "int *" } } */
+/* { dg-final { gdb-test "@main" "type:pci" "const int *" } } */
+/* { dg-final { gdb-test "@main" "type:pvi" "volatile int *" } } */
+/* { dg-final { gdb-test "@main" "type:pcvi" "const volatile int *" } } */
 
-/* { dg-final { gdb-test 50 "type:cip" "int * const" } } */
-/* { dg-final { gdb-test 50 "type:vip" "int * volatile" } } */
-/* { dg-final { gdb-test 50 "type:cvip" "int * const volatile" } } */
+/* { dg-final { gdb-test "@main" "type:cip" "int * const" } } */
+/* { dg-final { gdb-test "@main" "type:vip" "int * volatile" } } */
+/* { dg-final { gdb-test "@main" "type:cvip" "int * const volatile" } } */
 
-/* { dg-final { gdb-test 50 "type:vs" "volatile struct { const long cli; const signed char csc; }" } } */
+/* { dg-final { gdb-test "@main" "type:vs" "volatile struct { const long cli; const signed char csc; }" } } */
 
-/* { dg-final { gdb-test 50 "type:cvip" "int * const volatile" } } */
+/* { dg-final { gdb-test "@main" "type:cvip" "int * const volatile" } } */
 
-/* { dg-final { gdb-test 50 "type:bar" "struct bar { short s; const short cs; volatile short vs; const volatile short cvs; volatile long long vll; }" } } */
-/* { dg-final { gdb-test 50 "type:foo" "struct foo { const long cli; const signed char csc; }" } } */
-/* { dg-final { gdb-test 50 "type:cfoo" "const struct foo { const long cli; const signed char csc; }" } } */
-/* { dg-final { gdb-test 50 "type:vfoo" "volatile struct foo { const long cli; const signed char csc; }" } } */
-/* { dg-final { gdb-test 50 "type:cvfoo" "const volatile struct foo { const long cli; const signed char csc; }" } } */
+/* { dg-final { gdb-test "@main" "type:bar" "struct bar { short s; const short cs; volatile short vs; const volatile short cvs; volatile long long vll; }" } } */
+/* { dg-final { gdb-test "@main" "type:foo" "struct foo { const long cli; const signed char csc; }" } } */
+/* { dg-final { gdb-test "@main" "type:cfoo" "const struct foo { const long cli; const signed char csc; }" } } */
+/* { dg-final { gdb-test "@main" "type:vfoo" "volatile struct foo { const long cli; const signed char csc; }" } } */
+/* { dg-final { gdb-test "@main" "type:cvfoo" "const volatile struct foo { const long cli; const signed char csc; }" } } */
 
-/* { dg-final { gdb-test 58 "type:s" "volatile signed char" } } */
-/* { dg-final { gdb-test 50 "type:cs" "const volatile signed char" } } */
+/* { dg-final { gdb-test "@main" "type:s" "volatile signed char" } } */
+/* { dg-final { gdb-test "@main" "type:cs" "const volatile signed char" } } */
 
-/* { dg-final { gdb-test 50 "type:f" "int (const char *, volatile struct foo *, const score)" } } */
+/* { dg-final { gdb-test "@main" "type:f" "int (const char *, volatile struct foo *, const score)" } } */
diff --git a/gcc/testsuite/lib/gcc-gdb-test.exp b/gcc/testsuite/lib/gcc-gdb-test.exp
index c446f5b122d..bb966d43023 100644
--- a/gcc/testsuite/lib/gcc-gdb-test.exp
+++ b/gcc/testsuite/lib/gcc-gdb-test.exp
@@ -60,7 +60,12 @@ proc gdb-test { useline args } {
     set cmd_file "[file rootname [file tail $prog]].gdb"
 
     set fd [open $cmd_file "w"]
-    set line [get-absolute-line $useline [lindex $args 0]]
+    set line [lindex $args 0]
+    if { [string range $line 0 0] == "@" } {
+	set line [string range $line 1 end]
+    } else {
+	set line [get-absolute-line $useline $line]
+    }
     puts $fd "break $line"
     puts $fd "run"
     puts $fd "$command $var"


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]