2004-04-23 23:34:53 +00:00
|
|
|
# This testcase is part of GDB, the GNU debugger.
|
|
|
|
|
2016-01-01 04:33:14 +00:00
|
|
|
# Copyright 2004-2016 Free Software Foundation, Inc.
|
2004-04-23 23:34:53 +00:00
|
|
|
|
|
|
|
# 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
|
2007-08-23 18:14:19 +00:00
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
2004-04-23 23:34:53 +00:00
|
|
|
# (at your option) any later version.
|
2007-08-23 18:14:19 +00:00
|
|
|
#
|
2004-04-23 23:34:53 +00:00
|
|
|
# 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.
|
2007-08-23 18:14:19 +00:00
|
|
|
#
|
2004-04-23 23:34:53 +00:00
|
|
|
# You should have received a copy of the GNU General Public License
|
2007-08-23 18:14:19 +00:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2004-04-23 23:34:53 +00:00
|
|
|
|
|
|
|
# Test "return", "finish", and "call" of functions that a scalar (int,
|
|
|
|
# float, enum) and/or take a single scalar parameter.
|
|
|
|
|
|
|
|
|
|
|
|
# Some targets can't call functions, so don't even bother with this
|
|
|
|
# test.
|
|
|
|
|
|
|
|
if [target_info exists gdb,cannot_call_functions] {
|
|
|
|
setup_xfail "*-*-*"
|
|
|
|
fail "This target can not call functions"
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
test suite update - gdb.base/[cd]
Convert files gdb.base/[cd]*.exp to use standard_output_file et al.
* call-ar-st.exp, call-rt-st.exp, call-sc.exp,
call-signal-resume.exp, call-strs.exp, callexit.exp,
callfuncs.exp, catch-load.exp, catch-syscall.exp, charset.exp,
checkpoint.exp, chng-syms.exp, code-expr.exp, code_elim.exp,
commands.exp, completion.exp, complex.exp, cond-expr.exp,
condbreak.exp, consecutive.exp, constvars.exp, corefile.exp,
ctxobj.exp, cursal.exp, cvexpr.exp, dbx.exp, default.exp,
define.exp, del.exp, detach.exp, dfp-test.exp, display.exp,
dmsym.exp, dump.exp, dup-sect.exp: Use standard_testfile,
standard_output_file, prepare_for_testing, clean_restart.
2013-06-27 18:49:03 +00:00
|
|
|
standard_testfile .c
|
2004-04-23 23:34:53 +00:00
|
|
|
|
|
|
|
# Create and source the file that provides information about the
|
|
|
|
# compiler used to compile the test case.
|
|
|
|
|
2012-06-21 20:46:25 +00:00
|
|
|
if [get_compiler_info] {
|
gdb/testsuite/
* config/monitor.exp (gdb_target_cmd): Remove semicolon after
'return'.
(gdb_target_monitor, gdb_load): Likewise.
* config/sid.exp (gdb_load): Likewise.
* config/slite.exp (gdb_load): Likewise.
* config/vx.exp (gdb_start, spawn_vxgdb): Likewise.
* gdb.ada/arrayidx.exp, gdb.ada/null_array.exp: Likewise.
* gdb.arch/mips-octeon-bbit.exp (single_step): Likewise.
(single_step_until): Likewise.
* gdb.arch/powerpc-d128-regs.exp: Likewise.
* gdb.arch/system-gcore.exp: Likewise.
* gdb.base/bigcore.exp (extract_heap): Likewise.
* gdb.base/break-on-linker-gcd-function.exp: Likewise.
* gdb.base/call-ar-st.exp: Likewise.
* gdb.base/call-rt-st.exp: Likewise.
* gdb.base/call-sc.exp, gdb.base/call-strs.exp: Likewise.
* gdb.base/callfuncs.exp, gdb.base/completion.exp: Likewise.
* gdb.base/condbreak.exp, gdb.base/constvars.exp: Likewise.
* gdb.base/corefile.exp: Likewise.
* gdb.base/dbx.exp (gdb_file_cmd): Likewise.
* gdb.base/exprs.exp, gdb.base/fileio.exp: Likewise.
* gdb.base/fixsection.exp: Likewise.
* gdb.base/funcargs.exp: Likewise.
* gdb.base/gcore-buffer-overflow.exp: Likewise.
* gdb.base/gcore-relro.exp: Likewise.
* gdb.base/gcore.exp, gdb.base/gdb11530.exp: Likewise.
* gdb.base/gdb11531.exp, gdb.base/gnu-ifunc.exp: Likewise.
* gdb.base/info-os.exp, gdb.base/info-proc.exp: Likewise.
* gdb.base/interp.exp, gdb.base/langs.exp:: Likewise.
* gdb.base/list.exp: Likewise.
(set_listsize): Likewise.
* gdb.base/logical.exp, gdb.base/mips_pro.exp: Likewise.
* gdb.base/miscexprs.exp, gdb.base/nodebug.exp: Likewise.
* gdb.base/opaque.exp, gdb.base/pointers.exp: Likewise.
* gdb.base/psymtab.exp, gdb.base/ptype.exp: Likewise.
* gdb.base/relational.exp, gdb.base/scope.exp: Likewise.
* gdb.base/setvar.exp: Likewise.
(test_set): Likewise.
* gdb.base/signals.exp, gdb.base/sizeof.exp: Likewise.
* gdb.base/solib-overlap.exp: Likewise.
* gdb.base/store.exp, gdb.base/structs.exp: Likewise.
* gdb.base/structs2.exp, gdb.base/volatile.exp: Likewise.
* gdb.base/watchpoint.exp (initialize): Likewise.
(test_simple_watchpoint): Likewise.
(test_disabling_watchpoints): Likewise.
(test_watchpoint_triggered_in_syscall): Likewise.
* gdb.base/whatis.exp, gdb.cp/ambiguous.exp: Likewise.
* gdb.cp/casts.exp, gdb.cp/ctti.exp: Likewise.
* gdb.cp/namespace.exp, gdb.cp/nsdecl.exp: Likewise.
* gdb.cp/psmang.exp, gdb.dwarf2/dw2-ranges.exp: Likewise.
* gdb.hp/gdb.aCC/optimize.exp: Likewise.
* gdb.hp/gdb.aCC/watch-cmd.exp: Likewise.
* gdb.hp/gdb.base-hp/callfwmall.exp: Likewise.
* gdb.hp/gdb.base-hp/pxdb.exp: Likewise.
* gdb.hp/gdb.compat/xdb1.exp: Likewise.
* gdb.hp/gdb.compat/xdb2.exp: Likewise.
* gdb.hp/gdb.compat/xdb3.exp: Likewise.
* gdb.hp/gdb.defects/bs14602.exp: Likewise.
* gdb.hp/gdb.defects/solib-d.exp: Likewise.
* gdb.mi/gdb792.exp: Likewise.
* gdb.mi/mi-inheritance-syntax-error.exp: Likewise.
* gdb.mi/mi-logging.exp, gdb.mi/mi-var-cp.exp : Likewise.
* gdb.mi/mi-var-rtti.exp, gdb.python/py-type.exp: Likewise.
* gdb.threads/gcore-thread.exp: Likewise.
(load_core): Likewise.
* gdb.threads/pthreads.exp (all_threads_running): Likewise.
(test_startup, check_control_c): Likewise.
* gdb.threads/sigstep-threads.exp: Likewise.
* gdb.threads/thread_check.exp: Likewise.
* gdb.trace/backtrace.exp, gdb.trace/change-loc.exp: Likewise.
* gdb.trace/circ.exp (run_trace_experiment): Likewise.
(set_a_tracepoint, trace_buffer_normal): Likewise.
(gdb_trace_circular_tests): Likewise.
* gdb.trace/collection.exp: Likewise.
* gdb.trace/disconnected-tracing.exp: Likewise.
* gdb.trace/infotrace.exp: Likewise.
* gdb.trace/mi-traceframe-changed.exp: Likewise.
* gdb.trace/mi-tracepoint-changed.exp: Likewise.
* gdb.trace/mi-tsv-changed.exp (test_create_delete_modify_tsv): Likewise.
* gdb.trace/packetlen.exp, gdb.trace/passc-dyn.exp: Likewise.
* gdb.trace/pending.exp, gdb.trace/report.exp: Likewise.
* gdb.trace/stap-trace.exp: Likewise.
* gdb.trace/status-stop.exp,gdb.trace/strace.exp: Likewise.
* gdb.trace/tfind.exp, gdb.trace/trace-break.exp: Likewise.
* gdb.trace/trace-buffer-size.exp: Likewise.
* gdb.trace/tspeed.exp, gdb.trace/tsv.exp: Likewise.
* gdb.trace/unavailable.exp: Likewise.
* gdb.trace/while-dyn.exp: Likewise.
* lib/fortran.exp (set_lang_fortran): Likewise.
* lib/gdb.exp (default_gdb_version, gdb_start_cmd): Likewise.
(gdb_breakpoint, gdb_reinitialize_dir): Likewise.
(default_gdb_start, get_compiler_info): Likewise.
(gdb_compile, gdb_compile_objc, gdb_reload, gdb_init): Likewise.
(get_debug_format, setup_xfail_format): Likewise.
(rerun_to_main, gdb_skip_float_test): Likewise.
(build_id_debug_filename_get, get_remotetimeout): Likewise.
* lib/java.exp (set_lang_java): Likewise.
* lib/mi-support.exp (default_mi_gdb_start): Likewise.
(mi_gdb_reinitialize_dir, mi_gdb_target_cmd): Likewise.
(mi_gdb_file_cmd, mi_gdb_test): Likewise.
(mi_run_cmd_full, mi_expect_interrupt): Likewise.
* lib/objc.exp (set_lang_objc): Likewise.
* lib/pascal.exp (set_lang_pascal): Likewise.
* lib/prompt.exp (default_prompt_gdb_start): Likewise.
* lib/trace-support.exp (gdb_trace_setactions, gdb_tfind_test): Likewise.
(gdb_readexpr, gdb_gettpnum, gdb_find_recursion_test_baseline): Likewise.
2013-03-14 13:34:06 +00:00
|
|
|
return -1
|
2004-04-23 23:34:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Compile a variant of scalars.c using TYPE to specify the type of the
|
|
|
|
# parameter and return-type. Run the compiled program up to "main".
|
|
|
|
# Also updates the global "testfile" to reflect the most recent build.
|
|
|
|
|
|
|
|
proc start_scalars_test { type } {
|
|
|
|
global testfile
|
|
|
|
global srcfile
|
|
|
|
global binfile
|
|
|
|
global subdir
|
|
|
|
global srcdir
|
|
|
|
global gdb_prompt
|
|
|
|
global expect_out
|
|
|
|
|
|
|
|
# Create the additional flags
|
|
|
|
set flags "debug additional_flags=-DT=${type}"
|
|
|
|
set testfile "call-sc-${type}"
|
|
|
|
|
test suite update - gdb.base/[cd]
Convert files gdb.base/[cd]*.exp to use standard_output_file et al.
* call-ar-st.exp, call-rt-st.exp, call-sc.exp,
call-signal-resume.exp, call-strs.exp, callexit.exp,
callfuncs.exp, catch-load.exp, catch-syscall.exp, charset.exp,
checkpoint.exp, chng-syms.exp, code-expr.exp, code_elim.exp,
commands.exp, completion.exp, complex.exp, cond-expr.exp,
condbreak.exp, consecutive.exp, constvars.exp, corefile.exp,
ctxobj.exp, cursal.exp, cvexpr.exp, dbx.exp, default.exp,
define.exp, del.exp, detach.exp, dfp-test.exp, display.exp,
dmsym.exp, dump.exp, dup-sect.exp: Use standard_testfile,
standard_output_file, prepare_for_testing, clean_restart.
2013-06-27 18:49:03 +00:00
|
|
|
set binfile [standard_output_file ${testfile}]
|
2004-04-23 23:34:53 +00:00
|
|
|
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "${flags}"] != "" } {
|
|
|
|
# built the second test case since we can't use prototypes
|
|
|
|
warning "Prototypes not supported, rebuilding with -DNO_PROTOTYPES"
|
|
|
|
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "${flags} additional_flags=-DNO_PROTOTYPES"] != "" } {
|
2006-08-10 05:27:22 +00:00
|
|
|
untested call-sc.exp
|
|
|
|
return -1
|
2004-04-23 23:34:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Start with a fresh gdb.
|
|
|
|
gdb_exit
|
|
|
|
gdb_start
|
|
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
|
|
|
gdb_load ${binfile}
|
|
|
|
|
|
|
|
# Make certain that the output is consistent
|
2010-06-01 21:29:21 +00:00
|
|
|
gdb_test_no_output "set print sevenbit-strings"
|
|
|
|
gdb_test_no_output "set print address off"
|
|
|
|
gdb_test_no_output "set width 0"
|
2004-04-23 23:34:53 +00:00
|
|
|
|
|
|
|
# Advance to main
|
|
|
|
if { ![runto_main] } then {
|
2013-06-07 17:31:09 +00:00
|
|
|
gdb_suppress_tests
|
2004-04-23 23:34:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Get the debug format
|
|
|
|
get_debug_format
|
|
|
|
|
|
|
|
# check that type matches what was passed in
|
|
|
|
set test "ptype; ${testfile}"
|
|
|
|
set foo_t "xxx"
|
* c-typeprint.c (find_typedef_for_canonicalize,
print_name_maybe_canonical): New functions.
(c_print_type): Look up type name.
(cp_type_print_derivation_info): Add flags argument. Use
print_name_maybe_canonical.
(cp_type_print_method_args): Add wrapping.
(c_type_print_varspec_prefix): Use print_name_maybe_canonical.
(c_type_print_template_args): New function.
(c_type_print_base): Change wrapping. Use
print_name_maybe_canonical.
<TYPE_CODE_STRUCT>: Possibly create a typedef hash, and do
type name lookups.
* gdbtypes.c (types_equal): No longer static.
* gdbtypes.h (types_equal): Declare.
* typeprint.c (type_print_raw_options, default_ptype_flags):
Update.
(struct typedef_hash_table): New.
(hash_typedef_field, eq_typedef_field,
recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash, do_free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash_element,
copy_typedef_hash, find_typedef_in_hash): New functions.
* typeprint.h (struct type_print_options) <local_typedefs>:
New field.
(recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash,
find_typedef_in_hash): Declare.
testsuite
* gdb.base/call-sc.exp: Use "ptype/r".
* gdb.base/volatile.exp: Don't expect "int".
* gdb.cp/ptype-flags.cc: New file.
* gdb.cp/ptype-flags.exp: New file.
* gdb.cp/templates.exp: Use ptype/r.
(test_ptype_of_templates, test_template_typedef): Likewise.
* lib/cp-support.exp (cp_test_ptype_class): Add in_ptype_arg
argument. Handle template names and template parameters.
* gdb.mi/mi-var-cmd.exp: Accept "long".
* gdb.mi/mi-var-child.exp: Accept "long".
* gdb.mi/mi-var-display.exp: Accept "long".
* gdb.mi/mi2-var-child.exp: Accept "long".
2012-11-12 17:37:38 +00:00
|
|
|
gdb_test_multiple "ptype/r ${type}" "${test}" {
|
2004-04-28 00:15:52 +00:00
|
|
|
-re "type = (\[^\r\n\]*)\r\n$gdb_prompt $" {
|
2004-04-23 23:34:53 +00:00
|
|
|
set foo_t "$expect_out(1,string)"
|
|
|
|
pass "$test (${foo_t})"
|
|
|
|
}
|
|
|
|
}
|
* c-typeprint.c (find_typedef_for_canonicalize,
print_name_maybe_canonical): New functions.
(c_print_type): Look up type name.
(cp_type_print_derivation_info): Add flags argument. Use
print_name_maybe_canonical.
(cp_type_print_method_args): Add wrapping.
(c_type_print_varspec_prefix): Use print_name_maybe_canonical.
(c_type_print_template_args): New function.
(c_type_print_base): Change wrapping. Use
print_name_maybe_canonical.
<TYPE_CODE_STRUCT>: Possibly create a typedef hash, and do
type name lookups.
* gdbtypes.c (types_equal): No longer static.
* gdbtypes.h (types_equal): Declare.
* typeprint.c (type_print_raw_options, default_ptype_flags):
Update.
(struct typedef_hash_table): New.
(hash_typedef_field, eq_typedef_field,
recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash, do_free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash_element,
copy_typedef_hash, find_typedef_in_hash): New functions.
* typeprint.h (struct type_print_options) <local_typedefs>:
New field.
(recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash,
find_typedef_in_hash): Declare.
testsuite
* gdb.base/call-sc.exp: Use "ptype/r".
* gdb.base/volatile.exp: Don't expect "int".
* gdb.cp/ptype-flags.cc: New file.
* gdb.cp/ptype-flags.exp: New file.
* gdb.cp/templates.exp: Use ptype/r.
(test_ptype_of_templates, test_template_typedef): Likewise.
* lib/cp-support.exp (cp_test_ptype_class): Add in_ptype_arg
argument. Handle template names and template parameters.
* gdb.mi/mi-var-cmd.exp: Accept "long".
* gdb.mi/mi-var-child.exp: Accept "long".
* gdb.mi/mi-var-display.exp: Accept "long".
* gdb.mi/mi2-var-child.exp: Accept "long".
2012-11-12 17:37:38 +00:00
|
|
|
gdb_test "ptype/r foo" "type = ${foo_t}" "ptype foo; ${testfile} $expect_out(1,string)"
|
2004-04-23 23:34:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Given N (0..25), return the corresponding alphabetic letter in lower
|
|
|
|
# or upper case. This is ment to be i18n proof.
|
|
|
|
|
|
|
|
proc i2a { n } {
|
|
|
|
return [string range "abcdefghijklmnopqrstuvwxyz" $n $n]
|
|
|
|
}
|
|
|
|
|
|
|
|
proc I2A { n } {
|
|
|
|
return [string toupper [i2a $n]]
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Test GDB's ability to make inferior function calls to functions
|
|
|
|
# returning (or passing) in a single scalar.
|
|
|
|
|
|
|
|
# start_scalars_test() will have previously built a program with a
|
|
|
|
# specified scalar type. To ensure robustness of the output, "p/c" is
|
|
|
|
# used.
|
|
|
|
|
|
|
|
# This tests the code paths "which return-value convention?" and
|
|
|
|
# "extract return-value from registers" called by "infcall.c".
|
|
|
|
|
|
|
|
proc test_scalar_calls { } {
|
|
|
|
global testfile
|
|
|
|
global gdb_prompt
|
|
|
|
|
|
|
|
# Check that GDB can always extract a scalar-return value from an
|
|
|
|
# inferior function call. Since GDB always knows the location of
|
|
|
|
# an inferior function call's return value these should never fail
|
|
|
|
|
|
|
|
# Implemented by calling the parameterless function "fun" and then
|
|
|
|
# examining the return value printed by GDB.
|
|
|
|
|
|
|
|
set tests "call ${testfile}"
|
|
|
|
|
|
|
|
# Call fun, checking the printed return-value.
|
|
|
|
gdb_test "p/c fun()" "= 49 '1'" "p/c fun(); ${tests}"
|
|
|
|
|
|
|
|
# Check that GDB can always pass a structure to an inferior function.
|
|
|
|
# This test can never fail.
|
|
|
|
|
|
|
|
# Implemented by calling the one parameter function "Fun" which
|
|
|
|
# stores its parameter in the global variable "L". GDB then
|
|
|
|
# examining that global to confirm that the value is as expected.
|
|
|
|
|
2010-06-01 21:29:21 +00:00
|
|
|
gdb_test_no_output "call Fun(foo)" "call Fun(foo); ${tests}"
|
2004-04-23 23:34:53 +00:00
|
|
|
gdb_test "p/c L" " = 49 '1'" "p/c L; ${tests}"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Test GDB's ability to both return a function (with "return" or
|
|
|
|
# "finish") and correctly extract/store any corresponding
|
|
|
|
# return-value.
|
|
|
|
|
|
|
|
# Check that GDB can consistently extract/store structure return
|
|
|
|
# values. There are two cases - returned in registers and returned in
|
|
|
|
# memory. For the latter case, the return value can't be found and a
|
|
|
|
# failure is "expected". However GDB must still both return the
|
|
|
|
# function and display the final source and line information.
|
|
|
|
|
|
|
|
# N identifies the number of elements in the struct that will be used
|
|
|
|
# for the test case. FAILS is a list of target tuples that will fail
|
|
|
|
# this test.
|
|
|
|
|
|
|
|
# This tests the code paths "which return-value convention?", "extract
|
|
|
|
# return-value from registers", and "store return-value in registers".
|
|
|
|
# Unlike "test struct calls", this test is expected to "fail" when the
|
|
|
|
# return-value is in memory (GDB can't find the location). The test
|
|
|
|
# is in three parts: test "return"; test "finish"; check that the two
|
|
|
|
# are consistent. GDB can sometimes work for one command and not the
|
|
|
|
# other.
|
|
|
|
|
|
|
|
proc test_scalar_returns { } {
|
|
|
|
global gdb_prompt
|
|
|
|
global testfile
|
|
|
|
|
|
|
|
set tests "return ${testfile}"
|
|
|
|
|
|
|
|
|
|
|
|
# Check that "return" works.
|
|
|
|
|
|
|
|
# GDB must always force the return of a function that has
|
|
|
|
# a struct result. Dependant on the ABI, it may, or may not be
|
|
|
|
# possible to store the return value in a register.
|
|
|
|
|
|
|
|
# The relevant code looks like "L{n} = fun{n}()". The test forces
|
|
|
|
# "fun{n}" to "return" with an explicit value. Since that code
|
2011-04-19 18:04:11 +00:00
|
|
|
# snippet will store the returned value in "L{n}" the return
|
2004-04-23 23:34:53 +00:00
|
|
|
# is tested by examining "L{n}". This assumes that the
|
|
|
|
# compiler implemented this as fun{n}(&L{n}) and hence that when
|
|
|
|
# the value isn't stored "L{n}" remains unchanged. Also check for
|
|
|
|
# consistency between this and the "finish" case.
|
|
|
|
|
|
|
|
# Get into a call of fun
|
|
|
|
gdb_test "advance fun" \
|
|
|
|
"fun .*\[\r\n\]+\[0-9\].*return foo.*" \
|
|
|
|
"advance to fun for return; ${tests}"
|
|
|
|
|
|
|
|
# Check that the program invalidated the relevant global.
|
|
|
|
gdb_test "p/c L" " = 90 'Z'" "zed L for return; ${tests}"
|
|
|
|
|
|
|
|
# Force the "return". This checks that the return is always
|
|
|
|
# performed, and that GDB correctly reported this to the user.
|
|
|
|
# GDB 6.0 and earlier, when the return-value's location wasn't
|
|
|
|
# known, both failed to print a final "source and line" and misplaced
|
|
|
|
# the frame ("No frame").
|
|
|
|
|
|
|
|
# The test is writen so that it only reports one FAIL/PASS for the
|
|
|
|
# entire operation. The value returned is checked further down.
|
|
|
|
# "return_value_unknown", if non-empty, records why GDB realised
|
|
|
|
# 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}"
|
|
|
|
}
|
2004-08-20 10:57:08 +00:00
|
|
|
-re "zed \\(\\);.*$gdb_prompt $" {
|
2004-04-23 23:34:53 +00:00
|
|
|
pass "${test}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-26 18:02:59 +00:00
|
|
|
# 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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-04-23 23:34:53 +00:00
|
|
|
# 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.
|
|
|
|
|
|
|
|
# Test every single char struct from 1..17 in size. This is what the
|
|
|
|
# original "scalars" test was doing.
|
|
|
|
|
|
|
|
start_scalars_test tc
|
|
|
|
test_scalar_calls
|
|
|
|
test_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
|
2015-11-13 15:06:38 +00:00
|
|
|
# naturally aligned. Padding being added where needed.
|
2004-04-23 23:34:53 +00:00
|
|
|
|
|
|
|
# Approx size: 2, 4, ...
|
|
|
|
start_scalars_test ts
|
|
|
|
test_scalar_calls
|
|
|
|
test_scalar_returns
|
|
|
|
|
|
|
|
# Approx size: 4, 8, ...
|
|
|
|
start_scalars_test ti
|
|
|
|
test_scalar_calls
|
|
|
|
test_scalar_returns
|
|
|
|
|
|
|
|
# Approx size: 4, 8, ...
|
|
|
|
start_scalars_test tl
|
|
|
|
test_scalar_calls
|
|
|
|
test_scalar_returns
|
|
|
|
|
|
|
|
# Approx size: 8, 16, ...
|
|
|
|
start_scalars_test tll
|
|
|
|
test_scalar_calls
|
|
|
|
test_scalar_returns
|
|
|
|
|
2010-12-02 21:34:14 +00:00
|
|
|
if ![target_info exists gdb,skip_float_tests] {
|
|
|
|
# Approx size: 4, 8, ...
|
|
|
|
start_scalars_test tf
|
|
|
|
test_scalar_calls
|
|
|
|
test_scalar_returns
|
|
|
|
|
|
|
|
# Approx size: 8, 16, ...
|
|
|
|
start_scalars_test td
|
|
|
|
test_scalar_calls
|
|
|
|
test_scalar_returns
|
|
|
|
|
|
|
|
# Approx size: 16, 32, ...
|
|
|
|
start_scalars_test tld
|
|
|
|
test_scalar_calls
|
|
|
|
test_scalar_returns
|
|
|
|
}
|
2004-04-23 23:34:53 +00:00
|
|
|
|
|
|
|
# Approx size: 4, 8, ...
|
|
|
|
start_scalars_test te
|
|
|
|
test_scalar_calls
|
|
|
|
test_scalar_returns
|
|
|
|
|
|
|
|
return 0
|