From 2c0984cd9fb957ce306e9badbc45ff734c874048 Mon Sep 17 00:00:00 2001 From: jlarmour Date: Fri, 24 Mar 2000 21:35:42 +0000 Subject: [PATCH] * 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 --- gdb/testsuite/ChangeLog | 6 ++++ gdb/testsuite/gdb.base/break.exp | 73 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index e2d73142f9..78a0942edb 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2000-03-24 Jonathan Larmour + + * 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 From David Whedon diff --git a/gdb/testsuite/gdb.base/break.exp b/gdb/testsuite/gdb.base/break.exp index ab050b3a12..ce36c21bcc 100644 --- a/gdb/testsuite/gdb.base/break.exp +++ b/gdb/testsuite/gdb.base/break.exp @@ -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 -- 2.11.0