📄 call-sc.exp
字号:
# that it didn't know where the return value was. set test "return foo; ${tests}" set return_value_unknown 0 set return_value_unimplemented 0 gdb_test_multiple "return foo" "${test}" { -re "The location" { # Ulgh, a struct return, remember this (still need prompt). set return_value_unknown 1 exp_continue } -re "A structure or union" { # Ulgh, a struct return, remember this (still need prompt). set return_value_unknown 1 # Double ulgh. Architecture doesn't use return_value and # hence hasn't implemented small structure return. set return_value_unimplemented 1 exp_continue } -re "Make fun return now.*y or n. $" { gdb_test_multiple "y" "${test}" { -re "L *= fun.*${gdb_prompt} $" { # Need to step off the function call gdb_test "next" "zed.*" "${test}" } -re "zed \\(\\);.*$gdb_prompt $" { pass "${test}" } } } } # If the previous test did not work, the program counter might # still be inside foo() rather than main(). Make sure the program # counter is is main(). # # This happens on ppc64 GNU/Linux with gcc 3.4.1 and a buggy GDB set test "return foo; synchronize pc to main()" for {set loop_count 0} {$loop_count < 2} {incr loop_count} { gdb_test_multiple "backtrace 1" $test { -re "#0.*main \\(\\).*${gdb_prompt} $" { pass $test set loop_count 2 } -re "#0.*fun \\(\\).*${gdb_prompt} $" { if {$loop_count < 1} { gdb_test "finish" ".*" "" } else { fail $test set loop_count 2 } } } } # Check that the return-value is as expected. At this stage we're # just checking that GDB has returned a value consistent with # "return_value_unknown" set above. set test "value foo returned; ${tests}" gdb_test_multiple "p/c L" "${test}" { -re " = 49 '1'.*${gdb_prompt} $" { if $return_value_unknown { # This contradicts the above claim that GDB didn't # know the location of the return-value. fail "${test}" } else { pass "${test}" } } -re " = 90 .*${gdb_prompt} $" { if $return_value_unknown { # The struct return case. Since any modification # would be by reference, and that can't happen, the # value should be unmodified and hence Z is expected. # Is this a reasonable assumption? pass "${test}" } else { # This contradicts the above claim that GDB knew # the location of the return-value. fail "${test}" } } -re ".*${gdb_prompt} $" { if $return_value_unimplemented { # What a suprize. The architecture hasn't implemented # return_value, and hence has to fail. kfail "$test" gdb/1444 } else { fail "$test" } } } # Check that a "finish" works. # This is almost but not quite the same as "call struct funcs". # Architectures can have subtle differences in the two code paths. # The relevant code snippet is "L{n} = fun{n}()". The program is # advanced into a call to "fun{n}" and then that function is # finished. The returned value that GDB prints, reformatted using # "p/c", is checked. # Get into "fun()". gdb_test "advance fun" \ "fun .*\[\r\n\]+\[0-9\].*return foo.*" \ "advance to fun for finish; ${tests}" # Check that the program invalidated the relevant global. gdb_test "p/c L" " = 90 'Z'" "zed L for finish; ${tests}" # Finish the function, set 'finish_value_unknown" to non-empty if the # return-value was not found. set test "finish foo; ${tests}" set finish_value_unknown 0 gdb_test_multiple "finish" "${test}" { -re "Value returned is .*${gdb_prompt} $" { pass "${test}" } -re "Cannot determine contents.*${gdb_prompt} $" { # Expected bad value. For the moment this is ok. set finish_value_unknown 1 pass "${test}" } } # Re-print the last (return-value) using the more robust # "p/c". If no return value was found, the 'Z' from the previous # check that the variable was cleared, is printed. set test "value foo finished; ${tests}" gdb_test_multiple "p/c" "${test}" { -re " = 49 '1'\[\r\n\]+${gdb_prompt} $" { if $finish_value_unknown { # This contradicts the above claim that GDB didn't # know the location of the return-value. fail "${test}" } else { pass "${test}" } } -re " = 90 'Z'\[\r\n\]+${gdb_prompt} $" { # The value didn't get found. This is "expected". if $finish_value_unknown { pass "${test}" } else { # This contradicts the above claim that GDB did # know the location of the return-value. fail "${test}" } } } # Finally, check that "return" and finish" have consistent # behavior. # Since both "return" and "finish" use equivalent "which # return-value convention" logic, both commands should have # identical can/can-not find return-value messages. # Note that since "call" and "finish" use common code paths, a # failure here is a strong indicator of problems with "store # return-value" code paths. Suggest looking at "return_value" # when investigating a fix. set test "return and finish use same convention; ${tests}" if {$finish_value_unknown == $return_value_unknown} { pass "${test}" } else { kfail gdb/1444 "${test}" }}# ABIs pass anything >8 or >16 bytes in memory but below that things# randomly use register and/and structure conventions. Check all# possible sized char scalars in that range. But only a restricted# range of the other types.# NetBSD/PPC returns "unnatural" (3, 5, 6, 7) sized scalars in memory.# d10v is weird. 5/6 byte scalars go in memory. 2 or more char# scalars go in memory. Everything else is in a register!# Test every single char struct from 1..17 in size. This is what the# original "scalars" test was doing.start_scalars_test tctest_scalar_callstest_scalar_returns# Let the fun begin.# Assuming that any integer struct larger than 8 bytes goes in memory,# come up with many and varied combinations of a return struct. For# "struct calls" test just beyond that 8 byte boundary, for "struct# returns" test up to that boundary.# For floats, assumed that up to two struct elements can be stored in# floating point registers, regardless of their size.# The approx size of each structure it is computed assumed that tc=1,# ts=2, ti=4, tl=4, tll=8, tf=4, td=8, tld=16, and that all fields are# naturally aligned. Padding being added where needed. Note that# these numbers are just approx, the d10v has ti=2, a 64-bit has has# tl=8.# Approx size: 2, 4, ...start_scalars_test tstest_scalar_callstest_scalar_returns# Approx size: 4, 8, ...start_scalars_test titest_scalar_callstest_scalar_returns# Approx size: 4, 8, ...start_scalars_test tltest_scalar_callstest_scalar_returns# Approx size: 8, 16, ...start_scalars_test tlltest_scalar_callstest_scalar_returns# Approx size: 4, 8, ...start_scalars_test tftest_scalar_callstest_scalar_returns# Approx size: 8, 16, ...start_scalars_test tdtest_scalar_callstest_scalar_returns# Approx size: 16, 32, ...start_scalars_test tldtest_scalar_callstest_scalar_returns# Approx size: 4, 8, ...start_scalars_test tetest_scalar_callstest_scalar_returnsreturn 0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -