gdb/testsuite/
authorThomas Schwinge <tschwinge@gnu.org>
Tue, 28 Feb 2012 22:40:48 +0000 (22:40 +0000)
committerThomas Schwinge <tschwinge@gnu.org>
Tue, 28 Feb 2012 22:40:48 +0000 (22:40 +0000)
* gdb.base/annota1.exp: Use gdb_get_line_number for retrieving line
numbers instead of hardcoding them.
* gdb.base/annota1.c: Provide suitable markers.
* gdb.base/annota3.exp: Use gdb_get_line_number for retrieving line
numbers instead of hardcoding them.
* gdb.base/annota3.c: Provide suitable markers.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/annota1.c
gdb/testsuite/gdb.base/annota1.exp
gdb/testsuite/gdb.base/annota3.c
gdb/testsuite/gdb.base/annota3.exp

index ddb9cdc1494cabb1395142f784c2535362bd69de..5a72e3307b18359d6a46b4ea8216622930421c30 100644 (file)
@@ -1,10 +1,17 @@
 2012-02-28  Thomas Schwinge  <thomas@codesourcery.com>
 
-        * gdb.base/annota1.c [__sh__]: Remove any special-casing.
-        * gdb.base/annota3.c: Likewise.
-        * gdb.base/sigall.c: Likewise.
-        * gdb.base/signals.c: Likewise.
-        * gdb.reverse/sigall-reverse.c: Likewise.
+       * gdb.base/annota1.exp: Use gdb_get_line_number for retrieving line
+       numbers instead of hardcoding them.
+       * gdb.base/annota1.c: Provide suitable markers.
+       * gdb.base/annota3.exp: Use gdb_get_line_number for retrieving line
+       numbers instead of hardcoding them.
+       * gdb.base/annota3.c: Provide suitable markers.
+
+       * gdb.base/annota1.c [__sh__]: Remove any special-casing.
+       * gdb.base/annota3.c: Likewise.
+       * gdb.base/sigall.c: Likewise.
+       * gdb.base/signals.c: Likewise.
+       * gdb.reverse/sigall-reverse.c: Likewise.
 
 2012-02-27  Maciej W. Rozycki  <macro@codesourcery.com>
 
index 28c9ed1ba70c18c510251ebfa8e2a50fe98c18ed..239ea162af6b6591202fb93c57794fb4936c5cee 100644 (file)
@@ -25,7 +25,7 @@ int
 main ()
 #endif
 {
-  int my_array[3] = { 1, 2, 3 };
+  int my_array[3] = { 1, 2, 3 };  /* break main */
   
   value = 7;
   
@@ -39,9 +39,9 @@ main ()
   {
     int i;
     for (i = 0; i < 5; i++)
-      value++;
+      value++;  /* increment value */
   }
 
-  return 0;
+  return 0;  /* after loop */
 }
 
index 66f96e7b373b41bcae315fa23b05335676e81621..ae16667562a813c9eacf41c0f9fe9e571c94c4a3 100644 (file)
@@ -45,11 +45,6 @@ gdb_start
 gdb_reinitialize_dir $srcdir/$subdir
 gdb_load ${binfile}
 
-#
-# the line at which break main will put the breakpoint
-#
-set main_line 32
-
 # The commands we test here produce many lines of output; disable "press 
 # <return> to continue" prompts.
 gdb_test_no_output "set height 0"
@@ -57,8 +52,11 @@ gdb_test_no_output "set height 0"
 #
 # break at main
 #
+
+set main_line [gdb_get_line_number "break main"]
+
 gdb_test "break main" \
-    "Breakpoint.*at.* file .*$srcfile, line.*" \
+    "Breakpoint.*at.* file .*$srcfile, line $main_line\\." \
     "breakpoint main"
 
 
