2018-01-01 05:43:02 +01:00
# Copyright 1988-2018 Free Software Foundation, Inc.
1999-04-16 03:35:26 +02: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 20:14:19 +02:00
# the Free Software Foundation; either version 3 of the License, or
1999-04-16 03:35:26 +02:00
# (at your option) any later version.
2007-08-23 20:14:19 +02:00
#
1999-04-16 03:35:26 +02: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 20:14:19 +02:00
#
1999-04-16 03:35:26 +02:00
# You should have received a copy of the GNU General Public License
2007-08-23 20:14:19 +02:00
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1999-04-16 03:35:26 +02:00
# This file was written by Rob Savoye. (rob@cygnus.com)
#
# test running programs
#
test suite update - gdb.base/[n-r]
Convert files gdb.base/[n-r]*.exp to use standard_output_file et al.
* gdb.base/nextoverexit.exp, gdb.base/nextoverexit.exp,
gdb.base/nodebug.exp, gdb.base/nofield.exp, gdb.base/nostdlib.exp,
gdb.base/opaque.exp, gdb.base/overlays.exp, gdb.base/pc-fp.exp,
gdb.base/pending.exp, gdb.base/permissions.exp,
gdb.base/pie-execl.exp, gdb.base/pointers.exp,
gdb.base/pr11022.exp, gdb.base/print-file-var.exp,
gdb.base/printcmds.exp, gdb.base/prologue.exp,
gdb.base/psymtab.exp, gdb.base/ptr-typedef.exp,
gdb.base/ptype.exp, gdb.base/randomize.exp,
gdb.base/readline-ask.exp, gdb.base/recpar.exp,
gdb.base/recurse.exp, gdb.base/relativedebug.exp,
gdb.base/relocate.exp, gdb.base/remote.exp, gdb.base/reread.exp,
gdb.base/return-nodebug.exp, gdb.base/return2.exp: Use
standard_testfile, standard_output_file, prepare_for_testing,
clean_restart.
2013-06-27 20:53:49 +02:00
standard_testfile .c ptype1.c
2016-12-23 17:52:18 +01:00
if {[prepare_for_testing "failed to prepare" ${testfile} \
test suite update - gdb.base/[n-r]
Convert files gdb.base/[n-r]*.exp to use standard_output_file et al.
* gdb.base/nextoverexit.exp, gdb.base/nextoverexit.exp,
gdb.base/nodebug.exp, gdb.base/nofield.exp, gdb.base/nostdlib.exp,
gdb.base/opaque.exp, gdb.base/overlays.exp, gdb.base/pc-fp.exp,
gdb.base/pending.exp, gdb.base/permissions.exp,
gdb.base/pie-execl.exp, gdb.base/pointers.exp,
gdb.base/pr11022.exp, gdb.base/print-file-var.exp,
gdb.base/printcmds.exp, gdb.base/prologue.exp,
gdb.base/psymtab.exp, gdb.base/ptr-typedef.exp,
gdb.base/ptype.exp, gdb.base/randomize.exp,
gdb.base/readline-ask.exp, gdb.base/recpar.exp,
gdb.base/recurse.exp, gdb.base/relativedebug.exp,
gdb.base/relocate.exp, gdb.base/remote.exp, gdb.base/reread.exp,
gdb.base/return-nodebug.exp, gdb.base/return2.exp: Use
standard_testfile, standard_output_file, prepare_for_testing,
clean_restart.
2013-06-27 20:53:49 +02:00
[list $srcfile $srcfile2] {debug nowarnings}]} {
return -1
1999-04-16 03:35:26 +02:00
}
# Create and source the file that provides information about the compiler
# used to compile the test case.
2012-06-21 22:46:25 +02: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 14:34:06 +01:00
return -1
1999-04-16 03:35:26 +02:00
}
# Test ptype of unnamed enumeration members before any action causes
# the partial symbol table to be expanded to full symbols. This fails
# with stabs compilers which fail to use a nameless stab (such as
# pre-2.4.5 versions of gcc and most non-gcc compilers).
2010-05-25 21:34:05 +02:00
gdb_test_multiple "ptype red1" "ptype unnamed enumeration member" {
-re "type = enum primary1_tag \{red1, green1, blue1\}.*$gdb_prompt $" {
# The workaround is in effect. As this is a compiler, not GDB,
# bug, we'll make it a PASS but perhaps it should be an XFAIL.
pass "ptype unnamed enumeration member (worked around)"
}
-re "type = enum \{red1, green1, blue1\}.*$gdb_prompt $" {
pass "ptype unnamed enumeration member"
}
1999-04-16 03:35:26 +02:00
}
#
# test ptype command with structures
#
# Here and elsewhere, we accept
# "long", "long int", or "int" for long variables (whatis.exp already
# has an XFAIL for "int" (Sun cc bug), so no need to fail it here).
gdb_test "ptype struct t_struct" "type = struct t_struct \{.*\[\r\n\] (unsigned |)char v_char_member;.*\[\r\n\] (short|short int) v_short_member;.*\[\r\n\] int v_int_member;.*\[\r\n\] (long|long int|int) v_long_member;.*\[\r\n\] float v_float_member;.*\[\r\n\] double v_double_member;.*\[\r\n\]\}.*" "ptype structure"
# Test the equivalence between '.' and '->' for struct member references.
if [gdb_test "ptype v_struct1.v_float_member" "type = float"]<0 then {
return -1
}
if [gdb_test "ptype v_struct1->v_float_member" "type = float"]<0 then {
return -1
}
if [gdb_test "ptype v_t_struct_p.v_float_member" "type = float"]<0 then {
return -1
}
if [gdb_test "ptype v_t_struct_p->v_float_member" "type = float"]<0 then {
return -1
}
# IBM's xlc puts out bogus stabs--the stuff field is type 42,
# which isn't defined.
1999-06-28 18:06:02 +02:00
gdb_test "ptype struct link" "type = struct link \{\[\r\n\]+\[ \t\]+struct link \\*next;\[\r\n\]+\[ \t\]+struct link \\*\\(\\*linkfunc\\)\\((struct link \\*, int|void|)\\);\[\r\n\]+\[ \t\]+struct t_struct stuff.1..2..3.;\[\r\n\]+\}.*" "ptype linked list structure"
1999-04-16 03:35:26 +02:00
#
# test ptype command with unions
#
gdb_test "ptype union t_union" "type = union t_union \{.*\[\r\n\] (unsigned |)char v_char_member;.*\[\r\n\] (short|short int) v_short_member;.*\[\r\n\] int v_int_member;.*\[\r\n\] (long|long int|int) v_long_member;.*\[\r\n\] float v_float_member;.*\[\r\n\] double v_double_member;.*\[\r\n\]\}.*" "ptype union"
# IBM's xlc puts out bogus stabs--the stuff field is type 42,
# which isn't defined.
1999-06-28 18:06:02 +02:00
gdb_test "ptype union tu_link" "type = union tu_link \{\[\r\n\]+\[ \t\]+struct link \\*next;\[\r\n\]+\[ \t\]+struct link \\*\\(\\*linkfunc\\)\\((struct link \\*, int|void|)\\);\[\r\n\]+\[ \t\]+struct t_struct stuff.1..2..3.;\[\r\n\]+\}.*" "ptype linked list union"
1999-04-16 03:35:26 +02:00
#
# test ptype command with enums
#
gdb_test "ptype primary" "type = enum .red, green, blue.*" "ptype unnamed enumeration"
gdb_test "ptype enum colors" "type = enum colors \{yellow, purple, pink\}.*" "ptype named enumeration"
#
# test ptype command with enums as typedef
#
1999-06-28 18:06:02 +02:00
gdb_test "ptype boolean" "type = enum (boolean |)\{FALSE, TRUE\}.*" "ptype unnamed typedef'd enumeration"
1999-04-16 03:35:26 +02:00
# And check that whatis shows the name, not "enum {...}".
# This probably fails for all DWARF 1 cases, so assume so for now. -fnf
# The problem with xlc is that the stabs look like
# :t51=eFALSE:0,TRUE:1,;
# boolean:t55=51
# v_boolean:G51
# GDB's behavior is correct; the type which the variable is defined
# as (51) doesn't have a name. Only 55 has a name.
2015-12-21 17:23:43 +01:00
if {!$gcc_compiled} {
1999-08-03 01:48:37 +02:00
setup_xfail "rs6000-*-*" "i*86-*-sysv4*"
setup_xfail "hppa*-*-*" CLLbs14773
1999-06-28 18:06:02 +02:00
}
2000-02-05 08:30:26 +01:00
# For get_debug_format to do its job, we need to have a current source file.
2010-06-10 21:48:20 +02:00
gdb_test "list main" ".*"
1999-07-07 19:31:57 +02:00
get_debug_format
1999-06-28 18:06:02 +02:00
gdb_test "whatis v_boolean" "type = (enum |)boolean" \
1999-04-16 03:35:26 +02:00
"whatis unnamed typedef'd enum (compiler bug in IBM's xlc)"
# Same thing with struct and union.
1999-06-28 18:06:02 +02:00
gdb_test "ptype t_struct3" "type = struct (t_struct3 |)\{.*
1999-04-16 03:35:26 +02:00
*double v_double_member;.*
*int v_int_member;.*\}" "printing typedef'd struct"
1999-06-28 18:06:02 +02:00
gdb_test "ptype t_union3" "type = union (t_union3 |)\{.*
1999-04-16 03:35:26 +02:00
*double v_double_member;.*
*int v_int_member;.*\}" "printing typedef'd union"
1999-06-28 18:06:02 +02:00
gdb_test "ptype enum bvals" "type = enum bvals \{my_false, my_true\}.*" "ptype named typedef'd enumf'd enum"
1999-04-16 03:35:26 +02:00
#
# test ptype command with out-of-order enum values
#
gdb_test "ptype enum misordered" "type = enum misordered \{two = 2, one = 1, zero = 0, three = 3\}.*" "ptype misordered enumeration"
#
# test ptype command with a named enum's value
#
gdb_test "ptype three" "type = enum misordered \{two = 2, one = 1, zero = 0, three = 3\}.*" "ptype named enumeration member"
gdb_test "ptype red" "type = enum \{red, green, blue\}.*" "ptype unnamed enumeration member #2"
#
# test ptype command with basic C types
#
# I've commented most of this out because it duplicates tests in whatis.exp.
# I've just left in a token test or 2 which is designed to test that ptype
# acts like whatis for basic types. If it is thought to be necessary to
# test both whatis and ptype for all the types, the tests should be
# merged into whatis.exp, or else maintenance will be a royal pain -kingdon
2012-02-13 19:09:59 +01:00
#setup_xfail "mips-sgi-*"
1999-04-16 03:35:26 +02:00
#send "ptype v_char\n"
#gdb_expect {
# -re "type = char.*$gdb_prompt $" { pass "ptype char" }
# -re ".*$gdb_prompt $" { fail "ptype char" }
# timeout { fail "(timeout) ptype char" }
#}
#
#
2002-01-06 15:42:39 +01:00
#setup_xfail "mips-*-*"
1999-04-16 03:35:26 +02:00
#send "ptype v_signed_char\n"
#gdb_expect {
# -re "type = signed char.*$gdb_prompt $" { pass "ptype signed char" }
# -re ".*$gdb_prompt $" { fail "ptype signed char" }
# timeout { fail "(timeout) ptype signed char" }
#}
#
#
#send "ptype v_unsigned_char\n"
#gdb_expect {
# -re "type = unsigned char.*$gdb_prompt $" { pass "ptype unsigned char" }
# -re ".*$gdb_prompt $" { fail "ptype unsigned char" }
# timeout { fail "(timeout) ptype unsigned char" }
#}
gdb_test "ptype v_short" "type = short(| int).*" "ptype short"
#send "ptype v_signed_short\n"
#gdb_expect {
# -re "type = short.*$gdb_prompt $" { pass "ptype signed short" }
# -re ".*$gdb_prompt $" { fail "ptype signed short" }
# timeout { fail "(timeout) ptype signed short" }
#}
#
#
#send "ptype v_unsigned_short\n"
#gdb_expect {
# -re "type = unsigned short.*$gdb_prompt $" { pass "ptype unsigned short" }
# -re ".*$gdb_prompt $" { fail "ptype unsigned short" }
# timeout { fail "(timeout) ptype unsigned short" }
#}
gdb_test "ptype v_int" "type = int.*" "ptype int"
#send "ptype v_signed_int\n"
#gdb_expect {
# -re "type = int.*$gdb_prompt $" { pass "ptype signed int" }
# -re ".*$gdb_prompt $" { fail "ptype signed int" }
# timeout { fail "(timeout) ptype signed int" }
#}
#
#
#send "ptype v_unsigned_int\n"
#gdb_expect {
# -re "type = unsigned int.*$gdb_prompt $" { pass "ptype unsigned int" }
# -re ".*$gdb_prompt $" { fail "ptype unsigned int" }
# timeout { fail "(timeout) ptype unsigned int" }
#}
#
#
#send "ptype v_long\n"
#gdb_expect {
# -re "type = long.*$gdb_prompt $" { pass "ptype long" }
# -re ".*$gdb_prompt $" { fail "ptype long" }
# timeout { fail "(timeout) ptype long" }
#}
#
#
#send "ptype v_signed_long\n"
#gdb_expect {
# -re "type = long.*$gdb_prompt $" { pass "ptype signed long" }
# -re ".*$gdb_prompt $" { fail "ptype signed long" }
# timeout { fail "(timeout) ptype signed long" }
#}
#
#
#send "ptype v_unsigned_long\n"
#gdb_expect {
# -re "type = unsigned long.*$gdb_prompt $" { pass "ptype unsigned long" }
# -re ".*$gdb_prompt $" { fail "ptype unsigned long" }
# timeout { fail "(timeout) ptype unsigned long" }
#}
#
#
#send "ptype v_float\n"
#gdb_expect {
# -re "type = float.*$gdb_prompt $" { pass "ptype float" }
# -re ".*$gdb_prompt $" { fail "ptype float" }
# timeout { fail "(timeout) ptype float" }
#}
#
#
#send "ptype v_double\n"
#gdb_expect {
# -re "type = double.*$gdb_prompt $" { pass "ptype double" }
# -re ".*$gdb_prompt $" { fail "ptype double" }
# timeout { fail "(timeout) ptype double" }
#}
#
# test ptype command with arrays
#
2012-02-13 19:09:59 +01:00
#setup_xfail "mips-sgi-*"
1999-04-16 03:35:26 +02:00
#send "ptype v_char_array\n"
#gdb_expect {
# -re "type = char .2..*$gdb_prompt $" { pass "ptype char array" }
# -re ".*$gdb_prompt $" { fail "ptype char array" }
# timeout { fail "(timeout) ptype char array" }
#}
#
#
2002-01-06 15:42:39 +01:00
#setup_xfail "mips-*-*"
1999-04-16 03:35:26 +02:00
#send "ptype v_signed_char_array\n"
#gdb_expect {
# -re "type = (|signed )char .2..*$gdb_prompt $" { pass "ptype signed char array" }
# -re ".*$gdb_prompt $" { fail "ptype signed char array" }
# timeout { fail "(timeout) ptype signed char array" }
#}
#
#
#send "ptype v_unsigned_char_array\n"
#gdb_expect {
# -re "type = unsigned char .2..*$gdb_prompt $" { pass "ptype unsigned char array" }
# -re ".*$gdb_prompt $" { fail "ptype unsigned char array" }
# timeout { fail "(timeout) ptype unsigned char array" }
#}
#
#
#
#send "ptype v_int_array\n"
#gdb_expect {
# -re "type = int .2..*$gdb_prompt $" { pass "ptype int array" }
# -re ".*$gdb_prompt $" { fail "ptype int array" }
# timeout { fail "(timeout) ptype int array" }
#}
#
#
#send "ptype v_signed_int_array\n"
#gdb_expect {
# -re "type = int .2..*$gdb_prompt $" { pass "ptype signed int array" }
# -re ".*$gdb_prompt $" { fail "ptype signed int array" }
# timeout { fail "(timeout) ptype signed int array" }
#}
#
#
#send "ptype v_unsigned_int_array\n"
#gdb_expect {
# -re "type = unsigned int .2..*$gdb_prompt $" { pass "ptype unsigned int array" }
# -re ".*$gdb_prompt $" { fail "ptype unsigned int array" }
# timeout { fail "(timeout) ptype unsigned int array" }
#}
#
#
#send "ptype v_long_array\n"
#gdb_expect {
# -re "type = (long|int|long int) .2..*$gdb_prompt $" {
# pass "ptype long array" }
# -re ".*$gdb_prompt $" { fail "ptype long array" }
# timeout { fail "(timeout) ptype long array" }
#}
#
#
#send "ptype v_signed_long_array\n"
#gdb_expect {
# -re "type = (long|int|long int) .2..*$gdb_prompt $" {
# pass "ptype signed long array" }
# -re ".*$gdb_prompt $" { fail "ptype signed long array" }
# timeout { fail "(timeout) ptype signed long array" }
#}
#
#
#send "ptype v_unsigned_long_array\n"
#gdb_expect {
# -re "type = unsigned long .2..*$gdb_prompt $" { pass "ptype unsigned long array" }
# -re ".*$gdb_prompt $" { fail "ptype unsigned long array" }
# timeout { fail "(timeout) ptype unsigned long array" }
#}
#
#
#send "ptype v_float_array\n"
#gdb_expect {
# -re "type = float .2..*$gdb_prompt $" { pass "ptype float array" }
# -re ".*$gdb_prompt $" { fail "ptype float array" }
# timeout { fail "(timeout) ptype float array" }
#}
#
#
#send "ptype v_double_array\n"
#gdb_expect {
# -re "type = double .2..*$gdb_prompt $" { pass "ptype double array" }
# -re ".*$gdb_prompt $" { fail "ptype double array" }
# timeout { fail "(timeout) ptype double array" }
#}
#
if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" "i*86-*-sysv4*" }
gdb_test "ptype t_char_array" "type = (|unsigned )char \\\[0?\\\]"
2012-09-11 11:03:08 +02:00
gdb_test "ptype pv_char_array" "type = (|unsigned )char \\(\\*\\)\\\[0?\\\]"
1999-04-16 03:35:26 +02:00
#
##
## test ptype command with pointers
##
2012-02-13 19:09:59 +01:00
#setup_xfail "mips-sgi-*"
1999-04-16 03:35:26 +02:00
#send "ptype v_char_pointer\n"
#gdb_expect {
# -re "type = char \*.*$gdb_prompt $" { pass "ptype char pointer" }
# -re ".*$gdb_prompt $" { fail "ptype char pointer" }
# timeout { fail "(timeout) ptype char pointer" }
#}
#
#
2002-01-06 15:42:39 +01:00
#setup_xfail "mips-*-*"
1999-04-16 03:35:26 +02:00
#send "ptype v_signed_char_pointer\n"
#gdb_expect {
# -re "type = (|signed )char \*.*$gdb_prompt $"
# { pass "ptype signed char pointer" }
# -re ".*$gdb_prompt $" { fail "ptype signed char pointer" }
# timeout { fail "(timeout) ptype signed char pointer" }
#}
#
#
#send "ptype v_unsigned_char_pointer\n"
#gdb_expect {
# -re "type = unsigned char \*.*$gdb_prompt $" { pass "ptype unsigned char pointer" }
# -re ".*$gdb_prompt $" { fail "ptype unsigned char pointer" }
# timeout { fail "(timeout) ptype unsigned char pointer" }
#}
#
#
#send "ptype v_short_pointer\n"
#gdb_expect {
# -re "type = (short|short int) \*.*$gdb_prompt $" { pass "ptype short pointer" }
# -re ".*$gdb_prompt $" { fail "ptype short pointer" }
# timeout { fail "(timeout) ptype short pointer" }
#}
#
#
#send "ptype v_signed_short_pointer\n"
#gdb_expect {
# -re "type = short \*.*$gdb_prompt $" { pass "ptype signed short pointer" }
# -re ".*$gdb_prompt $" { fail "ptype signed short pointer" }
# timeout { fail "(timeout) ptype signed short pointer" }
#}
#
#
#send "ptype v_unsigned_short_pointer\n"
#gdb_expect {
# -re "type = unsigned short \*.*$gdb_prompt $" { pass "ptype unsigned short pointer" }
# -re ".*$gdb_prompt $" { fail "ptype unsigned short pointer" }
# timeout { fail "(timeout) ptype unsigned short pointer" }
#}
#
#
#send "ptype v_int_pointer\n"
#gdb_expect {
# -re "type = int \*.*$gdb_prompt $" { pass "ptype int pointer" }
# -re ".*$gdb_prompt $" { fail "ptype int pointer" }
# timeout { fail "(timeout) ptype int pointer" }
#}
#
#
#send "ptype v_signed_int_pointer\n"
#gdb_expect {
# -re "type = int \*.*$gdb_prompt $" { pass "ptype signed int pointer" }
# -re ".*$gdb_prompt $" { fail "ptype signed int pointer" }
# timeout { fail "(timeout) ptype signed int pointer" }
#}
#
#
#send "ptype v_unsigned_int_pointer\n"
#gdb_expect {
# -re "type = unsigned int \*.*$gdb_prompt $" { pass "ptype unsigned int pointer" }
# -re ".*$gdb_prompt $" { fail "ptype unsigned int pointer" }
# timeout { fail "(timeout) ptype unsigned int pointer" }
#}
#
#
#send "ptype v_long_pointer\n"
#gdb_expect {
# -re "type = long \*.*$gdb_prompt $" { pass "ptype long pointer" }
# -re ".*$gdb_prompt $" { fail "ptype long pointer" }
# timeout { fail "(timeout) ptype long pointer" }
#}
#
#
#send "ptype v_signed_long_pointer\n"
#gdb_expect {
# -re "type = long \*.*$gdb_prompt $" { pass "ptype signed long pointer" }
# -re ".*$gdb_prompt $" { fail "ptype signed long pointer" }
# timeout { fail "(timeout) ptype signed long pointer" }
#}
#
#
#send "ptype v_unsigned_long_pointer\n"
#gdb_expect {
# -re "type = unsigned long \*.*$gdb_prompt $" { pass "ptype unsigned long pointer" }
# -re ".*$gdb_prompt $" { fail "ptype unsigned long pointer" }
# timeout { fail "(timeout) ptype unsigned long pointer" }
#}
#
#
#send "ptype v_float_pointer\n"
#gdb_expect {
# -re "type = float \*.*$gdb_prompt $" { pass "ptype float pointer" }
# -re ".*$gdb_prompt $" { fail "ptype float pointer" }
# timeout { fail "(timeout) ptype float pointer" }
#}
#
#
#send "ptype v_double_pointer\n"
#gdb_expect {
# -re "type = double \*.*$gdb_prompt $" { pass "ptype double pointer" }
# -re ".*$gdb_prompt $" { fail "ptype double pointer" }
# timeout { fail "(timeout) ptype double pointer" }
#}
#
# test ptype command with nested structure and union
#
1999-06-28 18:06:02 +02:00
gdb_test "ptype struct outer_struct" "type = struct outer_struct \{.*\[\r\n\]+\
.*int outer_int;.*\[\r\n\]+\
2015-12-21 17:23:43 +01:00
.*(struct|) inner_struct inner_struct_instance;.*\[\r\n\]+\
.*(union|) inner_union inner_union_instance;.*\[\r\n\]+\
.*(long|long int|int) outer_long;.*\[\r\n\]\}.*" "ptype outer structure"
1999-04-16 03:35:26 +02:00
2015-12-21 17:23:43 +01:00
gdb_test "ptype struct inner_struct" "type = struct inner_struct \{.*\[\r\n\] int inner_int;.*\[\r\n\] (long|long int|int) inner_long;.*\[\r\n\]\}.*" "ptype inner structure"
1999-04-16 03:35:26 +02:00
2015-12-21 17:23:43 +01:00
gdb_test "ptype union inner_union" "type = union inner_union \{.*\[\r\n\] int inner_union_int;.*\[\r\n\] (long|long int|int) inner_union_long;.*\[\r\n\]\}.*" "ptype inner union"
1999-04-16 03:35:26 +02:00
2015-12-21 17:23:43 +01:00
gdb_test "ptype nested_su" "type = struct outer_struct \{.*\[\r\n\] int outer_int;.*\[\r\n\] (struct |)inner_struct inner_struct_instance;.*\[\r\n\] (union |)inner_union inner_union_instance;.*\[\r\n\] (long|long int|int) outer_long;.*\[\r\n\]\}.*" "ptype nested structure"
1999-04-16 03:35:26 +02:00
2015-12-21 17:23:43 +01:00
gdb_test "ptype nested_su.outer_int" "type = int.*" "ptype outer int"
1999-04-16 03:35:26 +02:00
2015-12-21 17:23:43 +01:00
gdb_test "ptype nested_su.inner_struct_instance" "type = struct inner_struct \{.*\[\r\n\] int inner_int;.*\[\r\n\] (long|long int|int) inner_long;.*\[\r\n\]\}.*" "ptype nested structure #2"
1999-04-16 03:35:26 +02:00
2015-12-21 17:23:43 +01:00
gdb_test "ptype nested_su.inner_struct_instance.inner_int" "type = int.*" "ptype inner int"
1999-04-16 03:35:26 +02:00
2015-12-21 17:23:43 +01:00
gdb_test "ptype nested_su.inner_union_instance" "type = union inner_union \{.*\[\r\n\] int inner_union_int;.*\[\r\n\] (long|long int|int) inner_union_long;.*\[\r\n\]\}.*" "ptype nested union"
1999-04-16 03:35:26 +02:00
2007-12-22 06:28:19 +01:00
# Print the type description of variable the_highest, and verify that
# the type description for the fields whose type is anonymous are
# correctly printed (at nesting level 1 and 2).
gdb_test "ptype the_highest" \
"type = struct highest \{.*\[\r\n\] *int a;.*\[\r\n\] *struct \{.*\[\r\n\] *int b;.*\[\r\n\] *struct \{\.\.\.\} anonymous_level_2;.*\[\r\n\] *\} anonymous_level_1;.*\[\r\n\]}.*" \
"ptype the_highest"
# Print the type descrption for one of the fields of variable the_highest.
# The purpose is to verify that the type of a field that was printed above
# as "struct {...}" is now printed in a more descriptive way (because the
# nesting level is now one level less).
gdb_test "ptype the_highest.anonymous_level_1" \
"type = struct \{.*\[\r\n\] *int b;.*\[\r\n\] *struct \{.*\[\r\n\] *int c;.*\[\r\n\] *\} anonymous_level_2;.*\[\r\n\]}.*" \
"ptype the_highest"
2002-02-21 21:34:16 +01:00
get_debug_format
# Print the type of the identifier ID, and check the response:
# - Expect to see PROTOTYPED as the type. PROTOTYPED is not a regular
# expression; it's a literal string.
# - If we instead see the unprototyped type PLAIN, and we're using STABS
# generated by GCC, that's an xfail; as of 9 Feb 2002, GCC never emits
# prototyped function types in STABS. Like PROTOTYPED, PLAIN is a
# literal string, not a regular expression.
2010-03-24 22:06:33 +01:00
# - If we see OVERPROTOTYPED, it's an xfail for RealView; RealView
# does not distinguish prototyped and unprototyped functions, and
# GDB defaults to prototyped.
2002-02-21 21:34:16 +01:00
# - Otherwise, it's a failure.
2010-03-24 22:06:33 +01:00
proc ptype_maybe_prototyped { id prototyped plain { overprototyped "NO-MATCH" } } {
2002-02-21 21:34:16 +01:00
global gdb_prompt
global gcc_compiled
2010-03-24 22:06:33 +01:00
# Turn the arguments, which are literal strings, into
2002-02-21 21:34:16 +01:00
# regular expressions by quoting any special characters they contain.
2010-03-24 22:06:33 +01:00
foreach var { prototyped plain overprototyped } {
eval "set val \$$var"
regsub -all "\[\]\[*()\]" $val "\\\\&" val
regsub -all "short int" $val "short( int)?" val
regsub -all "long int" $val "long( int)?" val
eval "set $var \$val"
}
2002-02-21 21:34:16 +01:00
2010-05-25 21:34:05 +02:00
gdb_test_multiple "ptype $id" "ptype $id" {
2002-02-21 21:34:16 +01:00
-re "type = $prototyped\[\r\n\]+$gdb_prompt $" {
pass "ptype $id"
}
-re "type = $plain\[\r\n\]+$gdb_prompt $" {
if {$gcc_compiled} { setup_xfail_format "stabs" }
fail "ptype $id (compiler doesn't emit prototyped types)"
}
2010-03-24 22:06:33 +01:00
-re "type = $overprototyped\[\r\n\]+$gdb_prompt $" {
if { [test_compiler_info "armcc-*"] } {
setup_xfail "*-*-*"
}
fail "ptype $id (compiler doesn't emit unprototyped types)"
}
2002-02-21 21:34:16 +01:00
}
}
ptype_maybe_prototyped "func_type" "int (*)(int (*)(int, float), float)" \
"int (*)()"
2010-03-24 22:06:33 +01:00
ptype_maybe_prototyped "old_fptr" "double (*)()" "double (*)()" \
"double (*)(void)"
2002-02-21 21:34:16 +01:00
ptype_maybe_prototyped "new_fptr" "double (*)(void)" "double (*)()"
ptype_maybe_prototyped "fptr" "int (*)(int, float)" "int (*)()"
ptype_maybe_prototyped "fptr2" "int *(*)(int (*)(int, float), float)" \
"int *(*)()"
ptype_maybe_prototyped "xptr" "int (*)(int (*)(), int (*)(void), int)" \
2010-03-24 22:06:33 +01:00
"int (*)()" \
"int (*)(int (*)(void), int (*)(void), int)"
2002-02-21 21:34:16 +01:00
ptype_maybe_prototyped "ffptr" "int (*(*)(char))(short int)" \
"int (*(*)())()"
ptype_maybe_prototyped "fffptr" "int (*(*(*)(char))(short int))(long int)" \
"int (*(*(*)())())()"
2006-01-04 15:46:17 +01:00
# Test printing type of typedefs in different scopes, with same name
# but different type.
2010-06-10 21:48:20 +02:00
gdb_test "list intfoo" ".*"
2006-01-04 15:46:17 +01:00
gdb_test "ptype foo" "type = int" "ptype foo typedef after first list of intfoo"
2010-06-10 21:48:20 +02:00
gdb_test "list charfoo" ".*"
2006-01-04 15:46:17 +01:00
gdb_test "ptype foo" "type = char" "ptype foo typedef after first list of charfoo"
2010-06-10 21:48:20 +02:00
gdb_test "list intfoo" ".*"
2006-01-04 15:46:17 +01:00
gdb_test "ptype foo" "type = int" "ptype foo typedef after second list of intfoo"
2010-06-10 21:48:20 +02:00
gdb_test "list charfoo" ".*"
2006-01-04 15:46:17 +01:00
gdb_test "ptype foo" "type = char" "ptype foo typedef after second list of charfoo"
1999-04-16 03:35:26 +02:00
# Test printing type of string constants and array constants, but
# requires a running process. These call malloc, and can take a long
# time to execute over a slow serial link, so increase the timeout.
if [runto_main] then {
if [target_info exists gdb,cannot_call_functions] {
2016-12-01 21:40:05 +01:00
unsupported "this target can not call functions"
1999-04-16 03:35:26 +02:00
continue
}
1999-07-07 19:31:57 +02:00
# We need to up this because this can be really slow on some boards.
# (malloc() is called as part of the test).
* gdb.base/call-strs.exp, gdb.base/default.exp,
gdb.base/ending-run.exp, gdb.base/finish.exp, gdb.base/funcargs.exp,
gdb.base/huge.exp, gdb.base/nodebug.exp, gdb.base/ptype.exp,
gdb.base/restore.exp, gdb.base/return.exp, gdb.base/setvar.exp,
gdb.base/watchpoints.exp, gdb.threads/gcore-thread.exp,
gdb.base/watchpoint-solib.exp: Save and restore timeout.
* gdb.base/ending-run.exp: Correct restore of timeout.
* gdb.base/page.exp: Remove unnecessary timeout setting.
2010-01-29 16:38:38 +01:00
set prev_timeout $timeout
set timeout 60
1999-07-07 19:31:57 +02:00
1999-04-16 03:35:26 +02:00
gdb_test "ptype \"abc\"" "type = char \\\[4\\\]"
gdb_test "ptype {'a','b','c'}" "type = char \\\[3\\\]"
gdb_test "ptype {0,1,2}" "type = int \\\[3\\\]"
gdb_test "ptype {(long)0,(long)1,(long)2}" "type = long \\\[3\\\]"
gdb_test "ptype {(float)0,(float)1,(float)2}" "type = float \\\[3\\\]"
gdb_test "ptype {{0,1,2},{3,4,5}}" "type = int \\\[2\\\]\\\[3\\\]"
gdb_test "ptype {4,5,6}\[2\]" "type = int"
2008-03-21 16:02:38 +01:00
gdb_test "ptype *&{4,5,6}\[1\]" "Attempt to take address of value not located in memory."
2008-01-30 19:48:07 +01:00
* gdb.base/call-strs.exp, gdb.base/default.exp,
gdb.base/ending-run.exp, gdb.base/finish.exp, gdb.base/funcargs.exp,
gdb.base/huge.exp, gdb.base/nodebug.exp, gdb.base/ptype.exp,
gdb.base/restore.exp, gdb.base/return.exp, gdb.base/setvar.exp,
gdb.base/watchpoints.exp, gdb.threads/gcore-thread.exp,
gdb.base/watchpoint-solib.exp: Save and restore timeout.
* gdb.base/ending-run.exp: Correct restore of timeout.
* gdb.base/page.exp: Remove unnecessary timeout setting.
2010-01-29 16:38:38 +01:00
set timeout $prev_timeout
2008-01-30 19:48:07 +01:00
# Test ptype of user register
gdb_test "ptype \$pc" "void \\(\\*\\)\\(\\)" "ptype \$pc"
1999-04-16 03:35:26 +02:00
}