4c93b1dbf4
(build_executable): Update. (get_compiler_info): Remove 'binfile' argument. * gdb.ada/arrayidx.exp: Update. * gdb.ada/null_array.exp: Update. * gdb.arch/altivec-abi.exp: Update. * gdb.arch/altivec-regs.exp: Update. * gdb.arch/amd64-byte.exp: Update. * gdb.arch/amd64-dword.exp: Update. * gdb.arch/amd64-word.exp: Update. * gdb.arch/i386-avx.exp: Update. * gdb.arch/i386-byte.exp: Update. * gdb.arch/i386-sse.exp: Update. * gdb.arch/i386-word.exp: Update. * gdb.arch/ppc-dfp.exp: Update. * gdb.arch/ppc-fp.exp: Update. * gdb.arch/vsx-regs.exp: Update. * gdb.base/all-bin.exp: Update. * gdb.base/annota1.exp: Update. * gdb.base/async.exp: Update. * gdb.base/attach.exp: Update. * gdb.base/break-interp.exp: Update. * gdb.base/call-ar-st.exp: Update. * gdb.base/call-rt-st.exp: Update. * gdb.base/call-sc.exp: Update. * gdb.base/callfuncs.exp: Update. * gdb.base/catch-load.exp: Update. * gdb.base/completion.exp: Update. * gdb.base/complex.exp: Update. * gdb.base/condbreak.exp: Update. * gdb.base/consecutive.exp: Update. * gdb.base/constvars.exp: Update. * gdb.base/corefile.exp: Update. * gdb.base/eval-skip.exp: Update. * gdb.base/expand-psymtabs.exp: Update. * gdb.base/exprs.exp: Update. * gdb.base/fileio.exp: Update. * gdb.base/fixsection.exp: Update. * gdb.base/funcargs.exp: Update. * gdb.base/gdb11530.exp: Update. * gdb.base/gdb1555.exp: Update. * gdb.base/gnu-ifunc.exp: Update. * gdb.base/gnu_vector.exp: Update. * gdb.base/info-macros.exp: Update. * gdb.base/jit-simple.exp: Update. * gdb.base/jit-so.exp: Update. * gdb.base/jit.exp: Update. * gdb.base/langs.exp: Update. * gdb.base/list.exp: Update. * gdb.base/logical.exp: Update. * gdb.base/long_long.exp: Update. * gdb.base/longjmp.exp: Update. * gdb.base/macscp.exp: Update. * gdb.base/mips_pro.exp: Update. * gdb.base/miscexprs.exp: Update. * gdb.base/morestack.exp: Update. * gdb.base/nodebug.exp: Update. * gdb.base/opaque.exp: Update. * gdb.base/pc-fp.exp: Update. * gdb.base/pending.exp: Update. * gdb.base/permissions.exp: Update. * gdb.base/pointers.exp: Update. * gdb.base/prelink.exp: Update. * gdb.base/printcmds.exp: Update. * gdb.base/psymtab.exp: Update. * gdb.base/ptype.exp: Update. * gdb.base/relational.exp: Update. * gdb.base/scope.exp: Update. * gdb.base/setvar.exp: Update. * gdb.base/shlib-call.exp: Update. * gdb.base/shreloc.exp: Update. * gdb.base/signals.exp: Update. * gdb.base/sizeof.exp: Update. * gdb.base/so-impl-ld.exp: Update. * gdb.base/so-indr-cl.exp: Update. * gdb.base/solib-disc.exp: Update. * gdb.base/solib-display.exp: Update. * gdb.base/solib-nodir.exp: Update. * gdb.base/solib-overlap.exp: Update. * gdb.base/solib-symbol.exp: Update. * gdb.base/solib-weak.exp: Update. * gdb.base/solib.exp: Update. * gdb.base/store.exp: Update. * gdb.base/structs.exp: Update. * gdb.base/structs2.exp: Update. * gdb.base/type-opaque.exp: Update. * gdb.base/unload.exp: Update. * gdb.base/varargs.exp: Update. * gdb.base/volatile.exp: Update. * gdb.base/watch_thread_num.exp: Update. * gdb.base/watchpoint-solib.exp: Update. * gdb.base/watchpoint.exp: Update. * gdb.base/watchpoints.exp: Update. * gdb.base/whatis.exp: Update. * gdb.cell/arch.exp: Update. * gdb.cell/break.exp: Update. * gdb.cell/bt.exp: Update. * gdb.cell/core.exp: Update. * gdb.cell/data.exp: Update. * gdb.cell/ea-cache.exp: Update. * gdb.cell/f-regs.exp: Update. * gdb.cell/fork.exp: Update. * gdb.cell/gcore.exp: Update. * gdb.cell/mem-access.exp: Update. * gdb.cell/ptype.exp: Update. * gdb.cell/registers.exp: Update. * gdb.cell/sizeof.exp: Update. * gdb.cell/solib-symbol.exp: Update. * gdb.cell/solib.exp: Update. * gdb.cp/ambiguous.exp: Update. * gdb.cp/breakpoint.exp: Update. * gdb.cp/bs15503.exp: Update. * gdb.cp/casts.exp: Update. * gdb.cp/class2.exp: Update. * gdb.cp/cpexprs.exp: Update. * gdb.cp/cplusfuncs.exp: Update. * gdb.cp/ctti.exp: Update. * gdb.cp/dispcxx.exp: Update. * gdb.cp/gdb1355.exp: Update. * gdb.cp/gdb2384.exp: Update. * gdb.cp/gdb2495.exp: Update. * gdb.cp/infcall-dlopen.exp: Update. * gdb.cp/local.exp: Update. * gdb.cp/m-data.exp: Update. * gdb.cp/m-static.exp: Update. * gdb.cp/mb-ctor.exp: Update. * gdb.cp/mb-inline.exp: Update. * gdb.cp/mb-templates.exp: Update. * gdb.cp/member-ptr.exp: Update. * gdb.cp/method.exp: Update. * gdb.cp/namespace.exp: Update. * gdb.cp/nextoverthrow.exp: Update. * gdb.cp/nsdecl.exp: Update. * gdb.cp/nsrecurs.exp: Update. * gdb.cp/nsstress.exp: Update. * gdb.cp/nsusing.exp: Update. * gdb.cp/pr-1023.exp: Update. * gdb.cp/pr-1210.exp: Update. * gdb.cp/pr-574.exp: Update. * gdb.cp/pr9631.exp: Update. * gdb.cp/printmethod.exp: Update. * gdb.cp/psmang.exp: Update. * gdb.cp/re-set-overloaded.exp: Update. * gdb.cp/rtti.exp: Update. * gdb.cp/shadow.exp: Update. * gdb.cp/templates.exp: Update. * gdb.cp/try_catch.exp: Update. * gdb.dwarf2/dw2-ranges.exp: Update. * gdb.dwarf2/pr10770.exp: Update. * gdb.fortran/library-module.exp: Update. * gdb.hp/gdb.aCC/optimize.exp: Update. * gdb.hp/gdb.aCC/watch-cmd.exp: Update. * gdb.hp/gdb.base-hp/callfwmall.exp: Update. * gdb.hp/gdb.base-hp/hwwatchbus.exp: Update. * gdb.hp/gdb.base-hp/pxdb.exp: Update. * gdb.hp/gdb.base-hp/sized-enum.exp: Update. * gdb.hp/gdb.base-hp/so-thresh.exp: Update. * gdb.hp/gdb.compat/xdb1.exp: Update. * gdb.hp/gdb.compat/xdb2.exp: Update. * gdb.hp/gdb.compat/xdb3.exp: Update. * gdb.hp/gdb.defects/bs14602.exp: Update. * gdb.hp/gdb.defects/solib-d.exp: Update. * gdb.hp/gdb.objdbg/objdbg01.exp: Update. * gdb.hp/gdb.objdbg/objdbg02.exp: Update. * gdb.hp/gdb.objdbg/objdbg03.exp: Update. * gdb.hp/gdb.objdbg/objdbg04.exp: Update. * gdb.mi/gdb792.exp: Update. * gdb.mi/mi-pending.exp: Update. * gdb.mi/mi-solib.exp: Update. * gdb.mi/mi-var-cp.exp: Update. * gdb.opt/clobbered-registers-O2.exp: Update. * gdb.opt/inline-bt.exp: Update. * gdb.opt/inline-cmds.exp: Update. * gdb.opt/inline-locals.exp: Update. * gdb.python/py-events.exp: Update. * gdb.python/py-finish-breakpoint.exp: Update. * gdb.python/py-type.exp: Update. * gdb.reverse/solib-precsave.exp: Update. * gdb.reverse/solib-reverse.exp: Update. * gdb.server/solib-list.exp: Update. * gdb.stabs/weird.exp: Update. * gdb.threads/attach-into-signal.exp: Update. * gdb.threads/attach-stopped.exp: Update. * gdb.threads/tls-shared.exp: Update. * gdb.trace/change-loc.exp: Update. * gdb.trace/strace.exp: Update.
329 lines
11 KiB
Text
329 lines
11 KiB
Text
# Copyright 2008, 2010-2012 Free Software Foundation, Inc.
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
set testfile "inline-cmds"
|
|
set srcfile "${testfile}.c"
|
|
set srcfile2 "inline-markers.c"
|
|
set fullsrcfile "${srcdir}/${subdir}/${srcfile}"
|
|
set fullsrcfile2 "${srcdir}/${subdir}/${srcfile2}"
|
|
set sources [list ${fullsrcfile} ${fullsrcfile2}]
|
|
set binfile ${objdir}/${subdir}/${testfile}
|
|
|
|
if { [gdb_compile $sources ${binfile} \
|
|
executable {debug optimize=-O2}] != "" } {
|
|
untested inline-cmds.exp
|
|
return -1
|
|
}
|
|
|
|
gdb_exit
|
|
gdb_start
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
|
gdb_load ${binfile}
|
|
|
|
gdb_test_no_output "set listsize 1"
|
|
|
|
runto_main
|
|
|
|
get_compiler_info
|
|
get_debug_format
|
|
if { [skip_inline_frame_tests] } {
|
|
untested inline-cmds.exp
|
|
return
|
|
}
|
|
|
|
# First, check that the things we expected to be inlined really were,
|
|
# and those that shouldn't be weren't.
|
|
set line1 [gdb_get_line_number "set breakpoint 1 here" ${srcfile2}]
|
|
gdb_breakpoint $srcfile2:$line1
|
|
set line2 [gdb_get_line_number "set breakpoint 2 here" ${srcfile2}]
|
|
gdb_breakpoint $srcfile2:$line2
|
|
|
|
gdb_test "continue" ".*set breakpoint 1 here.*" "continue to bar (1)"
|
|
gdb_test "backtrace" "#0 bar.*#1 .*func1.*#2 .*main.*" \
|
|
"backtrace from bar (1)"
|
|
gdb_test "up" "#1 .*func1.*" "up from bar (1)"
|
|
gdb_test "info frame" ".*inlined into frame.*" "func1 inlined (1)"
|
|
|
|
gdb_test "continue" ".*set breakpoint 1 here.*" "continue to bar (2)"
|
|
gdb_test "backtrace" "#0 bar.*#1 .*func1.*#2 .*func2.*#3 .*main.*" \
|
|
"backtrace from bar (2)"
|
|
gdb_test "up" "#1 .*func1.*" "up from bar (2)"
|
|
gdb_test "info frame" ".*inlined into frame.*" "func1 inlined (2)"
|
|
gdb_test "up" "#2 .*func2.*" "up from func1 (2)"
|
|
gdb_test "info frame" ".*inlined into frame.*" "func2 inlined (2)"
|
|
|
|
gdb_test "continue" ".*set breakpoint 2 here.*" "continue to marker"
|
|
gdb_test "backtrace" "#0 marker.*#1 .*main.*" "backtrace from marker"
|
|
gdb_test "info frame" ".*called by frame.*" "marker not inlined"
|
|
|
|
# Next, check that we can next over inlined functions. We should not end up
|
|
# inside any of them.
|
|
delete_breakpoints
|
|
runto_main
|
|
|
|
# The lines before the first inlined call.
|
|
set first "x = 7|y = 8"
|
|
|
|
# Some extra lines that end up in our stepping due to code motion.
|
|
set opt "start of main|result = 0"
|
|
|
|
# We start this test with a "list" instead of a "next", in case the
|
|
# first non-prologue instruction in main comes from the inlined function.
|
|
set msg "next over inlined functions"
|
|
gdb_test_multiple "list" $msg {
|
|
-re "($first|result = func1|result = func2|$opt).*$gdb_prompt $" {
|
|
send_gdb "next\r"
|
|
exp_continue
|
|
}
|
|
-re "marker \\\(\\\);\r\n$gdb_prompt $" {
|
|
pass $msg
|
|
}
|
|
}
|
|
|
|
# Check that when next shows the call of func1, it has not happened yet.
|
|
runto_main
|
|
|
|
# Like the return value of gdb_test: -1 something is wrong, 0 passed, 1 failed.
|
|
set bt_test -1
|
|
set x_test -1
|
|
set func1_step -1
|
|
|
|
set last_was_func1_call 0
|
|
set msg "next past inlined func1"
|
|
gdb_test_multiple "list" $msg {
|
|
-re "($first|$opt).*$gdb_prompt $" {
|
|
set last_was_func1_call 0
|
|
send_gdb "next\r"
|
|
exp_continue
|
|
}
|
|
-re "result = func1 \\\(\\\);\r\n$gdb_prompt $" {
|
|
# Check whether x has been set. If 0, we may be doing something
|
|
# else associated with this line besides the inlined call - e.g.
|
|
# loading the address of result. If 7, we may be at the call site.
|
|
# If 15, though, we might be past the call and back at the store to
|
|
# result - that's OK, as long as we weren't just here (see
|
|
# func1_step above).
|
|
set x_val -1
|
|
gdb_test_multiple "print x" "" {
|
|
-re "\\\$$decimal = (\[0-9\]*)\r\n$gdb_prompt $" {
|
|
set x_val $expect_out(1,string)
|
|
}
|
|
-re "$gdb_prompt $" { }
|
|
}
|
|
if { $x_val == 0 || $x_val == 7 } {
|
|
if { $x_test != 1 } {
|
|
set x_test 0
|
|
}
|
|
} elseif { $x_val == 15 } {
|
|
if { $func1_step == -1 } {
|
|
# We passed func1 without stopping at the call site.
|
|
set x_test 1
|
|
}
|
|
} else {
|
|
set x_test 1
|
|
}
|
|
|
|
# func1 should not show up on backtraces if we are at its call
|
|
# site.
|
|
if { $bt_test != 1 } {
|
|
set bt_test [gdb_test "backtrace" "#0 \[^#]*main.*" ""]
|
|
}
|
|
|
|
# When we next over func1, we should not return to the same
|
|
# line. But we might go past the line, according to source
|
|
# code order, and then come back. A valid but odd layout is
|
|
# body of func1, load result's address into a register using
|
|
# the source location of "result = 0" several lines down, and
|
|
# then return to this line for the store. GCC 4.3 does that
|
|
# on ARM.
|
|
if { $last_was_func1_call } {
|
|
set func1_step 1
|
|
} elseif { $func1_step == -1 } {
|
|
set func1_step 0
|
|
}
|
|
set last_was_func1_call 1
|
|
|
|
send_gdb "next\r"
|
|
exp_continue
|
|
}
|
|
|
|
-re "result = func2 \\\(\\\);\r\n$gdb_prompt $" {
|
|
pass $msg
|
|
}
|
|
}
|
|
|
|
if { $x_test == 0 } {
|
|
pass "print x before func1"
|
|
} else {
|
|
fail "print x before func1"
|
|
}
|
|
|
|
if { $bt_test == 0 } {
|
|
pass "backtrace does not include func1"
|
|
} else {
|
|
fail "backtrace does not include func1"
|
|
}
|
|
|
|
if { $bt_test == 0 } {
|
|
pass "stepped over call to func1"
|
|
} else {
|
|
fail "stepped over call to func1"
|
|
}
|
|
|
|
# Next, check that we can single step into inlined functions. We should always
|
|
# "stop" at the call sites before entering them.
|
|
runto_main
|
|
|
|
set msg "step into func1"
|
|
set saw_call_site 0
|
|
gdb_test_multiple "list" $msg {
|
|
-re "($first|$opt).*$gdb_prompt $" {
|
|
send_gdb "step\r"
|
|
exp_continue
|
|
}
|
|
-re "result = func1.*$gdb_prompt $" {
|
|
set saw_call_site 1
|
|
send_gdb "step\r"
|
|
exp_continue
|
|
}
|
|
-re "func1 \\\(\\\) at .*\r\n$decimal.*bar \\\(\\\);\r\n$gdb_prompt $" {
|
|
if { $saw_call_site } {
|
|
pass $msg
|
|
} else {
|
|
fail $msg
|
|
}
|
|
}
|
|
}
|
|
|
|
# Check finish out of an inlined function.
|
|
set msg "finish from func1"
|
|
gdb_test_multiple "finish" $msg {
|
|
-re "result = func1 \\\(\\\);\r\n$gdb_prompt $" {
|
|
pass $msg
|
|
}
|
|
-re "($first|$opt).*$gdb_prompt $" {
|
|
# Whoops. We finished, but ended up back at an earlier line. Keep
|
|
# trying.
|
|
send_gdb "step\r"
|
|
exp_continue
|
|
}
|
|
-re "func1 \\\(\\\) at .*\r\n$decimal.*bar \\\(\\\);\r\n$gdb_prompt $" {
|
|
send_gdb "finish\r"
|
|
exp_continue
|
|
}
|
|
}
|
|
|
|
# Test some corner cases involving consecutive inlined functions.
|
|
set line3 [gdb_get_line_number "set breakpoint 3 here"]
|
|
gdb_breakpoint $line3
|
|
gdb_continue_to_breakpoint "consecutive func1"
|
|
|
|
gdb_test "next" ".*func1 .*first call.*" "next to first func1"
|
|
set msg "next to second func1"
|
|
gdb_test_multiple "next" $msg {
|
|
-re ".*func1 .*second call.*$gdb_prompt $" {
|
|
pass $msg
|
|
}
|
|
-re ".*marker .*$gdb_prompt $" {
|
|
# This assembles to two consecutive call instructions.
|
|
# Both appear to be at the same line, because they're
|
|
# in the body of the same inlined function. This is
|
|
# reasonable for the line table. GDB should take the
|
|
# containing block and/or function into account when
|
|
# deciding how far to step. The single line table entry
|
|
# is actually two consecutive instances of the same line.
|
|
kfail gdb/NNNN $msg
|
|
}
|
|
}
|
|
|
|
# It is easier when the two inlined functions are not on the same line.
|
|
set line4 [gdb_get_line_number "set breakpoint 4 here"]
|
|
gdb_breakpoint $line4
|
|
gdb_continue_to_breakpoint "func1 then func3"
|
|
|
|
gdb_test "next" ".*func1 \\\(\\\);" "next to func1 before func3"
|
|
gdb_test "next" ".*func3 \\\(\\\);" "next to func3"
|
|
|
|
# Test finishing out of one thing and into another.
|
|
set line5 [gdb_get_line_number "set breakpoint 5 here"]
|
|
gdb_breakpoint $line5
|
|
gdb_continue_to_breakpoint "finish into func1"
|
|
|
|
gdb_test "next" ".*marker \\\(\\\);" "next to finish marker"
|
|
gdb_test "step" ".*set breakpoint 2 here.*" "step into finish marker"
|
|
|
|
# Some architectures will have one or more instructions after
|
|
# the call instruction which still are part of the call sequence,
|
|
# so it should be expected to return to the caller line after issue
|
|
# a 'finish' command.
|
|
gdb_test_multiple "finish" "finish from marker" {
|
|
-re "func1 \\\(\\\);.*\r\n$gdb_prompt $" {
|
|
pass "finish from marker to func1"
|
|
}
|
|
-re "marker \\\(\\\);.*\r\n$gdb_prompt $" {
|
|
pass "finish from marker"
|
|
gdb_test "step" "func1 \\\(\\\);.*" "step after marker to reach func1"
|
|
}
|
|
}
|
|
|
|
gdb_test "step" "bar \\\(\\\);" "step into func1 for finish"
|
|
gdb_test "finish" "func3 \\\(\\\);" "finish from func1 to func3"
|
|
|
|
# Test a deeper call stack.
|
|
set line6 [gdb_get_line_number "set breakpoint 6 here"]
|
|
gdb_breakpoint $line6
|
|
gdb_continue_to_breakpoint "before the outer_inline call"
|
|
gdb_test "step" "marker \\\(\\\) at .*" "reach 1 the outer_inline call"
|
|
gdb_test_multiple "finish" "finish from marker" {
|
|
-re "main \\\(\\\) at .*outer_inline2 \\\(\\\);.*\r\n$gdb_prompt $" {
|
|
pass "reach outer_inline2"
|
|
}
|
|
-re "main \\\(\\\) at .*marker \\\(\\\);.*\r\n$gdb_prompt $" {
|
|
pass "finish from marker"
|
|
gdb_test "step" "outer_inline2 \\\(\\\);.*" "step after marker to reach outer_inline2"
|
|
}
|
|
}
|
|
gdb_test "bt" "#0 main.*" "backtrace at main of outer_inline"
|
|
gdb_test "step" "outer_inline2 \\\(\\\) at .*" "enter outer_inline2"
|
|
gdb_test "bt" "#0 outer_inline2.*#1 main.*" "backtrace at outer_inline2"
|
|
gdb_test "step" "outer_inline1 \\\(\\\) at .*" "enter outer_inline1 from outer_inline2"
|
|
|
|
set msg "backtrace at outer_inline1"
|
|
gdb_test_multiple "bt" $msg {
|
|
-re "#0 outer_inline1.*#1 outer_inline2.*#2 main.*$gdb_prompt $" {
|
|
pass $msg
|
|
}
|
|
-re "#0 $hex in outer_inline1.*#1 outer_inline2.*#2 main.*$gdb_prompt $" {
|
|
# Binutils PR gas/6717. Gas moves .loc past .p2align and the
|
|
# leading nop of the inlined call appears to be on the same line
|
|
# as main's call to marker.
|
|
xfail $msg
|
|
gdb_test "step" "noinline \\\(\\\);" "step to call of noinline"
|
|
}
|
|
}
|
|
|
|
gdb_test "step" "noinline \\\(\\\) at .*" "enter noinline from outer_inline1"
|
|
gdb_test "bt" "#0 noinline.*#1 .*outer_inline1.*#2 .*outer_inline2.*#3 main.*" "backtrace at noinline from outer_inline1"
|
|
gdb_test "step" "inlined_fn \\\(\\\) at .*" "enter inlined_fn from noinline"
|
|
gdb_test "bt" "#0 inlined_fn.*#1 noinline.*#2 .*outer_inline1.*#3 .*outer_inline2.*#4 main.*" "backtrace at inlined_fn from noinline"
|
|
gdb_test "info frame" ".*inlined into frame.*" "inlined_fn from noinline inlined"
|
|
gdb_test "up" "#1 noinline.*" "up to noinline"
|
|
gdb_test "info frame" ".*\n called by frame.*" "noinline from outer_inline1 not inlined"
|
|
gdb_test "up" "#2 .*outer_inline1.*" "up to outer_inline1"
|
|
gdb_test "info frame" ".*inlined into frame.*" "outer_inline1 inlined"
|
|
gdb_test "up" "#3 .*outer_inline2.*" "up to outer_inline2"
|
|
gdb_test "info frame" ".*inlined into frame.*" "outer_inline2 inlined"
|
|
gdb_test "up" "#4 main.*" "up from outer_inline2"
|
|
gdb_test "info frame" ".*\n caller of frame.*" "main not inlined"
|