@@ -302,13 +300,13 @@ gdb_test_multiple "delete 3" "delete bp 3" {
 # break at main, after value is initialized. This is in preparation
 # to test the annotate output for the display command.
 #
-gdb_test_multiple "break main" "break at 28" {
+gdb_test_multiple "break main" "break at main" {
     -re "post-prompt.*\032\032breakpoints-invalid.*Breakpoint 4 at $hex: file ${escapedsrcfile}, line $main_line.*$gdb_prompt$" {
-       pass "break at 28"
+       pass "break at main"
     }
     -re "post-prompt.*\032\032breakpoints-invalid.*Breakpoint 4 at $hex: file .*${srcfile}, line $main_line.*$gdb_prompt$" {
        setup_xfail "*-*-*" 1270
-       fail "break at 28"
+       fail "break at main"
     }
 }
 
@@ -351,9 +349,12 @@ gdb_expect {
 # Test that breakpoints-invalid is issued once and only once for
 # breakpoint ignore count changes, after annotation stopped.
 #
-gdb_test_multiple "break 46" "break at 46" {
-    -re "Breakpoint 5 at $hex: file .*$srcfile, line 46.*$gdb_prompt$" {
-       pass "break at 46"
+
+set value_inc_line [gdb_get_line_number "increment value"]
+
+gdb_test_multiple "break $value_inc_line" "break at value++" {
+    -re "Breakpoint 5 at $hex: file .*$srcfile, line $value_inc_line.*$gdb_prompt$" {
+       pass "break at value++"
     }
 }
 
@@ -364,7 +365,7 @@ gdb_test_multiple "ignore 5 4" "ignore 5 4" {
 }
 
 gdb_test_multiple "continue" "annotate ignore count change" {
-    -re ".*$srcfile:46:.*\032\032stopped\r\n\r\n\032\032breakpoints-invalid\r\n$gdb_prompt$" {
+    -re ".*$srcfile:$value_inc_line:.*\032\032stopped\r\n\r\n\032\032breakpoints-invalid\r\n$gdb_prompt$" {
        pass "annotate ignore count change"
     }
 }
@@ -377,8 +378,10 @@ gdb_test_multiple "next" "next to exit loop" {
     }
 }
 
+set after_loop_line [gdb_get_line_number "after loop"]
+
 gdb_test_multiple "next" "breakpoint ignore count" {
-    -re ".*$srcfile:49:.*$gdb_prompt$" {
+    -re ".*$srcfile:$after_loop_line:.*$gdb_prompt$" {
        pass "breakpoint ignore count"
     }
 }
index 28c9ed1ba70c18c510251ebfa8e2a50fe98c18ed..239ea162af6b6591202fb93c57794fb4936c5cee 100644 (file)
@@ -25,7 +25,7 @@ int
 main ()
 #endif
 {
-  int my_array[3] = { 1, 2, 3 };
+  int my_array[3] = { 1, 2, 3 };  /* break main */
   
   value = 7;
   
@@ -39,9 +39,9 @@ main ()
   {
     int i;
     for (i = 0; i < 5; i++)
-      value++;
+      value++;  /* increment value */
   }
 
-  return 0;
+  return 0;  /* after loop */
 }
 
index 82abc0a1ddeff4ada490db95b81f401aa3b2eae7..246ff0b01f73a208dec29f430bcae162eadf3a7c 100644 (file)
@@ -45,11 +45,6 @@ gdb_start
 gdb_reinitialize_dir $srcdir/$subdir
 gdb_load ${binfile}
 
-#
-# the line at which break main will put the breakpoint
-#
-set main_line 32
-
 # The commands we test here produce many lines of output; disable "press 
 # <return> to continue" prompts.
 gdb_test_no_output "set height 0"
@@ -57,8 +52,11 @@ gdb_test_no_output "set height 0"
 #
 # break at main
 #
+
+set main_line [gdb_get_line_number "break main"]
+
 gdb_test "break main" \
-    "Breakpoint.*at.* file .*$srcfile, line.*" \
+    "Breakpoint.*at.* file .*$srcfile, line $main_line\\." \
     "breakpoint main"
 
 
@@ -106,11 +104,10 @@ gdb_test_multiple "end" "end if construct" {
 # info break:
 #
 send_gdb "info break\n" 
-gdb_expect_list "breakpoint info" "$gdb_prompt$" {
+gdb_expect_list "breakpoint info" "$gdb_prompt$" [concat {
     "\r\n\032\032post-prompt\r\n"
-    "Num     Type           Disp Enb Address    +What\r\n"
-    "1       breakpoint     keep y   0x\[0-9a-zA-Z\]+ +in main at .*annota3.c:32\r\n"
-}
+    "Num     Type           Disp Enb Address    +What\r\n" } [list \
+    "1       breakpoint     keep y   0x\[0-9a-zA-Z\]+ +in main at .*annota3.c:$main_line\r\n"]]
 
 
 #
@@ -118,18 +115,18 @@ gdb_expect_list "breakpoint info" "$gdb_prompt$" {
 #
 #exp_internal 1
 send_gdb "run\n"
-gdb_expect_list "run until main breakpoint" "$gdb_prompt$" {
+gdb_expect_list "run until main breakpoint" "$gdb_prompt$" [concat {
     "\r\n\032\032post-prompt\r\n"
     "Starting program: .*annota3(|\.exe) \r\n"
     "\r\n\032\032starting\r\n"
     "\r\n\032\032breakpoint 1\r\n"
     "\r\n"
     "Breakpoint 1, "
-    "\r\n\032\032frame-begin 0 0x\[0-9a-z\]+\r\n"
-    "main \\(\\) at .*annota3.c:32\r\n"
-    "\r\n\032\032source.*annota3.c:32:.*:beg:0x\[0-9a-z\]+\r\n"
+    "\r\n\032\032frame-begin 0 0x\[0-9a-z\]+\r\n" } [list \
+    "main \\(\\) at .*annota3.c:$main_line\r\n"] [list \
+    "\r\n\032\032source.*annota3.c:$main_line:.*:beg:0x\[0-9a-z\]+\r\n"] {
     "\r\n\032\032stopped\r\n"
-}
+}]
 #exp_internal 0
 #exit 0
 
@@ -270,10 +267,9 @@ gdb_expect_list "delete bp 3" "$gdb_prompt$" {
 # to test the annotate output for the display command.
 #
 send_gdb "break main\n"
-gdb_expect_list "break at 28" "$gdb_prompt$" {
-    "\r\n\032\032post-prompt\r\n"
-    "Breakpoint 4 at 0x\[0-9a-z\]+: file .*annota3.c, line 32.\r\n"
-}
+gdb_expect_list "break at main" "$gdb_prompt$" [concat {
+    "\r\n\032\032post-prompt\r\n" } [list \
+    "Breakpoint 4 at 0x\[0-9a-z\]+: file .*annota3.c, line $main_line.\r\n"]]
 
 #
 # display the value
@@ -309,11 +305,13 @@ gdb_expect {
 # NOTE: breakpoints-invalid annotations have been removed from
 # level 3 but keep these tests for continuity and comparison
 # with annota1.exp.
-send_gdb "break 46\n"
-gdb_expect_list  "break at 46" "$gdb_prompt$" {
-    "\r\n\032\032post-prompt\r\n"
-    "Breakpoint 5 at 0x\[0-9a-z\]+: file .*annota3.c, line 46.\r\n"
-}
+
+set value_inc_line [gdb_get_line_number "increment value"]
+
+send_gdb "break $value_inc_line\n"
+gdb_expect_list  "break at value++" "$gdb_prompt$" [concat {
+    "\r\n\032\032post-prompt\r\n" } [list \
+    "Breakpoint 5 at 0x\[0-9a-z\]+: file .*annota3.c, line $value_inc_line.\r\n"]]
 
 send_gdb "ignore 5 4\n"
 gdb_expect_list "ignore 5 4" "$gdb_prompt$" {
@@ -323,17 +321,17 @@ gdb_expect_list "ignore 5 4" "$gdb_prompt$" {
 }
 
 send_gdb "continue\n"
-gdb_expect_list "annotate ignore count change" "$gdb_prompt$" {
+gdb_expect_list "annotate ignore count change" "$gdb_prompt$" [concat {
     "\r\n\032\032post-prompt\r\n"
     "\r\n\032\032breakpoint 5\r\n"
     "\r\n"
     "Breakpoint 5, "
-    "\r\n\032\032frame-begin 0 0x\[0-9a-z\]+\r\n"
-    "main \\(\\) at .*annota3.c:46\r\n"
-    "\r\n\032\032source .*annota3.c:46:\[0-9\]+:beg:0x\[0-9a-z\]+\r\n"
+    "\r\n\032\032frame-begin 0 0x\[0-9a-z\]+\r\n" } [list \
+    "main \\(\\) at .*annota3.c:$value_inc_line\r\n"] [list \
+    "\r\n\032\032source .*annota3.c:$value_inc_line:\[0-9\]+:beg:0x\[0-9a-z\]+\r\n"] {
     "1: value = 11\r\n"
     "\r\n\032\032stopped\r\n"
-}
+}]
 
 # check that ignore command is working, or the above can provide
 # misleading assurance ...
@@ -347,14 +345,16 @@ gdb_expect_list "next to exit loop" "$gdb_prompt$"  {
     "\r\n\032\032stopped\r\n"
 }
 
+set after_loop_line [gdb_get_line_number "after loop"]
+
 send_gdb "next\n"
-gdb_expect_list "breakpoint ignore count" "$gdb_prompt$" {
+gdb_expect_list "breakpoint ignore count" "$gdb_prompt$" [concat {
     "\r\n\032\032post-prompt\r\n"
-    "\r\n\032\032starting\r\n"
-    "\r\n\032\032source.*annota3.c:49:\[0-9\]+:beg:0x\[0-9a-z\]+\r\n"
+    "\r\n\032\032starting\r\n" } [list \
+    "\r\n\032\032source.*annota3.c:$after_loop_line:\[0-9\]+:beg:0x\[0-9a-z\]+\r\n"] {
     "1: value = 12\r\n"
     "\r\n\032\032stopped\r\n"
-}
+}]
 
 # Get the inferior's PID for later.
 
This page took 0.044053 seconds and 4 git commands to generate.