* gdb.base/break.exp: Add new test for setting breakpoints on
authorJonathan Larmour <jifl@eCosCentric.com>
Fri, 24 Mar 2000 21:35:42 +0000 (21:35 +0000)
committerJonathan Larmour <jifl@eCosCentric.com>
Fri, 24 Mar 2000 21:35:42 +0000 (21:35 +0000)
        optimized code so we can test breakpoints work even when function
        prologues may be optimized away

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/break.exp

index e2d7314..78a0942 100644 (file)
@@ -1,3 +1,9 @@
+2000-03-24  Jonathan Larmour  <jlarmour@redhat.co.uk>
+
+       * gdb.base/break.exp: Add new test for setting breakpoints on
+       optimized code so we can test breakpoints work even when function
+       prologues may be optimized away
+
 2000-03-23  Fernando Nasser  <fnasser@totem.to.cygnus.com>
 
        From David Whedon <dwhedon@gordian.com>
index ab050b3..ce36c21 100644 (file)
@@ -801,6 +801,79 @@ proc test_next_with_recursion {} {
 test_clear_command
 test_next_with_recursion
 
+
+#********
+
+# build a new file with optimization enabled so that we can try breakpoints
+# on targets with optimized prologues
+
+set binfileo2 ${objdir}/${subdir}/${testfile}o2
+
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfileo2}" executable {debug additional_flags="-O2" }] != "" } {
+    gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+}
+
+if [get_compiler_info ${binfileo2}] {
+    return -1
+}
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfileo2}
+
+if [target_info exists gdb_stub] {
+    gdb_step_for_stub;
+}
+
+#
+# test break at function
+#
+gdb_test "break main" \
+    "Breakpoint.*at.* file .*$srcfile, line.*" \
+    "breakpoint function, optimized file"
+
+#
+# test break at function
+#
+gdb_test "break marker4" \
+    "Breakpoint.*at.* file .*$srcfile, line.*" \
+    "breakpoint small function, optimized file"
+
+#
+# run until the breakpoint at main is hit. For non-stubs-using targets.
+#
+if ![target_info exists use_gdb_stub] {
+  if [istarget "*-*-vxworks*"] then {
+    send_gdb "run vxmain \"2\"\n"
+    set timeout 120
+    verbose "Timeout is now $timeout seconds" 2
+  } else {
+       send_gdb "run\n"
+  }
+  gdb_expect {
+    -re "The program .* has been started already.*y or n. $" {
+       send_gdb "y\n"
+       exp_continue
+    }
+    -re "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:75.*75\[\t \]+if .argc.* \{.*$gdb_prompt $"\
+                           { pass "run until function breakpoint, optimized file" }
+    -re ".*$gdb_prompt $"       { fail "run until function breakpoint, optimized file" }
+    timeout                { fail "run until function breakpoint, optimized file (timeout)" }
+  }
+} else {
+    if ![target_info exists gdb_stub] {
+       gdb_test continue ".*Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:75.*75\[\t \]+if .argc.*\{.*" "stub continue, optimized file"
+    }
+}
+
+#
+# run until the breakpoint at a small function
+#
+gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, marker4 \\(d=177601976\\) at .*$srcfile:51.*51\[\t \]+void.*marker4.*" \
+                       "run until breakpoint set at small function, optimized file"
+
+
 # Reset the default arguments for VxWorks
 if [istarget "*-*-vxworks*"] {
     set timeout 10