diff options
author | nobody <> | 2003-08-29 17:18:28 +0000 |
---|---|---|
committer | nobody <> | 2003-08-29 17:18:28 +0000 |
commit | b43ae2f98f8f68bed2dd4534dc463af4d33bd58c (patch) | |
tree | 643f71319ae78cfc5c1d8ea9c350b58be54365eb | |
parent | 3ec5308b78f02afc4a36c37cc327811e6adaa0e0 (diff) | |
download | gdb-b43ae2f98f8f68bed2dd4534dc463af4d33bd58c.zip gdb-b43ae2f98f8f68bed2dd4534dc463af4d33bd58c.tar.gz gdb-b43ae2f98f8f68bed2dd4534dc463af4d33bd58c.tar.bz2 |
This commit was manufactured by cvs2svn to create branch
'carlton_dictionary-branch'.
Cherrypick from master 2003-08-29 17:18:27 UTC Mark Kettenis <kettenis@gnu.org> '* amd64-nat.h (struct regcache): Add opaque declaration.':
config/no-executables.m4
gdb/amd64-nat.c
gdb/amd64-nat.h
gdb/hppa-tdep.h
gdb/sparc64-tdep.h
gdb/sparc64fbsd-nat.c
gdb/sparc64fbsd-tdep.c
gdb/sparcbsd-nat.c
gdb/sparcbsd-nat.h
gdb/testsuite/gdb.arch/i386-prologue.c
gdb/testsuite/gdb.asm/ia64.inc
gdb/testsuite/gdb.cp/Makefile.in
gdb/testsuite/gdb.cp/ambiguous.cc
gdb/testsuite/gdb.cp/ambiguous.exp
gdb/testsuite/gdb.cp/annota2.cc
gdb/testsuite/gdb.cp/annota2.exp
gdb/testsuite/gdb.cp/annota3.cc
gdb/testsuite/gdb.cp/annota3.exp
gdb/testsuite/gdb.cp/anon-union.cc
gdb/testsuite/gdb.cp/anon-union.exp
gdb/testsuite/gdb.cp/casts.cc
gdb/testsuite/gdb.cp/casts.exp
gdb/testsuite/gdb.cp/classes.exp
gdb/testsuite/gdb.cp/cplusfuncs.cc
gdb/testsuite/gdb.cp/cplusfuncs.exp
gdb/testsuite/gdb.cp/ctti.exp
gdb/testsuite/gdb.cp/cttiadd.cc
gdb/testsuite/gdb.cp/cttiadd1.cc
gdb/testsuite/gdb.cp/cttiadd2.cc
gdb/testsuite/gdb.cp/cttiadd3.cc
gdb/testsuite/gdb.cp/demangle.exp
gdb/testsuite/gdb.cp/derivation.cc
gdb/testsuite/gdb.cp/derivation.exp
gdb/testsuite/gdb.cp/hang.H
gdb/testsuite/gdb.cp/hang.exp
gdb/testsuite/gdb.cp/hang1.C
gdb/testsuite/gdb.cp/hang2.C
gdb/testsuite/gdb.cp/hang3.C
gdb/testsuite/gdb.cp/inherit.exp
gdb/testsuite/gdb.cp/local.cc
gdb/testsuite/gdb.cp/local.exp
gdb/testsuite/gdb.cp/m-data.cc
gdb/testsuite/gdb.cp/m-data.exp
gdb/testsuite/gdb.cp/m-static.cc
gdb/testsuite/gdb.cp/m-static.exp
gdb/testsuite/gdb.cp/m-static.h
gdb/testsuite/gdb.cp/m-static1.cc
gdb/testsuite/gdb.cp/maint.exp
gdb/testsuite/gdb.cp/member-ptr.cc
gdb/testsuite/gdb.cp/member-ptr.exp
gdb/testsuite/gdb.cp/method.cc
gdb/testsuite/gdb.cp/method.exp
gdb/testsuite/gdb.cp/misc.cc
gdb/testsuite/gdb.cp/misc.exp
gdb/testsuite/gdb.cp/namespace.cc
gdb/testsuite/gdb.cp/namespace.exp
gdb/testsuite/gdb.cp/namespace1.cc
gdb/testsuite/gdb.cp/overload.cc
gdb/testsuite/gdb.cp/overload.exp
gdb/testsuite/gdb.cp/ovldbreak.cc
gdb/testsuite/gdb.cp/ovldbreak.exp
gdb/testsuite/gdb.cp/pr-1023.cc
gdb/testsuite/gdb.cp/pr-1023.exp
gdb/testsuite/gdb.cp/pr-1210.cc
gdb/testsuite/gdb.cp/pr-1210.exp
gdb/testsuite/gdb.cp/pr-574.cc
gdb/testsuite/gdb.cp/pr-574.exp
gdb/testsuite/gdb.cp/printmethod.cc
gdb/testsuite/gdb.cp/printmethod.exp
gdb/testsuite/gdb.cp/psmang.exp
gdb/testsuite/gdb.cp/psmang1.cc
gdb/testsuite/gdb.cp/psmang2.cc
gdb/testsuite/gdb.cp/ref-types.cc
gdb/testsuite/gdb.cp/ref-types.exp
gdb/testsuite/gdb.cp/rtti.exp
gdb/testsuite/gdb.cp/rtti.h
gdb/testsuite/gdb.cp/rtti1.cc
gdb/testsuite/gdb.cp/rtti2.cc
gdb/testsuite/gdb.cp/templates.cc
gdb/testsuite/gdb.cp/templates.exp
gdb/testsuite/gdb.cp/try_catch.cc
gdb/testsuite/gdb.cp/try_catch.exp
gdb/testsuite/gdb.cp/userdef.cc
gdb/testsuite/gdb.cp/userdef.exp
gdb/testsuite/gdb.cp/virtfunc.cc
gdb/testsuite/gdb.cp/virtfunc.exp
gdb/testsuite/gdb.mi/mi2-basics.exp
gdb/testsuite/gdb.mi/mi2-break.exp
gdb/testsuite/gdb.mi/mi2-cli.exp
gdb/testsuite/gdb.mi/mi2-console.exp
gdb/testsuite/gdb.mi/mi2-disassemble.exp
gdb/testsuite/gdb.mi/mi2-eval.exp
gdb/testsuite/gdb.mi/mi2-file.exp
gdb/testsuite/gdb.mi/mi2-hack-cli.exp
gdb/testsuite/gdb.mi/mi2-pthreads.exp
gdb/testsuite/gdb.mi/mi2-read-memory.exp
gdb/testsuite/gdb.mi/mi2-regs.exp
gdb/testsuite/gdb.mi/mi2-return.exp
gdb/testsuite/gdb.mi/mi2-simplerun.exp
gdb/testsuite/gdb.mi/mi2-stack.exp
gdb/testsuite/gdb.mi/mi2-stepi.exp
gdb/testsuite/gdb.mi/mi2-syn-frame.exp
gdb/testsuite/gdb.mi/mi2-until.exp
gdb/testsuite/gdb.mi/mi2-var-block.exp
gdb/testsuite/gdb.mi/mi2-var-child.exp
gdb/testsuite/gdb.mi/mi2-var-cmd.exp
gdb/testsuite/gdb.mi/mi2-var-display.exp
gdb/testsuite/gdb.mi/mi2-watch.exp
108 files changed, 21803 insertions, 0 deletions
diff --git a/config/no-executables.m4 b/config/no-executables.m4 new file mode 100644 index 0000000..ca26b71 --- /dev/null +++ b/config/no-executables.m4 @@ -0,0 +1,61 @@ +# GCC_NO_EXECUTABLES +# ----------------- +# FIXME: The GCC team has specific needs which the current Autoconf +# framework cannot solve elegantly. This macro implements a dirty +# hack until Autoconf is able to provide the services its users +# need. +# +# Several of the support libraries that are often built with GCC can't +# assume the tool-chain is already capable of linking a program: the +# compiler often expects to be able to link with some of such +# libraries. +# +# In several of these libraries, workarounds have been introduced to +# avoid the AC_PROG_CC_WORKS test, that would just abort their +# configuration. The introduction of AC_EXEEXT, enabled either by +# libtool or by CVS autoconf, have just made matters worse. +# +# Unlike the previous AC_NO_EXECUTABLES, this test does not +# disable link tests at autoconf time, but at configure time. +# This allows AC_NO_EXECUTABLES to be invoked conditionally. +AC_DEFUN_ONCE([GCC_NO_EXECUTABLES], +[m4_divert_push([KILL]) + +AC_BEFORE([$0], [_AC_COMPILER_EXEEXT]) +AC_BEFORE([$0], [AC_LINK_IFELSE]) + +m4_define([_AC_COMPILER_EXEEXT], +AC_LANG_CONFTEST([AC_LANG_PROGRAM()]) +# FIXME: Cleanup? +AS_IF([AC_TRY_EVAL(ac_link)], [gcc_no_link=no], [gcc_no_link=yes]) +if test x$gcc_no_link = xyes; then + # Setting cross_compile will disable run tests; it will + # also disable AC_CHECK_FILE but that's generally + # correct if we can't link. + cross_compiling=yes + EXEEXT= +else + m4_defn([_AC_COMPILER_EXEEXT])dnl +fi +) + +m4_define([AC_LINK_IFELSE], +if test x$gcc_no_link = xyes; then + AC_MSG_ERROR([Link tests are not allowed after [[$0]].]) +fi +m4_defn([AC_LINK_IFELSE])) + +dnl This is a shame. We have to provide a default for some link tests, +dnl similar to the default for run tests. +m4_define([AC_FUNC_MMAP], +if test x$gcc_no_link = xyes; then + if test "x${ac_cv_func_mmap_fixed_mapped+set}" != xset; then + ac_cv_func_mmap_fixed_mapped=no + fi +fi +if test "x${ac_cv_func_mmap_fixed_mapped+set}" != xset; then + m4_defn([AC_FUNC_MMAP]) +fi) + +m4_divert_pop()dnl +])# GCC_NO_EXECUTABLES diff --git a/gdb/amd64-nat.c b/gdb/amd64-nat.c new file mode 100644 index 0000000..fb0efcf --- /dev/null +++ b/gdb/amd64-nat.c @@ -0,0 +1,144 @@ +/* Native-dependent code for AMD64. + + Copyright 2003 Free Software Foundation, Inc. + + This file is part of GDB. + + 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 2 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include "defs.h" +#include "gdbarch.h" +#include "regcache.h" + +#include "gdb_assert.h" + +#include "i386-tdep.h" +#include "x86-64-tdep.h" + +/* The following bits of code help with implementing debugging 32-bit + code natively on AMD64. The idea is to define two mappings between + the register number as used by GDB and the register set used by the + host to represent the general-purpose registers; one for 32-bit + code and one for 64-bit code. The mappings are specified by the + follwing variables and consist of an array of offsets within the + register set indexed by register number, and the number of + registers supported by the mapping. We don't need mappings for the + floating-point and SSE registers, since the difference between + 64-bit and 32-bit variants are negligable. The difference in the + number of SSE registers is already handled by the target code. */ + +/* General-purpose register mapping for native 32-bit code. */ +int *amd64_native_gregset32_reg_offset; +int amd64_native_gregset32_num_regs = I386_NUM_GREGS; + +/* General-purpose register mapping for native 64-bit code. */ +int *amd64_native_gregset64_reg_offset; +int amd64_native_gregset64_num_regs = X86_64_NUM_GREGS; + +/* Return the offset of REGNUM within the appropriate native + general-purpose register set. */ + +static int +amd64_native_gregset_reg_offset (int regnum) +{ + int *reg_offset = amd64_native_gregset64_reg_offset; + int num_regs = amd64_native_gregset64_num_regs; + + gdb_assert (regnum >= 0); + + if (gdbarch_ptr_bit (current_gdbarch) == 32) + { + reg_offset = amd64_native_gregset32_reg_offset; + num_regs = amd64_native_gregset32_num_regs; + } + + if (num_regs > NUM_REGS) + num_regs = NUM_REGS; + + if (regnum < num_regs && regnum < NUM_REGS) + return reg_offset[regnum]; + + return -1; +} + +/* Return whether the native general-purpose register set supplies + register REGNUM. */ + +int +amd64_native_gregset_supplies_p (int regnum) +{ + return (amd64_native_gregset_reg_offset (regnum) != -1); +} + + +/* Supply register REGNUM, whose contents are store in BUF, to + REGCACHE. If REGNUM is -1, supply all appropriate registers. */ + +void +amd64_supply_native_gregset (struct regcache *regcache, + const void *gregs, int regnum) +{ + const char *regs = gregs; + int num_regs = amd64_native_gregset64_num_regs; + int i; + + if (gdbarch_ptr_bit (current_gdbarch) == 32) + num_regs = amd64_native_gregset32_num_regs; + + if (num_regs > NUM_REGS) + num_regs = NUM_REGS; + + for (i = 0; i < num_regs; i++) + { + if (regnum == -1 || regnum == i) + { + int offset = amd64_native_gregset_reg_offset (i); + + if (offset != -1) + regcache_raw_supply (current_regcache, i, regs + offset); + } + } +} + +/* Collect register REGNUM from REGCACHE and store its contents in + GREGS. If REGNUM is -1, collect and store all appropriate + registers. */ + +void +amd64_collect_native_gregset (const struct regcache *regcache, + void *gregs, int regnum) +{ + char *regs = gregs; + int num_regs = amd64_native_gregset64_num_regs; + int i; + + if (gdbarch_ptr_bit (current_gdbarch) == 32) + num_regs = amd64_native_gregset32_num_regs; + + if (num_regs > NUM_REGS) + num_regs = NUM_REGS; + + for (i = 0; i < num_regs; i++) + { + if (regnum == -1 || regnum == i) + { + int offset = amd64_native_gregset_reg_offset (i); + + if (offset != -1) + regcache_raw_collect (current_regcache, i, regs + offset); + } + } +} diff --git a/gdb/amd64-nat.h b/gdb/amd64-nat.h new file mode 100644 index 0000000..edf6df8 --- /dev/null +++ b/gdb/amd64-nat.h @@ -0,0 +1,53 @@ +/* Native-dependent code for AMD64. + + Copyright 2003 Free Software Foundation, Inc. + + This file is part of GDB. + + 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 2 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef AMD64_NAT_H +#define AMD64_NAT_H 1 + +struct regcache; + +/* General-purpose register set description for native 32-bit code. */ +extern int *amd64_native_gregset32_reg_offset; +extern int amd64_native_gregset32_num_regs; + +/* General-purpose register set description for native 64-bit code. */ +extern int *amd64_native_gregset64_reg_offset; +extern int amd64_native_gregset64_num_regs; + +/* Return whether the native general-purpose register set supplies + register REGNUM. */ + +extern int amd64_native_gregset_supplies_p (int regnum); + +/* Supply register REGNUM, whose contents are store in BUF, to + REGCACHE. If REGNUM is -1, supply all appropriate registers. */ + +extern void amd64_supply_native_gregset (struct regcache *regcache, + const void *gregs, int regnum); + +/* Collect register REGNUM from REGCACHE and store its contents in + GREGS. If REGNUM is -1, collect and store all appropriate + registers. */ + +extern void amd64_collect_native_gregset (const struct regcache *regcache, + void *gregs, int regnum); + +#endif /* amd64-nat.h */ diff --git a/gdb/hppa-tdep.h b/gdb/hppa-tdep.h new file mode 100644 index 0000000..05a4e89 --- /dev/null +++ b/gdb/hppa-tdep.h @@ -0,0 +1,32 @@ +/* Common target dependent code for GDB on HPPA systems. + Copyright 2003 Free Software Foundation, Inc. + + This file is part of GDB. + + 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 2 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef HPPA_TDEP_H +#define HPPA_TDEP_H + +/* Target-dependent structure in gdbarch. */ +struct gdbarch_tdep +{ + /* The number of bytes in an address. For now, this field is designed + to allow us to differentiate hppa32 from hppa64 targets. */ + int bytes_per_address; +}; + +#endif /* HPPA_TDEP_H */ diff --git a/gdb/sparc64-tdep.h b/gdb/sparc64-tdep.h new file mode 100644 index 0000000..e7b910d --- /dev/null +++ b/gdb/sparc64-tdep.h @@ -0,0 +1,103 @@ +/* Target-dependent code for UltraSPARC. + + Copyright 2003 Free Software Foundation, Inc. + + This file is part of GDB. + + 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 2 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef SPARC64_TDEP_H +#define SPARC62_TDEP_H 1 + +/* Register numbers of various important registers. */ + +enum sparc_regnum +{ + SPARC_G0_REGNUM, /* %g0 */ + SPARC_G1_REGNUM, + SPARC_G2_REGNUM, + SPARC_G3_REGNUM, + SPARC_G4_REGNUM, + SPARC_G5_REGNUM, + SPARC_G6_REGNUM, + SPARC_G7_REGNUM, /* %g7 */ + SPARC_O0_REGNUM, /* %o0 */ + SPARC_O1_REGNUM, + SPARC_O2_REGNUM, + SPARC_O3_REGNUM, + SPARC_O4_REGNUM, + SPARC_O5_REGNUM, + SPARC_SP_REGNUM, /* %sp (%o6) */ + SPARC_O7_REGNUM, /* %o7 */ + SPARC_L0_REGNUM, /* %l0 */ + SPARC_L1_REGNUM, + SPARC_L2_REGNUM, + SPARC_L3_REGNUM, + SPARC_L4_REGNUM, + SPARC_L5_REGNUM, + SPARC_L6_REGNUM, + SPARC_L7_REGNUM, /* %l7 */ + SPARC_I0_REGNUM, /* %i0 */ + SPARC_I1_REGNUM, + SPARC_I2_REGNUM, + SPARC_I3_REGNUM, + SPARC_I4_REGNUM, + SPARC_I5_REGNUM, + SPARC_FP_REGNUM, /* %fp (%i6) */ + SPARC_I7_REGNUM, /* %i7 */ + SPARC_F0_REGNUM, /* %f0 */ + SPARC_F31_REGNUM = SPARC_F0_REGNUM + 31 /* %f31 */ +}; + +enum sparc64_regnum +{ + SPARC64_F32_REGNUM = SPARC_F0_REGNUM + 32, /* %f32 */ + SPARC64_F62_REGNUM = SPARC64_F32_REGNUM + 15, /* %f62 */ + SPARC64_PC_REGNUM, /* %pc */ + SPARC64_NPC_REGNUM, /* %npc */ + SPARC64_STATE_REGNUM, + SPARC64_FSR_REGNUM, /* %fsr */ + SPARC64_FPRS_REGNUM, /* %fprs */ + SPARC64_Y_REGNUM, /* %y */ + + /* Pseudo registers. */ + SPARC64_CWP_REGNUM, /* %cwp */ + SPARC64_PSTATE_REGNUM, /* %pstate */ + SPARC64_ASI_REGNUM, /* %asi */ + SPARC64_CCR_REGNUM, /* %ccr */ + SPARC64_D0_REGNUM, /* %d0 */ + SPARC64_D10_REGNUM = SPARC64_D0_REGNUM + 5, /* %d10 */ + SPARC64_D30_REGNUM = SPARC64_D0_REGNUM + 15, /* %d30 */ + SPARC64_D32_REGNUM = SPARC64_D0_REGNUM + 16, /* %d32 */ + SPARC64_D62_REGNUM = SPARC64_D0_REGNUM + 31, /* %d62 */ + SPARC64_Q0_REGNUM, /* %q0 */ + SPARC64_Q8_REGNUM = SPARC64_Q0_REGNUM + 2, /* %q8 */ + SPARC64_Q28_REGNUM = SPARC64_Q0_REGNUM + 7, /* %q28 */ + SPARC64_Q32_REGNUM = SPARC64_Q0_REGNUM + 8, /* %q32 */ + SPARC64_Q60_REGNUM = SPARC64_Q0_REGNUM + 15 /* %q60 */ +}; + +extern void sparc_supply_rwindow (CORE_ADDR sp, int regnum); +extern void sparc_fill_rwindow (CORE_ADDR sp, int regnum); + +/* Functions exported from sparc64fbsd-tdep.c. */ + +extern void sparc64fbsd_supply_reg (const char *regs, int regnum); +extern void sparc64fbsd_fill_reg (char *regs, int regnum); +extern void sparc64fbsd_supply_fpreg (const char *regs, int regnum); +extern void sparc64fbsd_fill_fpreg (char *regs, int regnum); + +#endif /* sparc64-tdep.h */ diff --git a/gdb/sparc64fbsd-nat.c b/gdb/sparc64fbsd-nat.c new file mode 100644 index 0000000..26c58d8 --- /dev/null +++ b/gdb/sparc64fbsd-nat.c @@ -0,0 +1,80 @@ +/* Native-dependent code for FreeBSD/sparc64. + + Copyright 2003 Free Software Foundation, Inc. + + This file is part of GDB. + + 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 2 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include "defs.h" + +#include "sparc64-tdep.h" +#include "sparcbsd-nat.h" + +/* Determine whether `struct reg' contains register REGNUM. */ + +static int +sparc64fbsd_reg_supplies_p (int regnum) +{ + /* Integer registers. */ + if ((regnum >= SPARC_G0_REGNUM && regnum <= SPARC_G7_REGNUM) + || (regnum >= SPARC_O0_REGNUM && regnum <= SPARC_O7_REGNUM) + || (regnum >= SPARC_L0_REGNUM && regnum <= SPARC_L7_REGNUM) + || (regnum >= SPARC_I0_REGNUM && regnum <= SPARC_I7_REGNUM)) + return 1; + + /* Control registers. */ + if (regnum == SPARC64_PC_REGNUM + || regnum == SPARC64_NPC_REGNUM + || regnum == SPARC64_STATE_REGNUM + || regnum == SPARC64_FPRS_REGNUM + || regnum == SPARC64_Y_REGNUM) + return 1; + + return 0; +} + +/* Determine whether `struct fpreg' contains register REGNUM. */ + +static int +sparc64fbsd_fpreg_supplies_p (int regnum) +{ + /* Floating-point registers. */ + if ((regnum >= SPARC_F0_REGNUM && regnum <= SPARC_F31_REGNUM) + || (regnum >= SPARC64_F32_REGNUM && regnum <= SPARC64_F62_REGNUM)) + return 1; + + /* Control registers. */ + if (regnum == SPARC64_FSR_REGNUM) + return 1; + + return 0; +} + +/* Provide a prototype to silence -Wmissing-prototypes. */ +void _initialize_sparc64fbsd_nat (void); + +void +_initialize_sparc64fbsd_nat (void) +{ + sparcbsd_supply_reg = sparc64fbsd_supply_reg; + sparcbsd_fill_reg = sparc64fbsd_fill_reg; + sparcbsd_supply_fpreg = sparc64fbsd_supply_fpreg; + sparcbsd_fill_fpreg = sparc64fbsd_fill_fpreg; + + sparcbsd_reg_supplies_p = sparc64fbsd_reg_supplies_p; + sparcbsd_fpreg_supplies_p = sparc64fbsd_fpreg_supplies_p; +} diff --git a/gdb/sparc64fbsd-tdep.c b/gdb/sparc64fbsd-tdep.c new file mode 100644 index 0000000..2b910c1 --- /dev/null +++ b/gdb/sparc64fbsd-tdep.c @@ -0,0 +1,237 @@ +/* Target-dependent code for FreeBSD/sparc64. + + Copyright 2003 Free Software Foundation, Inc. + + This file is part of GDB. + + 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 2 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include "defs.h" +#include "gdbcore.h" +#include "osabi.h" +#include "regcache.h" +#include "target.h" + +#include "gdb_string.h" + +#include "sparc64-tdep.h" + +/* From <machine/reg.h>. */ + +/* Offset of registers in `struct reg'. */ +int sparc64fbsd_r_global_offset = (0 * 8); +int sparc64fbsd_r_out_offset = (8 * 8); +int sparc64fbsd_r_fprs_offset = (16 * 8); +int sparc64fbsd_r_tnpc_offset = (24 * 8); +int sparc64fbsd_r_tpc_offset = (25 * 8); +int sparc64fbsd_r_tstate_offset = (26 * 8); +int sparc64fbsd_r_y_offset = (28 * 8); + +/* Size of `struct reg' and `struct fpreg'. */ +int sparc64fbsd_sizeof_struct_reg = 256; +int sparc64fbsd_sizeof_struct_fpreg = 272; + +void +sparc64fbsd_supply_reg (const char *regs, int regnum) +{ + char buf[8]; + int i; + + if (regnum == SPARC64_PC_REGNUM || regnum == -1) + supply_register (SPARC64_PC_REGNUM, regs + sparc64fbsd_r_tpc_offset); + + if (regnum == SPARC64_NPC_REGNUM || regnum == -1) + supply_register (SPARC64_NPC_REGNUM, regs + sparc64fbsd_r_tnpc_offset); + + if (regnum == SPARC64_STATE_REGNUM || regnum == -1) + supply_register (SPARC64_STATE_REGNUM, regs + sparc64fbsd_r_tstate_offset); + + if (regnum == SPARC64_FPRS_REGNUM || regnum == -1) + supply_register (SPARC64_FPRS_REGNUM, regs + sparc64fbsd_r_fprs_offset); + + if (regnum == SPARC64_Y_REGNUM || regnum == -1) + supply_register (SPARC64_Y_REGNUM, regs + sparc64fbsd_r_y_offset); + + if ((regnum >= SPARC_G0_REGNUM && regnum <= SPARC_G7_REGNUM) || regnum == -1) + { + if (regnum == SPARC_G0_REGNUM || regnum == -1) + supply_register (SPARC_G0_REGNUM, NULL); /* %g0 is always zero. */ + for (i = SPARC_G1_REGNUM; i <= SPARC_G7_REGNUM; i++) + { + if (regnum == i || regnum == -1) + supply_register (i, (regs + sparc64fbsd_r_global_offset + + ((i - SPARC_G0_REGNUM) * 8))); + } + } + + if ((regnum >= SPARC_O0_REGNUM && regnum <= SPARC_O7_REGNUM) || regnum == -1) + { + for (i = SPARC_O0_REGNUM; i <= SPARC_O7_REGNUM; i++) + { + if (regnum == i || regnum == -1) + supply_register (i, (regs + sparc64fbsd_r_out_offset + + ((i - SPARC_O0_REGNUM) * 8))); + } + } + + /* Inputs and Locals are stored onto the stack by by the kernel. */ + if ((regnum >= SPARC_L0_REGNUM && regnum <= SPARC_I7_REGNUM) || regnum == -1) + { + ULONGEST sp; + + regcache_cooked_read_unsigned (current_regcache, SPARC_SP_REGNUM, &sp); + sparc_supply_rwindow (sp, regnum); + } +} + +void +sparc64fbsd_fill_reg (char *regs, int regnum) +{ + char buf[8]; + int i; + + if (regnum == SPARC64_PC_REGNUM || regnum == -1) + regcache_collect (SPARC64_PC_REGNUM, regs + sparc64fbsd_r_tpc_offset); + + if (regnum == SPARC64_NPC_REGNUM || regnum == -1) + regcache_collect (SPARC64_NPC_REGNUM, regs + sparc64fbsd_r_tnpc_offset); + + if (regnum == SPARC64_FPRS_REGNUM || regnum == -1) + regcache_collect (SPARC64_FPRS_REGNUM, regs + sparc64fbsd_r_fprs_offset); + + if (regnum == SPARC64_Y_REGNUM || regnum == -1) + regcache_collect (SPARC64_Y_REGNUM, regs + sparc64fbsd_r_y_offset); + + if ((regnum >= SPARC_G0_REGNUM && regnum <= SPARC_G7_REGNUM) || regnum == -1) + { + /* %g0 is always zero. */ + for (i = SPARC_G1_REGNUM; i <= SPARC_G7_REGNUM; i++) + { + if (regnum == i || regnum == -1) + regcache_collect (i, (regs + sparc64fbsd_r_global_offset + + ((i - SPARC_G0_REGNUM) * 8))); + } + } + + if ((regnum >= SPARC_O0_REGNUM && regnum <= SPARC_O7_REGNUM) || regnum == -1) + { + for (i = SPARC_O0_REGNUM; i <= SPARC_O7_REGNUM; i++) + { + if (regnum == i || regnum == -1) + regcache_collect (i, (regs + sparc64fbsd_r_out_offset + + ((i - SPARC_O0_REGNUM) * 8))); + } + } + + /* Responsibility for the stack regs is pushed off onto the caller. */ +} + +void +sparc64fbsd_supply_fpreg (const char *fpregs, int regnum) +{ + int i; + + for (i = 0; i < 32; i++) + { + if (regnum == (SPARC_F0_REGNUM + i) || regnum == -1) + supply_register (SPARC_F0_REGNUM + i, fpregs + (i * 4)); + } + + for (i = 0; i < 16; i++) + { + if (regnum == (SPARC64_F32_REGNUM + i) || regnum == -1) + supply_register (SPARC64_F32_REGNUM + i, fpregs + (32 * 4) + (i * 8)); + } + + if (regnum == SPARC64_FSR_REGNUM || regnum == -1) + supply_register (SPARC64_FSR_REGNUM, fpregs + (32 * 4) + (16 * 8)); +} + +void +sparc64fbsd_fill_fpreg (char *fpregs, int regnum) +{ + int i; + + for (i = 0; i < 32; i++) + { + if (regnum == (SPARC_F0_REGNUM + i) || regnum == -1) + regcache_collect (SPARC_F0_REGNUM + i, fpregs + (i * 4)); + } + + for (i = 0; i < 16; i++) + { + if (regnum == (SPARC64_F32_REGNUM + i) || regnum == -1) + regcache_collect (SPARC64_F32_REGNUM + i, fpregs + (32 * 4) + (i * 8)); + } + + if (regnum == SPARC64_FSR_REGNUM || regnum == -1) + regcache_collect (SPARC64_FSR_REGNUM, fpregs + (32 * 4) + (16 * 8)); +} + + +static void +fetch_core_registers (char *core_reg_sect, unsigned core_reg_size, int which, + CORE_ADDR ignore) +{ + switch (which) + { + case 0: /* Integer registers */ + if (core_reg_size != sparc64fbsd_sizeof_struct_reg) + warning ("Wrong size register set in core file."); + else + sparc64fbsd_supply_reg (core_reg_sect, -1); + break; + + case 2: /* Floating pointer registers */ + if (core_reg_size != sparc64fbsd_sizeof_struct_fpreg) + warning ("Wrong size FP register set in core file."); + else + sparc64fbsd_supply_fpreg (core_reg_sect, -1); + break; + + default: + /* Don't know what kind of register request this is; just ignore it. */ + break; + } +} + +static struct core_fns sparc64fbsd_core_fns = +{ + bfd_target_elf_flavour, /* core_flavour */ + default_check_format, /* check_format */ + default_core_sniffer, /* core_sniffer */ + fetch_core_registers, /* core_read_registers */ + NULL +}; + + +static void +sparc64fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) +{ + /* Nothing yet. */ +} + +/* Provide a prototype to silence -Wmissing-prototypes. */ +void _initialize_sparc64fbsd_tdep (void); + +void +_initialize_sparc64fbsd_tdep (void) +{ + gdbarch_register_osabi (bfd_arch_sparc, bfd_mach_sparc_v9, + GDB_OSABI_FREEBSD_ELF, sparc64fbsd_init_abi); + + add_core_fns (&sparc64fbsd_core_fns); +} diff --git a/gdb/sparcbsd-nat.c b/gdb/sparcbsd-nat.c new file mode 100644 index 0000000..8ab9537 --- /dev/null +++ b/gdb/sparcbsd-nat.c @@ -0,0 +1,126 @@ +/* Native-dependent code for SPARC BSD's. + + Copyright 2002, 2003 Free Software Foundation, Inc. + Based on code contributed by Wasabi Systems, Inc. + + This file is part of GDB. + + 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 2 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include "defs.h" +#include "inferior.h" +#include "regcache.h" + +/* FIXME: Should be changed to sparc-tdep.h when the old code is gone. */ +#include "sparc64-tdep.h" +#include "sparcbsd-nat.h" + +#include <sys/types.h> +#include <sys/ptrace.h> +#include <machine/reg.h> + +/* Functions translating between `struct reg' and `struct fpreg' and + GDB's register cache. */ +void (*sparcbsd_supply_reg)(const char *, int); +void (*sparcbsd_fill_reg)(char *, int); +void (*sparcbsd_supply_fpreg)(const char *, int); +void (*sparcbsd_fill_fpreg)(char *, int); + +/* Functions indication whether `struct reg' or `struct fpreg' provides + a certain register. */ +int (*sparcbsd_reg_supplies_p)(int); +int (*sparcbsd_fpreg_supplies_p)(int); + +void +fetch_inferior_registers (int regnum) +{ + if (regnum == -1 || sparcbsd_reg_supplies_p (regnum)) + { + struct reg regs; + + if (ptrace (PT_GETREGS, PIDGET (inferior_ptid), + (PTRACE_ARG3_TYPE) ®s, 0) == -1) + perror_with_name ("Couldn't get registers"); + + sparcbsd_supply_reg ((char *) ®s, regnum); + if (regnum != -1) + return; + } + + if (regnum == -1 || sparcbsd_fpreg_supplies_p (regnum)) + { + struct fpreg fpregs; + + if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid), + (PTRACE_ARG3_TYPE) &fpregs, 0) == -1) + perror_with_name ("Couldn't get floating-point registers"); + + sparcbsd_supply_fpreg ((char *) &fpregs, regnum); + if (regnum != -1) + return; + } +} + +void +store_inferior_registers (int regnum) +{ + if (regnum == -1 || sparcbsd_reg_supplies_p (regnum)) + { + struct reg regs; + + if (ptrace (PT_GETREGS, PIDGET (inferior_ptid), + (PTRACE_ARG3_TYPE) ®s, 0) == -1) + perror_with_name ("Couldn't get registers"); + + sparcbsd_fill_reg ((char *) ®s, regnum); + + if (ptrace (PT_SETREGS, PIDGET (inferior_ptid), + (PTRACE_ARG3_TYPE) ®s, 0) == -1) + perror_with_name ("Couldn't write registers"); + + /* Deal with the stack regs. */ + if (regnum == -1 || regnum == SPARC_SP_REGNUM + || (regnum >= SPARC_L0_REGNUM && regnum <= SPARC_I7_REGNUM)) + { + ULONGEST sp; + + regcache_cooked_read_unsigned (current_regcache, + SPARC_SP_REGNUM, &sp); + sparc_fill_rwindow (sp, regnum); + } + + if (regnum != -1) + return; + } + + if (regnum == -1 || sparcbsd_fpreg_supplies_p (regnum)) + { + struct fpreg fpregs; + + if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid), + (PTRACE_ARG3_TYPE) &fpregs, 0) == -1) + perror_with_name ("Couldn't get floating-point registers"); + + sparcbsd_fill_fpreg ((char *) &fpregs, regnum); + + if (ptrace (PT_SETFPREGS, PIDGET (inferior_ptid), + (PTRACE_ARG3_TYPE) &fpregs, 0) == -1) + perror_with_name ("Couldn't write floating-point registers"); + + if (regnum != -1) + return; + } +} diff --git a/gdb/sparcbsd-nat.h b/gdb/sparcbsd-nat.h new file mode 100644 index 0000000..326d669 --- /dev/null +++ b/gdb/sparcbsd-nat.h @@ -0,0 +1,37 @@ +/* Native-dependent code for SPARC BSD's. + + Copyright 2003 Free Software Foundation, Inc. + + This file is part of GDB. + + 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 2 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef SPARCBSD_NAT_H +#define SPARCBSD_NAT_H + +/* Functions translating between `struct reg' and `struct fpreg' and + GDB's register cache. */ +extern void (*sparcbsd_supply_reg)(const char *, int); +extern void (*sparcbsd_fill_reg)(char *, int); +extern void (*sparcbsd_supply_fpreg)(const char *, int); +extern void (*sparcbsd_fill_fpreg)(char *, int); + +/* Functions indication whether `struct reg' or `struct fpreg' provides + a certain register. */ +extern int (*sparcbsd_reg_supplies_p)(int); +extern int (*sparcbsd_fpreg_supplies_p)(int); + +#endif /* sparcbsd-nat.h */ diff --git a/gdb/testsuite/gdb.arch/i386-prologue.c b/gdb/testsuite/gdb.arch/i386-prologue.c new file mode 100644 index 0000000..4c92a9c --- /dev/null +++ b/gdb/testsuite/gdb.arch/i386-prologue.c @@ -0,0 +1,37 @@ +void gdb1253 (void); +void gdb1338 (void); + +int +main (void) +{ + gdb1253 (); + gdb1338 (); + return 0; +} + +/* Relevant part of the prologue from symtab/1253. */ + +asm(".text\n" + " .align 8\n" + "gdb1253:\n" + " pushl %ebp\n" + " xorl %ecx, %ecx\n" + " movl %esp, %ebp\n" + " pushl %edi\n" + " int $0x03\n" + " leave\n" + " ret\n"); + +/* Relevant part of the prologue from backtrace/1338. */ + +asm(".text\n" + " .align 8\n" + "gdb1338:\n" + " pushl %edi\n" + " pushl %esi\n" + " pushl %ebx\n" + " int $0x03\n" + " popl %ebx\n" + " popl %esi\n" + " popl %edi\n" + " ret\n"); diff --git a/gdb/testsuite/gdb.asm/ia64.inc b/gdb/testsuite/gdb.asm/ia64.inc new file mode 100644 index 0000000..d55cd22 --- /dev/null +++ b/gdb/testsuite/gdb.asm/ia64.inc @@ -0,0 +1,49 @@ + comment "subroutine prologue" + .macro gdbasm_enter + alloc r33=ar.pfs,0,2,0,0 + mov r32=b0 + nop.i 0 + .endm + + comment "subroutine epilogue" + .macro gdbasm_leave + nop.m 0 + mov ar.pfs=r33 + mov b0=r32 + nop.m 0 + nop.f 0 + br.ret.sptk.many b0 + .endm + + .macro gdbasm_call subr + nop.m 0 + nop.f 0 + br.call.sptk.many b0=\subr + .endm + + .macro gdbasm_several_nops + nop.m 0 + nop.i 0 + nop.i 0 + .endm + + comment "exit (0)" + .macro gdbasm_exit0 + break.m 0x0 + nop.m 0 + nop.i 0 + .endm + + comment "crt0 startup" + .macro gdbasm_startup + mov r32=r0 + nop.i 0 + nop.i 0 + .endm + + comment "Declare a data variable" + .macro gdbasm_datavar name value + .data +\name: + .long \value + .endm diff --git a/gdb/testsuite/gdb.cp/Makefile.in b/gdb/testsuite/gdb.cp/Makefile.in new file mode 100644 index 0000000..8f4a90e --- /dev/null +++ b/gdb/testsuite/gdb.cp/Makefile.in @@ -0,0 +1,16 @@ +VPATH = @srcdir@ +srcdir = @srcdir@ + +EXECUTABLES = ambiguous annota2 anon-union cplusfuncs cttiadd \ + derivation inherit local member-ptr method misc \ + overload ovldbreak ref-typ ref-typ2 templates userdef virtfunc namespace ref-types + +all info install-info dvi install uninstall installcheck check: + @echo "Nothing to be done for $@..." + +clean mostlyclean: + -rm -f *~ *.o *.ci + -rm -f core ${EXECUTABLES} + +distclean maintainer-clean realclean: clean + -rm -f Makefile config.status config.log diff --git a/gdb/testsuite/gdb.cp/ambiguous.cc b/gdb/testsuite/gdb.cp/ambiguous.cc new file mode 100644 index 0000000..6ee7bc1 --- /dev/null +++ b/gdb/testsuite/gdb.cp/ambiguous.cc @@ -0,0 +1,110 @@ + +void marker1() +{ + return; +} + +class A1 { +public: + int x; + int y; +}; + +class A2 { +public: + int x; + int y; +}; + +class A3 { +public: + int x; + int y; +}; + +class X : public A1, public A2 { +public: + int z; +}; + +class L : public A1 { +public: + int z; +}; + +class LV : public virtual A1 { +public: + int z; +}; + +class M : public A2 { +public: + int w; +}; + +class N : public L, public M { +public: + int r; +}; + +class K : public A1 { +public: + int i; +}; + +class KV : public virtual A1 { +public: + int i; +}; + +class J : public K, public L { +public: + int j; +}; + +class JV : public KV, public LV { +public: + int jv; +}; + +class JVA1 : public KV, public LV, public A1 { +public: + int jva1; +}; + +class JVA2 : public KV, public LV, public A2 { +public: + int jva2; +}; + +class JVA1V : public KV, public LV, public virtual A1 { +public: + int jva1v; +}; + +int main() +{ + A1 a1; + A2 a2; + A3 a3; + X x; + L l; + M m; + N n; + K k; + J j; + JV jv; + JVA1 jva1; + JVA2 jva2; + JVA1V jva1v; + + int i; + + i += k.i + m.w + a1.x + a2.x + a3.x + x.z + l.z + n.r + j.j; + + marker1(); + +} + + + diff --git a/gdb/testsuite/gdb.cp/ambiguous.exp b/gdb/testsuite/gdb.cp/ambiguous.exp new file mode 100644 index 0000000..4224b2d --- /dev/null +++ b/gdb/testsuite/gdb.cp/ambiguous.exp @@ -0,0 +1,237 @@ +# Copyright 1998, 1999 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# This file is part of the gdb testsuite + +# tests relating to ambiguous class members +# Written by Satish Pai <pai@apollo.hp.com> 1997-07-28 + +# This file is part of the gdb testsuite + +if $tracelevel then { + strace $tracelevel + } + +# +# test running programs +# + +set prms_id 0 +set bug_id 0 + +if { [skip_cplus_tests] } { continue } + +set testfile "ambiguous" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if [get_compiler_info ${binfile} "c++"] { + return -1; +} + +if { $gcc_compiled } then { continue } + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + + +# +# set it up at a breakpoint so we can play with the variable values +# +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + +send_gdb "break marker1\n" ; gdb_expect -re ".*$gdb_prompt $" + send_gdb "cont\n" + gdb_expect { + -re "Break.* marker1 \\(\\) at .*:$decimal.*$gdb_prompt $" { + send_gdb "up\n" + gdb_expect { + -re ".*$gdb_prompt $" { pass "up from marker1" } + timeout { fail "up from marker1" } + } + } + -re "$gdb_prompt $" { fail "continue to marker1" } + timeout { fail "(timeout) continue to marker1" } + } + +# print out various class objects' members. The values aren't +# important, just check that the warning is emitted at the +# right times. + +# X is derived from A1 and A2; both A1 and A2 have a member 'x' +send_gdb "print x.x\n" +gdb_expect { + -re "warning: x ambiguous; using X::A2::x. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" { + pass "print x.x" + } + -re "warning: x ambiguous; using X::A1::x. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" { + pass "print x.x" + } + -re ".*$gdb_prompt $" { fail "print x.x" } + timeout { fail "(timeout) print x.x" } +} + + +# N is derived from A1 and A2, but not immediately -- two steps +# up in the hierarchy. Both A1 and A2 have a member 'x'. +send_gdb "print n.x\n" +gdb_expect { + -re "warning: x ambiguous; using N::M::A2::x. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" { + pass "print n.x" + } + -re "warning: x ambiguous; using N::L::A1::x. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" { + pass "print n.x" + } + -re ".*$gdb_prompt $" { fail "print n.x" } + timeout { fail "(timeout) print n.x" } +} + +# J is derived from A1 twice. A1 has a member x. +send_gdb "print j.x\n" +gdb_expect { + -re "warning: x ambiguous; using J::L::A1::x. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" { + pass "print j.x" + } + -re "warning: x ambiguous; using J::K::A1::x. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" { + pass "print j.x" + } + -re ".*$gdb_prompt $" { fail "print j.x" } + timeout { fail "(timeout) print j.x" } +} + +# JV is derived from A1 but A1 is a virtual base. Should not +# report an ambiguity in this case. +send_gdb "print jv.x\n" +gdb_expect { + -re "warning: x ambiguous.*Use a cast to disambiguate.\r\n\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" { + fail "print jv.x (ambiguity reported)" + } + -re "\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" { pass "print jv.x" } + -re ".*$gdb_prompt $" { fail "print jv.x (??)" } + timeout { fail "(timeout) print jv.x" } +} + +# JVA1 is derived from A1; A1 occurs as a virtual base in two +# ancestors, and as a non-virtual immediate base. Ambiguity must +# be reported. +send_gdb "print jva1.x\n" +gdb_expect { + -re "warning: x ambiguous; using JVA1::A1::x. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" { + pass "print jva1.x" + } + -re "warning: x ambiguous; using JVA1::KV::A1::x. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" { + pass "print jva1.x" + } + -re ".*$gdb_prompt $" { fail "print jva1.x" } + timeout { fail "(timeout) print jva1.x" } +} + +# JVA2 is derived from A1 & A2; A1 occurs as a virtual base in two +# ancestors, and A2 is a non-virtual immediate base. Ambiguity must +# be reported as A1 and A2 both have a member 'x'. +send_gdb "print jva2.x\n" +gdb_expect { + -re "warning: x ambiguous; using JVA2::A2::x. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" { + pass "print jva2.x" + } + -re "warning: x ambiguous; using JVA2::KV::A1::x. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" { + pass "print jva2.x" + } + -re ".*$gdb_prompt $" { fail "print jva2.x" } + timeout { fail "(timeout) print jva2.x" } +} + +# JVA1V is derived from A1; A1 occurs as a virtual base in two +# ancestors, and also as a virtual immediate base. Ambiguity must +# not be reported. +send_gdb "print jva1v.x\n" +gdb_expect { + -re "warning: x ambiguous.*Use a cast to disambiguate.\r\n\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" { + fail "print jva1v.x (ambiguity reported)" + } + -re "\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" { pass "print jva1v.x" } + -re ".*$gdb_prompt $" { fail "print jva1v.x (??)" } + timeout { fail "(timeout) print jva1v.x" } +} + +# Now check for ambiguous bases. + +# J is derived from A1 twice; report ambiguity if a J is +# cast to an A1. +send_gdb "print (A1)j\n" +gdb_expect { + -re "warning: A1 ambiguous; using J::L::A1. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \{x = \[-\]*\[0-9\]*, y = \[-\]*\[0-9\]*\}\r\n$gdb_prompt $" { + pass "print (A1)j" + } + -re "warning: A1 ambiguous; using J::K::A1. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \{x = \[-\]*\[0-9\]*, y = \[-\]*\[0-9\]*\}\r\n$gdb_prompt $" { + pass "print (A1)j" + } + -re ".*$gdb_prompt $" { fail "print (A1)j" } + timeout { fail "(timeout) print (A1)j" } +} + +# JV is derived from A1 twice, but A1 is a virtual base; should +# not report ambiguity when a JV is cast to an A1. +send_gdb "print (A1)jv\n" +gdb_expect { + -re "warning: A1 ambiguous.*Use a cast to disambiguate.\r\n\\$\[0-9\]* = \{x = \[-\]*\[0-9\]*, y = \[-\]*\[0-9\]*\}\r\n$gdb_prompt $" { + fail "print (A1)jv (ambiguity reported)" + } + -re "\\$\[0-9\]* = \{x = \[-\]*\[0-9\]*, y = \[-\]*\[0-9\]*\}\r\n$gdb_prompt $" { pass "print (A1)jv" } + -re ".*$gdb_prompt $" { fail "print (A1)jv (??)" } + timeout { fail "(timeout) print (A1)jv" } +} + +# JVA1 is derived from A1; A1 is a virtual base and also a +# non-virtual base. Must report ambiguity if a JVA1 is cast to an A1. +send_gdb "print (A1)jva1\n" +gdb_expect { + -re "warning: A1 ambiguous; using JVA1::A1. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \{x = \[-\]*\[0-9\]*, y = \[-\]*\[0-9\]*\}\r\n$gdb_prompt $" { + pass "print (A1)jva1" + } + -re "warning: A1 ambiguous; using JVA1::KV::A1. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \{x = \[-\]*\[0-9\]*, y = \[-\]*\[0-9\]*\}\r\n$gdb_prompt $" { + pass "print (A1)jva1" + } + -re ".*$gdb_prompt $" { fail "print (A1)jva1" } + timeout { fail "(timeout) print (A1)jva1" } +} + +# JVA1V is derived from A1; A1 is a virtual base indirectly +# and also directly; must not report ambiguity when a JVA1V is cast to an A1. +send_gdb "print (A1)jva1v\n" +gdb_expect { + -re "warning: A1 ambiguous.*Use a cast to disambiguate.\r\n\\$\[0-9\]* = \{x = \[-\]*\[0-9\]*, y = \[-\]*\[0-9\]*\}\r\n$gdb_prompt $" { + fail "print (A1)jva1v (ambiguity reported)" + } + -re "\\$\[0-9\]* = \{x = \[-\]*\[0-9\]*, y = \[-\]*\[0-9\]*\}\r\n$gdb_prompt $" { pass "print (A1)jva1v" + } + -re ".*$gdb_prompt $" { fail "print (A1)jva1v (??)" } + timeout { fail "(timeout) print (A1)jva1v" } +} + diff --git a/gdb/testsuite/gdb.cp/annota2.cc b/gdb/testsuite/gdb.cp/annota2.cc new file mode 100644 index 0000000..234752e --- /dev/null +++ b/gdb/testsuite/gdb.cp/annota2.cc @@ -0,0 +1,28 @@ +#include <stdio.h> + +class A { +public: + int x; + int y; + int foo (int arg); +}; + + +int A::foo (int arg) +{ + x += arg; + return arg *2; +} + +int main() +{ + A a; + + a.x = 0; + a.x = 1; + a.y = 2; + + printf ("a.x is %d\n", a.x); + return 0; +} + diff --git a/gdb/testsuite/gdb.cp/annota2.exp b/gdb/testsuite/gdb.cp/annota2.exp new file mode 100644 index 0000000..0446eb3 --- /dev/null +++ b/gdb/testsuite/gdb.cp/annota2.exp @@ -0,0 +1,234 @@ +# Copyright 1999, 2000, 2001, 2002, 2003 +# 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# This file was written by Elena Zannoni (ezannoni@cygnus.com) + +if $tracelevel then { + strace $tracelevel +} + + +# +# test running programs +# +set prms_id 0 +set bug_id 0 + +if { [skip_cplus_tests] } { continue } + +set testfile "annota2" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++ additional_flags=-w}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +# are we on a target board? If so, don't run these tests. +# note: this is necessary because we cannot use runto_main (which would +# work for remote targets too) because of the different prompt we get +# when using annotation level 2. +# +if [is_remote target] then { + return 0 +} + + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if [target_info exists gdb_stub] { + gdb_step_for_stub; +} + +# +# line number where we need to stop in main +# +set main_line 25 + +# The commands we test here produce many lines of output; disable "press +# <return> to continue" prompts. +send_gdb "set height 0\n" +gdb_expect -re "$gdb_prompt $" + +# +# break at main +# +gdb_test "break 25" \ + "Breakpoint.*at.* file .*$srcfile, line.*" \ + "breakpoint main" + + +# +# NOTE: this prompt is OK only when the annotation level is > 1 +# NOTE: When this prompt is in use the gdb_test procedure cannot be used because +# it assumes that the last char of the gdb_prompt is a white space. This is not +# true with this annotated prompt. So we must use send_gdb and gdb_expect. +# + +set old_gdb_prompt $gdb_prompt +set gdb_prompt "\r\n\032\032pre-prompt\r\n$gdb_prompt \r\n\032\032prompt\r\n" + +send_gdb "set annotate 2\n" +gdb_expect { + -re "set annotate 2\r\n$gdb_prompt$" { pass "annotation set at level 2" } + -re ".*$gdb_prompt$" { fail "annotation set at level 2" } + timeout { fail "annotation set at level 2 (timeout)" } + } + +send_gdb "run\n" + gdb_expect { + -re "$main_line.*$gdb_prompt$" { pass "run until main breakpoint" } + -re ".*$gdb_prompt$" { fail "run until main breakpoint" } + timeout { fail "run until main breakpoint (timeout)" } + } + +# +# print class 'a' with public fields. +# this will test: +# annotate-field-begin +# annotate-field-name-end +# annotate-field-value +# annotate-field-end +# +send_gdb "print a\n" +gdb_expect { + -re "\r\n\032\032post-prompt\r\n\r\n\032\032value-history-begin 1 -\r\n.*= \r\n\032\032value-history-value\r\n\\{\r\n\032\032field-begin -\r\nx\r\n\032\032field-name-end\r\n = \r\n\032\032field-value\r\n1\r\n\032\032field-end\r\n, \r\n\032\032field-begin -\r\ny\r\n\032\032field-name-end\r\n = \r\n\032\032field-value\r\n2\r\n\032\032field-end\r\n\\}\r\n\r\n\032\032value-history-end\r\n$gdb_prompt$" \ + { pass "print class" } + -re ".*$gdb_prompt$" { fail "print class" } + timeout { fail "print class (timeout)" } +} + +# +# continue until exit +# this will test: +# annotate-exited +# +send_gdb "continue\n" +gdb_expect { + -re "\r\n\032\032post-prompt\r\nContinuing.\r\n\r\n\032\032starting\r\n\r\n\032\032frames-invalid\r\na.x is 1\r\n\r\n\032\032frames-invalid\r\n\r\n\032\032exited 0\r\n\r\nProgram exited normally.\r\n\r\n\032\032frames-invalid\r\n\r\n\032\032stopped\r\n$gdb_prompt$" \ + { pass "continue until exit" } + -re ".*$gdb_prompt$" { fail "continue to exit" } + timeout { fail "continue to exit (timeout)" } +} + +# +# delete all breakpoints +# +send_gdb "delete\n" +gdb_expect { + -re ".*Delete all breakpoints. \\(y or n\\) \r\n\032\032query.*$" { + send_gdb "y\n" + gdb_expect { + -re "\r\n\032\032post-query\r\n$gdb_prompt$" { pass "delete bps" } + -re ".*$gdb_prompt$" { fail "delete bps" } + timeout { fail "delete bps (timeout)" } + } + } + -re ".*$gdb_prompt$" { fail "delete bps" } + timeout { fail "delete bps (timeout)" } +} + +# +# break at first line of main. +# +send_gdb "break 22\n" +gdb_expect { + -re "\r\n\032\032post-prompt\r\n\r\n\032\032breakpoints-invalid\r\nBreakpoint.*at $hex: file.*$srcfile, line.*\r\n$gdb_prompt$" \ + { pass "breakpoint at main" } + -re ".*$gdb_prompt$" { fail "break at main" } + timeout { fail "break at main (timeout)" } +} + +# +# change value of main_line +# +set main_line 22 + +# +# run program up to breakpoint. +# + + +send_gdb "run\n" + gdb_expect { + -re "$main_line.*$gdb_prompt$" { pass "run until main breakpoint" } + -re ".*$gdb_prompt$" { fail "run until main breakpoint" } + timeout { fail "run until main breakpoint (timeout)" } + } + +# +# set up a watch point on a.x +# +send_gdb "watch a.x\n" +gdb_expect { + -re "\r\n\032\032post-prompt\r\n\r\n\032\032breakpoints-invalid\r\n.*atchpoint 3: a.x\r\n$gdb_prompt$" \ + { pass "set watch on a.x" } + -re ".*$gdb_prompt$" { fail "set watch on a.x" } + timeout { fail "set watch on a.x (timeout)" } +} + +# +# do a next, so that the watchpoint triggers. This will test: +# annotate-watchpoint +# +send_gdb "next\n" +gdb_expect { + -re "\r\n\032\032post-prompt\r\n\r\n\032\032starting\r\n\r\n\032\032frames-invalid\r\n\r\n\032\032frames-invalid\r\n\r\n\032\032frames-invalid\r\n\r\n\032\032watchpoint 3\r\nWatchpoint 3: a.x\r\n\r\nOld value = 0\r\nNew value = 1\r\n\r\n\032\032frame-begin 0 $hex\r\n\r\n\032\032frame-function-name\r\nmain\r\n\032\032frame-args\r\n \\(\\)\r\n\032\032frame-source-begin\r\n at \r\n\032\032frame-source-file\r\n.*$srcfile\r\n\032\032frame-source-file-end\r\n:\r\n\032\032frame-source-line\r\n$decimal\r\n\032\032frame-source-end\r\n\r\n\r\n\032\032source .*$srcfile.*beg:$hex\r\n\r\n\032\032frame-end\r\n\r\n\032\032stopped\r\n$gdb_prompt$" \ + { pass "watch triggered on a.x" } + -re "\r\n\032\032post-prompt\r\n\r\n\032\032starting\r\n\r\n\032\032frames-invalid\r\n\r\n\032\032frames-invalid\r\n\r\n\032\032frames-invalid\r\n\r\n\032\032frames-invalid\r\n\r\n\032\032watchpoint 3\r\n\.*atchpoint 3: a.x\r\n\r\nOld value = 0\r\nNew value = 1\r\n\r\n\032\032frame-begin 0 $hex\r\n\r\n\032\032frame-function-name\r\nmain\r\n\032\032frame-args\r\n \\(\\)\r\n\032\032frame-source-begin\r\n at \r\n\032\032frame-source-file\r\n.*$srcfile\r\n\032\032frame-source-file-end\r\n:\r\n\032\032frame-source-line\r\n$decimal\r\n\032\032frame-source-end\r\n\r\n\r\n\032\032source .*$srcfile.*beg:$hex\r\n\r\n\032\032frame-end\r\n\r\n\032\032stopped\r\n.*$gdb_prompt$" \ + { pass "watch triggered on a.x" } + -re "\r\n\032\032post-prompt\r\n\r\n\032\032starting\r\n\r\n\032\032frames-invalid\r\n\r\n\032\032source .*$srcfile.*beg:$hex\r\n\r\n\032\032frame-end\r\n\r\n\032\032stopped\r\n$gdb_prompt$" \ + { kfail "gdb/38" "watch triggered on a.x" } + -re ".*$gdb_prompt$" { fail "watch triggered on a.x" } + timeout { fail "watch triggered on a.x (timeout)" } +} + + +# +# send ^C to gdb, so that the quit() function gets called +# and annotate-quit is tested +# test: +# annotate-quit +# +# This test sometimes fails, but not reproducibly. See gdb/544. +# +send_gdb "\003" +gdb_expect { + -re "\r\n\032\032error-begin\r\nQuit\r\n\r\n\032\032quit\r\n$gdb_prompt$" \ + { pass "annotate-quit" } + -re "$gdb_prompt$" { kfail "gdb/544" "annotate-quit" } + -re ".*$gdb_prompt$" { fail "annotate-quit" } + timeout { fail "annotate-quit (timeout)" } +} + +# +# FIXME: the testsuite does not currently have tests for +# annotate_catchpoints and annotate_function_call +# and a few variants of the annotations that are +# tested (marked by FIXME on the annot?.exp files) +# + +# reinstall the old prompt for the rest of the testsuite. + +set gdb_prompt $old_gdb_prompt + diff --git a/gdb/testsuite/gdb.cp/annota3.cc b/gdb/testsuite/gdb.cp/annota3.cc new file mode 100644 index 0000000..234752e --- /dev/null +++ b/gdb/testsuite/gdb.cp/annota3.cc @@ -0,0 +1,28 @@ +#include <stdio.h> + +class A { +public: + int x; + int y; + int foo (int arg); +}; + + +int A::foo (int arg) +{ + x += arg; + return arg *2; +} + +int main() +{ + A a; + + a.x = 0; + a.x = 1; + a.y = 2; + + printf ("a.x is %d\n", a.x); + return 0; +} + diff --git a/gdb/testsuite/gdb.cp/annota3.exp b/gdb/testsuite/gdb.cp/annota3.exp new file mode 100644 index 0000000..431ed4f --- /dev/null +++ b/gdb/testsuite/gdb.cp/annota3.exp @@ -0,0 +1,238 @@ +# Copyright 2003 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# This file was written by Elena Zannoni (ezannoni@cygnus.com) + +if $tracelevel then { + strace $tracelevel +} + + +# +# test running programs +# +set prms_id 0 +set bug_id 0 + +if { [skip_cplus_tests] } { continue } + +set testfile "annota3" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++ additional_flags=-w}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +# are we on a target board? If so, don't run these tests. +# note: this is necessary because we cannot use runto_main (which would +# work for remote targets too) because of the different prompt we get +# when using annotation level 2. +# +if [is_remote target] then { + return 0 +} + + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if [target_info exists gdb_stub] { + gdb_step_for_stub; +} + +# +# line number where we need to stop in main +# +set main_line 25 + +# The commands we test here produce many lines of output; disable "press +# <return> to continue" prompts. +send_gdb "set height 0\n" +gdb_expect -re "$gdb_prompt $" + +# +# break at main +# +gdb_test "break 25" \ + "Breakpoint.*at.* file .*$srcfile, line.*" \ + "breakpoint main" + + +# +# NOTE: this prompt is OK only when the annotation level is > 1 +# NOTE: When this prompt is in use the gdb_test procedure cannot be used because +# it assumes that the last char of the gdb_prompt is a white space. This is not +# true with this annotated prompt. So we must use send_gdb and gdb_expect. +# + +set old_gdb_prompt $gdb_prompt +set gdb_prompt "\r\n\032\032pre-prompt\r\n$gdb_prompt \r\n\032\032prompt\r\n" + +send_gdb "set annotate 3\n" +gdb_expect_list "annotation set at level 3" "\r\n$gdb_prompt$" { + "set annotate 3" +} + +send_gdb "run\n" +gdb_expect_list "first run until main breakpoint" "$gdb_prompt$" { + "\r\n\032\032post-prompt\r\n" + "Starting program: .*annota3 \r\n" + "\(\r\n\032\032\(frames-invalid|breakpoints-invalid\)\r\n\)+" + "\r\n\032\032starting\r\n" + "\(\r\n\032\032\(frames-invalid|breakpoints-invalid\)\r\n\)+" + "\r\n\032\032breakpoint 1\r\n" + "\r\n" + "Breakpoint 1, main \\(\\) at .*annota3.cc:25\r\n" + "\r\n\032\032source.*annota3.cc:25:.*:beg:0x\[0-9a-z\]+\r\n" + "\r\n\032\032stopped\r\n" +} + +# +# print class 'a' with public fields. +# +send_gdb "print a\n" +gdb_expect_list "print class" "$gdb_prompt$" { + "\r\n\032\032post-prompt\r\n" + ".*= \\{x = 1, y = 2\\}\r\n" +} + +# +# continue until exit +# this will test: +# annotate-exited +# +send_gdb "continue\n" +gdb_expect_list "continue to exit" "$gdb_prompt$" { + "\r\n\032\032post-prompt\r\n" + "Continuing.\r\n" + "\r\n\032\032starting\r\n" + "\r\n\032\032frames-invalid\r\n" + "a.x is 1\r\n" + "\r\n\032\032frames-invalid\r\n" + "\r\n\032\032exited 0\r\n" + "\r\n" + "Program exited normally.\r\n" + "\r\n\032\032frames-invalid\r\n" + "\r\n\032\032stopped\r\n" +} + +# +# delete all breakpoints +# +send_gdb "delete\n" +gdb_expect { + -re ".*Delete all breakpoints. \\(y or n\\) \r\n\032\032query.*$" { + send_gdb "y\n" + gdb_expect { + -re "\r\n\032\032post-query\r\n$gdb_prompt$" { pass "delete bps" } + -re ".*$gdb_prompt$" { fail "delete bps" } + timeout { fail "delete bps (timeout)" } + } + } + -re ".*$gdb_prompt$" { fail "delete bps" } + timeout { fail "delete bps (timeout)" } +} + +# +# break at first line of main. +# +send_gdb "break 22\n" +gdb_expect_list "break at main" "$gdb_prompt$" { + "\r\n\032\032post-prompt\r\n" + "\r\n\032\032breakpoints-invalid\r\n" + "Breakpoint.*at 0x\[a-z0-9\]+: file.*annota3.cc, line 22.\r\n" +} + +# +# run program up to breakpoint. +# + + +send_gdb "run\n" +gdb_expect_list "second run until main breakpoint" "$gdb_prompt$" { + "\r\n\032\032post-prompt\r\n" + "\(\r\n\032\032\(frames-invalid|breakpoints-invalid\)\r\n\)+" + "\r\n\032\032starting\r\n" + "\(\r\n\032\032\(frames-invalid|breakpoints-invalid\)\r\n\)+" + "\r\n\032\032breakpoint 2\r\n" + "\r\n" + "Breakpoint 2, main \\(\\) at .*annota3.cc:22\r\n" + "\r\n\032\032source.*annota3.cc:22:.*:beg:0x\[0-9a-z\]+\r\n" + "\r\n\032\032stopped\r\n" +} + +# +# set up a watch point on a.x +# +send_gdb "watch a.x\n" +gdb_expect_list "set watch on a.x" "$gdb_prompt$" { + "\r\n\032\032post-prompt\r\n" + "\r\n\032\032breakpoints-invalid\r\n" + ".*atchpoint 3: a.x\r\n" \ +} + +# +# do a next, so that the watchpoint triggers. This will test: +# annotate-watchpoint +# +send_gdb "next\n" +gdb_expect { + -re "\r\n\032\032post-prompt\r\n\r\n\032\032starting\r\n\(\r\n\032\032frames-invalid\r\n\)+\r\n\032\032watchpoint 3\r\nWatchpoint 3: a.x\r\n\r\nOld value = 0\r\nNew value = 1\r\nmain \\(\\) at .*$srcfile:$decimal\r\n\r\n\032\032source .*$srcfile.*beg:$hex\r\n\r\n\032\032stopped\r\n.*$gdb_prompt$" { + pass "watch triggered on a.x" + } + -re "\r\n\032\032post-prompt\r\n\r\n\032\032starting\r\n\r\n\032\032frames-invalid\r\n\r\n\032\032source .*$srcfile.*beg:$hex\r\n\r\n\032\032stopped\r\n$gdb_prompt$" { + kfail "gdb/38" "watch triggered on a.x" + } + -re ".*$gdb_prompt$" { + fail "watch triggered on a.x" + } + timeout { + fail "watch triggered on a.x (timeout)" + } +} + +# +# send ^C to gdb, so that the quit() function gets called +# and annotate-quit is tested +# test: +# annotate-quit +# +# This test sometimes fails, but not reproducibly. See gdb/544. +# +send_gdb "\003" +gdb_expect_list "annotate-quit" "$gdb_prompt$" { + "\r\n\032\032error-begin\r\n" + "Quit\r\n" + "\r\n\032\032quit\r\n" +} + +# +# FIXME: the testsuite does not currently have tests for +# annotate_catchpoints and annotate_function_call +# and a few variants of the annotations that are +# tested (marked by FIXME on the annot?.exp files) +# + +# reinstall the old prompt for the rest of the testsuite. + +set gdb_prompt $old_gdb_prompt + diff --git a/gdb/testsuite/gdb.cp/anon-union.cc b/gdb/testsuite/gdb.cp/anon-union.cc new file mode 100644 index 0000000..0b3fd13 --- /dev/null +++ b/gdb/testsuite/gdb.cp/anon-union.cc @@ -0,0 +1,55 @@ + +struct Foo { + union { + int zero; + unsigned int one; + } num1; + struct X { + int rock; + unsigned int rock2; + }; + union { + int pebble; + X x; + union { + int qux; + unsigned int mux; + }; + unsigned int boulder; + }; + union { + int paper; + unsigned int cloth; + }; + union { + int two; + unsigned int three; + } num2; +}; + +union Bar { + int x; + unsigned int y; +}; + + +int main() +{ + Foo foo = {0, 0}; + + foo.paper = 33; + foo.pebble = 44; + foo.mux = 55; + + Bar bar = {0}; + + union { + int z; + unsigned int w; + }; w = 0; + + bar.x = 33; + + w = 45; + +} diff --git a/gdb/testsuite/gdb.cp/anon-union.exp b/gdb/testsuite/gdb.cp/anon-union.exp new file mode 100644 index 0000000..0d5c777 --- /dev/null +++ b/gdb/testsuite/gdb.cp/anon-union.exp @@ -0,0 +1,348 @@ +# Tests for anonymous union support. +# Copyright 1998, 1999, 2003 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# Written by Satish Pai <pai@apollo.hp.com> 1997-08-19 + +# This file is part of the gdb testsuite + +if $tracelevel then { + strace $tracelevel + } + +# +# test running programs +# + +set prms_id 0 +set bug_id 0 + +if { [skip_cplus_tests] } { continue } + +set testfile "anon-union" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + perror "Testcase compile failed" 0 + continue +} + +# Start with a fresh gdb +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + + +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + +send_gdb "set width 0\n" +gdb_expect -re "$gdb_prompt $" + +#send_gdb "ptype foo\n" +#gdb_expect { +# -re "\r\n$gdb_prompt $" { +# pass "ptype foo" +# } +# -re ".*$gdb_prompt $" { fail "ptype foo" } +# timeout { fail "(timeout) ptype foo" } +#} + +#send_gdb "ptype bar\n" +#gdb_expect { +# -re "\r\n$gdb_prompt $" { +# pass "ptype foo" +# } +# -re ".*$gdb_prompt $" { fail "ptype foo" } +# timeout { fail "(timeout) ptype foo" } +#} + +# NOTE: Add -- ptype foo.x, etc. when things are working + +#Initialize foo +send_gdb "next\n" +gdb_expect { + -re "40\[ \t\]*foo.paper = 33;\r\n$gdb_prompt $" { + pass "next 1" + } + -re ".*$gdb_prompt $" { fail "next 1" } + timeout { fail "(timeout) next 1" } +} + +# Print out the big anon union. +send_gdb "print foo\n" +gdb_expect { + -re "\\$\[0-9\]* = \{num1 = \{zero = 0, one = 0\}, \{pebble = 0, x = \{rock = 0, rock2 = 0\}, \{qux = 0, mux = 0\}, boulder = 0\}, \{paper = 0, cloth = 0\}, num2 = \{two = 0, three = 0\}\}\r\n$gdb_prompt $" { + pass "print foo 1" + } + -re ".*$gdb_prompt $" { fail "print foo 1" } + timeout { fail "(timeout) print foo 1" } +} + +# Step over assignment to member + +send_gdb "next\n" +gdb_expect { + -re "41\[ \t\]*foo.pebble = 44;\r\n$gdb_prompt $" { + pass "next 1" + } + -re ".*$gdb_prompt $" { fail "next 1" } + timeout { fail "(timeout) next 1" } +} + +# Now print out anon union again +send_gdb "print foo\n" +gdb_expect { + -re "\\$\[0-9\]* = \{num1 = \{zero = 0, one = 0\}, \{pebble = 0, x = \{rock = 0, rock2 = 0\}, \{qux = 0, mux = 0\}, boulder = 0\}, \{paper = 33, cloth = 33\}, num2 = \{two = 0, three = 0\}\}\r\n$gdb_prompt $" { + pass "print foo 2" + } + -re ".*$gdb_prompt $" { fail "print foo 2" } + timeout { fail "(timeout) print foo 2" } +} + +# Modify the member just set +send_gdb "set var foo.cloth = 35\n" +gdb_expect { + -re "\r\n$gdb_prompt $" { + pass "set var foo.cloth" + } + timeout { fail "(timeout) set var foo.cloth" } +} + +# Now print out anon union again to see if the right member was set +send_gdb "print foo\n" +gdb_expect { + -re "\\$\[0-9\]* = \{num1 = \{zero = 0, one = 0\}, \{pebble = 0, x = \{rock = 0, rock2 = 0\}, \{qux = 0, mux = 0\}, boulder = 0\}, \{paper = 35, cloth = 35\}, num2 = \{two = 0, three = 0\}\}\r\n$gdb_prompt $" { + pass "print foo 3" + } + -re ".*$gdb_prompt $" { fail "print foo 3" } + timeout { fail "(timeout) print foo 3" } +} + + +# Step over next assignment to member + +send_gdb "next\n" +gdb_expect { + -re "42\[ \t\]*foo.mux = 55;\r\n$gdb_prompt $" { + pass "next 2" + } + -re ".*$gdb_prompt $" { fail "next 2" } + timeout { fail "(timeout) next 2" } +} + +# Now print out anon union again +send_gdb "print foo\n" +gdb_expect { + -re "\\$\[0-9\]* = \{num1 = \{zero = 0, one = 0\}, \{pebble = 44, x = \{rock = 44, rock2 = 0\}, \{qux = 44, mux = 44\}, boulder = 44\}, \{paper = 35, cloth = 35\}, num2 = \{two = 0, three = 0\}\}\r\n$gdb_prompt $" { + pass "print foo 4" + } + -re ".*$gdb_prompt $" { fail "print foo 4" } + timeout { fail "(timeout) print foo 4" } +} + +# Modify the member just set +send_gdb "set var foo.pebble = 45\n" +gdb_expect { + -re "\r\n$gdb_prompt $" { + pass "set var foo.pebble" + } + timeout { fail "(timeout) set var foo.pebble" } +} + +# Now print out anon union again to see if the right member was set +send_gdb "print foo\n" +gdb_expect { + -re "\\$\[0-9\]* = \{num1 = \{zero = 0, one = 0\}, \{pebble = 45, x = \{rock = 45, rock2 = 0\}, \{qux = 45, mux = 45\}, boulder = 45\}, \{paper = 35, cloth = 35\}, num2 = \{two = 0, three = 0\}\}\r\n$gdb_prompt $" { + pass "print foo 5" + } + -re ".*$gdb_prompt $" { fail "print foo 5" } + timeout { fail "(timeout) print foo 5" } +} + +# Modify another member at a different level +send_gdb "set var foo.qux = 46\n" +gdb_expect { + -re "\r\n$gdb_prompt $" { + pass "set var foo.qux" + } + timeout { fail "(timeout) set var foo.qux" } +} + +# Now print out anon union again to see if the right member was set +send_gdb "print foo\n" +gdb_expect { + -re "\\$\[0-9\]* = \{num1 = \{zero = 0, one = 0\}, \{pebble = 46, x = \{rock = 46, rock2 = 0\}, \{qux = 46, mux = 46\}, boulder = 46\}, \{paper = 35, cloth = 35\}, num2 = \{two = 0, three = 0\}\}\r\n$gdb_prompt $" { + pass "print foo 6" + } + -re ".*$gdb_prompt $" { fail "print foo 6" } + timeout { fail "(timeout) print foo 6" } +} + +# Modify the member at another level, but not the first one in the union +send_gdb "set var foo.mux = 47\n" +gdb_expect { + -re "\r\n$gdb_prompt $" { + pass "set var foo.mux" + } + timeout { fail "(timeout) set var foo.mux" } +} + +# Now print out anon union again to see if things worked +send_gdb "print foo\n" +gdb_expect { + -re "\\$\[0-9\]* = \{num1 = \{zero = 0, one = 0\}, \{pebble = 47, x = \{rock = 47, rock2 = 0\}, \{qux = 47, mux = 47\}, boulder = 47\}, \{paper = 35, cloth = 35\}, num2 = \{two = 0, three = 0\}\}\r\n$gdb_prompt $" { + pass "print foo 7" + } + -re ".*$gdb_prompt $" { fail "print foo 7" } + timeout { fail "(timeout) print foo 7" } +} + +# Modify a member of a struct in an anon union +send_gdb "set var foo.x.rock = 48\n" +gdb_expect { + -re "\r\n$gdb_prompt $" { + pass "set var foo.x.rock" + } + timeout { fail "(timeout) set var foo.x.rock" } +} + +# Now print out anon union again to see if things worked +send_gdb "print foo\n" +gdb_expect { + -re "\\$\[0-9\]* = \{num1 = \{zero = 0, one = 0\}, \{pebble = 48, x = \{rock = 48, rock2 = 0\}, \{qux = 48, mux = 48\}, boulder = 48\}, \{paper = 35, cloth = 35\}, num2 = \{two = 0, three = 0\}\}\r\n$gdb_prompt $" { + pass "print foo 8" + } + -re ".*$gdb_prompt $" { fail "print foo 8" } + timeout { fail "(timeout) print foo 8" } +} + +# Modify a member of a struct in an anon union, but something +# that doesn't alias to some other union member +send_gdb "set var foo.x.rock2 = 49\n" +gdb_expect { + -re "\r\n$gdb_prompt $" { + pass "set var foo.x.rock2" + } + timeout { fail "(timeout) set var foo.x.rock2" } +} + +# Now print out anon union again to see if things worked +send_gdb "print foo\n" +gdb_expect { + -re "\\$\[0-9\]* = \{num1 = \{zero = 0, one = 0\}, \{pebble = 48, x = \{rock = 48, rock2 = 49\}, \{qux = 48, mux = 48\}, boulder = 48\}, \{paper = 35, cloth = 35\}, num2 = \{two = 0, three = 0\}\}\r\n$gdb_prompt $" { + pass "print foo 9" + } + -re ".*$gdb_prompt $" { fail "print foo 9" } + timeout { fail "(timeout) print foo 9" } +} + + +# Step over next four assignments +send_gdb "next 4\n" +gdb_expect { + -re "53\[ \t\]*w = 45;\r\n$gdb_prompt $" { + pass "next 3" + } + -re ".*$gdb_prompt $" { fail "next 3" } + timeout { fail "(timeout) next 3" } +} + +# Tests for anon unions that are not members of a class or struct + +send_gdb "print w\n" +gdb_expect { + -re "\\$\[0-9\]* = 0\r\n$gdb_prompt $" { + pass "print w 1" + } + -re ".*$gdb_prompt $" { fail "print w 1" } + timeout { fail "(timeout) print w 1" } +} + +send_gdb "print z\n" +gdb_expect { + -re "\\$\[0-9\]* = 0\r\n$gdb_prompt $" { + pass "print z 1" + } + -re ".*$gdb_prompt $" { fail "print z 1" } + timeout { fail "(timeout) print z 1" } +} + +# Step over next assignment to w +send_gdb "next\n" +gdb_expect { + -re "55\[ \t\]*\}\r\n$gdb_prompt $" { + pass "next 4" + } + -re ".*$gdb_prompt $" { fail "next 4" } + timeout { fail "(timeout) next 4" } +} + +# See if the change in value is noticed +send_gdb "print w\n" +gdb_expect { + -re "\\$\[0-9\]* = 45\r\n$gdb_prompt $" { + pass "print w 2" + } + -re ".*$gdb_prompt $" { fail "print w 2" } + timeout { fail "(timeout) print w 2" } +} + +# See if z shows the same value +send_gdb "print z\n" +gdb_expect { + -re "\\$\[0-9\]* = 45\r\n$gdb_prompt $" { + pass "print z 2" + } + -re ".*$gdb_prompt $" { fail "print z 2" } + timeout { fail "(timeout) print z 2" } +} + +# Set the anon union member +send_gdb "set var z = 27\n" +gdb_expect { + -re "\r\n$gdb_prompt $" { + pass "set var z" + } + timeout { fail "(timeout) set var z" } +} + +# See if the change in value is noticed +send_gdb "print w\n" +gdb_expect { + -re "\\$\[0-9\]* = 27\r\n$gdb_prompt $" { + pass "print w 3" + } + -re ".*$gdb_prompt $" { fail "print w 3" } + timeout { fail "(timeout) print w 3" } +} + +# See if z shows the same value +send_gdb "print z\n" +gdb_expect { + -re "\\$\[0-9\]* = 27\r\n$gdb_prompt $" { + pass "print z 3" + } + -re ".*$gdb_prompt $" { fail "print z 3" } + timeout { fail "(timeout) print z 3" } +} diff --git a/gdb/testsuite/gdb.cp/casts.cc b/gdb/testsuite/gdb.cp/casts.cc new file mode 100644 index 0000000..831add9 --- /dev/null +++ b/gdb/testsuite/gdb.cp/casts.cc @@ -0,0 +1,20 @@ +struct A +{ + int a; + A (int aa): a (aa) {} +}; + +struct B: public A +{ + int b; + B (int aa, int bb): A (aa), b(bb) {} +}; + +int +main (int argc, char **argv) +{ + A *a = new B(42, 1729); + B *b = (B *) a; + + return 0; /* breakpoint spot: casts.exp: 1 */ +} diff --git a/gdb/testsuite/gdb.cp/casts.exp b/gdb/testsuite/gdb.cp/casts.exp new file mode 100644 index 0000000..5b6cabe --- /dev/null +++ b/gdb/testsuite/gdb.cp/casts.exp @@ -0,0 +1,85 @@ +# Copyright 2002, 2003 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# This file is part of the gdb testsuite + +# Test casting, especially between class types or pointer-to-class +# types. + +# This file is part of the gdb testsuite + +if $tracelevel then { + strace $tracelevel + } + +# +# test running programs +# + +set prms_id 0 +set bug_id 0 + +if { [skip_cplus_tests] } { continue } + +set testfile "casts" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if [get_compiler_info ${binfile} "c++"] { + return -1; +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + +gdb_test "break [gdb_get_line_number "casts.exp: 1"]" \ + "Breakpoint.*at.* file .*" \ + "" + +gdb_test "continue" "Breakpoint .* at .*casts.cc.*" "" + +# Casting a pointer to a base class to a pointer to a derived class +# should yield the entire derived class. Until August 2002, GDB got +# the enclosing type on `(B *) a' wrong: while the value's static type +# was `B *', as it should be, the enclosing type (which is supposed to +# be the dynamic type) was `A *'. It's senseless to have a static +# type derived from the dynamic type; it should be the other way +# 'round. Dereferencing this oddly typed pointer yielded a value in +# which only the base class's members were initialized, since GDB uses +# the enclosing type to decide how many bytes to read. Members from +# the derived class were garbage, from GDB's address space. +gdb_test "print * (B *) a" ".* = {<A> = {a = 42}, b = 1729}" \ + "cast base class pointer to derived class pointer" + +# Check also that we get the same results from letting the compiler do +# the dereference. +gdb_test "print * b" ".* = {<A> = {a = 42}, b = 1729}" \ + "let compiler cast base class pointer to derived class pointer" diff --git a/gdb/testsuite/gdb.cp/classes.exp b/gdb/testsuite/gdb.cp/classes.exp new file mode 100644 index 0000000..3f398ac --- /dev/null +++ b/gdb/testsuite/gdb.cp/classes.exp @@ -0,0 +1,918 @@ +# Copyright 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# This file was written by Fred Fish. (fnf@cygnus.com) + +set ws "\[\r\n\t \]+" +set nl "\[\r\n\]+" + +if $tracelevel then { + strace $tracelevel +} + +if { [skip_cplus_tests] } { continue } + +set testfile "misc" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +# Create and source the file that provides information about the compiler +# used to compile the test case. + +if [get_compiler_info ${binfile} "c++"] { + return -1 +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +# +# Test ptype of class objects. +# + +proc test_ptype_class_objects {} { + global gdb_prompt + global ws + global nl + + # Note that struct members are public by default, so we don't print + # "public:" for the public members of structs. + # Accept it if gdb just fails to distinguish between + # class and struct, and everything else is OK. + + send_gdb "ptype struct default_public_struct\n" + gdb_expect { + -re "type = struct default_public_struct \{${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" { + pass "ptype struct default_public_struct" + } + -re "type = class default_public_struct \{$nl.*int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" { + pass "ptype struct default_public_struct" + } + -re ".*$gdb_prompt $" { fail "ptype struct default_public_struct" } + timeout { fail "ptype struct default_public_struct (timeout)" ; return } + } + + # Note that struct members are public by default, so we don't print + # "public:" for the public members of structs. + # Accept it if gdb just fails to distinguish between + # class and struct, and everything else is OK. + + send_gdb "ptype struct explicit_public_struct\n" + gdb_expect { + -re "type = struct explicit_public_struct \{${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" { + pass "ptype struct explicit_public_struct" + } + -re "type = class explicit_public_struct \{$nl.*int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" { + pass "ptype struct explicit_public_struct" + } + -re ".*$gdb_prompt $" { fail "ptype struct explicit_public_struct" } + timeout { fail "ptype struct explicit_public_struct (timeout)" ; return } + } + + # Accept it if gdb just fails to distinguish between + # class and struct, and everything else is OK. + + send_gdb "ptype struct protected_struct\n" + gdb_expect { + -re "type = struct protected_struct \{${ws}protected:${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" { + pass "ptype struct protected_struct" + } + -re "type = class protected_struct \{${ws}protected:${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" { + pass "ptype struct protected_struct" + } + -re ".*$gdb_prompt $" { fail "ptype struct protected_struct" } + timeout { fail "ptype struct protected_struct (timeout)" ; return } + } + + # Accept it if gdb just fails to distinguish between + # class and struct, and everything else is OK. + + send_gdb "ptype struct private_struct\n" + gdb_expect { + -re "type = struct private_struct \{${ws}private:${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" { + pass "ptype struct private_struct" + } + -re "type = class private_struct \{${ws}private:${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" { + pass "ptype struct private_struct" + } + -re ".*$gdb_prompt $" { fail "ptype struct private_struct" } + timeout { fail "ptype struct private_struct (timeout)" ; return } + } + + # Accept it if gdb just fails to distinguish between + # class and struct, and everything else is OK. + + send_gdb "ptype struct mixed_protection_struct\n" + gdb_expect { + -re "type = struct mixed_protection_struct \{${ws}int a;${ws}int b;${ws}private:${ws}int c;${ws}int d;${ws}protected:${ws}int e;${ws}int f;${ws}public:${ws}int g;${ws}private:${ws}int h;${ws}protected:${ws}int i;$nl\}$nl$gdb_prompt $" { + pass "ptype struct mixed_protection_struct" + } + -re "type = struct mixed_protection_struct \{${ws}public:${ws}int a;${ws}int b;${ws}private:${ws}int c;${ws}int d;${ws}protected:${ws}int e;${ws}int f;${ws}public:${ws}int g;${ws}private:${ws}int h;${ws}protected:${ws}int i;$nl.*\}$nl$gdb_prompt $" { + pass "ptype struct mixed_protection_struct (extra public)" + } + -re "type = class mixed_protection_struct \{${ws}public:${ws}int a;${ws}int b;${ws}private:${ws}int c;${ws}int d;${ws}protected:${ws}int e;${ws}int f;${ws}public:${ws}int g;${ws}private:${ws}int h;${ws}protected:${ws}int i;$nl.*\}$nl$gdb_prompt $" { + pass "ptype struct mixed_protection_struct" + } + -re ".*$gdb_prompt $" { fail "ptype struct mixed_protection_struct" } + timeout { fail "ptype struct mixed_protection_struct (timeout)" ; return } + } + + # Accept it if gdb just fails to distinguish between + # class and struct, and everything else is OK. + + send_gdb "ptype class public_class\n" + gdb_expect { + -re "type = class public_class \{${ws}public:${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" { + pass "ptype class public_class" + } + -re "type = struct public_class \{${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" { + pass "ptype class public_class" + } + -re ".*$gdb_prompt $" { fail "ptype class public_class" } + timeout { fail "ptype class public_class (timeout)" ; return } + } + + send_gdb "ptype class protected_class\n" + gdb_expect { + -re "type = class protected_class \{${ws}protected:${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" { + pass "ptype class protected_class" + } + -re "type = struct protected_class \{${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" { + fail "ptype class protected_class" + } + -re ".*$gdb_prompt $" { fail "ptype class protected_class" } + timeout { fail "ptype class protected_class (timeout)" ; return } + } + + # Accept it if gdb just emits a superflous "private:" + # attribute, since classes default to private and for consistency with + # structs (where we don't print the "public:" attribute) we don't print + # the "private:" attribute. + + send_gdb "ptype class default_private_class\n" + gdb_expect { + -re "type = class default_private_class \{${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" { + pass "ptype class default_private_class" + } + -re "type = class default_private_class \{${ws}private:${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" { + pass "ptype class default_private_class" + } + -re ".*$gdb_prompt $" { fail "ptype class default_private_class" } + timeout { fail "ptype class default_private_class (timeout)" ; return } + } + + send_gdb "ptype class explicit_private_class\n" + gdb_expect { + -re "type = class explicit_private_class \{${ws}private:${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" { + pass "ptype class explicit_private_class" + } + -re "type = class explicit_private_class \{${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" { + pass "ptype class explicit_private_class" + } + -re "type = struct explicit_private_class \{${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" { + fail "ptype class explicit_private_class" + } + -re ".*$gdb_prompt $" { fail "ptype class explicit_private_class" } + timeout { fail "ptype class explicit_private_class (timeout)" ; return } + } + + send_gdb "ptype class mixed_protection_class\n" + gdb_expect { + -re "type = class mixed_protection_class \{${ws}public:${ws}int a;${ws}int b;${ws}private:${ws}int c;${ws}int d;${ws}protected:${ws}int e;${ws}int f;${ws}public:${ws}int g;${ws}private:${ws}int h;${ws}protected:${ws}int i;$nl.*\}$nl$gdb_prompt $" { + pass "ptype class mixed_protection_class" + } + -re "type = struct mixed_protection_class \{${ws}int a;${ws}int b;${ws}int c;${ws}int d;${ws}int e;${ws}int f;${ws}int g;${ws}int h;${ws}int i;$nl.*\}$nl$gdb_prompt $" { + fail "ptype class mixed_protection_class" + } + -re ".*$gdb_prompt $" { fail "ptype class mixed_protection_class" } + timeout { fail "ptype class mixed_protection_class (timeout)" ; return } + } + + # This class does not use any C++-specific features, so it's fine for + # it to print as "struct". + send_gdb "ptype class A\n" + gdb_expect { + -re "type = (class|struct) A \{(${ws}public:|)${ws}int a;${ws}int x;((${ws}A & operator=\\(A const ?&\\);)|(${ws}A\\((A const|const A) ?&\\);)|(${ws}A\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" { + pass "ptype class A" + } + -re ".*$gdb_prompt $" { + fail "ptype class A" + } + timeout { + fail "ptype class A (timeout)" + return + } + } + + send_gdb "ptype class B\n" + gdb_expect { + -re "type = class B : public A \{${ws}public:${ws}int b;${ws}int x;${ws}B & operator=\\(B const ?&\\);${ws}B\\((B const|const B) ?&\\);${ws}B\\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype class B" + } + -re "type = class B : public A \{${ws}public:${ws}int b;${ws}int x;((${ws}B & operator=\\(B const ?&\\);)|(${ws}B\\(B const ?&\\);)|(${ws}B\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" { + pass "ptype class B (obsolescent gcc or gdb)" + } + -re ".*$gdb_prompt $" { + fail "ptype class B" + } + timeout { + fail "ptype class B (timeout)" + return + } + } + + send_gdb "ptype class C\n" + gdb_expect { + -re "type = class C : public A \{${ws}public:${ws}int c;${ws}int x;${ws}C & operator=\\(C const ?&\\);${ws}C\\((C const|const C) ?&\\);${ws}C\\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype class C" + } + -re "type = class C : public A \{${ws}public:${ws}int c;${ws}int x;((${ws}C & operator=\\(C const ?&\\);)|(${ws}C\\(C const ?&\\);)|(${ws}C\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" { + pass "ptype class C (obsolescent gcc or gdb)" + } + -re ".*$gdb_prompt $" { + fail "ptype class C" + } + timeout { + fail "ptype class C (timeout)" + return + } + } + + send_gdb "ptype class D\n" + gdb_expect { + -re "type = class D : public B, public C \{${ws}public:${ws}int d;${ws}int x;${ws}D & operator=\\(D const ?&\\);${ws}D\\((D const|const D) ?&\\);${ws}D\\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype class D" + } + -re "type = class D : public B, public C \{${ws}public:${ws}int d;${ws}int x;((${ws}D & operator=\\(D const ?&\\);)|(${ws}D\\(D const ?&\\);)|(${ws}D\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" { + pass "ptype class D (obsolescent gcc or gdb)" + } + -re ".*$gdb_prompt $" { + fail "ptype class D" + } + timeout { + fail "ptype class D (timeout)" + return + } + } + + send_gdb "ptype class E\n" + gdb_expect { + -re "type = class E : public D \{${ws}public:${ws}int e;${ws}int x;${ws}E & operator=\\(E const ?&\\);${ws}E\\((E const|const E) ?&\\);${ws}E\\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype class E" + } + -re "type = class E : public D \{${ws}public:${ws}int e;${ws}int x;((${ws}E & operator=\\(E const ?&\\);)|(${ws}E\\((E const|const E) ?&\\);)|(${ws}E\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" { + pass "ptype class E" + } + -re ".*$gdb_prompt $" { + fail "ptype class E" + } + timeout { + fail "ptype class E (timeout)" + return + } + } + + # With g++ 2.x and stabs debug info, we misinterpret static methods + # whose name matches their argument mangling. + send_gdb "ptype class Static\n" + gdb_expect { + -re "type = (class|struct) Static \{(${ws}public:|)${ws}Static & operator=\\(Static const ?&\\);${ws}Static\\((Static const|const Static) ?&\\);${ws}Static\\((void|)\\);${ws}static void ii\\(int, int\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype class Static" + } + -re "type = (class|struct) Static \{(${ws}public:|)${ws}static void ii\\(int, int\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype class Static" + } + -re ".*$gdb_prompt $" { + fail "ptype class Static" + } + timeout { + fail "ptype class Static (timeout)" + return + } + } + + send_gdb "ptype class vA\n" + gdb_expect { + -re "type = (class|struct) vA \{(${ws}public:|)${ws}int va;${ws}int vx;${ws}\}$nl$gdb_prompt $" { + pass "ptype class vA" + } + -re "type = (class|struct) vA \{(${ws}public:|)${ws}int va;${ws}int vx;${ws}vA & operator=\\(vA const ?&\\);${ws}vA\\((vA const|const vA) ?&\\);${ws}vA\\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype class vA" + } + -re "type = (class|struct) vA \{(${ws}public:|)${ws}int va;${ws}int vx;((${ws}vA & operator=\\(vA const ?&\\);)|(${ws}vA\\(vA const ?&\\);)|(${ws}vA\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" { + pass "ptype class vA (obsolescent gcc or gdb)" + } + -re ".*$gdb_prompt $" { + fail "ptype class vA" + } + timeout { + fail "ptype class vA (timeout)" + return + } + } + + # Accept the form with embedded GNU style mangled virtual table constructs + # for now, but with a FIXME. At some future point, gdb should use a + # portable representation for the virtual table constructs. + + # The format of a g++ virtual base pointer. + set vbptr "(_vb\[$.\]|__vb_)\[0-9\]?" + + send_gdb "ptype class vB\n" + gdb_expect { + -re "type = class vB : public virtual vA \{${ws}public:${ws}int vb;${ws}int vx;${ws}vB & operator=\\(vB const ?&\\);${ws}vB\\((vB const|const vB) ?&\\);${ws}vB\\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype class vB" + } + -re "type = class vB : public virtual vA \{${ws}private:${ws}vA \\*${vbptr}vA;${ws}public:${ws}int vb;${ws}int vx;${ws}vB & operator=\\(vB const ?&\\);${ws}vB\\(int, vB const ?&\\);${ws}vB\\(int\\);${ws}\}$nl$gdb_prompt $" { + setup_xfail "*-*-*" + fail "ptype class vB (FIXME: non-portable virtual table constructs)" + } + -re "type = class vB : public virtual vA \{${ws}public:${ws}int vb;${ws}int vx;${ws}\}$nl$gdb_prompt $" { + pass "ptype class vB" + } + -re "type = class vB : public virtual vA \{${ws}private:${ws}vA \\*_vb.vA;${ws}public:${ws}int vb;${ws}int vx;((${ws}vB & operator=\\(vB const ?&\\);)|(${ws}vB\\(int, vB const ?&\\);)|(${ws}vB\\(int\\);))*${ws}\}$nl$gdb_prompt $" { + setup_xfail "*-*-*" + fail "ptype class vB (FIXME) (obsolescent gcc or gdb)" + } + -re ".*$gdb_prompt $" { + fail "ptype class vB" + } + timeout { + fail "ptype class vB (timeout)" + return + } + } + + # Accept the form with embedded GNU style mangled virtual table constructs + # for now, but with a FIXME. At some future point, gdb should use a + # portable representation for the virtual table constructs. + + send_gdb "ptype class vC\n" + gdb_expect { + -re "type = class vC : public virtual vA \{${ws}public:${ws}int vc;${ws}int vx;${ws}vC & operator=\\(vC const ?&\\);${ws}vC\\((vC const|const vC) ?&\\);${ws}vC\\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype class vC" + } + -re "type = class vC : public virtual vA \{${ws}private:${ws}vA \\*${vbptr}vA;${ws}public:${ws}int vc;${ws}int vx;${ws}vC & operator=\\(vC const ?&\\);${ws}vC\\(int, vC const ?&\\);${ws}vC\\(int\\);${ws}\}$nl$gdb_prompt $" { + setup_xfail "*-*-*" + fail "ptype class vC (FIXME: non-portable virtual table constructs)" + } + -re "type = class vC : public virtual vA \{${ws}public:${ws}int vc;${ws}int vx;${ws}\}$nl$gdb_prompt $" { + pass "ptype class vC" + } + -re "type = class vC : public virtual vA \{${ws}private:${ws}vA \\*_vb.vA;${ws}public:${ws}int vc;${ws}int vx;((${ws}vC & operator=\\(vC const ?&\\);)|(${ws}vC\\(int, vC const ?&\\);)|(${ws}vC\\(int\\);))*${ws}\}$nl$gdb_prompt $" { + setup_xfail "*-*-*" + fail "ptype class vC (FIXME) (obsolescent gcc or gdb)" + } + -re ".*$gdb_prompt $" { + fail "ptype class vC" + } + timeout { + fail "ptype class vC (timeout)" + return + } + } + + # Accept the form with embedded GNU style mangled virtual table constructs + # for now, but with a FIXME. At some future point, gdb should use a + # portable representation for the virtual table constructs. + + send_gdb "ptype class vD\n" + gdb_expect { + -re "type = class vD : public virtual vB, public virtual vC \{${ws}public:${ws}int vd;${ws}int vx;${ws}vD & operator=\\(vD const ?&\\);${ws}vD\\((vD const|const vD) ?&\\);${ws}vD\\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype class vD" + } + -re "type = class vD : public virtual vB, public virtual vC \{${ws}private:${ws}vC \\*${vbptr}vC;${ws}vB \\*${vbptr}vB;${ws}public:${ws}int vd;${ws}int vx;${ws}vD & operator=\\(vD const ?&\\);${ws}vD\\(int, vD const ?&\\);${ws}vD\\(int\\);${ws}\}$nl$gdb_prompt $" { + setup_xfail "*-*-*" + fail "ptype class vD (FIXME: non-portable virtual table constructs)" + } + -re "type = class vD : public virtual vB, public virtual vC \{${ws}public:${ws}int vd;${ws}int vx;${ws}\}$nl$gdb_prompt $" { + pass "ptype class vD" + } + -re "type = class vD : public virtual vB, public virtual vC \{${ws}private:${ws}vC \\*_vb.vC;${ws}vB \\*_vb.vB;${ws}public:${ws}int vd;${ws}int vx;((${ws}vD & operator=\\(vD const ?&\\);)|(${ws}vD\\(int, vD const ?&\\);)|(${ws}vD\\(int\\);))*${ws}\}$nl$gdb_prompt $" { + setup_xfail "*-*-*" + fail "ptype class vD (FIXME) (obsolescent gcc or gdb)" + } + -re ".*$gdb_prompt $" { + fail "ptype class vD" + } + timeout { + fail "ptype class vD (timeout)" + return + } + } + + # Accept the form with embedded GNU style mangled virtual table constructs + # for now, but with a FIXME. At some future point, gdb should use a + # portable representation for the virtual table constructs. + + send_gdb "ptype class vE\n" + gdb_expect { + -re "type = class vE : public virtual vD \{${ws}public:${ws}int ve;${ws}int vx;${ws}vE & operator=\\(vE const ?&\\);${ws}vE\\((vE const|const vE) ?&\\);${ws}vE\\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype class vE" + } + -re "type = class vE : public virtual vD \{${ws}private:${ws}vD \\*${vbptr}vD;${ws}public:${ws}int ve;${ws}int vx;${ws}vE & operator=\\(vE const ?&\\);${ws}vE\\(int, vE const ?&\\);${ws}vE\\(int\\);${ws}\}$nl$gdb_prompt $" { + setup_xfail "*-*-*" + fail "ptype class vE (FIXME: non-portable virtual table constructs)" + } + -re "type = class vE : public virtual vD \{${ws}public:${ws}int ve;${ws}int vx;${ws}\}$nl$gdb_prompt $" { + pass "ptype class vE" + } + -re "type = class vE : public virtual vD \{${ws}private:${ws}vD \\*_vb.vD;${ws}public:${ws}int ve;${ws}int vx;((${ws}vE & operator=\\(vE const ?&\\);)|(${ws}vE\\(int, vE const ?&\\);)|(${ws}vE\\(int\\);))*${ws}\}$nl$gdb_prompt $" { + setup_xfail "*-*-*" + fail "ptype class vE (FIXME) (obsolescent gcc or gdb)" + } + -re ".*$gdb_prompt $" { + fail "ptype class vE" + } + timeout { + fail "ptype class vE (timeout)" + return + } + } + + send_gdb "ptype class Base1\n" + gdb_expect { + -re "type = class Base1 \{${ws}public:${ws}int x;${ws}Base1 & operator=\\(Base1 const ?&\\);${ws}Base1\\(((Base1 const)|(const Base1)) ?&\\);${ws}Base1\\(int\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype class Base1" + } + -re "type = class Base1 \{${ws}public:${ws}int x;${ws}Base1\\(int\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype class Base1" + } + -re "type = class Base1 \{${ws}public:${ws}int x;((${ws}Base1 & operator=\\(Base1 const ?&\\);)|(${ws}Base1\\(Base1 const ?&\\);)|(${ws}Base1\\(int\\);))*${ws}\}$nl$gdb_prompt $" { + pass "ptype class Base1 (obsolescent gcc or gdb)" + } + -re ".*$gdb_prompt $" { + fail "ptype class Base1" + } + timeout { + fail "ptype class Base1 (timeout)" + return + } + } + + send_gdb "ptype class Foo\n" + gdb_expect { + -re "type = class Foo \{${ws}public:${ws}int x;${ws}int y;${ws}static int st;\r\n${ws}Foo\\(int, int\\);${ws}int operator!\\((void|)\\);${ws}operator int\\((void|)\\);${ws}int times\\(int\\);$nl\}$nl$gdb_prompt $" { + pass "ptype class Foo" + } + -re "type = class Foo \{${ws}public:${ws}int x;${ws}int y;${ws}static int st;${ws}Foo & operator=\\(Foo const ?&\\);${ws}Foo\\((Foo const|const Foo) ?&\\);${ws}Foo\\(int, int\\);${ws}int operator!\\((void|)\\);${ws}operator int\\((void|)\\);${ws}int times\\(int\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype class Foo" + } + -re "type = class Foo \{${ws}public:${ws}int x;${ws}int y;${ws}static int st;((${ws}Foo & operator=\\(Foo const ?&\\);)|(${ws}Foo\\(Foo const ?&\\);)|(${ws}Foo\\(int, int\\);)|(${ws}int operator!\\((void|)\\);)|(${ws}int operator int\\((void|)\\);)|(${ws}int times\\(int\\);))*${ws}\}$nl$gdb_prompt $" { + pass "ptype class Foo (obsolescent gcc or gdb)" + } + -re ".*$gdb_prompt $" { + fail "ptype class Foo" + } + timeout { + fail "ptype class Foo (timeout)" + return + } + } + + send_gdb "ptype class Bar\n" + gdb_expect { + -re "type = class Bar : public Base1, public Foo \{${ws}public:${ws}int z;${ws}Bar & operator=\\(Bar const ?&\\);${ws}Bar\\((Bar const|const Bar) ?&\\);${ws}Bar\\(int, int, int\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype class Bar" + } + -re "type = class Bar : public Base1, public Foo \{${ws}public:${ws}int z;((${ws}Bar & operator=\\(Bar const ?&\\);)|(${ws}Bar\\(Bar const ?&\\);)|(${ws}Bar\\(int, int, int\\);))*${ws}\}$nl$gdb_prompt $" { + pass "ptype class Bar (obsolescent gcc or gdb)" + } + -re ".*$gdb_prompt $" { + fail "ptype class Bar" + } + timeout { + fail "ptype class Bar (timeout)" + return + } + } +} + +# +# Test simple access to class members. +# + +proc test_non_inherited_member_access {} { + global gdb_prompt + + # Print non-inherited members of g_A. + + gdb_test "print g_A.a" ".* = 1" "g_A.a incorrect" + + gdb_test "print g_A.x" ".* = 2" "g_A.x incorrect" + + # Print non-inherited members of g_B. + + gdb_test "print g_B.b" ".* = 5" "g_B.b incorrect" + + gdb_test "print g_B.x" ".* = 6" "g_B.x incorrect" + + # Print non-inherited members of g_C. + + gdb_test "print g_C.c" ".* = 9" "g_C.c incorrect" + + gdb_test "print g_C.x" ".* = 10" "g_C.x incorrect" + + # Print non-inherited members of g_D. + + gdb_test "print g_D.d" ".* = 19" "g_D.d incorrect" + + gdb_test "print g_D.x" ".* = 20" "g_D.x incorrect" + + # Print non-inherited members of g_E. + + gdb_test "print g_E.e" ".* = 31" "g_E.e incorrect" + + gdb_test "print g_E.x" ".* = 32" "g_E.x incorrect" +} + +# +# Try access to non-members that are members of another class. +# Should give errors. +# + +proc test_wrong_class_members {} { + global gdb_prompt + + gdb_test "print g_A.b" "There is no member( or method|) named b." "print g_A.b should be error" + + gdb_test "print g_B.c" "There is no member( or method|) named c." "print g_B.c should be error" + + gdb_test "print g_B.d" "There is no member( or method|) named d." "print g_B.d should be error" + + gdb_test "print g_C.b" "There is no member( or method|) named b." "print g_C.b should be error" + + gdb_test "print g_C.d" "There is no member( or method|) named d." "print g_C.d should be error" + + gdb_test "print g_D.e" "There is no member( or method|) named e." "print g_D.e should be error" +} + +# +# Try access to non-members that are not members of any class. +# Should give errors. +# + +proc test_nonexistent_members {} { + global gdb_prompt + + gdb_test "print g_A.y" "There is no member( or method|) named y." "print g_A.y should be error" + + gdb_test "print g_B.z" "There is no member( or method|) named z." "print g_B.z should be error" + + gdb_test "print g_C.q" "There is no member( or method|) named q." "print g_C.q should be error" + + gdb_test "print g_D.p" "There is no member( or method|) named p." "print g_D.p should be error" +} + +# +# Call a method that expects a base class parameter with base, inherited, +# and unrelated class arguments. +# + +proc test_method_param_class {} { + gdb_test "call class_param.Aptr_a (&g_A)" ".* = 1" "base class param->a" + gdb_test "call class_param.Aptr_x (&g_A)" ".* = 2" "base class param->x" + gdb_test "call class_param.Aptr_a (&g_B)" ".* = 3" "inherited class param->a" + gdb_test "call class_param.Aptr_x (&g_B)" ".* = 4" "inherited class param->x" + gdb_test "call class_param.Aref_a (g_A)" ".* = 1" "base class (¶m)->a" + gdb_test "call class_param.Aref_x (g_A)" ".* = 2" "base class (¶m)->x" + gdb_test "call class_param.Aref_a (g_B)" ".* = 3" "inherited class (¶m)->a" + gdb_test "call class_param.Aref_x (g_B)" ".* = 4" "inherited class (¶m)->x" + gdb_test "call class_param.Aval_a (g_A)" ".* = 1" "base class param.a" + gdb_test "call class_param.Aval_x (g_A)" ".* = 2" "base class param.x" + gdb_test "call class_param.Aval_a (g_B)" ".* = 3" "inherited class param.a" + gdb_test "call class_param.Aval_x (g_B)" ".* = 4" "inherited class param.x" + + gdb_test "call class_param.Aptr_a (&foo)" "Cannot resolve .*" "unrelated class *param" + gdb_test "call class_param.Aref_a (foo)" "Cannot resolve .*" "unrelated class ¶m" + gdb_test "call class_param.Aval_a (foo)" "Cannot resolve .*" "unrelated class param" +} + +# +# Examine a class with an enum field. +# + +proc test_enums {} { + global gdb_prompt + global hp_aCC_compiler + + # print the object + send_gdb "print obj_with_enum\n" + gdb_expect { + -re "\\$\[0-9\]* = \\{priv_enum = red, x = 0\\}.*$gdb_prompt $" { pass "print obj_with_enum (1)" } + -re "$gdb_prompt $" { fail "print obj_with_enum (1)" } + timeout { fail "(timeout) print obj_with_enum (1)" } + } + + send_gdb "next\n" + gdb_expect { + -re "$gdb_prompt $" { pass "next" } + timeout { fail "(timeout) next" } + } + + # print the object again + send_gdb "print obj_with_enum\n" + gdb_expect { + -re "\\$\[0-9\]* = \\{priv_enum = green, x = 0\\}.*$gdb_prompt $" { pass "print obj_with_enum (2)" } + -re "$gdb_prompt $" { fail "print obj_with_enum (2)" } + timeout { fail "(timeout) print obj_with_enum (2)" } + } + + # print out the enum member + send_gdb "print obj_with_enum.priv_enum\n" + gdb_expect { + -re "\\$\[0-9\]* = green.*$gdb_prompt $" { pass "print obj_with_enum.priv_enum" } + -re "$gdb_prompt $" { fail "print obj_with_enum.priv_enum" } + timeout { fail "(timeout) print obj_with_enum.priv_enum" } + } + + # ptype on the enum member + # The third success case is a little dubious, but it's not clear what + # ought to be required of a ptype on a private enum... -sts 19990324 + send_gdb "ptype obj_with_enum.priv_enum\n" + gdb_expect { + -re "type = enum ClassWithEnum::PrivEnum \\{red, green, blue, yellow = 42\\}.*$gdb_prompt $" { pass "ptype obj_with_enum.priv_enum" } + -re "type = enum PrivEnum \\{red, green, blue, yellow = 42\\}.*$gdb_prompt $" { pass "ptype obj_with_enum.priv_enum" } + -re "type = enum \\{red, green, blue, yellow = 42\\}.*$gdb_prompt $" { pass "ptype obj_with_enum.priv_enum" } + -re "$gdb_prompt $" { fail "ptype obj_with_enum.priv_enum" } + timeout { fail "(timeout) ptype obj_with_enum.priv_enum" } + } + + # ptype on the object + send_gdb "ptype obj_with_enum\n" + gdb_expect { + -re "type = class ClassWithEnum \\{\r\n\[ \t\]*public:\r\n\[ \t\]*(enum |)ClassWithEnum::PrivEnum priv_enum;\r\n\[ \t\]*int x;\r\n\\}\r\n$gdb_prompt $" { pass "ptype obj_with_enum" } + -re "type = class ClassWithEnum \\{\r\n\[ \t\]*public:\r\n\[ \t\]*(enum |)PrivEnum priv_enum;\r\n\[ \t\]*int x;.*\\}\r\n$gdb_prompt $" + { + # NOTE: carlton/2003-02-28: One could certainly argue that + # this output is acceptable: PrivEnum is a member of + # ClassWithEnum, so there's no need to explicitly qualify + # its name with "ClassWithEnum::". The truth, though, is + # that GDB is simply forgetting that PrivEnum is a member + # of ClassWithEnum, so we do that output for a bad reason + # instead of a good reason. Under stabs, we probably + # can't get this right; under DWARF-2, we can. + kfail "gdb/57" "ptype obj_with_enum" + } + -re "$gdb_prompt $" { fail "ptype obj_with_enum" } + timeout { fail "(timeout) ptype obj_with_enum" } + } + + # We'll do this test twice, because of a parser bug: see + # PR gdb/826. + + send_gdb "print (ClassWithEnum::PrivEnum) 42\n" + gdb_expect { + -re "\\$\[0-9\]* = yellow.*$gdb_prompt $" { pass "print (ClassWithEnum::PrivEnum) 42" } + -re "A parse error in expression, near `42'.\r\n$gdb_prompt $" + { kfail "gdb/826" "print (ClassWithEnum::PrivEnum) 42" } + -re "$gdb_prompt $" { fail "print (ClassWithEnum::PrivEnum) 42" } + timeout { fail "(timeout) print (ClassWithEnum::PrivEnum) 42" } + } + + send_gdb "print ('ClassWithEnum::PrivEnum') 42\n" + gdb_expect { + -re "\\$\[0-9\]* = yellow.*$gdb_prompt $" { pass "print ('ClassWithEnum::PrivEnum') 42" } + -re "No symbol \"ClassWithEnum::PrivEnum\" in current context.\r\n$gdb_prompt $" + { kfail "gdb/57" "print ('ClassWithEnum::PrivEnum') 42" } + -re "$gdb_prompt $" { fail "print ('ClassWithEnum::PrivEnum') 42" } + timeout { fail "(timeout) print ('ClassWithEnum::PrivEnum') 42" } + } +} + +# +# Pointers to class members +# + +proc test_pointers_to_class_members {} { + global gdb_prompt + global decimal + global nl + + gdb_test "print Bar::z" ".* = .int\[ \]*\[( \]*Bar::&\[)\]+\[ \]*Bar::z" "print Bar::z" + + gdb_test "print &Foo::x" ".* = .int\[ \]*\[( \]*Foo::\[*)\]+\[ \]*&Foo::x" "print &Foo::x" + + gdb_test "print (int)&Foo::x" ".* = 0" "print (int)&Foo::x" + + send_gdb "print (int)&Bar::y == 2*sizeof(int)\n" + gdb_expect { + -re ".* = true$nl$gdb_prompt $" { + pass "print (int)&Bar::y == 2*sizeof(int)" + } + -re "There is no field named y.*$gdb_prompt $" { + setup_xfail "*-*-*" + fail "print (int)&Bar::y == 2*sizeof(int)" + } + -re ".*$gdb_prompt $" { fail "print (int)&Bar::y == 2*sizeof(int)" } + timeout { fail "print (int)&Bar::y == 2*sizeof(int) (timeout)" ; return } + } + + send_gdb "next 2\n" + setup_xfail "*-*-*" + gdb_expect { + -re "$decimal\[ \t\]+inheritance3 \[)(\]+;$nl$gdb_prompt $" {} + -re ".*$gdb_prompt $" { fail "next to inheritance3" ; return } + } + clear_xfail "*-*-*" + + gdb_test "print (int)pmi == sizeof(int)" ".* = false" "print (int)pmi == sizeof(int)" +} + +# +# Test static members. +# + +proc test_static_members {} { + global gdb_prompt + global hex + global nl + + send_gdb "print Foo::st\n" + gdb_expect { + -re ".* = 100$nl$gdb_prompt $" { + pass "print Foo::st" + } + -re "There is no field named st.*$gdb_prompt $" { + setup_xfail "*-*-*" + fail "print Foo::st" + } + -re ".*$gdb_prompt $" { fail "print Foo::st" } + timeout { fail "print Foo::st (timeout)" ; return } + } + + send_gdb "set foo.st = 200\n" + gdb_expect { + -re ".*$gdb_prompt $" {} + } + + send_gdb "print bar.st\n" + gdb_expect { + -re ".* = 200$nl$gdb_prompt $" { + pass "print bar.st" + } + -re "There is no member( or method|) named st.*$gdb_prompt $" { + setup_xfail "*-*-*" + fail "print bar.st" + } + -re ".*$gdb_prompt $" { fail "print bar.st" } + timeout { fail "print bar.st (timeout)" ; return } + } + + send_gdb "print &foo.st\n" + gdb_expect { + -re ".* = .int \[*)\]+ $hex$nl$gdb_prompt $" { + pass "print &foo.st" + } + -re "There is no member( or method|) named st.*$gdb_prompt $" { + setup_xfail "*-*-*" + fail "print &foo.st" + } + -re ".*$gdb_prompt $" { fail "print &foo.st" } + timeout { fail "print &foo.st (timeout)" ; return } + } + + set got_bar_st 0 + send_gdb "print &Bar::st\n" + gdb_expect { + -re ".* = .int \[*)\]+ $hex$nl$gdb_prompt $" { + pass "print &Bar::st" + set got_bar_st 1 + } + -re "There is no field named st.*$gdb_prompt $" { + setup_xfail "*-*-*" + fail "print &Bar::st" + } + -re ".*$gdb_prompt $" { fail "print &Bar::st" } + timeout { fail "print &Bar::st (timeout)" ; return } + } + + if $got_bar_st then { + gdb_test "print *\$" ".* = 200" "print *\$" + } + + gdb_test "set print static-members off" "" + gdb_test "print csi" \ + "{x = 10, y = 20}" \ + "print csi without static members" + gdb_test "print cnsi" \ + "{x = 30, y = 40}" \ + "print cnsi without static members" + + gdb_test "set print static-members on" "" + gdb_test "print csi" \ + "{x = 10, y = 20, static null = {x = 0, y = 0, static null = <same as static member of an already seen type>}}" \ + "print csi with static members" + gdb_test "print cnsi" \ + "{x = 30, y = 40, static null = {x = 0, y = 0, static null = <same as static member of an already seen type>, static yy = {z = 5, static xx = {x = 1, y = 2, static null = <same as static member of an already seen type>, static yy = <same as static member of an already seen type>}}}, static yy = <same as static member of an already seen type>}" \ + "print cnsi with static members" +} + +proc do_tests {} { + global prms_id + global bug_id + global subdir + global objdir + global srcdir + global binfile + global gdb_prompt + + set prms_id 0 + set bug_id 0 + + # Start with a fresh gdb. + + gdb_exit + gdb_start + gdb_reinitialize_dir $srcdir/$subdir + gdb_load $binfile + + send_gdb "set language c++\n" + gdb_expect -re "$gdb_prompt $" + send_gdb "set width 0\n" + gdb_expect -re "$gdb_prompt $" + + runto_main + test_ptype_class_objects + + if [ runto 'inheritance2' ] then { + test_non_inherited_member_access + test_wrong_class_members + test_nonexistent_members + test_method_param_class + } + + gdb_breakpoint enums2 + if [ gdb_continue "enums2(\\(\\)|)" ]==0 then { + gdb_test "finish" "" "" + test_enums + } + + if [istarget "mips-idt-*"] then { + # Restart because IDT/SIM runs out of file descriptors. + gdb_exit + gdb_start + gdb_reinitialize_dir $srcdir/$subdir + gdb_load $binfile + } + + if [ runto_main ] then { + test_pointers_to_class_members + test_static_members + } + + if [istarget "mips-idt-*"] then { + # Restart because IDT/SIM runs out of file descriptors. + gdb_exit + gdb_start + gdb_reinitialize_dir $srcdir/$subdir + gdb_load $binfile + } + + if [ runto marker_reg1 ] then { + + gdb_test "finish" "Run till exit from.*" "finish from marker_reg1" + + send_gdb "print v.method ()\n" + gdb_expect { + -re "= 82.*$gdb_prompt $" { + pass "calling method for small class" + } + -re "Address requested for identifier .v. which is in register.*$gdb_prompt $" { + setup_xfail "*-*-*" 2972 + fail "calling method for small class" + } + -re ".*$gdb_prompt $" { fail "calling method for small class" } + timeout { fail "calling method for small class (timeout)" } + eof { fail "calling method for small class (eof)" } + } + } + +} + +do_tests + +send_gdb "maint demangle inheritance1__Fv\n" +gdb_expect { + -re "inheritance1\\(void\\).*$gdb_prompt $" { pass "demangle" } + -re ".*$gdb_prompt $" { fail "demangle" } + timeout { fail "(timeout) demangle" } +} diff --git a/gdb/testsuite/gdb.cp/cplusfuncs.cc b/gdb/testsuite/gdb.cp/cplusfuncs.cc new file mode 100644 index 0000000..7f033d6 --- /dev/null +++ b/gdb/testsuite/gdb.cp/cplusfuncs.cc @@ -0,0 +1,196 @@ +#include <stddef.h> + +class foo { +public: + foo (int); + foo (int, const char *); + foo (foo&); + ~foo (); + + void operator * (foo&); + void operator % (foo&); + void operator - (foo&); + void operator >> (foo&); + void operator != (foo&); + void operator > (foo&); + void operator >= (foo&); + void operator | (foo&); + void operator && (foo&); + void operator ! (void); + void operator ++ (int); + void operator = (foo&); + void operator += (foo&); + void operator *= (foo&); + void operator %= (foo&); + void operator >>= (foo&); + void operator |= (foo&); + void operator , (foo&); + void operator / (foo&); + void operator + (foo&); + void operator << (foo&); + void operator == (foo&); + void operator < (foo&); + void operator <= (foo&); + void operator & (foo&); + void operator ^ (foo&); + void operator || (foo&); + void operator ~ (void); + void operator -- (int); + foo* operator -> (void); + void operator -= (foo&); + void operator /= (foo&); + void operator <<= (foo&); + void operator &= (foo&); + void operator ^= (foo&); + void operator ->* (foo&); + void operator [] (foo&); + void operator () (foo&); + void* operator new (size_t) throw (); + void operator delete (void *); + /**/ operator int (); + /**/ operator char* (); + + int foofunc (int); // forced to have int return type, which is required + int foofunc (int, signed char *); // forced to have int return type, which is required + int ifoo; + const char *ccpfoo; +}; + +#ifdef usestubs +extern "C" { + void set_debug_traps(); + void breakpoint(); +}; +#endif + +int main () { +#ifdef usestubs + set_debug_traps(); + breakpoint(); +#endif + int z=3; +} + +foo::foo (int i) { ifoo = i;} +foo::foo (int i, const char *ccp) { ifoo = i; ccpfoo = ccp; } +foo::foo (foo& afoo) { afoo.ifoo = 0; } +foo::~foo () {} + +void foo::operator * (foo& afoo) { afoo.ifoo = 0; } +void foo::operator % (foo& afoo) { afoo.ifoo = 0; } +void foo::operator - (foo& afoo) { afoo.ifoo = 0; } +void foo::operator >> (foo& afoo) { afoo.ifoo = 0; } +void foo::operator != (foo& afoo) { afoo.ifoo = 0; } +void foo::operator > (foo& afoo) { afoo.ifoo = 0; } +void foo::operator >= (foo& afoo) { afoo.ifoo = 0; } +void foo::operator | (foo& afoo) { afoo.ifoo = 0; } +void foo::operator && (foo& afoo) { afoo.ifoo = 0; } +void foo::operator ! (void) {} +void foo::operator ++ (int ival) { ival = 0; } +void foo::operator = (foo& afoo) { afoo.ifoo = 0; } +void foo::operator += (foo& afoo) { afoo.ifoo = 0; } +void foo::operator *= (foo& afoo) { afoo.ifoo = 0; } +void foo::operator %= (foo& afoo) { afoo.ifoo = 0; } +void foo::operator >>= (foo& afoo) { afoo.ifoo = 0; } +void foo::operator |= (foo& afoo) { afoo.ifoo = 0; } +void foo::operator , (foo& afoo) { afoo.ifoo = 0; } +void foo::operator / (foo& afoo) { afoo.ifoo = 0; } +void foo::operator + (foo& afoo) { afoo.ifoo = 0; } +void foo::operator << (foo& afoo) { afoo.ifoo = 0; } +void foo::operator == (foo& afoo) { afoo.ifoo = 0; } +void foo::operator < (foo& afoo) { afoo.ifoo = 0; } +void foo::operator <= (foo& afoo) { afoo.ifoo = 0; } +void foo::operator & (foo& afoo) { afoo.ifoo = 0; } +void foo::operator ^ (foo& afoo) { afoo.ifoo = 0; } +void foo::operator || (foo& afoo) { afoo.ifoo = 0; } +void foo::operator ~ (void) {} +void foo::operator -- (int ival) { ival = 0; } +foo* foo::operator -> (void) {return this;} +void foo::operator -= (foo& afoo) { afoo.ifoo = 0; } +void foo::operator /= (foo& afoo) { afoo.ifoo = 0; } +void foo::operator <<= (foo& afoo) { afoo.ifoo = 0; } +void foo::operator &= (foo& afoo) { afoo.ifoo = 0; } +void foo::operator ^= (foo& afoo) { afoo.ifoo = 0; } +void foo::operator ->* (foo& afoo) { afoo.ifoo = 0; } +void foo::operator [] (foo& afoo) { afoo.ifoo = 0; } +void foo::operator () (foo& afoo) { afoo.ifoo = 0; } +void* foo::operator new (size_t ival) throw () { ival = 0; return 0; } +void foo::operator delete (void *ptr) { ptr = 0; } +/**/ foo::operator int () { return 0; } +/**/ foo::operator char* () { return 0; } + +/* Some functions to test overloading by varying one argument type. */ + +void overload1arg (void) { } +void overload1arg (char arg) { arg = 0; } +void overload1arg (signed char arg) { arg = 0; } +void overload1arg (unsigned char arg) { arg = 0; } +void overload1arg (short arg) { arg = 0; } +void overload1arg (unsigned short arg) { arg = 0; } +void overload1arg (int arg) { arg = 0; } +void overload1arg (unsigned int arg) { arg = 0; } +void overload1arg (long arg) { arg = 0; } +void overload1arg (unsigned long arg) { arg = 0; } +void overload1arg (float arg) { arg = 0; } +void overload1arg (double arg) { arg = 0; } + +/* Some functions to test overloading by varying argument count. */ + +void overloadargs (int a1) { a1 = 0; } +void overloadargs (int a1, int a2) { a1 = a2 = 0; } +void overloadargs (int a1, int a2, int a3) { a1 = a2 = a3 = 0; } +void overloadargs (int a1, int a2, int a3, int a4) + { a1 = a2 = a3 = a4 = 0; } +void overloadargs (int a1, int a2, int a3, int a4, int a5) + { a1 = a2 = a3 = a4 = a5 = 0; } +void overloadargs (int a1, int a2, int a3, int a4, int a5, int a6) + { a1 = a2 = a3 = a4 = a5 = a6 = 0; } +void overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7) + { a1 = a2 = a3 = a4 = a5 = a6 = a7 = 0; } +void overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7, + int a8) + { a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = 0; } +void overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7, + int a8, int a9) + { a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = a9 = 0; } +void overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7, + int a8, int a9, int a10) + { a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = a9 = + a10 = 0; } +void overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7, + int a8, int a9, int a10, int a11) + { a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = a9 = + a10 = a11 == 0; } + +/* Some hairy function definitions. + Use typedefs to help maintain sanity. */ + +typedef int (*PFPc_i)(char *); +typedef short (*PFPl_s)(long *); +typedef short (*PFPc_s)(char *); +typedef int (*PFl_i)(long); +typedef PFl_i (*PFPc_PFl_i)(char *); +typedef PFl_i (*PFPi_PFl_i)(int *); +typedef PFl_i (*PFPFPc_i_PFl_i)(PFPc_i); +typedef PFl_i (*PFs_PFl_i)(short); +typedef int (*PFPFPl_s_i)(PFPl_s); +typedef int (*PFPFPc_s_i)(PFPc_s); + +PFs_PFl_i hairyfunc1 (int arg) { arg = 0; return 0; } +int hairyfunc2 (PFPc_i arg) { arg = 0; return 0; } +int hairyfunc3 (PFPFPl_s_i arg) { arg = 0; return 0; } +int hairyfunc4 (PFPFPc_s_i arg) { arg = 0; return 0; } +int hairyfunc5 (PFPc_PFl_i arg) { arg = 0; return 0; } +int hairyfunc6 (PFPi_PFl_i arg) { arg = 0; return 0; } +int hairyfunc7 (PFPFPc_i_PFl_i arg) { arg = 0; return 0; } + +/* gdb has two demanglers (one for g++ 2.95, one for g++ 3). + These marker functions help me figure out which demangler is in use. */ + +char * dm_type_char_star (char * p) { return p; } +int dm_type_foo_ref (foo & foo) { return foo.ifoo; } +int * dm_type_int_star (int * p) { return p; } +long * dm_type_long_star (long * p) { return p; } +int dm_type_unsigned_int (unsigned int i) { return i; } +int dm_type_void (void) { return 0; } +void * dm_type_void_star (void * p) { return p; } diff --git a/gdb/testsuite/gdb.cp/cplusfuncs.exp b/gdb/testsuite/gdb.cp/cplusfuncs.exp new file mode 100644 index 0000000..0a5e1b3 --- /dev/null +++ b/gdb/testsuite/gdb.cp/cplusfuncs.exp @@ -0,0 +1,564 @@ +# Copyright 1992, 1997, 1999, 2001, 2002, 2003 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# This file was written by Fred Fish. (fnf@cygnus.com) +# Adapted for g++ 3.0 ABI by Michael Chastain. (chastain@redhat.com) + +if $tracelevel then { + strace $tracelevel +} + +if { [skip_cplus_tests] } { continue } + +set testfile "cplusfuncs" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [get_compiler_info $binfile "c++"] } { + return -1 +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +# +# g++ changed its ABI between 2.95 and 3.0. gdb has two demanglers +# for the two different styles. The two demanglers have some subtle +# discrepancies in their output. +# +# old demangler new demangler +# --- --------- --- --------- +# "operator, " "operator," +# "char *" "char*" +# "int *" "int*" +# "long *" "long*" +# "void *" "void*" +# "foo &" "foo&" +# "unsigned int" "unsigned" +# "void" "" +# +# I probe for the forms in use. +# The defaults are for the v3 demangler (as of 2001-02-13). +# + +set dm_operator_comma "," +set dm_type_char_star "char*" +set dm_type_char_star_quoted "char\\*" +set dm_type_foo_ref "foo&" +set dm_type_int_star "int*" +set dm_type_long_star "long*" +set dm_type_unsigned_int "unsigned" +set dm_type_void "" +set dm_type_void_star "void*" + +proc probe_demangler { } { + global gdb_prompt + global dm_operator_comma + global dm_type_char_star + global dm_type_char_star_quoted + global dm_type_foo_ref + global dm_type_int_star + global dm_type_long_star + global dm_type_unsigned_int + global dm_type_void + global dm_type_void_star + + send_gdb "print &'foo::operator,(foo&)'\n" + gdb_expect { + -re ".*foo::operator, \\(.*foo.*&.*\\).*\r\n$gdb_prompt $" { + # v2 demangler + set dm_operator_comma ", " + pass "detect dm_operator_comma" + } + -re ".*foo::operator,\\(.*foo.*&.*\\).*\r\n$gdb_prompt $" { + # v3 demangler + pass "detect dm_operator_comma" + } + -re ".*$gdb_prompt $" { + fail "detect dm_operator_comma" + } + timeout { + fail "detect dm_operator_comma" + } + } + + send_gdb "print &'dm_type_char_star'\n" + gdb_expect { + -re ".*dm_type_char_star\\(char \\*\\).*\r\n$gdb_prompt $" { + # v2 demangler + set dm_type_char_star "char *" + set dm_type_char_star_quoted "char \\*" + pass "detect dm_type_char_star" + } + -re ".*dm_type_char_star\\(char\\*\\).*\r\n$gdb_prompt $" { + # v3 demangler + pass "detect dm_type_char_star" + } + -re ".*$gdb_prompt $" { + fail "detect dm_type_char_star" + } + timeout { + fail "detect dm_type_char_star (timeout)" + } + } + + send_gdb "print &'dm_type_foo_ref'\n" + gdb_expect { + -re ".*dm_type_foo_ref\\(foo &\\).*\r\n$gdb_prompt $" { + # v2 demangler + set dm_type_foo_ref "foo &" + pass "detect dm_type_foo_ref" + } + -re ".*dm_type_foo_ref\\(foo&\\).*\r\n$gdb_prompt $" { + # v3 demangler + pass "detect dm_type_foo_ref" + } + -re ".*$gdb_prompt $" { + fail "detect dm_type_foo_ref" + } + timeout { + fail "detect dm_type_foo_ref (timeout)" + } + } + + send_gdb "print &'dm_type_int_star'\n" + gdb_expect { + -re ".*dm_type_int_star\\(int \\*\\).*\r\n$gdb_prompt $" { + # v2 demangler + set dm_type_int_star "int *" + pass "detect dm_type_int_star" + } + -re ".*dm_type_int_star\\(int\\*\\).*\r\n$gdb_prompt $" { + # v3 demangler + pass "detect dm_type_int_star" + } + -re ".*$gdb_prompt $" { + fail "detect dm_type_int_star" + } + timeout { + fail "detect dm_type_int_star (timeout)" + } + } + + send_gdb "print &'dm_type_long_star'\n" + gdb_expect { + -re ".*dm_type_long_star\\(long \\*\\).*\r\n$gdb_prompt $" { + # v2 demangler + set dm_type_long_star "long *" + pass "detect dm_type_long_star" + } + -re ".*dm_type_long_star\\(long\\*\\).*\r\n$gdb_prompt $" { + # v3 demangler + pass "detect dm_type_long_star" + } + -re ".*$gdb_prompt $" { + fail "detect dm_type_long_star" + } + timeout { + fail "detect dm_type_long_star (timeout)" + } + } + + send_gdb "print &'dm_type_unsigned_int'\n" + gdb_expect { + -re ".*dm_type_unsigned_int\\(unsigned int\\).*\r\n$gdb_prompt $" { + # v2 demangler + set dm_type_unsigned_int "unsigned int" + pass "detect dm_type_unsigned_int" + } + -re ".*dm_type_unsigned_int\\(unsigned\\).*\r\n$gdb_prompt $" { + # v3 demangler + pass "detect dm_type_unsigned_int" + } + -re ".*$gdb_prompt $" { + fail "detect dm_type_unsigned_int" + } + timeout { + fail "detect dm_unsigned int (timeout)" + } + } + + send_gdb "print &'dm_type_void'\n" + gdb_expect { + -re ".*dm_type_void\\(void\\).*\r\n$gdb_prompt $" { + # v2 demangler + set dm_type_void "void" + pass "detect dm_type_void" + } + -re ".*dm_type_void\\(\\).*\r\n$gdb_prompt $" { + # v3 demangler + pass "detect dm_type_void" + } + -re ".*$gdb_prompt $" { + fail "detect dm_type_void" + } + timeout { + fail "detect dm_type_void (timeout)" + } + } + + send_gdb "print &'dm_type_void_star'\n" + gdb_expect { + -re ".*dm_type_void_star\\(void \\*\\).*\r\n$gdb_prompt $" { + # v2 demangler + set dm_type_void_star "void *" + pass "detect dm_type_void_star" + } + -re ".*dm_type_void_star\\(void\\*\\).*\r\n$gdb_prompt $" { + # v3 demangler + pass "detect dm_type_void_star" + } + -re ".*$gdb_prompt $" { + fail "detect dm_type_void_star" + } + timeout { + fail "detect dm_type_void_star (timeout)" + } + } +} + +# +# Lookup a specific C++ function and print the demangled type. +# This form accepts the demangled type as a regexp. +# + +proc info_func_regexp { name demangled } { + global gdb_prompt + + send_gdb "info function $name\n" + gdb_expect { + -re ".*File .*:\r\n(class |)$demangled\r\n.*$gdb_prompt $" { + pass "info function for \"$name\"" + } + -re ".*$gdb_prompt $" { + fail "info function for \"$name\"" + } + timeout { + fail "info function for \"$name\" (timeout)" + } + } +} + +# +# Lookup a specific C++ function and print the demangled type. +# This form accepts the demangled type as a literal string. +# + +proc info_func { name demangled } { + info_func_regexp "$name" [string_to_regexp "$demangled"] +} + +# +# Print the address of a function. +# This checks that I can lookup a fully qualified C++ function. +# This also checks the argument types on the return string. + +# Note: carlton/2003-01-16: If you modify this, make a corresponding +# modification to print_addr_2_kfail. + +proc print_addr_2 { name good } { + global gdb_prompt + global hex + + set good_pattern [string_to_regexp $good] + + send_gdb "print &'$name'\n" + gdb_expect { + -re ".* = .* $hex <$good_pattern>\r\n$gdb_prompt $" { + pass "print &'$name'" + } + -re ".*$gdb_prompt $" { + fail "print &'$name'" + } + timeout { + fail "print &'$name' (timeout)" + } + } +} + +# NOTE: carlton/2003-01-16: hairyfunc5-6 fail on GCC 3.x (for at least +# x=1 and x=2.1). So I'm modifying print_addr_2 to accept a failure +# condition. FIXME: It would be nice if the failure condition were +# conditional on the compiler version, but I'm not sufficiently +# motivated. I did hardwire in the versions of char * and int *, +# which will give some compiler-specificity to the failure. + +proc print_addr_2_kfail { name good bad bugid } { + global gdb_prompt + global hex + + set good_pattern [string_to_regexp $good] + set bad_pattern [string_to_regexp $bad] + + send_gdb "print &'$name'\n" + gdb_expect { + -re ".* = .* $hex <$good_pattern>\r\n$gdb_prompt $" { + pass "print &'$name'" + } + -re ".* = .* $hex <$bad_pattern>\r\n$gdb_prompt $" { + kfail $bugid "print &'$name'" + } + -re ".*$gdb_prompt $" { + fail "print &'$name'" + } + timeout { + fail "print &'$name' (timeout)" + } + } +} + +# +# Simple interfaces to print_addr_2. +# + +proc print_addr { name } { + print_addr_2 "$name" "$name" +} + +# +# Test name demangling for operators. +# +# The '(' at the end of each regex input pattern is so that we match only +# the one we are looking for. I.E. "operator&" would match both +# "operator&(foo &)" and "operator&&(foo &)". +# +# gdb-gnats bug gdb/18: +# "gdb can't parse "info func operator*" or "info func operator\*". +# The star in "operator*" is interpreted as a regexp, but the "\*" +# in "operator\*" is not a legal operator. +# + +proc test_lookup_operator_functions {} { + global dm_operator_comma + global dm_type_char_star + global dm_type_char_star_quoted + global dm_type_foo_ref + global dm_type_void + global dm_type_void_star + + # operator* requires quoting so that GDB does not treat it as a regexp. + info_func "operator\\*(" "void foo::operator*($dm_type_foo_ref);" + info_func "operator%(" "void foo::operator%($dm_type_foo_ref);" + info_func "operator-(" "void foo::operator-($dm_type_foo_ref);" + info_func "operator>>(" "void foo::operator>>($dm_type_foo_ref);" + info_func "operator!=(" "void foo::operator!=($dm_type_foo_ref);" + info_func "operator>(" "void foo::operator>($dm_type_foo_ref);" + info_func "operator>=(" "void foo::operator>=($dm_type_foo_ref);" + info_func "operator|(" "void foo::operator|($dm_type_foo_ref);" + info_func "operator&&(" "void foo::operator&&($dm_type_foo_ref);" + info_func "operator!(" "void foo::operator!($dm_type_void);" + info_func "operator++(" "void foo::operator++(int);" + info_func "operator=(" "void foo::operator=($dm_type_foo_ref);" + info_func "operator+=(" "void foo::operator+=($dm_type_foo_ref);" + # operator*= requires quoting so that GDB does not treat it as a regexp. + info_func "operator\\*=(" "void foo::operator*=($dm_type_foo_ref);" + info_func "operator%=(" "void foo::operator%=($dm_type_foo_ref);" + info_func "operator>>=(" "void foo::operator>>=($dm_type_foo_ref);" + info_func "operator|=(" "void foo::operator|=($dm_type_foo_ref);" + info_func "operator$dm_operator_comma\(" \ + "void foo::operator$dm_operator_comma\($dm_type_foo_ref);" + info_func "operator/(" "void foo::operator/($dm_type_foo_ref);" + info_func "operator+(" "void foo::operator+($dm_type_foo_ref);" + info_func "operator<<(" "void foo::operator<<($dm_type_foo_ref);" + info_func "operator==(" "void foo::operator==($dm_type_foo_ref);" + info_func "operator<(" "void foo::operator<($dm_type_foo_ref);" + info_func "operator<=(" "void foo::operator<=($dm_type_foo_ref);" + info_func "operator&(" "void foo::operator&($dm_type_foo_ref);" + info_func "operator^(" "void foo::operator^($dm_type_foo_ref);" + info_func "operator||(" "void foo::operator||($dm_type_foo_ref);" + info_func "operator~(" "void foo::operator~($dm_type_void);" + info_func "operator--(" "void foo::operator--(int);" + info_func "operator->(" "foo *foo::operator->($dm_type_void);" + info_func "operator-=(" "void foo::operator-=($dm_type_foo_ref);" + info_func "operator/=(" "void foo::operator/=($dm_type_foo_ref);" + info_func "operator<<=(" "void foo::operator<<=($dm_type_foo_ref);" + info_func "operator&=(" "void foo::operator&=($dm_type_foo_ref);" + info_func "operator^=(" "void foo::operator^=($dm_type_foo_ref);" + # operator->* requires quoting so that GDB does not treat it as a regexp. + info_func "operator->\\*(" "void foo::operator->*($dm_type_foo_ref);" + + # operator[] needs double backslashes, so that a single backslash + # will be sent to GDB, preventing the square brackets from being + # evaluated as a regular expression. + info_func "operator\\\[\\\](" "void foo::operator\[\]($dm_type_foo_ref);" + + # These are gnarly because they might end with 'static'. + set dm_type_void_star_regexp [string_to_regexp $dm_type_void_star] + info_func_regexp "operator new(" "void \\*foo::operator new\\(.*\\)(| static);" + info_func_regexp "operator delete(" "void foo::operator delete\\($dm_type_void_star_regexp\\)(| static);" + + info_func "operator int(" "int foo::operator int($dm_type_void);" + info_func "operator()(" "void foo::operator()($dm_type_foo_ref);" + info_func "operator $dm_type_char_star_quoted\(" \ + "char *foo::operator $dm_type_char_star\($dm_type_void);" + +} + + +proc test_paddr_operator_functions {} { + global hex + global hp_aCC_compiler + global dm_operator_comma + global dm_type_char_star + global dm_type_foo_ref + global dm_type_long_star + global dm_type_unsigned_int + global dm_type_void + global dm_type_void_star + + print_addr "foo::operator*($dm_type_foo_ref)" + print_addr "foo::operator%($dm_type_foo_ref)" + print_addr "foo::operator-($dm_type_foo_ref)" + print_addr "foo::operator>>($dm_type_foo_ref)" + print_addr "foo::operator!=($dm_type_foo_ref)" + print_addr "foo::operator>($dm_type_foo_ref)" + print_addr "foo::operator>=($dm_type_foo_ref)" + print_addr "foo::operator|($dm_type_foo_ref)" + print_addr "foo::operator&&($dm_type_foo_ref)" + print_addr "foo::operator!($dm_type_void)" + print_addr "foo::operator++(int)" + print_addr "foo::operator=($dm_type_foo_ref)" + print_addr "foo::operator+=($dm_type_foo_ref)" + print_addr "foo::operator*=($dm_type_foo_ref)" + print_addr "foo::operator%=($dm_type_foo_ref)" + print_addr "foo::operator>>=($dm_type_foo_ref)" + print_addr "foo::operator|=($dm_type_foo_ref)" + print_addr "foo::operator$dm_operator_comma\($dm_type_foo_ref)" + print_addr "foo::operator/($dm_type_foo_ref)" + print_addr "foo::operator+($dm_type_foo_ref)" + print_addr "foo::operator<<($dm_type_foo_ref)" + print_addr "foo::operator==($dm_type_foo_ref)" + print_addr "foo::operator<($dm_type_foo_ref)" + print_addr "foo::operator<=($dm_type_foo_ref)" + print_addr "foo::operator&($dm_type_foo_ref)" + print_addr "foo::operator^($dm_type_foo_ref)" + print_addr "foo::operator||($dm_type_foo_ref)" + print_addr "foo::operator~($dm_type_void)" + print_addr "foo::operator--(int)" + print_addr "foo::operator->($dm_type_void)" + print_addr "foo::operator-=($dm_type_foo_ref)" + print_addr "foo::operator/=($dm_type_foo_ref)" + print_addr "foo::operator<<=($dm_type_foo_ref)" + print_addr "foo::operator&=($dm_type_foo_ref)" + print_addr "foo::operator^=($dm_type_foo_ref)" + print_addr "foo::operator->*($dm_type_foo_ref)" + print_addr "foo::operator\[\]($dm_type_foo_ref)" + print_addr "foo::operator()($dm_type_foo_ref)" + + gdb_test "print &'foo::operator new'" \ + " = .* $hex <foo::operator new\\(.*\\)(| static)>" + if { !$hp_aCC_compiler } { + print_addr "foo::operator delete($dm_type_void_star)" + } else { + gdb_test "print &'foo::operator delete($dm_type_void_star) static'" \ + " = .*(0x\[0-9a-f\]+|) <foo::operator delete.*>" + } + + print_addr "foo::operator int($dm_type_void)" + print_addr "foo::operator $dm_type_char_star\($dm_type_void)" +} + +# +# Test overloaded functions (1 arg). +# + +proc test_paddr_overloaded_functions {} { + global dm_type_unsigned_int + global dm_type_void + + print_addr "overload1arg($dm_type_void)" + print_addr "overload1arg(char)" + print_addr "overload1arg(signed char)" + print_addr "overload1arg(unsigned char)" + print_addr "overload1arg(short)" + print_addr "overload1arg(unsigned short)" + print_addr "overload1arg(int)" + print_addr "overload1arg($dm_type_unsigned_int)" + print_addr "overload1arg(long)" + print_addr "overload1arg(unsigned long)" + print_addr "overload1arg(float)" + print_addr "overload1arg(double)" + + print_addr "overloadargs(int)" + print_addr "overloadargs(int, int)" + print_addr "overloadargs(int, int, int)" + print_addr "overloadargs(int, int, int, int)" + print_addr "overloadargs(int, int, int, int, int)" + print_addr "overloadargs(int, int, int, int, int, int)" + print_addr "overloadargs(int, int, int, int, int, int, int)" + print_addr "overloadargs(int, int, int, int, int, int, int, int)" + print_addr "overloadargs(int, int, int, int, int, int, int, int, int)" + print_addr "overloadargs(int, int, int, int, int, int, int, int, int, int)" + print_addr "overloadargs(int, int, int, int, int, int, int, int, int, int, int)" +} + +proc test_paddr_hairy_functions {} { + global gdb_prompt + global hex + global dm_type_char_star + global dm_type_int_star + global dm_type_long_star + + print_addr_2 "hairyfunc1" "hairyfunc1(int)" + print_addr_2 "hairyfunc2" "hairyfunc2(int (*)($dm_type_char_star))" + print_addr_2 "hairyfunc3" "hairyfunc3(int (*)(short (*)($dm_type_long_star)))" + print_addr_2 "hairyfunc4" "hairyfunc4(int (*)(short (*)($dm_type_char_star)))" + + # gdb-gnats bug gdb/19: + # "gdb v3 demangler fails on hairyfunc5 hairyfunc6 hairyfunc7" + print_addr_2_kfail "hairyfunc5" "hairyfunc5(int (*(*)($dm_type_char_star))(long))" "hairyfunc5(int (*)(long) (*)(char*))" "gdb/19" + print_addr_2_kfail "hairyfunc6" "hairyfunc6(int (*(*)($dm_type_int_star))(long))" "hairyfunc6(int (*)(long) (*)(int*))" "gdb/19" + print_addr_2_kfail "hairyfunc7" "hairyfunc7(int (*(*)(int (*)($dm_type_char_star)))(long))" "hairyfunc7(int (*)(long) (*)(int (*)(char*)))" "gdb/19" +} + +proc do_tests {} { + global prms_id + global bug_id + global subdir + global objdir + global srcdir + global binfile + global gdb_prompt + + set prms_id 0 + set bug_id 0 + + # Start with a fresh gdb. + + gdb_exit + gdb_start + gdb_reinitialize_dir $srcdir/$subdir + gdb_load $binfile + + send_gdb "set language c++\n" + gdb_expect -re "$gdb_prompt $" + send_gdb "set width 0\n" + gdb_expect -re "$gdb_prompt $" + + runto_main + + probe_demangler + test_paddr_overloaded_functions + test_paddr_operator_functions + test_paddr_hairy_functions + test_lookup_operator_functions +} + +do_tests diff --git a/gdb/testsuite/gdb.cp/ctti.exp b/gdb/testsuite/gdb.cp/ctti.exp new file mode 100644 index 0000000..96e9fcf --- /dev/null +++ b/gdb/testsuite/gdb.cp/ctti.exp @@ -0,0 +1,269 @@ +# Copyright 1998, 1999, 2001 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + + +# This file is part of the gdb testsuite +# file written by Elena Zannoni (ezannoni@cygnus.com) +# +# source files cttiadd.cc, cttiadd1.cc, cttiadd2.cc, cttiadd3.cc +# + + +if $tracelevel then { + strace $tracelevel +} + +if { [skip_cplus_tests] } { continue } + +# Check to see if we have an executable to test. If not, then either we +# haven't tried to compile one, or the compilation failed for some reason. +# In either case, just notify the user and skip the tests in this file. + +set testfile "cttiadd" +set srcfile ${testfile}.cc +set srcfile1 ${testfile}1.cc +set srcfile2 ${testfile}2.cc +set srcfile3 ${testfile}3.cc +set binfile ${objdir}/${subdir}/${testfile} + +if [get_compiler_info ${binfile} "c++"] { + return -1; +} + +if { $gcc_compiled } then { continue } + +#if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${srcdir}/${subdir}/${srcfile1} ${srcdir}/${subdir}/${srcfile2} ${srcdir}/${subdir}/${srcfile3}" "${binfile}" executable {debug c++}] != "" } { +# gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +#} + +set cmdline "$CXX_FOR_TARGET ${srcdir}/${subdir}/${srcfile} ${srcdir}/${subdir}/${srcfile1} ${srcdir}/${subdir}/${srcfile2} ${srcdir}/${subdir}/${srcfile3} -g -o ${binfile}" + +remote_exec build $cmdline + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + + + +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + + +send_gdb "n\n" +gdb_expect { + -re "$decimal.*i = 2;.*$gdb_prompt $" { + pass "next " + } + -re ".*$gdb_prompt $" { fail "next " } + timeout { fail "next " } + } + + +send_gdb "n\n" +gdb_expect { + -re "$decimal.*f = 4.5;.*$gdb_prompt $" { + pass "next " + } + -re ".*$gdb_prompt $" { fail "next " } + timeout { fail "next " } + } + +send_gdb "n\n" +gdb_expect { + -re "$decimal.*c = add\\(c, c\\);.*$gdb_prompt $" { + pass "next " + } + -re ".*$gdb_prompt $" { fail "next " } + timeout { fail "next " } + } + +send_gdb "n\n" +gdb_expect { + -re "$decimal.*i = add\\(i, i\\);.*$gdb_prompt $" { + pass "next " + } + -re ".*$gdb_prompt $" { fail "next " } + timeout { fail "next " } + } + +send_gdb "n\n" +gdb_expect { + -re "$decimal.*f = add\\(f, f\\);.*$gdb_prompt $" { + pass "next " + } + -re ".*$gdb_prompt $" { fail "next " } + timeout { fail "next " } + } + +send_gdb "n\n" +gdb_expect { + -re "$decimal.*add1\\(\\);.*$gdb_prompt $" { + pass "next " + } + -re ".*$gdb_prompt $" { fail "next " } + timeout { fail "next " } + } + +send_gdb "print c\n" +gdb_expect { + -re ".$decimal = -62.*\r\n$gdb_prompt $" { + pass "print value of c" + } + -re ".*$gdb_prompt $" { fail "print value of c" } + timeout { fail "(timeout) print value of c" } + } + + +send_gdb "print f\n" +gdb_expect { + -re ".$decimal = 9\r\n$gdb_prompt $" { + pass "print value of f" + } + -re ".*$gdb_prompt $" { fail "print value of f" } + timeout { fail "(timeout) print value of f" } + } + + +send_gdb "print i\n" +gdb_expect { + -re ".$decimal = 4\r\n$gdb_prompt $" { + pass "print value of i" + } + -re ".*$gdb_prompt $" { fail "print value of i" } + timeout { fail "(timeout) print value of i" } + } + + + +send_gdb "print add<int>(2,2)\n" +gdb_expect { + -re ".$decimal = 4\r\n$gdb_prompt $" { + pass "print value of add<int>(2,2)" + } + -re ".*$gdb_prompt $" { fail "print value of add<int>(2,2)" } + timeout { fail "(timeout) print value of add<int>(2,2)" } + } + +send_gdb "print add<float>(2.3,2.3)\n" +gdb_expect { + -re ".$decimal = 4\\.5\[0-9\]+\r\n$gdb_prompt $" { + pass "print value of add<float>(2.3,2.3)" + } + -re ".*$gdb_prompt $" { fail "print value of add<float>(2.3,2.3)" } + timeout { fail "(timeout) print value of add<float>(2.3,2.3)" } + } + +send_gdb "print add<char>('A','A')\n" +gdb_expect { + -re ".$decimal = -126.*202.\r\n$gdb_prompt $" { + pass "print value of add<char>('A','A')" + } + -re ".*$gdb_prompt $" { fail "print value of add<char>('A','A')" } + timeout { fail "(timeout) print value of add<char>('A','A')" } + } + + +send_gdb "print add2<int>(2,2)\n" +gdb_expect { + -re ".$decimal = 4\r\n$gdb_prompt $" { + pass "print value of add2<int>(2,2)" + } + -re ".*$gdb_prompt $" { fail "print value of add2<int>(2,2)" } + timeout { fail "(timeout) print value of add2<int>(2,2)" } + } + +send_gdb "print add2<float>(2.3,2.3)\n" +gdb_expect { + -re ".$decimal = 4\\.5\[0-9\]+\r\n$gdb_prompt $" { + pass "print value of add2<float>(2.3,2.3)" + } + -re ".*$gdb_prompt $" { fail "print value of add2<float>(2.3,2.3)" } + timeout { fail "(timeout) print value of add2<float>(2.3,2.3)" } + } + +send_gdb "print add2<char>('A','A')\n" +gdb_expect { + -re ".$decimal = -126.*202.\r\n$gdb_prompt $" { + pass "print value of add2<char>('A','A')" + } + -re ".*$gdb_prompt $" { fail "print value of add2<char>('A','A')" } + timeout { fail "(timeout) print value of add2<char>('A','A')" } + } + +send_gdb "print add3<int>(2,2)\n" +gdb_expect { + -re ".$decimal = 4\r\n$gdb_prompt $" { + pass "print value of add3<int>(2,2)" + } + -re ".*$gdb_prompt $" { fail "print value of add3<int>(2,2)" } + timeout { fail "(timeout) print value of add3<int>(2,2)" } + } + +send_gdb "print add3<float>(2.3,2.3)\n" +gdb_expect { + -re ".$decimal = 4\\.5\[0-9\]+\r\n$gdb_prompt $" { + pass "print value of add3<float>(2.3,2.3)" + } + -re ".*$gdb_prompt $" { fail "print value of add3<float>(2.3,2.3)" } + timeout { fail "(timeout) print value of add3<float>(2.3,2.3)" } + } + +send_gdb "print add3<char>('A','A')\n" +gdb_expect { + -re ".$decimal = -126.*202.\r\n$gdb_prompt $" { + pass "print value of add3<char>('A','A')" + } + -re ".*$gdb_prompt $" { fail "print value of add3<char>('A','A')" } + timeout { fail "(timeout) print value of add3<char>('A','A')" } + } + +send_gdb "print add4<int>(2,2)\n" +gdb_expect { + -re ".$decimal = 4\r\n$gdb_prompt $" { + pass "print value of add4<int>(2,2)" + } + -re ".*$gdb_prompt $" { fail "print value of add4<int>(2,2)" } + timeout { fail "(timeout) print value of add4<int>(2,2)" } + } + +send_gdb "print add4<float>(2.3,2.3)\n" +gdb_expect { + -re ".$decimal = 4\\.5\[0-9\]+\r\n$gdb_prompt $" { + pass "print value of add4<float>(2.3,2.3)" + } + -re ".*$gdb_prompt $" { fail "print value of add4<float>(2.3,2.3)" } + timeout { fail "(timeout) print value of add4<float>(2.3,2.3)" } + } + +send_gdb "print add4<char>('A','A')\n" +gdb_expect { + -re ".$decimal = -126.*202.\r\n$gdb_prompt $" { + pass "print value of add4<char>('A','A')" + } + -re ".*$gdb_prompt $" { fail "print value of add4<char>('A','A')" } + timeout { fail "(timeout) print value of add4<char>('A','A')" } + } + + +gdb_exit +return 0 diff --git a/gdb/testsuite/gdb.cp/cttiadd.cc b/gdb/testsuite/gdb.cp/cttiadd.cc new file mode 100644 index 0000000..1f50fae --- /dev/null +++ b/gdb/testsuite/gdb.cp/cttiadd.cc @@ -0,0 +1,29 @@ +template<class T> T add(T v1, T v2) +{ + T v3; + v3 = v1; + v3 += v2; + return v3; + } + +int main() +{ + char c; + int i; + float f; + extern void add1(); + extern void subr2(); + extern void subr3(); + + c = 'a'; + i = 2; + f = 4.5; + + c = add(c, c); + i = add(i, i); + f = add(f, f); + + add1(); + subr2(); + subr3(); +} diff --git a/gdb/testsuite/gdb.cp/cttiadd1.cc b/gdb/testsuite/gdb.cp/cttiadd1.cc new file mode 100644 index 0000000..7113ece --- /dev/null +++ b/gdb/testsuite/gdb.cp/cttiadd1.cc @@ -0,0 +1,16 @@ +template<class T> T add(T v1, T v2); + +void add1() +{ + char c; + int i; + float f; + + c = 'b'; + i = 3; + f = 6.5; + + c = add(c, c); + i = add(i, i); + f = add(f, f); +} diff --git a/gdb/testsuite/gdb.cp/cttiadd2.cc b/gdb/testsuite/gdb.cp/cttiadd2.cc new file mode 100644 index 0000000..d0d9891 --- /dev/null +++ b/gdb/testsuite/gdb.cp/cttiadd2.cc @@ -0,0 +1,22 @@ +template<class T> T add2(T v1, T v2) +{ + T v3; + v3 = v1; + v3 += v2; + return v3; +} + +void subr2() +{ + char c; + int i; + float f; + + c = 'b'; + i = 3; + f = 6.5; + + c = add2(c, c); + i = add2(i, i); + f = add2(f, f); +} diff --git a/gdb/testsuite/gdb.cp/cttiadd3.cc b/gdb/testsuite/gdb.cp/cttiadd3.cc new file mode 100644 index 0000000..7ba1b01 --- /dev/null +++ b/gdb/testsuite/gdb.cp/cttiadd3.cc @@ -0,0 +1,33 @@ +template<class T> T add3(T v1, T v2) +{ + T v3; + v3 = v1; + v3 += v2; + return v3; +} + +template<class T> T add4(T v1, T v2) +{ + T v3; + v3 = v1; + v3 += v2; + return v3; +} + +void subr3() +{ + char c; + int i; + float f; + + c = 'b'; + i = 3; + f = 6.5; + + c = add3(c, c); + i = add3(i, i); + f = add3(f, f); + c = add4(c, c); + i = add4(i, i); + f = add4(f, f); +} diff --git a/gdb/testsuite/gdb.cp/demangle.exp b/gdb/testsuite/gdb.cp/demangle.exp new file mode 100644 index 0000000..7bd9fc5 --- /dev/null +++ b/gdb/testsuite/gdb.cp/demangle.exp @@ -0,0 +1,1582 @@ +# Copyright (C) 1992, 1997, 1999, 2003 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# This file was written by Fred Fish. (fnf@cygnus.com) + +if $tracelevel then { + strace $tracelevel +} + +if { [skip_cplus_tests] } { continue } + +### The demangling style we last sent to GDB. +set current_demangling_style none + +### Set GDB's current demangling style to STYLE. Subsequent calls to +### test_demangle will include STYLE in the test name when reporting +### passes and failures. +proc set_demangling_style {style} { + global gdb_prompt + global current_demangling_style + + send_gdb "set demangle-style $style\n" + gdb_expect { + -re "set demangle-style $style\[\r\n\]+$gdb_prompt $" { + pass "$style: set demangle-style" + } + -re ".*$gdb_prompt $" { + fail "$style: set demangle-style" + error "set_demangling_style: set style" + } + timeout { + fail "$style: set demangle-style (timeout)" + error "set_demangling_style: set style" + } + } + + send_gdb "show demangle-style\n" + gdb_expect { + -re "The current C\[+\]+ demangling style is \"$style\".\r\n$gdb_prompt $" { + pass "$style: check demangling style" + } + -re ".*$gdb_prompt $" { + fail "$style: check demangling style" + error "set_demangling_style: check style" + } + timeout { + fail "$style: check demangling style (timeout)" + error "set_demangling_style: check style" + } + } + + set current_demangling_style $style +} + + +### Utility function for test_demangling and test_demangling_exact. +proc test_demangling_core {tester test result} { + global current_demangling_style + + if {! [regexp {^([^ ]+): (.+)$} $test dummy style name]} { + error "bad test name passed to test_demangling" + } + + if {[string compare $style $current_demangling_style]} { + set_demangling_style $style + } + + $tester "maintenance demangle $name" $result $test +} + +### Demangle an identifier, and check that the result matches a pattern. +### +### TEST should be of the form "STYLE: NAME", where STYLE is the name +### of a demangling style (like "gnu" or "arm"), and NAME is a mangled +### identifier to demangle. Pass when the result matches the regular +### expression RESULT. Report passes and fails using TEST as the name +### of the test. +### +### Why don't we just pass the STYLE and NAME as two separate +### arguments, or let the style be a global variable? That would be +### cleaner. However, doing it this way means that: +### +### 1) the name of the test, as recorded in the summary and log, +### appears verbatim in the script, and +### +### 2) that test names are unique, even though we try to demangle the same +### identifiers using several different mangling styles. +### +### This makes it a lot easier for people tracking down failures to +### find the one they care about. + +proc test_demangling {test result} { + test_demangling_core gdb_test $test $result +} + +### Like test_demangling, above, except that RESULT is not a regexp, +### but a string that must match exactly. + +proc test_demangling_exact {test result} { + test_demangling_core gdb_test_exact $test $result +} + + + +# +# Test gnu style name demangling +# + +proc test_gnu_style_demangling {} { + global gdb_prompt + + test_demangling "gnu: Abort__FP6EditoriPCc" \ + "Abort\[(\]+Editor \[*\]+, int, (const char|char const) \[*\]+\[)\]+" + test_demangling_exact "gnu: AddAlignment__9ivTSolverUiP12ivInteractorP7ivTGlue" "ivTSolver::AddAlignment(unsigned int, ivInteractor *, ivTGlue *)" + test_demangling "gnu: Append__15NameChooserViewPCc" \ + "NameChooserView::Append\[(\]+(const char|char const) \[*\]+\[)\]+" + test_demangling_exact "gnu: ArrowheadIntersects__9ArrowLineP9ArrowheadR6BoxObjP7Graphic" "ArrowLine::ArrowheadIntersects(Arrowhead *, BoxObj &, Graphic *)" + test_demangling_exact "gnu: AtEnd__13ivRubberGroup" "ivRubberGroup::AtEnd(void)" + test_demangling_exact "gnu: BgFilter__9ivTSolverP12ivInteractor" "ivTSolver::BgFilter(ivInteractor *)" + test_demangling "gnu: BitPatterntoa__FRC10BitPatternccc" \ + "BitPatterntoa\[(\]+(const BitPattern|BitPattern const) &, char, char, char\[)\]+" + test_demangling_exact "gnu: Check__6UArrayi" "UArray::Check(int)" + test_demangling_exact "gnu: CoreConstDecls__8TextCodeR7ostream" "TextCode::CoreConstDecls(ostream &)" + test_demangling_exact "gnu: Detach__8StateVarP12StateVarView" "StateVar::Detach(StateVarView *)" + test_demangling_exact "gnu: Done__9ComponentG8Iterator" "Component::Done(Iterator)" + test_demangling "gnu: DrawDestinationTransformedImage__FP7_XImageiiT0iiUlUiiiUiUlUlP4_XGCRC13ivTransformeriiii" \ + "DrawDestinationTransformedImage\[(\]+_XImage \[*\]+, int, int, _XImage \[*\]+, int, int, unsigned long, unsigned int, int, int, unsigned int, unsigned long, unsigned long, _XGC \[*\]+, (const ivTransformer|ivTransformer const) &, int, int, int, int\[)\]+" + + test_demangling "gnu: Edit__12StringEditorPCcii" \ + "StringEditor::Edit\[(\]+(const char|char const) \[*\]+, int, int\[)\]+" + test_demangling_exact "gnu: Effect__11RelateManipR7ivEvent" "RelateManip::Effect(ivEvent &)" + test_demangling "gnu: FilterName__FPCc" \ + "FilterName\[(\]+(const char|char const) \[*\]+\[)\]+" + test_demangling "gnu: Filter__6PSTextPCci" \ + "PSText::Filter\[(\]+(const char|char const) \[*\]+, int\[)\]+" + test_demangling "gnu: FindColor__7CatalogPCciii" \ + "Catalog::FindColor\[(\]+(const char|char const) \[*\]+, int, int, int\[)\]+" + test_demangling_exact "gnu: FindFixed__FRP4CNetP4CNet" "FindFixed(CNet *&, CNet *)" + test_demangling "gnu: FindFont__7CatalogPCcN21" \ + "Catalog::FindFont\[(\]+(const char|char const) \[*\]+, (const char|char const) \[*\]+, (const char|char const) \[*\]+\[)\]+" + test_demangling_exact "gnu: Fix48_abort__FR8twolongs" "Fix48_abort(twolongs &)" + test_demangling_exact "gnu: GetBarInfo__15iv2_6_VScrollerP13ivPerspectiveRiT2" "iv2_6_VScroller::GetBarInfo(ivPerspective *, int &, int &)" + test_demangling_exact "gnu: GetBgColor__C9ivPainter" "ivPainter::GetBgColor(void) const" + + test_demangling "gnu: Iisdouble__FPC6IntRep" \ + "Iisdouble\[(\]+(const IntRep|IntRep const) \[*\]+\[)\]+" + test_demangling_exact "gnu: InsertBody__15H_PullrightMenuii" "H_PullrightMenu::InsertBody(int, int)" + test_demangling_exact "gnu: InsertCharacter__9TextManipc" "TextManip::InsertCharacter(char)" + + test_demangling_exact "gnu: InsertToplevel__7ivWorldP12ivInteractorT1" "ivWorld::InsertToplevel(ivInteractor *, ivInteractor *)" + test_demangling_exact "gnu: InsertToplevel__7ivWorldP12ivInteractorT1iiUi" "ivWorld::InsertToplevel(ivInteractor *, ivInteractor *, int, int, unsigned int)" + test_demangling "gnu: IsADirectory__FPCcR4stat" \ + "IsADirectory\[(\]+(const char|char const) \[*\]+, stat &\[)\]+" + test_demangling_exact "gnu: IsAGroup__FP11GraphicViewP11GraphicComp" "IsAGroup(GraphicView *, GraphicComp *)" + test_demangling_exact "gnu: IsA__10ButtonCodeUl" "ButtonCode::IsA(unsigned long)" + + test_demangling_exact "gnu: ReadName__FR7istreamPc" "ReadName(istream &, char *)" + test_demangling_exact "gnu: Redraw__13StringBrowseriiii" "StringBrowser::Redraw(int, int, int, int)" + test_demangling_exact "gnu: Rotate__13ivTransformerf" "ivTransformer::Rotate(float)" + test_demangling_exact "gnu: Rotated__C13ivTransformerf" "ivTransformer::Rotated(float) const" + test_demangling_exact "gnu: Round__Ff" "Round(float)" + + test_demangling_exact "gnu: SetExport__16MemberSharedNameUi" "MemberSharedName::SetExport(unsigned int)" + test_demangling_exact "gnu: Set__14ivControlState13ControlStatusUi" "ivControlState::Set(ControlStatus, unsigned int)" + test_demangling_exact "gnu: Set__5DFacePcii" "DFace::Set(char *, int, int)" + + test_demangling_exact "gnu: VConvert__9ivTSolverP12ivInteractorRP8TElementT2" "ivTSolver::VConvert(ivInteractor *, TElement *&, TElement *&)" + test_demangling_exact "gnu: VConvert__9ivTSolverP7ivTGlueRP8TElement" "ivTSolver::VConvert(ivTGlue *, TElement *&)" + test_demangling_exact "gnu: VOrder__9ivTSolverUiRP12ivInteractorT2" "ivTSolver::VOrder(unsigned int, ivInteractor *&, ivInteractor *&)" + test_demangling "gnu: Valid__7CatalogPCcRP4Tool" \ + "Catalog::Valid\[(\]+(const char|char const) \[*\]+, Tool \[*\]+&\[)\]+" + test_demangling_exact "gnu: _10PageButton\$__both" "PageButton::__both" + test_demangling_exact "gnu: _3RNG\$singleMantissa" "RNG::singleMantissa" + test_demangling_exact "gnu: _5IComp\$_release" "IComp::_release" + test_demangling_exact "gnu: _\$_10BitmapComp" "BitmapComp::~BitmapComp(void)" + + test_demangling_exact "gnu: _\$_9__io_defs" "__io_defs::~__io_defs(void)" + test_demangling_exact "gnu: _\$_Q23foo3bar" "foo::bar::~bar(void)" + test_demangling_exact "gnu: _\$_Q33foo3bar4bell" "foo::bar::bell::~bell(void)" + test_demangling_exact "gnu: __10ivTelltaleiP7ivGlyph" "ivTelltale::ivTelltale(int, ivGlyph *)" + test_demangling_exact "gnu: __10ivViewportiP12ivInteractorUi" "ivViewport::ivViewport(int, ivInteractor *, unsigned int)" + test_demangling_exact "gnu: __10ostrstream" "ostrstream::ostrstream(void)" + test_demangling_exact "gnu: __10ostrstreamPcii" "ostrstream::ostrstream(char *, int, int)" + test_demangling "gnu: __11BasicDialogiPCcP13ivButtonStateN22Ui" \ + "BasicDialog::BasicDialog\[(\]+int, (const char|char const) \[*\]+, ivButtonState \[*\]+, (const char|char const) \[*\]+, (const char|char const) \[*\]+, unsigned int\[)\]+" + test_demangling_exact "gnu: __11BitmapTablei" "BitmapTable::BitmapTable(int)" + test_demangling_exact "gnu: __12ViewportCodeP12ViewportComp" "ViewportCode::ViewportCode(ViewportComp *)" + test_demangling "gnu: __12iv2_6_BorderiPCci" \ + "iv2_6_Border::iv2_6_Border\[(\]+int, (const char|char const) \[*\]+, int\[)\]+" + test_demangling_exact "gnu: __12iv2_6_Borderii" "iv2_6_Border::iv2_6_Border(int, int)" + test_demangling "gnu: __12ivBackgroundiP7ivGlyphPC7ivColor" \ + "ivBackground::ivBackground\[(\]+int, ivGlyph \[*\]+, (const ivColor|ivColor const) \[*\]+\[)\]+" + test_demangling_exact "gnu: __12ivBreak_Listl" "ivBreak_List::ivBreak_List(long)" + test_demangling "gnu: __14TextInteractoriPCcUi" \ + "TextInteractor::TextInteractor\[(\]+int, (const char|char const) \[*\]+, unsigned int\[)\]+" + test_demangling_exact "gnu: __14iv2_6_MenuItemiP12ivInteractor" "iv2_6_MenuItem::iv2_6_MenuItem(int, ivInteractor *)" + test_demangling "gnu: __14iv2_6_MenuItemiPCcP12ivInteractor" \ + "iv2_6_MenuItem::iv2_6_MenuItem\[(\]+int, (const char|char const) \[*\]+, ivInteractor \[*\]+\[)\]+" + + test_demangling_exact "gnu: __20DisplayList_IteratorR11DisplayList" "DisplayList_Iterator::DisplayList_Iterator(DisplayList &)" + test_demangling_exact "gnu: __3fooRT0" "foo::foo(foo &)" + test_demangling_exact "gnu: __3fooiN31" "foo::foo(int, int, int, int)" + test_demangling "gnu: __3fooiPCc" \ + "foo::foo\[(\]+int, (const char|char const) \[*\]+\[)\]+" + test_demangling_exact "gnu: __3fooiRT0iT2iT2" "foo::foo(int, foo &, int, foo &, int, foo &)" + test_demangling "gnu: __6GetOptiPPcPCc" \ + "GetOpt::GetOpt\[(\]+int, char \[*\]+\[*\]+, (const char|char const) \[*\]+\[)\]+" + test_demangling_exact "gnu: __6KeyMapPT0" "KeyMap::KeyMap(KeyMap *)" + test_demangling "gnu: __7ivWorldPCcRiPPcPC12ivOptionDescPC14ivPropertyData" \ + "ivWorld::ivWorld\[(\]+(const char|char const) \[*\]+, int &, char \[*\]+\[*\]+, (const ivOptionDesc|ivOptionDesc const) \[*\]+, (const ivPropertyData|ivPropertyData const) \[*\]+\[)\]+" + test_demangling "gnu: __7procbufPCci" \ + "procbuf::procbuf\[(\]+(const char|char const) \[*\]+, int\[)\]+" + test_demangling_exact "gnu: __8ArrowCmdP6EditorUiUi" "ArrowCmd::ArrowCmd(Editor *, unsigned int, unsigned int)" + + test_demangling_exact "gnu: __9F_EllipseiiiiP7Graphic" "F_Ellipse::F_Ellipse(int, int, int, int, Graphic *)" + test_demangling_exact "gnu: __9FrameDataP9FrameCompi" "FrameData::FrameData(FrameComp *, int)" + test_demangling_exact "gnu: __9HVGraphicP9CanvasVarP7Graphic" "HVGraphic::HVGraphic(CanvasVar *, Graphic *)" + test_demangling_exact "gnu: __Q23foo3bar" "foo::bar::bar(void)" + test_demangling_exact "gnu: __Q33foo3bar4bell" "foo::bar::bell::bell(void)" + test_demangling_exact "gnu: __aa__3fooRT0" "foo::operator&&(foo &)" + test_demangling_exact "gnu: __aad__3fooRT0" "foo::operator&=(foo &)" + test_demangling_exact "gnu: __ad__3fooRT0" "foo::operator&(foo &)" + test_demangling_exact "gnu: __adv__3fooRT0" "foo::operator/=(foo &)" + test_demangling_exact "gnu: __aer__3fooRT0" "foo::operator^=(foo &)" + test_demangling_exact "gnu: __als__3fooRT0" "foo::operator<<=(foo &)" + test_demangling_exact "gnu: __amd__3fooRT0" "foo::operator%=(foo &)" + test_demangling_exact "gnu: __ami__3fooRT0" "foo::operator-=(foo &)" + test_demangling_exact "gnu: __aml__3FixRT0" "Fix::operator*=(Fix &)" + test_demangling_exact "gnu: __aml__5Fix16i" "Fix16::operator*=(int)" + test_demangling_exact "gnu: __aml__5Fix32RT0" "Fix32::operator*=(Fix32 &)" + test_demangling_exact "gnu: __aor__3fooRT0" "foo::operator|=(foo &)" + test_demangling_exact "gnu: __apl__3fooRT0" "foo::operator+=(foo &)" + test_demangling_exact "gnu: __ars__3fooRT0" "foo::operator>>=(foo &)" + + test_demangling_exact "gnu: __as__3fooRT0" "foo::operator=(foo &)" + test_demangling_exact "gnu: __cl__3fooRT0" "foo::operator()(foo &)" + test_demangling_exact "gnu: __cl__6Normal" "Normal::operator()(void)" + test_demangling_exact "gnu: __cl__6Stringii" "String::operator()(int, int)" + test_demangling_exact "gnu: __cm__3fooRT0" "foo::operator, (foo &)" + test_demangling_exact "gnu: __co__3foo" "foo::operator~(void)" + test_demangling_exact "gnu: __dl__3fooPv" "foo::operator delete(void *)" + test_demangling_exact "gnu: __dv__3fooRT0" "foo::operator/(foo &)" + test_demangling_exact "gnu: __eq__3fooRT0" "foo::operator==(foo &)" + test_demangling_exact "gnu: __er__3fooRT0" "foo::operator^(foo &)" + test_demangling_exact "gnu: __ge__3fooRT0" "foo::operator>=(foo &)" + test_demangling_exact "gnu: __gt__3fooRT0" "foo::operator>(foo &)" + test_demangling_exact "gnu: __le__3fooRT0" "foo::operator<=(foo &)" + test_demangling_exact "gnu: __ls__3fooRT0" "foo::operator<<(foo &)" + test_demangling_exact "gnu: __ls__FR7ostreamPFR3ios_R3ios" "operator<<(ostream &, ios &(*)(ios &))" + test_demangling_exact "gnu: __ls__FR7ostreamR3Fix" "operator<<(ostream &, Fix &)" + test_demangling_exact "gnu: __lt__3fooRT0" "foo::operator<(foo &)" + test_demangling_exact "gnu: __md__3fooRT0" "foo::operator%(foo &)" + test_demangling_exact "gnu: __mi__3fooRT0" "foo::operator-(foo &)" + test_demangling_exact "gnu: __ml__3fooRT0" "foo::operator*(foo &)" + test_demangling_exact "gnu: __mm__3fooi" "foo::operator--(int)" + + test_demangling_exact "gnu: __ne__3fooRT0" "foo::operator!=(foo &)" + test_demangling "gnu: __ne__FRC7ComplexT0" \ + "operator!=\[(\]+(const Complex|Complex const) &, (const Complex|Complex const) &\[)\]+" + test_demangling "gnu: __ne__FRC7Complexd" \ + "operator!=\[(\]+(const Complex|Complex const) &, double\[)\]+" + test_demangling "gnu: __ne__FRC9SubStringRC6String" \ + "operator!=\[(\]+(const SubString|SubString const) &, (const String|String const) &\[)\]+" + test_demangling_exact "gnu: __nt__3foo" "foo::operator!(void)" + test_demangling_exact "gnu: __nw__3fooi" "foo::operator new(int)" + test_demangling_exact "gnu: __oo__3fooRT0" "foo::operator||(foo &)" + test_demangling_exact "gnu: __opPc__3foo" "foo::operator char *(void)" + test_demangling_exact "gnu: __opi__3foo" "foo::operator int(void)" + test_demangling_exact "gnu: __or__3fooRT0" "foo::operator|(foo &)" + test_demangling_exact "gnu: __pl__3fooRT0" "foo::operator+(foo &)" + test_demangling_exact "gnu: __pp__3fooi" "foo::operator++(int)" + test_demangling_exact "gnu: __rf__3foo" "foo::operator->(void)" + test_demangling_exact "gnu: __rm__3fooRT0" "foo::operator->*(foo &)" + test_demangling_exact "gnu: __rs__3fooRT0" "foo::operator>>(foo &)" + test_demangling "gnu: __vc__3fooRT0" "foo::operator\\\[\\\]\\(foo &\\)" + test_demangling "gnu: _gsub__6StringRC5RegexPCci" \ + "String::_gsub\[(\]+(const Regex|Regex const) &, (const char|char const) \[*\]+, int\[)\]+" + test_demangling_exact "gnu: _new_Fix__FUs" "_new_Fix(unsigned short)" + + # gcc 2.4.5 (and earlier) style virtual tables. We want to continue to + # correctly demangle these even if newer compilers use a different form. + test_demangling_exact "gnu: _vt.foo" "foo virtual table" + test_demangling_exact "gnu: _vt.foo.bar" "foo::bar virtual table" + test_demangling_exact "gnu: _vt\$foo" "foo virtual table" + test_demangling_exact "gnu: _vt\$foo\$bar" "foo::bar virtual table" + + test_demangling_exact "gnu: append__7ivGlyphPT0" "ivGlyph::append(ivGlyph *)" + test_demangling "gnu: arg__FRC7Complex" \ + "arg\[(\]+(const Complex|Complex const) &\[)\]+" + test_demangling_exact "gnu: clearok__FP7_win_sti" "clearok(_win_st *, int)" + + test_demangling_exact "gnu: complexfunc2__FPFPc_i" "complexfunc2(int (*)(char *))" + test_demangling_exact "gnu: complexfunc3__FPFPFPl_s_i" "complexfunc3(int (*)(short (*)(long *)))" + test_demangling_exact "gnu: complexfunc4__FPFPFPc_s_i" "complexfunc4(int (*)(short (*)(char *)))" + test_demangling_exact "gnu: complexfunc5__FPFPc_PFl_i" "complexfunc5(int (*(*)(char *))(long))" + test_demangling_exact "gnu: complexfunc6__FPFPi_PFl_i" "complexfunc6(int (*(*)(int *))(long))" + test_demangling_exact "gnu: complexfunc7__FPFPFPc_i_PFl_i" "complexfunc7(int (*(*)(int (*)(char *)))(long))" + test_demangling "gnu: contains__C9BitStringRC10BitPattern" \ + "BitString::contains\[(\]+(const BitPattern|BitPattern const) &\[)\]+ const" + test_demangling "gnu: contains__C9BitStringRC12BitSubStringi" \ + "BitString::contains\[(\]+(const BitSubString|BitSubString const) &, int\[)\]+ const" + test_demangling "gnu: contains__C9BitStringRT0" \ + "BitString::contains\[(\]+(const BitString|BitString const) &\[)\]+ const" + test_demangling "gnu: div__FPC6IntRepT0P6IntRep" \ + "div\[(\]+(const IntRep|IntRep const) \[*\]+, (const IntRep|IntRep const) \[*\]+, IntRep \[*\]+\[)\]+" + test_demangling "gnu: div__FPC6IntReplP6IntRep" \ + "div\[(\]+(const IntRep|IntRep const) \[*\]+, long, IntRep \[*\]+\[)\]+" + test_demangling "gnu: div__FRC8RationalT0R8Rational" \ + "div\[(\]+(const Rational|Rational const) &, (const Rational|Rational const) &, Rational &\[)\]+" + test_demangling "gnu: divide__FRC7IntegerT0R7IntegerT2" \ + "divide\[(\]+(const Integer|Integer const) &, (const Integer|Integer const) &, Integer &, Integer &\[)\]+" + test_demangling "gnu: divide__FRC7IntegerlR7IntegerRl" \ + "divide\[(\]+(const Integer|Integer const) &, long, Integer &, long &\[)\]+" + test_demangling "gnu: enable__14DocumentViewerPCcUi" \ + "DocumentViewer::enable\[(\]+(const char|char const) \[*\]+, unsigned int\[)\]+" + + test_demangling_exact "gnu: foo__FiN30" "foo(int, int, int, int)" + test_demangling_exact "gnu: foo__FiR3fooiT1iT1" "foo(int, foo &, int, foo &, int, foo &)" + test_demangling_exact "gnu: foo___3barl" "bar::foo_(long)" + test_demangling_exact "gnu: insert__15ivClippingStacklRP8_XRegion" "ivClippingStack::insert(long, _XRegion *&)" + test_demangling_exact "gnu: insert__16ChooserInfo_ListlR11ChooserInfo" "ChooserInfo_List::insert(long, ChooserInfo &)" + test_demangling_exact "gnu: insert__17FontFamilyRepListlRP15ivFontFamilyRep" "FontFamilyRepList::insert(long, ivFontFamilyRep *&)" + test_demangling_exact "gnu: leaveok__FP7_win_stc" "leaveok(_win_st *, char)" + test_demangling_exact "gnu: left_mover__C7ivMFKitP12ivAdjustableP7ivStyle" "ivMFKit::left_mover(ivAdjustable *, ivStyle *) const" + test_demangling "gnu: matches__C9BitStringRC10BitPatterni" \ + "BitString::matches\[(\]+(const BitPattern|BitPattern const) &, int\[)\]+ const" + test_demangling "gnu: matches__C9SubStringRC5Regex" \ + "SubString::matches\[(\]+(const Regex|Regex const) &\[)\]+ const" + + test_demangling_exact "gnu: overload1arg__FSc" "overload1arg(signed char)" + test_demangling_exact "gnu: overload1arg__FUc" "overload1arg(unsigned char)" + test_demangling_exact "gnu: overload1arg__FUi" "overload1arg(unsigned int)" + test_demangling_exact "gnu: overload1arg__FUl" "overload1arg(unsigned long)" + test_demangling_exact "gnu: overload1arg__FUs" "overload1arg(unsigned short)" + test_demangling_exact "gnu: overload1arg__Fc" "overload1arg(char)" + test_demangling_exact "gnu: overload1arg__Fd" "overload1arg(double)" + test_demangling_exact "gnu: overload1arg__Ff" "overload1arg(float)" + test_demangling_exact "gnu: overload1arg__Fi" "overload1arg(int)" + test_demangling_exact "gnu: overload1arg__Fl" "overload1arg(long)" + test_demangling_exact "gnu: overload1arg__Fs" "overload1arg(short)" + test_demangling_exact "gnu: overload1arg__Fv" "overload1arg(void)" + test_demangling_exact "gnu: overloadargs__Fi" "overloadargs(int)" + test_demangling_exact "gnu: overloadargs__Fii" "overloadargs(int, int)" + test_demangling_exact "gnu: overloadargs__Fiii" "overloadargs(int, int, int)" + test_demangling_exact "gnu: overloadargs__Fiiii" "overloadargs(int, int, int, int)" + + test_demangling_exact "gnu: overloadargs__Fiiiii" "overloadargs(int, int, int, int, int)" + test_demangling_exact "gnu: overloadargs__Fiiiiii" "overloadargs(int, int, int, int, int, int)" + test_demangling_exact "gnu: overloadargs__Fiiiiiii" "overloadargs(int, int, int, int, int, int, int)" + test_demangling_exact "gnu: overloadargs__Fiiiiiiii" "overloadargs(int, int, int, int, int, int, int, int)" + test_demangling_exact "gnu: overloadargs__Fiiiiiiiii" "overloadargs(int, int, int, int, int, int, int, int, int)" + test_demangling_exact "gnu: overloadargs__Fiiiiiiiiii" "overloadargs(int, int, int, int, int, int, int, int, int, int)" + test_demangling_exact "gnu: overloadargs__Fiiiiiiiiiii" "overloadargs(int, int, int, int, int, int, int, int, int, int, int)" + test_demangling "gnu: pick__13ivCompositionP8ivCanvasRC12ivAllocationiR5ivHit" \ + "ivComposition::pick\[(\]+ivCanvas \[*\]+, (const ivAllocation|ivAllocation const) &, int, ivHit &\[)\]+" + test_demangling "gnu: pointer__C11ivHScrollerRC7ivEventRC12ivAllocation" \ + "ivHScroller::pointer\[(\]+(const ivEvent|ivEvent const) &, (const ivAllocation|ivAllocation const) &\[)\]+ const" + test_demangling_exact "gnu: poke__8ivRasterUlUlffff" "ivRaster::poke(unsigned long, unsigned long, float, float, float, float)" + test_demangling_exact "gnu: polar__Fdd" "polar(double, double)" + test_demangling "gnu: read__10osStdInputRPCc" \ + "osStdInput::read\[(\]+(const char|char const) \[*\]+&\[)\]+" + + test_demangling_exact "gnu: scale__13ivTransformerff" "ivTransformer::scale(float, float)" + test_demangling "gnu: scanw__12CursesWindowPCce" \ + "CursesWindow::scanw\[(\]+(const char|char const) \[*\]+,...\[)\]+" + test_demangling "gnu: scmp__FPCcT0" \ + "scmp\[(\]+(const char|char const) \[*\]+, (const char|char const) \[*\]+\[)\]+" + test_demangling_exact "gnu: sgetn__7filebufPci" "filebuf::sgetn(char *, int)" + test_demangling_exact "gnu: shift__FP5_FrepiT0" "shift(_Frep *, int, _Frep *)" + test_demangling_exact "gnu: test__C6BitSeti" "BitSet::test(int) const" + test_demangling_exact "gnu: test__C6BitSetii" "BitSet::test(int, int) const" + test_demangling "gnu: testbit__FRC7Integerl" \ + "testbit\[(\]+(const Integer|Integer const) &, long\[)\]+" + test_demangling_exact "gnu: text_source__8Documentl" "Document::text_source(long)" + test_demangling_exact "gnu: variance__6Erlangd" "Erlang::variance(double)" + test_demangling "gnu: vform__8iostreamPCcPc" \ + "iostream::vform\[(\]+(const char|char const) \[*\]+, char \[*\]+\[)\]+" + test_demangling_exact "gnu: view__14DocumentViewerP8ItemViewP11TabularItem" "DocumentViewer::view(ItemView *, TabularItem *)" + test_demangling_exact "gnu: xy_extents__11ivExtensionffff" "ivExtension::xy_extents(float, float, float, float)" + test_demangling_exact "gnu: zero__8osMemoryPvUi" "osMemory::zero(void *, unsigned int)" + test_demangling_exact "gnu: _2T4\$N" "T4::N" + test_demangling_exact "gnu: _Q22T42t1\$N" "T4::t1::N" + test_demangling_exact "gnu: get__2T1" "T1::get(void)" + test_demangling_exact "gnu: get__Q22T11a" "T1::a::get(void)" + test_demangling_exact "gnu: get__Q32T11a1b" "T1::a::b::get(void)" + test_demangling_exact "gnu: get__Q42T11a1b1c" "T1::a::b::c::get(void)" + test_demangling_exact "gnu: get__Q52T11a1b1c1d" "T1::a::b::c::d::get(void)" + test_demangling_exact "gnu: put__2T1i" "T1::put(int)" + test_demangling_exact "gnu: put__Q22T11ai" "T1::a::put(int)" + test_demangling_exact "gnu: put__Q32T11a1bi" "T1::a::b::put(int)" + test_demangling_exact "gnu: put__Q42T11a1b1ci" "T1::a::b::c::put(int)" + test_demangling_exact "gnu: put__Q52T11a1b1c1di" "T1::a::b::c::d::put(int)" + + test_demangling_exact "gnu: bar__3fooPv" "foo::bar(void *)" + test_demangling "gnu: bar__3fooPCv" \ + "foo::bar\[(\]+(const void|void const) *\[*\]+\[)\]+" + test_demangling_exact "gnu: bar__C3fooPv" "foo::bar(void *) const" + test_demangling "gnu: bar__C3fooPCv" \ + "foo::bar\[(\]+(const void|void const) *\[*\]+\[)\]+ const" + test_demangling_exact "gnu: __eq__3fooRT0" "foo::operator==(foo &)" + test_demangling "gnu: __eq__3fooRC3foo" \ + "foo::operator==\[(\]+(const foo|foo const) &\[)\]+" + test_demangling_exact "gnu: __eq__C3fooR3foo" "foo::operator==(foo &) const" + test_demangling "gnu: __eq__C3fooRT0" \ + "foo::operator==\[(\]+(const foo|foo const) &\[)\]+ const" + + test_demangling_exact "gnu: elem__t6vector1Zdi" "vector<double>::elem(int)" + test_demangling_exact "gnu: elem__t6vector1Zii" "vector<int>::elem(int)" + test_demangling_exact "gnu: __t6vector1Zdi" "vector<double>::vector(int)" + test_demangling_exact "gnu: __t6vector1Zii" "vector<int>::vector(int)" + test_demangling_exact "gnu: _\$_t6vector1Zdi" "vector<double>::~vector(int)" + test_demangling_exact "gnu: _\$_t6vector1Zii" "vector<int>::~vector(int)" + + test_demangling_exact "gnu: __nw__t2T11ZcUi" "T1<char>::operator new(unsigned int)" + test_demangling_exact "gnu: __nw__t2T11Z1tUi" "T1<t>::operator new(unsigned int)" + test_demangling_exact "gnu: __dl__t2T11ZcPv" "T1<char>::operator delete(void *)" + test_demangling_exact "gnu: __dl__t2T11Z1tPv" "T1<t>::operator delete(void *)" + test_demangling_exact "gnu: __t2T11Zci" "T1<char>::T1(int)" + test_demangling_exact "gnu: __t2T11Zc" "T1<char>::T1(void)" + test_demangling_exact "gnu: __t2T11Z1ti" "T1<t>::T1(int)" + test_demangling_exact "gnu: __t2T11Z1t" "T1<t>::T1(void)" + + test_demangling_exact "gnu: __Q2t4List1Z10VHDLEntity3Pix" \ + "List<VHDLEntity>::Pix::Pix(void)" + + test_demangling_exact "gnu: __Q2t4List1Z10VHDLEntity3PixPQ2t4List1Z10VHDLEntity7element" \ + "List<VHDLEntity>::Pix::Pix(List<VHDLEntity>::element *)" + + test_demangling_exact "gnu: __Q2t4List1Z10VHDLEntity3PixRCQ2t4List1Z10VHDLEntity3Pix" \ + "List<VHDLEntity>::Pix::Pix(List<VHDLEntity>::Pix const &)" + + test_demangling_exact "gnu: __Q2t4List1Z10VHDLEntity7elementRC10VHDLEntityPT0" \ + "List<VHDLEntity>::element::element(VHDLEntity const &, List<VHDLEntity>::element *)" + + test_demangling_exact "gnu: __Q2t4List1Z10VHDLEntity7elementRCQ2t4List1Z10VHDLEntity7element" \ + "List<VHDLEntity>::element::element(List<VHDLEntity>::element const &)" + + test_demangling_exact "gnu: __cl__C11VHDLLibraryGt4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntity" \ + "VHDLLibrary::operator()(PixX<VHDLLibrary, VHDLLibraryRep, List<VHDLEntity> >) const" + + test_demangling_exact "gnu: __cl__Ct4List1Z10VHDLEntityRCQ2t4List1Z10VHDLEntity3Pix" \ + "List<VHDLEntity>::operator()(List<VHDLEntity>::Pix const &) const" + + test_demangling_exact "gnu: __ne__FPvRCQ2t4List1Z10VHDLEntity3Pix" \ + "operator!=(void *, List<VHDLEntity>::Pix const &)" + + test_demangling_exact "gnu: __ne__FPvRCt4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntity" \ + "operator!=(void *, PixX<VHDLLibrary, VHDLLibraryRep, List<VHDLEntity> > const &)" + + test_demangling_exact "gnu: __t4List1Z10VHDLEntityRCt4List1Z10VHDLEntity" \ + "List<VHDLEntity>::List(List<VHDLEntity> const &)" + + test_demangling_exact "gnu: __t4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntity" \ + "PixX<VHDLLibrary, VHDLLibraryRep, List<VHDLEntity> >::PixX(void)" + + test_demangling_exact "gnu: __t4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntityP14VHDLLibraryRepGQ2t4List1Z10VHDLEntity3Pix" \ + "PixX<VHDLLibrary, VHDLLibraryRep, List<VHDLEntity> >::PixX(VHDLLibraryRep *, List<VHDLEntity>::Pix)" + + test_demangling_exact "gnu: __t4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntityRCt4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntity" \ + "PixX<VHDLLibrary, VHDLLibraryRep, List<VHDLEntity> >::PixX(PixX<VHDLLibrary, VHDLLibraryRep, List<VHDLEntity> > const &)" + + test_demangling_exact "gnu: nextE__C11VHDLLibraryRt4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntity" \ + "VHDLLibrary::nextE(PixX<VHDLLibrary, VHDLLibraryRep, List<VHDLEntity> > &) const" + + test_demangling_exact "gnu: next__Ct4List1Z10VHDLEntityRQ2t4List1Z10VHDLEntity3Pix" \ + "List<VHDLEntity>::next(List<VHDLEntity>::Pix &) const" + + test_demangling_exact "gnu: _GLOBAL_\$D\$set" "global destructors keyed to set" + + test_demangling_exact "gnu: _GLOBAL_\$I\$set" "global constructors keyed to set" + + test_demangling_exact "gnu: __as__t5ListS1ZUiRCt5ListS1ZUi" \ + "ListS<unsigned int>::operator=(ListS<unsigned int> const &)" + + test_demangling_exact "gnu: __cl__Ct5ListS1ZUiRCQ2t5ListS1ZUi3Vix" \ + "ListS<unsigned int>::operator()(ListS<unsigned int>::Vix const &) const" + + test_demangling_exact "gnu: __cl__Ct5SetLS1ZUiRCQ2t5SetLS1ZUi3Vix" \ + "SetLS<unsigned int>::operator()(SetLS<unsigned int>::Vix const &) const" + + test_demangling_exact "gnu: __t10ListS_link1ZUiRCUiPT0" \ + "ListS_link<unsigned int>::ListS_link(unsigned int const &, ListS_link<unsigned int> *)" + + test_demangling_exact "gnu: __t10ListS_link1ZUiRCt10ListS_link1ZUi" \ + "ListS_link<unsigned int>::ListS_link(ListS_link<unsigned int> const &)" + + test_demangling_exact "gnu: __t5ListS1ZUiRCt5ListS1ZUi" \ + "ListS<unsigned int>::ListS(ListS<unsigned int> const &)" + + test_demangling_exact "gnu: next__Ct5ListS1ZUiRQ2t5ListS1ZUi3Vix" \ + "ListS<unsigned int>::next(ListS<unsigned int>::Vix &) const" + + test_demangling_exact "gnu: __ne__FPvRCQ2t5SetLS1ZUi3Vix" \ + "operator!=(void *, SetLS<unsigned int>::Vix const &)" + test_demangling_exact "gnu: __t8ListElem1Z5LabelRt4List1Z5Label" \ + "ListElem<Label>::ListElem(List<Label> &)" + test_demangling_exact "gnu: __t8BDDHookV1ZPcRCPc" \ + "BDDHookV<char *>::BDDHookV(char *const &)" + + test_demangling_exact "gnu: _vt\$t8BDDHookV1ZPc" "BDDHookV<char *> virtual table" + + test_demangling_exact "gnu: __ne__FPvRCQ211BDDFunction4VixB" \ + "operator!=(void *, BDDFunction::VixB const &)" + test_demangling_exact "gnu: __eq__FPvRCQ211BDDFunction4VixB" \ + "operator==(void *, BDDFunction::VixB const &)" + + test_demangling_exact "gnu: relativeId__CQ36T_phi210T_preserve8FPC_nextRCQ26T_phi210T_preserveRC10Parameters" \ + "T_phi2::T_preserve::FPC_next::relativeId(T_phi2::T_preserve const &, Parameters const &) const" + + test_demangling_exact "gnu: _Utf390_1__1_9223372036854775807__9223372036854775" \ + "Can't demangle \"_Utf390_1__1_9223372036854775807__9223372036854775\"" + test_demangling_exact "gnu: foo__I40" "foo(int64_t)" + test_demangling_exact "gnu: foo__I_200_" "foo(int512_t)" + test_demangling_exact "gnu: foo__I_200" "Can't demangle \"foo__I_200\"" + + ## Buffer overrun. Should make GDB crash. Woo hoo! + test_demangling_exact "gnu: foo__I_4000000000000000000000000000000000000000000000000000000000000000000000000" "Can't demangle \"foo__I_4000000000000000000000000000000000000000000000000000000000000000000000000\"" + + ## 1999-04-19: "Fix from Dale Hawkins". Shouldn't segfault. + # Accept even a dubious demangling; the string is ambiguous. + send_gdb "maintenance demangle __thunk_64__0RL__list__Q29CosNaming20_proxy_NamingContextUlRPt25_CORBA_Unbounded_Sequence1ZQ29CosNaming7BindingRPQ29CosNaming15BindingIterator\n" + gdb_expect { + -re "virtual function thunk \\(delta:-64\\) for CosNaming::_proxy_NamingContext::_0RL__list\\(unsigned long, _CORBA_Unbounded_Sequence<CosNaming::Binding> \\*\\&, CosNaming::BindingIterator \\*\\&\\)\r\n$gdb_prompt $" { + pass "gnu: __thunk_64__0RL__list__Q29CosNaming20_proxy_NamingContextUlRPt25_CORBA_Unbounded_Sequence1ZQ29CosNaming7BindingRPQ29CosNaming15BindingIterator" + } + -re ".*Can't demangle \"__thunk_64__0RL__list__Q29CosNaming20_proxy_NamingContextUlRPt25_CORBA_Unbounded_Sequence1ZQ29CosNaming7BindingRPQ29CosNaming15BindingIterator\"\r\n$gdb_prompt $" { + pass "gnu: __thunk_64__0RL__list__Q29CosNaming20_proxy_NamingContextUlRPt25_CORBA_Unbounded_Sequence1ZQ29CosNaming7BindingRPQ29CosNaming15BindingIterator" + } + -re ".*$gdb_prompt $" { + fail "gnu: __thunk_64__0RL__list__Q29CosNaming20_proxy_NamingContextUlRPt25_CORBA_Unbounded_Sequence1ZQ29CosNaming7BindingRPQ29CosNaming15BindingIterator" + } + timeout { + fail "gnu: __thunk_64__0RL__list__Q29CosNaming20_proxy_NamingContextUlRPt25_CORBA_Unbounded_Sequence1ZQ29CosNaming7BindingRPQ29CosNaming15BindingIterator (timeout)" + } + } +} + +# +# Test lucid style name demangling +# + +proc test_lucid_style_demangling {} { + test_demangling_exact "lucid: WS__FR7istream" "WS(istream &)" + test_demangling_exact "lucid: __aa__3fooFR3foo" "foo::operator&&(foo &)" + test_demangling_exact "lucid: __aad__3fooFR3foo" "foo::operator&=(foo &)" + test_demangling_exact "lucid: __ad__3fooFR3foo" "foo::operator&(foo &)" + test_demangling_exact "lucid: __adv__3fooFR3foo" "foo::operator/=(foo &)" + test_demangling_exact "lucid: __adv__7complexF7complex" "complex::operator/=(complex)" + test_demangling_exact "lucid: __aer__3fooFR3foo" "foo::operator^=(foo &)" + test_demangling_exact "lucid: __als__3fooFR3foo" "foo::operator<<=(foo &)" + test_demangling_exact "lucid: __amd__3fooFR3foo" "foo::operator%=(foo &)" + test_demangling_exact "lucid: __ami__3fooFR3foo" "foo::operator-=(foo &)" + test_demangling_exact "lucid: __amu__3fooFR3foo" "foo::operator*=(foo &)" + test_demangling_exact "lucid: __amu__7complexF7complex" "complex::operator*=(complex)" + test_demangling_exact "lucid: __aor__3fooFR3foo" "foo::operator|=(foo &)" + test_demangling_exact "lucid: __apl__3fooFR3foo" "foo::operator+=(foo &)" + test_demangling_exact "lucid: __ars__3fooFR3foo" "foo::operator>>=(foo &)" + test_demangling_exact "lucid: __as__18istream_withassignFP9streambuf" "istream_withassign::operator=(streambuf *)" + test_demangling_exact "lucid: __as__18istream_withassignFR7istream" "istream_withassign::operator=(istream &)" + test_demangling_exact "lucid: __as__3fooFR3foo" "foo::operator=(foo &)" + test_demangling_exact "lucid: __as__3iosFR3ios" "ios::operator=(ios &)" + test_demangling_exact "lucid: __cl__3fooFR3foo" "foo::operator()(foo &)" + test_demangling_exact "lucid: __cm__3fooFR3foo" "foo::operator, (foo &)" + + test_demangling_exact "lucid: __co__3fooFv" "foo::operator~(void)" + test_demangling_exact "lucid: __ct__10istrstreamFPc" "istrstream::istrstream(char *)" + test_demangling_exact "lucid: __ct__10istrstreamFPci" "istrstream::istrstream(char *, int)" + test_demangling_exact "lucid: __ct__10ostrstreamFPciT2" "ostrstream::ostrstream(char *, int, int)" + test_demangling_exact "lucid: __ct__10ostrstreamFv" "ostrstream::ostrstream(void)" + test_demangling_exact "lucid: __ct__10smanip_intFPFR3iosi_R3iosi" "smanip_int::smanip_int(ios &(*)(ios &, int), int)" + test_demangling "lucid: __ct__11c_exceptionFPcRC7complexT2" "c_exception::c_exception\[(\]+char \[*\]+, (const complex|complex const) &, (const complex|complex const) &\[)\]+" + test_demangling "lucid: __ct__11fstreambaseFPCciT2" "fstreambase::fstreambase\[(\]+(const char|char const) \[*\]+, int, int\[)\]+" + test_demangling_exact "lucid: __ct__11fstreambaseFi" "fstreambase::fstreambase(int)" + test_demangling_exact "lucid: __ct__11fstreambaseFiPcT1" "fstreambase::fstreambase(int, char *, int)" + test_demangling_exact "lucid: __ct__11fstreambaseFv" "fstreambase::fstreambase(void)" + test_demangling_exact "lucid: __ct__11smanip_longFPFR3iosl_R3iosl" "smanip_long::smanip_long(ios &(*)(ios &, long), long)" + test_demangling_exact "lucid: __ct__11stdiostreamFP4FILE" "stdiostream::stdiostream(FILE *)" + test_demangling_exact "lucid: __ct__12strstreambufFPFl_PvPFPv_v" "strstreambuf::strstreambuf(void *(*)(long), void (*)(void *))" + test_demangling_exact "lucid: __ct__12strstreambufFPUciT1" "strstreambuf::strstreambuf(unsigned char *, int, unsigned char *)" + test_demangling_exact "lucid: __ct__12strstreambufFPciT1" "strstreambuf::strstreambuf(char *, int, char *)" + test_demangling_exact "lucid: __ct__12strstreambufFi" "strstreambuf::strstreambuf(int)" + test_demangling_exact "lucid: __ct__12strstreambufFv" "strstreambuf::strstreambuf(void)" + test_demangling_exact "lucid: __ct__13strstreambaseFPciT1" "strstreambase::strstreambase(char *, int, char *)" + test_demangling_exact "lucid: __ct__3fooFR3foo" "foo::foo(foo &)" + + test_demangling_exact "lucid: __ct__3fooFi" "foo::foo(int)" + test_demangling_exact "lucid: __ct__3fooFiN31" "foo::foo(int, int, int, int)" + test_demangling "lucid: __ct__3fooFiPCc" \ + "foo::foo\[(\]+int, (const char|char const) \[*\]+\[)\]+" + test_demangling_exact "lucid: __ct__3fooFiR3fooT1T2T1T2" "foo::foo(int, foo &, int, foo &, int, foo &)" + test_demangling_exact "lucid: __ct__3iosFP9streambuf" "ios::ios(streambuf *)" + test_demangling_exact "lucid: __ct__7filebufFiPcT1" "filebuf::filebuf(int, char *, int)" + test_demangling "lucid: __ct__7fstreamFPCciT2" \ + "fstream::fstream\[(\]+(const char|char const) \[*\]+, int, int\[)\]+" + test_demangling_exact "lucid: __ct__7fstreamFiPcT1" "fstream::fstream(int, char *, int)" + test_demangling_exact "lucid: __ct__7istreamFP9streambuf" "istream::istream(streambuf *)" + test_demangling_exact "lucid: __ct__7istreamFP9streambufiP7ostream" "istream::istream(streambuf *, int, ostream *)" + test_demangling_exact "lucid: __ct__7istreamFiPcT1" "istream::istream(int, char *, int)" + test_demangling_exact "lucid: __ct__7istreamFiT1P7ostream" "istream::istream(int, int, ostream *)" + test_demangling_exact "lucid: __ct__7ostreamFP9streambuf" "ostream::ostream(streambuf *)" + test_demangling_exact "lucid: __ct__7ostreamFiPc" "ostream::ostream(int, char *)" + test_demangling "lucid: __ct__8ifstreamFPCciT2" \ + "ifstream::ifstream\[(\]+(const char|char const) \[*\]+, int, int\[)\]+" + test_demangling_exact "lucid: __ct__8ifstreamFiPcT1" "ifstream::ifstream(int, char *, int)" + + test_demangling_exact "lucid: __ct__Q23foo3barFv" "foo::bar::bar(void)" + test_demangling_exact "lucid: __ct__Q33foo3bar4bellFv" "foo::bar::bell::bell(void)" + test_demangling_exact "lucid: __dl__3fooSFPv" "foo::operator delete(void *) static" + test_demangling_exact "lucid: __dl__FPv" "operator delete(void *)" + test_demangling_exact "lucid: __dt__10istrstreamFv" "istrstream::~istrstream(void)" + + test_demangling_exact "lucid: __dt__Q23foo3barFv" "foo::bar::~bar(void)" + test_demangling_exact "lucid: __dt__Q33foo3bar4bellFv" "foo::bar::bell::~bell(void)" + test_demangling_exact "lucid: __dv__3fooFR3foo" "foo::operator/(foo &)" + test_demangling_exact "lucid: __dv__F7complexT1" "operator/(complex, complex)" + test_demangling_exact "lucid: __eq__3fooFR3foo" "foo::operator==(foo &)" + test_demangling_exact "lucid: __er__3fooFR3foo" "foo::operator^(foo &)" + test_demangling_exact "lucid: __ge__3fooFR3foo" "foo::operator>=(foo &)" + test_demangling_exact "lucid: __gt__3fooFR3foo" "foo::operator>(foo &)" + test_demangling_exact "lucid: __le__3fooFR3foo" "foo::operator<=(foo &)" + test_demangling_exact "lucid: __ls__3fooFR3foo" "foo::operator<<(foo &)" + test_demangling_exact "lucid: __ls__7ostreamFP9streambuf" "ostream::operator<<(streambuf *)" + + test_demangling "lucid: __ls__7ostreamFPCc" \ + "ostream::operator<<\[(\]+(const char|char const) \[*\]+\[)\]+" + test_demangling_exact "lucid: __ls__7ostreamFPFR3ios_R3ios" "ostream::operator<<(ios &(*)(ios &))" + test_demangling_exact "lucid: __ls__7ostreamFPv" "ostream::operator<<(void *)" + test_demangling_exact "lucid: __ls__7ostreamFUi" "ostream::operator<<(unsigned int)" + test_demangling_exact "lucid: __ls__7ostreamFUl" "ostream::operator<<(unsigned long)" + test_demangling_exact "lucid: __ls__7ostreamFd" "ostream::operator<<(double)" + test_demangling_exact "lucid: __ls__7ostreamFf" "ostream::operator<<(float)" + test_demangling_exact "lucid: __ls__7ostreamFi" "ostream::operator<<(int)" + test_demangling_exact "lucid: __ls__7ostreamFl" "ostream::operator<<(long)" + test_demangling_exact "lucid: __ls__FR7ostream7complex" "operator<<(ostream &, complex)" + test_demangling_exact "lucid: __lt__3fooFR3foo" "foo::operator<(foo &)" + test_demangling_exact "lucid: __md__3fooFR3foo" "foo::operator%(foo &)" + test_demangling_exact "lucid: __mi__3fooFR3foo" "foo::operator-(foo &)" + test_demangling_exact "lucid: __ml__3fooFR3foo" "foo::operator*(foo &)" + test_demangling_exact "lucid: __ml__F7complexT1" "operator*(complex, complex)" + test_demangling_exact "lucid: __mm__3fooFi" "foo::operator--(int)" + test_demangling_exact "lucid: __ne__3fooFR3foo" "foo::operator!=(foo &)" + test_demangling_exact "lucid: __nt__3fooFv" "foo::operator!(void)" + test_demangling_exact "lucid: __nw__3fooSFi" "foo::operator new(int) static" + test_demangling_exact "lucid: __nw__FUi" "operator new(unsigned int)" + test_demangling_exact "lucid: __nw__FUiPv" "operator new(unsigned int, void *)" + test_demangling_exact "lucid: __oo__3fooFR3foo" "foo::operator||(foo &)" + test_demangling_exact "lucid: __opPc__3fooFv" "foo::operator char *(void)" + test_demangling_exact "lucid: __opi__3fooFv" "foo::operator int(void)" + test_demangling_exact "lucid: __or__3fooFR3foo" "foo::operator|(foo &)" + + test_demangling_exact "lucid: __pl__3fooFR3foo" "foo::operator+(foo &)" + test_demangling_exact "lucid: __pp__3fooFi" "foo::operator++(int)" + test_demangling_exact "lucid: __pt__3fooFv" "foo::operator->(void)" + test_demangling_exact "lucid: __rm__3fooFR3foo" "foo::operator->*(foo &)" + test_demangling_exact "lucid: __rs__3fooFR3foo" "foo::operator>>(foo &)" + test_demangling_exact "lucid: __rs__7istreamFP9streambuf" "istream::operator>>(streambuf *)" + test_demangling_exact "lucid: __rs__7istreamFPFR3ios_R3ios" "istream::operator>>(ios &(*)(ios &))" + test_demangling_exact "lucid: __rs__7istreamFPFR7istream_R7istream" "istream::operator>>(istream &(*)(istream &))" + test_demangling_exact "lucid: __rs__7istreamFPUc" "istream::operator>>(unsigned char *)" + test_demangling_exact "lucid: __rs__7istreamFPc" "istream::operator>>(char *)" + test_demangling_exact "lucid: __rs__7istreamFRUi" "istream::operator>>(unsigned int &)" + test_demangling_exact "lucid: __rs__7istreamFRUl" "istream::operator>>(unsigned long &)" + test_demangling_exact "lucid: __rs__7istreamFRUs" "istream::operator>>(unsigned short &)" + test_demangling_exact "lucid: __rs__7istreamFRd" "istream::operator>>(double &)" + test_demangling_exact "lucid: __rs__7istreamFRf" "istream::operator>>(float &)" + test_demangling_exact "lucid: __rs__7istreamFRi" "istream::operator>>(int &)" + test_demangling_exact "lucid: __rs__7istreamFRl" "istream::operator>>(long &)" + test_demangling_exact "lucid: __rs__7istreamFRs" "istream::operator>>(short &)" + test_demangling_exact "lucid: __rs__FR7istreamR7complex" "operator>>(istream &, complex &)" + test_demangling "lucid: __vc__3fooFR3foo" "foo::operator\\\[\\\]\\(foo &\\)" + test_demangling_exact "lucid: __vtbl__10istrstream" "istrstream virtual table" + test_demangling_exact "lucid: __vtbl__17ostream__iostream__19iostream_withassign" "iostream_withassign::ostream__iostream virtual table" + + test_demangling_exact "lucid: __vtbl__3ios" "ios virtual table" + test_demangling_exact "lucid: __vtbl__3ios__13strstreambase" "strstreambase::ios virtual table" + + # GDB 930414 demangles this as t_cc_main_ (obviously wrong). + # GDB 930701 gets into an infinite loop. + # GDB 930727 says "Can't demangle". + # What is the correct demangling? FIXME. + + # NOTE: carlton/2003-01-17: No, don't FIXME, just obsolete lucid. + # I'm KFAILing this rather than deleting it for form's sake. + setup_kfail "gdb/945" "*-*-*" + test_demangling_exact "lucid: __vtbl__3foo__vt_cc_main_" "" + + test_demangling_exact "lucid: abs__F7complex" "abs(complex)" + test_demangling_exact "lucid: allocate__9streambufFv" "streambuf::allocate(void)" + test_demangling_exact "lucid: attach__11fstreambaseFi" "fstreambase::attach(int)" + test_demangling_exact "lucid: bitalloc__3iosSFv" "ios::bitalloc(void) static" + test_demangling_exact "lucid: chr__FiT1" "chr(int, int)" + test_demangling_exact "lucid: complex_error__FR11c_exception" "complex_error(c_exception &)" + test_demangling_exact "lucid: complexfunc2__FPFPc_i" "complexfunc2(int (*)(char *))" + test_demangling_exact "lucid: complexfunc3__FPFPFPl_s_i" "complexfunc3(int (*)(short (*)(long *)))" + + test_demangling_exact "lucid: complexfunc4__FPFPFPc_s_i" "complexfunc4(int (*)(short (*)(char *)))" + test_demangling_exact "lucid: complexfunc5__FPFPc_PFl_i" "complexfunc5(int (*(*)(char *))(long))" + test_demangling_exact "lucid: complexfunc6__FPFPi_PFl_i" "complexfunc6(int (*(*)(int *))(long))" + test_demangling_exact "lucid: complexfunc7__FPFPFPc_i_PFl_i" "complexfunc7(int (*(*)(int (*)(char *)))(long))" + test_demangling_exact "lucid: complicated_put__7ostreamFc" "ostream::complicated_put(char)" + test_demangling_exact "lucid: conv10__FlPc" "conv10(long, char *)" + test_demangling_exact "lucid: conv16__FUlPc" "conv16(unsigned long, char *)" + test_demangling_exact "lucid: dec__FR3ios" "dec(ios &)" + test_demangling_exact "lucid: dec__Fli" "dec(long, int)" + test_demangling_exact "lucid: dofield__FP7ostreamPciT2T3" "dofield(ostream *, char *, int, char *, int)" + + test_demangling_exact "lucid: flags__3iosFl" "ios::flags(long)" + test_demangling_exact "lucid: flags__3iosFv" "ios::flags(void)" + test_demangling_exact "lucid: foo__FiN31" "foo(int, int, int, int)" + test_demangling_exact "lucid: foo__FiR3fooT1T2T1T2" "foo(int, foo &, int, foo &, int, foo &)" + test_demangling_exact "lucid: foo___3barFl" "bar::foo_(long)" + test_demangling "lucid: form__FPCce" "form\[(\]+(const char|char const) \[*\]+,...\[)\]+" + test_demangling_exact "lucid: get__7istreamFPcic" "istream::get(char *, int, char)" + test_demangling_exact "lucid: get__7istreamFR9streambufc" "istream::get(streambuf &, char)" + test_demangling_exact "lucid: get_complicated__7istreamFRUc" "istream::get_complicated(unsigned char &)" + test_demangling_exact "lucid: get_complicated__7istreamFRc" "istream::get_complicated(char &)" + test_demangling_exact "lucid: getline__7istreamFPUcic" "istream::getline(unsigned char *, int, char)" + test_demangling_exact "lucid: getline__7istreamFPcic" "istream::getline(char *, int, char)" + + test_demangling_exact "lucid: ignore__7istreamFiT1" "istream::ignore(int, int)" + test_demangling_exact "lucid: init__12strstreambufFPciT1" "strstreambuf::init(char *, int, char *)" + test_demangling_exact "lucid: init__3iosFP9streambuf" "ios::init(streambuf *)" + test_demangling_exact "lucid: initcount__13Iostream_init" "Iostream_init::initcount" + test_demangling_exact "lucid: ipfx__7istreamFi" "istream::ipfx(int)" + test_demangling_exact "lucid: ls_complicated__7ostreamFUc" "ostream::ls_complicated(unsigned char)" + test_demangling_exact "lucid: ls_complicated__7ostreamFc" "ostream::ls_complicated(char)" + test_demangling "lucid: open__11fstreambaseFPCciT2" \ + "fstreambase::open\[(\]+(const char|char const) \[*\]+, int, int\[)\]+" + test_demangling "lucid: open__7filebufFPCciT2" \ + "filebuf::open\[(\]+(const char|char const) \[*\]+, int, int\[)\]+" + + test_demangling_exact "lucid: overload1arg__FSc" "overload1arg(signed char)" + test_demangling_exact "lucid: overload1arg__FUc" "overload1arg(unsigned char)" + test_demangling_exact "lucid: overload1arg__FUi" "overload1arg(unsigned int)" + test_demangling_exact "lucid: overload1arg__FUl" "overload1arg(unsigned long)" + test_demangling_exact "lucid: overload1arg__FUs" "overload1arg(unsigned short)" + test_demangling_exact "lucid: overload1arg__Fc" "overload1arg(char)" + test_demangling_exact "lucid: overload1arg__Fd" "overload1arg(double)" + test_demangling_exact "lucid: overload1arg__Ff" "overload1arg(float)" + test_demangling_exact "lucid: overload1arg__Fi" "overload1arg(int)" + test_demangling_exact "lucid: overload1arg__Fl" "overload1arg(long)" + test_demangling_exact "lucid: overload1arg__Fs" "overload1arg(short)" + test_demangling_exact "lucid: overload1arg__Fv" "overload1arg(void)" + test_demangling_exact "lucid: overloadargs__FiN21" "overloadargs(int, int, int)" + test_demangling_exact "lucid: overloadargs__FiN31" "overloadargs(int, int, int, int)" + test_demangling_exact "lucid: overloadargs__FiN41" "overloadargs(int, int, int, int, int)" + test_demangling_exact "lucid: overloadargs__FiN51" "overloadargs(int, int, int, int, int, int)" + test_demangling_exact "lucid: overloadargs__FiN61" "overloadargs(int, int, int, int, int, int, int)" + + test_demangling_exact "lucid: overloadargs__FiN71" "overloadargs(int, int, int, int, int, int, int, int)" + test_demangling_exact "lucid: overloadargs__FiN81" "overloadargs(int, int, int, int, int, int, int, int, int)" + test_demangling_exact "lucid: overloadargs__FiN91" "overloadargs(int, int, int, int, int, int, int, int, int, int)" + test_demangling_exact "lucid: overloadargs__FiN91N11" "overloadargs(int, int, int, int, int, int, int, int, int, int, int)" + test_demangling_exact "lucid: overloadargs__FiT1" "overloadargs(int, int)" + test_demangling_exact "lucid: polar__FdT1" "polar(double, double)" + test_demangling_exact "lucid: pow__F7complexT1" "pow(complex, complex)" + test_demangling_exact "lucid: pow__F7complexd" "pow(complex, double)" + test_demangling_exact "lucid: pow__F7complexi" "pow(complex, int)" + test_demangling_exact "lucid: pow__Fd7complex" "pow(double, complex)" + test_demangling_exact "lucid: pstart__FPciT2" "pstart(char *, int, int)" + test_demangling_exact "lucid: put__7ostreamFc" "ostream::put(char)" + + test_demangling_exact "lucid: read__7istreamFPci" "istream::read(char *, int)" + test_demangling_exact "lucid: resetiosflags__FR3iosl" "resetiosflags(ios &, long)" + test_demangling_exact "lucid: restore_errno__FRi" "restore_errno(int &)" + test_demangling_exact "lucid: rs_complicated__7istreamFRUc" "istream::rs_complicated(unsigned char &)" + test_demangling_exact "lucid: rs_complicated__7istreamFRc" "istream::rs_complicated(char &)" + test_demangling_exact "lucid: seekg__7istreamFl8seek_dir" "istream::seekg(long, seek_dir)" + test_demangling_exact "lucid: seekoff__12strstreambufFl8seek_diri" "strstreambuf::seekoff(long, seek_dir, int)" + test_demangling_exact "lucid: seekoff__9streambufFlQ2_3ios12ios_seek_diri" "streambuf::seekoff(long, ios::ios_seek_dir, int)" + test_demangling_exact "lucid: seekpos__9streambufFli" "streambuf::seekpos(long, int)" + test_demangling_exact "lucid: set_new_handler__FPFv_v" "set_new_handler(void (*)(void))" + test_demangling_exact "lucid: setb__9streambufFPcT1i" "streambuf::setb(char *, char *, int)" + + test_demangling_exact "lucid: setb__FR3iosi" "setb(ios &, int)" + test_demangling_exact "lucid: setbuf__11fstreambaseFPci" "fstreambase::setbuf(char *, int)" + test_demangling_exact "lucid: setbuf__9streambufFPUci" "streambuf::setbuf(unsigned char *, int)" + test_demangling_exact "lucid: setbuf__9streambufFPciT2" "streambuf::setbuf(char *, int, int)" + test_demangling_exact "lucid: setf__3iosFlT1" "ios::setf(long, long)" + test_demangling_exact "lucid: setfill__FR3iosi" "setfill(ios &, int)" + test_demangling_exact "lucid: setg__9streambufFPcN21" "streambuf::setg(char *, char *, char *)" + test_demangling_exact "lucid: setp__9streambufFPcT1" "streambuf::setp(char *, char *)" + + test_demangling "lucid: sputn__9streambufFPCci" \ + "streambuf::sputn\[(\]+(const char|char const) \[*\]+, int\[)\]+" + test_demangling "lucid: str__FPCci" \ + "str\[(\]+(const char|char const) \[*\]+, int\[)\]+" + test_demangling_exact "lucid: tie__3iosFP7ostream" "ios::tie(ostream *)" + test_demangling_exact "lucid: uconv10__FUlPc" "uconv10(unsigned long, char *)" + + test_demangling "lucid: write__7ostreamFPCci" \ + "ostream::write\[(\]+(const char|char const) \[*\]+, int\[)\]+" + test_demangling_exact "lucid: xget__7istreamFPc" "istream::xget(char *)" + test_demangling_exact "lucid: xsgetn__9streambufFPci" "streambuf::xsgetn(char *, int)" + test_demangling "lucid: xsputn__9streambufFPCci" \ + "streambuf::xsputn\[(\]+(const char|char const) \[*\]+, int\[)\]+" + + test_demangling_exact "lucid: _Utf390_1__1_9223372036854775807__9223372036854775" \ + "Can't demangle \"_Utf390_1__1_9223372036854775807__9223372036854775\"" +} + +# +# Test arm style name demangling +# + +proc test_arm_style_demangling {} { + test_demangling_exact "arm: __dt__21T5__pt__11_PFiPPdPv_iFv" "T5<int (*)(int, double **, void *)>::~T5(void)" + + test_demangling_exact "arm: __ct__1cFi" "c::c(int)" + + test_demangling_exact "arm: __dt__11T5__pt__2_iFv" "T5<int>::~T5(void)" + + test_demangling_exact "arm: __dt__11T5__pt__2_cFv" "T5<char>::~T5(void)" + + test_demangling_exact "arm: __ct__2T2Fi" "T2::T2(int)" + test_demangling_exact "arm: __dt__2T1Fv" "T1::~T1(void)" + + test_demangling_exact "arm: __dt__12T5__pt__3_1xFv" "T5<x>::~T5(void)" + + test_demangling_exact "arm: __dt__17T5__pt__8_PFcPv_iFv" "T5<int (*)(char, void *)>::~T5(void)" + + test_demangling "arm: g__FP1cPC1cT1" \ + "g\[(\]+c *\[*\]+, (const c|c const) *\[*\]+, c *\[*\]+\[)\]+" + test_demangling "arm: g__FPUlPCUlT1" \ + "g\[(\]+unsigned long \[*\]+, (const unsigned long|unsigned long const) \[*\]+, unsigned long \[*\]+\[)\]+" + test_demangling "arm: g__FPUiPCUiT1" \ + "g\[(\]+unsigned int \[*\]+, (const unsigned int|unsigned int const) \[*\]+, unsigned int \[*\]+\[)\]+" + test_demangling "arm: g__FPUsPCUsT1" \ + "g\[(\]+unsigned short \[*\]+, (const unsigned short|unsigned short const) \[*\]+, unsigned short \[*\]+\[)\]+" + test_demangling "arm: g__FPUcPCUcT1" \ + "g\[(\]+unsigned char \[*\]+, (const unsigned char|unsigned char const) \[*\]+, unsigned char \[*\]+\[)\]+" + test_demangling "arm: g__F1TPlPClT2" \ + "g\[(\]+T, long \[*\]+, (const long|long const) \[*\]+, long \[*\]+\[)\]+" + test_demangling "arm: g__F1RRlRClT2" \ + "g\[(\]+R, long &, (const long|long const) &, long &\[)\]+" + test_demangling "arm: g__F1TPiPCiT2" \ + "g\[(\]+T, int \[*\]+, (const int|int const) \[*\]+, int \[*\]+\[)\]+" + test_demangling "arm: g__F1RRiRCiT2" \ + "g\[(\]+R, int &, (const int|int const) &, int &\[)\]+" + test_demangling "arm: g__F1TPsPCsT2" \ + "g\[(\]+T, short \[*\]+, (const short|short const) \[*\]+, short \[*\]+\[)\]+" + test_demangling "arm: g__F1RRsRCsT2" \ + "g\[(\]+R, short &, (const short|short const) &, short &\[)\]+" + test_demangling "arm: g__F1TPcPCcT2" \ + "g\[(\]+T, char \[*\]+, (const char|char const) \[*\]+, char \[*\]+\[)\]+" + test_demangling "arm: g__F1RRcRCcT2" \ + "g\[(\]+R, char &, (const char|char const) &, char &\[)\]+" + + test_demangling_exact "arm: __ct__21T5__pt__11_PFiPPdPv_iFi" "T5<int (*)(int, double **, void *)>::T5(int)" + + test_demangling "arm: __gt__FRC2T2c" \ + "operator>\[(\]+(const T2|T2 const) &, char\[)\]+" + test_demangling "arm: __ge__FRC2T2c" \ + "operator>=\[(\]+(const T2|T2 const) &, char\[)\]+" + test_demangling "arm: __lt__FRC2T2c" \ + "operator<\[(\]+(const T2|T2 const) &, char\[)\]+" + + test_demangling "arm: __le__FRC2T2c" \ + "operator<=\[(\]+(const T2|T2 const) &, char\[)\]+" + test_demangling "arm: __ne__FRC2T2c" \ + "operator!=\[(\]+(const T2|T2 const) &, char\[)\]+" + test_demangling "arm: __eq__FRC2T2c" \ + "operator==\[(\]+(const T2|T2 const) &, char\[)\]+" + test_demangling_exact "arm: __amd__FR2T2i" "operator%=(T2 &, int)" + test_demangling_exact "arm: __adv__FR2T2i" "operator/=(T2 &, int)" + test_demangling_exact "arm: __amu__FR2T2i" "operator*=(T2 &, int)" + test_demangling_exact "arm: __ami__FR2T2i" "operator-=(T2 &, int)" + test_demangling_exact "arm: __apl__FR2T2i" "operator+=(T2 &, int)" + test_demangling_exact "arm: __nw__2T1SFUi" "T1::operator new(unsigned int) static" + test_demangling_exact "arm: __dl__2T1SFPv" "T1::operator delete(void *) static" + test_demangling_exact "arm: put__2T7SFi" "T7::put(int) static" + + test_demangling_exact "arm: __dl__12T5__pt__3_1xSFPv" "T5<x>::operator delete(void *) static" + + test_demangling_exact "arm: h__FUc" "h(unsigned char)" + test_demangling_exact "arm: f__Fic" "f(int, char)" + test_demangling_exact "arm: h__FUi" "h(unsigned int)" + test_demangling_exact "arm: h__Fci" "h(char, int)" + test_demangling_exact "arm: h__FUl" "h(unsigned long)" + test_demangling_exact "arm: h__Fcl" "h(char, long)" + test_demangling_exact "arm: h__FUs" "h(unsigned short)" + test_demangling_exact "arm: h__Fcs" "h(char, short)" + test_demangling "arm: __amd__FR2T2RC2T2" \ + "operator%=\[(\]+T2 &, (const T2|T2 const) &\[)\]+" + test_demangling "arm: __adv__FR2T2RC2T2" \ + "operator/=\[(\]+T2 &, (const T2|T2 const) &\[)\]+" + test_demangling "arm: __amu__FR2T2RC2T2" \ + "operator\[*\]+=\[(\]+T2 &, (const T2|T2 const) &\[)\]+" + test_demangling "arm: __ami__FR2T2RC2T2" \ + "operator-=\[(\]+T2 &, (const T2|T2 const) &\[)\]+" + test_demangling "arm: __apl__FR2T2RC2T2" \ + "operator\[+\]+=\[(\]+T2 &, (const T2|T2 const) &\[)\]+" + + test_demangling "arm: g__F1SRPUlRPCUlT2" \ + "g\[(\]+S, unsigned long \[*\]+&, (const unsigned long|unsigned long const) \[*\]+&, unsigned long \[*\]+&\[)\]+" + test_demangling "arm: g__F1SRPUiRPCUiT2" \ + "g\[(\]+S, unsigned int \[*\]+&, (const unsigned int|unsigned int const) \[*\]+&, unsigned int \[*\]+&\[)\]+" + test_demangling "arm: g__F1SRPUsRPCUsT2" \ + "g\[(\]+S, unsigned short \[*\]+&, (const unsigned short|unsigned short const) \[*\]+&, unsigned short \[*\]+&\[)\]+" + test_demangling "arm: g__F1SRPUcRPCUcT2" \ + "g\[(\]+S, unsigned char \[*\]+&, (const unsigned char|unsigned char const) \[*\]+&, unsigned char \[*\]+&\[)\]+" + test_demangling "arm: g__F1T1SRPlRPClT3" \ + "g\[(\]+T, S, long \[*\]+&, (const long|long const) \[*\]+&, long \[*\]+&\[)\]+" + test_demangling "arm: g__F1T1SRPiRPCiT3" \ + "g\[(\]+T, S, int \[*\]+&, (const int|int const) \[*\]+&, int \[*\]+&\[)\]+" + test_demangling "arm: g__F1T1SRPcRPCcT3" \ + "g\[(\]+T, S, char \[*\]+&, (const char|char const) \[*\]+&, char \[*\]+&\[)\]+" + + test_demangling_exact "arm: X__12T5__pt__3_1x" "T5<x>::X" + + test_demangling_exact "arm: __ct__11T5__pt__2_iFi" "T5<int>::T5(int)" + + test_demangling_exact "arm: __ct__11T5__pt__2_cFi" "T5<char>::T5(int)" + + test_demangling "arm: __gt__FRC2T2T1" \ + "operator>\[(\]+(const T2|T2 const) &, (const T2|T2 const) &\[)\]+" + test_demangling "arm: __ge__FRC2T2T1" \ + "operator>=\[(\]+(const T2|T2 const) &, (const T2|T2 const) &\[)\]+" + test_demangling "arm: __lt__FRC2T2T1" \ + "operator<\[(\]+(const T2|T2 const) &, (const T2|T2 const) &\[)\]+" + test_demangling "arm: __le__FRC2T2T1" \ + "operator<=\[(\]+(const T2|T2 const) &, (const T2|T2 const) &\[)\]+" + test_demangling "arm: __ne__FRC2T2T1" \ + "operator!=\[(\]+(const T2|T2 const) &, (const T2|T2 const) &\[)\]+" + test_demangling "arm: __eq__FRC2T2T1" \ + "operator==\[(\]+(const T2|T2 const) &, (const T2|T2 const) &\[)\]+" + test_demangling "arm: g__FcR1cRC1cT2" \ + "g\[(\]+char, c &, (const c|c const) &, c &\[)\]+" + test_demangling "arm: g__FcRPdRPCdT2" \ + "g\[(\]+char, double *\[*\]+&, (const double|double const) *\[*\]+&, double *\[*\]+&\[)\]+" + test_demangling "arm: g__FcRPfRPCfT2" \ + "g\[(\]+char, float *\[*\]+&, (const float|float const) *\[*\]+&, float *\[*\]+&\[)\]+" + test_demangling_exact "arm: h__FcT1" "h(char, char)" + test_demangling_exact "arm: f__Ficd" "f(int, char, double)" + test_demangling "arm: g__F1T1SdRPsRPCsT4" \ + "g\[(\]+T, S, double, short \[*\]+&, (const short|short const) \[*\]+&, short \[*\]+&\[)\]+" + test_demangling "arm: g__F1cC1cT1" \ + "g\[(\]+c, (const c|c const), c\[)\]+" + test_demangling "arm: g__FPdPCdT1" \ + "g\[(\]+double *\[*\]+, (const double|double const) *\[*\]+, double *\[*\]+\[)\]+" + test_demangling "arm: g__FPfPCfT1" \ + "g\[(\]+float *\[*\]+, (const float|float const) *\[*\]+, float *\[*\]+\[)\]+" + + test_demangling "arm: g__FUlCUlT1" \ + "g\[(\]+unsigned long, (const unsigned long|unsigned long const), unsigned long\[)\]+" + test_demangling "arm: g__FPlPClT1" \ + "g\[(\]+long \[*\]+, (const long|long const) \[*\]+, long \[*\]+\[)\]+" + test_demangling "arm: g__FUiCUiT1" \ + "g\[(\]+unsigned int, (const unsigned int|unsigned int const), unsigned int\[)\]+" + test_demangling "arm: g__FPiPCiT1" \ + "g\[(\]+int \[*\]+, (const int|int const) \[*\]+, int \[*\]+\[)\]+" + test_demangling "arm: g__FUsCUsT1" \ + "g\[(\]+unsigned short, (const unsigned short|unsigned short const), unsigned short\[)\]+" + test_demangling "arm: g__FPsPCsT1" \ + "g\[(\]+short \[*\]+, (const short|short const) \[*\]+, short \[*\]+\[)\]+" + test_demangling "arm: g__FUcCUcT1" \ + "g\[(\]+unsigned char, (const unsigned char|unsigned char const), unsigned char\[)\]+" + test_demangling "arm: g__FPcPCcT1" \ + "g\[(\]+char \[*\]+, (const char|char const) \[*\]+, char \[*\]+\[)\]+" + test_demangling "arm: g__F1TlClT2" \ + "g\[(\]+T, long, (const long|long const), long\[)\]+" + test_demangling "arm: g__F1TiCiT2" \ + "g\[(\]+T, int, (const int|int const), int\[)\]+" + test_demangling "arm: g__F1TsCsT2" \ + "g\[(\]+T, short, (const short|short const), short\[)\]+" + test_demangling "arm: g__F1TcCcT2" \ + "g\[(\]+T, char, (const char|char const), char\[)\]+" + + test_demangling_exact "arm: __dl__17T5__pt__8_PFcPv_iSFPv" "T5<int (*)(char, void *)>::operator delete(void *) static" + + test_demangling "arm: printf__FPCce" \ + "printf\[(\]+(const char|char const) \[*\]+,...\[)\]+" + + test_demangling_exact "arm: X__17T5__pt__8_PFcPv_i" "T5<int (*)(char, void *)>::X" + + test_demangling_exact "arm: __ct__12T5__pt__3_1xFi" "T5<x>::T5(int)" + + test_demangling "arm: g__F1SRUlRCUlT2" \ + "g\[(\]+S, unsigned long &, (const unsigned long|unsigned long const) &, unsigned long &\[)\]+" + test_demangling "arm: g__F1SRPlRPClT2" \ + "g\[(\]+S, long \[*\]+&, (const long|long const) \[*\]+&, long \[*\]+&\[)\]+" + test_demangling "arm: g__F1RRUiRCUiT2" \ + "g\[(\]+R, unsigned int &, (const unsigned int|unsigned int const) &, unsigned int &\[)\]+" + test_demangling "arm: g__F1SRPiRPCiT2" \ + "g\[(\]+S, int \[*\]+&, (const int|int const) \[*\]+&, int \[*\]+&\[)\]+" + test_demangling "arm: g__F1RRUsRCUsT2" \ + "g\[(\]+R, unsigned short &, (const unsigned short|unsigned short const) &, unsigned short &\[)\]+" + test_demangling "arm: g__F1SRPsRPCsT2" \ + "g\[(\]+S, short \[*\]+&, (const short|short const) \[*\]+&, short \[*\]+&\[)\]+" + test_demangling "arm: g__F1RRUcRCUcT2" \ + "g\[(\]+R, unsigned char &, (const unsigned char|unsigned char const) &, unsigned char &\[)\]+" + test_demangling "arm: g__F1SRPcRPCcT2" \ + "g\[(\]+S, char \[*\]+&, (const char|char const) \[*\]+&, char \[*\]+&\[)\]+" + test_demangling "arm: g__F1T1RRlRClT3" \ + "g\[(\]+T, R, long &, (const long|long const) &, long &\[)\]+" + test_demangling "arm: g__F1T1RRiRCiT3" \ + "g\[(\]+T, R, int &, (const int|int const) &, int &\[)\]+" + test_demangling "arm: g__F1T1RRsRCsT3" \ + "g\[(\]+T, R, short &, (const short|short const) &, short &\[)\]+" + test_demangling "arm: g__F1T1RRcRCcT3" \ + "g\[(\]+T, R, char &, (const char|char const) &, char &\[)\]+" + + test_demangling_exact "arm: __dl__21T5__pt__11_PFiPPdPv_iSFPv" "T5<int (*)(int, double **, void *)>::operator delete(void *) static" + + test_demangling_exact "arm: __std__foo" "global destructors keyed to foo" + + test_demangling_exact "arm: __sti__bar" "global constructors keyed to bar" + + test_demangling_exact "arm: f__FicdPcPFci_v" "f(int, char, double, char *, void (*)(char, int))" + test_demangling_exact "arm: f__FicdPcPFic_v" "f(int, char, double, char *, void (*)(int, char))" + test_demangling_exact "arm: get__2T7SFv" "T7::get(void) static" + + test_demangling_exact "arm: X__21T5__pt__11_PFiPPdPv_i" "T5<int (*)(int, double **, void *)>::X" + + test_demangling "arm: g__FcRdRCdT2" \ + "g\[(\]+char, double &, (const double|double const) &, double &\[)\]+" + test_demangling "arm: g__FcRfRCfT2" \ + "g\[(\]+char, float &, (const float|float const) &, float &\[)\]+" + test_demangling "arm: __md__FC2T2i" \ + "operator%\[(\]+(const T2|T2 const), int\[)\]+" + test_demangling "arm: __dv__FC2T2i" \ + "operator/\[(\]+(const T2|T2 const), int\[)\]+" + test_demangling "arm: __ml__FC2T2i" \ + "operator\[*\]+\[(\]+(const T2|T2 const), int\[)\]+" + test_demangling "arm: __mi__FC2T2i" \ + "operator-\[(\]+(const T2|T2 const), int\[)\]+" + test_demangling "arm: __pl__FC2T2i" \ + "operator\[+\]+\[(\]+(const T2|T2 const), int\[)\]+" + + test_demangling_exact "arm: __dl__11T5__pt__2_iSFPv" "T5<int>::operator delete(void *) static" + + test_demangling_exact "arm: __dl__11T5__pt__2_cSFPv" "T5<char>::operator delete(void *) static" + + test_demangling_exact "arm: h__Fc" "h(char)" + test_demangling_exact "arm: h__Fd" "h(double)" + test_demangling_exact "arm: h__Ff" "h(float)" + test_demangling_exact "arm: h__Fi" "h(int)" + test_demangling_exact "arm: f__Fi" "f(int)" + test_demangling_exact "arm: h__Fl" "h(long)" + + test_demangling_exact "arm: h__Fs" "h(short)" + test_demangling "arm: __md__FC2T2RC2T2" \ + "operator%\[(\]+(const T2|T2 const), (const T2|T2 const) &\[)\]+" + test_demangling "arm: __dv__FC2T2RC2T2" \ + "operator/\[(\]+(const T2|T2 const), (const T2|T2 const) &\[)\]+" + test_demangling "arm: __ml__FC2T2RC2T2" \ + "operator\[*\]+\[(\]+(const T2|T2 const), (const T2|T2 const) &\[)\]+" + test_demangling "arm: __mi__FC2T2RC2T2" \ + "operator-\[(\]+(const T2|T2 const), (const T2|T2 const) &\[)\]+" + test_demangling "arm: __pl__FC2T2RC2T2" \ + "operator\[+\]+\[(\]+(const T2|T2 const), (const T2|T2 const) &\[)\]+" + test_demangling "arm: g__FcRP1cRPC1cT2" \ + "g\[(\]+char, c *\[*\]+&, (const c|c const) *\[*\]+&, c *\[*\]+&\[)\]+" + + test_demangling_exact "arm: X__11T5__pt__2_c" "T5<char>::X" + + test_demangling_exact "arm: X__11T5__pt__2_i" "T5<int>::X" + + test_demangling "arm: g__FdCdT1" \ + "g\[(\]+double, (const double|double const), double\[)\]+" + test_demangling "arm: g__FfCfT1" \ + "g\[(\]+float, (const float|float const), float\[)\]+" + test_demangling "arm: g__FlClT1" \ + "g\[(\]+long, (const long|long const), long\[)\]+" + test_demangling "arm: g__FiCiT1" \ + "g\[(\]+int, (const int|int const), int\[)\]+" + test_demangling "arm: g__FsCsT1" \ + "g\[(\]+short, (const short|short const), short\[)\]+" + test_demangling "arm: g__FcCcT1" \ + "g\[(\]+char, (const char|char const), char\[)\]+" + + test_demangling_exact "arm: __ct__17T5__pt__8_PFcPv_iFi" "T5<int (*)(char, void *)>::T5(int)" + + test_demangling_exact "arm: f__FicdPc" "f(int, char, double, char *)" + test_demangling_exact "arm: __nw__FUi" "operator new(unsigned int)" + test_demangling_exact "arm: __ct__Q3_2T11a1bSFi" "T1::a::b::b(int) static" + test_demangling_exact "arm: __dt__Q3_2T11a1bSFi" "T1::a::b::~b(int) static" + test_demangling_exact "arm: put__Q3_2T11a1bSFi" "T1::a::b::put(int) static" + test_demangling_exact "arm: get__Q2_2T11aSFv" "T1::a::get(void) static" + test_demangling_exact "arm: put__2T1SFi" "T1::put(int) static" + test_demangling_exact "arm: put__Q5_2T11a1b1c1dSFi" "T1::a::b::c::d::put(int) static" + test_demangling_exact "arm: get__Q4_2T11a1b1cSFv" "T1::a::b::c::get(void) static" + test_demangling_exact "arm: put__Q2_2T11aSFi" "T1::a::put(int) static" + test_demangling_exact "arm: put__Q4_2T11a1b1cSFi" "T1::a::b::c::put(int) static" + test_demangling_exact "arm: get__Q3_2T11a1bSFv" "T1::a::b::get(void) static" + test_demangling_exact "arm: get__2T1SFv" "T1::get(void) static" + test_demangling_exact "arm: get__Q5_2T11a1b1c1dSFv" "T1::a::b::c::d::get(void) static" + + test_demangling_exact "arm: __dt__11T1__pt__2_cFv" "T1<char>::~T1(void)" + + test_demangling_exact "arm: __dt__12T1__pt__3_1tFv" "T1<t>::~T1(void)" + + test_demangling_exact "arm: __dl__12T1__pt__3_1tSFPv" "T1<t>::operator delete(void *) static" + + test_demangling_exact "arm: __ct__11T1__pt__2_cFi" "T1<char>::T1(int)" + + test_demangling_exact "arm: __ct__11T1__pt__2_cFv" "T1<char>::T1(void)" + + test_demangling_exact "arm: __ct__12T1__pt__3_1tFi" "T1<t>::T1(int)" + + test_demangling_exact "arm: __ct__12T1__pt__3_1tFv" "T1<t>::T1(void)" + + test_demangling_exact "arm: __dl__11T1__pt__2_cSFPv" "T1<char>::operator delete(void *) static" + + test_demangling_exact "arm: bar__3fooFPv" "foo::bar(void *)" + test_demangling "arm: bar__3fooFPCv" \ + "foo::bar\[(\]+(const void|void const) *\[*\]+\[)\]+" + test_demangling_exact "arm: bar__3fooCFPv" "foo::bar(void *) const" + test_demangling "arm: bar__3fooCFPCv" \ + "foo::bar\[(\]+(const void|void const) *\[*\]+\[)\]+ const" + test_demangling_exact "arm: __eq__3fooFR3foo" "foo::operator==(foo &)" + test_demangling "arm: __eq__3fooFRC3foo" \ + "foo::operator==\[(\]+(const foo|foo const) &\[)\]+" + test_demangling_exact "arm: __eq__3fooCFR3foo" "foo::operator==(foo &) const" + test_demangling "arm: __eq__3fooCFRC3foo" \ + "foo::operator==\[(\]+(const foo|foo const) &\[)\]+ const" + + test_demangling_exact "arm: elem__15vector__pt__2_dFi" "vector<double>::elem(int)" + + test_demangling_exact "arm: elem__15vector__pt__2_iFi" "vector<int>::elem(int)" + + test_demangling_exact "arm: __ct__15vector__pt__2_dFi" "vector<double>::vector(int)" + + test_demangling_exact "arm: __ct__15vector__pt__2_iFi" "vector<int>::vector(int)" + + test_demangling_exact "arm: __ct__25DListNode__pt__9_R6RLabelFR6RLabelP25DListNode__pt__9_R6RLabelT2" \ + "DListNode<RLabel &>::DListNode(RLabel &, DListNode<RLabel &> *, DListNode<RLabel &> *)" + + test_demangling_exact "arm: bar__3fooFiT16FooBar" "foo::bar(int, int, FooBar)" + + test_demangling_exact "arm: bar__3fooFPiN51PdN37PcN211T1iN215" \ + "foo::bar(int *, int *, int *, int *, int *, int *, double *, double *, double *, double *, char *, char *, char *, int *, int, int, int)" + + test_demangling_exact "arm: _Utf390_1__1_9223372036854775807__9223372036854775" \ + "Can't demangle \"_Utf390_1__1_9223372036854775807__9223372036854775\"" +} + +proc test_hp_style_demangling {} { + + # HP aCC mangling style is based on ARM for all the basic stuff, + # so first we use some of the ARM tests here. Later we have HP-specific + # tests. + + test_demangling "hp: g__FP1cPC1cT1" \ + "g\[(\]+c *\[*\]+, (const c|c const) *\[*\]+, c *\[*\]+\[)\]+" + test_demangling "hp: g__FPUlPCUlT1" \ + "g\[(\]+unsigned long \[*\]+, (const unsigned long|unsigned long const) \[*\]+, unsigned long \[*\]+\[)\]+" + test_demangling "hp: g__FPUiPCUiT1" \ + "g\[(\]+unsigned int \[*\]+, (const unsigned int|unsigned int const) \[*\]+, unsigned int \[*\]+\[)\]+" + test_demangling "hp: g__FPUsPCUsT1" \ + "g\[(\]+unsigned short \[*\]+, (const unsigned short|unsigned short const) \[*\]+, unsigned short \[*\]+\[)\]+" + test_demangling "hp: g__FPUcPCUcT1" \ + "g\[(\]+unsigned char \[*\]+, (const unsigned char|unsigned char const) \[*\]+, unsigned char \[*\]+\[)\]+" + test_demangling "hp: g__F1TPlPClT2" \ + "g\[(\]+T, long \[*\]+, (const long|long const) \[*\]+, long \[*\]+\[)\]+" + test_demangling "hp: g__F1RRlRClT2" \ + "g\[(\]+R, long &, (const long|long const) &, long &\[)\]+" + test_demangling "hp: g__F1TPiPCiT2" \ + "g\[(\]+T, int \[*\]+, (const int|int const) \[*\]+, int \[*\]+\[)\]+" + test_demangling "hp: g__F1RRiRCiT2" \ + "g\[(\]+R, int &, (const int|int const) &, int &\[)\]+" + test_demangling "hp: g__F1TPsPCsT2" \ + "g\[(\]+T, short \[*\]+, (const short|short const) \[*\]+, short \[*\]+\[)\]+" + test_demangling "hp: g__F1RRsRCsT2" \ + "g\[(\]+R, short &, (const short|short const) &, short &\[)\]+" + test_demangling "hp: g__F1TPcPCcT2" \ + "g\[(\]+T, char \[*\]+, (const char|char const) \[*\]+, char \[*\]+\[)\]+" + test_demangling "hp: g__F1RRcRCcT2" \ + "g\[(\]+R, char &, (const char|char const) &, char &\[)\]+" + + test_demangling "hp: __gt__FRC2T2c" \ + "operator>\[(\]+(const T2|T2 const) &, char\[)\]+" + test_demangling "hp: __ge__FRC2T2c" \ + "operator>=\[(\]+(const T2|T2 const) &, char\[)\]+" + test_demangling "hp: __lt__FRC2T2c" \ + "operator<\[(\]+(const T2|T2 const) &, char\[)\]+" + + test_demangling "hp: __le__FRC2T2c" \ + "operator<=\[(\]+(const T2|T2 const) &, char\[)\]+" + test_demangling "hp: __ne__FRC2T2c" \ + "operator!=\[(\]+(const T2|T2 const) &, char\[)\]+" + test_demangling "hp: __eq__FRC2T2c" \ + "operator==\[(\]+(const T2|T2 const) &, char\[)\]+" + test_demangling_exact "hp: __amd__FR2T2i" "operator%=(T2 &, int)" + test_demangling_exact "hp: __adv__FR2T2i" "operator/=(T2 &, int)" + test_demangling_exact "hp: __amu__FR2T2i" "operator*=(T2 &, int)" + test_demangling_exact "hp: __ami__FR2T2i" "operator-=(T2 &, int)" + test_demangling_exact "hp: __apl__FR2T2i" "operator+=(T2 &, int)" + test_demangling_exact "hp: __nw__2T1SFUi" "T1::operator new(unsigned int) static" + test_demangling_exact "hp: __dl__2T1SFPv" "T1::operator delete(void *) static" + test_demangling_exact "hp: put__2T7SFi" "T7::put(int) static" + + test_demangling_exact "hp: h__FUc" "h(unsigned char)" + test_demangling_exact "hp: f__Fic" "f(int, char)" + test_demangling_exact "hp: h__FUi" "h(unsigned int)" + test_demangling_exact "hp: h__Fci" "h(char, int)" + test_demangling_exact "hp: h__FUl" "h(unsigned long)" + test_demangling_exact "hp: h__Fcl" "h(char, long)" + test_demangling_exact "hp: h__FUs" "h(unsigned short)" + test_demangling_exact "hp: h__Fcs" "h(char, short)" + test_demangling "hp: __amd__FR2T2RC2T2" \ + "operator%=\[(\]+T2 &, (const T2|T2 const) &\[)\]+" + test_demangling "hp: __adv__FR2T2RC2T2" \ + "operator/=\[(\]+T2 &, (const T2|T2 const) &\[)\]+" + test_demangling "hp: __amu__FR2T2RC2T2" \ + "operator\[*\]+=\[(\]+T2 &, (const T2|T2 const) &\[)\]+" + test_demangling "hp: __ami__FR2T2RC2T2" \ + "operator-=\[(\]+T2 &, (const T2|T2 const) &\[)\]+" + test_demangling "hp: __apl__FR2T2RC2T2" \ + "operator\[+\]+=\[(\]+T2 &, (const T2|T2 const) &\[)\]+" + + test_demangling "hp: g__F1SRPUlRPCUlT2" \ + "g\[(\]+S, unsigned long \[*\]+&, (const unsigned long|unsigned long const) \[*\]+&, unsigned long \[*\]+&\[)\]+" + test_demangling "hp: g__F1SRPUiRPCUiT2" \ + "g\[(\]+S, unsigned int \[*\]+&, (const unsigned int|unsigned int const) \[*\]+&, unsigned int \[*\]+&\[)\]+" + test_demangling "hp: g__F1SRPUsRPCUsT2" \ + "g\[(\]+S, unsigned short \[*\]+&, (const unsigned short|unsigned short const) \[*\]+&, unsigned short \[*\]+&\[)\]+" + test_demangling "hp: g__F1SRPUcRPCUcT2" \ + "g\[(\]+S, unsigned char \[*\]+&, (const unsigned char|unsigned char const) \[*\]+&, unsigned char \[*\]+&\[)\]+" + test_demangling "hp: g__F1T1SRPlRPClT3" \ + "g\[(\]+T, S, long \[*\]+&, (const long|long const) \[*\]+&, long \[*\]+&\[)\]+" + test_demangling "hp: g__F1T1SRPiRPCiT3" \ + "g\[(\]+T, S, int \[*\]+&, (const int|int const) \[*\]+&, int \[*\]+&\[)\]+" + test_demangling "hp: g__F1T1SRPcRPCcT3" \ + "g\[(\]+T, S, char \[*\]+&, (const char|char const) \[*\]+&, char \[*\]+&\[)\]+" + + + test_demangling "hp: __gt__FRC2T2T1" \ + "operator>\[(\]+(const T2|T2 const) &, (const T2|T2 const) &\[)\]+" + test_demangling "hp: __ge__FRC2T2T1" \ + "operator>=\[(\]+(const T2|T2 const) &, (const T2|T2 const) &\[)\]+" + test_demangling "hp: __lt__FRC2T2T1" \ + "operator<\[(\]+(const T2|T2 const) &, (const T2|T2 const) &\[)\]+" + test_demangling "hp: __le__FRC2T2T1" \ + "operator<=\[(\]+(const T2|T2 const) &, (const T2|T2 const) &\[)\]+" + test_demangling "hp: __ne__FRC2T2T1" \ + "operator!=\[(\]+(const T2|T2 const) &, (const T2|T2 const) &\[)\]+" + test_demangling "hp: __eq__FRC2T2T1" \ + "operator==\[(\]+(const T2|T2 const) &, (const T2|T2 const) &\[)\]+" + test_demangling "hp: g__FcR1cRC1cT2" \ + "g\[(\]+char, c &, (const c|c const) &, c &\[)\]+" + test_demangling "hp: g__FcRPdRPCdT2" \ + "g\[(\]+char, double *\[*\]+&, (const double|double const) *\[*\]+&, double *\[*\]+&\[)\]+" + test_demangling "hp: g__FcRPfRPCfT2" \ + "g\[(\]+char, float *\[*\]+&, (const float|float const) *\[*\]+&, float *\[*\]+&\[)\]+" + test_demangling_exact "hp: h__FcT1" "h(char, char)" + test_demangling_exact "hp: f__Ficd" "f(int, char, double)" + test_demangling "hp: g__F1T1SdRPsRPCsT4" \ + "g\[(\]+T, S, double, short \[*\]+&, (const short|short const) \[*\]+&, short \[*\]+&\[)\]+" + test_demangling "hp: g__F1cC1cT1" \ + "g\[(\]+c, (const c|c const), c\[)\]+" + test_demangling "hp: g__FPdPCdT1" \ + "g\[(\]+double *\[*\]+, (const double|double const) *\[*\]+, double *\[*\]+\[)\]+" + test_demangling "hp: g__FPfPCfT1" \ + "g\[(\]+float *\[*\]+, (const float|float const) *\[*\]+, float *\[*\]+\[)\]+" + + test_demangling "hp: g__FUlCUlT1" \ + "g\[(\]+unsigned long, (const unsigned long|unsigned long const), unsigned long\[)\]+" + test_demangling "hp: g__FPlPClT1" \ + "g\[(\]+long \[*\]+, (const long|long const) \[*\]+, long \[*\]+\[)\]+" + test_demangling "hp: g__FUiCUiT1" \ + "g\[(\]+unsigned int, (const unsigned int|unsigned int const), unsigned int\[)\]+" + test_demangling "hp: g__FPiPCiT1" \ + "g\[(\]+int \[*\]+, (const int|int const) \[*\]+, int \[*\]+\[)\]+" + test_demangling "hp: g__FUsCUsT1" \ + "g\[(\]+unsigned short, (const unsigned short|unsigned short const), unsigned short\[)\]+" + test_demangling "hp: g__FPsPCsT1" \ + "g\[(\]+short \[*\]+, (const short|short const) \[*\]+, short \[*\]+\[)\]+" + test_demangling "hp: g__FUcCUcT1" \ + "g\[(\]+unsigned char, (const unsigned char|unsigned char const), unsigned char\[)\]+" + test_demangling "hp: g__FPcPCcT1" \ + "g\[(\]+char \[*\]+, (const char|char const) \[*\]+, char \[*\]+\[)\]+" + test_demangling "hp: g__F1TlClT2" \ + "g\[(\]+T, long, (const long|long const), long\[)\]+" + test_demangling "hp: g__F1TiCiT2" \ + "g\[(\]+T, int, (const int|int const), int\[)\]+" + test_demangling "hp: g__F1TsCsT2" \ + "g\[(\]+T, short, (const short|short const), short\[)\]+" + test_demangling "hp: g__F1TcCcT2" \ + "g\[(\]+T, char, (const char|char const), char\[)\]+" + + test_demangling "hp: printf__FPCce" \ + "printf\[(\]+(const char|char const) \[*\]+,...\[)\]+" + + + test_demangling "hp: g__F1SRUlRCUlT2" \ + "g\[(\]+S, unsigned long &, (const unsigned long|unsigned long const) &, unsigned long &\[)\]+" + test_demangling "hp: g__F1SRPlRPClT2" \ + "g\[(\]+S, long \[*\]+&, (const long|long const) \[*\]+&, long \[*\]+&\[)\]+" + test_demangling "hp: g__F1RRUiRCUiT2" \ + "g\[(\]+R, unsigned int &, (const unsigned int|unsigned int const) &, unsigned int &\[)\]+" + test_demangling "hp: g__F1SRPiRPCiT2" \ + "g\[(\]+S, int \[*\]+&, (const int|int const) \[*\]+&, int \[*\]+&\[)\]+" + test_demangling "hp: g__F1RRUsRCUsT2" \ + "g\[(\]+R, unsigned short &, (const unsigned short|unsigned short const) &, unsigned short &\[)\]+" + test_demangling "hp: g__F1SRPsRPCsT2" \ + "g\[(\]+S, short \[*\]+&, (const short|short const) \[*\]+&, short \[*\]+&\[)\]+" + test_demangling "hp: g__F1RRUcRCUcT2" \ + "g\[(\]+R, unsigned char &, (const unsigned char|unsigned char const) &, unsigned char &\[)\]+" + test_demangling "hp: g__F1SRPcRPCcT2" \ + "g\[(\]+S, char \[*\]+&, (const char|char const) \[*\]+&, char \[*\]+&\[)\]+" + test_demangling "hp: g__F1T1RRlRClT3" \ + "g\[(\]+T, R, long &, (const long|long const) &, long &\[)\]+" + test_demangling "hp: g__F1T1RRiRCiT3" \ + "g\[(\]+T, R, int &, (const int|int const) &, int &\[)\]+" + test_demangling "hp: g__F1T1RRsRCsT3" \ + "g\[(\]+T, R, short &, (const short|short const) &, short &\[)\]+" + test_demangling "hp: g__F1T1RRcRCcT3" \ + "g\[(\]+T, R, char &, (const char|char const) &, char &\[)\]+" + + + test_demangling_exact "hp: f__FicdPcPFci_v" "f(int, char, double, char *, void (*)(char, int))" + test_demangling_exact "hp: f__FicdPcPFic_v" "f(int, char, double, char *, void (*)(int, char))" + test_demangling_exact "hp: get__2T7SFv" "T7::get(void) static" + + + test_demangling "hp: g__FcRdRCdT2" \ + "g\[(\]+char, double &, (const double|double const) &, double &\[)\]+" + test_demangling "hp: g__FcRfRCfT2" \ + "g\[(\]+char, float &, (const float|float const) &, float &\[)\]+" + test_demangling "hp: __md__FC2T2i" \ + "operator%\[(\]+(const T2|T2 const), int\[)\]+" + test_demangling "hp: __dv__FC2T2i" \ + "operator/\[(\]+(const T2|T2 const), int\[)\]+" + test_demangling "hp: __ml__FC2T2i" \ + "operator\[*\]+\[(\]+(const T2|T2 const), int\[)\]+" + test_demangling "hp: __mi__FC2T2i" \ + "operator-\[(\]+(const T2|T2 const), int\[)\]+" + test_demangling "hp: __pl__FC2T2i" \ + "operator\[+\]+\[(\]+(const T2|T2 const), int\[)\]+" + + + test_demangling_exact "hp: h__Fc" "h(char)" + test_demangling_exact "hp: h__Fd" "h(double)" + test_demangling_exact "hp: h__Ff" "h(float)" + test_demangling_exact "hp: h__Fi" "h(int)" + test_demangling_exact "hp: f__Fi" "f(int)" + test_demangling_exact "hp: h__Fl" "h(long)" + + test_demangling_exact "hp: h__Fs" "h(short)" + test_demangling "hp: __md__FC2T2RC2T2" \ + "operator%\[(\]+(const T2|T2 const), (const T2|T2 const) &\[)\]+" + test_demangling "hp: __dv__FC2T2RC2T2" \ + "operator/\[(\]+(const T2|T2 const), (const T2|T2 const) &\[)\]+" + test_demangling "hp: __ml__FC2T2RC2T2" \ + "operator\[*\]+\[(\]+(const T2|T2 const), (const T2|T2 const) &\[)\]+" + test_demangling "hp: __mi__FC2T2RC2T2" \ + "operator-\[(\]+(const T2|T2 const), (const T2|T2 const) &\[)\]+" + test_demangling "hp: __pl__FC2T2RC2T2" \ + "operator\[+\]+\[(\]+(const T2|T2 const), (const T2|T2 const) &\[)\]+" + test_demangling "hp: g__FcRP1cRPC1cT2" \ + "g\[(\]+char, c *\[*\]+&, (const c|c const) *\[*\]+&, c *\[*\]+&\[)\]+" + + + test_demangling "hp: g__FdCdT1" \ + "g\[(\]+double, (const double|double const), double\[)\]+" + test_demangling "hp: g__FfCfT1" \ + "g\[(\]+float, (const float|float const), float\[)\]+" + test_demangling "hp: g__FlClT1" \ + "g\[(\]+long, (const long|long const), long\[)\]+" + test_demangling "hp: g__FiCiT1" \ + "g\[(\]+int, (const int|int const), int\[)\]+" + test_demangling "hp: g__FsCsT1" \ + "g\[(\]+short, (const short|short const), short\[)\]+" + test_demangling "hp: g__FcCcT1" \ + "g\[(\]+char, (const char|char const), char\[)\]+" + + + test_demangling_exact "hp: f__FicdPc" "f(int, char, double, char *)" + test_demangling_exact "hp: __nw__FUi" "operator new(unsigned int)" + test_demangling_exact "hp: __ct__Q3_2T11a1bSFi" "T1::a::b::b(int) static" + test_demangling_exact "hp: __dt__Q3_2T11a1bSFi" "T1::a::b::~b(int) static" + test_demangling_exact "hp: put__Q3_2T11a1bSFi" "T1::a::b::put(int) static" + test_demangling_exact "hp: get__Q2_2T11aSFv" "T1::a::get(void) static" + test_demangling_exact "hp: put__2T1SFi" "T1::put(int) static" + test_demangling_exact "hp: put__Q5_2T11a1b1c1dSFi" "T1::a::b::c::d::put(int) static" + test_demangling_exact "hp: get__Q4_2T11a1b1cSFv" "T1::a::b::c::get(void) static" + test_demangling_exact "hp: put__Q2_2T11aSFi" "T1::a::put(int) static" + test_demangling_exact "hp: put__Q4_2T11a1b1cSFi" "T1::a::b::c::put(int) static" + test_demangling_exact "hp: get__Q3_2T11a1bSFv" "T1::a::b::get(void) static" + test_demangling_exact "hp: get__2T1SFv" "T1::get(void) static" + test_demangling_exact "hp: get__Q5_2T11a1b1c1dSFv" "T1::a::b::c::d::get(void) static" + + + test_demangling_exact "hp: bar__3fooFPv" "foo::bar(void *)" + test_demangling "hp: bar__3fooFPCv" \ + "foo::bar\[(\]+(const void|void const) *\[*\]+\[)\]+" + test_demangling_exact "hp: bar__3fooCFPv" "foo::bar(void *) const" + test_demangling "hp: bar__3fooCFPCv" \ + "foo::bar\[(\]+(const void|void const) *\[*\]+\[)\]+ const" + test_demangling_exact "hp: __eq__3fooFR3foo" "foo::operator==(foo &)" + test_demangling "hp: __eq__3fooFRC3foo" \ + "foo::operator==\[(\]+(const foo|foo const) &\[)\]+" + test_demangling_exact "hp: __eq__3fooCFR3foo" "foo::operator==(foo &) const" + test_demangling "hp: __eq__3fooCFRC3foo" \ + "foo::operator==\[(\]+(const foo|foo const) &\[)\]+ const" + + test_demangling_exact "hp: bar__3fooFiT16FooBar" "foo::bar(int, int, FooBar)" + + test_demangling_exact "hp: bar__3fooFPiN51PdN37PcN211T1iN215" \ + "foo::bar(int *, int *, int *, int *, int *, int *, double *, double *, double *, double *, char *, char *, char *, int *, int, int, int)" + + + # HP aCC specific tests. HP aCC demangling does not use __pt__ for + # template specifications. There are other differences as well. + + test_demangling_exact "hp: __dt__2T5XTPFiPPdPv_i__Fv" "T5<int (*)(int, double **, void *)>::~T5(void)" + + test_demangling_exact "hp: __ct__1cFi" "c::c(int)" + + test_demangling_exact "hp: __dt__2T5XTi__Fv" "T5<int>::~T5(void)" + + test_demangling_exact "hp: __dt__2T5XTc__Fv" "T5<char>::~T5(void)" + + test_demangling_exact "hp: __ct__2T2Fi" "T2::T2(int)" + test_demangling_exact "hp: __dt__2T1Fv" "T1::~T1(void)" + + test_demangling_exact "hp: __dt__2T5XT1x__Fv" "T5<x>::~T5(void)" + + test_demangling_exact "hp: __dt__2T5XTPFcPv_i__Fv" "T5<int (*)(char, void *)>::~T5(void)" + + test_demangling_exact "hp: __ct__2T5XTPFiPPdPv_i__Fi" "T5<int (*)(int, double **, void *)>::T5(int)" + + test_demangling_exact "hp: __dl__2T5XT1x__SFPv" "T5<x>::operator delete(void *) static" + + test_demangling_exact "hp: X__2T5XT1x" "T5<x>::X" + + test_demangling_exact "hp: __ct__2T5XTi__Fi" "T5<int>::T5(int)" + + test_demangling_exact "hp: __ct__2T5XTc__Fi" "T5<char>::T5(int)" + + test_demangling_exact "hp: __dl__2T5XTPFcPv_i__SFPv" "T5<int (*)(char, void *)>::operator delete(void *) static" + + test_demangling_exact "hp: X__2T5XTPFcPv_i" "T5<int (*)(char, void *)>::X" + + test_demangling_exact "hp: __ct__2T5XT1x__Fi" "T5<x>::T5(int)" + + test_demangling_exact "hp: __dl__2T5XTPFiPPdPv_i__SFPv" "T5<int (*)(int, double **, void *)>::operator delete(void *) static" + test_demangling_exact "hp: X__2T5XTPFiPPdPv_i" "T5<int (*)(int, double **, void *)>::X" + + test_demangling_exact "hp: __dl__2T5XTi__SFPv" "T5<int>::operator delete(void *) static" + + test_demangling_exact "hp: __dl__2T5XTc__SFPv" "T5<char>::operator delete(void *) static" + + test_demangling_exact "hp: X__2T5XTc" "T5<char>::X" + + test_demangling_exact "hp: X__2T5XTi" "T5<int>::X" + + test_demangling_exact "hp: __ct__2T5XTPFcPv_i__Fi" "T5<int (*)(char, void *)>::T5(int)" + + test_demangling_exact "hp: __dt__2T1XTc__Fv" "T1<char>::~T1(void)" + + test_demangling_exact "hp: __dt__2T1XT1t__Fv" "T1<t>::~T1(void)" + + test_demangling_exact "hp: __dl__2T1XT1t__SFPv" "T1<t>::operator delete(void *) static" + + test_demangling_exact "hp: __ct__2T1XTc__Fi" "T1<char>::T1(int)" + + test_demangling_exact "hp: __ct__2T1XTc__Fv" "T1<char>::T1(void)" + + test_demangling_exact "hp: __ct__2T1XT1t__Fi" "T1<t>::T1(int)" + + test_demangling_exact "hp: __ct__2T1XT1t__Fv" "T1<t>::T1(void)" + + test_demangling_exact "hp: __dl__2T1XTc__SFPv" "T1<char>::operator delete(void *) static" + + test_demangling_exact "hp: elem__6vectorXTd__Fi" "vector<double>::elem(int)" + + test_demangling_exact "hp: elem__6vectorXTi__Fi" "vector<int>::elem(int)" + + test_demangling_exact "hp: __ct__6vectorXTd__Fi" "vector<double>::vector(int)" + + test_demangling_exact "hp: __ct__6vectorXTi__Fi" "vector<int>::vector(int)" + + test_demangling_exact "hp: __ct__9DListNodeXTR6RLabel__FR6RLabelP9DListNodeXTR6RLabel_T2" \ + "DListNode<RLabel &>::DListNode(RLabel &, DListNode<RLabel &> *, DListNode<RLabel &> *)" + + + # Absolute integer constants in template args + + test_demangling_exact "hp: elem__6vectorXTiUP34__Fi" "vector<int,34U>::elem(int)" + test_demangling_exact "hp: elem__6vectorXUP2701Td__Fi" "vector<2701U,double>::elem(int)" + test_demangling_exact "hp: elem__6vectorXTiSP334__Fi" "vector<int,334>::elem(int)" + test_demangling_exact "hp: elem__6vectorXTiSN67__Fi" "vector<int,-67>::elem(int)" + test_demangling_exact "hp: elem__6vectorXTiSM__SCFPPd" "vector<int,-2147483648>::elem(double **) static const" + test_demangling_exact "hp: elem__6vectorXTiSN67UP4000TRs__Fi" "vector<int,-67,4000U,short &>::elem(int)" + test_demangling_exact "hp: elem__6vectorXTiSN67TRdTFPv_i__Fi" "vector<int,-67,double &,int (void *)>::elem(int)" + test_demangling_exact "hp: X__6vectorXTiSN67TdTPvUP5TRs" "vector<int,-67,double,void *,5U,short &>::X" + + # Named constants in template args + + test_demangling_exact "hp: elem__6vectorXTiA3foo__Fi" "vector<int,&foo>::elem(int)" + test_demangling_exact "hp: elem__6vectorXTiA3fooTPvA5Label__FiPPvT2" "vector<int,&foo,void *,&Label>::elem(int, void **, void **)" + test_demangling_exact "hp: elem__6vectorXTiSN42A3foo__Fi" "vector<int,-42,&foo>::elem(int)" + + # Alternate entry points for functions + + test_demangling_exact "hp: __ct__2T5XTPFcPv_i__Fi_2" "T5<int (*)(char, void *)>::T5(int)" + test_demangling_exact "hp: __ct__2T5XTPFcPv_i__Fi_19" "T5<int (*)(char, void *)>::T5(int)" + test_demangling_exact "hp: f__FicdPcPFci_v_34" "f(int, char, double, char *, void (*)(char, int))" + + + # Template partial specializations + +# FIXME! The # characters don't go through expect, and backslashes don't seem to work. +# test_demangling_exact "hp: spec__13Spec<#1,#1.*>XTiTPi_FPi" "Spec<int,int *>::spec(int *)" +# test_demangling_exact "hp: spec__16Spec<#1,#1.&,#1>XTiTRiTi_FPi" "Spec<int,int &, int>::spec(int *)" +# Fake test -- replace # with % + test_demangling_exact "hp: spec__13Spec<%1,%1.*>XTiTPi_FPi" "Spec<int,int *>::spec(int *)" + test_demangling_exact "hp: spec__16Spec<%1,%1.&,%1>XTiTRiTi_FPi" "Spec<int,int &,int>::spec(int *)" + + # Global template functions + + test_demangling_exact "hp: add__XTc_FcT1" "add<char>(char, char)" + test_demangling_exact "hp: add__XTcSP9A5label_FcPPlT1" "add<char,9,&label>(char, long **, char)" + test_demangling_exact "hp: add__XTPfTFPd_f_FcT1" "add<float *,float (double *)>(char, char)" + + # Template for template arg + + test_demangling_exact "hp: unLink__12basic_stringXTcT18string_char_traitsXTc_T9allocator_Fv" "basic_string<char,string_char_traits<char>,allocator>::unLink(void)" + + test_demangling_exact "hp: _Utf390_1__1_9223372036854775807__9223372036854775" \ + "Can't demangle \"_Utf390_1__1_9223372036854775807__9223372036854775\"" +} + + +proc catch_demangling_errors {command} { + if {[catch $command result]} { + puts "ERROR: demangle.exp: while running $command: $result" + } +} + +# Test support for different demangling styles. Note that this does +# not depend upon running the test program and does not depend upon +# gdb being able to lookup any C++ symbols. It simply calls the +# internal demangler with synthesized strings and tests the results. + +proc do_tests {} { + global prms_id + global bug_id + global subdir + global gdb_prompt + + set prms_id 0 + set bug_id 0 + + # Start with a fresh gdb. + + gdb_exit + gdb_start + + send_gdb "set language c++\n" + gdb_expect -re "$gdb_prompt $" + send_gdb "set width 0\n" + gdb_expect -re "$gdb_prompt $" + + # Using catch_demangling_errors this way ensures that, if one of + # the functions raises a Tcl error, then it'll get reported, and + # the rest of the functions will still run. + catch_demangling_errors test_lucid_style_demangling + catch_demangling_errors test_gnu_style_demangling + catch_demangling_errors test_arm_style_demangling + catch_demangling_errors test_hp_style_demangling +} + +do_tests diff --git a/gdb/testsuite/gdb.cp/derivation.cc b/gdb/testsuite/gdb.cp/derivation.cc new file mode 100644 index 0000000..f6d42e7 --- /dev/null +++ b/gdb/testsuite/gdb.cp/derivation.cc @@ -0,0 +1,240 @@ +class A { +public: + int a; + int aa; + + A() + { + a=1; + aa=2; + } + int afoo(); + int foo(); + +}; + + + +class B { +public: + int b; + int bb; + + B() + { + b=3; + bb=4; + } + int bfoo(); + int foo(); + +}; + + + +class C { +public: + int c; + int cc; + + C() + { + c=5; + cc=6; + } + int cfoo(); + int foo(); + +}; + + + +class D : private A, public B, protected C { +public: + int d; + int dd; + + D() + { + d =7; + dd=8; + } + int dfoo(); + int foo(); + +}; + + +class E : public A, B, protected C { +public: + int e; + int ee; + + E() + { + e =9; + ee=10; + } + int efoo(); + int foo(); + +}; + + +class F : A, public B, C { +public: + int f; + int ff; + + F() + { + f =11; + ff=12; + } + int ffoo(); + int foo(); + +}; + +class G : private A, public B, protected C { +public: + int g; + int gg; + int a; + int b; + int c; + + G() + { + g =13; + gg =14; + a=15; + b=16; + c=17; + + } + int gfoo(); + int foo(); + +}; + + + + +int A::afoo() { + return 1; +} + +int B::bfoo() { + return 2; +} + +int C::cfoo() { + return 3; +} + +int D::dfoo() { + return 4; +} + +int E::efoo() { + return 5; +} + +int F::ffoo() { + return 6; +} + +int G::gfoo() { + return 77; +} + +int A::foo() +{ + return 7; + +} + +int B::foo() +{ + return 8; + +} + +int C::foo() +{ + return 9; + +} + +int D::foo() +{ + return 10; + +} + +int E::foo() +{ + return 11; + +} + +int F::foo() +{ + return 12; + +} + +int G::foo() +{ + return 13; + +} + + +void marker1() +{ +} + + +int main(void) +{ + + A a_instance; + B b_instance; + C c_instance; + D d_instance; + E e_instance; + F f_instance; + G g_instance; + + #ifdef usestubs + set_debug_traps(); + breakpoint(); + #endif + + + marker1(); // marker1-returns-here + + a_instance.a = 20; // marker1-returns-here + a_instance.aa = 21; + b_instance.b = 22; + b_instance.bb = 23; + c_instance.c = 24; + c_instance.cc = 25; + d_instance.d = 26; + d_instance.dd = 27; + e_instance.e = 28; + e_instance.ee =29; + f_instance.f =30; + f_instance.ff =31; + + + + + return 0; + +} + + + diff --git a/gdb/testsuite/gdb.cp/derivation.exp b/gdb/testsuite/gdb.cp/derivation.exp new file mode 100644 index 0000000..38a46a2 --- /dev/null +++ b/gdb/testsuite/gdb.cp/derivation.exp @@ -0,0 +1,337 @@ +# Copyright 1998, 1999, 2000, 2001, 2002 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# This file was written by Elena Zannoni (ezannoni@cygnus.com) + +# This file is part of the gdb testsuite +# + +# +# tests for inheritance, with several derivations types combinations (private, +# public, protected) +# classes have simple members and member functions. +# + + +if $tracelevel then { + strace $tracelevel + } + +# +# test running programs +# +set prms_id 0 +set bug_id 0 + +if { [skip_cplus_tests] } { continue } + +set testfile "derivation" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +# Create and source the file that provides information about the compiler +# used to compile the test case. + +if [get_compiler_info ${binfile} "c++"] { + return -1 +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +# +# set it up at a breakpoint so we can play with the variable values +# +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + +if ![runto 'marker1'] then { + perror "couldn't run to marker1" + continue +} + +gdb_test "up" ".*main.*" "up from marker1" + + + +send_gdb "print a_instance\n" +gdb_expect { + -re ".\[0-9\]* = \{a = 1, aa = 2\}\r\n$gdb_prompt $" { + pass "print value of a_instance" + } + -re ".*$gdb_prompt $" { fail "print value of a_instance" } + timeout { fail "(timeout) print value of a_instance" } + } + + +send_gdb "ptype a_instance\n" +gdb_expect { + -re "type = class A \{\r\n\[\t \]*public:\r\n\[\t \]*int a;\r\n\[\t \]*int aa;\[\r\n\t ]+A & operator=\\(A const ?&\\);\[\r\n\t ]+A\\((A const|const A) ?&\\);\[\r\n\t ]+A\\((void|)\\);\r\n\[\t \]*int afoo\\((void|)\\);\r\n\[\t \]*int foo\\((void|)\\);\r\n\}.*$gdb_prompt $" { pass "ptype a_instance (with synth ops)" } + -re "type = class A \{\r\n\[\t \]*public:\r\n\[\t \]*int a;\r\n\[\t \]*int aa;\[\r\n\t \]+A\\(void\\);\r\n\[\t \]*int afoo\\((void|)\\);\r\n\[\t \]*int foo\\((void|)\\);\r\n\}.*$gdb_prompt $" { pass "ptype a_instance (no synth ops)" } + -re ".*$gdb_prompt $" { fail "ptype a_instance" } + timeout { fail "(timeout) ptype a_instance" } +} + + +send_gdb "print d_instance\n" +gdb_expect { + -re ".\[0-9\]* = \{<A> = \{a = 1, aa = 2\}, <B> = \{b = 3, bb = 4\}, <C> = \{c = 5, cc = 6\}, d = 7, dd = 8\}\r\n$gdb_prompt $" { + pass "print value of d_instance" + } + -re ".\[0-9\]* = \{<class A> = \{a = 1, aa = 2\}, <class B> = \{b = 3, bb = 4\}, <class C> = \{c = 5, cc = 6\}, d = 7, dd = 8\}\r\n$gdb_prompt $" { + pass "print value of d_instance" + } + -re ".*$gdb_prompt $" { fail "print value of d_instance" } + timeout { fail "(timeout) print value of d_instance" } + } + + if {$gcc_compiled} then { + send_gdb "ptype d_instance\n" + gdb_expect { + -re "type = class D : private A, public B, (protected|private) C \{\r\n\[\t \]*public:\r\n\[\t \]*int d;\r\n\[\t \]*int dd;\[\r\n\t ]+D & operator=\\(D const ?&\\);\[\r\n\t ]+D\\((D const|const D) ?&\\);\[\r\n\t \]+D\\((void|)\\);\r\n\[\t \]*int dfoo\\((void|)\\);\r\n\[\t \]*int foo\\((void|)\\);\r\n\}.*$gdb_prompt $" { pass "ptype d_instance" } + -re "type = class D : private A, public B, (protected|private) C \{\r\n\[\t \]*public:\r\n\[\t \]*int d;\r\n\[\t \]*int dd;\[\r\n\t ]+D & operator=\\(D const ?&\\);\[\r\n\t ]+D\\((D const|const D) ?&\\);\[\r\n\t \]+D\\((void|)\\);\r\n\[\t \]*int dfoo\\((void|)\\);\r\n\[\t \]*int foo\\((void|)\\);\r\n\}.*$gdb_prompt $" { pass "ptype d_instance" } + -re "type = class D : private A, public B, (protected|private) C \{\r\n\[\t \]*public:\r\n\[\t \]*int d;\r\n\[\t \]*int dd;\[\r\n\t \]+D\\(void\\);\r\n\[\t \]*int dfoo\\((void|)\\);\r\n\[\t \]*int foo\\((void|)\\);\r\n\}.*$gdb_prompt $" { pass "ptype d_instance" } + -re ".*$gdb_prompt $" { fail "ptype d_instance" } + timeout { fail "(timeout) ptype d_instance" } + } + } else { + send_gdb "ptype d_instance\n" + gdb_expect { + -re "type = class D : private A, public B, protected C \{\r\n\[\t \]*public:\r\n\[\t \]*int d;\r\n\[\t \]*int dd;\[\r\n\t \]+D\\(void\\);\r\n\[\t \]*int dfoo\\((void|)\\);\r\n\[\t \]*int foo\\((void|)\\);\r\n\}.*$gdb_prompt $" { pass "ptype d_instance" } + -re ".*$gdb_prompt $" { fail "ptype d_instance" } + timeout { fail "(timeout) ptype d_instance" } + } + } + + +send_gdb "print e_instance\n" +gdb_expect { + -re ".\[0-9\]* = \{<A> = \{a = 1, aa = 2\}, <B> = \{b = 3, bb = 4\}, <C> = \{c = 5, cc = 6\}, e = 9, ee = 10\}\r\n$gdb_prompt $" { + pass "print value of e_instance" + } + -re ".\[0-9\]* = \{<class A> = \{a = 1, aa = 2\}, <class B> = \{b = 3, bb = 4\}, <class C> = \{c = 5, cc = 6\}, e = 9, ee = 10\}\r\n$gdb_prompt $" { + pass "print value of e_instance" + } + -re ".*$gdb_prompt $" { fail "print value of e_instance" } + timeout { fail "(timeout) print value of e_instance" } + } + + if {$gcc_compiled} { + send_gdb "ptype e_instance\n" + gdb_expect { + -re "type = class E : public A, private B, (protected|private) C \{\r\n\[\t \]*public:\r\n\[\t \]*int e;\r\n\[\t \]*int ee;\[\r\n\t ]+E & operator=\\(E const ?&\\);\[\r\n\t ]+E\\((E const|const E) ?&\\);\[\r\n\t \]+E\\((void|)\\);\r\n\[\t \]*int efoo\\((void|)\\);\r\n\[\t \]*int foo\\((void|)\\);\r\n\}.*$gdb_prompt $" { pass "ptype e_instance" } + -re "type = class E : public A, private B, (protected|private) C \{\r\n\[\t \]*public:\r\n\[\t \]*int e;\r\n\[\t \]*int ee;\[\r\n\t \]+E\\((void|)\\);\r\n\[\t \]*int efoo\\((void|)\\);\r\n\[\t \]*int foo\\((void|)\\);\r\n\}.*$gdb_prompt $" { pass "ptype e_instance" } + -re ".*$gdb_prompt $" { fail "ptype e_instance" } + timeout { fail "(timeout) ptype e_instance" } + } + } else { + send_gdb "ptype e_instance\n" + gdb_expect { + -re "type = class E : public A, private B, protected C \{\r\n\[\t \]*public:\r\n\[\t \]*int e;\r\n\[\t \]*int ee;\[\r\n\t \]+E\\((void|)\\);\r\n\[\t \]*int efoo\\((void|)\\);\r\n\[\t \]*int foo\\((void|)\\);\r\n\}.*$gdb_prompt $" { pass "ptype e_instance" } + -re ".*$gdb_prompt $" { fail "ptype e_instance" } + timeout { fail "(timeout) ptype e_instance" } + } + } + + +send_gdb "print f_instance\n" +gdb_expect { + -re ".\[0-9\]* = \{<A> = \{a = 1, aa = 2\}, <B> = \{b = 3, bb = 4\}, <C> = \{c = 5, cc = 6\}, f = 11, ff = 12\}\r\n$gdb_prompt $" { + pass "print value of f_instance" + } + -re ".\[0-9\]* = \{<class A> = \{a = 1, aa = 2\}, <class B> = \{b = 3, bb = 4\}, <class C> = \{c = 5, cc = 6\}, f = 11, ff = 12\}\r\n$gdb_prompt $" { + pass "print value of f_instance" + } + -re ".*$gdb_prompt $" { fail "print value of f_instance" } + timeout { fail "(timeout) print value of f_instance" } + } + +send_gdb "ptype f_instance\n" +gdb_expect { + -re "type = class F : private A, public B, private C \{\r\n\[\t \]*public:\r\n\[\t \]*int f;\r\n\[\t \]*int ff;\[\r\n\t ]+F & operator=\\(F const ?&\\);\[\r\n\t ]+F\\((F const|const F) ?&\\);\[\r\n\t \]+F\\((void|)\\);\r\n\[\t \]*int ffoo\\((void|)\\);\r\n\[\t \]*int foo\\((void|)\\);\r\n\}.*$gdb_prompt $" { pass "ptype f_instance" } + -re "type = class F : private A, public B, private C \{\r\n\[\t \]*public:\r\n\[\t \]*int f;\r\n\[\t \]*int ff;\[\r\n\t \]+F\\((void|)\\);\r\n\[\t \]*int ffoo\\((void|)\\);\r\n\[\t \]*int foo\\((void|)\\);\r\n\}.*$gdb_prompt $" { pass "ptype f_instance" } + -re ".*$gdb_prompt $" { fail "ptype f_instance" } + timeout { fail "(timeout) ptype f_instance" } +} + + + +send_gdb "print d_instance.a\n" +gdb_expect { + -re ".\[0-9\]* = 1.*$gdb_prompt $" { + pass "print value of d_instance.a" + } + -re ".*$gdb_prompt $" { fail "print value of d_instance.a" } + timeout { fail "(timeout) print value of d_instance.a" } + } + +send_gdb "print d_instance.aa\n" +gdb_expect { + -re ".\[0-9\]* = 2.*$gdb_prompt $" { + pass "print value of d_instance.aa" + } + -re ".*$gdb_prompt $" { fail "print value of d_instance.aa" } + timeout { fail "(timeout) print value of d_instance.aa" } + } + +send_gdb "print d_instance.b\n" +gdb_expect { + -re ".\[0-9\]* = 3.*$gdb_prompt $" { + pass "print value of d_instance.b" + } + -re ".*$gdb_prompt $" { fail "print value of d_instance.b" } + timeout { fail "(timeout) print value of d_instance.b" } + } + +send_gdb "print d_instance.bb\n" +gdb_expect { + -re ".\[0-9\]* = 4.*$gdb_prompt $" { + pass "print value of d_instance.bb" + } + -re ".*$gdb_prompt $" { fail "print value of d_instance.bb" } + timeout { fail "(timeout) print value of d_instance.bb" } + } + +send_gdb "print d_instance.c\n" +gdb_expect { + -re ".\[0-9\]* = 5.*$gdb_prompt $" { + pass "print value of d_instance.c" + } + -re ".*$gdb_prompt $" { fail "print value of d_instance.c" } + timeout { fail "(timeout) print value of d_instance.c" } + } + +send_gdb "print d_instance.cc\n" +gdb_expect { + -re ".\[0-9\]* = 6.*$gdb_prompt $" { + pass "print value of d_instance.cc" + } + -re ".*$gdb_prompt $" { fail "print value of d_instance.cc" } + timeout { fail "(timeout) print value of d_instance.cc" } + } + +send_gdb "print d_instance.d\n" +gdb_expect { + -re ".\[0-9\]* = 7.*$gdb_prompt $" { + pass "print value of d_instance.d" + } + -re ".*$gdb_prompt $" { fail "print value of d_instance.d" } + timeout { fail "(timeout) print value of d_instance.d" } + } + +send_gdb "print d_instance.dd\n" +gdb_expect { + -re ".\[0-9\]* = 8.*$gdb_prompt $" { + pass "print value of d_instance.dd" + } + -re ".*$gdb_prompt $" { fail "print value of d_instance.dd" } + timeout { fail "(timeout) print value of d_instance.dd" } + } + +send_gdb "print g_instance.a\n" +gdb_expect { + -re "warning.*$gdb_prompt $" { + # The compiler doesn't think this is ambiguous. + fail "print value of g_instance.a" + } + -re ".\[0-9\]* = 15.*$gdb_prompt $" { + pass "print value of g_instance.a" + } + -re ".*$gdb_prompt $" { fail "print value of g_instance.a" } + timeout { fail "(timeout) print value of g_instance.a" } + } + +send_gdb "print g_instance.b\n" +gdb_expect { + -re "warning.*$gdb_prompt $" { + # The compiler doesn't think this is ambiguous. + fail "print value of g_instance.b" + } + -re ".\[0-9\]* = 16.*$gdb_prompt $" { + pass "print value of g_instance.b" + } + -re ".*$gdb_prompt $" { fail "print value of g_instance.b" } + timeout { fail "(timeout) print value of g_instance.b" } + } + +send_gdb "print g_instance.c\n" +gdb_expect { + -re "warning.*$gdb_prompt $" { + # The compiler doesn't think this is ambiguous. + fail "print value of g_instance.c" + } + -re ".\[0-9\]* = 17.*$gdb_prompt $" { + pass "print value of g_instance.c" + } + -re ".*$gdb_prompt $" { fail "print value of g_instance.c" } + timeout { fail "(timeout) print value of g_instance.c" } + } + +send_gdb "print g_instance.afoo()\n" +gdb_expect { + -re ".\[0-9\]* = 1.*$gdb_prompt $" { + pass "print value of g_instance.afoo()" + } + -re ".*$gdb_prompt $" { fail "print value of g_instance.afoo()" } + timeout { fail "(timeout) print value of g_instance.afoo()" } + } + + +# If GDB fails to restore the selected frame properly after the +# inferior function call above (see GDB PR 1155 for an explanation of +# why this might happen), all the subsequent tests will fail. We +# should detect report that failure, but let the marker call finish so +# that the rest of the tests can run undisturbed. +gdb_test_multiple "frame" "re-selected 'main' frame after inferior call" { + -re "#0 marker1.*$gdb_prompt $" { + setup_kfail "gdb/1155" s390-*-linux-gnu + fail "re-selected 'main' frame after inferior call" + gdb_test "finish" ".*main.*at .*derivation.cc:.*// marker1-returns-here.*" \ + "finish call to marker1" + } + -re "#1 ($hex in )?main.*$gdb_prompt $" { + pass "re-selected 'main' frame after inferior call" + } +} + +send_gdb "print g_instance.bfoo()\n" +gdb_expect { + -re ".\[0-9\]* = 2.*$gdb_prompt $" { + pass "print value of g_instance.bfoo()" + } + -re ".*$gdb_prompt $" { fail "print value of g_instance.bfoo()" } + timeout { fail "(timeout) print value of g_instance.bfoo()" } + } + +send_gdb "print g_instance.cfoo()\n" +gdb_expect { + -re ".\[0-9\]* = 3.*$gdb_prompt $" { + pass "print value of g_instance.cfoo()" + } + -re ".*$gdb_prompt $" { fail "print value of g_instance.cfoo()" } + timeout { fail "(timeout) print value of g_instance.cfoo()" } + } diff --git a/gdb/testsuite/gdb.cp/hang.H b/gdb/testsuite/gdb.cp/hang.H new file mode 100644 index 0000000..26fec87 --- /dev/null +++ b/gdb/testsuite/gdb.cp/hang.H @@ -0,0 +1,12 @@ +struct A +{ + struct B *b_ptr_in_a; +}; + +struct C +{ + struct B + { + int member_of_B_in_C; + }; +}; diff --git a/gdb/testsuite/gdb.cp/hang.exp b/gdb/testsuite/gdb.cp/hang.exp new file mode 100644 index 0000000..4c117a1 --- /dev/null +++ b/gdb/testsuite/gdb.cp/hang.exp @@ -0,0 +1,128 @@ +# Copyright (C) 2002 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +if $tracelevel then { + strace $tracelevel +} + +set prms_id 0 +set bug_id 0 + +if { [skip_cplus_tests] } { continue } + +set testfile hang +set binfile ${objdir}/${subdir}/${testfile} + +foreach file {hang1 hang2 hang3} { + if {[gdb_compile "${srcdir}/${subdir}/${file}.C" "${file}.o" object {c++ debug}] != ""} { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." + } +} + +if {[gdb_compile "hang1.o hang2.o hang3.o" ${binfile} executable {c++ debug}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + + +# As of May 1, 2002, GDB hangs trying to read the debug info for the +# `hang2.o' compilation unit from the executable `hang', when compiled +# by g++ 2.96 with STABS debugging info. Here's what's going on, as +# best as I can tell. +# +# The definition of `struct A' in `hang.H' refers to `struct B' as an +# incomplete type. The stabs declare type number (1,3) to be a cross- +# reference type, `xsB:'. +# +# The definition of `struct C' contains a nested definition for +# `struct B' --- or more properly, `struct C::B'. However, the stabs +# fail to qualify the structure tag: it just looks like a definition +# for `struct B'. I think this is a compiler bug, but perhaps GCC +# doesn't emit qualified names for a reason. +# +# `hang.H' gets #included by both `hang1.C' and `hang2.C'. So the +# stabs for `struct A', the incomplete `struct B', and `struct C' +# appear in both hang1.o's and hang2.o's stabs. +# +# When those two files are linked together, since hang2.o appears +# later in the command line, its #inclusion of `hang.H' gets replaced +# with an N_EXCL stab, referring back to hang1.o's stabs for the +# header file. +# +# When GDB builds psymtabs for the executable hang, it notes that +# hang2.o's stabs contain an N_EXCL referring to a header that appears +# in full in hang1.o's stabs. So hang2.o's psymtab lists a dependency +# on hang1.o's psymtab. +# +# When the user types the command `print var_in_b', GDB scans the +# psymtabs for a symbol by that name, and decides to read full symbols +# for `hang2.o'. +# +# Since `hang2.o''s psymtab lists `hang1.o' as a dependency, GDB first +# reads `hang1.o''s symbols. When GDB sees `(1,3)=xsB:', it creates a +# type object for `struct B', sets its TYPE_FLAG_STUB flag, and +# records it as type number `(1,3)'. +# +# When GDB finds the definition of `struct C::B', since the stabs +# don't indicate that the type is nested within C, it treats it as +# a definition of `struct B'. +# +# When GDB is finished reading `hang1.o''s symbols, it calls +# `cleanup_undefined_types'. This function mistakes the definition of +# `struct C::B' for a definition for `struct B', and overwrites the +# incomplete type object for the real `struct B', using `memcpy'. Now +# stabs type number `(1,3)' refers to this (incorrect) complete type. +# Furthermore, the `memcpy' simply copies the original's `cv_type' +# field to the target, giving the target a corrupt `cv_type' ring: the +# chain does not point back to the target type. +# +# Having satisfied `hang2.o''s psymtab's dependencies, GDB begins to +# read `hang2.o''s symbols. These contain the true definition for +# `struct B', which refers to type number `(1,3)' as the type it's +# defining. GDB looks up type `(1,3)', and finds the (incorrect) +# complete type established by the call to `cleanup_undefined_types' +# above. However, it doesn't notice that the type is already defined, +# and passes it to `read_struct_type', which then writes the new +# definition's size, field list, etc. into the type object which +# already has those fields initialized. Adding insult to injury, +# `read_struct_type' then calls `finish_cv_type'; since the `memcpy' +# in `cleanup_undefined_types' corrupted the target type's `cv_type' +# ring, `finish_cv_type' enters an infinite loop. + +# This checks that GDB recognizes when a structure is about to be +# overwritten, and refuses, with a complaint. +gdb_test "print var_in_b" " = 1729" "doesn't overwrite struct type" + +# This checks that cleanup_undefined_types doesn't create corrupt +# cv_type chains. Note that var_in_hang3 does need to be declared in +# a separate compilation unit, whose psymtab depends on hang1.o's +# psymtab. Otherwise, GDB won't call cleanup_undefined_types (as it +# finishes hang1.o's symbols) before it calls make_cv_type (while +# reading hang3.o's symbols). +# +# The bug only happens when you compile with -gstabs+; Otherwise, GCC +# won't include the `const' qualifier on `const_B_ptr' in `hang3.o''s +# STABS, so GDB won't try to create a const variant of the smashed +# struct type, and get caught by the corrupted cv_type chain. +gdb_test "print var_in_hang3" " = 42" "doesn't corrupt cv_type chain" diff --git a/gdb/testsuite/gdb.cp/hang1.C b/gdb/testsuite/gdb.cp/hang1.C new file mode 100644 index 0000000..4b04d77 --- /dev/null +++ b/gdb/testsuite/gdb.cp/hang1.C @@ -0,0 +1,3 @@ +#include "hang.H" + +int main (int argc, char **argv) { return 0; } diff --git a/gdb/testsuite/gdb.cp/hang2.C b/gdb/testsuite/gdb.cp/hang2.C new file mode 100644 index 0000000..59732f8 --- /dev/null +++ b/gdb/testsuite/gdb.cp/hang2.C @@ -0,0 +1,8 @@ +#include "hang.H" + +struct B +{ + int member_of_B; +}; + +int var_in_b = 1729; diff --git a/gdb/testsuite/gdb.cp/hang3.C b/gdb/testsuite/gdb.cp/hang3.C new file mode 100644 index 0000000..92c82fa --- /dev/null +++ b/gdb/testsuite/gdb.cp/hang3.C @@ -0,0 +1,4 @@ +#include "hang.H" + +const struct B *const_B_ptr; +int var_in_hang3 = 42; diff --git a/gdb/testsuite/gdb.cp/inherit.exp b/gdb/testsuite/gdb.cp/inherit.exp new file mode 100644 index 0000000..993bfb1 --- /dev/null +++ b/gdb/testsuite/gdb.cp/inherit.exp @@ -0,0 +1,1018 @@ +# Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2003 +# 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# This file was written by Fred Fish. (fnf@cygnus.com) + +set ws "\[\r\n\t \]+" +set nl "\[\r\n\]+" + +# The format of a g++ virtual base pointer. +set vbptr "(_vb\[$.\]|__vb_)\[0-9\]?" + +if $tracelevel then { + strace $tracelevel +} + +if { [skip_cplus_tests] } { continue } + +# Note - create separate "inherit" executable from misc.cc + +set testfile "inherit" +set srcfile misc.cc +set binfile ${objdir}/${subdir}/${testfile} + + +# Create and source the file that provides information about the compiler +# used to compile the test case. + +if [get_compiler_info ${binfile} "c++"] { + return -1 +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +# +# Single inheritance, print individual members. +# + +proc test_print_si_members {} { + # Print all members of g_A using fully qualified form. + + gdb_test "print g_A.A::a" ".* = 1" "print g_A.A::a" + + gdb_test "print g_A.A::x" ".* = 2" "print g_A.A::x" + + # Print members of g_A using nonambiguous compact form. + + gdb_test "print g_A.a" ".* = 1" "print g_A.a" + + gdb_test "print g_A.x" ".* = 2" "print g_A.x" + + # Print all members of g_B using fully qualified form. + + gdb_test "print g_B.A::a" ".* = 3" "print g_B.A::a" + + gdb_test "print g_B.A::x" ".* = 4" "print g_B.A::x" + + gdb_test "print g_B.B::b" ".* = 5" "print g_B.B::b" + + gdb_test "print g_B.B::x" ".* = 6" "print g_B.B::x" + + # Print members of g_B using nonambiguous compact form. + + gdb_test "print g_B.a" ".* = 3" "print g_B.a" + + gdb_test "print g_B.b" ".* = 5" "print g_B.b" + + gdb_test "print g_B.x" ".* = 6" "print g_B.x" + + # Print all members of g_C using fully qualified form. + + gdb_test "print g_C.A::a" ".* = 7" "print g_C.A::a" + + gdb_test "print g_C.A::x" ".* = 8" "print g_C.A::x" + + gdb_test "print g_C.C::c" ".* = 9" "print g_C.C::c" + + gdb_test "print g_C.C::x" ".* = 10" "print g_C.C::x" + + # Print members of g_C using nonambiguous compact form. + + gdb_test "print g_C.a" ".* = 7" "print g_C.a" + + gdb_test "print g_C.c" ".* = 9" "print g_C.c" + + gdb_test "print g_C.x" ".* = 10" "print g_C.x" +} + +# +# Single inheritance, print type definitions. +# + +proc test_ptype_si {} { + global gdb_prompt + global ws + global nl + global hp_aCC_compiler + + # Print class A as a type. + + send_gdb "ptype A\n" + gdb_expect { + -re "type = class A \{$nl.*\[ \]*int a;$nl\[ \]*int x;$nl.*\[ \]*\}$nl$gdb_prompt $" { + pass "ptype A (FIXME)" + } + -re "type = struct A \{$nl\[ \]*int a;$nl\[ \]*int x;$nl\[ \]*\}$nl$gdb_prompt $" { + setup_xfail "*-*-*" + fail "ptype A (FIXME)" + } + -re ".*$gdb_prompt $" { fail "ptype A" } + timeout { fail "ptype A (timeout)" ; return } + } + + # Print class A as an explicit class. + + send_gdb "ptype class A\n" + gdb_expect { + -re "type = class A \{$nl.*\[ \]*int a;$nl\[ \]*int x;$nl.*\[ \]*\}$nl$gdb_prompt $" { + pass "ptype class A (FIXME)" + } + -re "type = struct A \{$nl\[ \]*int a;$nl\[ \]*int x;$nl\[ \]*\}$nl$gdb_prompt $" { + if {!$hp_aCC_compiler} {setup_xfail "*-*-*"} + fail "ptype class A (FIXME)" + } + -re ".*$gdb_prompt $" { fail "ptype class A" } + timeout { fail "ptype class A (timeout)" ; return } + } + + # Print type of an object of type A. + + send_gdb "ptype g_A\n" + gdb_expect { + -re "type = class A \{$nl.*\[ \]*int a;$nl\[ \]*int x;$nl.*\[ \]*\}$nl$gdb_prompt $" { + pass "ptype g_A (FIXME)" + } + -re "type = struct A \{$nl\[ \]*int a;$nl\[ \]*int x;$nl\[ \]*\}$nl$gdb_prompt $" { + if {!$hp_aCC_compiler} {setup_xfail "*-*-*"} + fail "ptype g_A (FIXME)" + } + -re ".*$gdb_prompt $" { fail "ptype g_A" } + timeout { fail "ptype g_A (timeout)" ; return } + } + + # Print class B as a type. + + gdb_test "ptype B" "type = class B : public A \{$nl\[ \]*public:$nl\[ \]*int b;$nl\[ \]*int x;$nl.*\}" "ptype B" + + # Print class B as an explicit class. + + gdb_test "ptype class B" "type = class B : public A \{$nl\[ \]*public:$nl\[ \]*int b;$nl\[ \]*int x;$nl.*\}" "ptype class B" + + # Print type of an object of type B. + + gdb_test "ptype g_B" "type = class B : public A \{$nl\[ \]*public:$nl\[ \]*int b;$nl\[ \]*int x;$nl.*\}" "ptype g_B" + + # Print class C as a type. + + gdb_test "ptype C" "type = class C : public A \{$nl\[ \]*public:$nl\[ \]*int c;$nl\[ \]*int x;$nl.*\}" "ptype C" + + # Print class C as an explicit class. + + gdb_test "ptype class C" "type = class C : public A \{$nl\[ \]*public:$nl\[ \]*int c;$nl\[ \]*int x;$nl.*\}" "ptype class C" + + # Print type of an object of type g_C. + + gdb_test "ptype g_C" "type = class C : public A \{$nl\[ \]*public:$nl\[ \]*int c;$nl\[ \]*int x;$nl.*\}" "ptype g_C" + + # gcc cygnus-2.3.3 (Q1) has this bug, but it was fixed as of + # cygnus-2.3.3-930417. PR 2819. + send_gdb "ptype tagless_struct\n" + gdb_expect { + -re "type = class \{${ws}public:${ws}int one;${ws}int two;${ws}tagless_struct & operator=\\(tagless_struct (const ?)?&\\);${ws}tagless_struct\\(tagless_struct (const ?)?&\\);${ws}tagless_struct\\(\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype tagless struct" + } + -re "type = class \{${ws}public:${ws}int one;${ws}int two;;${ws}\}$nl$gdb_prompt $" { + pass "ptype tagless struct" + } + -re "type = (struct|class).*\{.*int one;.*int two;.*\}$nl$gdb_prompt $" { + pass "ptype tagless struct (obsolete gcc or gdb)" + } + -re ".*$gdb_prompt $" { + fail "ptype tagless struct" + } + timeout { + fail "ptype tagless struct (timeout)" + } + } + + send_gdb "ptype v_tagless\n" + gdb_expect { + -re "type = class \{${ws}public:${ws}int one;${ws}int two;${ws}tagless_struct & operator=\\(tagless_struct (const ?)?&\\);${ws}tagless_struct\\(tagless_struct (const ?)?&\\);${ws}tagless_struct\\(\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype variable of type tagless struct" + } + -re "type = class \{${ws}public:${ws}int one;${ws}int two;;${ws}\}$nl$gdb_prompt $" { + pass "ptype tagless struct" + } + -re "type = (struct|class).*\{.*int one;.*int two;.*\}$nl$gdb_prompt $" { + pass "ptype variable of type tagless struct (obsolete gcc or gdb)" + } + -re ".*$gdb_prompt $" { + fail "ptype variable of type tagless struct" + } + timeout { + fail "ptype variable of type tagless struct (timeout)" + } + } +} + +# +# Single inheritance, print complete classes. +# + +proc test_print_si_classes {} { + # Print all members of g_A. + + gdb_test "print g_A" ".* = \{a = 1, x = 2\}" "print g_A" + + # Print all members of g_B. + + gdb_test "print g_B" ".* = \{\<(class |)A\> = \{a = 3, x = 4\}, b = 5, x = 6\}" "print g_B" + + # Print all members of g_C. + + gdb_test "print g_C" ".* = \{\<(class |)A\> = \{a = 7, x = 8\}, c = 9, x = 10\}" "print g_C" +} + +# +# Single inheritance, print anonymous unions. +# GDB versions prior to 4.14 entered an infinite loop when printing +# the type of a class containing an anonymous union, and they were also +# incapable of printing the member of an anonymous union. +# We test the printing of the member first, and perform the other tests +# only if the test succeeds, to avoid the infinite loop. +# + +proc test_print_anon_union {} { + global gdb_prompt + global ws + global nl + + gdb_test "print g_anon_union.a" ".* = 2" "print anonymous union member" + send_gdb "print g_anon_union\n" + gdb_expect { + -re ".* = \{one = 1, ( = |)\{a = 2, b = 2\}\}$nl$gdb_prompt $" { + pass "print variable of type anonymous union" + } + -re ".* = .*\{one = 1, ( = |)\{a = 2, b = .*\}\}$nl$gdb_prompt $" { + pass "print variable of type anonymous union (obsolete gcc or gdb)" + } + -re ".*$nl$gdb_prompt $" { + fail "print variable of type anonymous union" + } + timeout { + fail "print variableof type anonymous union (timeout)" + } + } + send_gdb "ptype g_anon_union\n" + gdb_expect { + -re "type = class class_with_anon_union \{${ws}public:${ws}int one;${ws}union \{${ws}public:${ws}int a;${ws}long int b;${ws}union \{\.\.\.\} & operator=\\(union \{\.\.\.\} &\\);${ws}\\\$_0 \\(union \{\.\.\.\} &\\);${ws}\\\$_0 \\(\\);${ws}\};${ws}class_with_anon_union & operator=\\(class_with_anon_union const &\\);${ws}class_with_anon_union\\(class_with_anon_union const &\\);${ws}class_with_anon_union\\(void\\);${ws}\}$nl$gdb_prompt $" { + pass "print type of anonymous union" + } + -re "type = class class_with_anon_union \{${ws}public:${ws}int one;${ws}union \{${ws}int a;${ws}long int b;${ws}\};${ws}class_with_anon_union & operator=\\(class_with_anon_union const ?&\\);${ws}class_with_anon_union\\(class_with_anon_union const ?&\\);${ws}class_with_anon_union\\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "print type of anonymous union" + } + -re "type = class class_with_anon_union \{${ws}public:${ws}int one;${ws}union \{${ws}int a;${ws}long int b;${ws}\};${ws}\}$nl$gdb_prompt $" { + pass "print type of anonymous union" + } + -re "type = (struct|class).*\{.*int one;.*union \{.*int a;.*(long|long int|int) b;.*\};.*\}$nl$gdb_prompt $" { + pass "print type of anonymous union (obsolete gcc or gdb)" + } + -re ".*$nl$gdb_prompt $" { + fail "print type of anonymous union" + } + timeout { + fail "print type of anonymous union (timeout)" + } + } +} + +# +# Multiple inheritance, print individual members. +# + +proc test_print_mi_members {} { + global gdb_prompt + global nl + global hp_aCC_compiler + + # Print all members of g_A. + + gdb_test "print g_A.A::a" ".* = 1" "print g_A.A::a" + + gdb_test "print g_A.A::x" ".* = 2" "print g_A.A::x" + + # Print all members of g_B. + + gdb_test "print g_B.A::a" ".* = 3" "print g_B.A::a" + + gdb_test "print g_B.A::x" ".* = 4" "print g_B.A::x" + + gdb_test "print g_B.B::b" ".* = 5" "print g_B.B::b" + + gdb_test "print g_B.B::x" ".* = 6" "print g_B.B::x" + + # Print all members of g_C. + + gdb_test "print g_C.A::a" ".* = 7" "print g_C.A::a" + + gdb_test "print g_C.A::x" ".* = 8" "print g_C.A::x" + + gdb_test "print g_C.C::c" ".* = 9" "print g_C.C::c" + + gdb_test "print g_C.C::x" ".* = 10" "print g_C.C::x" + + # Print all members of g_D. + + # The following is ambiguous, and gdb should detect this. + # For now, accept gdb's behavior as an expected failure if it + # simply prints either member correctly. + + send_gdb "print g_D.A::a\n" + gdb_expect { + -re "warning: A ambiguous; using D::C::A. Use a cast to disambiguate.$nl\\$\[0-9\]* = 15$nl$gdb_prompt $" { + pass "print g_D.A::a" + } + -re "warning: A ambiguous; using D::B::A. Use a cast to disambiguate.$nl\\$\[0-9\]* = 11$nl$gdb_prompt $" { + pass "print g_D.A::a (using B)" + } + -re ".* = 15$nl$gdb_prompt $" { + kfail "gdb/68" "print g_D.A::a" + } + -re ".* = 11$nl$gdb_prompt $" { + kfail "gdb/68" "print g_D.A::a" + } + -re ".*$gdb_prompt $" { fail "print g_D.A::a" } + timeout { fail "print g_D.A::a (timeout)" ; return } + } + + # The following is ambiguous, and gdb should detect this. + # For now, accept gdb's behavior as an expected failure if it + # simply prints either member correctly. + + send_gdb "print g_D.A::x\n" + gdb_expect { + -re "warning: A ambiguous; using D::C::A. Use a cast to disambiguate.$nl\\$\[0-9\]* = 16$nl$gdb_prompt $" { + pass "print g_D.A::x" + } + -re "warning: A ambiguous; using D::B::A. Use a cast to disambiguate.$nl\\$\[0-9\]* = 12$nl$gdb_prompt $" { + pass "print g_D.A::x (using B)" + } + -re ".* = 16$nl$gdb_prompt $" { + kfail "gdb/68" "print g_D.A::x" + } + -re ".* = 12$nl$gdb_prompt $" { + kfail "gdb/68" "print g_D.A::x" + } + -re ".*$gdb_prompt $" { fail "print g_D.A::x" } + timeout { fail "print g_D.A::x (timeout)" ; return } + } + + gdb_test "print g_D.B::b" ".* = 13" "print g_D.B::b" + + gdb_test "print g_D.B::x" ".* = 14" "print g_D.B::x" + + gdb_test "print g_D.C::c" ".* = 17" "print g_D.C::c" + + gdb_test "print g_D.C::x" ".* = 18" "print g_D.C::x" + + gdb_test "print g_D.D::d" ".* = 19" "print g_D.D::d" + + gdb_test "print g_D.D::x" ".* = 20" "print g_D.D::x" + + # Print all members of g_E. + + # The following is ambiguous, and gdb should detect this. + # For now, accept gdb's behavior as an expected failure if it + # simply prints either member correctly. + + send_gdb "print g_E.A::a\n" + gdb_expect { + -re ".* = 21$nl$gdb_prompt $" { + kfail "gdb/68" "print g_E.A::a" + } + -re ".* = 25$nl$gdb_prompt $" { + kfail "gdb/68" "print g_E.A::a" + } + -re ".*$gdb_prompt $" { fail "print g_E.A::a" } + timeout { fail "print g_E.A::a (timeout)" ; return } + } + + # The following is ambiguous, and gdb should detect this. + # For now, accept gdb's behavior as an expected failure if it + # simply prints either member correctly. + + send_gdb "print g_E.A::x\n" + gdb_expect { + -re "warning: A ambiguous; using E::D::C::A. Use a cast to disambiguate.$nl\\$\[0-9\]* = 26$nl$gdb_prompt $" { + pass "print g_E.A::x" + } + -re "warning: A ambiguous; using E::D::B::A. Use a cast to disambiguate.$nl\\$\[0-9\]* = 22$nl$gdb_prompt $" { + pass "print g_E.A::x (using B)" + } + -re ".* = 26$nl$gdb_prompt $" { + kfail "gdb/68" "print g_E.A::x" + } + -re ".* = 22$nl$gdb_prompt $" { + kfail "gdb/68" "print g_E.A::x" + } + -re ".*$gdb_prompt $" { fail "print g_E.A::x" } + timeout { fail "print g_E.A::x (timeout)" ; return } + } + + gdb_test "print g_E.B::b" ".* = 23" "print g_E.B::b" + + gdb_test "print g_E.B::x" ".* = 24" "print g_E.B::x" + + gdb_test "print g_E.C::c" ".* = 27" "print g_E.C::c" + + gdb_test "print g_E.C::x" ".* = 28" "print g_E.C::x" + + gdb_test "print g_E.D::d" ".* = 29" "print g_E.D::d" + + gdb_test "print g_E.D::x" ".* = 30" "print g_E.D::x" + + gdb_test "print g_E.E::e" ".* = 31" "print g_E.E::e" + + gdb_test "print g_E.E::x" ".* = 32" "print g_E.E::x" +} + +# +# Multiple inheritance, print type definitions. +# + +proc test_ptype_mi {} { + global nl + + gdb_test "ptype D" "type = class D : public B, public C \{$nl\[ \]*public:$nl\[ \]*int d;$nl\[ \]*int x;$nl.*\}" "ptype D" + + gdb_test "ptype class D" "type = class D : public B, public C \{$nl\[ \]*public:$nl\[ \]*int d;$nl\[ \]*int x;$nl.*\}" "ptype class D" + + gdb_test "ptype g_D" "type = class D : public B, public C \{$nl\[ \]*public:$nl\[ \]*int d;$nl\[ \]*int x;$nl.*\}" "ptype g_D" + + gdb_test "ptype E" "type = class E : public D \{$nl\[ \]*public:$nl\[ \]*int e;$nl\[ \]*int x;$nl.*\}" "ptype E" + + gdb_test "ptype class E" "type = class E : public D \{$nl\[ \]*public:$nl\[ \]*int e;$nl\[ \]*int x;$nl.*\}" "ptype class E" + + gdb_test "ptype g_E" "type = class E : public D \{$nl\[ \]*public:$nl\[ \]*int e;$nl\[ \]*int x;$nl.*\}" "ptype g_E" +} + +# +# Multiple inheritance, print complete classes. +# + +proc test_print_mi_classes {} { + # Print all members of g_D. + + gdb_test "print g_D" ".* = \{\<(class |)B\> = \{\<(class |)A\> = \{a = 11, x = 12\}, b = 13, x = 14\}, \<(class |)C\> = \{\<(class |)A\> = \{a = 15, x = 16\}, c = 17, x = 18\}, d = 19, x = 20\}" "print g_D" + + # Print all members of g_E. + + gdb_test "print g_E" ".* = \{\<(class |)D\> = \{\<(class |)B\> = \{\<(class |)A\> = \{a = 21, x = 22\}, b = 23, x = 24\}, \<(class |)C\> = \{\<(class |)A\> = \{a = 25, x = 26\}, c = 27, x = 28\}, d = 29, x = 30\}, e = 31, x = 32\}" "print g_E" +} + +# +# Single virtual inheritance, print individual members. +# + +proc test_print_svi_members {} { + global gdb_prompt + global decimal + global nl + + # Print all members of g_vA. + + gdb_test "print g_vA.vA::va" ".* = 1" "print g_vA.vA::va" + + gdb_test "print g_vA.vA::vx" ".* = 2" "print g_vA.vA::vx" + + # Print members of g_vA using compact form. + + gdb_test "print g_vA.va" ".* = 1" "print g_vA.va" + + gdb_test "print g_vA.vx" ".* = 2" "print g_vA.vx" + + # Print all members of g_vB. + + send_gdb "print g_vB.vA::va\n" + gdb_expect { + -re ".* = 3$nl$gdb_prompt $" { pass "print g_vB.vA::va" } + -re ".*virtual baseclass botch.*$gdb_prompt $" { + # Does not happen with gcc cygnus-2.4.5-930828 + fail "print g_vB.vA::va (known bug with gcc cygnus-2.4.5-930417)" + # Many of the rest of these tests have the same problem. + return 0 + } + -re ".*$gdb_prompt $" { fail "print g_vB.vA::va" } + timeout { fail "print g_vB.vA::va (timeout)" ; return } + } + + gdb_test "print g_vB.vA::vx" ".* = 4" "print g_vB.vA::vx" + + gdb_test "print g_vB.vB::vb" ".* = 5" "print g_vB.vB::vb" + + gdb_test "print g_vB.vB::vx" ".* = 6" "print g_vB.vB::vx" + + # Print members of g_vB using compact form. + + gdb_test "print g_vB.va" ".* = 3" "print g_vB.va" + + gdb_test "print g_vB.vb" ".* = 5" "print g_vB.vb" + + gdb_test "print g_vB.vx" ".* = 6" "print g_vB.vx" + + # Print all members of g_vC. + + gdb_test "print g_vC.vA::va" ".* = 7" "print g_vC.vA::va" + + gdb_test "print g_vC.vA::vx" ".* = 8" "print g_vC.vA::vx" + + gdb_test "print g_vC.vC::vc" ".* = 9" "print g_vC.vC::vc" + + gdb_test "print g_vC.vC::vx" ".* = 10" "print g_vC.vC::vx" + + # Print members of g_vC using compact form. + + gdb_test "print g_vC.va" ".* = 7" "print g_vC.va" + + gdb_test "print g_vC.vc" ".* = 9" "print g_vC.vc" + + gdb_test "print g_vC.vx" ".* = 10" "print g_vC.vx" +} + +# +# Single virtual inheritance, print type definitions. +# + +proc test_ptype_vi {} { + global gdb_prompt + global ws + global nl + global vbptr + + # This class does not use any C++-specific features, so it's fine for + # it to print as "struct". + send_gdb "ptype vA\n" + gdb_expect { + -re "type = class vA \{$nl\[ \]*public:$nl\[ \]*int va;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" { + pass "ptype vA" + } + -re "type = struct vA \{$nl\[ \]*int va;$nl\[ \]*int vx;$nl\}$nl$gdb_prompt $" { + pass "ptype vA" + } + -re ".*$gdb_prompt $" { fail "ptype vA" } + timeout { fail "ptype vA (timeout)" ; return } + } + + # This class does not use any C++-specific features, so it's fine for + # it to print as "struct". + send_gdb "ptype class vA\n" + gdb_expect { + -re "type = class vA \{$nl\[ \]*public:$nl\[ \]*int va;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" { + pass "ptype class vA" + } + -re "type = struct vA \{$nl\[ \]*int va;$nl\[ \]*int vx;$nl\}$nl$gdb_prompt $" { + pass "ptype class vA" + } + -re ".*$gdb_prompt $" { fail "ptype class vA" } + timeout { fail "ptype class vA (timeout)" ; return } + } + + # This class does not use any C++-specific features, so it's fine for + # it to print as "struct". + send_gdb "ptype g_vA\n" + gdb_expect { + -re "type = class vA \{$nl\[ \]*public:$nl\[ \]*int va;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" { + pass "ptype g_vA" + } + -re "type = struct vA \{$nl\[ \]*int va;$nl\[ \]*int vx;$nl\}$nl$gdb_prompt $" { + pass "ptype g_vA" + } + -re ".*$gdb_prompt $" { fail "ptype g_vA" } + timeout { fail "ptype g_vA (timeout)" ; return } + } + + send_gdb "ptype vB\n" + gdb_expect { + -re "ptype vB${nl}type = class vB : public virtual vA \{$nl private:${ws}vA \\*${vbptr}vA;$nl public:${ws}int vb;${ws}int vx;$nl.*\}$nl$gdb_prompt $" { + pass "ptype vB" + } + -re "ptype vB${nl}type = class vB : public virtual vA \{$nl public:${ws}int vb;${ws}int vx;$nl.*\}$nl$gdb_prompt $" { + pass "ptype vB (aCC)" + } + -re ".*$gdb_prompt $" { fail "ptype vB" } + timeout { fail "ptype vB (timeout)" } + } + + send_gdb "ptype class vB\n" + gdb_expect { + -re "type = class vB : public virtual vA \{$nl\[ \]*private:$nl\[ \]*vA \\*${vbptr}vA;$nl\[ \]*public:$nl\[ \]*int vb;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" { + pass "ptype class vB" + } + -re "type = class vB : public virtual vA \{$nl\[ \]*public:$nl\[ \]*int vb;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" { + pass "ptype class vB (aCC)" + } + -re ".*$gdb_prompt $" { fail "ptype class vB" } + timeout { fail "ptype class vB (timeout)" } + } + + send_gdb "ptype g_vB\n" + gdb_expect { + -re "type = class vB : public virtual vA \{$nl\[ \]*private:$nl\[ \]*vA \\*${vbptr}vA;$nl\[ \]*public:$nl\[ \]*int vb;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" { + pass "ptype g_vB" + } + -re "type = class vB : public virtual vA \{$nl\[ \]*public:$nl\[ \]*int vb;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" { + pass "ptype g_vB (aCC)" + } + -re ".*$gdb_prompt $" { fail "ptype g_vB" } + timeout { fail "ptype g_vB (timeout)" } + } + + send_gdb "ptype vC\n" + gdb_expect { + -re "type = class vC : public virtual vA \{$nl\[ \]*private:$nl\[ \]*vA \\*${vbptr}vA;$nl\[ \]*public:$nl\[ \]*int vc;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" { + pass "ptype vC" + } + -re "type = class vC : public virtual vA \{$nl\[ \]*public:$nl\[ \]*int vc;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" { + pass "ptype vC (aCC)" + } + -re ".*$gdb_prompt $" { fail "ptype vC" } + timeout { fail "ptype vC (timeout)" } + } + + send_gdb "ptype class vC\n" + gdb_expect { + -re "type = class vC : public virtual vA \{$nl\[ \]*private:$nl\[ \]*vA \\*${vbptr}vA;$nl\[ \]*public:$nl\[ \]*int vc;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" { + pass "ptype class vC" + } + -re "type = class vC : public virtual vA \{$nl\[ \]*public:$nl\[ \]*int vc;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" { + pass "ptype class vC (aCC)" + } + -re ".*$gdb_prompt $" { fail "ptype class vC" } + timeout { fail "ptype class vC (timeout)" } + } + + send_gdb "ptype g_vC\n" + gdb_expect { + -re "type = class vC : public virtual vA \{$nl\[ \]*private:$nl\[ \]*vA \\*${vbptr}vA;$nl\[ \]*public:$nl\[ \]*int vc;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" { + pass "ptype g_vC" + } + -re "type = class vC : public virtual vA \{$nl\[ \]*public:$nl\[ \]*int vc;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" { + pass "ptype g_vC (aCC)" + } + -re ".*$gdb_prompt $" { fail "ptype g_vC" } + timeout { fail "ptype g_vC (timeout)" } + } +} + +# +# Single virtual inheritance, print complete classes. +# + +proc test_print_svi_classes {} { + global gdb_prompt + global hex + global decimal + global nl + global vbptr + + # Print all members of g_vA. + + gdb_test "print g_vA" ".* = \{va = 1, vx = 2\}" "print g_vA" + + # Print all members of g_vB. + + send_gdb "print g_vB\n" + gdb_expect { + -re ".* = \{\<class vA\> = \{va = 3, vx = 4\}, vb = 5, vx = 6, Virtual table at $hex\}$nl$gdb_prompt $" { + pass "print g_vB (aCC)" + } + -re ".* = \{\<class vA\> = \{va = 3, vx = 4\}, vb = 5, vx = 6, __vfp = $hex\}$nl$gdb_prompt $" { + pass "print g_vB (aCC)" + } + -re ".* = \{\<vA\> = \{va = 3, vx = 4\}, ${vbptr}vA = $hex, vb = 5, vx = 6\}$nl$gdb_prompt $" { + pass "print g_vB" + } + -re ".* = \{\<vA\> = \{va = 3, vx = 4\}, _vptr.vB = $hex, vb = 5, vx = 6\}$nl$gdb_prompt $" { + pass "print g_vB (FIXME v3 vtbl ptr)" + } + -re ".* = \{\<vA\> = \{va = 3, vx = 4\}, _vptr.vB = $hex <VTT for vB>, vb = 5, vx = 6\}$nl$gdb_prompt $" { + # Happens with gcc 3.3 -gstabs+ + # Does not happen with gcc 3.2.3 -gstabs+. + # Does not happen gcc HEAD%20030624 (pre-3.4) -gstabs+. + # -- chastain 2003-06-29 + pass "print g_vB" + } + + -re ".*invalid address 0x0.*$gdb_prompt $" { + # Does not happen with gcc cygnus-2.4.5-930828 + fail "print g_vB (known bug with gcc cygnus-2.4.5-930417)" + # Many of the rest of these tests have the same problem. + return 0 + } + -re ".*$gdb_prompt $" { fail "print g_vB" } + timeout { fail "print g_vB (timeout)" ; return } + } + + # Print all members of g_vC. + + send_gdb "print g_vC\n" + gdb_expect { + -re ".* = \{\<class vA\> = \{va = 7, vx = 8\}, vc = 9, vx = 10, Virtual table at $hex\}$nl$gdb_prompt $" { + pass "print g_vC (aCC)" + } + -re ".* = \{\<class vA\> = \{va = 7, vx = 8\}, vc = 9, vx = 10, __vfp = $hex\}$nl$gdb_prompt $" { + pass "print g_vC (aCC)" + } + -re ".* = \{\<vA\> = \{va = 7, vx = 8\}, ${vbptr}vA = $hex, vc = 9, vx = 10\}$nl$gdb_prompt $" { + pass "print g_vC" + } + -re ".* = \{\<vA\> = \{va = 7, vx = 8\}, _vptr.vC = $hex, vc = 9, vx = 10\}$nl$gdb_prompt $" { + pass "print g_vC (FIXME v3 vtbl ptr)" + } + -re ".* = \{\<vA\> = \{va = 7, vx = 8\}, _vptr.vC = $hex <VTT for vC>, vc = 9, vx = 10\}$nl$gdb_prompt $" { + # Happens with gcc 3.3 -gstabs+ + # Does not happen with gcc 3.2.3 -gstabs+. + # Does not happen gcc HEAD%20030624 (pre-3.4) -gstabs+. + # -- chastain 2003-06-29 + pass "print g_vC" + } + -re ".*$gdb_prompt $" { fail "print g_vC" } + timeout { fail "print g_vC (timeout)" } + } +} + +# +# Multiple virtual inheritance, print individual members. +# + +proc test_print_mvi_members {} { + global gdb_prompt + global decimal + global nl + + # Print all members of g_vD. + + send_gdb "print g_vD.vA::va\n" + gdb_expect { + -re ".* = 19$nl$gdb_prompt $" { pass "print g_vD.vA::va" } + -re ".*virtual baseclass botch.*$gdb_prompt $" { + # Does not happen with gcc cygnus-2.4.5-930828 + fail "print g_vD.vA::va (known bug with gcc cygnus-2.4.5-930417)" + # Many of the rest of these tests have the same problem. + return 0 + } + -re ".*$gdb_prompt $" { fail "print g_vD.vA::va" } + timeout { fail "print g_vD.vA::va (timeout)" ; return } + } + + gdb_test "print g_vD.vA::vx" ".* = 20" "print g_vD.vA::vx" + + gdb_test "print g_vD.vB::vb" ".* = 21" "print g_vD.vB::vb" + + gdb_test "print g_vD.vB::vx" ".* = 22" "print g_vD.vB::vx" + + gdb_test "print g_vD.vC::vc" ".* = 23" "print g_vD.vC::vc" + + gdb_test "print g_vD.vC::vx" ".* = 24" "print g_vD.vC::vx" + + gdb_test "print g_vD.vD::vd" ".* = 25" "print g_vD.vD::vd" + + gdb_test "print g_vD.vD::vx" ".* = 26" "print g_vD.vD::vx" + + # Print all members of g_vE. + + gdb_test "print g_vE.vA::va" ".* = 0" "print g_vE.vA::va" + + gdb_test "print g_vE.vA::vx" ".* = 0" "print g_vE.vA::vx" + + gdb_test "print g_vE.vB::vb" ".* = 0" "print g_vE.vB::vb" + + gdb_test "print g_vE.vB::vx" ".* = 0" "print g_vE.vB::vx" + + gdb_test "print g_vE.vC::vc" ".* = 0" "print g_vE.vC::vc" + + gdb_test "print g_vE.vC::vx" ".* = 0" "print g_vE.vC::vx" + + gdb_test "print g_vE.vD::vd" ".* = 0" "print g_vE.vD::vd" + + gdb_test "print g_vE.vD::vx" ".* = 0" "print g_vE.vD::vx" + + gdb_test "print g_vE.vE::ve" ".* = 27" "print g_vE.vE::ve" + + gdb_test "print g_vE.vE::vx" ".* = 28" "print g_vE.vE::vx" +} + +# +# Multiple virtual inheritance, print type definitions. +# + +proc test_ptype_mvi {} { + global gdb_prompt + global ws + global nl + global vbptr + + send_gdb "ptype vD\n" + gdb_expect { + -re "type = class vD : public virtual vB, public virtual vC \{${ws}private:${ws}vC \\*${vbptr}vC;${ws}vB \\*${vbptr}vB;${ws}public:${ws}int vd;${ws}int vx;$nl.*\}.*$gdb_prompt $" { + pass "ptype vD" + } + -re ".*class vD : public virtual vB, public virtual vC \{${ws}public:${ws}int vd;${ws}int vx;.*\}.*$gdb_prompt $" { + pass "ptype vD" + } + -re ".*$gdb_prompt $" { fail "ptype vD" } + timeout { fail "(timeout) ptype vD" } + } + + send_gdb "ptype class vD\n" + gdb_expect { + -re "type = class vD : public virtual vB, public virtual vC \{${ws}private:${ws}vC \\*${vbptr}vC;${ws}vB \\*${vbptr}vB;${ws}public:${ws}int vd;${ws}int vx;$nl.*\}.*$gdb_prompt $" { + pass "ptype class vD" + } + -re ".*class vD : public virtual vB, public virtual vC \{${ws}public:${ws}int vd;${ws}int vx;.*\}.*$gdb_prompt $" { + pass "ptype class vD" + } + -re ".*$gdb_prompt $" { fail "ptype class vD" } + timeout { fail "(timeout) ptype class vD" } + } + + send_gdb "ptype g_vD\n" + gdb_expect { + -re "type = class vD : public virtual vB, public virtual vC \{${ws}private:${ws}vC \\*${vbptr}vC;${ws}vB \\*${vbptr}vB;${ws}public:${ws}int vd;${ws}int vx;$nl.*\}.*$gdb_prompt $" { + pass "ptype g_vD" + } + -re ".*class vD : public virtual vB, public virtual vC \{${ws}public:${ws}int vd;${ws}int vx;\r\n.*\}.*$gdb_prompt $" { + pass "ptype g_vD" + } + -re ".*$gdb_prompt $" { fail "ptype g_vD" } + timeout { fail "(timeout) ptype g_vD" } + } + + send_gdb "ptype vE\n" + gdb_expect { + -re "type = class vE : public virtual vD \{${ws}private:${ws}vD \\*${vbptr}vD;${ws}public:${ws}int ve;${ws}int vx;$nl.*\}.*$gdb_prompt $" { + pass "ptype vE" + } + -re ".*class vE : public virtual vD \{${ws}public:${ws}int ve;${ws}int vx;\r\n.*\}.*$gdb_prompt $" { + pass "ptype vE" + } + -re ".*$gdb_prompt $" { fail "ptype vE" } + timeout { fail "(timeout) ptype vE" } + } + + send_gdb "ptype class vE\n" + gdb_expect { + -re "type = class vE : public virtual vD \{${ws}private:${ws}vD \\*${vbptr}vD;${ws}public:${ws}int ve;${ws}int vx;$nl.*\}.*$gdb_prompt $" { + pass "ptype class vE" + } + -re "type = class vE : public virtual vD \{${ws}public:${ws}int ve;${ws}int vx;\r\n.*\}.*$gdb_prompt $" { + pass "ptype class vE" + } + -re ".*$gdb_prompt $" { fail "ptype class vE" } + timeout { fail "(timeout) ptype class vE" } + } + + send_gdb "ptype g_vE\n" + gdb_expect { + -re "type = class vE : public virtual vD \{${ws}private:${ws}vD \\*${vbptr}vD;${ws}public:${ws}int ve;${ws}int vx;$nl.*\}.*$gdb_prompt $" { + pass "ptype g_vE" + } + -re "type = class vE : public virtual vD \{${ws}public:${ws}int ve;${ws}int vx;\r\n.*\}.*$gdb_prompt $" { + pass "ptype g_vE" + } + -re ".*$gdb_prompt $" { fail "ptype g_vE" } + timeout { fail "(timeout) ptype g_vE" } + } +} + +# +# Multiple virtual inheritance, print complete classes. +# + +proc test_print_mvi_classes {} { + global gdb_prompt + global hex + global decimal + global nl + global vbptr + + # Print all members of g_vD. + + send_gdb "print g_vD\n" + gdb_expect { + -re ".* = \{\<class vB\> = \{\<class vA\> = \{va = 19, vx = 20\}, vb = 21, vx = 22, Virtual table at $hex\}, \<class vC\> = \{vc = 23, vx = 24, Virtual table at $hex\}, vd = 25, vx = 26, Virtual table at $hex\}$nl$gdb_prompt $" { + pass "print g_vD (aCC)" + } + -re ".* = \{\<class vB\> = \{\<class vA\> = \{va = 19, vx = 20\}, vb = 21, vx = 22, __vfp = $hex\}, \<class vC\> = \{vc = 23, vx = 24, __vfp = $hex\}, vd = 25, vx = 26, __vfp = $hex\}$nl$gdb_prompt $" { + pass "print g_vD (aCC)" + } + -re ".* = \{\<vB\> = \{\<vA\> = \{va = 19, vx = 20\}, ${vbptr}vA = $hex, vb = 21, vx = 22\}, \<vC\> = \{${vbptr}vA = $hex, vc = 23, vx = 24\}, ${vbptr}vC = $hex, ${vbptr}vB = $hex, vd = 25, vx = 26\}$nl$gdb_prompt $" { + pass "print g_vD" + } + -re ".* = \{\<vB\> = \{\<vA\> = \{va = 19, vx = 20\}, _vptr.vB = $hex, vb = 21, vx = 22\}, \<vC\> = \{_vptr.vC = $hex, vc = 23, vx = 24\}, _vptr.vD = $hex, vd = 25, vx = 26\}$nl$gdb_prompt $" { + pass "print g_vD (FIXME v3 vtbl ptr)" + } + -re ".* = \{\<vB\> = \{\<vA\> = \{va = 19, vx = 20\}, _vptr.vB = $hex, vb = 21, vx = 22\}, \<vC\> = \{_vptr.vC = $hex <VTT for vD>, vc = 23, vx = 24\}, _vptr.vD = $hex, vd = 25, vx = 26\}$nl$gdb_prompt $" { + # Happens with gcc 3.3 -gstabs+ + # Does not happen with gcc 3.2.3 -gstabs+. + # Does not happen gcc HEAD%20030624 (pre-3.4) -gstabs+. + # -- chastain 2003-06-29 + pass "print g_vD" + } + -re ".*invalid address 0x0.*$gdb_prompt $" { + # Does not happen with gcc cygnus-2.4.5-930828 + fail "print g_vD (known bug with gcc cygnus-2.4.5-930417)" + # Many of the rest of these tests have the same problem. + return 0 + } + -re ".*$gdb_prompt $" { fail "print g_vD" } + timeout { fail "print g_vD (timeout)" ; return } + } + + # Print all members of g_vE. + + send_gdb "print g_vE\n" + gdb_expect { + -re ".* = \{\<class vD\> = \{\<class vB\> = \{\<class vA\> = \{va = 0, vx = 0\}, vb = 0, vx = 0, Virtual table at $hex\}, \<class vC\> = \{vc = 0, vx = 0, Virtual table at $hex\}, vd = 0, vx = 0, Virtual table at $hex\}, ve = 27, vx = 28, Virtual table at $hex\}$nl$gdb_prompt $" { + pass "print g_vE (aCC)" + } + -re ".* = \{\<class vD\> = \{\<class vB\> = \{\<class vA\> = \{va = 0, vx = 0\}, vb = 0, vx = 0, __vfp = $hex\}, \<class vC\> = \{vc = 0, vx = 0, __vfp = $hex\}, vd = 0, vx = 0, __vfp = $hex\}, ve = 27, vx = 28, __vfp = $hex\}$nl$gdb_prompt $" { + pass "print g_vE (aCC)" + } + -re ".* = \{\<vD\> = \{\<vB\> = \{\<vA\> = \{va = 0, vx = 0\}, ${vbptr}vA = $hex, vb = 0, vx = 0\}, \<vC\> = \{${vbptr}vA = $hex, vc = 0, vx = 0\}, ${vbptr}vC = $hex, ${vbptr}vB = $hex, vd = 0, vx = 0\}, ${vbptr}vD = $hex, ve = 27, vx = 28\}$nl$gdb_prompt $" { + pass "print g_vE" + } + -re ".* = \{\<vD\> = \{\<vB\> = \{\<vA\> = \{va = 0, vx = 0\}, _vptr.vB = $hex *(\<VTT for vD\>)?, vb = 0, vx = 0\}, \<vC\> = \{_vptr.vC = $hex *(\<VTT for vD\>)?, vc = 0, vx = 0\}, _vptr.vD = $hex, vd = 0, vx = 0\}, _vptr.vE = $hex, ve = 27, vx = 28\}$nl$gdb_prompt $" { + pass "print g_vE (FIXME v3 vtbl ptr)" + } + -re ".*$gdb_prompt $" { fail "print g_vE" } + timeout { fail "print g_vE (timeout)" } + } +} + +proc do_tests {} { + global prms_id + global bug_id + global subdir + global objdir + global srcdir + global binfile + + set prms_id 0 + set bug_id 0 + + # Start with a fresh gdb. + + gdb_exit + gdb_start + gdb_reinitialize_dir $srcdir/$subdir + gdb_load $binfile + + gdb_test "set language c++" "" + gdb_test "set width 0" "" + + # Get the debug format for the compiled test case. + + if { ![ runto_main] } { + gdb_suppress_tests; + } + + test_ptype_si + test_ptype_mi + test_ptype_vi + test_ptype_mvi + + gdb_stop_suppressing_tests; + + if { ![ runto 'inheritance2' ] } { + gdb_suppress_tests; + } + + test_print_si_members + test_print_si_classes + test_print_mi_members + test_print_mi_classes + test_print_anon_union + + gdb_stop_suppressing_tests; + + if { ![ runto 'inheritance4' ] } { + gdb_suppress_tests; + } + + test_print_svi_members + test_print_svi_classes + test_print_mvi_members + test_print_mvi_classes +} + +do_tests diff --git a/gdb/testsuite/gdb.cp/local.cc b/gdb/testsuite/gdb.cp/local.cc new file mode 100644 index 0000000..85fd6e1 --- /dev/null +++ b/gdb/testsuite/gdb.cp/local.cc @@ -0,0 +1,66 @@ +// Tests for local types + +void marker1 (void) +{ +} + +void marker2 (void) +{ +} + +int foobar (int x) +{ + class Local { + public: + int loc1; + char loc_foo (char c) + { + return c + 3; + } + }; + + Local l; + static Local l1; + char c; + + marker1 (); + + l.loc1 = 23; + + c = l.loc_foo('x'); + return c + 2; +} + +int main() +{ + int c; + + c = foobar (31); + + { // inner block + class InnerLocal { + public: + char ilc; + int * ip; + int il_foo (unsigned const char & uccr) + { + return uccr + 333; + } + class NestedInnerLocal { + public: + int nil; + int nil_foo (int i) + { + return i * 27; + } + }; + NestedInnerLocal nest1; + }; + + InnerLocal il; + + il.ilc = 'b'; + il.ip = &c; + marker2(); + } +} diff --git a/gdb/testsuite/gdb.cp/local.exp b/gdb/testsuite/gdb.cp/local.exp new file mode 100644 index 0000000..21ceb7a --- /dev/null +++ b/gdb/testsuite/gdb.cp/local.exp @@ -0,0 +1,228 @@ +# Copyright 1998, 1999, 2000, 2001, 2002, 2003 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# tests for local variables +# Written by Satish Pai <pai@apollo.hp.com> 1997-07-08 +# Cleaned by Michael Chastain <mec@shout.net> 2002-04-08 + + +# This file is part of the gdb testsuite + +if $tracelevel then { + strace $tracelevel + } + +# +# test running programs +# +set prms_id 0 +set bug_id 0 + +if { [skip_cplus_tests] } { continue } + +set testfile "local" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if [get_compiler_info $binfile "c++"] { + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + + +# +# set it up at a breakpoint so we can play with the variable values +# +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + +if ![runto 'marker1'] then { + perror "couldn't run to marker1" + continue +} + +gdb_test "up" ".*foobar.*" "up from marker1" + +# Local classes in g++ get names like "main.1::InnerLocal", just like local +# static variables. Some targets use "___" instead of ".". + +# --- +# Pattern 1: +# PASS +# dwarf-2 +# gcc 2.95.3 +# +# Pattern 2: +# FAIL +# This has a duplicate "char loc_foo" line. This is a bug. +# Historically this has been an XFAIL. +# dwarf-2 +# gcc 2.96-rh, 3.0.4, gcc-3_1-branch, HEAD +# +# Pattern 3: +# PASS +# stabs+ +# gcc 2.95.3, 2.96-rh, 3.0.4, gcc-3_1-branch, HEAD +# +# Pattern 4: +# This an old pattern from the hppa aCC version of this file. +# I left it alone. +# +# chastain 2002-04-08 + +set sep "(\[.\]|___)\[0-9\]" + +send_gdb "ptype Local\n" +gdb_expect { + -re "type = class Local \{\[\r\n\t \]*public:\[\r\n\t \]*int loc1;\[\r\n\t \]*char loc_foo\\((const *|)char\\);\[\r\n\t \]*\}.*$gdb_prompt $" { pass "ptype Local" } + -re "type = class Local \{\[\r\n\t \]*public:\[\r\n\t \]*int loc1;\[\r\n\t \]*char loc_foo\\((const *|)char\\);\[\r\n\t \]*char loc_foo\\((const *|)char\\);\[\r\n\t \]*\}.*$gdb_prompt $" { + kfail "gdb/483" "ptype Local" + } + -re "type = class Local \{\[\r\n\t \]*public:\[\r\n\t \]*int loc1;\[\r\n\t \]*Local & operator *=\\((foobar__Fi${sep}::|)Local const *&\\);\[\r\n\t \]*Local\\((foobar__Fi${sep}::|)Local const *&\\);\[\r\n\t \]*Local\\((void|)\\);\[\r\n\t \]*char loc_foo\\(char\\);\[\r\n\t \]*\}.*$gdb_prompt $" { pass "ptype Local" } + -re "type = class Local \{\r\n\[\t \]*public:\r\n\[\t \]*int loc1;\r\n\r\n\[\t \]*char loc_foo\\(char\\);\r\n\[\t \]*\\(Local at.*local\\.cc:\[0-9\]*\\)\r\n\}.*$gdb_prompt $" { xpass "ptype Local (old aCC)" } + -re ".*$gdb_prompt $" { fail "ptype Local" } + timeout { fail "(timeout) ptype Local" } +} + +gdb_test "break marker2" +gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, marker2.*" \ + "continuing to marker2" + +gdb_test "up" ".*main.*" "up from marker2" + +# Make sure that `Local' isn't in scope here; it's local to foobar. +# setup_kfail "gdb/825" +send_gdb "ptype Local\n" +set eol "\[\t \]*\[\r\n\]+\[\t \]*" +gdb_expect { + -re "No symbol \"Local\" in current context.*${gdb_prompt} $" { + pass "Local out of scope" + } + -re "ptype Local${eol}type = class Local {${eol} public:${eol} int loc1;${eol}.*${eol} char loc_foo\\(char\\);${eol}}${eol}${gdb_prompt} " { + # GCC emits STABS debugging information in a way that doesn't + # properly preserve the scoping of local classes. I think + # we'd need to start using Sun's extensions to stabs to get + # this right. + kfail gdb/825 "Local out of scope" + } + -re ".*${gdb_prompt} $" { + fail "Local out of scope" + } + timeout { + fail "Local out of scope (timeout)" + } +} + + +# DTS CLLbs14316 and CLLbs17058 +# coulter - I added a clause for HP's aCC compiler. We print out the type +# as xx instead of const unsigned char, but we still have an expected failure +# because of two reasons: +# There is a number at the end of InnerLocal4 which should not be there, +# DTS CLLbs14316 +# The line number for the class +# setup_xfail "hppa*-*-*" CLLbs14316 + +# --- +# Pattern 1: +# PASS +# dwarf-2 +# 2.95.3, 2.96-rh, 3.0.4, 3.1, gcc-3_1-branch, HEAD +# +# Pattern 2: +# PASS +# stabs+ +# 2.95.3, 2.96-rh, 3.0.4, 3.1, gcc-3_1-branch, HEAD +# +# Pattern 3: +# Old hppa pattern. +# +# Pattern 4: +# Old hppa pattern. +# +# chastain 2002-05-27 + +send_gdb "ptype InnerLocal\n" +gdb_expect { + -re "type = class InnerLocal \{\[\r\n\t \]*public:\[\r\n\t \]*char ilc;\[\r\n\t \]*int \\* *ip;\[\r\n\t \]*(InnerLocal::|)NestedInnerLocal nest1;\[\r\n\t \]*int il_foo\\((unsigned char const|const unsigned char) *&\\);\[\r\n\t \]*\}.*$gdb_prompt $" { pass "ptype InnerLocal (pattern 1)" } + -re "type = class InnerLocal \{\[\r\n\t \]*public:\[\r\n\t \]*char ilc;\[\r\n\t \]*int \\* *ip;\[\r\n\t \]*(InnerLocal::|)NestedInnerLocal nest1;\[\r\n\t \]*InnerLocal *& operator *=\\((main${sep}::|)InnerLocal const *&\\);\[\r\n\t \]*InnerLocal\\((main${sep}::|)InnerLocal const *&\\);\[\r\n\t \]*InnerLocal\\((void|)\\);\[\r\n\t \]*int il_foo\\(unsigned char const *&\\);\[\r\n\t \]*\}.*$gdb_prompt $" { pass "ptype InnerLocal (pattern 2)" } + -re "type = class InnerLocal \{\r\n\[\t \]*public:\r\n\[\t \]*char ilc;\r\n\[\t \]*int \\*ip;\r\n\[\t \]*InnerLocal::NestedInnerLocal nest1;\r\n\r\n\[\t \]*.int il_foo\\(unsigned char const &\\);\r\n\[\t \]*\}\[\t \]*\\(Local at.*local\\.cc:36\\).*$gdb_prompt $" { pass "ptype InnerLocal (old HP aCC)" } + -re "type = class InnerLocal \{\r\n\[\t \]*public:\r\n\[\t \]*char ilc;\r\n\[\t \]*int \\*ip;\r\n\[\t \]*class InnerLocal4::NestedInnerLocal nest1;\r\n\r\n\[\t \]*int il_foo\\(unsigned char const &\\);\r\n\[\t \]*\\(Local at.*local\.cc:\[0-9\]+\\)\r\n\}.*$gdb_prompt $" { pass "ptype InnerLocal (old HP aCC)" } + -re ".*$gdb_prompt $" { fail "ptype InnerLocal" } + timeout { fail "(timeout) ptype InnerLocal" } +} + +#--- +# Pattern 1: +# PASS +# dwarf-2 +# gcc 2.95.3, 2.96-rh, 3.0.4, gcc-3_1-branch, HEAD +# +# Pattern 2: +# PASS +# stabs+ +# gcc 2.95.3, 2.96-rh, 3.0.4, gcc-3_1-branch, HEAD +# +# chastain 2002-04-08 + +send_gdb "ptype NestedInnerLocal\n" +gdb_expect { + -re "type = class NestedInnerLocal \{\[\r\n\t \]*public:\[\r\n\t \]*int nil;\[\r\n\t \]*int nil_foo\\(int\\);\[\r\n\t \]*\}.*$gdb_prompt $" { pass "ptype NestedInnerLocal" } + -re "type = class NestedInnerLocal \{\[\r\n\t \]*public:\[\r\n\t \]*int nil;\[\r\n\t \]*NestedInnerLocal *& *operator *= *\\((main${sep}::|)InnerLocal::NestedInnerLocal const *&\\);\[\r\n\t \]*NestedInnerLocal\\((main${sep}::|)InnerLocal::NestedInnerLocal const *&\\);\[\r\n\t \]*NestedInnerLocal\\((void|)\\);\[\r\n\t \]*int nil_foo\\(int\\);\[\r\n\t \]*\}.*$gdb_prompt $" { pass "ptype NestedInnerLocal" } + -re ".*$gdb_prompt $" { fail "ptype NestedInnerLocal" } + timeout { fail "(timeout) ptype NestedInnerLocal" } +} + +# gdb incorrectly interprets the NestedInnerLocal in +# InnerLocal::NestedInnerLocal as field name instead of a type name; +# See CLLbs14784. + +#--- +# Pattern 3: +# FAIL +# The comment above, about CLLbs14784, is still correct. +# dwarf-2 +# gcc 2.95.3, 2.96-rh, 3.0.4, gcc-3_1-branch, HEAD +# stabs+ +# gcc 2.95.3, 2.96-rh, 3.0.4, gcc-3_1-branch, HEAD +# +# chastain 2002-04-08 + +send_gdb "ptype InnerLocal::NestedInnerLocal\n" +gdb_expect { + -re "type = class InnerLocal::NestedInnerLocal \{\[\r\n\t \]*public:\[\r\n\t \]*int nil;\[\r\n\t \]*int nil_foo\\(int\\);\[\r\n\t \]*\}.*$gdb_prompt $" { pass "ptype InnerLocal::NestedInnerLocal" } + -re "type = class InnerLocal::NestedInnerLocal \{\[\r\n\t \]*public:\[\r\n\t \]*int nil;\[\r\n\t \]*NestedInnerLocal *& *operator *= *\\((main${sep}::|)InnerLocal::NestedInnerLocal const *&\\);\[\r\n\t \]*NestedInnerLocal\\((main${sep}::|)InnerLocal::NestedInnerLocal const *&\\);\[\r\n\t \]*NestedInnerLocal\\((void|)\\);\[\r\n\t \]*int nil_foo\\(int\\);\[\r\n\t \]*\}.*$gdb_prompt $" { pass "ptype InnerLocal::NestedInnerLocal" } + -re "There is no field named NestedInnerLocal.*$gdb_prompt $" { + setup_kfail "gdb/482" *-*-* + fail "ptype InnerLocal::NestedInnerLocal" + } + -re "No symbol .*NestedInnerLocal.* in current context.*$gdb_prompt $" { fail "ptype InnerLocal::NestedInnerLocal (bogus symbol lookup)" } + -re ".*$gdb_prompt $" { fail "ptype InnerLocal::NestedInnerLocal" } + timeout { fail "(timeout) ptype InnerLocal::NestedInnerLocal" } +} diff --git a/gdb/testsuite/gdb.cp/m-data.cc b/gdb/testsuite/gdb.cp/m-data.cc new file mode 100644 index 0000000..c97e719 --- /dev/null +++ b/gdb/testsuite/gdb.cp/m-data.cc @@ -0,0 +1,64 @@ +// 2002-05-13 + +enum region { oriental, egyptian, greek, etruscan, roman }; + +// Test one. +class gnu_obj_1 +{ +protected: + typedef region antiquities; + const bool test; + const int key1; + long key2; + + antiquities value; + +public: + gnu_obj_1(antiquities a, long l): test(true), key1(5), key2(l), value(a) {} +}; + +// Test two. +template<typename T> +class gnu_obj_2: public virtual gnu_obj_1 +{ +protected: + antiquities value_derived; + +public: + gnu_obj_2(antiquities b): gnu_obj_1(oriental, 7), value_derived(b) { } +}; + +// Test three. +template<typename T> +class gnu_obj_3 +{ +protected: + typedef region antiquities; + gnu_obj_2<int> data; + +public: + gnu_obj_3(antiquities b): data(etruscan) { } +}; + +int shadow = 0; + +class C +{ +public: + C (int x) : shadow (x) {} + void marker () {} +private: + int shadow; +}; + +int main() +{ + gnu_obj_1 test1(egyptian, 4589); + gnu_obj_2<long> test2(roman); + gnu_obj_3<long> test3(greek); + + C theC (1); // breakpoint: first-constructs-done + theC.marker (); + + return 0; +} diff --git a/gdb/testsuite/gdb.cp/m-data.exp b/gdb/testsuite/gdb.cp/m-data.exp new file mode 100644 index 0000000..85adb5e --- /dev/null +++ b/gdb/testsuite/gdb.cp/m-data.exp @@ -0,0 +1,119 @@ +# Copyright 2002 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Tests for member data +# 2002-05-13 Benjamin Kosnik <bkoz@redhat.com> + +# This file is part of the gdb testsuite + +if $tracelevel then { + strace $tracelevel + } + +if { [skip_cplus_tests] } { continue } + +# +# test running programs +# +set prms_id 0 +set bug_id 0 + +set testfile "m-data" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if [get_compiler_info ${binfile} "c++"] { + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + + +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + +# First, run to after we've constructed all the gnu_obj_N's: + +gdb_breakpoint [gdb_get_line_number "first-constructs-done"] +gdb_continue_to_breakpoint "end of first constructors" + +# One. + +# simple object, const bool +gdb_test "print test1.test" "\\$\[0-9\]* = true" "simple object, const bool" + +# simple object, const int +gdb_test "print test1.key1" "\\$\[0-9\]* = 5" "simple object, const int" + +# simple object, long +gdb_test "print test1.key2" "\\$\[0-9\]* = 4589" "simple object, long" + +# simple object, enum +gdb_test "print test1.value" "\\$\[0-9\]* = egyptian" "simple object, enum" + +# Two. + +# derived template object, base const bool +gdb_test "print test2.test" "\\$\[0-9\]* = true" "derived template object, base const bool" + +# derived template object, base const int +gdb_test "print test2.key1" "\\$\[0-9\]* = 5" "derived template object, base const int" + +# derived template object, base long +gdb_test "print test2.key2" "\\$\[0-9\]* = 7" "derived template object, base long" + +# derived template object, base enum +gdb_test "print test2.value" "\\$\[0-9\]* = oriental" "derived template object, base enum" + +# derived template object, enum +gdb_test "print test2.value_derived" "\\$\[0-9\]* = roman" "derived template object, derived enum" + +# Three. + +# template object, derived template data member's base const bool +gdb_test "print test3.data.test" "\\$\[0-9\]* = true" "template object, const bool" + +# template object, derived template data member's base const int +gdb_test "print test3.data.key1" "\\$\[0-9\]* = 5" "template object, const int" + +# template object, derived template data member's base long +gdb_test "print test3.data.key2" "\\$\[0-9\]* = 7" "template object, long" + +# template object, derived template data member's base enum +gdb_test "print test3.data.value" "\\$\[0-9\]* = oriental" "template object, base enum" + +# template object, derived template data member's enum +gdb_test "print test3.data.value_derived" "\\$\[0-9]\* = etruscan" "template object, derived enum" + +# Now some tests for shadowing (see PR gdb/804): + +gdb_breakpoint "C::marker" +gdb_continue_to_breakpoint "continue to shadow breakpoint" + +gdb_test "print shadow" "\\$\[0-9]\* = 1" "shadowing member" +gdb_test "print ::shadow" "\\$\[0-9]\* = 0" "shadowed global variable" + +gdb_exit +return 0 diff --git a/gdb/testsuite/gdb.cp/m-static.cc b/gdb/testsuite/gdb.cp/m-static.cc new file mode 100644 index 0000000..6d08cb0 --- /dev/null +++ b/gdb/testsuite/gdb.cp/m-static.cc @@ -0,0 +1,72 @@ +// 2002-05-13 + +enum region { oriental, egyptian, greek, etruscan, roman }; + +// Test one. +class gnu_obj_1 +{ +protected: + typedef region antiquities; + static const bool test = true; + static const int key1 = 5; + static long key2; + + static antiquities value; + +public: + gnu_obj_1(antiquities a, long l) {} +}; + +const bool gnu_obj_1::test; +const int gnu_obj_1::key1; +long gnu_obj_1::key2 = 77; +gnu_obj_1::antiquities gnu_obj_1::value = oriental; + + +// Test two. +template<typename T> +class gnu_obj_2: public virtual gnu_obj_1 +{ +public: + static antiquities value_derived; + +public: + gnu_obj_2(antiquities b): gnu_obj_1(oriental, 7) { } +}; + +template<typename T> +typename gnu_obj_2<T>::antiquities gnu_obj_2<T>::value_derived = etruscan; + +// Test three. +template<typename T> +class gnu_obj_3 +{ +public: + typedef region antiquities; + static gnu_obj_2<int> data; + +public: + gnu_obj_3(antiquities b) { } +}; + +template<typename T> +gnu_obj_2<int> gnu_obj_3<T>::data(etruscan); + +// 2002-08-16 +// Test four. +#include "m-static.h" + +// instantiate templates explicitly so their static members will exist +template class gnu_obj_2<int>; +template class gnu_obj_2<long>; +template class gnu_obj_3<long>; + +int main() +{ + gnu_obj_1 test1(egyptian, 4589); + gnu_obj_2<long> test2(roman); + gnu_obj_3<long> test3(greek); + gnu_obj_4 test4; + + return 0; // breakpoint: constructs-done +} diff --git a/gdb/testsuite/gdb.cp/m-static.exp b/gdb/testsuite/gdb.cp/m-static.exp new file mode 100644 index 0000000..d291135 --- /dev/null +++ b/gdb/testsuite/gdb.cp/m-static.exp @@ -0,0 +1,128 @@ +# Copyright 2002 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Tests for member static data +# 2002-05-13 Benjamin Kosnik <bkoz@redhat.com> +# 2002-08-22 David Carlton <carlton@math.stanford.edu> + +# This file is part of the gdb testsuite + +if $tracelevel then { + strace $tracelevel + } + +if { [skip_cplus_tests] } { continue } + +# +# test running programs +# +set prms_id 0 +set bug_id 0 + +set testfile "m-static" +set srcfile ${testfile}.cc +set srcfile1 ${testfile}1.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${srcdir}/${subdir}/${srcfile1}" "${binfile}" executable {debug c++}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if [get_compiler_info ${binfile} "c++"] { + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + + +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + +# First, run to after we've constructed all the objects: + +gdb_breakpoint [gdb_get_line_number "constructs-done"] +gdb_continue_to_breakpoint "end of constructors" + + +# One. + +# simple object, static const bool +gdb_test "print test1.test" "\\$\[0-9\]* = true" "simple object, static const bool" + +# simple object, static const int +gdb_test "print test1.key1" "\\$\[0-9\]* = 5" "simple object, static const int" + +# simple object, static long +gdb_test "print test1.key2" "\\$\[0-9\]* = 77" "simple object, static long" + +# simple object, static enum +gdb_test "print test1.value" "\\$\[0-9\]* = oriental" "simple object, static enum" + +# Two. + +# derived template object, base static const bool +gdb_test "print test2.test" "\\$\[0-9\]* = true" "derived template object, base static const bool" + +# derived template object, base static const int +gdb_test "print test2.key1" "\\$\[0-9\]* = 5" "derived template object, base static const int" + +# derived template object, base static long +gdb_test "print test2.key2" "\\$\[0-9\]* = 77" "derived template object, base static long" + +# derived template object, base static enum +gdb_test "print test2.value" "\\$\[0-9\].* = oriental" "derived template object, base static enum" + +# derived template object, static enum +gdb_test "print test2.value_derived" "\\$\[0-9\].* = etruscan" "derived template object, static enum" + +# Three. + +# template object, static derived template data member's base static const bool +gdb_test "print test3.data.test" "\\$\[0-9\].* = true" "template object, static const bool" + +# template object, static derived template data member's base static const int +gdb_test "print test3.data.key1" "\\$\[0-9\].* = 5" "template object, static const int" + +# template object, static derived template data member's base static long +gdb_test "print test3.data.key2" "\\$\[0-9\].* = 77" "template object, static long" + +# template object, static derived template data member's base static enum +gdb_test "print test3.data.value" "\\$\[0-9\].* = oriental" "template object, static enum" + +# template object, static derived template data member's static enum +gdb_test "print test3.data.value_derived" "\\$\[0-9\].* = etruscan" "template object, static derived enum" + +# 2002-08-16 +# Four. + +# static const int initialized in another file. +gdb_test "print test4.elsewhere" "\\$\[0-9\].* = 221" "static const int initialized elsewhere" + +# static const int that nobody initializes. From PR gdb/635. +gdb_test "print test4.nowhere" "field nowhere is nonexistent or has been optimised out" "static const int initialized nowhere" + +# Perhaps at some point test4 should also include a test for a static +# const int that was initialized in the header file. But I'm not sure +# that GDB's current behavior in such situations is either consistent +# across platforms or optimal, so I'm not including one now. + +gdb_exit +return 0 diff --git a/gdb/testsuite/gdb.cp/m-static.h b/gdb/testsuite/gdb.cp/m-static.h new file mode 100644 index 0000000..137d3b7 --- /dev/null +++ b/gdb/testsuite/gdb.cp/m-static.h @@ -0,0 +1,11 @@ +// 2002-08-16 + +class gnu_obj_4 +{ + public: + static const int elsewhere; + static const int nowhere; + // At some point, perhaps: + // static const int everywhere = 317; +}; + diff --git a/gdb/testsuite/gdb.cp/m-static1.cc b/gdb/testsuite/gdb.cp/m-static1.cc new file mode 100644 index 0000000..302a5ad --- /dev/null +++ b/gdb/testsuite/gdb.cp/m-static1.cc @@ -0,0 +1,5 @@ +// 2002-08-16 + +#include "m-static.h" + +const int gnu_obj_4::elsewhere = 221; diff --git a/gdb/testsuite/gdb.cp/maint.exp b/gdb/testsuite/gdb.cp/maint.exp new file mode 100644 index 0000000..1042c91 --- /dev/null +++ b/gdb/testsuite/gdb.cp/maint.exp @@ -0,0 +1,113 @@ +# Copyright 2003 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + + +# This file tests C++-specific maintenance commands and help on those. + +# Currently, no source file is used. + +if $tracelevel then { + strace $tracelevel + } + +# Test the help messages. + +proc test_help {} { + gdb_test "help maintenance cplus" "C\\+\\+ maintenance commands.\r\n\r\nList of maintenance cplus subcommands:\r\n\r\nmaintenance cplus first_component -- Print the first class/namespace component of NAME\r\n\r\nType \"help maintenance cplus\" followed by maintenance cplus subcommand name for full documentation.\r\nCommand name abbreviations are allowed if unambiguous." + + gdb_test "help maint cp" "C\\+\\+ maintenance commands.\r\n\r\nList of maintenance cplus subcommands:\r\n\r\nmaintenance cplus first_component -- Print the first class/namespace component of NAME\r\n\r\nType \"help maintenance cplus\" followed by maintenance cplus subcommand name for full documentation.\r\nCommand name abbreviations are allowed if unambiguous." + + gdb_test "maint cp" "\"maintenance cplus\" must be followed by the name of a command.\r\nList of maintenance cplus subcommands:\r\n\r\nmaintenance cplus first_component -- Print the first class/namespace component of NAME\r\n\r\nType \"help maintenance cplus\" followed by maintenance cplus subcommand name for full documentation.\r\nCommand name abbreviations are allowed if unambiguous." + + gdb_test "help maint cp first_component" "Print the first class/namespace component of NAME." +} + +# This is used when NAME should contain only a single component. Be +# careful to make sure that parentheses get escaped properly. +proc test_single_component {name} { + set matchname [string_to_regexp "$name"] + gdb_test "maint cp first_component $name" "$matchname" +} + +# This is used when NAME is invalid. +proc test_invalid_name {name} { + set matchname [string_to_regexp "$name"] + gdb_test "maint cp first_component $name" \ + "During symbol reading, unexpected demangled name '$matchname'.\r\n$matchname" +} + +proc test_first_component {} { + # The function in question might complain; make sure that we see + # all complaints. + + gdb_test "set complaints -1" "" + + test_single_component "foo" + test_single_component "operator<<" + test_single_component "operator>>" + test_single_component "operator ->" + test_single_component "operator()" + test_single_component "operator>" + test_single_component "operator<" + test_single_component "operator ->" + test_single_component "operator ->" + + test_single_component "foo()" + test_single_component "foo(int)" + test_single_component "foo(X::Y)" + test_single_component "foo(X::Y, A::B)" + test_single_component "foo(std::basic_streambuf<wchar_t,std::char_traits<wchar_t> >)" + test_single_component "operator>(X::Y)" + + # Operator names can show up in weird places. + + test_single_component "int operator<< <char>()" + test_single_component "T<Cooperator>" + + # NOTE: carlton/2003-04-23: I've only seen the first of these + # produced by the demangler, but I'm including two more just to be + # on the safe side. + test_single_component "int foo<&(operator<<(C, C))>()" + test_single_component "int foo<&operator<<(C, C)>()" + test_single_component "int foo<operator<<(C, C)>()" + + gdb_test "maint cp first_component foo::bar" "foo" + gdb_test "maint cp first_component foo::bar::baz" "foo" + gdb_test "maint cp first_component C<A>::bar" "C<A>" + gdb_test "maint cp first_component C<std::basic_streambuf<wchar_t,std::char_traits<wchar_t> > >::bar" "C<std::basic_streambuf<wchar_t,std::char_traits<wchar_t> > >" + + # Make sure we behave appropriately on invalid input. + + # NOTE: carlton/2003-06-25: As of today, the demangler can in fact + # produce examples like the third case below: there really should + # be a space between the two <'s. See PR gdb/1245. + + test_invalid_name "foo<" + test_invalid_name "foo(" + test_invalid_name "bool operator<<char>" +} + +gdb_exit +gdb_start + +test_help +test_first_component + +gdb_exit +return 0 diff --git a/gdb/testsuite/gdb.cp/member-ptr.cc b/gdb/testsuite/gdb.cp/member-ptr.cc new file mode 100644 index 0000000..4beb926 --- /dev/null +++ b/gdb/testsuite/gdb.cp/member-ptr.cc @@ -0,0 +1,106 @@ +extern "C" { +#include <stdio.h> +} + + +class A { +public: + A(); + int foo (int x); + int bar (int y); + virtual int baz (int z); + char c; + int j; + int jj; + static int s; +}; + +class B { +public: + static int s; +}; + +int A::s = 10; +int B::s = 20; + +A::A() +{ + c = 'x'; + j = 5; +} + +int A::foo (int dummy) +{ + j += 3; + return j + dummy; +} + +int A::bar (int dummy) +{ + int r; + j += 13; + r = this->foo(15); + return r + j + 2 * dummy; +} + +int A::baz (int dummy) +{ + int r; + j += 15; + r = this->foo(15); + return r + j + 12 * dummy; +} + +int fum (int dummy) +{ + return 2 + 13 * dummy; +} + +typedef int (A::*PMF)(int); + +typedef int A::*PMI; + +int main () +{ + A a; + A * a_p; + PMF pmf; + + PMF * pmf_p; + PMI pmi; + + a.j = 121; + a.jj = 1331; + + int k; + + a_p = &a; + + pmi = &A::j; + pmf = &A::bar; + pmf_p = &pmf; + + pmi = NULL; + + k = (a.*pmf)(3); + + pmi = &A::jj; + pmf = &A::foo; + pmf_p = &pmf; + + k = (a.*pmf)(4); + + k = (a.**pmf_p)(5); + + k = a.*pmi; + + + k = a.bar(2); + + k += fum (4); + + B b; + + k += b.s; + +} diff --git a/gdb/testsuite/gdb.cp/member-ptr.exp b/gdb/testsuite/gdb.cp/member-ptr.exp new file mode 100644 index 0000000..f21cd15 --- /dev/null +++ b/gdb/testsuite/gdb.cp/member-ptr.exp @@ -0,0 +1,549 @@ +# Copyright 1998, 1999 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu +# Tests for pointer-to-member support +# Written by Satish Pai <pai@apollo.hp.com> 1997-08-19 + +# This file is part of the gdb testsuite + + +if $tracelevel then { + strace $tracelevel + } + +if { [skip_cplus_tests] } { continue } + +# +# test running programs +# + +# Start with a fresh gdb +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir + +set prms_id 0 +set bug_id 0 + +set testfile "member-ptr" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +# Create and source the file that provides information about the compiler +# used to compile the test case. + +if [get_compiler_info ${binfile} "c++"] { + return -1 +} + +# Nearly all of these tests fail when compiled with G++, so just give up +# until GDB gets enhanced. -sts 1999-06-22 + +if {$gcc_compiled} { + continue +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + + +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + +send_gdb "break 83\n" +gdb_expect { + -re "Breakpoint \[0-9\]*.*line 83\\.\r\n$gdb_prompt $" { + pass "set break at 83" + } + -re ".*$gdb_prompt $" { fail "set break at 83" } + timeout { fail "(timeout) set break at 83" } +} + +send_gdb "continue\n" +gdb_expect { + -re "Continuing\\.\r\n\r\nBreakpoint.*at.*member-ptr\\.cc:83\r\n83\[ \t]*pmi = NULL;\r\n$gdb_prompt $" { + pass "continue to 83" + } + -re ".*$gdb_prompt $" { fail "continue to 83" } + timeout { fail "(timeout) continue to 83" } +} + +# ptype on pointer to data member + +send_gdb "ptype pmi\n" +gdb_expect { + -re "type = int \\( A::\\*\\)\r\n$gdb_prompt $" { + pass "ptype pmi" + } + -re ".*$gdb_prompt $" { fail "ptype pmi" } + timeout { fail "(timeout) ptype pmi" } +} + +# print pointer to data member + +setup_xfail "hppa*-*-*" CLLbs16901 +send_gdb "print pmi\n" +gdb_expect { + -re "\\$\[0-9\]* = \\(int \\( A::\\*\\)\\) &A::j\r\n$gdb_prompt $" { + pass "print pmi" + } + -re ".*$gdb_prompt $" { fail "print pmi" } + timeout { fail "(timeout) print pmi" } +} + + +# print dereferenced pointer to data member + +setup_xfail "hppa*-*-*" CLLbs16901 +send_gdb "print a.*pmi\n" +gdb_expect { + -re "\\$\[0-9\]* = 121\r\n$gdb_prompt $" { + pass "print a.*pmi" + } + -re ".*$gdb_prompt $" { fail "print a.*pmi" } + timeout { fail "(timeout) print a.*pmi" } +} + +# print dereferenced pointer to data member +# this time, dereferenced through a pointer + +setup_xfail "hppa*-*-*" CLLbs16901 +send_gdb "print a_p->*pmi\n" +gdb_expect { + -re "\\$\[0-9\]* = 121\r\n$gdb_prompt $" { + pass "print a->*pmi" + } + -re ".*$gdb_prompt $" { fail "print a->*pmi" } + timeout { fail "(timeout) print a->*pmi" } +} + + +# set the pointer to data member + +send_gdb "set var pmi = &A::jj\n" +gdb_expect { + -re "$gdb_prompt $" { + pass "set var (not really a pass)" + } + timeout { fail "(timeout) " } +} + +# Now print the pointer again + +send_gdb "print pmi\n" +gdb_expect { + -re "\\$\[0-9\]* = \\(int \\( A::\\*\\)\\) &A::jj\r\n$gdb_prompt $" { + pass "print pmi after setting" + } + -re ".*$gdb_prompt $" { fail "print pmi after setting" } + timeout { fail "(timeout) print pmi after setting" } +} + +# print dereferenced pointer to data member again + +send_gdb "print a.*pmi\n" +gdb_expect { + -re "\\$\[0-9\]* = 1331\r\n$gdb_prompt $" { + pass "print a.*pmi after setting" + } + -re ".*$gdb_prompt $" { fail "print a.*pmi after setting" } + timeout { fail "(timeout) print a.*pmi after setting" } +} + +# set the pointer to data member back to A::j + +send_gdb "set var pmi = &A::j\n" +gdb_expect { + -re "$gdb_prompt $" { + pass "set var back to A::j (not really a pass)" + } + timeout { fail "(timeout) set var pmi" } +} + +# print dereferenced pointer to data member yet again (extra check, why not) + +send_gdb "print a.*pmi\n" +gdb_expect { + -re "\\$\[0-9\]* = 121\r\n$gdb_prompt $" { + pass "print a.*pmi after resetting" + } + -re ".*$gdb_prompt $" { fail "print a.*pmi after resetting" } + timeout { fail "(timeout) print a.*pmi after resetting" } +} + +# Set the data member pointed to. + +send_gdb "print a.*pmi = 33\n" +gdb_expect { + -re "\\$\[0-9\]* = 33\r\n$gdb_prompt $" { + pass "print command to set" + } + -re ".*$gdb_prompt $" { fail "print command to set" } + timeout { fail "(timeout) print command to set" } +} + +# Now check that the data really was changed +send_gdb "print a.*pmi\n" +gdb_expect { + -re "\\$\[0-9\]* = 33\r\n$gdb_prompt $" { + pass "print a.*pmi after setting member pointed to" + } + -re ".*$gdb_prompt $" { fail "print a.*pmi after setting member pointed to" } + timeout { fail "(timeout) print a.*pmi after setting member pointed to" } +} + +# Double-check by printing a. +setup_xfail "hppa*-*-*" CLLbs16901 +send_gdb "print a\n" +gdb_expect { + -re "\\$\[0-9\]* = \{c = 120 'x', j = 33, jj = 1331, static s = 10, Virtual table at $hex\}\r\n$gdb_prompt $" { + pass "print a after setting member pointed to by pmi" + } + -re ".*$gdb_prompt $" { fail "print a after setting member pointed to by pmi" } + timeout { fail "(timeout) print a after setting member pointed to by pmi" } +} + + +# Set the data member pointed to, using ->* + +send_gdb "print a_p->*pmi = 44\n" +gdb_expect { + -re "\\$\[0-9\]* = 44\r\n$gdb_prompt $" { + pass "print command to set (->)" + } + -re ".*$gdb_prompt $" { fail "print command to set (->)" } + timeout { fail "(timeout) print command to set (->)" } +} + +# Now check that the data really was changed +send_gdb "print a_p->*pmi\n" +gdb_expect { + -re "\\$\[0-9\]* = 44\r\n$gdb_prompt $" { + pass "print a_p->*pmi after setting member pointed to" + } + -re ".*$gdb_prompt $" { fail "print a_p->*pmi after setting member pointed to" } + timeout { fail "(timeout) print a_p->*pmi after setting member pointed to" } +} + +# Double-check by printing a. +setup_xfail "hppa*-*-*" CLLbs16901 +send_gdb "print a\n" +gdb_expect { + -re "\\$\[0-9\]* = \{c = 120 'x', j = 44, jj = 1331, static s = 10, Virtual table at $hex\}\r\n$gdb_prompt $" { + pass "print a after setting member pointed to by pmi (->) " + } + -re ".*$gdb_prompt $" { fail "print a after setting member pointed to by pmi (->) " } + timeout { fail "(timeout) print a after setting member pointed to by pmi (->) " } +} + + +# Do a ptype on the dereferenced pointer to member +# pai/1997-08-20 Doesn't work + +# send_gdb "ptype a.*pmi\n" +# gdb_expect { +# -re "type = int\r\n$gdb_prompt $" { +# pass "ptype a.*pmi" +# } +# -re ".*$gdb_prompt $" { fail "ptype a.*pmi" } +# timeout { fail "(timeout) ptype a.*pmi" } +#} + +# Try to dereference the pointer to data member without any object + +send_gdb "print *pmi\n" +gdb_expect { + -re "Attempt to dereference pointer to member without an object\r\n$gdb_prompt $" { + pass "attempt to print ptr to member without object" + } + -re ".*$gdb_prompt $" { fail "attempt to print ptr to member without object" } + timeout { fail "(timeout) attempt to print ptr to member without object" } +} + +# Try to ptype a dereference of the pointer to data member without any object + +send_gdb "ptype *pmi\n" +gdb_expect { + -re "Attempt to dereference pointer to member without an object\r\n$gdb_prompt $" { + pass "attempt to ptype ptr to member without object" + } + -re ".*$gdb_prompt $" { fail "attempt to ptype ptr to member without object" } + timeout { fail "(timeout) attempt to ptype ptr to member without object" } +} + +# Ptype a pointer to a method. + +setup_xfail "hppa*-*-*" CLLbs16901 +send_gdb "ptype pmf\n" +gdb_expect { + -re "type = int \\( A::\\*\\)\\(\\.\\.\\.\\)\r\n$gdb_prompt $" { + pass "ptype pmf" + } + -re ".*$gdb_prompt $" { fail "ptype pmf" } + timeout { fail "(timeout) ptype pmf" } +} + +# print a pointer to a method + +setup_xfail "hppa*-*-*" CLLbs16901 +send_gdb "print pmf\n" +gdb_expect { + -re "\\$\[0-9\]* = \\(int \\( A::\\*\\)\\(\\.\\.\\.\\)\\) \\?\\? <not supported with HP aCC>\r\n$gdb_prompt $" { + pass "print pmf" + } + -re ".*$gdb_prompt $" { fail "print pmf" } + timeout { fail "(timeout) print pmf" } +} + + +# Ptype a pointer to a pointer to a method + +setup_xfail "hppa*-*-*" CLLbs16901 +send_gdb "ptype pmf_p\n" +gdb_expect { + -re "type = int \\( A::\\*\\*\\)\\(\\.\\.\\.\\)\r\n$gdb_prompt $" { + pass "ptype pmf_p" + } + -re ".*$gdb_prompt $" { fail "ptype pmf_p" } + timeout { fail "(timeout) ptype pmf_p" } +} + +# print a pointer to a pointer to a method + +setup_xfail "hppa*-*-*" CLLbs16901 +send_gdb "print pmf_p\n" +gdb_expect { + -re "\\$\[0-9\]* = \\(int \\( A::\\*\\*\\)\\(\\.\\.\\.\\)\\) $hex\r\n$gdb_prompt $" { + pass "print pmf_p" + } + -re ".*$gdb_prompt $" { fail "print pmf_p" } + timeout { fail "(timeout) print pmf_p" } +} + +# print dereferenced pointer to method + +setup_xfail "hppa*-*-*" CLLbs16901 +send_gdb "print a.*pmf\n" +gdb_expect { + -re "Pointers to methods not supported with HP aCC\r\n$gdb_prompt $" { + pass "print a.*pmf (known aCC limitation)" + } + -re ".*$gdb_prompt $" { fail "print a.*pmf" } + timeout { fail "(timeout) print a.*pmf" } +} + +# print dereferenced pointer to method, using ->* + +setup_xfail "hppa*-*-*" CLLbs16901 +send_gdb "print a_p->*pmf\n" +gdb_expect { + -re "Pointers to methods not supported with HP aCC\r\n$gdb_prompt $" { + pass "print a_p->*pmf (known aCC limitation)" + } + -re ".*$gdb_prompt $" { fail "print a_p->*pmf" } + timeout { fail "(timeout) print a_p->*pmf" } +} + +# set the pointer to data member + +setup_xfail "hppa*-*-*" +send_gdb "set var pmf = &A::foo\n" +gdb_expect { + -re "Assignment to pointers to methods not implemented with HP aCC\r\n$gdb_prompt $" { + pass "set var pmf (known aCC limitation)" + } + -re ".*$gdb_prompt $" { fail "set var pmf" } + timeout { fail "(timeout) set var pmf" } +} + +# Try to dereference the pointer to method without any object + +setup_xfail "hppa*-*-*" CLLbs16901 +send_gdb "print *pmf\n" +gdb_expect { + -re "Attempt to dereference pointer to member without an object\r\n$gdb_prompt $" { + pass "attempt to print ptr to method without object" + } + -re ".*$gdb_prompt $" { fail "attempt to print ptr to method without object" } + timeout { fail "(timeout) attempt to print ptr to method without object" } +} + +# Try to ptype a dereference of the pointer to method without any object + +send_gdb "ptype *pmi\n" +gdb_expect { + -re "Attempt to dereference pointer to member without an object\r\n$gdb_prompt $" { + pass "attempt to ptype ptr to member without object" + } + -re ".*$gdb_prompt $" { fail "attempt to ptype ptr to member without object" } + timeout { fail "(timeout) attempt to ptype ptr to member without object" } +} + +# Check cast of pointer to member to integer +setup_xfail "hppa*-*-*" CLLbs16901 +send_gdb "print (int) pmi\n" +gdb_expect { + -re "\\$\[0-9\]* = 8\r\n$gdb_prompt $" { + pass "casting pmi to int" + } + -re ".*$gdb_prompt $" { fail "casting pmi to int" } + timeout { fail "(timeout) casting pmi to int" } +} + +# Check cast of pointer to method to integer +setup_xfail "hppa*-*-*" CLLbs16901 +send_gdb "print (int) pmf\n" +gdb_expect { + -re "Pointers to methods not supported with HP aCC\r\n$gdb_prompt $" { + pass "casting pmf to int (known aCC limitation)" + } + -re ".*$gdb_prompt $" { fail "casting pmf to int" } + timeout { fail "(timeout) casting pmf to int" } +} + +# Try to invoke a function through a pointer to data member +setup_xfail "hppa*-*-*" CLLbs16901 +send_gdb "print (a.*pmi)(3)\n" +gdb_expect { + -re "Not implemented: function invocation through pointer to method with HP aCC\r\n$gdb_prompt $" { + pass "print (a.*pmi)(3) -- error message should be different" + } + -re ".*$gdb_prompt $" { fail "print (a.*pmi)(3)" } + timeout { fail "(timeout) print (a.*pmi)(3)" } +} + +# Try to invoke a function through a pointer to a method +setup_xfail "hppa*-*-*" CLLbs16901 +send_gdb "print (a.*pmf)(3)\n" +gdb_expect { + -re "Not implemented: function invocation through pointer to method with HP aCC\r\n$gdb_prompt $" { + pass "print (a.*pmi)(3) -- known aCC limitation" + } + -re ".*$gdb_prompt $" { fail "print (a.*pmf)(3)" } + timeout { fail "(timeout) print (a.*pmf)(3)" } +} + + +# Go past assignment of NULL to pmi +setup_xfail "hppa*-*-*" CLLbs16901 +send_gdb "next\n" +gdb_expect { + -re "\r\n85\[ \t\]*k = \\(a.\\*pmf\\)\\(3\\);\r\n$gdb_prompt $" { + pass "next past 83" + } + -re ".*$gdb_prompt $" { fail "next past 83" } + timeout { fail "(timeout) next past 83" } +} + +#send_gdb "print pmi\n" +#gdb_expect { +# -re "Attempted dereference of null pointer-to-member\r\n$gdb_prompt $" { +# pass "" +# } +# -re ".*$gdb_prompt $" { fail "" } +# timeout { fail "(timeout) " } +#} + +# Dereference the null pointer to member +setup_xfail "hppa*-*-*" CLLbs16901 +send_gdb "print a.*pmi\n" +gdb_expect { + -re "Attempted dereference of null pointer-to-member\r\n$gdb_prompt $" { + pass "print a.*NULL" + } + -re ".*$gdb_prompt $" { fail "print a.*NULL" } + timeout { fail "(timeout) print a.*NULL" } +} + + +# Go to another part of the program +send_gdb "break 91\n" +gdb_expect { + -re "Breakpoint \[0-9\]*.*line 91\\.\r\n$gdb_prompt $" { + pass "set break at 91" + } + -re ".*$gdb_prompt $" { fail "set break at 91" } + timeout { fail "(timeout) set break at 91" } +} + +setup_xfail "hppa*-*-*" CLLbs16901 +send_gdb "continue\n" +gdb_expect { + -re "Continuing\\.\r\n\r\nBreakpoint.*at.*member-ptr\\.cc:91\r\n91\[ \t]*k = \\(a.\\*pmf\\)\\(4\\);\r\n$gdb_prompt $" { + pass "continue to 91" + } + -re ".*$gdb_prompt $" { fail "continue to 91" } + timeout { fail "(timeout) continue to 91" } +} + + +# Now check again that pmi works even when not set to +# something that's at the beginning of the object + +setup_xfail "hppa*-*-*" CLLbs16901 +send_gdb "print pmi\n" +gdb_expect { + -re "\\$\[0-9\]* = \\(int \\( A::\\*\\)\\) &A::jj\r\n$gdb_prompt $" { + pass "print pmi (2)" + } + -re ".*$gdb_prompt $" { fail "print pmi (2)" } + timeout { fail "(timeout) print pmi (2)" } +} + + +# print dereferenced pointer to data member + +setup_xfail "hppa*-*-*" CLLbs16901 +send_gdb "print a.*pmi\n" +gdb_expect { + -re "\\$\[0-9\]* = 1331\r\n$gdb_prompt $" { + pass "print a.*pmi (2)" + } + -re ".*$gdb_prompt $" { fail "print a.*pmi (2)" } + timeout { fail "(timeout) print a.*pmi (2)" } +} + +# print dereferenced pointer to data member +# this time, dereferenced through a pointer + +setup_xfail "hppa*-*-*" CLLbs16901 +send_gdb "print a_p->*pmi\n" +gdb_expect { + -re "\\$\[0-9\]* = 1331\r\n$gdb_prompt $" { + pass "print a->*pmi" + } + -re ".*$gdb_prompt $" { fail "print a->*pmi (2)" } + timeout { fail "(timeout) print a->*pmi (2)" } +} + + +# p a.*pmf - fail + +# p pmi + +# p a.*pmi + diff --git a/gdb/testsuite/gdb.cp/method.cc b/gdb/testsuite/gdb.cp/method.cc new file mode 100644 index 0000000..949b027 --- /dev/null +++ b/gdb/testsuite/gdb.cp/method.cc @@ -0,0 +1,80 @@ +// Class funk has a constructor and an ordinary method +// Test for CHFts23426 + +class funk +{ +public: + funk(); + void getFunky(int a, int b); + int data_; +}; + +funk::funk() + : data_(33) +{ +} + +void funk::getFunky(int a, int b) +{ + int res; + res = a + b - data_; + data_ = res; +} + +// Class A has const and volatile methods + +class A { +public: + int x; + int y; + int foo (int arg); + int bar (int arg) const; + int baz (int arg, char c) volatile; + int qux (int arg, float f) const volatile; +}; + +int A::foo (int arg) +{ + x += arg; + return arg *2; +} + +int A::bar (int arg) const +{ + return arg + 2 * x; +} + +int A::baz (int arg, char c) volatile +{ + return arg - 2 * x + c; +} + +int A::qux (int arg, float f) const volatile +{ + if (f > 0) + return 2 * arg - x; + else + return 2 * arg + x; +} + + +int main() +{ + A a; + int k; + + k = 10; + a.x = k * 2; + + k = a.foo(13); + + k += a.bar(15); + + // Test for CHFts23426 follows + funk f; + f.getFunky(1, 2); + return 0; +} + + + diff --git a/gdb/testsuite/gdb.cp/method.exp b/gdb/testsuite/gdb.cp/method.exp new file mode 100644 index 0000000..a085b14 --- /dev/null +++ b/gdb/testsuite/gdb.cp/method.exp @@ -0,0 +1,194 @@ +# Copyright 1998, 1999, 2001, 2002 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# tests for misc. C++ method stuff +# Written by Satish Pai <pai@apollo.hp.com> 1997-07-08 + +# This file is part of the gdb testsuite + +# This tests: +# 0. method arguments are correct +# 1. access to class data members inside method scopes +# 2. correct param types for methods in ptype. +# 3. const and volatile methods + +# (#0 and #1 above relate to an HP specific problem -- GDB must correctly +# integrate FPARAM symbols in HP debug info into the local var list +# for the function or method's block.) + +if $tracelevel then { + strace $tracelevel + } + +# +# test running programs +# +set prms_id 0 +set bug_id 0 + +if { [skip_cplus_tests] } { continue } + +set testfile "method" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if [get_compiler_info $binfile "c++"] { + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + + +# +# set it up at a breakpoint so we can play with the variable values +# +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + +gdb_test "break A::foo" \ + "Breakpoint \[0-9\]* at $hex.*file .*method.cc, line 38\\." + +gdb_test "continue" \ + "Continuing\\.\r\n\r\nBreakpoint \[0-9\]*, A::foo(\\(int\\)|) \\(this=$hex, arg=13\\) at .*method\\.cc:38\r\n38\[\t \]*x \\+= arg;" \ + "continue to A::foo" + +# Check ability to access this-relative stuff. + +gdb_test "print x" \ + "\\$\[0-9\]* = 20" \ + "print x in A::foo" + +# Check access to this pointer + +gdb_test "print this" \ + "\\$\[0-9\]* = \\((class |)A *\\* *(const|)\\) $hex" \ + "print this in A::foo" + +# Now do everything over again for A::bar, because sometimes processing one method +# (the first one) is fine, but the second one's debug info gets munged beyond recognition. + +gdb_test "break A::bar" \ + "Breakpoint \[0-9\]* at $hex.*file .*method.cc, line 44\\." + +gdb_test "continue" \ + "Continuing\\.\r\n\r\nBreakpoint \[0-9\]*, A::bar(\\(int\\) const|) \\(this=$hex, arg=15\\) at .*method\\.cc:44\r\n44\[\t \]*return arg \\+ 2 \\* x;" \ + "continue to A::bar" + +# Check ability to access this-relative stuff. + +gdb_test "print x" \ + "\\$\[0-9\]* = 33" \ + "print x in A::bar" + +# Check access to this pointer + +get_debug_format + +send_gdb "print this\n" +gdb_expect { + -re "\\$\[0-9\]* = \\(const (class |)A *\\* *(const|)\\) $hex\r\n$gdb_prompt $" { + pass "print this in A::bar" + } + -re "\\$\[0-9\]* = \\((class |)A *\\* *(const|)\\) $hex\r\n$gdb_prompt $" { + # gcc versions up to 3.0.4 with -gstabs+ do not emit "const" indicators, + # so the output is "A *". It should be "const A *" or "const A * const". + setup_xfail_format "stabs" + fail "print this in A::bar (missing const)" + } + -re "\\$\[0-9\]* = \\(const (class |)\{\\.\\.\\.\} *\\* *(const|)\\) $hex\r\n$gdb_prompt $" { + # gcc versions gcc-3_1-branch%20020404 and HEAD%20020404 with -gstabs+ + # produce good stabs, but gdb prints "const class {...} *" const. + # This is PR gdb/277. + # setup_kfail "gdb/277" + fail "print this in A::bar (gdb/277)" + } + -re ".*$gdb_prompt $" { fail "print this in A::bar" } + timeout { fail "(timeout) print this in A::bar" } +} + +# Check again with funk::getFunky (this is the original test case +# for CHFts23426); sometimes having a constructor with no arguments +# will nuke the debug info read in for other methods in the class. + +gdb_test "break 21" \ + "Breakpoint \[0-9\]* at $hex.*file .*method.cc, line 21\\." + +gdb_test "continue" \ + "Continuing\\.\r\n\r\nBreakpoint \[0-9\]*, funk::getFunky(\\(int, int\\)|) \\(this=$hex, a=1, b=2\\) at .*method\\.cc:21\r\n21\[\t \]*data_ = res;" \ + "continue to 21" + +# Check ability to access this-relative stuff. + +gdb_test "print data_" \ + "\\$\[0-9\]* = 33" \ + "print data_ in funk::getFunky" + +# Check access to this pointer + +gdb_test "print this" \ + "\\$\[0-9\]* = \\((class |)funk *\\* *(const|)\\) $hex" \ + "print this in funk::getFunky" + +# Check access to local variable + +gdb_test "print res" \ + "\\$\[0-9\]* = -30" \ + "print res in funk::getFunky" + +# Check ptype of class -- should show const/volatile methods + +send_gdb "ptype A\n" +gdb_expect { + -re "type = class A \{\r\n\[ \]*public:\r\n\[ \]*int x;\r\n\[ \]*int y;\r\n\r\n\[ \]*int foo\\(int\\);\r\n\[ \]*int bar\\(int\\) const;\r\n\[ \]*int baz\\(int, char\\) volatile;\r\n\[ \]*int qux\\(int, float\\) (const volatile|volatile const);\r\n\}\r\n$gdb_prompt $" { + pass "ptype A" + } + -re "type = class A \{\r\n\[ \]*public:\r\n\[ \]*int x;\r\n\[ \]*int y;\r\n\r\n\[ \]*A & operator=\\(A const ?&\\);\r\n\[ \]*A\\(A const ?&\\);\r\n\[ \]*A\\((void|)\\);\r\n\[ \]*int foo\\(int\\);\r\n\[ \]*int bar\\(int\\) const;\r\n\[ \]*int baz\\(int, char\\) volatile;\r\n\[ \]*int qux\\(int, float\\) (const volatile|volatile const);\r\n\}\r\n$gdb_prompt $" { + pass "ptype A" + } + -re "type = class A \{\r\n\[ \]*public:\r\n\[ \]*int x;\r\n\[ \]*int y;\r\n\r\n\[ \]*int foo\\(int\\);\r\n\[ \]*int bar\\(int\\) const;\r\n\[ \]*int baz\\(int, char\\);\r\n\[ \]*int qux\\(int, float\\) const;\r\n\}\r\n$gdb_prompt $" { + pass "ptype A (HP aCC bug -- volatile not indicated)" + } + -re "type = class A \{\r\n\[ \]*public:\r\n\[ \]*int x;\r\n\[ \]*int y;\r\n\r\n\[ \]*int foo\\(int\\);\r\n\[ \]*int bar\\(int\\) const;\r\n\[ \]*int baz\\(int, char\\) volatile;\r\n\[ \]*int qux\\(int, float\\) const volatile;\r\n\}\r\n$gdb_prompt $" { + pass "ptype A" + } + -re ".*$gdb_prompt $" { fail "ptype A" } + timeout { fail "(timeout) ptype A" } +} + +send_gdb "cont\n" +gdb_expect { + -re "Continuing.\r\n\r\nProgram exited normally.*$gdb_prompt $" { + pass "finish program" + } + -re "Continuing.* EXIT code 0.*Program exited normally.*$gdb_prompt $" { + pass "finish program (exit wrapper)" + } + -re ".*$gdb_prompt $" { fail "finish program" } + default:{ fail "finish program (timeout)" } +} + diff --git a/gdb/testsuite/gdb.cp/misc.cc b/gdb/testsuite/gdb.cp/misc.cc new file mode 100644 index 0000000..286c02b --- /dev/null +++ b/gdb/testsuite/gdb.cp/misc.cc @@ -0,0 +1,587 @@ +// Test various -*- C++ -*- things. + +// ====================== basic C++ types ======================= +bool v_bool; +bool v_bool_array[2]; + +typedef struct fleep fleep; +struct fleep { int a; } s; + +// ====================== simple class structures ======================= + +struct default_public_struct { + // defaults to public: + int a; + int b; +}; + +struct explicit_public_struct { + public: + int a; + int b; +}; + +struct protected_struct { + protected: + int a; + int b; +}; + +struct private_struct { + private: + int a; + int b; +}; + +struct mixed_protection_struct { + public: + int a; + int b; + private: + int c; + int d; + protected: + int e; + int f; + public: + int g; + private: + int h; + protected: + int i; +}; + +class public_class { + public: + int a; + int b; +}; + +class protected_class { + protected: + int a; + int b; +}; + +class default_private_class { + // defaults to private: + int a; + int b; +}; + +class explicit_private_class { + private: + int a; + int b; +}; + +class mixed_protection_class { + public: + int a; + int b; + private: + int c; + int d; + protected: + int e; + int f; + public: + int g; + private: + int h; + protected: + int i; +}; + +class const_vol_method_class { +public: + int a; + int b; + int foo (int &) const; + int bar (int &) volatile; + int baz (int &) const volatile; +}; + +int const_vol_method_class::foo (int & ir) const +{ + return ir + 3; +} +int const_vol_method_class::bar (int & ir) volatile +{ + return ir + 4; +} +int const_vol_method_class::baz (int & ir) const volatile +{ + return ir + 5; +} + +// ========================= simple inheritance ========================== + +class A { + public: + int a; + int x; +}; + +A g_A; + +class B : public A { + public: + int b; + int x; +}; + +B g_B; + +class C : public A { + public: + int c; + int x; +}; + +C g_C; + +class D : public B, public C { + public: + int d; + int x; +}; + +D g_D; + +class E : public D { + public: + int e; + int x; +}; + +E g_E; + +class class_with_anon_union +{ + public: + int one; + union + { + int a; + long b; + }; +}; + +class_with_anon_union g_anon_union; + +void inheritance2 (void) +{ +} + +void inheritance1 (void) +{ + int ival; + int *intp; + + // {A::a, A::x} + + g_A.A::a = 1; + g_A.A::x = 2; + + // {{A::a,A::x},B::b,B::x} + + g_B.A::a = 3; + g_B.A::x = 4; + g_B.B::b = 5; + g_B.B::x = 6; + + // {{A::a,A::x},C::c,C::x} + + g_C.A::a = 7; + g_C.A::x = 8; + g_C.C::c = 9; + g_C.C::x = 10; + + // {{{A::a,A::x},B::b,B::x},{{A::a,A::x},C::c,C::x},D::d,D::x} + + // The following initialization code is non-portable, but allows us + // to initialize all members of g_D until we can fill in the missing + // initialization code with legal C++ code. + + for (intp = (int *) &g_D, ival = 11; + intp < ((int *) &g_D + sizeof (g_D) / sizeof (int)); + intp++, ival++) + { + *intp = ival; + } + + // Overlay the nonportable initialization with legal initialization. + + // ????? = 11; (g_D.A::a = 11; is ambiguous) + // ????? = 12; (g_D.A::x = 12; is ambiguous) +/* djb 6-3-2000 + + This should take care of it. Rather than try to initialize using an ambiguous + construct, use 2 unambiguous ones for each. Since the ambiguous a/x member is + coming from C, and B, initialize D's C::a, and B::a, and D's C::x and B::x. + */ + g_D.C::a = 15; + g_D.C::x = 12; + g_D.B::a = 11; + g_D.B::x = 12; + g_D.B::b = 13; + g_D.B::x = 14; + // ????? = 15; + // ????? = 16; + g_D.C::c = 17; + g_D.C::x = 18; + g_D.D::d = 19; + g_D.D::x = 20; + + + // {{{{A::a,A::x},B::b,B::x},{{A::a,A::x},C::c,C::x},D::d,D::x}},E::e,E::x} + + // The following initialization code is non-portable, but allows us + // to initialize all members of g_D until we can fill in the missing + // initialization code with legal C++ code. + + for (intp = (int *) &g_E, ival = 21; + intp < ((int *) &g_E + sizeof (g_E) / sizeof (int)); + intp++, ival++) + { + *intp = ival; + } + + // Overlay the nonportable initialization with legal initialization. + + // ????? = 21; (g_E.A::a = 21; is ambiguous) + // ????? = 22; (g_E.A::x = 22; is ambiguous) + g_E.B::b = 23; + g_E.B::x = 24; + // ????? = 25; + // ????? = 26; + g_E.C::c = 27; + g_E.C::x = 28; + g_E.D::d = 29; + g_E.D::x = 30; + g_E.E::e = 31; + g_E.E::x = 32; + + g_anon_union.one = 1; + g_anon_union.a = 2; + + inheritance2 (); +} + +// ======================== static member functions ===================== + +class Static { +public: + static void ii(int, int); +}; +void Static::ii (int, int) { } + +// ======================== virtual base classes========================= + +class vA { + public: + int va; + int vx; +}; + +vA g_vA; + +class vB : public virtual vA { + public: + int vb; + int vx; +}; + +vB g_vB; + +class vC : public virtual vA { + public: + int vc; + int vx; +}; + +vC g_vC; + +class vD : public virtual vB, public virtual vC { + public: + int vd; + int vx; +}; + +vD g_vD; + +class vE : public virtual vD { + public: + int ve; + int vx; +}; + +vE g_vE; + +void inheritance4 (void) +{ +} + +void inheritance3 (void) +{ + int ival; + int *intp; + + // {vA::va, vA::vx} + + g_vA.vA::va = 1; + g_vA.vA::vx = 2; + + // {{vA::va, vA::vx}, vB::vb, vB::vx} + + g_vB.vA::va = 3; + g_vB.vA::vx = 4; + g_vB.vB::vb = 5; + g_vB.vB::vx = 6; + + // {{vA::va, vA::vx}, vC::vc, vC::vx} + + g_vC.vA::va = 7; + g_vC.vA::vx = 8; + g_vC.vC::vc = 9; + g_vC.vC::vx = 10; + + // {{{{vA::va, vA::vx}, vB::vb, vB::vx}, vC::vc, vC::vx}, vD::vd,vD::vx} + + g_vD.vA::va = 11; + g_vD.vA::vx = 12; + g_vD.vB::vb = 13; + g_vD.vB::vx = 14; + g_vD.vC::vc = 15; + g_vD.vC::vx = 16; + g_vD.vD::vd = 17; + g_vD.vD::vx = 18; + + + // {{{{{vA::va,vA::vx},vB::vb,vB::vx},vC::vc,vC::vx},vD::vd,vD::vx},vE::ve,vE::vx} + + g_vD.vA::va = 19; + g_vD.vA::vx = 20; + g_vD.vB::vb = 21; + g_vD.vB::vx = 22; + g_vD.vC::vc = 23; + g_vD.vC::vx = 24; + g_vD.vD::vd = 25; + g_vD.vD::vx = 26; + g_vE.vE::ve = 27; + g_vE.vE::vx = 28; + + inheritance4 (); +} + +// ====================================================================== + +class Base1 { + public: + int x; + Base1(int i) { x = i; } +}; + +class Foo +{ + public: + int x; + int y; + static int st; + Foo (int i, int j) { x = i; y = j; } + int operator! (); + operator int (); + int times (int y); +}; + +class Bar : public Base1, public Foo { + public: + int z; + Bar (int i, int j, int k) : Base1 (10*k), Foo (i, j) { z = k; } +}; + +int Foo::operator! () { return !x; } + +int Foo::times (int y) { return x * y; } + +int Foo::st = 100; + +Foo::operator int() { return x; } + +Foo foo(10, 11); +Bar bar(20, 21, 22); + +class ClassWithEnum { +public: + enum PrivEnum { red, green, blue, yellow = 42 }; + PrivEnum priv_enum; + int x; +}; + +void enums2 (void) +{ +} + +/* classes.exp relies on statement order in this function for testing + enumeration fields. */ + +void enums1 () +{ + ClassWithEnum obj_with_enum; + obj_with_enum.priv_enum = ClassWithEnum::red; + obj_with_enum.x = 0; + enums2 (); + obj_with_enum.priv_enum = ClassWithEnum::green; +} + +class ClassParam { +public: + int Aptr_a (A *a) { return a->a; } + int Aptr_x (A *a) { return a->x; } + int Aref_a (A &a) { return a.a; } + int Aref_x (A &a) { return a.x; } + int Aval_a (A a) { return a.a; } + int Aval_x (A a) { return a.x; } +}; + +ClassParam class_param; + +class Contains_static_instance +{ + public: + int x; + int y; + Contains_static_instance (int i, int j) { x = i; y = j; } + static Contains_static_instance null; +}; + +Contains_static_instance Contains_static_instance::null(0,0); +Contains_static_instance csi(10,20); + +class Contains_nested_static_instance +{ + public: + class Nested + { + public: + Nested(int i) : z(i) {} + int z; + static Contains_nested_static_instance xx; + }; + + Contains_nested_static_instance(int i, int j) : x(i), y(j) {} + + int x; + int y; + + static Contains_nested_static_instance null; + static Nested yy; +}; + +Contains_nested_static_instance Contains_nested_static_instance::null(0, 0); +Contains_nested_static_instance::Nested Contains_nested_static_instance::yy(5); +Contains_nested_static_instance + Contains_nested_static_instance::Nested::xx(1,2); +Contains_nested_static_instance cnsi(30,40); + +typedef struct { + int one; + int two; +} tagless_struct; +tagless_struct v_tagless; + +/* Try to get the compiler to allocate a class in a register. */ +class small { + public: + int x; + int method (); +}; + +int +small::method () +{ + return x + 5; +} + +void marker_reg1 () {} + +int +register_class () +{ + /* We don't call any methods for v, so gcc version cygnus-2.3.3-930220 + might put this variable in a register. This is a lose, though, because + it means that GDB can't call any methods for that variable. */ + register small v; + + int i; + + /* Perform a computation sufficiently complicated that optimizing compilers + won't optimized out the variable. If some compiler constant-folds this + whole loop, maybe using a parameter to this function here would help. */ + v.x = 0; + for (i = 0; i < 13; ++i) + v.x += i; + --v.x; /* v.x is now 77 */ + marker_reg1 (); + return v.x + 5; +} + +void dummy() +{ + v_bool = true; + v_bool_array[0] = false; + v_bool_array[1] = v_bool; +} + +void use_methods () +{ + /* Refer to methods so that they don't get optimized away. */ + int i; + i = class_param.Aptr_a (&g_A); + i = class_param.Aptr_x (&g_A); + i = class_param.Aref_a (g_A); + i = class_param.Aref_x (g_A); + i = class_param.Aval_a (g_A); + i = class_param.Aval_x (g_A); +} + + +int +main() +{ +#ifdef usestubs + set_debug_traps(); + breakpoint(); +#endif + dummy(); + inheritance1 (); + inheritance3 (); + enums1 (); + register_class (); + + /* FIXME: pmi gets optimized out. Need to do some more computation with + it or something. (No one notices, because the test is xfail'd anyway, + but that probably won't always be true...). */ + int Foo::* pmi = &Foo::y; + + /* Make sure the AIX linker doesn't remove the variable. */ + v_tagless.one = 5; + + use_methods (); + + return foo.*pmi; +} + +/* Create an instance for some classes, otherwise they get optimized away. */ + +default_public_struct default_public_s; +explicit_public_struct explicit_public_s; +protected_struct protected_s; +private_struct private_s; +mixed_protection_struct mixed_protection_s; +public_class public_c; +protected_class protected_c; +default_private_class default_private_c; +explicit_private_class explicit_private_c; +mixed_protection_class mixed_protection_c; diff --git a/gdb/testsuite/gdb.cp/misc.exp b/gdb/testsuite/gdb.cp/misc.exp new file mode 100644 index 0000000..a2d122f --- /dev/null +++ b/gdb/testsuite/gdb.cp/misc.exp @@ -0,0 +1,159 @@ +# Copyright 1992, 1994, 1995, 1996, 1997, 1999, 2002 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# This file was written by Fred Fish. (fnf@cygnus.com) + +if $tracelevel then { + strace $tracelevel +} + +if { [skip_cplus_tests] } { continue } + +set testfile "misc" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +# +# Deduce language of main() +# + +proc deduce_language_of_main {} { + global gdb_prompt + + # See what language gdb thinks main() is, prior to reading full symbols. + # I think this fails for COFF targets. + send_gdb "show language\n" + gdb_expect { + -re ".* source language is \"auto; currently c\[+\]+\".*$gdb_prompt $" { + pass "deduced language is C++, before full symbols" + } + -re ".*$gdb_prompt $" { + fail "source language not correct for C++ (psymtabs only)" + return + } + timeout { + fail "can't show language (timeout)" + return + } + } + + runto_main + + # See if our idea of the language has changed. + + send_gdb "show language\n" + gdb_expect { + -re ".* source language is \"auto; currently c\[+\]+\".*$gdb_prompt $" { + pass "deduced language is C++, after full symbols" + } + -re ".*$gdb_prompt $" { + fail "source language not correct for C++ (full symbols)" + return + } + timeout { + fail "can't show language (timeout)" + return + } + } +} + +proc test_expr { args } { + if { [llength $args] % 2 } { + warning "an even # of arguments should be passed to test_expr" + } + set last_ent [expr [llength $args] - 1]; + set testname [lindex $args $last_ent]; + if [gdb_test [lindex $args 0] "" "$testname (setup)"] { + gdb_suppress_tests; + } + for {set x 1} {$x < $last_ent} {set x [expr $x + 2]} { + if [gdb_test [lindex $args $x] [lindex $args [expr $x + 1]] "$testname ([lindex $args $x])"] { + gdb_suppress_tests; + } + } + gdb_stop_suppressing_tests; +} + +proc do_tests {} { + global prms_id + global bug_id + global subdir + global objdir + global srcdir + global binfile + global gdb_prompt + + set prms_id 0 + set bug_id 0 + + # Start with a fresh gdb. + + gdb_exit + gdb_start + gdb_reinitialize_dir $srcdir/$subdir + gdb_load $binfile + + deduce_language_of_main + # Check for fixes for PRs 8916 and 8630 + gdb_test "print s.a" ".* = 0" "print s.a for foo struct (known gcc 2.7.2 and earlier bug)" +} + +do_tests + +test_expr "set language c++" \ + "print 1 == 1" "print.*\\$\[0-9\]* = true" \ + "print 1 == 2" "print.*\\$\[0-9\]* = false" \ + "print as bool" + +# Test bool type printing, etc. +# Note: Language is already set to C++ above! +gdb_test "print v_bool" "\\$\[0-9\]* = false" "print a bool var" + +# set a bool variable +test_expr "set variable v_bool = true" \ + "print v_bool" "\\$\[0-9\]* = true" \ + "set a bool var" + +# next print an array of bool +gdb_test "print v_bool_array" "\\$\[0-9\]* = \\{false, false\\}" "print a bool array" + +# set elements of a bool array +test_expr "set variable v_bool_array\[1\] = true" \ + "print v_bool_array" "\\$\[0-9\]* = \\{false, true\\}" \ + "set a bool array elem" + +# bool constants +gdb_test "print true" "\\$\[0-9\]* = true" "print true" +gdb_test "print false" "\\$\[0-9\]* = false" "print false" + +# arithmetic conversions +gdb_test "print 1 + true" "\\$\[0-9\]* = 2" "1 + true" +gdb_test "print 3 + false" "\\$\[0-9\]* = 3" "3 + false" +gdb_test "print 1 < 2 < 3" "\\$\[0-9\]* = true" "1 < 2 < 3" +gdb_test "print 2 < 1 > 4" "\\$\[0-9\]* = false" "2 < 1 > 4" +gdb_test "print (bool)43" "\\$\[0-9\]* = true" "(bool)43" +gdb_test "print (bool)0" "\\$\[0-9\]* = false" "(bool)0" +gdb_test "print (bool)17.93" "\\$\[0-9\]* = true" "(bool)17.93" +gdb_test "print (bool)0.0" "\\$\[0-9\]* = false" "(bool)0.0" +gdb_test "print (int)true" "\\$\[0-9\]* = 1" "(int)true" +gdb_test "print (int)false" "\\$\[0-9\]* = 0" "(int)false" diff --git a/gdb/testsuite/gdb.cp/namespace.cc b/gdb/testsuite/gdb.cp/namespace.cc new file mode 100644 index 0000000..7b9a173 --- /dev/null +++ b/gdb/testsuite/gdb.cp/namespace.cc @@ -0,0 +1,163 @@ +namespace AAA { + char c; + int i; + int A_xyzq (int); + char xyzq (char); + class inA { + public: + int xx; + int fum (int); + }; +}; + +int AAA::inA::fum (int i) +{ + return 10 + i; +} + +namespace BBB { + char c; + int i; + int B_xyzq (int); + char xyzq (char); + + namespace CCC { + char xyzq (char); + }; + + class Class { + public: + char xyzq (char); + int dummy; + }; +}; + +int AAA::A_xyzq (int x) +{ + return 2 * x; +} + +char AAA::xyzq (char c) +{ + return 'a'; +} + + +int BBB::B_xyzq (int x) +{ + return 3 * x; +} + +char BBB::xyzq (char c) +{ + return 'b'; +} + +char BBB::CCC::xyzq (char c) +{ + return 'z'; +} + +char BBB::Class::xyzq (char c) +{ + return 'o'; +} + +void marker1(void) +{ + return; +} + +namespace +{ + int X = 9; + + namespace G + { + int Xg = 10; + } +} + +namespace C +{ + int c = 1; + int shadow = 12; + + namespace + { + int cX = 6; + + namespace F + { + int cXf = 7; + } + } + + namespace C + { + int cc = 2; + } + + namespace D + { + int cd = 3; + int shadow = 13; + + namespace E + { + int cde = 5; + } + + void marker2 (void) + { + // NOTE: carlton/2003-04-23: I'm listing the expressions that I + // plan to have GDB try to print out, just to make sure that the + // compiler and I agree which ones should be legal! It's easy + // to screw up when testing the boundaries of namespace stuff. + c; + //cc; + C::cc; + cd; + E::cde; + shadow; + cX; + F::cXf; + X; + G::Xg; + //cXOtherFile; + //XOtherFile; + + return; + } + + } +} + +int main () +{ + using AAA::inA; + char c1; + + using namespace BBB; + + c1 = xyzq ('x'); + c1 = AAA::xyzq ('x'); + c1 = BBB::CCC::xyzq ('m'); + + inA ina; + + ina.xx = 33; + + int y; + + y = AAA::A_xyzq (33); + y += B_xyzq (44); + + BBB::Class cl; + + c1 = cl.xyzq('e'); + + marker1(); + + C::D::marker2 (); +} diff --git a/gdb/testsuite/gdb.cp/namespace.exp b/gdb/testsuite/gdb.cp/namespace.exp new file mode 100644 index 0000000..f4efaf6 --- /dev/null +++ b/gdb/testsuite/gdb.cp/namespace.exp @@ -0,0 +1,219 @@ +# Copyright 1997, 1998, 2000, 2001, 2002, 2003 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# tests for namespaces +# Written by Satish Pai <pai@apollo.hp.com> 1997-07-23 + +# This file is part of the gdb testsuite + +# Note: These tests are geared to the HP aCC compiler, +# which has an idiosyncratic way of emitting debug info +# for namespaces. +# Note: As of 2000-06-03, these pass under g++ - djb + + +if $tracelevel then { + strace $tracelevel + } + +set prms_id 0 +set bug_id 0 + +if { [skip_cplus_tests] } { continue } + +set testfile "namespace" +set srcfile ${testfile}.cc +set objfile ${objdir}/${subdir}/${testfile}.o +set srcfile1 ${testfile}1.cc +set objfile1 ${objdir}/${subdir}/${testfile}1.o +set binfile ${objdir}/${subdir}/${testfile} + +if [get_compiler_info ${binfile}] { + return -1; +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objfile}" object {debug c++}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${objfile1}" object {debug c++}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if { [gdb_compile "${objfile} ${objfile1}" "${binfile}" executable {debug c++}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + + +# +# set it up at a breakpoint so we can play with the variable values +# +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + +if ![runto 'marker1'] then { + perror "couldn't run to marker1" + continue +} + +gdb_test "up" ".*main.*" "up from marker1" + +# Access a data item inside a namespace using colons and +# single quotes :-( + +send_gdb "print 'AAA::c'\n" +gdb_expect { + -re "\\$\[0-9\]* = 0 '\\\\(0|000)'\r\n$gdb_prompt $" { pass "print 'AAA::c'" } + -re ".*$gdb_prompt $" { fail "print 'AAA::c'" } + timeout { fail "(timeout) print 'AAA::c'" } +} + +# An object declared using "using". + +send_gdb "print ina\n" +gdb_expect { + -re "\\$\[0-9\]+ = {xx = 33}.*$gdb_prompt $" { + pass "print ina" + } + -re ".*$gdb_prompt $" { fail "print ina" } + timeout { fail "(timeout) print ina" } +} + +send_gdb "ptype ina\n" +gdb_expect { + -re "type = class (AAA::|)inA \{\r\n\[ \]*public:\r\n\[ \]*int xx;\r\n\[ \]*\r\n\[ \]*.*int fum\\(int\\);\r\n\}\r\n$gdb_prompt $" { + pass "ptype ina" + } + -re ".*$gdb_prompt $" { fail "ptype ina" } + timeout { fail "(timeout) ptype ina" } +} + +# Check all functions are known to GDB + +setup_xfail hppa*-*-*11* CLLbs14869 +send_gdb "info func xyzq\n" +gdb_expect { + -re "All functions.*File.*namespace.cc:\r\nint AAA::A_xyzq\\(int\\);\r\nint BBB::B_xyzq\\(int\\);\r\nchar AAA::xyzq\\(char\\);\r\nchar BBB::xyzq\\(char\\);\r\nchar BBB::CCC::xyzq\\(char\\);\r\nchar BBB::Class::xyzq\\(char\\);\r\n$gdb_prompt $" { + pass "info func xyzq" + } + -re "All functions.*File.*namespace.cc:\r\nint AAA::A_xyzq\\(int\\);\r\nchar AAA::xyzq\\(char\\);\r\nint BBB::B_xyzq\\(int\\);\r\nchar BBB::CCC::xyzq\\(char\\);\r\nchar BBB::Class::xyzq\\(char\\);\r\nchar BBB::xyzq\\(char\\);\r\n$gdb_prompt $" { + pass "info func xyzq" + } + -re ".*$gdb_prompt $" { fail "info func xyzq" } + timeout { fail "(timeout) info func xyzq" } +} + +# Call a function in a namespace + +send_gdb "print 'AAA::xyzq'('x')\n" +gdb_expect { + -re "\\$\[0-9\]* = 97 'a'\r\n$gdb_prompt $" { + pass "print 'AAA::xyzq'('x')" + } + -re ".*$gdb_prompt $" { fail "print 'AAA::xyzq'('x')" } + timeout { fail "(timeout) print 'AAA::xyzq'('x')" } +} + +# Break on a function in a namespace + +send_gdb "break AAA::xyzq\n" +gdb_expect { + -re "Breakpoint.*at $hex: file.*namespace.cc, line 42\\.\r\n$gdb_prompt $" { + pass "break AAA::xyzq" + } + -re ".*$gdb_prompt $" { fail "break AAA::xyzq" } + timeout { fail "(timeout) break AAA::xyzq" } +} + +# Call a function in a nested namespace + +send_gdb "print 'BBB::CCC::xyzq'('x')\n" +gdb_expect { + -re "\\$\[0-9\]* = 122 'z'\r\n$gdb_prompt $" { + pass "print 'BBB::CCC::xyzq'('x')" + } + -re ".*$gdb_prompt $" { fail "print 'BBB::CCC::xyzq'('x')" } + timeout { fail "(timeout) print 'BBB::CCC::xyzq'('x')" } +} + +# Break on a function in a nested namespace + +send_gdb "break BBB::CCC::xyzq\n" +gdb_expect { + -re "Breakpoint.*at $hex: file.*namespace.cc, line 58\\.\r\n$gdb_prompt $" { + pass "break BBB::CCC::xyzq" + } + -re ".*$gdb_prompt $" { fail "break BBB::CCC::xyzq" } + timeout { fail "(timeout) break BBB::CCC::xyzq" } +} + +# Print address of a function in a class in a namespace + +send_gdb "print 'BBB::Class::xyzq'\n" +gdb_expect { + -re "\\$\[0-9\]* = \{char \\((BBB::|)Class \\*( const|), (char|int)\\)\} $hex <BBB::Class::xyzq\\(char\\)>\r\n$gdb_prompt $" { + pass "print 'BBB::Class::xyzq'" + } + -re ".*$gdb_prompt $" { fail "print 'BBB::Class::xyzq'" } + timeout { fail "(timeout) print 'BBB::Class::xyzq'" } +} + +# Break on a function in a class in a namespace + +send_gdb "break BBB::Class::xyzq\n" +gdb_expect { + -re "Breakpoint.*at $hex: file.*namespace.cc, line 63\\.\r\n$gdb_prompt $" { + pass "break BBB::Class::xyzq" + } + -re ".*$gdb_prompt $" { fail "break BBB::Class::xyzq" } + timeout { fail "(timeout) break BBB::Class::xyzq" } +} + +# Test to see if the appropriate namespaces are in scope when trying +# to print out stuff from within a function defined within a +# namespace. + +if ![runto "C::D::marker2"] then { + perror "couldn't run to marker2" + continue +} + +gdb_test "print c" "\\$\[0-9\].* = 1" +gdb_test "print cc" "No symbol \"cc\" in current context." +gdb_test "print 'C::cc'" "\\$\[0-9\].* = 2" +gdb_test "print cd" "\\$\[0-9\].* = 3" +gdb_test "print 'E::cde'" "\\$\[0-9\].* = 5" +gdb_test "print shadow" "\\$\[0-9\].* = 13" +gdb_test "print cOtherFile" "\\$\[0-9\].* = 316" + +# Some anonymous namespace tests. + +gdb_test "print cX" "\\$\[0-9\].* = 6" +gdb_test "print 'F::cXf'" "\\$\[0-9\].* = 7" +gdb_test "print X" "\\$\[0-9\].* = 9" +gdb_test "print 'G::Xg'" "\\$\[0-9\].* = 10" +gdb_test "print cXOtherFile" "No symbol \"cXOtherFile\" in current context." +gdb_test "print XOtherFile" "No symbol \"XOtherFile\" in current context." diff --git a/gdb/testsuite/gdb.cp/namespace1.cc b/gdb/testsuite/gdb.cp/namespace1.cc new file mode 100644 index 0000000..4a5900a --- /dev/null +++ b/gdb/testsuite/gdb.cp/namespace1.cc @@ -0,0 +1,31 @@ +/* Copyright 2003 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 2 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + Please email any bugs, comments, and/or additions to this file to: + bug-gdb@prep.ai.mit.edu */ + +namespace C +{ + namespace { + int cXOtherFile = 29; + }; + + int cOtherFile = 316; +} + +namespace { + int XOtherFile = 317; +} diff --git a/gdb/testsuite/gdb.cp/overload.cc b/gdb/testsuite/gdb.cp/overload.cc new file mode 100644 index 0000000..56afc96 --- /dev/null +++ b/gdb/testsuite/gdb.cp/overload.cc @@ -0,0 +1,168 @@ +#include <stddef.h> + +class foo { +public: + foo (int); + foo (int, const char *); + foo (foo&); + ~foo (); + void foofunc (int); + void foofunc (int, signed char *); + int ifoo; + const char *ccpfoo; + +int overload1arg (void); +int overload1arg (char); +int overload1arg (signed char); +int overload1arg (unsigned char); +int overload1arg (short); +int overload1arg (unsigned short); +int overload1arg (int); +int overload1arg (unsigned int); +int overload1arg (long); +int overload1arg (unsigned long); +int overload1arg (float); +int overload1arg (double); + +int overloadfnarg (void); +int overloadfnarg (int); +int overloadfnarg (int, int (*) (int)); + +int overloadargs (int a1); +int overloadargs (int a1, int a2); +int overloadargs (int a1, int a2, int a3); +int overloadargs (int a1, int a2, int a3, int a4); +int overloadargs (int a1, int a2, int a3, int a4, int a5); +int overloadargs (int a1, int a2, int a3, int a4, int a5, int a6); +int overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7); +int overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8); +int overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9); +int overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7, + int a8, int a9, int a10); +int overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7, + int a8, int a9, int a10, int a11); + + +}; + +int intToChar (char c) +{ + return 297; +} + +void marker1() +{} + +int main () +{ + char arg2 = 2; + signed char arg3 =3; + unsigned char arg4 =4; + short arg5 =5; + unsigned short arg6 =6; + int arg7 =7; + unsigned int arg8 =8; + long arg9 =9; + unsigned long arg10 =10; + float arg11 =100.0; + double arg12 = 200.0; + + char *str = (char *) "A"; + foo foo_instance1(111); + foo foo_instance2(222, str); + foo foo_instance3(foo_instance2); + + #ifdef usestubs + set_debug_traps(); + breakpoint(); + #endif + + // Verify that intToChar should work: + intToChar(1); + + marker1(); // marker1-returns-here + return 0; // marker1-returns-here +} + +foo::foo (int i) { ifoo = i; ccpfoo = NULL; } +foo::foo (int i, const char *ccp) { ifoo = i; ccpfoo = ccp; } +foo::foo (foo& afoo) { ifoo = afoo.ifoo; ccpfoo = afoo.ccpfoo;} +foo::~foo () {} + + +/* Some functions to test overloading by varying one argument type. */ + +int foo::overload1arg (void) { return 1; } +int foo::overload1arg (char arg) { arg = 0; return 2;} +int foo::overload1arg (signed char arg) { arg = 0; return 3;} +int foo::overload1arg (unsigned char arg) { arg = 0; return 4;} +int foo::overload1arg (short arg) { arg = 0; return 5;} +int foo::overload1arg (unsigned short arg) { arg = 0; return 6;} +int foo::overload1arg (int arg) { arg = 0; return 7;} +int foo::overload1arg (unsigned int arg) { arg = 0; return 8;} +int foo::overload1arg (long arg) { arg = 0; return 9;} +int foo::overload1arg (unsigned long arg) { arg = 0; return 10;} +int foo::overload1arg (float arg) { arg = 0; return 11;} +int foo::overload1arg (double arg) { arg = 0; return 12;} + +/* Test to see that we can explicitly request overloaded functions + with function pointers in the prototype. */ + +int foo::overloadfnarg (void) { return ifoo * 20; } +int foo::overloadfnarg (int arg) { arg = 0; return 13;} +int foo::overloadfnarg (int arg, int (*foo) (int)) { return foo(arg); } + +/* Some functions to test overloading by varying argument count. */ + +int foo::overloadargs (int a1) +{ a1 = 0; +return 1;} + +int foo::overloadargs (int a1, int a2) +{ a1 = a2 = 0; +return 2;} + +int foo::overloadargs (int a1, int a2, int a3) +{ a1 = a2 = a3 = 0; +return 3;} + +int foo::overloadargs (int a1, int a2, int a3, int a4) +{ a1 = a2 = a3 = a4 = 0; +return 4;} + +int foo::overloadargs (int a1, int a2, int a3, int a4, int a5) +{ a1 = a2 = a3 = a4 = a5 = 0; +return 5;} + +int foo::overloadargs (int a1, int a2, int a3, int a4, int a5, int a6) +{ a1 = a2 = a3 = a4 = a5 = a6 = 0; +return 6;} + +int foo::overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7) +{ a1 = a2 = a3 = a4 = a5 = a6 = a7 = 0; +return 7;} + +int foo::overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7, + int a8) +{ a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = 0; +return 8;} + +int foo::overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7, + int a8, int a9) +{ + a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = a9 = 0; + return 9; +} + +int foo::overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7, + int a8, int a9, int a10) + { a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = a9 = + a10 = 0; return 10;} + +int foo::overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7, + int a8, int a9, int a10, int a11) + { a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = a9 = + a10 = a11 = 0; return 11;} + + + diff --git a/gdb/testsuite/gdb.cp/overload.exp b/gdb/testsuite/gdb.cp/overload.exp new file mode 100644 index 0000000..3e14678 --- /dev/null +++ b/gdb/testsuite/gdb.cp/overload.exp @@ -0,0 +1,400 @@ +# Copyright 1998, 1999, 2000, 2001, 2002, 2003 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# written by Elena Zannoni (ezannoni@cygnus.com) + +# This file is part of the gdb testsuite +# +# tests for overloaded member functions. Command Line calls +# + + +if $tracelevel then { + strace $tracelevel + } + +# +# test running programs +# +set prms_id 0 +set bug_id 0 + +if { [skip_cplus_tests] } { continue } + +set testfile "overload" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if [get_compiler_info ${binfile} "c++"] { + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +# set it up at a breakpoint so we can play with the variable values +# +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + +if ![runto 'marker1'] then { + perror "couldn't run to marker1" + continue +} + +gdb_test "up" ".*main.*" "up from marker1" + +send_gdb "print foo_instance1\n" +gdb_expect { + -re ".\[0-9\]* = \{ifoo = 111, ccpfoo = 0x0\}\r\n$gdb_prompt $" { + pass "print foo_instance1" + } + -re ".*$gdb_prompt $" { fail "print foo_instance1" } + timeout { fail "(timeout) print foo_instance1" } + } + + +setup_xfail "hppa*-*-*" CLLbs16901 +send_gdb "ptype foo_instance1\n" +gdb_expect { + -re "type = class foo \{.*public:.*int ifoo;.*const char \\*ccpfoo;.*foo\\(int\\);.*foo\\(int, (const char|char const) \\*\\);.*foo\\(foo &\\);.*~foo\\(void\\);.*void foofunc\\(int\\);.*void foofunc\\(int, signed char \\*\\);.*int overload1arg\\(void\\);.*int overload1arg\\(char\\);.*int overload1arg\\(signed char\\);.*int overload1arg\\(unsigned char\\);.*int overload1arg\\(short\\);.*int overload1arg\\(unsigned short\\);.*int overload1arg\\(int\\);.*int overload1arg\\(unsigned int\\);.*int overload1arg\\(long\\);.*int overload1arg\\(unsigned long\\);.*int overload1arg\\(float\\);.*int overload1arg\\(double\\);.*int overloadargs\\(int\\);.*int overloadargs\\(int, int\\);.*int overloadargs\\(int, int, int\\);.*int overloadargs\\(int, int, int, int\\);.*int overloadargs\\(int, int, int, int, int\\);.*int overloadargs\\(int, int, int, int, int, int\\);.*int overloadargs\\(int, int, int, int, int, int, int\\);.*int overloadargs\\(int, int, int, int, int, int, int, int\\);.*int overloadargs\\(int, int, int, int, int, int, int, int, int\\);.*int overloadargs\\(int, int, int, int, int, int, int, int, int, int\\);.*int overloadargs\\(int, int, int, int, int, int, int, int, int, int, int\\);\r\n\}\r\n$gdb_prompt $" { + pass "ptype foo_instance1 (HP aCC -- known quirk with ~foo parameter list)" + } + -re "type = class foo .*int overloadargs\\(int, int, int, int, int, int, int, int, int, int, int\\);\r\n\}\r\n$gdb_prompt $" { + pass "ptype foo_instance1 (shorter match)" + } + -re ".*$gdb_prompt $" { fail "ptype foo_instance1" } + timeout { fail "(timeout) ptype foo_instance1" } + } + +send_gdb "print foo_instance2\n" +gdb_expect { + -re ".\[0-9\]* = \{ifoo = 222, ccpfoo = $hex \"A\"\}\r\n$gdb_prompt $" { + pass "print foo_instance2" + } + -re ".*$gdb_prompt $" { fail "print foo_instance2" } + timeout { fail "(timeout) print foo_instance2" } + } + +send_gdb "print foo_instance3\n" +gdb_expect { + -re ".\[0-9\]* = \{ifoo = 222, ccpfoo = $hex \"A\"\}\r\n$gdb_prompt $" { + pass "print foo_instance3" + } + -re ".*$gdb_prompt $" { fail "print foo_instance3" } + timeout { fail "(timeout) print foo_instance3" } + } + + +send_gdb "print foo_instance1.overloadargs(1)\n" +gdb_expect { + -re ".\[0-9\]* = 1\r\n$gdb_prompt $" { + pass "print call overloaded func 1 arg" + } + -re ".*$gdb_prompt $" { fail "print call overloaded func 1 arg" } + timeout { fail "(timeout) print call overloaded func 1 arg" } + } + + +# If GDB fails to restore the selected frame properly after the +# inferior function call above (see GDB PR 1155 for an explanation of +# why this might happen), all the subsequent tests will fail. We +# should detect and report that failure, but let the marker call +# finish so that the rest of the tests can run undisturbed. +gdb_test_multiple "frame" "re-selected 'main' frame after inferior call" { + -re "#0 marker1.*$gdb_prompt $" { + setup_kfail "gdb/1155" s390-*-linux-gnu + fail "re-selected 'main' frame after inferior call" + gdb_test "finish" ".*main.*at .*overload.cc:.*// marker1-returns-here.*" \ + "finish call to marker1" + } + -re "#1 ($hex in )?main.*$gdb_prompt $" { + pass "re-selected 'main' frame after inferior call" + } +} + + +send_gdb "print foo_instance1.overloadargs(1, 2)\n" +gdb_expect { + -re ".\[0-9\]* = 2\r\n$gdb_prompt $" { + pass "print call overloaded func 2 args" + } + -re ".*$gdb_prompt $" { fail "print call overloaded func 2 args" } + timeout { fail "(timeout) print call overloaded func 2 args" } + } + + +send_gdb "print foo_instance1.overloadargs(1, 2, 3)\n" +gdb_expect { + -re ".\[0-9\]* = 3\r\n$gdb_prompt $" { + pass "print call overloaded func 3 args" + } + -re ".*$gdb_prompt $" { fail "print call overloaded func 3 args" } + timeout { fail "(timeout) print call overloaded func 3 args" } + } + + +send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4)\n" +gdb_expect { + -re ".\[0-9\]* = 4\r\n$gdb_prompt $" { + pass "print call overloaded func 4 args" + } + -re ".*$gdb_prompt $" { fail "print call overloaded func 4 args" } + timeout { fail "(timeout) print call overloaded func 4 args" } + } + + +send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4, 5)\n" +gdb_expect { + -re ".\[0-9\]* = 5\r\n$gdb_prompt $" { + pass "print call overloaded func 5 args" + } + -re ".*$gdb_prompt $" { fail "print call overloaded func 5 args" } + timeout { fail "(timeout) print call overloaded func 5 args" } + } + + +send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6)\n" +gdb_expect { + -re ".\[0-9\]* = 6\r\n$gdb_prompt $" { + pass "print call overloaded func 6 args" + } + -re ".*$gdb_prompt $" { fail "print call overloaded func 6 args" } + timeout { fail "(timeout) print call overloaded func 6 args" } + } + + +send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7)\n" +gdb_expect { + -re ".\[0-9\]* = 7\r\n$gdb_prompt $" { + pass "print call overloaded func 7 args" + } + -re ".*$gdb_prompt $" { fail "print call overloaded func 7 args" } + timeout { fail "(timeout) print call overloaded func 7 args" } + } + + +send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8)\n" +gdb_expect { + -re ".\[0-9\]* = 8\r\n$gdb_prompt $" { + pass "print call overloaded func 8 args" + } + -re ".*$gdb_prompt $" { fail "print call overloaded func 8 args" } + timeout { fail "(timeout) print call overloaded func 8 args" } + } + + +send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8, 9)\n" +gdb_expect { + -re ".\[0-9\]* = 9\r\n$gdb_prompt $" { + pass "print call overloaded func 9 args" + } + -re ".*$gdb_prompt $" { fail "print call overloaded func 9 args" } + timeout { fail "(timeout) print call overloaded func 9 args" } + } + + +send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)\n" +gdb_expect { + -re ".\[0-9\]* = 10\r\n$gdb_prompt $" { + pass "print call overloaded func 10 args" + } + -re ".*$gdb_prompt $" { fail "print call overloaded func 10 args" } + timeout { fail "(timeout) print call overloaded func 10 args" } + } + + +send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)\n" +gdb_expect { + -re ".\[0-9\]* = 11\r\n$gdb_prompt $" { + pass "print call overloaded func 11 args" + } + -re ".*$gdb_prompt $" { fail "print call overloaded func 11 args" } + timeout { fail "(timeout) print call overloaded func 11 args" } + } + + +send_gdb "print foo_instance1.overload1arg()\n" +gdb_expect { + -re ".\[0-9\]* = 1\r\n$gdb_prompt $" { + pass "print call overloaded func void arg" + } + -re ".*$gdb_prompt $" { fail "print call overloaded func void arg" } + timeout { fail "(timeout) print call overloaded func void arg" } + } + + +send_gdb "print foo_instance1.overload1arg((char)arg2)\n" +gdb_expect { + -re ".\[0-9\]* = 2\r\n$gdb_prompt $" { + pass "print call overloaded func char arg" + } + -re ".*$gdb_prompt $" { fail "print call overloaded func char arg" } + timeout { fail "(timeout) print call overloaded func char arg" } + } + + +send_gdb "print foo_instance1.overload1arg((signed char)arg3)\n" +gdb_expect { + -re ".\[0-9\]* = 3\r\n$gdb_prompt $" { + pass "print call overloaded func signed char arg" + } + -re ".*$gdb_prompt $" { fail "print call overloaded func signed char arg" } + timeout { fail "(timeout) print call overloaded func signed char arg" } + } + + +send_gdb "print foo_instance1.overload1arg((unsigned char)arg4)\n" +gdb_expect { + -re ".\[0-9\]* = 4\r\n$gdb_prompt $" { + pass "print call overloaded func unsigned char arg" + } + -re ".*$gdb_prompt $" { fail "print call overloaded func unsigned char arg" } + timeout { fail "(timeout) print call overloaded func unsigned char arg" } + } + + +send_gdb "print foo_instance1.overload1arg((short)arg5)\n" +gdb_expect { + -re ".\[0-9\]* = 5\r\n$gdb_prompt $" { + pass "print call overloaded func short arg" + } + -re ".*$gdb_prompt $" { fail "print call overloaded func short arg" } + timeout { fail "(timeout) print call overloaded func short arg" } + } + + +send_gdb "print foo_instance1.overload1arg((unsigned short)arg6)\n" +gdb_expect { + -re ".\[0-9\]* = 6\r\n$gdb_prompt $" { + pass "print call overloaded func unsigned short arg" + } + -re ".*$gdb_prompt $" { fail "print call overloaded func unsigned short arg" } + timeout { fail "(timeout) print call overloaded func unsigned short arg" } + } + + +send_gdb "print foo_instance1.overload1arg((int)arg7)\n" +gdb_expect { + -re ".\[0-9\]* = 7\r\n$gdb_prompt $" { + pass "print call overloaded func int arg" + } + -re ".*$gdb_prompt $" { fail "print call overloaded func int arg" } + timeout { fail "(timeout) print call overloaded func int arg" } + } + + +send_gdb "print foo_instance1.overload1arg((unsigned int)arg8)\n" +gdb_expect { + -re ".\[0-9\]* = 8\r\n$gdb_prompt $" { + pass "print call overloaded func unsigned int arg" + } + -re ".*$gdb_prompt $" { fail "print call overloaded func unsigned int arg" } + timeout { fail "(timeout) print call overloaded func unsigned int arg" } + } + + +send_gdb "print foo_instance1.overload1arg((long)arg9)\n" +gdb_expect { + -re ".\[0-9\]* = 9\r\n$gdb_prompt $" { + pass "print call overloaded func long arg" + } + -re ".*$gdb_prompt $" { fail "print call overloaded func long arg" } + timeout { fail "(timeout) print call overloaded func long arg" } + } + + +send_gdb "print foo_instance1.overload1arg((unsigned long)arg10)\n" +gdb_expect { + -re ".\[0-9\]* = 10\r\n$gdb_prompt $" { + pass "print call overloaded func unsigned long arg" + } + -re ".*$gdb_prompt $" { fail "print call overloaded func unsigned long arg" } + timeout { fail "(timeout) print call overloaded func unsigned long arg" } + } + + +send_gdb "print foo_instance1.overload1arg((float)arg11)\n" +gdb_expect { + -re ".\[0-9\]* = 11\r\n$gdb_prompt $" { + pass "print call overloaded func float arg" + } + -re ".*$gdb_prompt $" { fail "print call overloaded func float arg" } + timeout { fail "(timeout) print call overloaded func float arg" } + } + + +send_gdb "print foo_instance1.overload1arg((double)arg12)\n" +gdb_expect { + -re ".\[0-9\]* = 12\r\n$gdb_prompt $" { + pass "print call overloaded func double arg" + } + -re ".*$gdb_prompt $" { fail "print call overloaded func double arg" } + timeout { fail "(timeout) print call overloaded func double arg" } + } + +# Now some tests to see if we can list overloaded functions properly: + +gdb_test "set listsize 1" "" "" +# send_gdb "set listsize 1\n" +# gdb_expect -re ".*$gdb_prompt $" + +# +# Decide whether to use "()" or "(void)" +# + +send_gdb "info func overloadfnarg\n" +gdb_expect { + -re ".*overloadfnarg\\(void\\).*$gdb_prompt $" { + gdb_test "list foo::overloadfnarg(void)"\ + ".*int foo::overloadfnarg.*\\(void\\).*" \ + "list overloaded function with no args" + } + -re ".*overloadfnarg\\(\\).*$gdb_prompt $" { + gdb_test "list foo::overloadfnarg()"\ + ".*int foo::overloadfnarg.*\\(void\\).*" \ + "list overloaded function with no args" + } + -re ".*$gdb_prompt $" { + fail "list overloaded function with no args (no matching symbol)" + } +} + +gdb_test "list foo::overloadfnarg(int)"\ + "int foo::overloadfnarg.*\\(int arg\\).*" \ + "list overloaded function with int arg" + +gdb_test "list foo::overloadfnarg(int, int (*)(int))" \ + "int foo::overloadfnarg.*\\(int arg, int \\(\\*foo\\) \\(int\\)\\).*" \ + "list overloaded function with function ptr args" + +# This one crashes GDB. Don't know why yet. +gdb_test "list \"foo::overloadfnarg(int, int (*)(int))\"" \ + "int foo::overloadfnarg.*\\(int arg, int \\(\\*foo\\) \\(int\\)\\).*" \ + "list overloaded function with function ptr args - quotes around argument" + +gdb_test "print intToChar(1)" ".\[0-9\]* = 297" diff --git a/gdb/testsuite/gdb.cp/ovldbreak.cc b/gdb/testsuite/gdb.cp/ovldbreak.cc new file mode 100644 index 0000000..9a5b5cb --- /dev/null +++ b/gdb/testsuite/gdb.cp/ovldbreak.cc @@ -0,0 +1,177 @@ +#include <stddef.h> + +class foo { +public: + foo (int); + foo (int, const char *); + foo (foo&); + ~foo (); + void foofunc (int); + void foofunc (int, signed char *); + int ifoo; + const char *ccpfoo; + +int overload1arg (void); +int overload1arg (char); +int overload1arg (signed char); +int overload1arg (unsigned char); +int overload1arg (short); +int overload1arg (unsigned short); +int overload1arg (int); +int overload1arg (unsigned int); +int overload1arg (long); +int overload1arg (unsigned long); +int overload1arg (float); +int overload1arg (double); + +int overloadargs (int a1); +int overloadargs (int a1, int a2); +int overloadargs (int a1, int a2, int a3); +int overloadargs (int a1, int a2, int a3, int a4); +int overloadargs (int a1, int a2, int a3, int a4, int a5); +int overloadargs (int a1, int a2, int a3, int a4, int a5, int a6); +int overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7); +int overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8); +int overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9); +int overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7, + int a8, int a9, int a10); +int overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7, + int a8, int a9, int a10, int a11); + + +}; + +void marker1() +{} + +int main () +{ + char arg2 = 2; + signed char arg3 =3; + unsigned char arg4 =4; + short arg5 =5; + unsigned short arg6 =6; + int arg7 =7; + unsigned int arg8 =8; + long arg9 =9; + unsigned long arg10 =10; + float arg11 =100.0; + double arg12 = 200.0; + + char ch='A'; + foo foo_instance1(111); + foo foo_instance2(222, &ch); + foo foo_instance3(foo_instance2); + + foo_instance1.overload1arg(); + foo_instance1.overload1arg(arg2); + foo_instance1.overload1arg(arg3); + foo_instance1.overload1arg(arg4); + foo_instance1.overload1arg(arg5); + foo_instance1.overload1arg(arg6); + foo_instance1.overload1arg(arg7); + foo_instance1.overload1arg(arg8); + foo_instance1.overload1arg(arg9); + foo_instance1.overload1arg(arg10); + foo_instance1.overload1arg(arg11); + foo_instance1.overload1arg(arg12); + + foo_instance1.overloadargs(1); + foo_instance1.overloadargs(1, 2); + foo_instance1.overloadargs(1, 2, 3); + foo_instance1.overloadargs(1, 2, 3, 4); + foo_instance1.overloadargs(1, 2, 3, 4, 5); + foo_instance1.overloadargs(1, 2, 3, 4, 5, 6); + foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7); + foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8); + foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8, 9); + foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); + + + #ifdef usestubs + set_debug_traps(); + breakpoint(); + #endif + + + marker1(); + return 0; +} + +foo::foo (int i) { ifoo = i;} +foo::foo (int i, const char *ccp) { ifoo = i; ccpfoo = ccp; } +foo::foo (foo& afoo) { ifoo = afoo.ifoo; ccpfoo = afoo.ccpfoo;} +foo::~foo () {} + + +/* Some functions to test overloading by varying one argument type. */ + +int foo::overload1arg (void) { return 1; } +int foo::overload1arg (char arg) { arg = 0; return 2;} +int foo::overload1arg (signed char arg) { arg = 0; return 3;} +int foo::overload1arg (unsigned char arg) { arg = 0; return 4;} +int foo::overload1arg (short arg) { arg = 0; return 5;} +int foo::overload1arg (unsigned short arg) { arg = 0; return 6;} +int foo::overload1arg (int arg) { arg = 0; return 7;} +int foo::overload1arg (unsigned int arg) { arg = 0; return 8;} +int foo::overload1arg (long arg) { arg = 0; return 9;} +int foo::overload1arg (unsigned long arg) { arg = 0; return 10;} +int foo::overload1arg (float arg) { arg = 0; return 11;} +int foo::overload1arg (double arg) { arg = 0; return 12;} + + +/* Some functions to test overloading by varying argument count. */ + +int foo::overloadargs (int a1) +{ a1 = 0; +return 1;} + +int foo::overloadargs (int a1, int a2) +{ a1 = a2 = 0; +return 2;} + +int foo::overloadargs (int a1, int a2, int a3) +{ a1 = a2 = a3 = 0; +return 3;} + +int foo::overloadargs (int a1, int a2, int a3, int a4) +{ a1 = a2 = a3 = a4 = 0; +return 4;} + +int foo::overloadargs (int a1, int a2, int a3, int a4, int a5) +{ a1 = a2 = a3 = a4 = a5 = 0; +return 5;} + +int foo::overloadargs (int a1, int a2, int a3, int a4, int a5, int a6) +{ a1 = a2 = a3 = a4 = a5 = a6 = 0; +return 6;} + +int foo::overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7) +{ a1 = a2 = a3 = a4 = a5 = a6 = a7 = 0; +return 7;} + +int foo::overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7, + int a8) +{ a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = 0; +return 8;} + +int foo::overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7, + int a8, int a9) +{ + a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = a9 = 0; + return 9; +} + +int foo::overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7, + int a8, int a9, int a10) + { a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = a9 = + a10 = 0; return 10;} + +int foo::overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7, + int a8, int a9, int a10, int a11) + { a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = a9 = + a10 = a11 = 0; return 11;} + + + diff --git a/gdb/testsuite/gdb.cp/ovldbreak.exp b/gdb/testsuite/gdb.cp/ovldbreak.exp new file mode 100644 index 0000000..043243d --- /dev/null +++ b/gdb/testsuite/gdb.cp/ovldbreak.exp @@ -0,0 +1,360 @@ +# Copyright (C) 1998, 1999, 2001 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# written by Elena Zannoni (ezannoni@cygnus.com) +# modified by Michael Chastain (chastain@redhat.com) + +# This file is part of the gdb testsuite +# +# tests for overloaded member functions. Set breakpoints on +# overloaded member functions +# + + +if $tracelevel then { + strace $tracelevel + } + +# +# test running programs +# +set prms_id 0 +set bug_id 0 + +if { [skip_cplus_tests] } { continue } + +set testfile "ovldbreak" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +# set it up at a breakpoint so we can play with the variable values +# +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + + + +# When I ask gdb to set a breakpoint on an overloaded function, +# gdb gives me a choice menu. I might get stuck in that choice menu +# (for example, if C++ name mangling is not working properly). +# +# This procedure issues a command that works at either the menu +# prompt or the command prompt to get back to the command prompt. +# +# Note that an empty line won't do it (it means 'repeat the previous command' +# at top level). A line with a single space in it works nicely. + +proc take_gdb_out_of_choice_menu {} { + global gdb_prompt + send_gdb " \n" + gdb_expect { + -re ".*$gdb_prompt $" { + } + timeout { + perror "could not resynchronize to command prompt (timeout)" + continue + } + } +} + + + +# This procedure sets an overloaded breakpoint. +# When I ask for such a breakpoint, gdb gives me a menu of 'cancel' 'all' +# and a bunch of choices. I then choose from that menu by number. + +proc set_bp_overloaded {name expectedmenu mychoice bpnumber linenumber} { + global gdb_prompt hex srcfile + + # Get into the overload menu. + send_gdb "break $name\n" + gdb_expect { + -re "$expectedmenu" { + pass "bp menu for $name choice $mychoice" + + # Choose my choice. + send_gdb "$mychoice\n" + gdb_expect { + -re "Breakpoint $bpnumber at $hex: file.*$srcfile, line $linenumber.\r\n$gdb_prompt $" { + pass "set bp $bpnumber on $name $mychoice line $linenumber" + } + -re ".*$gdb_prompt $" { + fail "set bp $bpnumber on $name $mychoice line $linenumber (bad bp)" + } + timeout { + fail "set bp $bpnumber on $name $mychoice line $linenumber (timeout)" + take_gdb_out_of_choice_menu + } + } + } + -re ".*\r\n> " { + fail "bp menu for $name choice $mychoice (bad menu)" + take_gdb_out_of_choice_menu + } + -re ".*$gdb_prompt $" { + fail "bp menu for $name choice $mychoice (no menu)" + } + timeout { + fail "bp menu for $name choice $mychoice (timeout)" + take_gdb_out_of_choice_menu + } + } +} + +# This is the expected menu for overload1arg. +# Note the arg type variations on lines 6 and 13. +# This accommodates different versions of g++. + +set menu_overload1arg "\\\[0\\\] cancel\r\n\\\[1\\\] all\r\n\\\[2\\\] foo::overload1arg\\(double\\) at.*$srcfile:121\r\n\\\[3\\\] foo::overload1arg\\(float\\) at.*$srcfile:120\r\n\\\[4\\\] foo::overload1arg\\(unsigned long\\) at.*$srcfile:119\r\n\\\[5\\\] foo::overload1arg\\(long\\) at.*$srcfile:118\r\n\\\[6\\\] foo::overload1arg\\((unsigned int|unsigned)\\) at.*$srcfile:117\r\n\\\[7\\\] foo::overload1arg\\(int\\) at.*$srcfile:116\r\n\\\[8\\\] foo::overload1arg\\(unsigned short\\) at.*$srcfile:115\r\n\\\[9\\\] foo::overload1arg\\(short\\) at.*$srcfile:114\r\n\\\[10\\\] foo::overload1arg\\(unsigned char\\) at.*$srcfile:113\r\n\\\[11\\\] foo::overload1arg\\(signed char\\) at.*$srcfile:112\r\n\\\[12\\\] foo::overload1arg\\(char\\) at.*$srcfile:111\r\n\\\[13\\\] foo::overload1arg\\((void|)\\) at.*$srcfile:110\r\n> $" + + + +# Set breakpoints on foo::overload1arg, one by one. + +set_bp_overloaded "foo::overload1arg" "$menu_overload1arg" 12 2 111 +set_bp_overloaded "foo::overload1arg" "$menu_overload1arg" 11 3 112 +set_bp_overloaded "foo::overload1arg" "$menu_overload1arg" 10 4 113 +set_bp_overloaded "foo::overload1arg" "$menu_overload1arg" 9 5 114 +set_bp_overloaded "foo::overload1arg" "$menu_overload1arg" 8 6 115 +set_bp_overloaded "foo::overload1arg" "$menu_overload1arg" 7 7 116 +set_bp_overloaded "foo::overload1arg" "$menu_overload1arg" 6 8 117 +set_bp_overloaded "foo::overload1arg" "$menu_overload1arg" 5 9 118 +set_bp_overloaded "foo::overload1arg" "$menu_overload1arg" 4 10 119 +set_bp_overloaded "foo::overload1arg" "$menu_overload1arg" 3 11 120 +set_bp_overloaded "foo::overload1arg" "$menu_overload1arg" 2 12 121 +set_bp_overloaded "foo::overload1arg" "$menu_overload1arg" 13 13 110 + + + +# Verify the breakpoints. + +gdb_test "info break" \ + "Num Type\[\t \]+Disp Enb Address\[\t \]+What.* +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in main at.*$srcfile:49\r +\[\t \]+breakpoint already hit 1 time\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(char\\) at.*$srcfile:111\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(signed char\\) at.*$srcfile:112\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned char\\) at.*$srcfile:113\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(short\\) at.*$srcfile:114\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned short\\) at.*$srcfile:115\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(int\\) at.*$srcfile:116\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned|unsigned int)\\) at.*$srcfile:117\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(long\\) at.*$srcfile:118\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned long\\) at.*$srcfile:119\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(float\\) at.*$srcfile:120\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(double\\) at.*$srcfile:121\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((void|)\\) at.*$srcfile:110" \ + "breakpoint info (after setting one-by-one)" + + + +# Test choice "cancel". +# This is copy-and-paste from set_bp_overloaded. + +send_gdb "break foo::overload1arg\n" +gdb_expect { + -re "$menu_overload1arg" { + pass "bp menu for foo::overload1arg choice cancel" + # Choose cancel. + send_gdb "0\n" + gdb_expect { + -re "canceled\r\n$gdb_prompt $" { + pass "set bp on overload1arg canceled" + } + -re "cancelled\r\n$gdb_prompt $" { + pass "set bp on overload1arg canceled" + } + -re ".*$gdb_prompt $" { + fail "set bp on overload1arg canceled (bad message)" + } + timeout { + fail "set bp on overload1arg canceled (timeout)" + take_gdb_out_of_choice_menu + } + } + } + -re ".*\r\n> " { + fail "bp menu for foo::overload1arg choice cancel (bad menu)" + take_gdb_out_of_choice_menu + } + -re ".*$gdb_prompt $" { + fail "bp menu for foo::overload1arg choice cancel (no menu)" + } + timeout { + fail "bp menu for foo::overload1arg choice cancel (timeout)" + take_gdb_out_of_choice_menu + } +} + +gdb_test "info break" \ + "Num Type\[\t \]+Disp Enb Address\[\t \]+What.* +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in main at.*$srcfile:49\r +\[\t \]+breakpoint already hit 1 time\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(char\\) at.*$srcfile:111\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(signed char\\) at.*$srcfile:112\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned char\\) at.*$srcfile:113\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(short\\) at.*$srcfile:114\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned short\\) at.*$srcfile:115\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(int\\) at.*$srcfile:116\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned|unsigned int)\\) at.*$srcfile:117\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(long\\) at.*$srcfile:118\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned long\\) at.*$srcfile:119\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(float\\) at.*$srcfile:120\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(double\\) at.*$srcfile:121\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((void|)\\) at.*$srcfile:110" \ + "breakpoint info (after cancel)" + + + +# Delete these breakpoints. + +send_gdb "delete breakpoints\n" +gdb_expect { + -re "Delete all breakpoints.* $" { + send_gdb "y\n" + gdb_expect { + -re ".*$gdb_prompt $" { + pass "delete all breakpoints" + } + timeout { + fail "delete all breakpoints (timeout)" + } + } + } + timeout { + fail "delete all breakpoints (timeout)" + } +} + +gdb_test "info breakpoints" "No breakpoints or watchpoints." "breakpoint info (after delete)" + + + +# Test choice "all". +# This is copy-and-paste from set_bp_overloaded. + +send_gdb "break foo::overload1arg\n" +gdb_expect { + -re "$menu_overload1arg" { + pass "bp menu for foo::overload1arg choice all" + # Choose all. + send_gdb "1\n" + gdb_expect { + -re "Breakpoint $decimal at $hex: file.*$srcfile, line 121.\r\nBreakpoint $decimal at $hex: file.*$srcfile, line 120.\r\nBreakpoint $decimal at $hex: file.*$srcfile, line 119.\r\nBreakpoint $decimal at $hex: file.*$srcfile, line 118.\r\nBreakpoint $decimal at $hex: file.*$srcfile, line 117.\r\nBreakpoint $decimal at $hex: file.*$srcfile, line 116.\r\nBreakpoint $decimal at $hex: file.*$srcfile, line 115.\r\nBreakpoint $decimal at $hex: file.*$srcfile, line 114.\r\nBreakpoint $decimal at $hex: file.*$srcfile, line 113.\r\nBreakpoint $decimal at $hex: file.*$srcfile, line 112.\r\nBreakpoint $decimal at $hex: file.*$srcfile, line 111.\r\nBreakpoint $decimal at $hex: file.*$srcfile, line 110.\r\nwarning: Multiple breakpoints were set.\r\nwarning: Use the .delete. command to delete unwanted breakpoints.\r\n$gdb_prompt $" { + pass "set bp on overload1arg all" + } + -re ".*$gdb_prompt $" { + fail "set bp on overload1arg all (bad message)" + } + timeout { + fail "set bp on overload1arg all (timeout)" + take_gdb_out_of_choice_menu + } + } + } + -re ".*\r\n> " { + fail "bp menu for foo::overload1arg choice all (bad menu)" + take_gdb_out_of_choice_menu + } + -re ".*$gdb_prompt $" { + fail "bp menu for foo::overload1arg choice all (no menu)" + } + timeout { + fail "bp menu for foo::overload1arg choice all (timeout)" + take_gdb_out_of_choice_menu + } +} + +gdb_test "info break" \ + "Num Type\[\t \]+Disp Enb Address\[\t \]+What.* +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(double\\) at.*$srcfile:121\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(float\\) at.*$srcfile:120\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned long\\) at.*$srcfile:119\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(long\\) at.*$srcfile:118\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned|unsigned int)\\) at.*$srcfile:117\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(int\\) at.*$srcfile:116\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned short\\) at.*$srcfile:115\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(short\\) at.*$srcfile:114\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned char\\) at.*$srcfile:113\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(signed char\\) at.*$srcfile:112\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(char\\) at.*$srcfile:111\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((void|)\\) at.*$srcfile:110" \ + "breakpoint info (after setting on all)" + + + +# Run through each breakpoint. + +# NOTE: carlton/2003-02-03: I'm seeing failures on some of the tests, +# with the wrong arg being printed out. Michael Chastain sees +# failures at times, too, albeit fewer than I do. + +proc continue_to_bp_overloaded {might_kfail bpnumber argtype actuals} { + global gdb_prompt hex decimal srcfile + + send_gdb "continue\n" + gdb_expect { + -re "Continuing.\r\n\r\nBreakpoint ${bpnumber}, (${hex} in )?foo::overload1arg(\\(${argtype}\\))? \\(this=${hex}(, )?${actuals}\\) at.*${srcfile}:${decimal}\r\n${decimal}\[\t \]+int foo::overload1arg \\(${argtype}( arg)?\\).*\r\n.*$gdb_prompt $" { + pass "continue to bp overloaded : ${argtype}" + } + -re "Continuing.\r\n\r\nBreakpoint ${bpnumber}, (${hex} in )?foo::overload1arg(\\(${argtype}\\))? \\(this=${hex}, arg=.*\\) at.*${srcfile}:${decimal}\r\n${decimal}\[\t \]+int foo::overload1arg \\(${argtype}( arg)?\\).*\r\n.*$gdb_prompt $" { + if $might_kfail { + kfail "gdb/1025" "continue to bp overloaded : ${argtype}" + } else { + fail "continue to bp overloaded : ${argtype}" + } + } + -re ".*$gdb_prompt $" { + fail "continue to bp overloaded : ${argtype}" + } + timeout { + fail "continue to bp overloaded : ${argtype} (timeout)" + } + } +} + +continue_to_bp_overloaded 0 25 "(void|)" "" +continue_to_bp_overloaded 1 24 "char" "arg=2 \\'\\\\002\\'" +continue_to_bp_overloaded 1 23 "signed char" "arg=3 \\'\\\\003\\'" +continue_to_bp_overloaded 1 22 "unsigned char" "arg=4 \\'\\\\004\\'" +continue_to_bp_overloaded 1 21 "short" "arg=5" +continue_to_bp_overloaded 1 20 "unsigned short" "arg=6" +continue_to_bp_overloaded 0 19 "int" "arg=7" +continue_to_bp_overloaded 0 18 "(unsigned|unsigned int)" "arg=8" +continue_to_bp_overloaded 0 17 "long" "arg=9" +continue_to_bp_overloaded 0 16 "unsigned long" "arg=10" +continue_to_bp_overloaded 0 15 "float" "arg=100" +continue_to_bp_overloaded 1 14 "double" "arg=200" + + + +# That's all, folks. + +gdb_continue_to_end "finish program" diff --git a/gdb/testsuite/gdb.cp/pr-1023.cc b/gdb/testsuite/gdb.cp/pr-1023.cc new file mode 100644 index 0000000..7583084 --- /dev/null +++ b/gdb/testsuite/gdb.cp/pr-1023.cc @@ -0,0 +1,20 @@ +class myClass +{ + public: + myClass() {}; + ~myClass() {}; + void performUnblocking( short int cell_index ); + void performBlocking( int cell_index ); +}; + +void myClass::performUnblocking( short int cell_index ) {} + +void myClass::performBlocking( int cell_index ) {} + +int main () +{ + myClass mc; + mc.performBlocking (0); + mc.performUnblocking (0); +} + diff --git a/gdb/testsuite/gdb.cp/pr-1023.exp b/gdb/testsuite/gdb.cp/pr-1023.exp new file mode 100644 index 0000000..c8c9802 --- /dev/null +++ b/gdb/testsuite/gdb.cp/pr-1023.exp @@ -0,0 +1,79 @@ +# Copyright 2003 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Tests for PR gdb/1023. +# 2003-02-03 Michael Chastain <mec@shout.net> + +# This file is part of the gdb testsuite. + +if $tracelevel then { + strace $tracelevel + } + +if { [skip_cplus_tests] } { continue } + +# +# test running programs +# +set prms_id 0 +set bug_id 0 + +set testfile "pr-1023" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if [get_compiler_info ${binfile} "c++"] { + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + +send_gdb "break myClass::performBlocking\n" +gdb_expect { + -re "Breakpoint $decimal at $hex: file .*$srcfile, line 12.*$gdb_prompt $" { + pass "break myClass::performBlocking" + } + -re "the class myClass does not have any method named performBlocking.*$gdb_prompt $" { + # fails with gcc 2.95.3 -gstabs+, native i686-pc-linux-gnu + # -- chastain 2003-02-03 + kfail "gdb/1023" "break myClass::performBlocking" + } + -re ".*$gdb_prompt $" { + fail "break myClass::performBlocking" + } + timeout { + fail "break myClass::performBlocking (timeout)" + } +} + +gdb_test \ + "break myClass::performUnblocking" \ + "Breakpoint $decimal at $hex: file .*$srcfile, line 10.*" + +gdb_exit +return 0 diff --git a/gdb/testsuite/gdb.cp/pr-1210.cc b/gdb/testsuite/gdb.cp/pr-1210.cc new file mode 100644 index 0000000..5747e5d --- /dev/null +++ b/gdb/testsuite/gdb.cp/pr-1210.cc @@ -0,0 +1,19 @@ +class A +{ +}; + +class B : virtual public A +{ +}; + +class C : public A +{ + protected: + B myB; +}; + +int main() +{ + C *obj = new C(); + return 0; +} diff --git a/gdb/testsuite/gdb.cp/pr-1210.exp b/gdb/testsuite/gdb.cp/pr-1210.exp new file mode 100644 index 0000000..3ff850d --- /dev/null +++ b/gdb/testsuite/gdb.cp/pr-1210.exp @@ -0,0 +1,76 @@ +# Copyright 2003 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Tests for PR gdb/1210. + +# This file is part of the gdb testsuite. + +if $tracelevel then { + strace $tracelevel +} + +if { [skip_cplus_tests] } { continue } + +# +# test running programs +# +set prms_id 0 +set bug_id 0 + +set testfile "pr-1210" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if [get_compiler_info ${binfile} "c++"] { + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + +gdb_test "next" ".*return 0;" "step past initialization" + +gdb_test_multiple "print *obj" "" { + -re "Cannot access memory.*$gdb_prompt $" { + fail "print *obj" + } + -re " = {<A> = {<No data fields>}, myB = {<A> = {<No data fields>}.*}}\r\n$gdb_prompt $" { + pass "print *obj" + } +} + +gdb_test_multiple "print obj->myB" "" { + -re "Cannot access memory.*$gdb_prompt $" { + fail "print obj->myB" + } + -re " = {<A> = {<No data fields>}.*}\r\n$gdb_prompt $" { + pass "print obj->myB" + } +} + +gdb_exit +return 0 diff --git a/gdb/testsuite/gdb.cp/pr-574.cc b/gdb/testsuite/gdb.cp/pr-574.cc new file mode 100644 index 0000000..eb06b61 --- /dev/null +++ b/gdb/testsuite/gdb.cp/pr-574.cc @@ -0,0 +1,22 @@ +/* + An attempt to replicate PR gdb/574 with a shorter program. + + Printing out *theB failed if the program was compiled with GCC 2.95. +*/ + +class A { +public: + virtual void foo() {}; // Stick in a virtual function. + int a; // Stick in a data member. +}; + +class B : public A { + static int b; // Stick in a static data member. +}; + +int main() +{ + B *theB = new B; + + return 0; // breakpoint: constructs-done +} diff --git a/gdb/testsuite/gdb.cp/pr-574.exp b/gdb/testsuite/gdb.cp/pr-574.exp new file mode 100644 index 0000000..5beacd1 --- /dev/null +++ b/gdb/testsuite/gdb.cp/pr-574.exp @@ -0,0 +1,72 @@ +# Copyright 2002 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Tests for the bug mentioned in PR gdb/574. It's a bit +# idiosyncratic, so I gave it its own file. + +# 2002-08-16 David Carlton <carlton@math.stanford.edu> + +# This file is part of the gdb testsuite + +if $tracelevel then { + strace $tracelevel + } + +if { [skip_cplus_tests] } { continue } + +# +# test running programs +# +set prms_id 0 +set bug_id 0 + +set testfile "pr-574" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if [get_compiler_info ${binfile} "c++"] { + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + + +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + +# First, run to after we've constructed the object: + +gdb_breakpoint [gdb_get_line_number "constructs-done"] +gdb_continue_to_breakpoint "end of constructors" + +# This failed, as long as the code was compiled with GCC v. 2. + +# Different compilers order the data for <A> differently, so I'm not +# matching the result exactly. + +gdb_test "print *theB" "\\$\[0-9\]* = {<A> = {\[^}\]*}, static b = <optimized out>}" "PR gdb/574" + +gdb_exit +return 0 diff --git a/gdb/testsuite/gdb.cp/printmethod.cc b/gdb/testsuite/gdb.cp/printmethod.cc new file mode 100644 index 0000000..d32e1b1 --- /dev/null +++ b/gdb/testsuite/gdb.cp/printmethod.cc @@ -0,0 +1,14 @@ +/* Create some objects, and try to print out their methods. */ + +class A { +public: + virtual void virt() {}; + void nonvirt() {}; +}; + +int main() +{ + A *theA = new A; + + return 0; // breakpoint: constructs-done +} diff --git a/gdb/testsuite/gdb.cp/printmethod.exp b/gdb/testsuite/gdb.cp/printmethod.exp new file mode 100644 index 0000000..a45393f --- /dev/null +++ b/gdb/testsuite/gdb.cp/printmethod.exp @@ -0,0 +1,69 @@ +# Copyright 2002, 2003 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# This tries to print out methods of classes. + +# 2002-08-16 David Carlton <carlton@math.stanford.edu> + +# This file is part of the gdb testsuite + +if $tracelevel then { + strace $tracelevel + } + +if { [skip_cplus_tests] } { continue } + +# +# test running programs +# +set prms_id 0 +set bug_id 0 + +set testfile "printmethod" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if [get_compiler_info ${binfile} "c++"] { + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + + +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + +# First, run to after we've constructed the object: + +gdb_breakpoint [gdb_get_line_number "constructs-done"] +gdb_continue_to_breakpoint "end of constructors" + +# The first of these is for PR gdb/653. + +gdb_test "print theA->virt" "\\$\[0-9\]* = &A::virt\\((void|)\\)" "print virtual method." +gdb_test "print theA->nonvirt" "Cannot take address of a method" "print nonvirtual method." + +gdb_exit +return 0 diff --git a/gdb/testsuite/gdb.cp/psmang.exp b/gdb/testsuite/gdb.cp/psmang.exp new file mode 100644 index 0000000..31dd346 --- /dev/null +++ b/gdb/testsuite/gdb.cp/psmang.exp @@ -0,0 +1,226 @@ +# Copyright 2002 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# This file is part of the gdb testsuite + +# Looking up methods by name, in programs with multiple compilation units. + +# ====== PLEASE BE VERY CAREFUL WHEN CHANGING THIS TEST. ===== +# +# The bug we're testing for (circa October 2002) is very sensitive to +# various conditions that are hard to control directly in the test +# suite. If you change the test, please revert this change, and make +# sure the test still fails: +# +# 2002-08-29 Jim Blandy <jimb@redhat.com> +# +# * symtab.c (lookup_symbol_aux): In the cases where we find a +# minimal symbol of an appropriate name and use its address to +# select a symtab to read and search, use `name' (as passed to us) +# as the demangled name when searching the symtab's global and +# static blocks, not the minsym's name. +# +# The original bug was that you'd try to set a breakpoint on a method +# (e.g., `break s::method1'), and you'd get an error, but if you +# repeated the command, it would work the second time: +# +# (gdb) break s::method1 +# the class s does not have any method named method1 +# Hint: try 's::method1<TAB> or 's::method1<ESC-?> +# (Note leading single quote.) +# (gdb) break s::method1 +# Breakpoint 1 at 0x804841b: file psmang1.cc, line 13. +# (gdb) +# +# We observed this bug first using Stabs, and then using Dwarf 2. +# +# The problem was in lookup_symbol_aux: when looking up s::method1, it +# would fail to find it in any symtabs, find the minsym with the +# corresponding mangled name (say, `_ZN1S7method1Ev'), pass the +# minsym's address to find_pc_sect_symtab to look up the symtab +# (causing the compilation unit's full symbols to be read in), and +# then look up the symbol in that symtab's global block. All that is +# correct. However, it would pass the minsym's name as the NAME +# argument to lookup_block_symbol; a minsym's name is mangled, whereas +# lookup_block_symbol's NAME argument should be demangled. +# +# This is a pretty simple bug, but it turns out to be a bear to +# construct a test for. That's why this test case is so delicate. If +# you can see how to make it less so, please contribute a patch. +# +# Here are the twists: +# +# The bug only manifests itself when we call lookup_symbol to look up +# a method name (like "s::method1" or "s::method2"), and that method's +# definition is in a compilation unit for which we have read partial +# symbols, but not full symbols. The partial->full conversion must be +# caused by that specific lookup. (If we already have full symbols +# for the method's compilation unit, we won't need to look up the +# minsym, find the symtab for the minsym's address, and then call +# lookup_block_symbol; it's that last call where things go awry.) +# +# Now, when asked to set a breakpoint at `s::method1', GDB will first +# look up `s' to see if that is, in fact, the name of a class, and +# then look up 's::method1'. So we have to make sure that looking up +# `s' doesn't cause full symbols to be read for the compilation unit +# containing the definition of `s::method1'. +# +# The partial symbol tables for `psmang1.cc' and `psmang2.cc' will +# both have entries for `s'; GDB will read full symbols for whichever +# compilation unit's partial symbol table appears first in the +# objfile's list. The order in which compilation units appear in the +# partial symbol table list depends on how the program is linked, and +# how the debug info reader does the partial symbol scan. Ideally, +# the test shouldn't rely on them appearing in any particular order. +# +# So, since we don't know which compilation unit's full symbols are +# going to get read, we simply try looking up one method from each of +# the two compilation units. One of them has to come after the other +# in the partial symbol table list, so whichever comes later will +# still need its partial symbols read by the time we go to look up +# 's::methodX'. +# +# Second twist: don't move the common definition of `struct s' into a +# header file. If the compiler emits identical stabs for the +# #inclusion of that header file into psmang1.cc and into psmang2.cc, +# then the linker will do stabs compression, and replace one of the +# BINCL/EINCL regions with an EXCL stab, pointing to the other +# BINCL/EINCL region. GDB will read this, and record that the +# compilation unit that got the EXCL depends on the compilation unit +# that kept the BINCL/EINCL. Then, when it decides it needs to read +# full symbols for the former, it'll also read full symbols for the +# latter. Now, if it just so happens that the compilation unit that +# got the EXCL is also the first one with a definition of `s' in the +# partial symbol table list, then that first probe for `s' will cause +# both compilation units' full symbols to be read --- again defeating +# the test. +# +# We could work around this by having three compilation units, or by +# ensuring that the header file produces different stabs each time +# it's #included, but it seems simplest just to avoid compilation unit +# dependencies altogether, drop the header file, and duplicate the +# (pretty trivial) struct definition. +# +# Note that #including any header file at all into both compilation +# units --- say, <stdio.h> --- could create this sort of dependency. +# +# This is the aspect of the test which the debug format is most likely +# to affect, I think. The different formats create different kinds of +# inter-CU dependencies, which could mask the bug. It might be +# possible for the test to check that at least one of the partial +# symtabs remains unread, and fail otherwise --- the failure +# indicating that the test itself isn't going to catch the bug it was +# meant to, not that GDB is misbehaving. +# +# Third twist: given the way lookup_block_symbol is written, it's +# possible to find the symbol even when it gets passed a mangled name +# for its NAME parameter. There are three ways lookup_block_symbol +# might search a block, depending on how it was constructed: +# +# linear search. In this case, this bug will never manifest itself, +# since we check every symbol against NAME using SYMBOL_MATCHES_NAME. +# Since that macro checks its second argument (NAME) against both the +# mangled and demangled names of the symbol, this will always find the +# symbol successfully, so, no bug. +# +# hash table. If both the mangled and demangled names hash to the +# same bucket, then you'll again find the symbol "by accident", since +# we search the entire bucket using SYMBOL_SOURCE_NAME. Since GDB +# chooses the number of buckets based on the number of symbols, small +# compilation units may have only one hash bucket; in this case, the +# search always succeeds, even though we hashed on the wrong name. +# This test works around that by having a lot of dummy variables, +# making it less likely that the mangled and demangled names fall in +# the same bucket. +# +# binary search. (GDB 5.2 produced these sorts of blocks, and this +# test tries to detect the bug there, but subsequent versions of GDB +# almost never build them, and they may soon be removed entirely.) In +# this case, the symbols in the block are sorted by their +# SYMBOL_SOURCE_NAME (whose behavior depends on the current demangling +# setting, so that's wrong, but let's try to stay focussed). +# lookup_block_symbol does a binary search comparing NAME with +# SYMBOL_SOURCE_NAME until the range has been narrowed down to only a +# few symbols; then it starts a linear search forward from the lower +# end of that range, until it reaches a symbol whose +# SYMBOL_SOURCE_NAME follows NAME in lexicographic order. This means +# that, if you're doing a binary search for a mangled name in a block +# sorted by SYMBOL_SOURCE_NAME, you might find the symbol `by +# accident' if the mangled and demangled names happen to fall near +# each other in the ordering. The initial version of this patch used +# a class called `S'; all the other symbols in the compilation unit +# started with lower-case letters, so the demangled name `S::method1' +# sorted at the same place as the mangled name `_ZN1S7method1Ev': at +# the very beginning. Using a lower-case 's' as the name ensures that +# the demangled name falls after all the dummy symbols introduced for +# the hash table, as described above. +# +# This is all so tortured, someone will probably come up with still +# other ways this test could fail to do its job. If you need to make +# revisions, please be very careful. + +if $tracelevel then { + strace $tracelevel +} + +# +# test running programs +# + +set prms_id 0 +set bug_id 0 + +if { [skip_cplus_tests] } { continue } + +set testfile "psmang" +set binfile ${objdir}/${subdir}/${testfile} + +if [get_compiler_info ${binfile} "c++"] { + return -1; +} + +if { [gdb_compile "${srcdir}/${subdir}/${testfile}1.cc" "${testfile}1.o" object {debug c++}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if { [gdb_compile "${srcdir}/${subdir}/${testfile}2.cc" "${testfile}2.o" object {debug c++}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if { [gdb_compile "${testfile}1.o ${testfile}2.o" ${binfile} executable {debug c++}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +gdb_test "break s::method1" "Breakpoint .* at .*: file .*psmang1.cc.*" + +# We have to exit and restart GDB here, to make sure that all the +# compilation units are psymtabs again. + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +gdb_test "break s::method2" "Breakpoint .* at .*: file .*psmang2.cc.*" diff --git a/gdb/testsuite/gdb.cp/psmang1.cc b/gdb/testsuite/gdb.cp/psmang1.cc new file mode 100644 index 0000000..19a9283 --- /dev/null +++ b/gdb/testsuite/gdb.cp/psmang1.cc @@ -0,0 +1,159 @@ +/* Do not move this definition into a header file! See the comments + in psmang.exp. */ +struct s +{ + int value; + void method1 (void); + void method2 (void); +}; + +void +s::method1 () +{ + value = 42; +} + +int +main (int argc, char **argv) +{ + s si; + + si.method1 (); + si.method2 (); +} + + +/* The presence of these variables ensures there will be so many + symbols in psmang1.cc's symtab's global block that it will have a + non-trivial hash table. When there are only a very few symbols, + the block only has one hash bucket, so even if we compute the hash + value for the wrong symbol name, we'll still find a symbol that + matches. */ +int ax; +int bx; +int a1x; +int b1x; +int a2x; +int b2x; +int a12x; +int b12x; +int a3x; +int b3x; +int a13x; +int b13x; +int a23x; +int b23x; +int a123x; +int b123x; +int a4x; +int b4x; +int a14x; +int b14x; +int a24x; +int b24x; +int a124x; +int b124x; +int a34x; +int b34x; +int a134x; +int b134x; +int a234x; +int b234x; +int a1234x; +int b1234x; +int a5x; +int b5x; +int a15x; +int b15x; +int a25x; +int b25x; +int a125x; +int b125x; +int a35x; +int b35x; +int a135x; +int b135x; +int a235x; +int b235x; +int a1235x; +int b1235x; +int a45x; +int b45x; +int a145x; +int b145x; +int a245x; +int b245x; +int a1245x; +int b1245x; +int a345x; +int b345x; +int a1345x; +int b1345x; +int a2345x; +int b2345x; +int a12345x; +int b12345x; +int a6x; +int b6x; +int a16x; +int b16x; +int a26x; +int b26x; +int a126x; +int b126x; +int a36x; +int b36x; +int a136x; +int b136x; +int a236x; +int b236x; +int a1236x; +int b1236x; +int a46x; +int b46x; +int a146x; +int b146x; +int a246x; +int b246x; +int a1246x; +int b1246x; +int a346x; +int b346x; +int a1346x; +int b1346x; +int a2346x; +int b2346x; +int a12346x; +int b12346x; +int a56x; +int b56x; +int a156x; +int b156x; +int a256x; +int b256x; +int a1256x; +int b1256x; +int a356x; +int b356x; +int a1356x; +int b1356x; +int a2356x; +int b2356x; +int a12356x; +int b12356x; +int a456x; +int b456x; +int a1456x; +int b1456x; +int a2456x; +int b2456x; +int a12456x; +int b12456x; +int a3456x; +int b3456x; +int a13456x; +int b13456x; +int a23456x; +int b23456x; +int a123456x; +int b123456x; diff --git a/gdb/testsuite/gdb.cp/psmang2.cc b/gdb/testsuite/gdb.cp/psmang2.cc new file mode 100644 index 0000000..b9b1bb5 --- /dev/null +++ b/gdb/testsuite/gdb.cp/psmang2.cc @@ -0,0 +1,152 @@ +#include <stdio.h> + +/* Do not move this definition into a header file! See the comments + in psmang.exp. */ +struct s +{ + int value; + void method1 (void); + void method2 (void); +}; + +void +s::method2 (void) +{ + printf ("%d\n", value); +} + + +/* The presence of these variables ensures there will be so many + symbols in psmang2.cc's symtab's global block that it will have a + non-trivial hash table. When there are only a very few symbols, + the block only has one hash bucket, so even if we compute the hash + value for the wrong symbol name, we'll still find a symbol that + matches. */ +int a; +int b; +int a1; +int b1; +int a2; +int b2; +int a12; +int b12; +int a3; +int b3; +int a13; +int b13; +int a23; +int b23; +int a123; +int b123; +int a4; +int b4; +int a14; +int b14; +int a24; +int b24; +int a124; +int b124; +int a34; +int b34; +int a134; +int b134; +int a234; +int b234; +int a1234; +int b1234; +int a5; +int b5; +int a15; +int b15; +int a25; +int b25; +int a125; +int b125; +int a35; +int b35; +int a135; +int b135; +int a235; +int b235; +int a1235; +int b1235; +int a45; +int b45; +int a145; +int b145; +int a245; +int b245; +int a1245; +int b1245; +int a345; +int b345; +int a1345; +int b1345; +int a2345; +int b2345; +int a12345; +int b12345; +int a6; +int b6; +int a16; +int b16; +int a26; +int b26; +int a126; +int b126; +int a36; +int b36; +int a136; +int b136; +int a236; +int b236; +int a1236; +int b1236; +int a46; +int b46; +int a146; +int b146; +int a246; +int b246; +int a1246; +int b1246; +int a346; +int b346; +int a1346; +int b1346; +int a2346; +int b2346; +int a12346; +int b12346; +int a56; +int b56; +int a156; +int b156; +int a256; +int b256; +int a1256; +int b1256; +int a356; +int b356; +int a1356; +int b1356; +int a2356; +int b2356; +int a12356; +int b12356; +int a456; +int b456; +int a1456; +int b1456; +int a2456; +int b2456; +int a12456; +int b12456; +int a3456; +int b3456; +int a13456; +int b13456; +int a23456; +int b23456; +int a123456; +int b123456; diff --git a/gdb/testsuite/gdb.cp/ref-types.cc b/gdb/testsuite/gdb.cp/ref-types.cc new file mode 100644 index 0000000..23cc510 --- /dev/null +++ b/gdb/testsuite/gdb.cp/ref-types.cc @@ -0,0 +1,79 @@ +int main2(void); + +void marker1 (void) +{ + +} + + + +int main(void) +{ + short s; + short &rs = s; + short *ps; + short *&rps = ps; + short as[4]; + short (&ras)[4] = as; + s = -1; + ps = &s; + as[0] = 0; + as[1] = 1; + as[2] = 2; + as[3] = 3; + + #ifdef usestubs + set_debug_traps(); + breakpoint(); + #endif + marker1(); + + main2(); + + return 0; +} + +int f() +{ + int f1; + f1 = 1; + return f1; +} + +int main2(void) +{ + char C; + unsigned char UC; + short S; + unsigned short US; + int I; + unsigned int UI; + long L; + unsigned long UL; + float F; + double D; + char &rC = C; + unsigned char &rUC = UC; + short &rS = S; + unsigned short &rUS = US; + int &rI = I; + unsigned int &rUI = UI; + long &rL = L; + unsigned long &rUL = UL; + float &rF = F; + double &rD = D; + C = 'A'; + UC = 21; + S = -14; + US = 7; + I = 102; + UI = 1002; + L = -234; + UL = 234; + F = 1.25E10; + D = -1.375E-123; + I = f(); + + return 0; + +} diff --git a/gdb/testsuite/gdb.cp/ref-types.exp b/gdb/testsuite/gdb.cp/ref-types.exp new file mode 100644 index 0000000..dd06f02 --- /dev/null +++ b/gdb/testsuite/gdb.cp/ref-types.exp @@ -0,0 +1,663 @@ +# Tests for reference types with short type variables in GDB. +# Copyright 1998, 1999, 2000 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# written by Elena Zannoni (ezannoni@cygnus.com) + +if $tracelevel then { + strace $tracelevel + } + +# +# test running programs +# +set prms_id 0 +set bug_id 0 + +if { [skip_cplus_tests] } { continue } + +set testfile "ref-types" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + + +# +# set it up at a breakpoint so we can play with the variable values +# +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + +if ![runto 'marker1'] then { + perror "couldn't run to marker1" + continue +} + +gdb_test "up" ".*main.*" "up from marker1 1" + +proc gdb_start_again {} { + global srcdir + global subdir + global binfile + global gdb_prompt + global decimal + + gdb_start + gdb_reinitialize_dir $srcdir/$subdir + gdb_load ${binfile} + + source ${binfile}.ci + + # + # set it up at a breakpoint so we can play with the variable values + # + if ![runto_main] then { + perror "couldn't run to breakpoint" + continue + } + + if ![runto 'marker1'] then { + perror "couldn't run to marker1" + continue + } + + gdb_test "up" ".*main.*" "up from marker1 2" +} + + + +send_gdb "print s\n" +gdb_expect { + -re ".\[0-9\]* = -1.*$gdb_prompt $" { + pass "print value of s" + } + -re ".*$gdb_prompt $" { fail "print value of s" } + timeout { fail "(timeout) print value of s" } + } + + +send_gdb "ptype s\n" +gdb_expect { + -re "type = short.*$gdb_prompt $" { pass "ptype s" } + -re ".*$gdb_prompt $" { fail "ptype s" } + timeout { fail "(timeout) ptype s" } +} + + +send_gdb "print *ps\n" +gdb_expect { + -re ".\[0-9\]* = -1.*$gdb_prompt $" { + pass "print value of ps" + } + -re ".*$gdb_prompt $" { fail "print value of ps" } + timeout { fail "(timeout) print value of ps" } + } + + +send_gdb "ptype ps\n" +gdb_expect { + -re "type = short \*.*$gdb_prompt $" { pass "ptype ps" } + -re ".*$gdb_prompt $" { fail "ptype ps" } + timeout { fail "(timeout) ptype ps" } +} + +send_gdb "print as\[0\]\n" +gdb_expect { + -re ".\[0-9\]* = 0.*$gdb_prompt $" { + pass "print value of as\[0\]" + } + -re ".*$gdb_prompt $" { fail "print value of as\[0\]" } + timeout { fail "(timeout) print value of as\[0\]" } + } + + +send_gdb "ptype as\n" +gdb_expect { + -re "type = short \\\[4\\\].*$gdb_prompt $" { pass "ptype as" } + -re "type = short int \\\[4\\\].*$gdb_prompt $" { pass "ptype as" } + -re ".*$gdb_prompt $" { fail "ptype as" } + timeout { fail "(timeout) ptype as" } +} + +send_gdb "print as\[1\]\n" +gdb_expect { + -re ".\[0-9\]* = 1.*$gdb_prompt $" { + pass "print value of as\[1\]" + } + -re ".*$gdb_prompt $" { fail "print value of as\[1\]" } + timeout { fail "(timeout) print value of as\[1\]" } + } + +send_gdb "print as\[2\]\n" +gdb_expect { + -re ".\[0-9\]* = 2.*$gdb_prompt $" { + pass "print value of as\[2\]" + } + -re ".*$gdb_prompt $" { fail "print value of as\[2\]" } + timeout { fail "(timeout) print value of as\[2\]" } + } + +send_gdb "print as\[3\]\n" +gdb_expect { + -re ".\[0-9\]* = 3.*$gdb_prompt $" { + pass "print value of as\[3\]" + } + -re ".*$gdb_prompt $" { fail "print value of as\[3\]" } + timeout { fail "(timeout) print value of as\[3\]" } + } + +send_gdb "print rs\n" +gdb_expect { + -re ".\[0-9\]* = \\(short &\\) @$hex: -1.*$gdb_prompt $" { + pass "print value of rs" + } + -re ".\[0-9\]* = \\(short int &\\) @$hex: -1.*$gdb_prompt $" { + pass "print value of rs" + } + -re ".*$gdb_prompt $" { fail "print value of rs" } + timeout { fail "(timeout) print value of rs" } + eof { fail "print rs ($GDB dumped core) (FIXME)" ; gdb_start_again ; } + + } + +send_gdb "ptype rs\n" +gdb_expect { + -re "type = short &.*$gdb_prompt $" { pass "ptype rs" } + -re "type = short int &.*$gdb_prompt $" { pass "ptype rs" } + -re ".*$gdb_prompt $" { fail "ptype rs" } + timeout { fail "(timeout) ptype rs" } +} + + +send_gdb "print *rps\n" +gdb_expect { + -re ".\[0-9\]* = -1.*$gdb_prompt $" { + pass "print value of *rps" + } + -re ".*$gdb_prompt $" { fail "print value of *rps" } + timeout { fail "(timeout) print value of *rps" } + } + + +send_gdb "ptype rps\n" +gdb_expect { + -re "type = short \\*&.*$gdb_prompt $" { pass "ptype rps" } + -re "type = short int \\*&.*$gdb_prompt $" { pass "ptype rps" } + -re ".*$gdb_prompt $" { fail "ptype rps" } + timeout { fail "(timeout) ptype rps" } +} + + + +send_gdb "print ras\[0\]\n" +gdb_expect { + -re ".\[0-9\]* = 0.*$gdb_prompt $" { + pass "print value of ras\[0\]" + } + -re ".*$gdb_prompt $" { fail "print value of ras\[0\]" } + timeout { fail "(timeout) print value of ras\[0\]" } + } + + +send_gdb "ptype ras\n" +gdb_expect { + -re "type = short \\\(&\\\)\\\[4\\\].*$gdb_prompt $" { pass "ptype ras" } + -re "type = short int \\\(&\\\)\\\[4\\\].*$gdb_prompt $" { pass "ptype ras" } + -re ".*$gdb_prompt $" { fail "ptype ras" } + timeout { fail "(timeout) ptype ras" } +} + +send_gdb "print ras\[1\]\n" +gdb_expect { + -re ".\[0-9\]* = 1.*$gdb_prompt $" { + pass "print value of ras\[1\]" + } + -re ".*$gdb_prompt $" { fail "print value of ras\[1\]" } + timeout { fail "(timeout) print value of ras\[1\]" } + } + +send_gdb "print ras\[2\]\n" +gdb_expect { + -re ".\[0-9\]* = 2.*$gdb_prompt $" { + pass "print value of ras\[2\]" + } + -re ".*$gdb_prompt $" { fail "print value of ras\[2\]" } + timeout { fail "(timeout) print value of ras\[2\]" } + } + +send_gdb "print ras\[3\]\n" +gdb_expect { + -re ".\[0-9\]* = 3.*$gdb_prompt $" { + pass "print value of ras\[3\]" + } + -re ".*$gdb_prompt $" { fail "print value of ras\[3\]" } + timeout { fail "(timeout) print value of ras\[3\]" } + } + + +if ![runto 'f'] then { + perror "couldn't run to f" + continue +} + +gdb_test "up" ".main2.*" "up from f" + +send_gdb "print C\n" +gdb_expect { + -re ".\[0-9\]* = 65 \'A\'.*$gdb_prompt $" { + pass "print value of C" + } + -re ".*$gdb_prompt $" { fail "print value of C" } + timeout { fail "(timeout) print value of C" } + } + + +send_gdb "ptype C\n" +gdb_expect { + -re "type = char.*$gdb_prompt $" { pass "ptype C" } + -re ".*$gdb_prompt $" { fail "ptype C" } + timeout { fail "(timeout) ptype C" } +} + + +send_gdb "print UC\n" +gdb_expect { + -re ".\[0-9\]* = 21 '\.025'\.*$gdb_prompt $" { + pass "print value of UC" + } + -re ".*$gdb_prompt $" { fail "print value of UC" } + timeout { fail "(timeout) print value of UC" } + } + + +send_gdb "ptype UC\n" +gdb_expect { + -re "type = unsigned char.*$gdb_prompt $" { pass "ptype UC" } + -re ".*$gdb_prompt $" { fail "ptype UC" } + timeout { fail "(timeout) ptype UC" } +} + + +send_gdb "print S\n" +gdb_expect { + -re ".\[0-9\]* = -14.*$gdb_prompt $" { + pass "print value of S" + } + -re ".*$gdb_prompt $" { fail "print value of S" } + timeout { fail "(timeout) print value of S" } + } + + +send_gdb "ptype S\n" +gdb_expect { + -re "type = short.*$gdb_prompt $" { pass "ptype S" } + -re ".*$gdb_prompt $" { fail "ptype S" } + timeout { fail "(timeout) ptype S" } +} + + +send_gdb "print US\n" +gdb_expect { + -re ".\[0-9\]* = 7.*$gdb_prompt $" { + pass "print value of US" + } + -re ".*$gdb_prompt $" { fail "print value of US" } + timeout { fail "(timeout) print value of US" } + } + + +send_gdb "ptype US\n" +gdb_expect { + -re "type = unsigned short.*$gdb_prompt $" { pass "ptype US" } + -re "type = short unsigned.*$gdb_prompt $" { pass "ptype US" } + -re ".*$gdb_prompt $" { fail "ptype US" } + timeout { fail "(timeout) ptype US" } +} + + +send_gdb "print I\n" +gdb_expect { + -re ".\[0-9\]* = 102.*$gdb_prompt $" { + pass "print value of I" + } + -re ".*$gdb_prompt $" { fail "print value of I" } + timeout { fail "(timeout) print value of I" } + } + + +send_gdb "ptype I\n" +gdb_expect { + -re "type = int.*$gdb_prompt $" { pass "ptype I" } + -re ".*$gdb_prompt $" { fail "ptype I" } + timeout { fail "(timeout) ptype I" } +} + + +send_gdb "print UI\n" +gdb_expect { + -re ".\[0-9\]* = 1002.*$gdb_prompt $" { + pass "print value of UI" + } + -re ".*$gdb_prompt $" { fail "print value of UI" } + timeout { fail "(timeout) print value of UI" } + } + + +send_gdb "ptype UI\n" +gdb_expect { + -re "type = unsigned int.*$gdb_prompt $" { pass "ptype UI" } + -re ".*$gdb_prompt $" { fail "ptype UI" } + timeout { fail "(timeout) ptype UI" } +} + + +send_gdb "print L\n" +gdb_expect { + -re ".\[0-9\]* = -234.*$gdb_prompt $" { + pass "print value of L" + } + -re ".*$gdb_prompt $" { fail "print value of L" } + timeout { fail "(timeout) print value of L" } + } + + +send_gdb "ptype L\n" +gdb_expect { + -re "type = long.*$gdb_prompt $" { pass "ptype L" } + -re ".*$gdb_prompt $" { fail "ptype L" } + timeout { fail "(timeout) ptype L" } +} + + +send_gdb "print UL\n" +gdb_expect { + -re ".\[0-9\]* = 234.*$gdb_prompt $" { + pass "print value of UL" + } + -re ".*$gdb_prompt $" { fail "print value of UL" } + timeout { fail "(timeout) print value of UL" } + } + + +send_gdb "ptype UL\n" +gdb_expect { + -re "type = unsigned long.*$gdb_prompt $" { pass "ptype UL" } + -re "type = long unsigned.*$gdb_prompt $" { pass "ptype UL" } + -re ".*$gdb_prompt $" { fail "ptype UL" } + timeout { fail "(timeout) ptype UL" } +} + + +send_gdb "print F\n" +gdb_expect { + -re ".\[0-9\]* = 1.2\[0-9\]*e\\+10.*$gdb_prompt $" { + pass "print value of F" + } + -re ".*$gdb_prompt $" { fail "print value of F" } + timeout { fail "(timeout) print value of F" } + } + + + +send_gdb "ptype F\n" +gdb_expect { + -re "type = float.*$gdb_prompt $" { pass "ptype F" } + -re ".*$gdb_prompt $" { fail "ptype F" } + timeout { fail "(timeout) ptype F" } +} + + +send_gdb "print D\n" +gdb_expect { + -re ".\[0-9\]* = -1.375e-123.*$gdb_prompt $" { + pass "print value of D" + } + -re ".*$gdb_prompt $" { fail "print value of D" } + timeout { fail "(timeout) print value of D" } + } + + +send_gdb "ptype D\n" +gdb_expect { + -re "type = double.*$gdb_prompt $" { pass "ptype D" } + -re ".*$gdb_prompt $" { fail "ptype D" } + timeout { fail "(timeout) ptype D" } +} + + + +# +# test reference types +# + + + + +send_gdb "ptype rC\n" +gdb_expect { + -re "type = char &.*$gdb_prompt $" { pass "ptype rC" } + -re ".*$gdb_prompt $" { fail "ptype rC" } + timeout { fail "(timeout) ptype rC" } +} + + + + +send_gdb "ptype rUC\n" +gdb_expect { + -re "type = unsigned char &.*$gdb_prompt $" { pass "ptype rUC" } + -re ".*$gdb_prompt $" { fail "ptype rUC" } + timeout { fail "(timeout) ptype rUC" } +} + + + +send_gdb "ptype rS\n" +gdb_expect { + -re "type = short &.*$gdb_prompt $" { pass "ptype rS" } + -re "type = short int &.*$gdb_prompt $" { pass "ptype rS" } + -re ".*$gdb_prompt $" { fail "ptype rS" } + timeout { fail "(timeout) ptype rS" } +} + + + +send_gdb "ptype rUS\n" +gdb_expect { + -re "type = unsigned short &.*$gdb_prompt $" { pass "ptype rUS" } + -re "type = short unsigned int &.*$gdb_prompt $" { pass "ptype rUS" } + -re ".*$gdb_prompt $" { fail "ptype rUS" } + timeout { fail "(timeout) ptype rUS" } +} + + +send_gdb "ptype rI\n" +gdb_expect { + -re "type = int &.*$gdb_prompt $" { pass "ptype rI" } + -re ".*$gdb_prompt $" { fail "ptype rI" } + timeout { fail "(timeout) ptype rI" } +} + + + +send_gdb "ptype rUI\n" +gdb_expect { + -re "type = unsigned int &.*$gdb_prompt $" { pass "ptype rUI" } + -re ".*$gdb_prompt $" { fail "ptype rUI" } + timeout { fail "(timeout) ptype rUI" } +} + + + +send_gdb "ptype rL\n" +gdb_expect { + -re "type = long &.*$gdb_prompt $" { pass "ptype rL" } + -re "type = long int &.*$gdb_prompt $" { pass "ptype rL" } + -re ".*$gdb_prompt $" { fail "ptype rL" } + timeout { fail "(timeout) ptype rL" } +} + + +send_gdb "ptype rUL\n" +gdb_expect { + -re "type = unsigned long &.*$gdb_prompt $" { pass "ptype rUL" } + -re "type = long unsigned int &.*$gdb_prompt $" { pass "ptype rUL" } + -re ".*$gdb_prompt $" { fail "ptype rUL" } + timeout { fail "(timeout) ptype rUL" } +} + + +send_gdb "ptype rF\n" +gdb_expect { + -re "type = float &.*$gdb_prompt $" { pass "ptype rF" } + -re ".*$gdb_prompt $" { fail "ptype rF" } + timeout { fail "(timeout) ptype rF" } +} + + +send_gdb "ptype rD\n" +gdb_expect { + -re "type = double &.*$gdb_prompt $" { pass "ptype rD" } + -re ".*$gdb_prompt $" { fail "ptype rD" } + timeout { fail "(timeout) ptype rD" } +} + + +send_gdb "print rC\n" +gdb_expect { + -re ".\[0-9\]* = \\(char &\\) @$hex: 65 \'A\'.*$gdb_prompt $" { + pass "print value of rC" + } + -re ".*$gdb_prompt $" { fail "print value of rC" } + timeout { fail "(timeout) print value of rC" } + } + + +send_gdb "print rUC\n" +gdb_expect { + -re ".\[0-9\]* = \\(unsigned char &\\) @$hex: 21 \'.025\'.*$gdb_prompt $" { + pass "print value of rUC" + } + -re ".*$gdb_prompt $" { fail "print value of rUC" } + timeout { fail "(timeout) print value of rUC" } + } + + +send_gdb "print rS\n" +gdb_expect { + -re ".\[0-9\]* = \\(short &\\) @$hex: -14.*$gdb_prompt $" { + pass "print value of rS" + } + -re ".\[0-9\]* = \\(short int &\\) @$hex: -14.*$gdb_prompt $" { + pass "print value of rS" + } + -re ".*$gdb_prompt $" { fail "print value of rS" } + timeout { fail "(timeout) print value of rS" } + } + + +send_gdb "print rUS\n" +gdb_expect { + -re ".\[0-9\]* = \\(unsigned short &\\) @$hex: 7.*$gdb_prompt $" { + pass "print value of rUS" + } + -re ".\[0-9\]* = \\(short unsigned int &\\) @$hex: 7.*$gdb_prompt $" { + pass "print value of rUS" + } + -re ".*$gdb_prompt $" { fail "print value of rUS" } + timeout { fail "(timeout) print value of rUS" } + } + + +send_gdb "print rI\n" +gdb_expect { + -re ".\[0-9\]* = \\(int &\\) @$hex: 102.*$gdb_prompt $" { + pass "print value of rI" + } + -re ".*$gdb_prompt $" { fail "print value of rI" } + timeout { fail "(timeout) print value of rI" } + } + + +send_gdb "print rUI\n" +gdb_expect { + -re ".\[0-9\]* = \\(unsigned int &\\) @$hex: 1002.*$gdb_prompt $" { + pass "print value of UI" + } + -re ".*$gdb_prompt $" { fail "print value of rUI" } + timeout { fail "(timeout) print value of rUI" } + } + + +send_gdb "print rL\n" +gdb_expect { + -re ".\[0-9\]* = \\(long &\\) @$hex: -234.*$gdb_prompt $" { + pass "print value of rL" + } + -re ".\[0-9\]* = \\(long int &\\) @$hex: -234.*$gdb_prompt $" { + pass "print value of rL" + } + -re ".*$gdb_prompt $" { fail "print value of rL" } + timeout { fail "(timeout) print value of rL" } + } + + + +send_gdb "print rUL\n" +gdb_expect { + -re ".\[0-9\]* = \\(unsigned long &\\) @$hex: 234.*$gdb_prompt $" { + pass "print value of rUL" + } + -re ".\[0-9\]* = \\(long unsigned int &\\) @$hex: 234.*$gdb_prompt $" { + pass "print value of rUL" + } + -re ".*$gdb_prompt $" { fail "print value of rUL" } + timeout { fail "(timeout) print value of rUL" } + } + + +send_gdb "print rF\n" +gdb_expect { + -re ".\[0-9\]* = \\(float &\\) @$hex: 1.2\[0-9\]*e\\+10.*$gdb_prompt $" { + pass "print value of rF" + } + -re ".*$gdb_prompt $" { fail "print value of rF" } + timeout { fail "(timeout) print value of rF" } + } + + +send_gdb "print rD\n" +gdb_expect { + -re ".\[0-9\]* = \\(double &\\) @$hex: -1.375e-123.*$gdb_prompt $" { + pass "print value of rD" + } + -re ".*$gdb_prompt $" { fail "print value of rD" } + timeout { fail "(timeout) print value of rD" } + } + diff --git a/gdb/testsuite/gdb.cp/rtti.exp b/gdb/testsuite/gdb.cp/rtti.exp new file mode 100644 index 0000000..f99637a --- /dev/null +++ b/gdb/testsuite/gdb.cp/rtti.exp @@ -0,0 +1,127 @@ +# Copyright 2003 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# This file is part of the gdb testsuite. + +# This contains tests for GDB's use of RTTI information. This stems +# from a bug reported in PR gdb/488 and other places, which leads to +# statements like 'warning: can't find class named 'C::D', as given by +# C++ RTTI'. It arises from GDB not knowing about classes that are +# defined in namespaces. + +# NOTE: carlton/2003-05-16: I suspect it could arise from nested class +# issues, too, and even once we fix that, there might be situations +# (involving templates, in particular) where this problem triggers +# because GDB and GCC have different ideas what a class is called. + +if $tracelevel then { + strace $tracelevel + } + +if { [skip_cplus_tests] } { continue } + +# +# test running programs +# +set prms_id 0 +set bug_id 0 + +set testfile "rtti" +set srcfile1 "${srcdir}/${subdir}/${testfile}1.cc" +set objfile1 "${objdir}/${subdir}/${testfile}1.o" +set srcfile2 "${srcdir}/${subdir}/${testfile}2.cc" +set objfile2 "${objdir}/${subdir}/${testfile}2.o" +set binfile ${objdir}/${subdir}/${testfile} + +# gdb_get_line_number needs this to be called srcfile. +set srcfile "${srcfile1}" + +if { [gdb_compile "${srcfile1}" "${objfile1}" object {debug c++}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if { [gdb_compile "${srcfile2}" "${objfile2}" object {debug c++}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if { [gdb_compile "${objfile1} ${objfile2}" "${binfile}" executable {debug c++}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if [get_compiler_info ${binfile} "c++"] { + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + + +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + +# First, run to after we've constructed the object: + +gdb_breakpoint [gdb_get_line_number "constructs-done"] +gdb_continue_to_breakpoint "end of constructors" + +gdb_test_multiple "print *e1" "print *e1" { + -re "warning: can't find class named `n1::D1', as given by C\\+\\+ RTTI.*$gdb_prompt $" { + kfail "gdb/488" "print *e1" + } + -re "\\$\[0-9\]* = {<n1::Base1> = .*}\r\n$gdb_prompt $" { + pass "print *e1" + } + -re "\\$\[0-9\]* = {<Base1> = .*}\r\n$gdb_prompt $" { + # NOTE: carlton/2003-05-16: If code is compiled by GCC2, we + # don't print the warning (for no particular reason), but we + # still call the class via the wrong name; PR gdb/57 is our + # catch-all PR for nested type problems. + kfail "gdb/57" "print *e1" + } +} + +# NOTE: carlton/2003-05-16: This test fails on my branch with an +# "<incomplete type>" message because, within rtt1.cc, GDB has no way +# of knowing that the class is called 'n2::D2' instead of just 'D2'. +# This is an artifical test case, though: if we were using these +# classes in a more substantial way, G++ would emit more debug info. +# As is, I don't think there's anything that GDB can do about this +# case until G++ starts emitting DW_TAG_namespace info; when that part +# of the branch gets merged in, then we'll probably want to convert +# that fail branch to an xfail. + +gdb_test_multiple "print *e2" "print *e2" { + -re "warning: can't find class named `n2::D2', as given by C\\+\\+ RTTI.*$gdb_prompt $" { + kfail "gdb/488" "print *e2" + } + -re "\\$\[0-9\]* = <incomplete type>\r\n$gdb_prompt $" { + # See above NOTE. + fail "print *e2" + } + -re "\\$\[0-9\]* = {<n2::Base2> = .*}\r\n$gdb_prompt $" { + pass "print *e2" + } + -re "\\$\[0-9\]* = {<Base2> = .*}\r\n$gdb_prompt $" { + kfail "gdb/57" "print *e2" + } +} + +gdb_exit +return 0 diff --git a/gdb/testsuite/gdb.cp/rtti.h b/gdb/testsuite/gdb.cp/rtti.h new file mode 100644 index 0000000..879896d --- /dev/null +++ b/gdb/testsuite/gdb.cp/rtti.h @@ -0,0 +1,48 @@ +/* Code to go along with tests in rtti.exp. + + Copyright 2003 Free Software Foundation, Inc. + + Contributed by David Carlton <carlton@bactrian.org> and by Kealia, + Inc. + + This file is part of GDB. + + 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 2 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +namespace n2 { + + class C2; + + class Base2 { + public: + virtual ~Base2() { } + }; + + + class C2: public Base2 { + public: + }; + + class D2 : public C2{ + public: + D2(C2 *, C2 *); + + C2* expr_1_; + C2* expr_2_; + }; + + extern C2 *create2(); +} diff --git a/gdb/testsuite/gdb.cp/rtti1.cc b/gdb/testsuite/gdb.cp/rtti1.cc new file mode 100644 index 0000000..6e9d862 --- /dev/null +++ b/gdb/testsuite/gdb.cp/rtti1.cc @@ -0,0 +1,67 @@ +/* Code to go along with tests in rtti.exp. + + Copyright 2003 Free Software Foundation, Inc. + + Contributed by David Carlton <carlton@bactrian.org> and by Kealia, + Inc. + + This file is part of GDB. + + 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 2 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include "rtti.h" + +namespace n1 { + + class C1; + + class Base1 { + public: + virtual ~Base1() { } + }; + + + class C1: public Base1 { + public: + }; + + class D1 : public C1{ + public: + D1(C1 *, C1 *); + + C1* expr_1_; + C1* expr_2_; + }; + + D1::D1(C1 *expr_1, C1 *expr_2) + : expr_1_(expr_1), expr_2_(expr_2) { } + + C1 *create1() { + return new D1(0, 0); + } + +} // n1 + +int main() +{ + using namespace n1; + using namespace n2; + + C1 *e1 = create1(); + C2 *e2 = create2(); + + return 0; // constructs-done +} diff --git a/gdb/testsuite/gdb.cp/rtti2.cc b/gdb/testsuite/gdb.cp/rtti2.cc new file mode 100644 index 0000000..8bb1ed6 --- /dev/null +++ b/gdb/testsuite/gdb.cp/rtti2.cc @@ -0,0 +1,36 @@ +/* Code to go along with tests in rtti.exp. + + Copyright 2003 Free Software Foundation, Inc. + + Contributed by David Carlton <carlton@bactrian.org> and by Kealia, + Inc. + + This file is part of GDB. + + 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 2 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include "rtti.h" + +namespace n2 { + + D2::D2(C2 *expr_1, C2 *expr_2) + : expr_1_(expr_1), expr_2_(expr_2) { } + + C2 *create2() { + return new D2(0, 0); + } + +} diff --git a/gdb/testsuite/gdb.cp/templates.cc b/gdb/testsuite/gdb.cp/templates.cc new file mode 100644 index 0000000..c13f18b --- /dev/null +++ b/gdb/testsuite/gdb.cp/templates.cc @@ -0,0 +1,785 @@ +/* This test code is from Wendell Baker (wbaker@comet.berkeley.edu) */ + +#include <stddef.h> + +int a_i; +char a_c; +double a_d; + +typedef void *Pix; + +int +f(int i) +{ return 0; } + +int +f(int i, char c) +{ return 0; } + +int +f(int i, char c, double d) +{ return 0; } + +int +f(int i, char c, double d, char *cs) +{ return 0; } + +int +f(int i, char c, double d, char *cs, void (*fig)(int, char)) +{ return 0; } + +int +f(int i, char c, double d, char *cs, void (*fig)(char, int)) +{ return 0; } + +class R { +public: + int i; +}; +class S { +public: + int i; +}; +class T { +public: + int i; +}; + +char g(char, const char, volatile char) +{ return 'c'; } +char g(R, char&, const char&, volatile char&) +{ return 'c'; } +char g(char*, const char*, volatile char*) +{ return 'c'; } +char g(S, char*&, const char*&, volatile char*&) +{ return 'c'; } + +signed char g(T,signed char, const signed char, volatile signed char) +{ return 'c'; } +signed char g(T, R, signed char&, const signed char&, volatile signed char&) +{ return 'c'; } +signed char g(T, signed char*, const signed char*, volatile signed char*) +{ return 'c'; } +signed char g(T, S, signed char*&, const signed char*&, volatile signed char*&) +{ return 'c'; } + +unsigned char g(unsigned char, const unsigned char, volatile unsigned char) +{ return 'c'; } +unsigned char g(R, unsigned char&, const unsigned char&, volatile unsigned char&) +{ return 'c'; } +unsigned char g(unsigned char*, const unsigned char*, volatile unsigned char*) +{ return 'c'; } +unsigned char g(S, unsigned char*&, const unsigned char*&, volatile unsigned char*&) +{ return 'c'; } + +short g(short, const short, volatile short) +{ return 0; } +short g(R, short&, const short&, volatile short&) +{ return 0; } +short g(short*, const short*, volatile short*) +{ return 0; } +short g(S, short*&, const short*&, volatile short*&) +{ return 0; } + +signed short g(T, signed short, const signed short, volatile signed short) +{ return 0; } +signed short g(T, R, signed short&, const signed short&, volatile signed short&) +{ return 0; } +signed short g(T, signed short*, const signed short*, volatile signed short*) +{ return 0; } +signed short g(T, S, double, signed short*&, const signed short*&, volatile signed short*&) +{ return 0; } + +unsigned short g(unsigned short, const unsigned short, volatile unsigned short) +{ return 0; } +unsigned short g(R, unsigned short&, const unsigned short&, volatile unsigned short&) +{ return 0; } +unsigned short g(unsigned short*, const unsigned short*, volatile unsigned short*) +{ return 0; } +unsigned short g(S, unsigned short*&, const unsigned short*&, volatile unsigned short*&) +{ return 0; } + +int g(int, const int, volatile int) +{ return 0; } +int g(R, int&, const int&, volatile int&) +{ return 0; } +int g(int*, const int*, volatile int*) +{ return 0; } +int g(S, int*&, const int*&, volatile int*&) +{ return 0; } + +signed int g(T, signed int, const signed int, volatile signed int) +{ return 0; } +signed int g(T, R, signed int&, const signed int&, volatile signed int&) +{ return 0; } +signed int g(T, signed int*, const signed int*, volatile signed int*) +{ return 0; } +signed int g(T, S, signed int*&, const signed int*&, volatile signed int*&) +{ return 0; } + +unsigned int g(unsigned int, const unsigned int, volatile unsigned int) +{ return 0; } +unsigned int g(R, unsigned int&, const unsigned int&, volatile unsigned int&) +{ return 0; } +unsigned int g(unsigned int*, const unsigned int*, volatile unsigned int*) +{ return 0; } +unsigned int g(S, unsigned int*&, const unsigned int*&, volatile unsigned int*&) +{ return 0; } + +long g(long, const long, volatile long) +{ return 0; } +long g(R, long&, const long&, volatile long&) +{ return 0; } +long g(long*, const long*, volatile long*) +{ return 0; } +long g(S, long*&, const long*&, volatile long*&) +{ return 0; } + +signed long g(T, signed long, const signed long, volatile signed long) +{ return 0; } +signed long g(T, R, signed long&, const signed long&, volatile signed long&) +{ return 0; } +signed long g(T, signed long*, const signed long*, volatile signed long*) +{ return 0; } +signed long g(T, S, signed long*&, const signed long*&, volatile signed long*&) +{ return 0; } + +unsigned long g(unsigned long, const unsigned long, volatile unsigned long) +{ return 0; } +unsigned long g(S, unsigned long&, const unsigned long&, volatile unsigned long&) +{ return 0; } +unsigned long g(unsigned long*, const unsigned long*, volatile unsigned long*) +{ return 0; } +unsigned long g(S, unsigned long*&, const unsigned long*&, volatile unsigned long*&) +{ return 0; } + +#ifdef __GNUC__ +long long g(long long, const long long, volatile long long) +{ return 0; } +long long g(S, long long&, const long long&, volatile long long&) +{ return 0; } +long long g(long long*, const long long*, volatile long long*) +{ return 0; } +long long g(R, long long*&, const long long*&, volatile long long*&) +{ return 0; } + +signed long long g(T, signed long long, const signed long long, volatile signed long long) +{ return 0; } +signed long long g(T, R, signed long long&, const signed long long&, volatile signed long long&) +{ return 0; } +signed long long g(T, signed long long*, const signed long long*, volatile signed long long*) +{ return 0; } +signed long long g(T, S, signed long long*&, const signed long long*&, volatile signed long long*&) +{ return 0; } + +unsigned long long g(unsigned long long, const unsigned long long, volatile unsigned long long) +{ return 0; } +unsigned long long g(R, unsigned long long*, const unsigned long long*, volatile unsigned long long*) +{ return 0; } +unsigned long long g(unsigned long long&, const unsigned long long&, volatile unsigned long long&) +{ return 0; } +unsigned long long g(S, unsigned long long*&, const unsigned long long*&, volatile unsigned long long*&) +{ return 0; } +#endif + +float g(float, const float, volatile float) +{ return 0; } +float g(char, float&, const float&, volatile float&) +{ return 0; } +float g(float*, const float*, volatile float*) +{ return 0; } +float g(char, float*&, const float*&, volatile float*&) +{ return 0; } + +double g(double, const double, volatile double) +{ return 0; } +double g(char, double&, const double&, volatile double&) +{ return 0; } +double g(double*, const double*, volatile double*) +{ return 0; } +double g(char, double*&, const double*&, volatile double*&) +{ return 0; } + +#ifdef __GNUC__ +long double g(long double, const long double, volatile long double) +{ return 0; } +long double g(char, long double&, const long double&, volatile long double&) +{ return 0; } +long double g(long double*, const long double*, volatile long double*) +{ return 0; } +long double g(char, long double*&, const long double*&, volatile long double*&) +{ return 0; } +#endif + +class c { +public: + c(int) {}; + int i; +}; + +class c g(c, const c, volatile c) +{ return 0; } +c g(char, c&, const c&, volatile c&) +{ return 0; } +c g(c*, const c*, volatile c*) +{ return 0; } +c g(char, c*&, const c*&, volatile c*&) +{ return 0; } + +/* +void h(char = 'a') +{ } +void h(char, signed char = 'a') +{ } +void h(unsigned char = 'a') +{ } +*/ +/* +void h(char = (char)'a') +{ } +void h(char, signed char = (signed char)'a') +{ } +void h(unsigned char = (unsigned char)'a') +{ } + + +void h(short = (short)43) +{ } +void h(char, signed short = (signed short)43) +{ } +void h(unsigned short = (unsigned short)43) +{ } + +void h(int = (int)43) +{ } +void h(char, signed int = (signed int)43) +{ } +void h(unsigned int = (unsigned int)43) +{ } + + +void h(long = (long)43) +{ } +void h(char, signed long = (signed long)43) +{ } +void h(unsigned long = (unsigned long)43) +{ } + +#ifdef __GNUC__ +void h(long long = 43) +{ } +void h(char, signed long long = 43) +{ } +void h(unsigned long long = 43) +{ } +#endif + +void h(float = 4.3e-10) +{ } +void h(double = 4.3) +{ } +#ifdef __GNUC__ +void h(long double = 4.33e33) +{ } +#endif +*/ + +/* An unneeded printf() definition - actually, just a stub - used to occupy + this space. It has been removed and replaced with this comment which + exists to occupy some lines so that templates.exp won't need adjustment. */ + +class T1 { +public: + static void* operator new(size_t) throw (); + static void operator delete(void *pointer); + + void operator=(const T1&); + T1& operator=(int); + + int operator==(int) const; + int operator==(const T1&) const; + int operator!=(int) const; + int operator!=(const T1&) const; + + int operator<=(int) const; + int operator<=(const T1&) const; + int operator<(int) const; + int operator<(const T1&) const; + int operator>=(int) const; + int operator>=(const T1&) const; + int operator>(int) const; + int operator>(const T1&) const; + + void operator+(int) const; + T1& operator+(const T1&) const; + void operator+=(int) const; + T1& operator+=(const T1&) const; + + T1& operator++() const; + + void operator-(int) const; + T1& operator-(const T1&) const; + void operator-=(int) const; + T1& operator-=(const T1&) const; + + T1& operator--() const; + + void operator*(int) const; + T1& operator*(const T1&) const; + void operator*=(int) const; + T1& operator*=(const T1&) const; + + void operator/(int) const; + T1& operator/(const T1&) const; + void operator/=(int) const; + T1& operator/=(const T1&) const; + + void operator%(int) const; + T1& operator%(const T1&) const; + void operator%=(int) const; + T1& operator%=(const T1&) const; + + void operator&&(int) const; + T1& operator&&(const T1&) const; + + void operator||(int) const; + T1& operator||(const T1&) const; + + void operator&(int) const; + T1& operator&(const T1&) const; + void operator&=(int) const; + T1& operator&=(const T1&) const; + + void operator|(int) const; + T1& operator|(const T1&) const; + void operator|=(int) const; + T1& operator|=(const T1&) const; + + void operator^(int) const; + T1& operator^(const T1&) const; + void operator^=(int) const; + T1& operator^=(const T1&) const; + + T1& operator!() const; + T1& operator~() const; +}; + +void* +T1::operator new(size_t) throw () +{ return 0; } + +void +T1::operator delete(void *pointer) +{ } + +class T2 { +public: + T2(int i): integer(i) + { } + int integer; +}; + +int operator==(const T2&, const T2&) +{ return 0; } +int operator==(const T2&, char) +{ return 0; } +int operator!=(const T2&, const T2&) +{ return 0; } +int operator!=(const T2&, char) +{ return 0; } + +int operator<=(const T2&, const T2&) +{ return 0; } +int operator<=(const T2&, char) +{ return 0; } +int operator<(const T2&, const T2&) +{ return 0; } +int operator<(const T2&, char) +{ return 0; } +int operator>=(const T2&, const T2&) +{ return 0; } +int operator>=(const T2&, char) +{ return 0; } +int operator>(const T2&, const T2&) +{ return 0; } +int operator>(const T2&, char) +{ return 0; } + +T2 operator+(const T2 t, int i) +{ return t.integer + i; } +T2 operator+(const T2 a, const T2& b) +{ return a.integer + b.integer; } +T2& operator+=(T2& t, int i) +{ t.integer += i; return t; } +T2& operator+=(T2& a, const T2& b) +{ a.integer += b.integer; return a; } + +T2 operator-(const T2 t, int i) +{ return t.integer - i; } +T2 operator-(const T2 a, const T2& b) +{ return a.integer - b.integer; } +T2& operator-=(T2& t, int i) +{ t.integer -= i; return t; } +T2& operator-=(T2& a, const T2& b) +{ a.integer -= b.integer; return a; } + +T2 operator*(const T2 t, int i) +{ return t.integer * i; } +T2 operator*(const T2 a, const T2& b) +{ return a.integer * b.integer; } +T2& operator*=(T2& t, int i) +{ t.integer *= i; return t; } +T2& operator*=(T2& a, const T2& b) +{ a.integer *= b.integer; return a; } + +T2 operator/(const T2 t, int i) +{ return t.integer / i; } +T2 operator/(const T2 a, const T2& b) +{ return a.integer / b.integer; } +T2& operator/=(T2& t, int i) +{ t.integer /= i; return t; } +T2& operator/=(T2& a, const T2& b) +{ a.integer /= b.integer; return a; } + +T2 operator%(const T2 t, int i) +{ return t.integer % i; } +T2 operator%(const T2 a, const T2& b) +{ return a.integer % b.integer; } +T2& operator%=(T2& t, int i) +{ t.integer %= i; return t; } +T2& operator%=(T2& a, const T2& b) +{ a.integer %= b.integer; return a; } + +template<class T> +class T5 { +public: + T5(int); + T5(const T5<T>&); + ~T5(); + static void* operator new(size_t) throw (); + static void operator delete(void *pointer); + int value(); + + static T X; + T x; + int val; +}; + +template<class T> +T5<T>::T5(int v) +{ val = v; } + +template<class T> +T5<T>::T5(const T5<T>&) +{} + +template<class T> +T5<T>::~T5() +{} + +template<class T> +void* +T5<T>::operator new(size_t) throw () +{ return 0; } + +template<class T> +void +T5<T>::operator delete(void *pointer) +{ } + +template<class T> +int +T5<T>::value() +{ return val; } + + +#if ! defined(__GNUC__) || defined(GCC_BUG) +template<class T> +T T5<T>::X; +#endif + + + + +T5<char> t5c(1); +T5<int> t5i(2); +T5<int (*)(char, void *)> t5fi1(3); +T5<int (*)(int, double **, void *)> t5fi2(4); + + + + + + +class x { +public: + int (*manage[5])(double, + void *(*malloc)(unsigned size), + void (*free)(void *pointer)); + int (*device[5])(int open(const char *, unsigned mode, unsigned perms, int extra), + int *(*read)(int fd, void *place, unsigned size), + int *(*write)(int fd, void *place, unsigned size), + void (*close)(int fd)); +}; +T5<x> t5x(5); + +#if !defined(__GNUC__) || (__GNUC__ > 2) || (__GNUC__ == 2 && __GNUC_MINOR__ >= 6) +template class T5<char>; +template class T5<int>; +template class T5<int (*)(char, void *)>; +template class T5<int (*)(int, double **, void *)>; +template class T5<x>; +#endif + +class T7 { +public: + static int get(); + static void put(int); +}; + +int +T7::get() +{ return 1; } + +void +T7::put(int i) +{ + // nothing +} + +// More template kinds. GDB 4.16 didn't handle these, but +// Wildebeest does. Note: Assuming HP aCC is used to compile +// this file; with g++ or HP cfront or other compilers the +// demangling may not get done correctly. + +// Ordinary template, to be instantiated with different types +template<class T> +class Foo { +public: + int x; + T t; + T foo (int, T); +}; + + +template<class T> T Foo<T>::foo (int i, T tt) +{ + return tt; +} + +// Template with int parameter + +template<class T, int sz> +class Bar { +public: + int x; + T t; + T bar (int, T); +}; + + +template<class T, int sz> T Bar<T, sz>::bar (int i, T tt) +{ + if (i < sz) + return tt; + else + return 0; +} + +// function template with int parameter +template<class T> int dummy (T tt, int i) +{ + return tt; +} + +// Template with partial specializations +template<class T1, class T2> +class Spec { +public: + int x; + T1 spec (T2); +}; + +template<class T1, class T2> +T1 Spec<T1, T2>::spec (T2 t2) +{ + return 0; +} + +template<class T> +class Spec<T, T*> { +public: + int x; + T spec (T*); +}; + +template<class T> +T Spec<T, T*>::spec (T * tp) +{ + return *tp; +} + +// Template with char parameter +template<class T, char sz> +class Baz { +public: + int x; + T t; + T baz (int, T); +}; + +template<class T, char sz> T Baz<T, sz>::baz (int i, T tt) +{ + if (i < sz) + return tt; + else + return 0; +} + +// Template with char * parameter +template<class T, char * sz> +class Qux { +public: + int x; + T t; + T qux (int, T); +}; + +template<class T, char * sz> T Qux<T, sz>::qux (int i, T tt) +{ + if (sz[0] == 'q') + return tt; + else + return 0; +} + +// Template with a function pointer parameter +template<class T, int (*f)(int) > +class Qux1 { +public: + int x; + T t; + T qux (int, T); +}; + +template<class T, int (*f)(int)> T Qux1<T, f>::qux (int i, T tt) +{ + if (f != 0) + return tt; + else + return 0; +} + +// Some functions to provide as arguments to template +int gf1 (int a) { + return a * 2 + 13; +} +int gf2 (int a) { + return a * 2 + 26; +} + +char string[3]; + + +// Template for nested instantiations + +template<class T> +class Garply { +public: + int x; + T t; + T garply (int, T); +}; + +template<class T> T Garply<T>::garply (int i, T tt) +{ + if (i > x) + return tt; + else + { + x += i; + return tt; + } +} + + +int main() +{ + int i; +#ifdef usestubs + set_debug_traps(); + breakpoint(); +#endif + i = i + 1; + + // New tests added here + + Foo<int> fint={0,0}; + Foo<char> fchar={0,0}; + Foo<volatile char *> fvpchar = {0, 0}; + + Bar<int, 33> bint; + Bar<int, (4 > 3)> bint2; + + Baz<int, 's'> bazint; + Baz<char, 'a'> bazint2; + + Qux<char, string> quxint2; + Qux<int, string> quxint; + + Qux1<int, gf1> qux11; + + int x = fint.foo(33, 47); + char c = fchar.foo(33, 'x'); + volatile char * cp = fvpchar.foo(33, 0); + + int y = dummy<int> (400, 600); + + int z = bint.bar(55, 66); + z += bint2.bar(55, 66); + + c = bazint2.baz(4, 'y'); + c = quxint2.qux(4, 'z'); + + y = bazint.baz(4,3); + y = quxint.qux(4, 22); + y += qux11.qux(4, 22); + + y *= gf1(y) - gf2(y); + + Spec<int, char> sic; + Spec<int, int *> siip; + + sic.spec ('c'); + siip.spec (&x); + + Garply<int> f; + Garply<char> fc; + f.x = 13; + + Garply<Garply<char> > nf; + nf.x = 31; + + x = f.garply (3, 4); + + fc = nf.garply (3, fc); + + y = x + fc.x; + + + return 0; + +} + + + + + + + + + + + + + diff --git a/gdb/testsuite/gdb.cp/templates.exp b/gdb/testsuite/gdb.cp/templates.exp new file mode 100644 index 0000000..0ae8788 --- /dev/null +++ b/gdb/testsuite/gdb.cp/templates.exp @@ -0,0 +1,516 @@ +# Copyright 1992, 1994, 1995, 1996, 1997, 1999, 2000, 2002, 2003 +# 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# This file was written by Fred Fish. (fnf@cygnus.com) + +set ws "\[\r\n\t \]+" + +if $tracelevel then { + strace $tracelevel +} + +if { [skip_cplus_tests] } { continue } + +set testfile "templates" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +# Create and source the file that provides information about the compiler +# used to compile the test case. +if [get_compiler_info ${binfile} "c++"] { + return -1 +} +source ${binfile}.ci + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +# +# Test printing of the types of templates. +# + +proc test_ptype_of_templates {} { + global gdb_prompt + global ws + + send_gdb "ptype T5<int>\n" + gdb_expect { + -re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}T5<int> & operator=\\(T5<int> const ?&\\);${ws}T5\\(int\\);${ws}T5\\((T5<int> const|const T5<int>) ?&\\);${ws}~T5\\((void|)\\);${ws}static void \\* operator new\\(unsigned( int| long)?\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}\}\r\n$gdb_prompt $" { + pass "ptype T5<int>" + } + -re "type = class T5<int> \\{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}${ws}T5 \\(int\\);${ws}T5 \\(const class T5<int> &\\);${ws}void ~T5 \\(int\\);${ws}static void \\* new \\(unsigned int\\);${ws}static void delete \\(void ?\\*\\);${ws}int value \\((void|)\\);${ws}\\}${ws}$gdb_prompt $" { pass "ptype T5<int> -- new with unsigned int" } + -re "type = class T5<int> \\{.*public:.*static int X;.*int x;.*int val;.*T5 \\(int\\);.*T5 \\(const class T5<int> &\\);.*void ~T5 \\(int\\);.*static void \\* new \\(unsigned long\\);.*static void delete \\(void ?\\*\\);.*int value \\((void|)\\);.*\\}\r\n$gdb_prompt $" { pass "ptype T5<int> -- new with unsigned long" } + -re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;((${ws}T5<int> & operator=\\(T5<int> const ?&\\);)|(${ws}T5\\(int\\);)|(${ws}T5\\((T5<int> const|const T5<int>) ?&\\);)|(${ws}~T5\\((void|)\\);)|(${ws}static void \\* operator new\\(unsigned( int| long)?\\);)|(${ws}static void operator delete\\(void ?\\*\\);)|(${ws}int value\\((void|)\\);))*${ws}\}\r\n$gdb_prompt $" { + pass "ptype T5<int> (obsolescent gcc or gdb)" + } + -re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}void T5\\(int\\);${ws}void T5\\((T5<int> const|const T5<int>) ?&\\);${ws}~T5\\(int\\);${ws}static void \\* operator new\\(unsigned( long|)\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}\}\r\n$gdb_prompt $" { + # This also triggers gdb/1113... + kfail "gdb/1111" "ptype T5<int>" + } + -re ".*$gdb_prompt $" { + fail "ptype T5<int>" + } + timeout { + fail "ptype T5<int> (timeout)" + } + } + + send_gdb "ptype t5i\n" + gdb_expect { + -re "type = class T5<int> \\{${ws}public:${ws}static int X;${ws}int x;${ws}int val;\r\n${ws}T5\\(int\\);${ws}T5\\(T5<int> const ?&\\);${ws}~T5\\((void|)\\);${ws}static void \\* operator new\\(unsigned( int| long)?\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}\\}\r\n$gdb_prompt $" { pass "ptype T5<int> -- with several fixes from 4.17" } + -re "type = class T5<int> \\{${ws}public:${ws}static int X;${ws}int x;${ws}int val;\r\n${ws}T5 \\(int\\);${ws}T5 \\(const class T5<int> &\\);${ws}void ~T5 \\(int\\);${ws}static void \\* new \\(unsigned int\\);${ws}static void delete \\(void ?\\*\\);${ws}int value \\((void|)\\);${ws}\\}\r\n$gdb_prompt $" { pass "ptype t5i<int> -- new with unsigned int" } + -re "type = class T5<int> \\{${ws}public:${ws}static int X;${ws}int x;${ws}int val;\r\n${ws}T5 \\(int\\);${ws}T5 \\(const class T5<int> &\\);${ws}void ~T5 \\(int\\);${ws}static void \\* new \\(unsigned long\\);${ws}static void delete \\(void ?\\*\\);${ws}int value \\((void|)\\);${ws}\\}\r\n$gdb_prompt $" { pass "ptype t5i<int> -- new with unsigned long" } + -re "type = class T5<int> \{.*public:.*static int X;.*int x;.*int val;.*.*T5 \\(int\\);.*.*void ~T5 \\(int\\).*.*.*int value \\((void|)\\);.*\}.*$gdb_prompt $" { + pass "ptype t5i" + } + -re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}T5<int> & operator=\\(T5<int> const ?&\\);${ws}T5\\(int\\);${ws}T5\\((T5<int> const|const T5<int>) ?&\\);${ws}~T5\\((void|)\\);${ws}static void \\* operator new\\(unsigned( int| long)?\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}\}\r\n$gdb_prompt $" { + pass "ptype t5i" + } + -re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;((${ws}T5<int> & operator=\\(T5<int> const ?&\\);)|(${ws}T5\\(int\\);)|(${ws}T5\\(T5<int> const ?&\\);)|(${ws}~T5\\((void|)\\);)|(${ws}static void \\* operator new\\(unsigned( int| long)?\\);)|(${ws}static void operator delete\\(void ?\\*\\);)|(${ws}int value\\((void|)\\);))*${ws}\}\r\n$gdb_prompt $" { + pass "ptype t5i (obsolescent gcc or gdb)" + } + -re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}void T5\\(int\\);${ws}void T5\\((T5<int> const|const T5<int>) ?&\\);${ws}~T5\\(int\\);${ws}static void \\* operator new\\(unsigned( long|)\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}\}\r\n$gdb_prompt $" { + # This also triggers gdb/1113... + kfail "gdb/1111" "ptype T5<int>" + } + -re ".*$gdb_prompt $" { + fail "ptype t5i" + } + timeout { + fail "ptype t5i (timeout)" + } + } +} + +# +# Test breakpoint setting on template methods. +# + +proc test_template_breakpoints {} { + global gdb_prompt + global testfile + global srcdir + global hp_aCC_compiler + + send_gdb "break T5<int>::T5\n" + gdb_expect { + -re "0. cancel.*\[\r\n\]*.1. all.*\[\r\n\]*.2. T5<int>::T5\\(int\\) at .*\[\r\n\]*.3. T5<int>::T5\\((T5<int> const|const T5<int>) ?&\\) at .*\[\r\n\]*> $" { + gdb_test "0" \ + "canceled" \ + "constructor breakpoint (obsolete format!)" + } + -re ".0. cancel\[\r\n\]*.1. all\[\r\n\]*.2. T5<int>::T5\\((T5<int> const|const T5<int>) ?&\\) at .*templates.cc:.*\[\r\n\]*.3. T5<int>::T5\\(int\\) at .*templates.cc:.*\[\r\n\]*> $" { + gdb_test "0" \ + "canceled" \ + "constructor breakpoint" + } + -re "0. cancel.*\[\r\n\]*.1. all.*\[\r\n\]*.2. T5 at .*\[\r\n\]*.3. T5 at .*\[\r\n\]*> $" { + setup_kfail "gdb/1062" "*-*-*" + gdb_test "0" \ + "nonsense intended to insure that this test fails" \ + "constructor breakpoint" + } + -re ".*\n> $" { + gdb_test "0" \ + "nonsense intended to insure that this test fails" \ + "constructor breakpoint (bad menu choices)" + } + -re ".*$gdb_prompt $" { fail "constructor breakpoint" } + default { fail "constructor breakpoint (timeout)" } + } + +# See CLLbs14792 + if {$hp_aCC_compiler} {setup_xfail hppa*-*-* CLLbs14792} + + gdb_test_multiple "break T5<int>::~T5" "destructor_breakpoint" { + -re "Breakpoint.*at.* file .*${testfile}.cc, line.*$gdb_prompt $" + { + pass "destructor breakpoint" + } + -re "the class `T5<int>' does not have destructor defined\r\nHint: try 'T5<int>::~T5<TAB> or 'T5<int>::~T5<ESC-\\?>\r\n\\(Note leading single quote.\\)\r\n$gdb_prompt $" + { + kfail "gdb/1112" "destructor breakpoint" + } + } + + gdb_test "break T5<int>::value" \ + "Breakpoint.*at.* file .*${testfile}.cc, line.*" \ + "value method breakpoint" + + delete_breakpoints +} + +# +# Test calling of template methods. +# + +proc test_template_calls {} { + global gdb_prompt + global hp_aCC_compiler + + if [target_info exists gdb,cannot_call_functions] { + setup_xfail "*-*-*" 2416 + fail "This target can not call functions" + return + } + + if {!$hp_aCC_compiler} {setup_xfail hppa*-*-*} + send_gdb "print t5i.value()\n" + gdb_expect { + -re ".* = 2\[\r\n\]*$gdb_prompt $" { pass "print t5i.value()" } + -re "Cannot invoke functions on this machine.*$gdb_prompt $" { + fail "print t5i.value()" + } + -re "Cannot resolve .* to any overloaded instance.*$gdb_prompt $" { + setup_xfail hppa*-*-* CLLbs16899 + xfail "print t5i.value" + } + -re ".*$gdb_prompt $" { fail "print t5i.value()" } + timeout { fail "print t5i.value() (timeout)" } + } +} + + +proc do_tests {} { + global prms_id + global bug_id + global subdir + global objdir + global srcdir + global binfile + global gdb_prompt + global supports_template_debugging + + set prms_id 0 + set bug_id 0 + + # Start with a fresh gdb. + + gdb_exit + gdb_start + gdb_reinitialize_dir $srcdir/$subdir + gdb_load $binfile + + if { !$supports_template_debugging } { + warning "compiler lacks debugging info for templates; tests suppressed." 0 + return + } + + runto_main + + test_ptype_of_templates + test_template_breakpoints + + if [ runto_main] { + test_template_calls + } +} + +do_tests + + +# More tests for different kinds of template parameters, +# templates with partial specializations, nested templates, etc. +# These have been tested only with HP aCC. They probably won't +# work with other compilers because of differences in mangling +# schemes. +# Added by Satish Pai <pai@apollo.hp.com> 1997-09-25 +# As of 2000-06-03, C++ support has been improved to the point that g++ can +# pass all of theses, excluding what appears to be one that exposes a stabs bug. - djb + +# I don't know how HP could be passing these tests without this. They +# weren't breakpointing past a point where the below expressions were +# initialized in the actual source. - djb + +send_gdb "b 770\n" +gdb_expect { + -re ".*$gdb_prompt $" +} +send_gdb "c\n" +gdb_expect { + -re ".*$gdb_prompt $" +} +send_gdb "print fint\n" +gdb_expect { + -re "\\$\[0-9\]* = \\{x = 0, t = 0\\}\r\n$gdb_prompt $" { pass "print fint" } + -re "$gdb_prompt $" { fail "print fint" } + timeout { fail "(timeout) print fint" } +} + +send_gdb "print fvpchar\n" +gdb_expect { + -re "\\$\[0-9\]* = \\{x = 0, t = 0x0\\}\r\n$gdb_prompt $" { pass "print fvpchar" } + -re "$gdb_prompt $" { fail "print fvpchar" } + timeout { fail "(timeout) print fvpchar" } +} + +# Template Foo<T> + +# Neither stabs nor DWARF-2 contains type information about templates +# (as opposed to instantiations of templates), so in those +# circumstances we expect GDB to not find a symbol. HP has a debug +# format that contains more info, though, so it's also correct to +# print out template info. (This affects several subsequent tests as +# well.) + +# NOTE: carlton/2003-02-26: However, because of a bug in the way GDB +# handles nested types, we don't get this right in the DWARF-2 case. + +send_gdb "ptype Foo\n" +gdb_expect { + -re "type = template <(class |)T> (class |)Foo \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}\r\ntemplate instantiations:\r\n\[ \t\]*(class |)Foo<volatile char \\*>\r\n\[ \t\]*(class |)Foo<char>\r\n\[ \t\]*(class |)Foo<int>\r\n$gdb_prompt $" { pass "ptype Foo" } + -re "type = template <(class |)T> (class |)Foo \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}\r\n$gdb_prompt $" { xfail "ptype Foo" } + -re "type = class Foo<int> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int foo\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" + { # GCC 3.1, DWARF-2 output. + kfail "gdb/57" "ptype Foo" } + -re "No symbol \"Foo\" in current context.\r\n$gdb_prompt $" + { # GCC 2.95.3, stabs+ output. + pass "ptype Foo" } + -re "$gdb_prompt $" { fail "ptype Foo" } + timeout { fail "(timeout) ptype Foo" } +} +# -re "type = class Foo<int> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int foo(int, int);\r\n\\}\r\n$gdb_prompt $" + +# ptype Foo<int> + +send_gdb "ptype fint\n" +gdb_expect { + -re "type = (class |)Foo<int> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*.*int foo\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" { pass "ptype fint" } + -re "$gdb_prompt $" { fail "ptype fint" } + timeout { fail "(timeout) ptype fint" } +} + +# ptype Foo<char> + +send_gdb "ptype fchar\n" +gdb_expect { + -re "type = (class |)Foo<char> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*char t;\r\n\r\n\[ \t\]*.*char foo\\(int, char\\);\r\n\\}\r\n$gdb_prompt $" { pass "ptype fchar" } + -re "$gdb_prompt $" { fail "ptype fchar" } + timeout { fail "(timeout) ptype fchar" } +} + +# ptype Foo<volatile char *> + +send_gdb "ptype fvpchar\n" +gdb_expect { + -re "type = (class |)Foo<volatile char ?\\*> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*.*char.*\\*t;\r\n\r\n\[ \t\]*.*char \\* foo\\(int,.*char.*\\*\\);\r\n\\}\r\n$gdb_prompt $" { pass "ptype fvpchar" } + -re "$gdb_prompt $" { fail "ptype fvpchar" } + timeout { fail "(timeout) ptype fvpchar" } +} + +# print a function from Foo<volatile char *> + +# This test is sensitive to whitespace matching, so we'll do it twice, +# varying the spacing, because of PR gdb/33. + +send_gdb "print Foo<volatile char *>::foo\n" +gdb_expect { + -re "\\$\[0-9\]* = \\{.*char \\*\\((class |)Foo<volatile char ?\\*> \\*(| const), int, .*char \\*\\)\\} $hex <Foo<.*char.*\\*>::foo\\(int, .*char.*\\*\\)>\r\n$gdb_prompt $" { pass "print Foo<volatile char *>::foo" } + -re "No symbol \"Foo<volatile char \\*>\" in current context.\r\n$gdb_prompt $" + { + # This used to be a kfail gdb/33, but it shouldn't occur any more now. + fail "print Foo<volatile char *>::foo" + } + -re "$gdb_prompt $" { fail "print Foo<volatile char *>::foo" } + timeout { fail "(timeout) print Foo<volatile char *>::foo" } +} + +send_gdb "print Foo<volatile char*>::foo\n" +gdb_expect { + -re "\\$\[0-9\]* = \\{.*char \\*\\((class |)Foo<volatile char ?\\*> \\*(| const), int, .*char \\*\\)\\} $hex <Foo<.*char.*\\*>::foo\\(int, .*char.*\\*\\)>\r\n$gdb_prompt $" { pass "print Foo<volatile char*>::foo" } + -re "No symbol \"Foo<volatile char\\*>\" in current context.\r\n$gdb_prompt $" + { + # This used to be a kfail gdb/33, but it shouldn't occur any more now. + fail "print Foo<volatile char *>::foo" + } + -re "$gdb_prompt $" { fail "print Foo<volatile char*>::foo" } + timeout { fail "(timeout) print Foo<volatile char*>::foo" } +} + +# Template Bar<T, int> + +# same as Foo for g++ +send_gdb "ptype Bar\n" +gdb_expect { + -re "type = template <(class |)T, (class |)sz> (class |)Bar \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}\r\ntemplate instantiations:\r\n\[ \t\]*(class |)Bar<int,(\\(int\\)|)1>\r\n\[ \t\]*(class |)Bar<int,(\\(int\\)|)33>\r\n$gdb_prompt $" { pass "ptype Bar" } + -re "type = <(class |)T, (class |)sz> (class |)Bar \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}\r\n$gdb_prompt $" { xfail "ptype Bar" } + -re "ptype Bar\r\ntype = class Bar<int,33> {\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int bar\\(int, int\\);\r\n}\r\n$gdb_prompt $" + { # GCC 3.1, DWARF-2 output. + kfail "gdb/57" "ptype Bar" } + -re "No symbol \"Bar\" in current context.\r\n$gdb_prompt $" + { # GCC 2.95.3, stabs+ output. + pass "ptype Bar" } + -re "$gdb_prompt $" { fail "ptype Bar" } + timeout { fail "(timeout) ptype Bar" } +} + + +# ptype Bar<int,33> + +send_gdb "ptype bint\n" +gdb_expect { + -re "type = (class |)Bar<int,(\\(int\\)|)33> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*.*int bar\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" { pass "ptype bint" } + -re "$gdb_prompt $" { fail "ptype bint" } + timeout { fail "(timeout) ptype bint" } +} + +# ptype Bar<int, (4>3)> + +send_gdb "ptype bint2\n" +gdb_expect { + -re "type = (class |)Bar<int,(\\(int\\)|)1> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*.*int bar\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" { pass "ptype bint2" } + -re "$gdb_prompt $" { fail "ptype bint2" } + timeout { fail "(timeout) ptype bint2" } +} + +# Template Baz<T, char> + +# Same as Foo, for g++ +send_gdb "ptype Baz\n" +gdb_expect { + -re "type = template <(class |)T, (class |)sz> (class |)Baz \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}\r\ntemplate instantiations:\r\n\[ \t\]*(class |)Baz<char,(\\(char\\)|)97>\r\n\[ \t\]*(class |)Baz<int,(\\(char\\)|)115>\r\n$gdb_prompt $" { pass "ptype Baz" } + -re "type = <(class |)T, (class |)sz> (class |)Baz \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}\r\n$gdb_prompt $" { xfail "ptype Baz" } + -re "type = class Baz<int,'s'> {\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int baz\\(int, int\\);\r\n}\r\n$gdb_prompt $" + { # GCC 3.1, DWARF-2 output. + kfail "gdb/57" "ptype Baz" } + -re "No symbol \"Baz\" in current context.\r\n$gdb_prompt $" + { # GCC 2.95.3, stabs+ output. + pass "ptype Baz" } + -re "$gdb_prompt $" { fail "ptype Baz" } + timeout { fail "(timeout) ptype Baz" } +} + + +# ptype Baz<int, 's'> + +send_gdb "ptype bazint\n" +gdb_expect { + -re "type = (class |)Baz<int,(\\(char\\)|)(115|\\'s\\')> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*.*int baz\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" { pass "ptype bazint" } + -re "$gdb_prompt $" { fail "ptype bazint" } + timeout { fail "(timeout) ptype bazint" } +} + +# ptype Baz<char, 'a'> + +send_gdb "ptype bazint2\n" +gdb_expect { + -re "type = (class |)Baz<char,(\\(char\\)|)(97|\\'a\\')> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*char t;\r\n\r\n\[ \t\]*.*char baz\\(int, char\\);\r\n\\}\r\n$gdb_prompt $" { pass "ptype bazint2" } + -re "$gdb_prompt $" { fail "ptype bazint2" } + timeout { fail "(timeout) ptype bazint2" } +} + +# Template Qux<T, int (*f)(int) > +# Same as Foo for g++ +send_gdb "ptype Qux\n" +gdb_expect { + -re "type = template <(class |)T, (class |)sz> (class |)Qux \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}\r\ntemplate instantiations:\r\n\[ \t\]*(class |)Qux<int,&string>\r\n\[ \t\]*(class |)Qux<char,&string>\r\n$gdb_prompt $" { pass "ptype Qux" } + -re ".*type = template <(class |)T.*, (class |)sz> (class |)Qux \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}.*$gdb_prompt $" { pass "ptype Qux" } + -re "type = class Qux<char,&string> {\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*char t;\r\n\r\n\[ \t\]*char qux\\(int, char\\);\r\n}\r\n$gdb_prompt $" + { # GCC 3.1, DWARF-2 output. + kfail "gdb/57" "ptype Qux" } + -re "No symbol \"Qux\" in current context.\r\n$gdb_prompt $" + { # GCC 2.95.3, stabs+ output. + pass "ptype Qux" } + -re "$gdb_prompt $" { fail "ptype Qux" } + timeout { fail "(timeout) ptype Qux" } +} + +# pt Qux<int,&string> + +send_gdb "ptype quxint\n" +gdb_expect { + -re "type = class Qux<int,&string> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*.*int qux\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" { pass "ptype quxint" } + -re "$gdb_prompt $" { fail "ptype quxint" } + timeout { fail "(timeout) ptype quxint" } +} + +# pt Qux<char,0> + +# commented out this as quxint2 declaration was commented out in +# templates.exp -- ovidiu +# send_gdb "ptype quxint2\n" +# gdb_expect { +# -re "type = class Qux<char,&string> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*char t;\r\n\r\n\[ \t\]*char qux\\(int, char\\);\r\n\\}\r\n$gdb_prompt $" { pass "ptype quxint2" } +# -re "$gdb_prompt $" { fail "ptype quxint2" } +# timeout { fail "(timeout) ptype quxint2" } +# } + +# Template Spec<T1, T2> + +# Same as Foo for g++ +send_gdb "ptype Spec\n" +gdb_expect { + -re "type = template <(class |)T1, (class |)T2> (class |)Spec \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\\}\r\ntemplate instantiations:\r\n\[ \t\]*(class |)Spec<int,int \\*>\r\n\[ \t\]*(class |)Spec<int,char>\r\n$gdb_prompt $" { pass "ptype Spec" } + -re "type = <(class |)T1, (class |)T2> (class |)Spec \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\\}\r\n$gdb_prompt $" { xfail "ptype Spec" } + -re "type = class Spec<int,char> {\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\r\n\[ \t\]*int spec\\(char\\);\r\n}\r\n$gdb_prompt $" + { # GCC 3.1, DWARF-2 output. + kfail "gdb/57" "ptype Spec" } + -re "No symbol \"Spec\" in current context.\r\n$gdb_prompt $" + { # GCC 2.95.3, stabs+ output. + pass "ptype Spec" } + -re "$gdb_prompt $" { fail "ptype Spec" } + timeout { fail "(timeout) ptype Spec" } +} + +# pt Spec<char,0> + +send_gdb "ptype siip\n" +gdb_expect { + -re "type = class Spec<int,int ?\\*> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\r\n\[ \t\]*.*int spec\\(int ?\\*\\);\r\n\\}\r\n$gdb_prompt $" { pass "ptype siip" } + -re "$gdb_prompt $" { fail "ptype siip" } + timeout { fail "(timeout) ptype siip" } +} + +# pt Garply<int> + +send_gdb "ptype Garply<int>\n" +gdb_expect { + -re "type = class Garply<int> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*.*int garply\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" { pass "ptype Garply<int>" } + -re "$gdb_prompt $" { fail "ptype Garply<int>" } + timeout { fail "(timeout) ptype Garply<int>" } +} + +# ptype of nested template name + +send_gdb "ptype Garply<Garply<char> >\n" +gdb_expect { + -re "type = (class |)Garply<Garply<char> > \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*.*(class |)Garply<char> t;\r\n\r\n\[ \t\]*.*(class |)Garply<char> garply\\(int, (class |)Garply<char>\\);\r\n\\}\r\n$gdb_prompt $" { pass "ptype Garply<Garply<char> >" } + -re "$gdb_prompt $" { fail "ptype Garply<Garply<char> >" } + timeout { fail "(timeout) ptype Garply<Garply<char> >" } +} + +# print out a function from a nested template name + +send_gdb "print Garply<Garply<char> >::garply\n" +gdb_expect { + -re "\\$\[0-9\]* = \\{(class |)Garply<char> \\((class |)Garply<Garply<char> > \\*(| const), int, (class |)Garply<char>\\)\\} $hex <Garply<Garply<char>\[ \t\]*>::garply\\(int, (class |)Garply<char>\\)>\r\n$gdb_prompt $" { pass "print Garply<Garply<char> >::garply" } + -re ".*$gdb_prompt $" { fail "print Garply<Garply<char> >::garply" } + timeout { fail "print Garply<Garply<char> >::garply (timeout)" } +} + +# djb - 06-03-2000 +# Now should work fine +send_gdb "break Garply<Garply<char> >::garply\n" +gdb_expect { + -re "Breakpoint \[0-9\]* at $hex: file .*templates.cc, line.*\r\n$gdb_prompt $" { pass "break Garply<Garply<char> >::garply" } + -re ".*$gdb_prompt $" { fail "break Garply<Garply<char> >::garply" } + timeout { fail "break Garply<Garply<char> >::garply (timeout)" } +} diff --git a/gdb/testsuite/gdb.cp/try_catch.cc b/gdb/testsuite/gdb.cp/try_catch.cc new file mode 100644 index 0000000..e13dd64 --- /dev/null +++ b/gdb/testsuite/gdb.cp/try_catch.cc @@ -0,0 +1,121 @@ +// 2002-05-27 + +#include <exception> +#include <stdexcept> +#include <string> + +enum region { oriental, egyptian, greek, etruscan, roman }; + +// Test one. +class gnu_obj_1 +{ +public: + typedef region antiquities; + const bool test; + const int key1; + long key2; + + antiquities value; + + gnu_obj_1(antiquities a, long l): test(true), key1(5), key2(l), value(a) {} +}; + +// Test two. +template<typename T> +class gnu_obj_2: public virtual gnu_obj_1 +{ +public: + antiquities value_derived; + + gnu_obj_2(antiquities b): gnu_obj_1(oriental, 7), value_derived(b) { } +}; + +// Test three. +template<typename T> +class gnu_obj_3 +{ +public: + typedef region antiquities; + gnu_obj_2<int> data; + + gnu_obj_3(antiquities b): data(etruscan) { } +}; + +int main() +{ + bool test = true; + const int i = 5; + int j = i; + gnu_obj_2<long> test2(roman); + gnu_obj_3<long> test3(greek); + + // 1 + try + { + ++j; + throw gnu_obj_1(egyptian, 4589); // marker 1-throw + } + catch (gnu_obj_1& obj) + { + ++j; + if (obj.value != egyptian) // marker 1-catch + test &= false; + if (obj.key2 != 4589) + test &= false; + } + catch (...) + { + j = 0; + test &= false; + } + + // 2 + try + { + ++j; // marker 2-start + try + { + ++j; // marker 2-next + try + { + ++j; + throw gnu_obj_1(egyptian, 4589); // marker 2-throw + } + catch (gnu_obj_1& obj) + { + ++j; + if (obj.value != egyptian) // marker 2-catch + test &= false; + if (obj.key2 != 4589) + test &= false; + } + } + catch (gnu_obj_1& obj) + { + ++j; + if (obj.value != egyptian) + test &= false; + if (obj.key2 != 4589) + test &= false; + } + } + catch (...) + { + j = 0; + test &= false; + } + + // 3 use standard library + using namespace std; + try + { + if (j < 100) + throw invalid_argument("gdb.1"); // marker 3-throw + } + catch (exception& obj) + { + if (obj.what() != "gdb.1") // marker 3-catch + test &= false; + } + return 0; +} diff --git a/gdb/testsuite/gdb.cp/try_catch.exp b/gdb/testsuite/gdb.cp/try_catch.exp new file mode 100644 index 0000000..1473e20 --- /dev/null +++ b/gdb/testsuite/gdb.cp/try_catch.exp @@ -0,0 +1,82 @@ +# Copyright 2002 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Tests for member data +# 2002-05-27 Benjamin Kosnik <bkoz@redhat.com> + +# This file is part of the gdb testsuite + +if $tracelevel then { + strace $tracelevel + } + +if { [skip_cplus_tests] } { continue } + +# +# test running programs +# +set prms_id 0 +set bug_id 0 + +set testfile "try_catch" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if [get_compiler_info ${binfile} "c++"] { + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + + +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + +gdb_breakpoint [gdb_get_line_number "marker 1-throw"] +gdb_continue_to_breakpoint "marker 1-throw" + +gdb_breakpoint [gdb_get_line_number "marker 1-catch"] +gdb_continue_to_breakpoint "marker 1-catch" + +gdb_breakpoint [gdb_get_line_number "marker 2-start"] +gdb_continue_to_breakpoint "marker 2-start" + +gdb_breakpoint [gdb_get_line_number "marker 2-next"] +gdb_continue_to_breakpoint "marker 2-next" + +gdb_breakpoint [gdb_get_line_number "marker 2-throw"] +gdb_continue_to_breakpoint "marker 2-throw" + +gdb_breakpoint [gdb_get_line_number "marker 2-catch"] +gdb_continue_to_breakpoint "marker 2-catch" + +gdb_breakpoint [gdb_get_line_number "marker 3-throw"] +gdb_continue_to_breakpoint "marker 3-throw" + +gdb_breakpoint [gdb_get_line_number "marker 3-catch"] +gdb_continue_to_breakpoint "marker 3-catch" + +gdb_exit +return 0 diff --git a/gdb/testsuite/gdb.cp/userdef.cc b/gdb/testsuite/gdb.cp/userdef.cc new file mode 100644 index 0000000..0bb88a2 --- /dev/null +++ b/gdb/testsuite/gdb.cp/userdef.cc @@ -0,0 +1,341 @@ +#include <iostream> + +using namespace std; + +void marker1() +{ + return; +} + +class A1 { + int x; + int y; + +friend ostream& operator<<(ostream& outs, A1 one); + +public: + + A1(int a, int b) + { + x=a; + y=b; + } + +A1 operator+=(int value); +A1 operator+(const A1&); +A1 operator-(const A1&); +A1 operator%(const A1&); +int operator==(const A1&); +int operator!=(const A1&); +int operator&&(const A1&); +int operator||(const A1&); +A1 operator<<(int); +A1 operator>>(int); +A1 operator|(const A1&); +A1 operator^(const A1&); +A1 operator&(const A1&); +int operator<(const A1&); +int operator<=(const A1&); +int operator>=(const A1&); +int operator>(const A1&); +A1 operator*(const A1&); +A1 operator/(const A1&); +A1 operator=(const A1&); + +A1 operator~(); +A1 operator-(); +int operator!(); +A1 operator++(); +A1 operator++(int); +A1 operator--(); +A1 operator--(int); + +}; + + +A1 A1::operator+(const A1& second) +{ + A1 sum(0,0); + sum.x = x + second.x; + sum.y = y + second.y; + + return (sum); +} + +A1 A1::operator*(const A1& second) +{ + A1 product(0,0); + product.x = this->x * second.x; + product.y = this->y * second.y; + + return product; +} + +A1 A1::operator-(const A1& second) +{ + A1 diff(0,0); + diff.x = x - second.x; + diff.y = y - second.y; + + return diff; +} + +A1 A1::operator/(const A1& second) +{ + A1 div(0,0); + div.x = x / second.x; + div.y = y / second.y; + + return div; +} + +A1 A1::operator%(const A1& second) +{ + A1 rem(0,0); + rem.x = x % second.x; + rem.y = y % second.y; + + return rem; +} + +int A1::operator==(const A1& second) +{ + int a = (x == second.x); + int b = (y == second.y); + + return (a && b); +} + +int A1::operator!=(const A1& second) +{ + int a = (x != second.x); + int b = (y != second.y); + + return (a || b); +} + +int A1::operator&&(const A1& second) +{ + return ( x && second.x); +} + +int A1::operator||(const A1& second) +{ + return ( x || second.x); +} + +A1 A1::operator<<(int value) +{ + A1 lshft(0,0); + lshft.x = x << value; + lshft.y = y << value; + + return lshft; +} + +A1 A1::operator>>(int value) +{ + A1 rshft(0,0); + rshft.x = x >> value; + rshft.y = y >> value; + + return rshft; +} + +A1 A1::operator|(const A1& second) +{ + A1 abitor(0,0); + abitor.x = x | second.x; + abitor.y = y | second.y; + + return abitor; +} + +A1 A1::operator^(const A1& second) +{ + A1 axor(0,0); + axor.x = x ^ second.x; + axor.y = y ^ second.y; + + return axor; +} + +A1 A1::operator&(const A1& second) +{ + A1 abitand(0,0); + abitand.x = x & second.x; + abitand.y = y & second.y; + + return abitand; +} + +int A1::operator<(const A1& second) +{ + A1 b(0,0); + b.x = 3; + return (x < second.x); +} + +int A1::operator<=(const A1& second) +{ + return (x <= second.x); +} + +int A1::operator>=(const A1& second) +{ + return (x >= second.x); +} + +int A1::operator>(const A1& second) +{ + return (x > second.x); +} + +int A1::operator!(void) +{ + return (!x); +} + +A1 A1::operator-(void) +{ + A1 neg(0,0); + neg.x = -x; + neg.y = -y; + + return (neg); +} + +A1 A1::operator~(void) +{ + A1 acompl(0,0); + acompl.x = ~x; + acompl.y = ~y; + + return (acompl); +} + +A1 A1::operator++() // pre increment +{ + x = x +1; + + return (*this); +} + +A1 A1::operator++(int) // post increment +{ + y = y +1; + + return (*this); +} + +A1 A1::operator--() // pre decrement +{ + x = x -1; + + return (*this); +} + +A1 A1::operator--(int) // post decrement +{ + y = y -1; + + return (*this); +} + + +A1 A1::operator=(const A1& second) +{ + + x = second.x; + y = second.y; + + return (*this); +} + +A1 A1::operator+=(int value) +{ + + x += value; + y += value; + + return (*this); +} + +ostream& operator<<(ostream& outs, A1 one) +{ + return (outs << endl << "x = " << one.x << endl << "y = " << one.y << endl << "-------" << endl); +} + +int main (void) +{ + A1 one(2,3); + A1 two(4,5); + A1 three(0,0); + int val; + + marker1(); // marker1-returns-here + cout << one; // marker1-returns-here + cout << two; + three = one + two; + cout << "+ " << three; + three = one - two; + cout << "- " << three; + three = one * two; + cout <<"* " << three; + three = one / two; + cout << "/ " << three; + three = one % two; + cout << "% " << three; + three = one | two; + cout << "| " <<three; + three = one ^ two; + cout << "^ " <<three; + three = one & two; + cout << "& "<< three; + + val = one && two; + cout << "&& " << val << endl << "-----"<<endl; + val = one || two; + cout << "|| " << val << endl << "-----"<<endl; + val = one == two; + cout << " == " << val << endl << "-----"<<endl; + val = one != two; + cout << "!= " << val << endl << "-----"<<endl; + val = one >= two; + cout << ">= " << val << endl << "-----"<<endl; + val = one <= two; + cout << "<= " << val << endl << "-----"<<endl; + val = one < two; + cout << "< " << val << endl << "-----"<<endl; + val = one > two; + cout << "> " << val << endl << "-----"<<endl; + + three = one << 2; + cout << "lsh " << three; + three = one >> 2; + cout << "rsh " << three; + + three = one; + cout << " = "<< three; + three += 5; + cout << " += "<< three; + + val = (!one); + cout << "! " << val << endl << "-----"<<endl; + three = (-one); + cout << "- " << three; + three = (~one); + cout << " ~" << three; + three++; + cout << "postinc " << three; + three--; + cout << "postdec " << three; + + --three; + cout << "predec " << three; + ++three; + cout << "preinc " << three; + + return 0; + +} diff --git a/gdb/testsuite/gdb.cp/userdef.exp b/gdb/testsuite/gdb.cp/userdef.exp new file mode 100644 index 0000000..4575249 --- /dev/null +++ b/gdb/testsuite/gdb.cp/userdef.exp @@ -0,0 +1,148 @@ +# Tests of overloaded operators resolution. +# Copyright 1998, 1999, 2002 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# written by Elena Zannoni (ezannoni@cygnus.com) +# +# source file "userdef.cc" +# + +if $tracelevel then { + strace $tracelevel +} + +if { [skip_cplus_tests] } { continue } + +set testfile "userdef" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + + +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + +send_gdb "break marker1\n" ; gdb_expect -re ".*$gdb_prompt $" + send_gdb "cont\n" + gdb_expect { + -re "Break.* marker1(\\(\\)|) \\(\\) at .*:$decimal.*$gdb_prompt $" { + send_gdb "up\n" + gdb_expect { + -re ".*$gdb_prompt $" { pass "up from marker1" } + timeout { fail "up from marker1" } + } + } + -re "$gdb_prompt $" { fail "continue to marker1" } + timeout { fail "(timeout) continue to marker1" } + } + + +gdb_test "print one + two" "\\\$\[0-9\]* = {x = 6, y = 8}" + +# If GDB fails to restore the selected frame properly after the +# inferior function call above (see GDB PR 1155 for an explanation of +# why this might happen), all the subsequent tests will fail. We +# should detect report that failure, but let the marker call finish so +# that the rest of the tests can run undisturbed. +gdb_test_multiple "frame" "re-selected 'main' frame after inferior call" { + -re "#0 marker1.*$gdb_prompt $" { + setup_kfail "gdb/1155" s390-*-linux-gnu + fail "re-selected 'main' frame after inferior call" + gdb_test "finish" ".*main.*at .*userdef.cc:.*// marker1-returns-here.*" \ + "finish call to marker1" + } + -re "#1 ($hex in )?main.*$gdb_prompt $" { + pass "re-selected 'main' frame after inferior call" + } +} + +gdb_test "print one - two" "\\\$\[0-9\]* = {x = -2, y = -2}" + +gdb_test "print one * two" "\\\$\[0-9\]* = {x = 8, y = 15}" + +gdb_test "print one / two" "\\\$\[0-9\]* = {x = 0, y = 0}" + +gdb_test "print one % two" "\\\$\[0-9\]* = {x = 2, y = 3}" + +gdb_test "print one && two" "\\\$\[0-9\]* = 1\[\r\n\]" + +gdb_test "print one || two" "\\\$\[0-9\]* = 1\[\r\n\]" + +gdb_test "print one & two" "\\\$\[0-9\]* = {x = 0, y = 1}" + +gdb_test "print one | two" "\\\$\[0-9\]* = {x = 6, y = 7}" + +gdb_test "print one ^ two" "\\\$\[0-9\]* = {x = 6, y = 6}" + +gdb_test "print one < two" "\\\$\[0-9\]* = 1\[\r\n\]" + +gdb_test "print one <= two" "\\\$\[0-9\]* = 1\[\r\n\]" + +gdb_test "print one > two" "\\\$\[0-9\]* = 0\[\r\n\]" + +gdb_test "print one >= two" "\\\$\[0-9\]* = 0\[\r\n\]" + +gdb_test "print one == two" "\\\$\[0-9\]* = 0\[\r\n\]" + +gdb_test "print one != two" "\\\$\[0-9\]* = 1\[\r\n\]" + +# Can't really check the output of this one without knowing +# target integer width. Make sure we don't try to call +# the iostreams operator instead, though. +gdb_test "print one << 31" "\\\$\[0-9\]* = {x = -?\[0-9\]*, y = -?\[0-9\]*}" + +# Should be fine even on < 32-bit targets. +gdb_test "print one >> 31" "\\\$\[0-9\]* = {x = 0, y = 0}" + +gdb_test "print !one" "\\\$\[0-9\]* = 0\[\r\n\]" + +# Assumes 2's complement. So does everything... +gdb_test "print ~one" "\\\$\[0-9\]* = {x = -3, y = -4}" + +gdb_test "print -one" "\\\$\[0-9\]* = {x = -2, y = -3}" + +gdb_test "print one++" "\\\$\[0-9\]* = {x = 2, y = 4}" + +gdb_test "print ++one" "\\\$\[0-9\]* = {x = 3, y = 4}" + +gdb_test "print one--" "\\\$\[0-9\]* = {x = 3, y = 3}" + +gdb_test "print --one" "\\\$\[0-9\]* = {x = 2, y = 3}" + +gdb_test "print one += 7" "\\\$\[0-9\]* = {x = 9, y = 10}" + +gdb_test "print two = one" "\\\$\[0-9\]* = {x = 9, y = 10}" + +# Check that GDB tolerates whitespace in operator names. +gdb_test "break A1::'operator+'" ".*Breakpoint $decimal at.*" +gdb_test "break A1::'operator +'" ".*Breakpoint $decimal at.*" + +gdb_exit +return 0 diff --git a/gdb/testsuite/gdb.cp/virtfunc.cc b/gdb/testsuite/gdb.cp/virtfunc.cc new file mode 100644 index 0000000..005de9d --- /dev/null +++ b/gdb/testsuite/gdb.cp/virtfunc.cc @@ -0,0 +1,201 @@ +// Pls try the following program on virtual functions and try to do print on +// most of the code in main(). Almost none of them works ! + +// +// The inheritance structure is: +// +// V : VA VB +// A : (V) +// B : A +// D : AD (V) +// C : (V) +// E : B (V) D C +// + +class VA +{ +public: + int va; +}; + +class VB +{ +public: + int vb; + int fvb(); + virtual int vvb(); +}; + +class V : public VA, public VB +{ +public: + int f(); + virtual int vv(); + int w; +}; + +class A : virtual public V +{ +public: + virtual int f(); +private: + int a; +}; + +class B : public A +{ +public: + int f(); +private: + int b; +}; + +class C : public virtual V +{ +public: + int c; +}; + +class AD +{ +public: + virtual int vg() = 0; +}; + +class D : public AD, virtual public V +{ +public: + static void s(); + virtual int vg(); + virtual int vd(); + int fd(); + int d; +}; + +class E : public B, virtual public V, public D, public C +{ +public: + int f(); + int vg(); + int vv(); + int e; +}; + +D dd; +D* ppd = ⅆ +AD* pAd = ⅆ + +A a; +B b; +C c; +D d; +E e; +V v; +VB vb; + + +A* pAa = &a; +A* pAe = &e; + +B* pBe = &e; + +D* pDd = &d; +D* pDe = &e; + +V* pVa = &a; +V* pVv = &v; +V* pVe = &e; +V* pVd = &d; + +AD* pADe = &e; + +E* pEe = &e; + +VB* pVB = &vb; + +void init() +{ + a.vb = 1; + b.vb = 2; + c.vb = 3; + d.vb = 4; + e.vb = 5; + v.vb = 6; + vb.vb = 7; + + d.d = 1; + e.d = 2; +} + +extern "C" int printf(const char *, ...); + +int all_count = 0; +int failed_count = 0; + +#define TEST(EXPR, EXPECTED) \ + ret = EXPR; \ + if (ret != EXPECTED) {\ + printf("Failed %s is %d, should be %d!\n", #EXPR, ret, EXPECTED); \ + failed_count++; } \ + all_count++; + +int ret; + +void test_calls() +{ + TEST(pAe->f(), 20); + TEST(pAa->f(), 1); + + TEST(pDe->vg(), 202); + TEST(pADe->vg(), 202); + TEST(pDd->vg(), 101); + + TEST(pEe->vvb(), 411); + + TEST(pVB->vvb(), 407); + + TEST(pBe->vvb(), 411); + TEST(pDe->vvb(), 411); + + TEST(pEe->vd(), 282); + TEST(pEe->fvb(), 311); + + TEST(pEe->D::vg(), 102); + printf("Did %d tests, of which %d failed.\n", all_count, failed_count); +} +#ifdef usestubs +extern "C" { + void set_debug_traps(); + void breakpoint(); +}; +#endif + +int main() +{ +#ifdef usestubs + set_debug_traps(); + breakpoint(); +#endif + init(); + + e.w = 7; + e.vb = 11; + + test_calls(); + return 0; + +} + +int A::f() {return 1;} +int B::f() {return 2;} +void D::s() {} +int E::f() {return 20;} +int D::vg() {return 100+d;} +int E::vg() {return 200+d;} +int V::f() {return 600+w;} +int V::vv() {return 400+w;} +int E::vv() {return 450+w;} +int D::fd() {return 250+d;} +int D::vd() {return 280+d;} +int VB::fvb() {return 300+vb;} +int VB::vvb() {return 400+vb;} diff --git a/gdb/testsuite/gdb.cp/virtfunc.exp b/gdb/testsuite/gdb.cp/virtfunc.exp new file mode 100644 index 0000000..dbd575c --- /dev/null +++ b/gdb/testsuite/gdb.cp/virtfunc.exp @@ -0,0 +1,948 @@ +# Copyright 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2003 +# 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# This file was written by Fred Fish. (fnf@cygnus.com) + +set ws "\[\r\n\t \]+" +set nl "\[\r\n\]+" + +if $tracelevel then { + strace $tracelevel +} + +if { [skip_cplus_tests] } { continue } + +set testfile "virtfunc" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if [get_compiler_info ${binfile} "c++"] { + return -1 +} + +source ${binfile}.ci + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {c++ debug}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +proc gdb_virtfunc_init {} { + global srcdir subdir binfile + global gdb_prompt + + gdb_reinitialize_dir $srcdir/$subdir + gdb_load $binfile + + send_gdb "set language c++\n" + gdb_expect -re "$gdb_prompt $" + send_gdb "set width 0\n" + gdb_expect -re "$gdb_prompt $" +} + +proc gdb_virtfunc_restart {} { + gdb_exit; + gdb_start; + gdb_virtfunc_init; + runto 'test_calls'; +} + +# +# Test printing of the types of various classes. +# + +proc test_ptype_of_classes {} { + global gdb_prompt + global ws + global nl + + # This used to be a fail if it printed "struct" not "class". But + # since this struct doesn't use any special C++ features, it is + # considered right for GDB to print it as "struct". + send_gdb "ptype VA\n" + gdb_expect { + -re "type = (struct|class) VA \{(${ws}public:|)${ws}int va;${ws}VA & operator=\\(VA const ?&\\);${ws}VA\\((VA const|const VA) ?&\\);${ws}VA\\((void|)\\);${ws}\}.*$gdb_prompt $" { + pass "ptype VA" + } + -re "type = (struct|class) VA \{(${ws}public:|)${ws}int va;((${ws}VA & operator=\\(VA const ?&\\);)|(${ws}VA\\(VA const ?&\\);)|(${ws}VA\\((void|)\\);))*${ws}\}.*$gdb_prompt $" { + pass "ptype VA (obsolescent gcc or gdb)" + } + -re ".*$gdb_prompt $" { + fail "ptype VA" + } + timeout { + fail "ptype VA (timeout)" + } + } + + send_gdb "ptype VB\n" + gdb_expect { + -re "type = class VB \{${ws}public:${ws}int vb;${ws}VB & operator=\\(VB const ?&\\);${ws}VB\\((VB const|const VB) ?&\\);${ws}VB\\((void|)\\);${ws}int fvb\\((void|)\\);${ws}virtual int vvb\\((void|)\\);${ws}\}.*$gdb_prompt $" { + pass "ptype VB" + } + -re "type = class VB \{${ws}public:${ws}int vb;${ws}int fvb \\((void|)\\);${ws}virtual int vvb \\((void|)\\);${ws}\}.*$gdb_prompt $" { + pass "ptype VB (aCC)" + } + -re "type = class VB \{${ws}public:${ws}int vb;((${ws}VB & operator=\\(VB const ?&\\);)|(${ws}VB\\(VB const ?&\\);)|(${ws}VB\\((void|)\\);)|(${ws}int fvb\\((void|)\\);)|(${ws}virtual int vvb\\((void|)\\);))*${ws}\}.*$gdb_prompt $" { + pass "ptype VB (obsolescent gcc or gdb)" + } + -re ".*$gdb_prompt $" { + fail "ptype VB" + } + timeout { + fail "ptype VB (timeout)" + } + } + + send_gdb "ptype V\n" + gdb_expect { + -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;${ws}V & operator=\\(V const ?&\\);${ws}V\\((V const|const V) ?&\\);${ws}V\\((void|)\\);${ws}int f\\((void|)\\);${ws}virtual int vv\\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype V" + } + -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;${ws}int f \\((void|)\\);${ws}virtual int vv \\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype V (aCC)" + } + -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;((${ws}V & operator=\\(V const ?&\\);)|(${ws}V\\(V const ?&\\);)|(${ws}V\\((void|)\\);)|(${ws}int f\\((void|)\\);)|(${ws}virtual int vv\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" { + pass "ptype V (obsolescent gcc or gdb)" + } + -re ".*$gdb_prompt $" { + fail "ptype V" + } + timeout { + fail "ptype V (timeout)" + } + } + + # The format of a g++ virtual base pointer. + set vbptr "(_vb\[$.\]|__vb_)\[0-9\]?" + + send_gdb "ptype A\n" + gdb_expect { + -re "type = class A : public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}int a;${ws}public:${ws}A & operator=\\(A const ?&\\);${ws}A\\(int, A const ?&\\);${ws}A\\(int\\);${ws}virtual int f\\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype A" + } + -re "type = class A : public virtual V \{${ws}private:${ws}int a;${ws}public:${ws}A & operator=\\(A const ?&\\);${ws}A\\((A const|const A) ?&\\);${ws}A\\((void|)\\);${ws}virtual int f\\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype A" + } + -re "type = class A : public virtual V \{${ws}private:${ws}int a;${ws}public:${ws}virtual int f\\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype A (aCC)" + } + -re "type = class A : public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}int a;${ws}public:((${ws}A & operator=\\(A const ?&\\);)|(${ws}A\\(int, A const ?&\\);)|(${ws}A\\(int\\);)|(${ws}virtual int f\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" { + pass "ptype A (obsolescent gcc or gdb)" + } + -re "type = class A : public virtual V \{${ws}private:${ws}V \\*${vbptr}FOO;${ws}int a;${ws}public:${ws}virtual int f.void.;${ws}\}$nl$gdb_prompt $" { + # This happens because the type is defined only after it is + # too late. + fail "ptype A (known failure with gcc cygnus-2.4.5-930417)" + # Many of the rest of these tests have the same problem. + return 0 + } + -re ".*$gdb_prompt $" { + fail "ptype A" + } + timeout { + fail "ptype A (timeout)" + } + } + + send_gdb "ptype B\n" + gdb_expect { + -re "type = class B : public A \{${ws}private:${ws}int b;${ws}public:${ws}B & operator=\\(B const ?&\\);${ws}B\\(int, B const ?&\\);${ws}B\\(int\\);${ws}virtual int f\\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype B" + } + -re "type = class B : public A \{${ws}private:${ws}int b;${ws}public:${ws}B & operator=\\(B const ?&\\);${ws}B\\((B const|const B) ?&\\);${ws}B\\((void|)\\);${ws}virtual int f\\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype B" + } + -re "type = class B : public A \{${ws}private:${ws}int b;${ws}public:${ws}virtual int f \\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype B (aCC)" + } + -re "type = class B : public A \{${ws}private:${ws}int b;${ws}public:((${ws}B & operator=\\(B const ?&\\);)|(${ws}B\\(int, B const ?&\\);)|(${ws}B\\(int\\);)|(${ws}virtual int f\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" { + pass "ptype B (obsolescent gcc or gdb)" + } + -re ".*$gdb_prompt $" { + fail "ptype B" + } + timeout { + fail "ptype B (timeout)" + } + } + + send_gdb "ptype C\n" + gdb_expect { + -re "type = class C : public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}public:${ws}int c;${ws}C & operator=\\(C const ?&\\);${ws}C\\(int, C const ?&\\);${ws}C\\(int\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype C" + } + -re "type = class C : public virtual V \{${ws}public:${ws}int c;${ws}C & operator=\\(C const ?&\\);${ws}C\\((C const|const C) ?&\\);${ws}C\\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype C" + } + -re "type = class C : public virtual V \{${ws}public:${ws}int c;${ws}\}$nl$gdb_prompt $" { + pass "ptype C (aCC)" + } + -re "type = class C : public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}public:${ws}int c;((${ws}C & operator=\\(C const ?&\\);)|(${ws}C\\(int, C const ?&\\);)|(${ws}C\\(int\\);))*${ws}\}$nl$gdb_prompt $" { + pass "ptype C (obsolescent gcc or gdb)" + } + -re ".*$gdb_prompt $" { + fail "ptype C" + } + timeout { + fail "ptype C (timeout)" + } + } + + send_gdb "ptype AD\n" + gdb_expect { + -re "type = class AD \{${ws}public:${ws}AD & operator=\\(AD const ?&\\);${ws}AD\\((AD const|const AD) ?&\\);${ws}AD\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype AD" + } + -re "type = class AD \{${ws}public:${ws}virtual int vg \\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype AD (aCC)" + } + -re "type = class AD \{${ws}public:((${ws}AD & operator=\\(AD const ?&\\);)|(${ws}AD\\(AD const ?&\\);)|(${ws}AD\\((void|)\\);)|(${ws}virtual int vg\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" { + pass "ptype AD (obsolescent gcc or gdb)" + } + -re ".*$gdb_prompt $" { + fail "ptype AD" + } + timeout { + fail "ptype AD (timeout)" + } + } + + send_gdb "ptype D\n" + gdb_expect { + -re "type = class D : public AD, public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}public:${ws}int d;${ws}D & operator=\\(D const ?&\\);${ws}D\\(int, D const ?&\\);${ws}D\\(int\\);${ws}static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype D" + } + -re "type = class D : public AD, public virtual V \{${ws}public:${ws}int d;${ws}D & operator=\\(D const ?&\\);${ws}D\\((D const|const D) ?&\\);${ws}D\\((void|)\\);${ws}static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype D" + } + -re "type = class D : public AD, public virtual V \{${ws}public:${ws}int d;${ws}static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype D (aCC)" + } + -re "type = class D : public AD, public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}public:${ws}int d;((${ws}D & operator=\\(D const ?&\\);)|(${ws}D\\(int, D const ?&\\);)|(${ws}D\\(int\\);)|(${ws}static void s\\((void|)\\);)|(${ws}virtual int vg\\((void|)\\);)|(${ws}virtual int vd\\((void|)\\);)|(${ws}int fd\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" { + pass "ptype D (obsolescent gcc or gdb)" + } + -re ".*$gdb_prompt $" { + fail "ptype D" + } + timeout { + fail "ptype D (timeout)" + } + } + + send_gdb "ptype E\n" + gdb_expect { + -re "type = class E : public B, public virtual V, public D, public C \{${ws}public:${ws}int e;${ws}E & operator=\\(E const ?&\\);${ws}E\\(int, E const ?&\\);${ws}E\\(int\\);${ws}virtual int f\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vv\\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype E" + } + -re "type = class E : public B, public virtual V, public D, public C \{${ws}public:${ws}int e;${ws}E & operator=\\(E const ?&\\);${ws}E\\((E const|const E) ?&\\);${ws}E\\((void|)\\);${ws}virtual int f\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vv\\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype E" + } + -re "type = class E : public B, public virtual V, public D, public C \{${ws}public:${ws}int e;${ws}virtual int f \\((void|)\\);${ws}virtual int vg \\((void|)\\);${ws}virtual int vv \\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype E (aCC)" + } + -re "type = class E : public B, public virtual V, public D, public C \{${ws}public:${ws}int e;((${ws}E & operator=\\(E const ?&\\);)|(${ws}E\\(int, E const ?&\\);)|(${ws}E\\(int\\);)|(${ws}virtual int f\\((void|)\\);)|(${ws}virtual int vg\\((void|)\\);)|(${ws}virtual int vv\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" { + pass "ptype E (obsolescent gcc or gdb)" + } + -re ".*$gdb_prompt $" { + fail "ptype E" + } + timeout { + fail "ptype E (timeout)" + } + } + + send_gdb "ptype dd\n" + gdb_expect { + -re "type = class D : public AD, public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}public:${ws}int d;${ws}D & operator=\\(D const ?&\\);${ws}D\\(int, D const ?&\\);${ws}D\\(int\\);${ws}static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype dd" + } + -re "type = class D : public AD, public virtual V \{${ws}public:${ws}int d;${ws}D & operator=\\(D const ?&\\);${ws}D\\((D const|const D) ?&\\);${ws}D\\((void|)\\);${ws}static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype dd" + } + -re "type = class D : public AD, public virtual V \{${ws}public:${ws}int d;${ws}static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype dd (aCC)" + } + -re "type = class D : public AD, public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}public:${ws}int d;((${ws}D & operator=\\(D const ?&\\);)|(${ws}D\\(int, D const ?&\\);)|(${ws}D\\(int\\);)|(${ws}static void s\\((void|)\\);)|(${ws}virtual int vg\\((void|)\\);)|(${ws}virtual int vd\\((void|)\\);)|(${ws}int fd\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" { + pass "ptype dd (obsolescent gcc or gdb)" + } + -re ".*$gdb_prompt $" { + fail "ptype dd" + } + timeout { + fail "ptype dd (timeout)" + } + } + + send_gdb "ptype ppd\n" + gdb_expect { + -re "type = class D : public AD, public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}public:${ws}int d;${ws}D & operator=\\(D const ?&\\);${ws}D\\(int, D const ?&\\);${ws}D\\(int\\);${ws}static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype ppd" + } + -re "type = class D : public AD, public virtual V \{${ws}public:${ws}int d;${ws}D & operator=\\(D const ?&\\);${ws}D\\((D const|const D) ?&\\);${ws}D\\((void|)\\);${ws}static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype ppd" + } + -re "type = class D : public AD, public virtual V \{${ws}public:${ws}int d;${ws}static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype ppd (aCC)" + } + -re "type = class D : public AD, public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}public:${ws}int d;((${ws}D & operator=\\(D const ?&\\);)|(${ws}D\\(int, D const ?&\\);)|(${ws}D\\(int\\);)|(${ws}static void s\\((void|)\\);)|(${ws}virtual int vg\\((void|)\\);)|(${ws}virtual int vd\\((void|)\\);)|(${ws}int fd\\((void|)\\);))*${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype ppd (obsolescent gcc or gdb)" + } + -re ".*$gdb_prompt $" { + fail "ptype ppd" + } + timeout { + fail "ptype ppd (timeout)" + } + } + + send_gdb "ptype pAd\n" + gdb_expect { + -re "type = class AD \{${ws}public:${ws}AD & operator=\\(AD const ?&\\);${ws}AD\\((AD const|const AD) ?&\\);${ws}AD\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype pAd" + } + -re "type = class AD \{${ws}public:${ws}virtual int vg \\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype pAd (aCC)" + } + -re "type = class AD \{${ws}public:((${ws}AD & operator=\\(AD const ?&\\);)|(${ws}AD\\(AD const ?&\\);)|(${ws}AD\\((void|)\\);)|(${ws}virtual int vg\\((void|)\\);))*${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype pAd (obsolescent gcc or gdb)" + } + -re ".*$gdb_prompt $" { + fail "ptype pAd" + } + timeout { + fail "ptype pAd (timeout)" + } + } + + send_gdb "ptype a\n" + gdb_expect { + -re "type = class A : public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}int a;${ws}public:${ws}A & operator=\\(A const ?&\\);${ws}A\\(int, A const ?&\\);${ws}A\\(int\\);${ws}virtual int f\\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype a" + } + -re "type = class A : public virtual V \{${ws}private:${ws}int a;${ws}public:${ws}A & operator=\\(A const ?&\\);${ws}A\\((A const|const A) ?&\\);${ws}A\\((void|)\\);${ws}virtual int f\\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype a" + } + -re "type = class A : public virtual V \{${ws}private:${ws}int a;${ws}public:${ws}virtual int f\\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype a (aCC)" + } + -re "type = class A : public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}int a;${ws}public:((${ws}A & operator=\\(A const ?&\\);)|(${ws}A\\(int, A const ?&\\);)|(${ws}A\\(int\\);)|(${ws}virtual int f\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" { + pass "ptype a (obsolescent gcc or gdb)" + } + -re ".*$gdb_prompt $" { + fail "ptype a" + } + timeout { + fail "ptype a (timeout)" + } + } + + send_gdb "ptype b\n" + gdb_expect { + -re "type = class B : public A \{${ws}private:${ws}int b;${ws}public:${ws}B & operator=\\(B const ?&\\);${ws}B\\(int, B const ?&\\);${ws}B\\(int\\);${ws}virtual int f\\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype b" + } + -re "type = class B : public A \{${ws}private:${ws}int b;${ws}public:${ws}B & operator=\\(B const ?&\\);${ws}B\\((B const|const B) ?&\\);${ws}B\\((void|)\\);${ws}virtual int f\\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype b" + } + -re "type = class B : public A \{${ws}private:${ws}int b;${ws}public:${ws}virtual int f \\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype b (aCC)" + } + -re "type = class B : public A \{${ws}private:${ws}int b;${ws}public:((${ws}B & operator=\\(B const ?&\\);)|(${ws}B\\(int, B const ?&\\);)|(${ws}B\\(int\\);)|(${ws}virtual int f\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" { + pass "ptype b (obsolescent gcc or gdb)" + } + -re ".*$gdb_prompt $" { + fail "ptype b" + } + timeout { + fail "ptype b (timeout)" + } + } + + send_gdb "ptype c\n" + gdb_expect { + -re "type = class C : public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}public:${ws}int c;${ws}C & operator=\\(C const ?&\\);${ws}C\\(int, C const ?&\\);${ws}C\\(int\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype c" + } + -re "type = class C : public virtual V \{${ws}public:${ws}int c;${ws}C & operator=\\(C const ?&\\);${ws}C\\((C const|const C) ?&\\);${ws}C\\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype c" + } + -re "type = class C : public virtual V \{${ws}public:${ws}int c;${ws}\}$nl$gdb_prompt $" { + pass "ptype c (aCC)" + } + -re "type = class C : public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}public:${ws}int c;((${ws}C & operator=\\(C const ?&\\);)|(${ws}C\\(int, C const ?&\\);)|(${ws}C\\(int\\);))*${ws}\}$nl$gdb_prompt $" { + pass "ptype c (obsolescent gcc or gdb)" + } + -re ".*$gdb_prompt $" { + fail "ptype c" + } + timeout { + fail "ptype c (timeout)" + } + } + + send_gdb "ptype d\n" + gdb_expect { + -re "type = class D : public AD, public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}public:${ws}int d;${ws}D & operator=\\(D const ?&\\);${ws}D\\(int, D const ?&\\);${ws}D\\(int\\);${ws}static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype d" + } + -re "type = class D : public AD, public virtual V \{${ws}public:${ws}int d;${ws}D & operator=\\(D const ?&\\);${ws}D\\((D const|const D) ?&\\);${ws}D\\((void|)\\);${ws}static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype d" + } + -re "type = class D : public AD, public virtual V \{${ws}public:${ws}int d;${ws}static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype d (aCC)" + } + -re "type = class D : public AD, public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}public:${ws}int d;((${ws}D & operator=\\(D const ?&\\);)|(${ws}D\\(int, D const ?&\\);)|(${ws}D\\(int\\);)|(${ws}static void s\\((void|)\\);)|(${ws}virtual int vg\\((void|)\\);)|(${ws}virtual int vd\\((void|)\\);)|(${ws}int fd\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" { + pass "ptype d (obsolescent gcc or gdb)" + } + -re ".*$gdb_prompt $" { + fail "ptype d" + } + timeout { + fail "ptype d (timeout)" + } + } + + send_gdb "ptype e\n" + gdb_expect { + -re "type = class E : public B, public virtual V, public D, public C \{${ws}public:${ws}int e;${ws}E & operator=\\(E const ?&\\);${ws}E\\(int, E const ?&\\);${ws}E\\(int\\);${ws}virtual int f\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vv\\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype e" + } + -re "type = class E : public B, public virtual V, public D, public C \{${ws}public:${ws}int e;${ws}E & operator=\\(E const ?&\\);${ws}E\\((E const|const E) ?&\\);${ws}E\\((void|)\\);${ws}virtual int f\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vv\\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype e" + } + -re "type = class E : public B, public virtual V, public D, public C \{${ws}public:${ws}int e;${ws}virtual int f \\((void|)\\);${ws}virtual int vg \\((void|)\\);${ws}virtual int vv \\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype e (aCC)" + } + -re "type = class E : public B, public virtual V, public D, public C \{${ws}public:${ws}int e;((${ws}E & operator=\\(E const ?&\\);)|(${ws}E\\(int, E const ?&\\);)|(${ws}E\\(int\\);)|(${ws}virtual int f\\((void|)\\);)|(${ws}virtual int vg\\((void|)\\);)|(${ws}virtual int vv\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" { + pass "ptype e (obsolescent gcc or gdb)" + } + -re ".*$gdb_prompt $" { + fail "ptype e" + } + timeout { + fail "ptype e (timeout)" + } + } + + send_gdb "ptype v\n" + gdb_expect { + -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;${ws}V & operator=\\(V const ?&\\);${ws}V\\((V const|const V) ?&\\);${ws}V\\((void|)\\);${ws}int f\\((void|)\\);${ws}virtual int vv\\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype v" + } + -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;${ws}int f \\((void|)\\);${ws}virtual int vv \\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype v (aCC)" + } + -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;((${ws}V & operator=\\(V const ?&\\);)|(${ws}V\\(V const ?&\\);)|(${ws}V\\((void|)\\);)|(${ws}int f\\((void|)\\);)|(${ws}virtual int vv\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" { + pass "ptype v (obsolescent gcc or gdb)" + } + -re ".*$gdb_prompt $" { + fail "ptype v" + } + timeout { + fail "ptype v (timeout)" + } + } + + send_gdb "ptype vb\n" + gdb_expect { + -re "type = class VB \{${ws}public:${ws}int vb;${ws}VB & operator=\\(VB const ?&\\);${ws}VB\\((VB const|const VB) ?&\\);${ws}VB\\((void|)\\);${ws}int fvb\\((void|)\\);${ws}virtual int vvb\\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype vb" + } + -re "type = class VB \{${ws}public:${ws}int vb;${ws}int fvb \\((void|)\\);${ws}virtual int vvb \\((void|)\\);${ws}\}$nl$gdb_prompt $" { + pass "ptype vb (aCC)" + } + -re "type = class VB \{${ws}public:${ws}int vb;((${ws}VB & operator=\\(VB const ?&\\);)|(${ws}VB\\(VB const ?&\\);)|(${ws}VB\\((void|)\\);)|(${ws}int fvb\\((void|)\\);)|(${ws}virtual int vvb\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" { + pass "ptype vb (obsolescent gcc or gdb)" + } + -re ".*$gdb_prompt $" { + fail "ptype vb" + } + timeout { + fail "ptype vb (timeout)" + } + } + + send_gdb "ptype pAa\n" + gdb_expect { + -re "type = class A : public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}int a;${ws}public:${ws}A & operator=\\(A const ?&\\);${ws}A\\(int, A const ?&\\);${ws}A\\(int\\);${ws}virtual int f\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype pAa" + } + -re "type = class A : public virtual V \{${ws}private:${ws}int a;${ws}public:${ws}A & operator=\\(A const ?&\\);${ws}A\\((A const|const A) ?&\\);${ws}A\\((void|)\\);${ws}virtual int f\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype pAa" + } + -re "type = class A : public virtual V \{${ws}private:${ws}int a;${ws}public:${ws}virtual int f\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype pAa (aCC)" + } + -re "type = class A : public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}int a;${ws}public:((${ws}A & operator=\\(A const ?&\\);)|(${ws}A\\(int, A const ?&\\);)|(${ws}A\\(int\\);)|(${ws}virtual int f\\((void|)\\);))*${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype pAa (obsolescent gcc or gdb)" + } + -re ".*$gdb_prompt $" { + fail "ptype pAa" + } + timeout { + fail "ptype pAa (timeout)" + } + } + + send_gdb "ptype pAe\n" + gdb_expect { + -re "type = class A : public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}int a;${ws}public:${ws}A & operator=\\(A const ?&\\);${ws}A\\(int, A const ?&\\);${ws}A\\(int\\);${ws}virtual int f\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype pAe" + } + -re "type = class A : public virtual V \{${ws}private:${ws}int a;${ws}public:${ws}A & operator=\\(A const ?&\\);${ws}A\\((A const|const A) ?&\\);${ws}A\\((void|)\\);${ws}virtual int f\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype pAe" + } + -re "type = class A : public virtual V \{${ws}private:${ws}int a;${ws}public:${ws}virtual int f\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype pAe (aCC)" + } + -re "type = class A : public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}int a;${ws}public:((${ws}A & operator=\\(A const ?&\\);)|(${ws}A\\(int, A const ?&\\);)|(${ws}A\\(int\\);)|(${ws}virtual int f\\((void|)\\);))*${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype pAe (obsolescent gcc or gdb)" + } + -re ".*$gdb_prompt $" { + fail "ptype pAe" + } + timeout { + fail "ptype pAe (timeout)" + } + } + + send_gdb "ptype pBe\n" + gdb_expect { + -re "type = class B : public A \{${ws}private:${ws}int b;${ws}public:${ws}B & operator=\\(B const ?&\\);${ws}B\\(int, B const ?&\\);${ws}B\\(int\\);${ws}virtual int f\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype pBe" + } + -re "type = class B : public A \{${ws}private:${ws}int b;${ws}public:${ws}B & operator=\\(B const ?&\\);${ws}B\\((B const|const B) ?&\\);${ws}B\\((void|)\\);${ws}virtual int f\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype pBe" + } + -re "type = class B : public A \{${ws}private:${ws}int b;${ws}public:${ws}virtual int f \\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype pBe (aCC)" + } + -re "type = class B : public A \{${ws}private:${ws}int b;${ws}public:((${ws}B & operator=\\(B const ?&\\);)|(${ws}B\\(int, B const ?&\\);)|(${ws}B\\(int\\);)|(${ws}virtual int f\\((void|)\\);))*${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype pBe (obsolescent gcc or gdb)" + } + -re ".*$gdb_prompt $" { + fail "ptype pBe" + } + timeout { + fail "ptype pBe (timeout)" + } + } + + send_gdb "ptype pDd\n" + gdb_expect { + -re "type = class D : public AD, public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}public:${ws}int d;${ws}D & operator=\\(D const ?&\\);${ws}D\\(int, D const ?&\\);${ws}D\\(int\\);${ws}static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype pDd" + } + -re "type = class D : public AD, public virtual V \{${ws}public:${ws}int d;${ws}D & operator=\\(D const ?&\\);${ws}D\\((D const|const D) ?&\\);${ws}D\\((void|)\\);${ws}static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype pDd" + } + -re "type = class D : public AD, public virtual V \{${ws}public:${ws}int d;${ws}static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype pDd (aCC)" + } + -re "type = class D : public AD, public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}public:${ws}int d;((${ws}D & operator=\\(D const ?&\\);)|(${ws}D\\(int, D const ?&\\);)|(${ws}D\\(int\\);)|(${ws}static void s\\((void|)\\);)|(${ws}virtual int vg\\((void|)\\);)|(${ws}virtual int vd\\((void|)\\);)|(${ws}int fd\\((void|)\\);))*${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype pDd (obsolescent gcc or gdb)" + } + -re ".*$gdb_prompt $" { + fail "ptype pDd" + } + timeout { + fail "ptype pDd (timeout)" + } + } + + send_gdb "ptype pDe\n" + gdb_expect { + -re "type = class D : public AD, public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}public:${ws}int d;${ws}D & operator=\\(D const ?&\\);${ws}D\\(int, D const ?&\\);${ws}D\\(int\\);${ws}static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype pDe" + } + -re "type = class D : public AD, public virtual V \{${ws}public:${ws}int d;${ws}D & operator=\\(D const ?&\\);${ws}D\\((D const|const D) ?&\\);${ws}D\\((void|)\\);${ws}static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype pDe" + } + -re "type = class D : public AD, public virtual V \{${ws}public:${ws}int d;${ws}static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype pDe (aCC)" + } + -re "type = class D : public AD, public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}public:${ws}int d;((${ws}D & operator=\\(D const ?&\\);)|(${ws}D\\(int, D const ?&\\);)|(${ws}D\\(int\\);)|(${ws}static void s\\((void|)\\);)|(${ws}virtual int vg\\((void|)\\);)|(${ws}virtual int vd\\((void|)\\);)|(${ws}int fd\\((void|)\\);))*${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype pDe (obsolescent gcc or gdb)" + } + -re ".*$gdb_prompt $" { + fail "ptype pDe" + } + timeout { + fail "ptype pDe (timeout)" + } + } + + send_gdb "ptype pVa\n" + gdb_expect { + -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;${ws}V & operator=\\(V const ?&\\);${ws}V\\((V const|const V) ?&\\);${ws}V\\((void|)\\);${ws}int f\\((void|)\\);${ws}virtual int vv\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype pVa" + } + -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;${ws}int f \\((void|)\\);${ws}virtual int vv \\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype pVa (aCC)" + } + -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;((${ws}V & operator=\\(V const ?&\\);)|(${ws}V\\(V const ?&\\);)|(${ws}V\\((void|)\\);)|(${ws}int f\\((void|)\\);)|(${ws}virtual int vv\\((void|)\\);))*${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype pVa (obsolescent gcc or gdb)" + } + -re ".*$gdb_prompt $" { + fail "ptype pVa" + } + timeout { + fail "ptype pVa (timeout)" + } + } + + send_gdb "ptype pVv\n" + gdb_expect { + -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;${ws}V & operator=\\(V const ?&\\);${ws}V\\((V const|const V) ?&\\);${ws}V\\((void|)\\);${ws}int f\\((void|)\\);${ws}virtual int vv\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype pVv" + } + -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;${ws}int f \\((void|)\\);${ws}virtual int vv \\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype pVv (aCC)" + } + -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;((${ws}V & operator=\\(V const ?&\\);)|(${ws}V\\(V const ?&\\);)|(${ws}V\\((void|)\\);)|(${ws}int f\\((void|)\\);)|(${ws}virtual int vv\\((void|)\\);))*${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype pVv (obsolescent gcc or gdb)" + } + -re ".*$gdb_prompt $" { + fail "ptype pVv" + } + timeout { + fail "ptype pVv (timeout)" + } + } + + send_gdb "ptype pVe\n" + gdb_expect { + -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;${ws}V & operator=\\(V const ?&\\);${ws}V\\((V const|const V) ?&\\);${ws}V\\((void|)\\);${ws}int f\\((void|)\\);${ws}virtual int vv\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype pVe" + } + -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;${ws}int f \\((void|)\\);${ws}virtual int vv \\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype pVe (aCC)" + } + -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;((${ws}V & operator=\\(V const ?&\\);)|(${ws}V\\(V const ?&\\);)|(${ws}V\\((void|)\\);)|(${ws}int f\\((void|)\\);)|(${ws}virtual int vv\\((void|)\\);))*${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype pVe (obsolescent gcc or gdb)" + } + -re ".*$gdb_prompt $" { + fail "ptype pVe" + } + timeout { + fail "ptype pVe (timeout)" + } + } + + send_gdb "ptype pVd\n" + gdb_expect { + -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;${ws}V & operator=\\(V const ?&\\);${ws}V\\((V const|const V) ?&\\);${ws}V\\((void|)\\);${ws}int f\\((void|)\\);${ws}virtual int vv\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype pVd" + } + -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;${ws}int f \\((void|)\\);${ws}virtual int vv \\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype pVd (aCC)" + } + -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;((${ws}V & operator=\\(V const ?&\\);)|(${ws}V\\(V const ?&\\);)|(${ws}V\\((void|)\\);)|(${ws}int f\\((void|)\\);)|(${ws}virtual int vv\\((void|)\\);))*${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype pVd (obsolescent gcc or gdb)" + } + -re ".*$gdb_prompt $" { + fail "ptype pVd" + } + timeout { + fail "ptype pVd (timeout)" + } + } + + send_gdb "ptype pADe\n" + gdb_expect { + -re "type = class AD \{${ws}public:${ws}AD & operator=\\(AD const ?&\\);${ws}AD\\((AD const|const AD) ?&\\);${ws}AD\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype pADe" + } + -re "type = class AD \{${ws}public:${ws}virtual int vg \\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype pADe (aCC)" + } + -re "type = class AD \{${ws}public:((${ws}AD & operator=\\(AD const ?&\\);)|(${ws}AD\\(AD const ?&\\);)|(${ws}AD\\((void|)\\);)|(${ws}virtual int vg\\((void|)\\);))*${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype pADe (obsolescent gcc or gdb)" + } + -re ".*$gdb_prompt $" { + fail "ptype pADe" + } + timeout { + fail "ptype pADe (timeout)" + } + } + + send_gdb "ptype pEe\n" + gdb_expect { + -re "type = class E : public B, public virtual V, public D, public C \{${ws}public:${ws}int e;${ws}E & operator=\\(E const ?&\\);${ws}E\\(int, E const ?&\\);${ws}E\\(int\\);${ws}virtual int f\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vv\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype pEe" + } + -re "type = class E : public B, public virtual V, public D, public C \{${ws}public:${ws}int e;${ws}E & operator=\\(E const ?&\\);${ws}E\\((E const|const E) ?&\\);${ws}E\\((void|)\\);${ws}virtual int f\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vv\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype pEe" + } + -re "type = class E : public B, public virtual V, public D, public C \{${ws}public:${ws}int e;${ws}virtual int f \\((void|)\\);${ws}virtual int vg \\((void|)\\);${ws}virtual int vv \\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype pEe (aCC)" + } + -re "type = class E : public B, public virtual V, public D, public C \{${ws}public:${ws}int e;((${ws}E & operator=\\(E const ?&\\);)|(${ws}E\\(int, E const ?&\\);)|(${ws}E\\(int\\);)|(${ws}virtual int f\\((void|)\\);)|(${ws}virtual int vg\\((void|)\\);)|(${ws}virtual int vv\\((void|)\\);))*${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype pEe (obsolescent gcc or gdb)" + } + -re ".*$gdb_prompt $" { + fail "ptype pEe" + } + timeout { + fail "ptype pEe (timeout)" + } + } + + send_gdb "ptype pVB\n" + gdb_expect { + -re "type = class VB \{${ws}public:${ws}int vb;${ws}VB & operator=\\(VB const ?&\\);${ws}VB\\((VB const|const VB) ?&\\);${ws}VB\\((void|)\\);${ws}int fvb\\((void|)\\);${ws}virtual int vvb\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype pVB" + } + -re "type = class VB \{${ws}public:${ws}int vb;${ws}int fvb \\((void|)\\);${ws}virtual int vvb \\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype pVB (aCC)" + } + -re "type = class VB \{${ws}public:${ws}int vb;((${ws}VB & operator=\\(VB const ?&\\);)|(${ws}VB\\(VB const ?&\\);)|(${ws}VB\\((void|)\\);)|(${ws}int fvb\\((void|)\\);)|(${ws}virtual int vvb\\((void|)\\);))*${ws}\} \[*\]+$nl$gdb_prompt $" { + pass "ptype pVB (obsolescent gcc or gdb)" + } + -re ".*$gdb_prompt $" { + fail "ptype pVB" + } + timeout { + fail "ptype pVB (timeout)" + } + } +} + +# +# Test calling of virtual functions. +# + +proc test_virtual_calls {} { + global gdb_prompt + global GDB + global nl + global gcc_compiled + + if [target_info exists gdb,cannot_call_functions] { + setup_xfail "*-*-*" 2416 + fail "This target can not call functions" + return 0 + } + + send_gdb "print pAe->f()\n" + gdb_expect { + -re ".* = 20$nl$gdb_prompt $" { pass "print pAe->f()" } + -re "Cannot invoke functions on this machine.*$gdb_prompt $" { + fail "print pAe->f() (cannot invoke functions, skipping virtual calls)" + return 0 + } + -re ".*Cannot access memory at address 0x8.*$gdb_prompt $" { + fail "print pAe->f() \ +(known failure with gcc cygnus-2.4.5-930417, skipping virtual calls)" + return 0 + } + -re "Cannot resolve .* to any overloaded instance.*$gdb_prompt $" { + setup_xfail hppa*-*-* CLLbs16899 + fail "print pAe->f()" + } + -re ".*$gdb_prompt $" { fail "print pAe->f()" } + timeout { fail "print pAe->f() (timeout)" } + eof { fail "print pAe->f() ($GDB dumped core) (FIXME)" ; gdb_virtfunc_restart; return } + } + + send_gdb "print pAa->f()\n" + gdb_expect { + -re ".* = 1$nl$gdb_prompt $" { pass "print pAa->f()" } + -re "Cannot resolve .* to any overloaded instance.*$gdb_prompt $" { + setup_xfail hppa*-*-* CLLbs16899 + fail "print pAa->f()" + } + -re ".*$gdb_prompt $" { fail "print pAa->f()" } + timeout { fail "print pAa->f() (timeout)" } + eof { fail "print pAa->f() ($GDB dumped core) (FIXME)" ; gdb_virtfunc_restart; return } + } + + send_gdb "print pDe->vg()\n" + gdb_expect { + -re ".* = 202$nl$gdb_prompt $" { pass "print pDe->vg()" } + -re "Cannot resolve .* to any overloaded instance.*$gdb_prompt $" { + setup_xfail hppa*-*-* CLLbs16899 + fail "print pDe->vg()" + } + -re ".*$gdb_prompt $" { fail "print pDe->vg()" } + timeout { fail "print pDe->vg() (timeout)" } + eof { fail "print pDe->vg() ($GDB dumped core) (FIXME)" ; gdb_virtfunc_restart; return } + } + + send_gdb "print pADe->vg()\n" + gdb_expect { + -re ".* = 202$nl$gdb_prompt $" { pass "print pADe->vg()" } + -re "Cannot resolve .* to any overloaded instance.*$gdb_prompt $" { + setup_xfail hppa*-*-* CLLbs16899 + fail "print pADe->vg()" + } + -re ".*$gdb_prompt $" { fail "print pADe->vg()" } + timeout { fail "print pADe->vg() (timeout)" } + eof { fail "print pADe->vg() ($GDB dumped core) (FIXME)" ; gdb_virtfunc_restart; return } + } + + send_gdb "print pDd->vg()\n" + gdb_expect { + -re ".* = 101$nl$gdb_prompt $" { pass "print pDd->vg()" } + -re "Cannot resolve .* to any overloaded instance.*$gdb_prompt $" { + setup_xfail hppa*-*-* CLLbs16899 + fail "print pDd->vg()" + } + -re ".*$gdb_prompt $" { fail "print pDd->vg()" } + timeout { fail "print pDd->vg() (timeout)" } + eof { fail "print pDd->vg() ($GDB dumped core) (FIXME)" ; gdb_virtfunc_restart; return } + } + + send_gdb "print pEe->vvb()\n" + gdb_expect { + -re ".* = 411$nl$gdb_prompt $" { pass "print pEe->vvb()" } + -re "Cannot resolve .* to any overloaded instance.*$gdb_prompt $" { + setup_xfail hppa*-*-* CLLbs16899 + fail "print pEe->vvb()" + } + -re ".*$gdb_prompt $" { fail "print pEe->vvb()" } + timeout { fail "print pEe->vvb() (timeout)" } + eof { fail "print pEe->vvb() ($GDB dumped core) (FIXME)" ; gdb_virtfunc_restart; return } + } + + send_gdb "print pVB->vvb()\n" + gdb_expect { + -re ".* = 407$nl$gdb_prompt $" { pass "print pVB->vvb()" } + -re "Cannot resolve .* to any overloaded instance.*$gdb_prompt $" { + setup_xfail hppa*-*-* CLLbs16899 + fail "print pVB->vvb()" + } + -re ".*$gdb_prompt $" { fail "print pVB->vvb()" } + timeout { fail "print pVB->vvb() (timeout)" } + eof { fail "print pVB->vvb() ($GDB dumped core) (FIXME)" ; gdb_virtfunc_restart; return } + } + + send_gdb "print pBe->vvb()\n" + gdb_expect { + -re ".* = 411$nl$gdb_prompt $" { pass "print pBe->vvb()" } + -re "Cannot resolve .* to any overloaded instance.*$gdb_prompt $" { + setup_xfail hppa*-*-* CLLbs16899 + fail "print pBe->vvb()" + } + -re ".*$gdb_prompt $" { fail "print pBe->vvb()" } + timeout { fail "print pBe->vvb() (timeout)" } + eof { fail "print pBe->vvb() ($GDB dumped core) (FIXME)" ; gdb_virtfunc_restart; return } + } + + send_gdb "print pDe->vvb()\n" + gdb_expect { + -re ".* = 411$nl$gdb_prompt $" { pass "print pDe->vvb()" } + -re "Cannot resolve .* to any overloaded instance.*$gdb_prompt $" { + setup_xfail hppa*-*-* CLLbs16899 + fail "print pDe->vvb()" + } + -re ".*$gdb_prompt $" { fail "print pDe->vvb()" } + timeout { fail "print pDe->vvb() (timeout)" } + eof { fail "print pDe->vvb() ($GDB dumped core) (FIXME)" ; gdb_virtfunc_restart; return } + } + + send_gdb "print pEe->vd()\n" + gdb_expect { + -re ".* = 282$nl$gdb_prompt $" { pass "print pEe->vd()" } + -re "Cannot resolve .* to any overloaded instance.*$gdb_prompt $" { + setup_xfail hppa*-*-* CLLbs16899 + fail "print pEe->vd()" + } + -re ".*$gdb_prompt $" { fail "print pEe->vd()" } + timeout { fail "print pEe->vd() (timeout)" } + eof { fail "print pEe->vd() ($GDB dumped core) (FIXME)" ; gdb_virtfunc_restart; return } + } + + send_gdb "print pEe->fvb()\n" + gdb_expect { + -re ".* = 311$nl$gdb_prompt $" { pass "print pEe->fvb()" } + -re "Cannot resolve .* to any overloaded instance.*$gdb_prompt $" { + setup_xfail hppa*-*-* CLLbs16899 + fail "print pEe->fvb()" + } + -re ".*$gdb_prompt $" { fail "print pEe->fvb()" } + timeout { fail "print pEe->fvb() (timeout)" } + eof { fail "print pEe->fvb() ($GDB dumped core) (FIXME)" ; gdb_virtfunc_restart; return } + } + + # fails on target=native, host=i686-pc-linux-gnu%rh-7.2, + # gdb=HEAD%2002-02-16, gcc=2.95.3, goption=-gdwarf-2. + # + # fails on target=native, host=i686-pc-linux-gnu%rh-7.2, + # gdb=HEAD%2002-02-16, gcc=2.95.3, goption=-gstabs+. + # + # fails on target=native, host=i686-pc-linux-gnu%rh-7.2, + # gdb=HEAD%2002-02-16, gcc=3.0.3, goption=-gdwarf-2. + # + # fails on target=native, host=i686-pc-linux-gnu%rh-7.2, + # gdb=HEAD%2002-02-16, gcc=3.0.3, goption=-gstabs+. + # + # fails on target=native, host=i686-pc-linux-gnu%rh-7.2, + # gdb=HEAD%2002-02-16, gcc=3.0.4-20020215, goption=-gdwarf-2. + # + # fails on target=native, host=i686-pc-linux-gnu%rh-7.2, + # gdb=HEAD%2002-02-16, gcc=3.0.4-20020215, goption=-gstabs+. + # + # fails on target=native, host=i686-pc-linux-gnu%rh-7.2, + # gdb=HEAD%2002-02-16, gcc=gcc-3_0-branch%2002-02-16, goption=-gdwarf-2. + # + # fails on target=native, host=i686-pc-linux-gnu%rh-7.2, + # gdb=HEAD%2002-02-16, gcc=gcc-3_0-branch%2002-02-16, goption=-gstabs+. + # + # fails on target=native, host=i686-pc-linux-gnu%rh-7.2, + # gdb=HEAD%2002-02-16, gcc=HEAD%2002-02-16, goption=-gdwarf-2. + # + # fails on target=native, host=i686-pc-linux-gnu%rh-7.2, + # gdb=HEAD%2002-02-16, gcc=HEAD%2002-02-16, goption=-gstabs+. + # + # -- chastain 2002-02-20 + + send_gdb "print pEe->D::vg()\n" + gdb_expect { + -re ".* = 102$nl$gdb_prompt $" { pass "print pEe->D::vg()" } + -re "Attempt to take address of value not located in memory.\r\n$gdb_prompt $" + { kfail "gdb/1064" "print pEe->D::vg()" } + -re ".*$gdb_prompt $" { fail "print pEe->D::vg()" } + timeout { fail "print pEe->D::vg() (timeout)" } + eof { fail "print pEe->D::vg() ($GDB dumped core) (FIXME)" ; gdb_virtfunc_restart; return } + } +} + +proc do_tests {} { + global prms_id + global bug_id + + set prms_id 0 + set bug_id 0 + + gdb_start; + gdb_virtfunc_init; + + runto_main + + test_ptype_of_classes + + if [ runto 'test_calls' ] then { + test_virtual_calls + } +} + +do_tests diff --git a/gdb/testsuite/gdb.mi/mi2-basics.exp b/gdb/testsuite/gdb.mi/mi2-basics.exp new file mode 100644 index 0000000..44d2e4b --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi2-basics.exp @@ -0,0 +1,246 @@ +# Copyright 1999, 2000 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# +# test basic Machine interface (MI) operations +# +# Verify that, using the MI, we can load a program and do +# other basic things that are used by all test files through mi_gdb_exit, +# mi_gdb_start, mi_delete_breakpoints, mi_gdb_reinitialize_dir and +# mi_gdb_load, so we can safely use those. +# +# The goal is not to test gdb functionality, which is done by other tests, +# but the command syntax and correct output response to MI operations. +# + +load_lib mi-support.exp +set MIFLAGS "-i=mi2" + +gdb_exit +if [mi_gdb_start] { + continue +} + +set testfile "basics" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +# In this file we want to test if the operations needed by the following +# procedures work, so it makes no sense using them here. + +# mi_delete_breakpoints +# mi_gdb_reinitialize_dir $srcdir/$subdir +# mi_gdb_load ${binfile} + +# Test if the MI interpreter has been configured + +proc test_mi_interpreter_selection {} { + global mi_gdb_prompt + global gdb_prompt + + # All this test expects is to get the prompt back + # with no syntax error message + send_gdb "-gdb-version\n" + gdb_expect { + -re "GNU gdb .*\r\n$mi_gdb_prompt$" \ + { pass "acceptance of MI operations" + return 1} + -re ".*\r\n$mi_gdb_prompt$" \ + { fail "acceptance of MI operations" + note "Skipping all other MI tests." } + -re "Undefined command.*$gdb_prompt $" \ + { fail "acceptance of MI operations" + note "Skipping all other MI tests." } + -re ".*$gdb_prompt $" \ + { fail "acceptance of MI operations" + note "Skipping all other MI tests." } + timeout { fail "acceptance of MI operations (timeout)" + note "Skipping all other MI tests." } + } + return 0 +} + +proc test_exec_and_symbol_mi_operatons {} { + global mi_gdb_prompt + global binfile + + # Load symbols and specify executable on a single operation + # Tests: + # -file-exec-and-symbols + + # Can't use mi_gdb_test as if this doesn't work, + # we must give up on the whole test file + send_gdb "-file-exec-and-symbols ${binfile}\n" + gdb_expect { + -re "\[\r\n\]*\\\^done\r\n$mi_gdb_prompt$" \ + { pass "file-exec-and-symbols operation" } + timeout { fail "file-exec-and-symbols operation (timeout)" + note "Skipping all other MI tests." + return 0} + } + + # The following is not used by mi-support.exp, but we test here so + # we get done with loading a program basics. + + # Do it again, but now load symbols and specify executable with + # two separate operations + # Tests: + # -file-clear + # -file-exec-file + # -file-symbol-file + + # FIXME: file-clear is not implemented yet. +# mi_gdb_test "-file-clear" \ +# "\\\^done" \ +# "file-clear operation" + + mi_gdb_test "-file-exec-file ${binfile}" \ + "\\\^done" \ + "file-exec-file operation" + + mi_gdb_test "-file-symbol-file ${binfile}" \ + "\\\^done" \ + "file-symbol-file operation" + + # FIXME: if we cannot load we have to skip all other tests. +} + +proc test_breakpoints_deletion {} { + global mi_gdb_prompt + global srcfile + + # Clear all breakpoints and list to confirm + # Tests: + # -break-delete (all) + # -break-list + + # The all parameter is actually no parameter. + mi_gdb_test "200-break-delete" \ + "\\\^done" \ + "break-delete (all) operation" + + mi_gdb_test "201-break-list" \ + ".*\\\^done,BreakpointTable=\\\{.*,body=\\\[\\\]\\\}" \ + "all breakpoints removed" +} + +proc test_dir_specification {} { + global mi_gdb_prompt + global srcdir + global subdir + + # Add to the search directories, display, then reset back to default + # Tests: + # -environment-directory arg + # -environment-directory + # -environment-directory -r + +#exp_internal 1 + mi_gdb_test "202-environment-directory ${srcdir}/${subdir}" \ + "\\\^done,source-path=\"${srcdir}/${subdir}.\\\$cdir.\\\$cwd\"" \ + "environment-directory arg operation" + + mi_gdb_test "203-environment-directory" \ + "\\\^done,source-path=\"${srcdir}/${subdir}.\\\$cdir.\\\$cwd\"" \ + "environment-directory empty-string operation" + + mi_gdb_test "204-environment-directory -r" \ + "\\\^done,source-path=\"\\\$cdir.\\\$cwd\"" \ + "environment-directory operation" + +#exp_internal 0 +} + +proc test_cwd_specification {} { + global mi_gdb_prompt + global objdir + global subdir + + # Change the working directory, then print the current working directory + # Tests: + # -environment-cd ${objdir} + # -environment-pwd + + mi_gdb_test "205-environment-cd ${objdir}" \ + "\\\^done" \ + "environment-cd arg operation" + + mi_gdb_test "206-environment-pwd" \ + "\\\^done,cwd=\"${objdir}\"" \ + "environment-pwd operation" +} + +proc test_path_specification {} { + global mi_gdb_prompt + global orig_path + global objdir + global srcdir + + # Add to the path, display, then reset + # Tests: + # -environment-path + # -environment-path dir1 dir2 + # -environment-path -r dir + # -environment-path -r + +#exp_internal 1 + + send_gdb "-environment-path\n" + gdb_expect 20 { + -re "\\\^done,path=\"\(.*\)\"\r\n$mi_gdb_prompt" { + set orig_path $expect_out(1,string); + } + timeout { + perror "-environment-path (timeout)" ; + return + } + } + + mi_gdb_test "207-environment-path" \ + "\\\^done,path=\"$orig_path\"" \ + "environment-path no-args operation" + + mi_gdb_test "208-environment-path $srcdir $objdir" \ + "\\\^done,path=\"$srcdir.$objdir.$orig_path\"" \ + "environment-path dir1 dir2 operation" + + mi_gdb_test "209-environment-path -r $objdir" \ + "\\\^done,path=\"$objdir.$orig_path\"" \ + "environment-path -r dir operation" + + mi_gdb_test "210-environment-path -r" \ + "\\\^done,path=\"$orig_path\"" \ + "environment-path -r operation" + +#exp_internal 0 +} + +if [test_mi_interpreter_selection] { + test_exec_and_symbol_mi_operatons + test_breakpoints_deletion + test_dir_specification + test_cwd_specification + test_path_specification +} + +mi_gdb_exit +return 0 diff --git a/gdb/testsuite/gdb.mi/mi2-break.exp b/gdb/testsuite/gdb.mi/mi2-break.exp new file mode 100644 index 0000000..11cb0d9 --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi2-break.exp @@ -0,0 +1,138 @@ +# Copyright 1999 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# +# Test essential Machine interface (MI) operations +# +# Verify that, using the MI, we can run a simple program and perform basic +# debugging activities like: insert breakpoints, run the program, +# step, next, continue until it ends and, last but not least, quit. +# +# The goal is not to test gdb functionality, which is done by other tests, +# but to verify the correct output response to MI operations. +# + +load_lib mi-support.exp +set MIFLAGS "-i=mi2" + +gdb_exit +if [mi_gdb_start] { + continue +} + +set testfile "basics" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +proc test_tbreak_creation_and_listing {} { + global mi_gdb_prompt + global srcfile + global hex + + # Insert some breakpoints and list them + # Also, disable some so they do not interfere with other tests + # Tests: + # -break-insert -t main + # -break-insert -t basics.c:callee2 + # -break-insert -t basics.c:15 + # -break-insert -t srcfile:6 + # -break-list + + mi_gdb_test "222-break-insert -t main" \ + "222\\^done,bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"del\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*basics.c\",line=\"32\",times=\"0\"\}" \ + "break-insert -t operation" + + mi_gdb_test "333-break-insert -t basics.c:callee2" \ + "333\\^done,bkpt=\{number=\"2\",type=\"breakpoint\",disp=\"del\",enabled=\"y\",addr=\"$hex\",func=\"callee2\",file=\".*basics.c\",line=\"22\",times=\"0\"\}" \ + "insert temp breakpoint at basics.c:callee2" + + mi_gdb_test "444-break-insert -t basics.c:15" \ + "444\\^done,bkpt=\{number=\"3\",type=\"breakpoint\",disp=\"del\",enabled=\"y\",addr=\"$hex\",func=\"callee3\",file=\".*basics.c\",line=\"15\",times=\"0\"\}" \ + "insert temp breakpoint at basics.c:15 (callee3)" + + # Getting the quoting right is tricky. That is "\"<file>\":6" + mi_gdb_test "555-break-insert -t \"\\\"${srcfile}\\\":6\"" \ + "555\\^done,bkpt=\{number=\"4\",type=\"breakpoint\",disp=\"del\",enabled=\"y\",addr=\"$hex\",func=\"callee4\",file=\".*basics.c\",line=\"6\",times=\"0\"\}" \ + "insert temp breakpoint at \"<fullfilename>\":6 (callee4)" + + mi_gdb_test "666-break-list" \ + "666\\\^done,BreakpointTable=\{nr_rows=\".\",nr_cols=\".\",hdr=\\\[\{width=\".*\",alignment=\".*\",col_name=\"number\",colhdr=\"Num\"\}.*colhdr=\"Type\".*colhdr=\"Disp\".*colhdr=\"Enb\".*colhdr=\"Address\".*colhdr=\"What\".*\\\],body=\\\[bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"del\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*basics.c\",line=\"32\",times=\"0\"\}.*\\\]\}" \ + "list of breakpoints" + + mi_gdb_test "777-break-delete" \ + "777\\^done" \ + "delete temp breakpoints" +} + +proc test_rbreak_creation_and_listing {} { + global mi_gdb_prompt + global srcfile + global hex + + # Insert some breakpoints and list them + # Also, disable some so they do not interfere with other tests + # Tests: + # -break-insert -r main + # -break-insert -r callee2 + # -break-insert -r callee + # -break-insert -r .*llee + # -break-list + + setup_xfail "*-*-*" + mi_gdb_test "122-break-insert -r main" \ + "122\\^done,bkpt=\{number=\"5\",addr=\"$hex\",file=\".*basics.c\",line=\"32\"\}" \ + "break-insert -r operation" + + setup_xfail "*-*-*" + mi_gdb_test "133-break-insert -r callee2" \ + "133\\^done,bkpt=\{number=\"6\",addr=\"$hex\",file=\".*basics.c\",line=\"22\"\}" \ + "insert breakpoint with regexp callee2" + + setup_xfail "*-*-*" + mi_gdb_test "144-break-insert -r callee" \ + "144\\^done,bkpt=\{number=\"7\",addr=\"$hex\",file=\".*basics.c\",line=\"27\"\},bkpt=\{number=\"8\",addr=\"$hex\",file=\".*basics.c\",line=\"22\"\},bkpt=\{number=\"9\",addr=\"$hex\",file=\".*basics.c\",line=\"17\"\},bkpt=\{number=\"10\",addr=\"$hex\",file=\".*basics.c\",line=\"8\"\}" \ + "insert breakpoint with regexp callee" + + setup_xfail "*-*-*" + mi_gdb_test "155-break-insert -r \.\*llee" \ + "155\\^done,bkpt=\{number=\"11\",addr=\"$hex\",file=\".*basics.c\",line=\"27\"\},bkpt=\{number=\"12\",addr=\"$hex\",file=\".*basics.c\",line=\"22\"\},bkpt=\{number=\"13\",addr=\"$hex\",file=\".*basics.c\",line=\"17\"\},bkpt=\{number=\"14\",addr=\"$hex\",file=\".*basics.c\",line=\"8\"\}" \ + "insert breakpoint with regexp .*llee" + + setup_xfail "*-*-*" + mi_gdb_test "166-break-list" \ + "1\\\^done,BreakpointTable=\{nr_rows=\".\",nr_cols=\".\",hdr=\\\[\{width=\".*\",alignment=\".*\",col_name=\"number\",colhdr=\"Num\"\}.*colhdr=\"Type\".*colhdr=\"Disp\".*colhdr=\"Enb\".*colhdr=\"Address\".*colhdr=\"What\".*\\\],body=\\\[bkpt=\{number=\"5\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*basics.c\",line=\"32\",times=\"0\"\},.*\}\\\]\}" \ + "list of breakpoints" + + mi_gdb_test "177-break-delete" \ + "177\\^done" \ + "delete temp breakpoints" +} + +test_tbreak_creation_and_listing +test_rbreak_creation_and_listing + +mi_gdb_exit +return 0 diff --git a/gdb/testsuite/gdb.mi/mi2-cli.exp b/gdb/testsuite/gdb.mi/mi2-cli.exp new file mode 100644 index 0000000..10295a9 --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi2-cli.exp @@ -0,0 +1,208 @@ +# Copyright 2002, 2003 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# This file tests that GDB's console can be accessed via the MI. +# Specifically, we are testing the "interpreter-exec" command and that +# the commands that are executed via this command are properly executed. +# Console commands executed via MI should use MI output wrappers, MI event +# handlers, etc. + +load_lib mi-support.exp +set MIFLAGS "-i=mi2" + +gdb_exit +if [mi_gdb_start] { + continue +} + +set testfile "basics" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +mi_gdb_reinitialize_dir $srcdir/$subdir + +mi_gdb_test "-interpreter-exec" \ + {\^error,msg="mi_cmd_interpreter_exec: Usage: -interpreter-exec interp command"} \ + "-interpreter-exec with no arguments" + +mi_gdb_test "-interpreter-exec console" \ + {\^error,msg="mi_cmd_interpreter_exec: Usage: -interpreter-exec interp command"} \ + "-interpreter-exec with one argument" + +mi_gdb_test "-interpreter-exec bogus command" \ + {\^error,msg="mi_cmd_interpreter_exec: could not find interpreter \\\"bogus\\\""} \ + "-interpreter-exec with bogus interpreter" + +set msg {Undefined command: \\\"bogus\\\"\. Try \\\"help\\\"\.} +mi_gdb_test "-interpreter-exec console bogus" \ + "&\\\"$msg\\\\n\\\".*\\^error,msg=\\\"$msg\\\".*" \ + "-interpreter-exec console bogus" + +# NOTE: cagney/2003-02-03: Not yet. +# mi_gdb_test "-interpreter-exec console \"file $binfile\"" \ +# {(=.*)+\^done} \ +# "-interpreter-exec console \"file \$binfile\"" +mi_gdb_test "-interpreter-exec console \"file $binfile\"" \ + {\^done} \ + "-interpreter-exec console \"file \$binfile\"" + +mi_run_to_main + +mi_gdb_test "-interpreter-exec console \"set args foobar\"" \ + {\^done} \ + "-interpreter-exec console \"set args foobar\"" + +mi_gdb_test "-interpreter-exec console \"show args\"" \ + {\~"Argument list to give program being debugged when it is started is \\\"foobar\\\"\.\\n".*\^done} \ + "-interpreter-exec console \"show args\"" + +# NOTE: cagney/2003-02-03: Not yet. +# mi_gdb_test "-interpreter-exec console \"break callee4\"" \ +# {(&.*)*.*~"Breakpoint 2 at.*\\n".*=breakpoint-create,number="2".*\^done} \ +# "-interpreter-exec console \"break callee4\"" +mi_gdb_test "-interpreter-exec console \"break callee4\"" \ + {(&.*)*.*~"Breakpoint 2 at.*\\n".*\^done} \ + "-interpreter-exec console \"break callee4\"" + +mi_gdb_test "-interpreter-exec console \"info break\"" \ + {\~"Num[ \t]*Type[ \t]*Disp[ \t]*Enb[ \t]*Address[ \t]*What\\n".*~"2[ \t]*breakpoint[ \t]*keep[ \t]*y[ \t]*0x[0-9A-Fa-f]+[ \t]*in callee4 at .*basics.c:[0-9]+\\n".*\^done} \ + "-interpreter-exec console \"info break\"" + +mi_gdb_test "-interpreter-exec console \"set listsize 1\"" \ + {\^done} \ + "-interpreter-exec console \"set listsize 1\"" + +mi_gdb_test "-interpreter-exec console \"list\"" \ + {.*\~"32[ \t(\\t)]*callee1.*\\n".*\^done} \ + "-interpreter-exec console \"list\"" + +# # NOTE: cagney/2003-02-03: Not yet. +# mi_gdb_test "-exec-continue" \ +# {.*\*stopped,reason="breakpoint-hit",.*func="callee4".*file=".*basics.c",line="8"\}} \ +# "-interpreter-exec console \"continue to callee4\"" +send_gdb "999-exec-continue\n" +gdb_expect { + -re "999\\^running\[\r\n\]+$mi_gdb_prompt.*999\\*stopped,reason=.breakpoint-hit.*$mi_gdb_prompt$" { + pass "continue to callee4" + } + timeout { + fail "continue to callee4 (timeout)" + } +} + +# NOTE: cagney/2003-02-03: Not yet. +# mi_gdb_test "100-interpreter-exec console \"delete 2\"" \ +# {.*=breakpoint-delete,number=\"2\".*\^done} \ +# "-interpreter-exec console \"delete 2\"" +mi_gdb_test "100-interpreter-exec console \"delete 2\"" \ + {100\^done} \ + "-interpreter-exec console \"delete 2\"" + +# NOTE: cagney/2003-02-03: Not yet. +# mi_gdb_test "200-interpreter-exec console \"up\"" \ +# {.*=selected-frame-level-changed,level="1".*\^done} \ +# "-interpreter-exec console \"up\"" +mi_gdb_test "200-interpreter-exec console \"up\"" \ + {200\^done} \ + "-interpreter-exec console \"up\"" + +# NOTE: cagney/2003-02-03: Not yet. +# mi_gdb_test "300-interpreter-exec console \"down\"" \ +# {.*=selected-frame-level-changed,level="0".*\^done} \ +# "-interpreter-exec console \"down\"" +mi_gdb_test "300-interpreter-exec console \"down\"" \ + {300\^done} \ + "-interpreter-exec console \"down\"" + +# NOTE: cagney/2003-02-03: Not yet. +# mi_gdb_test "-interpreter-exec console \"frame 2\"" \ +# {.*=selected-frame-level-changed,level="2".*\^done} \ +# "-interpreter-exec console \"frame 2\"" +mi_gdb_test "400-interpreter-exec console \"frame 2\"" \ + {400\^done} \ + "-interpreter-exec console \"frame 2\"" + +# NOTE: cagney/2003-02-03: Not yet. +# mi_gdb_test "-stack-select-frame 0" \ +# {.*=selected-frame-level-changed,level="0".*\^done} \ +# "-stack-select-frame 0" +mi_gdb_test "500-stack-select-frame 0" \ + {500\^done} \ + "-stack-select-frame 0" + +# NOTE: cagney/2003-02-03: Not yet. +# mi_gdb_test "-break-insert -t basics.c:35" \ +# {.*=breakpoint-create,number="3".*\^done} \ +# "-break-insert -t basics.c:35" +mi_gdb_test "600-break-insert -t basics.c:35" \ + {600\^done,bkpt=.number="3",type="breakpoint".*\}} \ + "-break-insert -t basics.c:35" + +# mi_gdb_test "-exec-continue" \ +# {.*\*stopped.*,file=".*basics.c",line="35"\}} \ +# "-exec-continue to line 35" +send_gdb "700-exec-continue\n" +gdb_expect { + -re "700\\^running\[\r\n\]+$mi_gdb_prompt.*\\*stopped.*,file=.*basics.c.,line=.35.*$mi_gdb_prompt$" { + pass "-exec-continue to line 35" + } + timeout { + fail "-exec-continue to line 35" + } +} + +# NOTE: cagney/2003-02-03: Not yet. +# mi_gdb_test "-exec-next" \ +# {.*\*stopped,reason="end-stepping-range",.*,file=".*basics.c",line="37"\}} \ +# "-exec-next to line 37" +send_gdb "800-exec-next\n" +gdb_expect { + -re "800\\^running\[\r\n\]+$mi_gdb_prompt.*\\*stopped,reason=.end-stepping-range.*,file=.*basics.c.,line=.37.*$mi_gdb_prompt$" { + pass "-exec-next to line 37" + } + timeout { + fail "-exec-next to line 37" + } +} + +mi_gdb_test "-interpreter-exec console \"list\"" \ + {\~"37[ \t(\\t)]*return 0;\\n".*\^done} \ + "-interpreter-exec console \"list\" at basics.c:37" + +mi_gdb_test "-interpreter-exec console \"help set args\"" \ + {\~"Set argument list to give program being debugged when it is started\.\\nFollow this command with any number of args, to be passed to the program\.".*\^done} \ + "-interpreter-exec console \"help set args\"" + +# NOTE: cagney/2003-02-03: Not yet. +# mi_gdb_test "-interpreter-exec console \"set \$pc=0x0\"" \ +# {.*=target-changed.*\^done} \ +# "-interpreter-exec console \"set \$pc=0x0\"" +mi_gdb_test "888-interpreter-exec console \"set \$pc=0x0\"" \ + {888\^done} \ + "-interpreter-exec console \"set \$pc=0x0\"" + +#mi_gdb_test "-interpreter-exec console \"\"" \ + {} \ + "-interpreter-exec console \"\"" + +mi_gdb_exit +return 0 diff --git a/gdb/testsuite/gdb.mi/mi2-console.exp b/gdb/testsuite/gdb.mi/mi2-console.exp new file mode 100644 index 0000000..5e307b9 --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi2-console.exp @@ -0,0 +1,97 @@ +# Copyright 1999, 2000, 2001, 2002 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# +# Test essential Machine interface (MI) operations +# +# Verify that, using the MI, we can run a simple program and perform basic +# debugging activities like: insert breakpoints, run the program, +# step, next, continue until it ends and, last but not least, quit. +# +# The goal is not to test gdb functionality, which is done by other tests, +# but to verify the correct output response to MI operations. +# + +# This test only works when talking to a target that routes its output +# through GDB. Check that we're either talking to a simulator or a +# remote target. + +load_lib mi-support.exp +set MIFLAGS "-i=mi2" + +gdb_exit +if [mi_gdb_start] { + continue +} + +set testfile "mi-console" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +mi_run_to_main + +# Next over the hello() call which will produce lots of output +send_gdb "47-exec-next\n" +gdb_expect { + -re "47\\^running\r\n$mi_gdb_prompt" { + pass "Started step over hello" + } + timeout { + fail "Started step over hello (timeout)" + } +} + +gdb_expect { + -re "@\"H\"\r\n.*@\"e\"\r\n.*@\"l\"\r\n.*@\"l\"\r\n.*@\"o\"\r\n.*@\" \"\r\n.*@\"\\\\\\\\\"\r\n.*@\"\\\\\"\"\r\n.*@\"!\"\r\n.*@\"\\\\r\"\r\n.*@\"\\\\n\"\r\n" { + pass "Hello message" + } + -re "Hello" { + + # Probably a native system where GDB doesn't have direct + # control over the inferior console. + # For this to work, GDB would need to run the inferior process + # under a PTY and then use the even-loops ability to wait on + # multiple event sources to channel the output back through the + # MI. + + kfail "gdb/623" "Hello message" + } + timeout { + fail "Hello message (timeout)" + } +} + +gdb_expect { + -re "47\\*stopped.*$mi_gdb_prompt$" { + pass "Finished step over hello" + } + timeout { + fail "Finished step over hello (timeout)" + } +} + +mi_gdb_exit +return 0 diff --git a/gdb/testsuite/gdb.mi/mi2-disassemble.exp b/gdb/testsuite/gdb.mi/mi2-disassemble.exp new file mode 100644 index 0000000..8cd76f9 --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi2-disassemble.exp @@ -0,0 +1,178 @@ +# Copyright 1999, 2000, 2002 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# +# Test Machine interface (MI) operations for disassembly. +# +# The goal is not to test gdb functionality, which is done by other tests, +# but to verify the correct output response to MI operations. +# + +load_lib mi-support.exp +set MIFLAGS "-i=mi2" + +gdb_exit +if [mi_gdb_start] { + continue +} + +set testfile "basics" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +proc test_disassembly_only {} { + global mi_gdb_prompt + global hex + global decimal + + # Test disassembly more only for the current function. + # Tests: + # -data-disassemble -s $pc -e "$pc+8" -- 0 + # -data-disassembly -f basics.c -l 32 -- 0 + + mi_gdb_test "print/x \$pc" "" "" + mi_gdb_test "111-data-disassemble -s \$pc -e \"\$pc + 12\" -- 0" \ + "111\\^done,asm_insns=\\\[\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\},\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}.*\]" \ + "data-disassemble from pc to pc+12 assembly only" + + mi_gdb_test "222-data-disassemble -f basics.c -l 32 -- 0" \ + "222\\^done,asm_insns=\\\[\{address=\"$hex\",func-name=\"main\",offset=\"0\",inst=\".*\"\},.*,\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}\\\]" \ + "data-disassemble file & line, assembly only" +} + +proc test_disassembly_lines_limit {} { + global mi_gdb_prompt + global hex + global decimal + + # Test disassembly more only for the current function. + # Tests: + # -data-disassembly -f basics.c -l 32 -n 20 -- 0 + # -data-disassembly -f basics.c -l 32 -n 0 -- 0 + # -data-disassembly -f basics.c -l 32 -n 50 -- 0 + + mi_gdb_test "print/x \$pc" "" "" + mi_gdb_test "222-data-disassemble -f basics.c -l 32 -n 20 -- 0" \ + "222\\^done,asm_insns=\\\[\{address=\"$hex\",func-name=\"main\",offset=\"0\",inst=\".*\"\},.*,\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}\\\]" \ + "data-disassemble file, line, number assembly only" + + mi_gdb_test "222-data-disassemble -f basics.c -l 32 -n 0 -- 0" \ + "222\\^done,asm_insns=\\\[\\\]" \ + "data-disassemble file, line, number (zero lines) assembly only" + + mi_gdb_test "222-data-disassemble -f basics.c -l 32 -n 50 -- 0" \ + "222\\^done,asm_insns=\\\[\{address=\"$hex\",func-name=\"main\",offset=\"0\",inst=\".*\"\},.*,\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}\\\]" \ + "data-disassemble file, line, number (more than main lines) assembly only" +} + + +proc test_disassembly_mixed {} { + global mi_gdb_prompt + global hex + global decimal + + # Test disassembly more only for the current function. + # Tests: + # -data-disassembly -f basics.c -l 21 -- 1 + # -data-disassembly -s $pc -e "$pc+8" -- 1 + + mi_gdb_test "002-data-disassemble -f basics.c -l 21 -- 1" \ + "002\\^done,asm_insns=\\\[src_and_asm_line=\{line=\"21\",file=\".*basics.c\",line_asm_insn=\\\[\{address=\"$hex\",func-name=\"callee2\",offset=\"0\",inst=\".*\"\}.*\\\]\}.*,src_and_asm_line=\{line=\"$decimal\",file=\".*basics.c\",line_asm_insn=\\\[.*\{address=\"$hex\",func-name=\"callee2\",offset=\"$decimal\",inst=\".*\"\}\\\]\}\\\]" \ + "data-disassemble file, line assembly mixed" + + # + # In mixed mode, the lowest level of granularity is the source line. + # So we are going to get the disassembly for the source line at + # which we are now, even if we have specified that the range is only 2 insns. + # + mi_gdb_test "003-data-disassemble -s \$pc -e \"\$pc+4\" -- 1" \ + "003\\^done,asm_insns=\\\[src_and_asm_line=\{line=\"$decimal\",file=\".*basics.c\",line_asm_insn=\\\[\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}.*\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}\\\]\}\\\]" \ + "data-disassemble range assembly mixed" +} + +proc test_disassembly_mixed_lines_limit {} { + global mi_gdb_prompt + global hex + global decimal + + # Test disassembly more only for the current function. + # Tests: + # -data-disassembly -f basics.c -l 32 -n 20 -- 1 + # -data-disassembly -f basics.c -l 32 -n 0 -- 1 + # -data-disassembly -f basics.c -l 32 -n 50 -- 1 + + mi_gdb_test "print/x \$pc" "" "" + mi_gdb_test "222-data-disassemble -f basics.c -l 32 -n 20 -- 1" \ + "222\\^done,asm_insns=\\\[src_and_asm_line=\{line=\"$decimal\",file=\".*basics.c\",line_asm_insn=\\\[\{address=\"$hex\",func-name=\"main\",offset=\"0\",inst=\".*\"\},.*,\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}\\\]\}\]" \ + "data-disassemble file, line, number assembly mixed" + + mi_gdb_test "222-data-disassemble -f basics.c -l 32 -n 0 -- 1" \ + "222\\^done,asm_insns=\\\[src_and_asm_line=\{line=\"31\",file=\".*basics.c\",line_asm_insn=\\\[\\\]\}\\\]" \ + "data-disassemble file, line, number (zero lines) assembly mixed" + + mi_gdb_test "222-data-disassemble -f basics.c -l 32 -n 50 -- 1" \ + "222\\^done,asm_insns=\\\[src_and_asm_line=\{line=\"$decimal\",file=\".*basics.c\",line_asm_insn=\\\[\{address=\"$hex\",func-name=\"main\",offset=\"0\",inst=\".*\"\}.*,\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}\\\]\}\]" \ + "data-disassemble file, line, number (more than main lines) assembly mixed" +} + +proc test_disassembly_bogus_args {} { + global mi_gdb_prompt + global hex + + # Test that bogus input to disassembly command is rejected. + # Tests: + # -data-disassembly -f foo -l abc -n 0 -- 0 + # -data-disassembly -s foo -e bar -- 0 + # -data-disassembly -s $pc -f basics.c -- 0 + # -data-disassembly -f basics.c -l 32 -- 9 + + mi_gdb_test "123-data-disassemble -f foo -l abc -n 0 -- 0" \ + ".*123\\^error,msg=\"mi_cmd_disassemble: Invalid filename.\"" \ + "data-disassemble bogus filename" + + mi_gdb_test "321-data-disassemble -s foo -e bar -- 0" \ + "321\\^error,msg=\"No symbol \\\\\"foo\\\\\" in current context.\"" \ + "data-disassemble bogus address" + + mi_gdb_test "456-data-disassemble -s \$pc -f basics.c -- 0" \ + "456\\^error,msg=\"mi_cmd_disassemble: Usage: \\( .-f filename -l linenum .-n howmany.. | .-s startaddr -e endaddr.\\) .--. mixed_mode.\"" \ + "data-disassemble mix different args" + + mi_gdb_test "789-data-disassemble -f basics.c -l 32 -- 9" \ + "789\\^error,msg=\"mi_cmd_disassemble: Mixed_mode argument must be 0 or 1.\"" \ + "data-disassemble wrong mode arg" + +} + +mi_run_to_main +test_disassembly_only +test_disassembly_mixed +test_disassembly_bogus_args +test_disassembly_lines_limit +test_disassembly_mixed_lines_limit + +mi_gdb_exit +return 0 diff --git a/gdb/testsuite/gdb.mi/mi2-eval.exp b/gdb/testsuite/gdb.mi/mi2-eval.exp new file mode 100644 index 0000000..85fd991 --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi2-eval.exp @@ -0,0 +1,62 @@ +# Copyright 1999, 2000, 2002 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# +# Test essential Machine interface (MI) operations +# +# Verify -data-evaluate-expression. There are really minimal tests. + +# The goal is not to test gdb functionality, which is done by other tests, +# but to verify the correct output response to MI operations. +# + +load_lib mi-support.exp +set MIFLAGS "-i=mi2" + +gdb_exit +if [mi_gdb_start] { + continue +} + +set testfile "basics" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +mi_runto callee4 +mi_next_to "callee4" "" "basics.c" "9" "next at callee4" + +mi_gdb_test "211-data-evaluate-expression A" "211\\^done,value=\"1\"" "eval A" + +mi_gdb_test "311-data-evaluate-expression &A" "311\\^done,value=\"$hex\"" "eval &A" + +mi_gdb_test "411-data-evaluate-expression A+3" "411\\^done,value=\"4\"" "eval A+3" + +mi_gdb_test "511-data-evaluate-expression \"A + 3\"" "511\\^done,value=\"4\"" "eval A + 3" + + +mi_gdb_exit +return 0 diff --git a/gdb/testsuite/gdb.mi/mi2-file.exp b/gdb/testsuite/gdb.mi/mi2-file.exp new file mode 100644 index 0000000..fe75a93 --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi2-file.exp @@ -0,0 +1,65 @@ +# Copyright 1999 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# +# Test essential Machine interface (MI) operations +# +# Verify that, using the MI, we can run a simple program and perform basic +# debugging activities like: insert breakpoints, run the program, +# step, next, continue until it ends and, last but not least, quit. +# +# The goal is not to test gdb functionality, which is done by other tests, +# but to verify the correct output response to MI operations. +# + +load_lib mi-support.exp +set MIFLAGS "-i=mi2" + +gdb_exit +if [mi_gdb_start] { + continue +} + +set testfile "basics" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +proc test_tbreak_creation_and_listing {} { + global srcfile + global srcdir + global subdir + set srcfilepath [string_to_regexp ${srcdir}/${subdir}/${srcfile}] + + # get the path and absolute path to the current executable + mi_gdb_test "111-file-list-exec-source-file" \ + "111\\\^done,line=\"23\",file=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \ + "request path info of current source file (${srcfile})" +} + +test_tbreak_creation_and_listing + +mi_gdb_exit +return 0 diff --git a/gdb/testsuite/gdb.mi/mi2-hack-cli.exp b/gdb/testsuite/gdb.mi/mi2-hack-cli.exp new file mode 100644 index 0000000..066eea2 --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi2-hack-cli.exp @@ -0,0 +1,40 @@ +# Copyright 1999 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + + +# Some basic checks for the CLI. + +load_lib mi-support.exp +set MIFLAGS "-i=mi2" + +gdb_exit +if [mi_gdb_start] { + continue +} + +mi_gdb_test "show architecture" \ + "&\"show architecture\\\\n\"\r\n~\"The target architecture.*\"\r\n\\^done" \ + "show architecture" + +mi_gdb_test "47show architecture" \ + "&\"show architecture\\\\n\"\r\n~\"The target architecture.*\"\r\n47\\^done" \ + "47show architecture" + +mi_gdb_exit +return 0 diff --git a/gdb/testsuite/gdb.mi/mi2-pthreads.exp b/gdb/testsuite/gdb.mi/mi2-pthreads.exp new file mode 100644 index 0000000..fe007e5 --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi2-pthreads.exp @@ -0,0 +1,221 @@ +# Copyright 2002, 2003 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# This file tests MI thread commands. +# Specifically, we are testing the MI command set and the console (in MI) +# command set ("interpreter-exec") and that the commands that are executed +# via these command pathways are properly executed. Console commands +# executed via MI should use MI output wrappers, MI event handlers, etc. + +# This only works with native configurations +if {![isnative]} { + return +} + +load_lib mi-support.exp +set MIFLAGS "-i=mi2" + +gdb_exit +if {[mi_gdb_start]} { + continue +} + +# The procs below dealing with parsing cli/mi output for the threadlist +# is duplicated in gdb669.exp. Any changes here will probably need to +# be made there as well. + +proc get_mi_thread_list {name} { + global expect_out + + # MI will return a list of thread ids: + # + # -thread-list-ids + # ^done,thread-ids=[thread-id="1",thread-id="2",...],number-of-threads="N" + # (gdb) + mi_gdb_test "-thread-list-ids" \ + {\^done,thread-ids={(thread-id="[0-9]+"(,)?)+},number-of-threads="[0-9]+"} \ + "-thread_list_ids ($name)" + + set output {} + if {[info exists expect_out(buffer)]} { + set output $expect_out(buffer) + } + + set thread_list {} + if {![regexp {thread-ids=\{(thread-id="[0-9]+"(,)?)*\}} $output threads]} { + fail "finding threads in MI output ($name)" + } else { + pass "finding threads in MI output ($name)" + + # Make list of console threads + set start [expr {[string first \{ $threads] + 1}] + set end [expr {[string first \} $threads] - 1}] + set threads [string range $threads $start $end] + foreach thread [split $threads ,] { + if {[scan $thread {thread-id="%d"} num]} { + lappend thread_list $num + } + } + } + + return $thread_list +} + +# Check that MI and the console know of the same threads. +# Appends NAME to all test names. +proc check_mi_and_console_threads {name} { + global expect_out + + mi_gdb_test "-thread-list-ids" \ + {\^done,thread-ids={(thread-id="[0-9]+"(,)*)+},number-of-threads="[0-9]+"} \ + "-thread-list-ids ($name)" + set mi_output {} + if {[info exists expect_out(buffer)]} { + set mi_output $expect_out(buffer) + } + + # GDB will return a list of thread ids and some more info: + # + # (gdb) + # -interpreter-exec console "info threads" + # ~" 4 Thread 2051 (LWP 7734) 0x401166b1 in __libc_nanosleep () at __libc_nanosleep:-1" + # ~" 3 Thread 1026 (LWP 7733) () at __libc_nanosleep:-1" + # ~" 2 Thread 2049 (LWP 7732) 0x401411f8 in __poll (fds=0x804bb24, nfds=1, timeout=2000) at ../sysdeps/unix/sysv/linux/poll.c:63" + # ~"* 1 Thread 1024 (LWP 7731) main (argc=1, argv=0xbfffdd94) at ../../../src/gdb/testsuite/gdb.mi/pthreads.c:160" + # FIXME: kseitz/2002-09-05: Don't use the hack-cli method. + mi_gdb_test "info threads" \ + {.*(~".*"[\r\n]*)+.*} \ + "info threads ($name)" + set console_output {} + if {[info exists $expect_out(buffer)]} { + set console_output $expect_out(buffer) + } + + # Make a list of all known threads to console (gdb's thread IDs) + set console_thread_list {} + foreach line [split $console_output \n] { + if {[string index $line 0] == "~"} { + # This is a line from the console; trim off "~", " ", "*", and "\"" + set line [string trim $line ~\ \"\*] + if {[scan $line "%d" id] == 1} { + lappend console_thread_list $id + } + } + } + + # Now find the result string from MI + set mi_result "" + foreach line [split $mi_output \n] { + if {[string range $line 0 4] == "^done"} { + set mi_result $line + } + } + if {$mi_result == ""} { + fail "finding MI result string ($name)" + } else { + pass "finding MI result string ($name)" + } + + # Finally, extract the thread ids and compare them to the console + set num_mi_threads_str "" + if {![regexp {number-of-threads="[0-9]+"} $mi_result num_mi_threads_str]} { + fail "finding number of threads in MI output ($name)" + } else { + pass "finding number of threads in MI output ($name)" + + # Extract the number of threads from the MI result + if {![scan $num_mi_threads_str {number-of-threads="%d"} num_mi_threads]} { + fail "got number of threads from MI ($name)" + } else { + pass "got number of threads from MI ($name)" + + # Check if MI and console have same number of threads + if {$num_mi_threads != [llength $console_thread_list]} { + fail "console and MI have same number of threads ($name)" + } else { + pass "console and MI have same number of threads ($name)" + + # Get MI thread list + set mi_thread_list [get_mi_thread_list $name] + + # Check if MI and console have the same threads + set fails 0 + foreach ct [lsort $console_thread_list] mt [lsort $mi_thread_list] { + if {$ct != $mt} { + incr fails + } + } + if {$fails > 0} { + fail "MI and console have same threads ($name)" + + # Send a list of failures to the log + send_log "Console has thread ids: $console_thread_list\n" + send_log "MI has thread ids: $mi_thread_list\n" + } else { + pass "MI and console have same threads ($name)" + } + } + } + } +} + +# This procedure tests the various thread commands in MI. +proc check_mi_thread_command_set {} { + + mi_runto done_making_threads + + set thread_list [get_mi_thread_list "in check_mi_thread_command_set"] + + mi_gdb_test "-thread-select" \ + {\^error,msg="mi_cmd_thread_select: USAGE: threadnum."} \ + "check_mi_thread_command_set: -thread-select" + + mi_gdb_test "-thread-select 123456789" \ + {\^error,msg="Thread ID 123456789 not known\."} \ + "check_mi_thread_command_set: -thread-select 123456789" + + foreach thread $thread_list { + # line and file are optional. + # many of the threads are blocked in libc calls, + # and many people have libc's with no symbols. + mi_gdb_test "-thread-select $thread" \ + "\\^done,new-thread-id=\"$thread\",frame={.*}(,line=\"(-)?\[0-9\]+\",file=\".*\")?" \ + "check_mi_thread_command_set: -thread-select $thread" + } +} + +# +# Start here +# +set testfile "pthreads" +set srcfile "$testfile.c" +set binfile "$objdir/$subdir/$testfile" + +set options [list debug incdir=$objdir] +if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } { + return -1 +} + +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load $binfile + +check_mi_thread_command_set + +mi_gdb_exit + diff --git a/gdb/testsuite/gdb.mi/mi2-read-memory.exp b/gdb/testsuite/gdb.mi/mi2-read-memory.exp new file mode 100644 index 0000000..eee36a7 --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi2-read-memory.exp @@ -0,0 +1,86 @@ +# Copyright 1999, 2000, 2002 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# +# test basic Machine interface (MI) operations +# +# Verify that, using the MI, we can load a program and do +# other basic things that are used by all test files through mi_gdb_exit, +# mi_gdb_start, mi_delete_breakpoints, mi_gdb_reinitialize_dir and +# mi_gdb_load, so we can safely use those. +# +# The goal is not to test gdb functionality, which is done by other tests, +# but the command syntax and correct output response to MI operations. +# + +load_lib mi-support.exp +set MIFLAGS "-i=mi2" + +gdb_exit +if [mi_gdb_start] { + continue +} + +set testfile "mi-read-memory" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + + +mi_run_to_main +mi_next_to "main" "" "mi-read-memory.c" "20" "next at main" + +mi_gdb_test "1-data-read-memory" \ + "1\\^error,msg=\".*\"" \ + "no arguments" + + +mi_gdb_test "2-data-read-memory bytes x 1 3 2" \ + "2\\^done,addr=\"$hex\",nr-bytes=\"6\",total-bytes=\"6\",next-row=\"$hex\",prev-row=\"$hex\",next-page=\"$hex\",prev-page=\"$hex\",memory=\\\[{addr=\"$hex\",data=\\\[\"0x00\",\"0x01\"\\\]},{addr=\"$hex\",data=\\\[\"0x02\",\"0x03\"\\\]},{addr=\"$hex\",data=\\\[\"0x04\",\"0x05\"\\\]}\\\]" \ + "3x2, one byte" + + +mi_gdb_test "9-data-read-memory -o -6 -- -0+bytes+6 x 1 3 2" \ + "9\\^done,addr=\"$hex\",nr-bytes=\"6\",total-bytes=\"6\",next-row=\"$hex\",prev-row=\"$hex\",next-page=\"$hex\",prev-page=\"$hex\",memory=\\\[{addr=\"$hex\",data=\\\[\"0x00\",\"0x01\"\\\]},{addr=\"$hex\",data=\\\[\"0x02\",\"0x03\"\\\]},{addr=\"$hex\",data=\\\[\"0x04\",\"0x05\"\\\]}\\\]" \ + "3x2, one byte offset by -6" + + +mi_gdb_test "3-data-read-memory \"(shorts + 128)\" x 2 1 2" \ + "3\\^done,addr=\"$hex\",nr-bytes=\"4\",total-bytes=\"4\",next-row=\"$hex\",prev-row=\"$hex\",next-page=\"$hex\",prev-page=\"$hex\",memory=\\\[{addr=\"$hex\",data=\\\[\"0x0100\",\"0x0102\"\\\]}\\\]" \ + "expression in quotes" + + +mi_gdb_test "4-data-read-memory bytes+16 x 1 8 4 x" \ + "4\\^done,addr=\"$hex\",nr-bytes=\"32\",total-bytes=\"32\",next-row=\"$hex\",prev-row=\"$hex\",next-page=\"$hex\",prev-page=\"$hex\",memory=\\\[{addr=\"$hex\",data=\\\[\"0x10\",\"0x11\",\"0x12\",\"0x13\"\\\],ascii=\"xxxx\"},{addr=\"$hex\",data=\\\[\"0x14\",\"0x15\",\"0x16\",\"0x17\"\\\],ascii=\"xxxx\"},{addr=\"$hex\",data=\\\[\"0x18\",\"0x19\",\"0x1a\",\"0x1b\"\\\],ascii=\"xxxx\"},{addr=\"$hex\",data=\\\[\"0x1c\",\"0x1d\",\"0x1e\",\"0x1f\"\\\],ascii=\"xxxx\"},{addr=\"$hex\",data=\\\[\"0x20\",\"0x21\",\"0x22\",\"0x23\"\\\],ascii=\" !\\\\\"#\"},{addr=\"$hex\",data=\\\[\"0x24\",\"0x25\",\"0x26\",\"0x27\"\\\],ascii=\"\\$%&'\"},{addr=\"$hex\",data=\\\[\"0x28\",\"0x29\",\"0x2a\",\"0x2b\"\\\],ascii=\"().+\"},{addr=\"$hex\",data=\\\[\"0x2c\",\"0x2d\",\"0x2e\",\"0x2f\"\\\],ascii=\",-\./\"}\\\]" \ + "ascii and data" + + +mi_gdb_test "5-data-read-memory shorts+64 d 2 1 1" \ + "5\\^done,addr=\"$hex\",nr-bytes=\"2\",total-bytes=\"2\",next-row=\"$hex\",prev-row=\"$hex\",next-page=\"$hex\",prev-page=\"$hex\",memory=\\\[{addr=\"$hex\",data=\\\[\"128\"\\\]}\\\]" \ + "decimal" + +mi_gdb_test "6-data-read-memory shorts+64 o 2 1 1" \ + "6\\^done,addr=\"$hex\",nr-bytes=\"2\",total-bytes=\"2\",next-row=\"$hex\",prev-row=\"$hex\",next-page=\"$hex\",prev-page=\"$hex\",memory=\\\[{addr=\"$hex\",data=\\\[\"0200\"\\\]}\\\]" \ + "octal" + + +mi_gdb_exit +return 0 diff --git a/gdb/testsuite/gdb.mi/mi2-regs.exp b/gdb/testsuite/gdb.mi/mi2-regs.exp new file mode 100644 index 0000000..a14b241 --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi2-regs.exp @@ -0,0 +1,129 @@ +# Copyright 1999, 2000, 2002 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu +# +# Test essential Machine interface (MI) operations +# +# Verify that, using the MI, we can run a simple program and look at registers. +# +# The goal is not to test gdb functionality, which is done by other tests, +# but to verify the correct output response to MI operations. +# + + +load_lib mi-support.exp +set MIFLAGS "-i=mi2" + +gdb_exit +if [mi_gdb_start] { + continue +} + +set testfile "basics" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +proc sparc_register_tests_no_exec { } { + # Test the generic IDT chip. + mi_gdb_test "111-data-list-register-values" \ + ".*111\\^error,msg=\"mi_cmd_data_list_register_values: Usage: -data-list-register-values <format> \\\[<regnum1>...<regnumN>\\\]\"" \ + "wrong arguments" + + mi_gdb_test "111-data-list-register-values x" \ + ".*111\\^error,msg=\"mi_cmd_data_list_register_values: No registers\.\"" \ + "no executable" +} + +# These tests exercise IDT-specific MIPS registers for several +# different processor models. + +# This should detect the actual processor in use and change +# the expected results appropriately. FIXME + +proc sparc_register_tests { } { + global hex + global decimal + set octal "\[0-7\]+" + set binary "\[0-1\]+" + set float "\\-?((\[0-9\]+(\\.\[0-9\]+)?(e\[-+\]\[0-9\]+)?)|(nan\\($hex\\)))" + set float2 "\\-?\[0-9\]+" + + mi_gdb_test "111-data-list-register-names" \ + "111\\^done,register-names=\\\[\"g0\",\"g1\",\"g2\",\"g3\",\"g4\",\"g5\",\"g6\",\"g7\",\"o0\",\"o1\",\"o2\",\"o3\",\"o4\",\"o5\",\"sp\",\"o7\",\"l0\",\"l1\",\"l2\",\"l3\",\"l4\",\"l5\",\"l6\",\"l7\",\"i0\",\"i1\",\"i2\",\"i3\",\"i4\",\"i5\",\"fp\",\"i7\",\"f0\",\"f1\",\"f2\",\"f3\",\"f4\",\"f5\",\"f6\",\"f7\",\"f8\",\"f9\",\"f10\",\"f11\",\"f12\",\"f13\",\"f14\",\"f15\",\"f16\",\"f17\",\"f18\",\"f19\",\"f20\",\"f21\",\"f22\",\"f23\",\"f24\",\"f25\",\"f26\",\"f27\",\"f28\",\"f29\",\"f30\",\"f31\",\"y\",\"psr\",\"wim\",\"tbr\",\"pc\",\"npc\",\"fpsr\",\"cpsr\"\\\]" \ + "list register names" + + mi_gdb_test "222-data-list-register-values x" \ + "222\\^done,register-values=\\\[\{number=\"0\",value=\"$hex\"\}.*\{number=\"71\",value=\"$hex\"\}\\\]" \ + "register values x" + + mi_gdb_test "333-data-list-register-values f" \ + "333\\^done,register-values=\\\[\{number=\"0\",value=\"$float\"\},\{number=\"1\",value=\"$float\"\},.*\{number=\"71\",value=\"$float\"\}\\\]" \ + "register values f" + + mi_gdb_test "444-data-list-register-values d" \ + "444\\^done,register-values=\\\[\{number=\"0\",value=\"$decimal\"\}.*\{number=\"71\",value=\"$decimal\"\}\\\]" \ + "register values d" + + mi_gdb_test "555-data-list-register-values o" \ + "555\\^done,register-values=\\\[\{number=\"0\",value=\"$octal\"\}.*\{number=\"71\",value=\"$octal\"\}\\\]" \ + "register values o" + + mi_gdb_test "666-data-list-register-values t" \ + "666\\^done,register-values=\\\[\{number=\"0\",value=\"$binary\"\}.*\{number=\"71\",value=\"$binary\"\}\\\]" \ + "register values t" + + # On the sparc, registers 0-31 are int, 32-63 float, 64-71 int + + mi_gdb_test "777-data-list-register-values N" \ + "777\\^done,register-values=\\\[\{number=\"0\",value=\"$decimal\"\}.*\{number=\"31\",value=\"$decimal\"\},\{number=\"32\",value=\"$float\"\}.*\{number=\"63\",value=\"$float\"\},\{number=\"64\",value=\"$decimal\"\}.*\{number=\"71\",value=\"$decimal\"\}\\\]" \ + "register values N" + + mi_gdb_test "888-data-list-register-values r" \ + "888\\^done,register-values=\\\[\{number=\"0\",value=\"$hex\"\}.*\{number=\"71\",value=\"$hex\"\}\\\]" \ + "register values r" + + mi_gdb_test "999-data-list-register-names 68 69 70 71" \ + "999\\^done,register-names=\\\[\"pc\",\"npc\",\"fpsr\",\"cpsr\"\\\]" \ + "list names of some regs" + + mi_gdb_test "001-data-list-register-values x 68 69 70 71" \ + "001\\^done,register-values=\\\[\{number=\"68\",value=\"$hex\"\},\{number=\"69\",value=\"$hex\"\},\{number=\"70\",value=\"$hex\"\},\{number=\"71\",value=\"$hex\"\}\\\]" \ + "list values of some regs" + + mi_gdb_test "002-data-list-changed-registers" \ + "002\\^done,changed-registers=\\\[(\"${decimal}\"(,\"${decimal}\")*)?\\\]" \ + "list changed registers" +} + +if [istarget "sparc-*-*"] then { + sparc_register_tests_no_exec + mi_run_to_main + sparc_register_tests +} else { + verbose "mi-regs.exp tests ignored for this target" +} + +mi_gdb_exit +return 0 diff --git a/gdb/testsuite/gdb.mi/mi2-return.exp b/gdb/testsuite/gdb.mi/mi2-return.exp new file mode 100644 index 0000000..b54f15a --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi2-return.exp @@ -0,0 +1,72 @@ +# Copyright 1999, 2000, 2002 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# Test Machine interface (MI) operations +# Verify that, using the MI, we can run a simple program and perform +# exec-return. + +# The goal is not to +# test gdb functionality, which is done by other tests, but to verify +# the correct output response to MI operations. +# + +load_lib mi-support.exp +set MIFLAGS "-i=mi2" + +gdb_exit +if [mi_gdb_start] { + continue +} + +set testfile "basics" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + + +proc test_return_simple {} { + global mi_gdb_prompt + global hex + + send_gdb "111-exec-return\n" + gdb_expect { + -re "111\\^done,frame=\{level=\"0\",addr=\"$hex\",func=\"callee3\",args=\\\[.*\\\],file=\".*basics.c\",line=\"18\"\}\r\n$mi_gdb_prompt$" {pass "return from callee4 now"} + -re ".*\r\n$mi_gdb_prompt$" { fail "return from callee4 now" } + timeout { fail "return from callee4 now (timeout)" + } + } +} + +mi_runto callee4 + +mi_gdb_test "205-break-delete" \ + "205\\^done.*" \ + "delete all breakpoints" + +test_return_simple + +mi_gdb_exit +return 0 diff --git a/gdb/testsuite/gdb.mi/mi2-simplerun.exp b/gdb/testsuite/gdb.mi/mi2-simplerun.exp new file mode 100644 index 0000000..93d4426 --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi2-simplerun.exp @@ -0,0 +1,199 @@ +# Copyright 1999, 2000 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# +# Test essential Machine interface (MI) operations +# +# Verify that, using the MI, we can run a simple program and perform basic +# debugging activities like: insert breakpoints, run the program, +# step, next, continue until it ends and, last but not least, quit. +# +# The goal is not to test gdb functionality, which is done by other tests, +# but to verify the correct output response to MI operations. +# + +load_lib mi-support.exp +set MIFLAGS "-i=mi2" + +gdb_exit +if [mi_gdb_start] { + continue +} + +set testfile "basics" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +proc test_breakpoints_creation_and_listing {} { + global mi_gdb_prompt + global srcfile + global hex + + # Insert some breakpoints and list them + # Also, disable some so they do not interfere with other tests + # Tests: + # -break-insert + # -break-list + # -break-disable + # -break-info + + mi_gdb_test "200-break-insert main" \ + "200\\^done,bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*basics.c\",line=\"32\",times=\"0\"\}" \ + "break-insert operation" + + mi_gdb_test "201-break-insert basics.c:callee2" \ + "201\\^done,bkpt=\{number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"callee2\",file=\".*basics.c\",line=\"22\",times=\"0\"\}" \ + "insert breakpoint at basics.c:callee2" + + mi_gdb_test "202-break-insert basics.c:15" \ + "202\\^done,bkpt=\{number=\"3\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"callee3\",file=\".*basics.c\",line=\"15\",times=\"0\"\}" \ + "insert breakpoint at basics.c:15 (callee3)" + + mi_gdb_test "203-break-insert \"\\\"${srcfile}\\\":6\"" \ + "203\\^done,bkpt=\{number=\"4\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"callee4\",file=\".*basics.c\",line=\"6\",times=\"0\"\}" \ + "insert breakpoint at \"<fullfilename>\":6 (callee4)" + + mi_gdb_test "204-break-list" \ + "204\\^done,BreakpointTable=\{.*,hdr=\\\[.*\\\],body=\\\[bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*basics.c\",line=\"32\",times=\"0\"\},.*\}\\\]\}" \ + "list of breakpoints" + + mi_gdb_test "205-break-disable 2 3 4" \ + "205\\^done.*" \ + "disabling of breakpoints" + + mi_gdb_test "206-break-info 2" \ + "206\\^done,BreakpointTable=\{.*,hdr=\\\[.*\\\],body=\\\[bkpt=\{number=\"2\",.*,enabled=\"n\",.*\}\\\]\}" \ + "list of breakpoints, 16 disabled" +} + +proc test_running_the_program {} { + global mi_gdb_prompt + global hex + + # Run the program without args, then specify srgs and rerun the program + # Tests: + # -exec-run + # -gdb-set + + # mi_gdb_test cannot be used for asynchronous commands because there are + # two prompts involved and this can lead to a race condition. + # The following is equivalent to a send_gdb "000-exec-run\n" + mi_run_cmd + gdb_expect { + -re "000\\*stopped,reason=\"breakpoint-hit\",bkptno=\"1\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"main\",args=\\\[\\\],file=\".*basics.c\",line=\"32\"\}\r\n$mi_gdb_prompt$" { + pass "run to main" + } + -re ".*$mi_gdb_prompt$" { + fail "run to main (2)" + } + timeout { + fail "run to main (timeout)" + } + } +} + +proc test_controlled_execution {} { + global mi_gdb_prompt + global hex + + # Continue execution until a breakpoint is reached, step into calls, verifying + # if the arguments are correctly shown, continue to the end of a called + # function, step over a call (next). + # Tests: + # -exec-continue + # -exec-next + # -exec-step + # -exec-finish + + mi_next_to "main" "" "basics.c" "33" "next at main" + + # FIXME: A string argument is not printed right; should be fixed and + # we should look for the right thing here. + # NOTE: The ``\\\\\"'' is for \". + mi_step_to "callee1" \ + "\{name=\"intarg\",value=\"2\"\},\{name=\"strarg\",value=\"$hex \\\\\"A string argument\.\\\\\"\"\},\{name=\"fltarg\",value=\"3.5\"\}" \ + "basics.c" "27" "step at main" + + # FIXME: A string argument is not printed right; should be fixed and + # we should look for the right thing here. + mi_execute_to "exec-step 3" "end-stepping-range" "callee4" "" \ + "basics.c" "8" "" "step to callee4" + + # FIXME: A string argument is not printed right; should be fixed and + # we should look for the right thing here. + # NOTE: The ``.'' is part of ``gdb-result-var="$1"'' + mi_finish_to "callee3" ".*" "basics.c" "18" ".1" "0" "exec-finish" +} + +proc test_controlling_breakpoints {} { + global mi_gdb_prompt + + # Enable, delete, set ignore counts in breakpoints + # (disable was already tested above) + # Tests: + # -break-delete + # -break-enable + # -break-after + # -break-condition + +} + +proc test_program_termination {} { + global mi_gdb_prompt + + # Run to completion: normal and forced + # Tests: + # -exec-abort + # (normal termination of inferior) + + # FIXME: "stopped" doesn't seem appropriate. + # mi_gdb_test cannot be used for asynchronous commands because there are + # two prompts involved and this can lead to a race condition. + send_gdb "999-exec-continue\n" + gdb_expect { + -re "999\\^running\r\n$mi_gdb_prompt" { + gdb_expect { + -re "999\\*stopped,reason=\"exited-normally\"\r\n$mi_gdb_prompt$" { + pass "continue to end" + } + -re ".*$mi_gdb_prompt$" {fail "continue to end (2)"} + timeout {fail "continue to end (timeout 2)"} + } + } + -re ".*$mi_gdb_prompt$" {fail "continue to end (1)"} + timeout {fail "continue to end (timeout 1)"} + } +} + +test_breakpoints_creation_and_listing +test_running_the_program +test_controlled_execution +test_controlling_breakpoints +test_program_termination + +mi_gdb_exit +return 0 diff --git a/gdb/testsuite/gdb.mi/mi2-stack.exp b/gdb/testsuite/gdb.mi/mi2-stack.exp new file mode 100644 index 0000000..f0a4a61 --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi2-stack.exp @@ -0,0 +1,203 @@ +# Copyright 2000, 2002 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# +# Test essential Machine interface (MI) operations +# +# Verify that stack commands work. + +# The goal is not to test gdb functionality, which is done by other tests, +# but to verify the correct output response to MI operations. +# + +load_lib mi-support.exp +set MIFLAGS "-i=mi2" + +gdb_exit +if [mi_gdb_start] { + continue +} + +set testfile "basics" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +proc test_stack_frame_listing {} { + global mi_gdb_prompt + global hex + + # Obtain a stack trace + # Tests: + # -stack-list-frames + # -stack-list-frames 1 1 + # -stack-list-frames 1 3 + + mi_gdb_test "231-stack-list-frames" \ + "231\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"callee4\",file=\".*basics.c\",line=\"8\"\},frame=\{level=\"1\",addr=\"$hex\",func=\"callee3\",.*\},frame=\{level=\"2\",addr=\"$hex\",func=\"callee2\",.*\},frame=\{level=\"3\",addr=\"$hex\",func=\"callee1\",.*\},frame=\{level=\"4\",addr=\"$hex\",func=\"main\",.*\}\\\]" \ + "stack frame listing" + mi_gdb_test "232-stack-list-frames 1 1" \ + "232\\^done,stack=\\\[frame=\{level=\"1\",addr=\"$hex\",func=\"callee3\",.*\}\\\]" \ + "stack frame listing 1 1" + mi_gdb_test "233-stack-list-frames 1 3" \ + "233\\^done,stack=\\\[frame=\{level=\"1\",addr=\"$hex\",func=\"callee3\",.*\},frame=\{level=\"2\",addr=\"$hex\",func=\"callee2\",.*\},frame=\{level=\"3\",addr=\"$hex\",func=\"callee1\",.*\}\\\]" \ + "stack frame listing 1 3" + + mi_gdb_test "234-stack-list-frames 1" \ + "234\\^error,msg=\"mi_cmd_stack_list_frames: Usage.*FRAME_LOW FRAME_HIGH.*\"" \ + "stack frame listing wrong" +} + +proc test_stack_args_listing {} { + global mi_gdb_prompt + global hex + + # Obtain lists for args for the stack frames + # Tests: + # -stack-list-arguments 0 + # -stack-list-arguments 0 1 1 + # -stack-list-arguments 0 1 3 + # -stack-list-arguments 1 + # -stack-list-arguments 1 1 1 + # -stack-list-arguments 1 1 3 + # -stack-list-arguments + + mi_gdb_test "231-stack-list-arguments 0" \ + "231\\^done,stack-args=\\\[frame=\{level=\"0\",args=\\\[\\\]\},frame=\{level=\"1\",args=\\\[name=\"strarg\"\\\]\},frame=\{level=\"2\",args=\\\[name=\"intarg\",name=\"strarg\"\\\]\},frame=\{level=\"3\",args=\\\[name=\"intarg\",name=\"strarg\",name=\"fltarg\"\\\]\},frame=\{level=\"4\",args=\\\[\\\]\}\\\]" \ + "stack args listing 0" + + mi_gdb_test "232-stack-list-arguments 0 1 1" \ + "232\\^done,stack-args=\\\[frame=\{level=\"1\",args=\\\[name=\"strarg\"\\\]\}\\\]" \ + "stack args listing 0 1 1" + + mi_gdb_test "233-stack-list-arguments 0 1 3" \ + "233\\^done,stack-args=\\\[frame=\{level=\"1\",args=\\\[name=\"strarg\"\\\]\},frame=\{level=\"2\",args=\\\[name=\"intarg\",name=\"strarg\"\\\]\},frame=\{level=\"3\",args=\\\[name=\"intarg\",name=\"strarg\",name=\"fltarg\"\\\]\}\\\]" \ + "stack args listing 0 1 3" + + mi_gdb_test "231-stack-list-arguments 1" \ + "231\\^done,stack-args=\\\[frame=\{level=\"0\",args=\\\[\\\]\},frame=\{level=\"1\",args=\\\[\{name=\"strarg\",value=\"$hex \\\\\"A string argument.\\\\\"\"\}\\\]\},frame=\{level=\"2\",args=\\\[\{name=\"intarg\",value=\"2\"\},\{name=\"strarg\",value=\"$hex \\\\\"A string argument.\\\\\"\"\}\\\]\},frame=\{level=\"3\",args=\\\[\{name=\"intarg\",value=\"2\"\},\{name=\"strarg\",value=\"$hex \\\\\"A string argument.\\\\\"\"\},\{name=\"fltarg\",value=\"3.5\"\}\\\]\},frame=\{level=\"4\",args=\\\[\\\]\}\\\]" \ + "stack args listing 1" + + mi_gdb_test "232-stack-list-arguments 1 1 1" \ + "232\\^done,stack-args=\\\[frame=\{level=\"1\",args=\\\[\{name=\"strarg\",value=\"$hex \\\\\"A string argument.\\\\\"\"\}\\\]\}\\\]" \ + "stack args listing 1 1 1" + + mi_gdb_test "233-stack-list-arguments 1 1 3" \ + "233\\^done,stack-args=\\\[frame=\{level=\"1\",args=\\\[\{name=\"strarg\",value=\"$hex \\\\\"A string argument.\\\\\"\"\}\\\]\},frame=\{level=\"2\",args=\\\[\{name=\"intarg\",value=\"2\"\},\{name=\"strarg\",value=\"$hex \\\\\"A string argument.\\\\\"\"\}\\\]\},frame=\{level=\"3\",args=\\\[\{name=\"intarg\",value=\"2\"\},\{name=\"strarg\",value=\"$hex \\\\\"A string argument.\\\\\"\"\},\{name=\"fltarg\",value=\"3.5\"\}\\\]\}\\\]" \ + "stack args listing 1 1 3" + + mi_gdb_test "234-stack-list-arguments" \ + "234\\^error,msg=\"mi_cmd_stack_list_args: Usage.*PRINT_VALUES.*FRAME_LOW FRAME_HIGH.*\"" \ + "stack args listing wrong" +} + +proc test_stack_info_depth {} { + global mi_gdb_prompt + global hex + + # Obtain depth of stack + # Tests: + # -stack-info-depth + # -stack-info-depth 3 + # -stack-info-depth 99 + + mi_gdb_test "231-stack-info-depth" \ + "231\\^done,depth=\"5\"" \ + "stack info-depth" + + mi_gdb_test "231-stack-info-depth 3" \ + "231\\^done,depth=\"3\"" \ + "stack info-depth 3" + + mi_gdb_test "231-stack-info-depth 99" \ + "231\\^done,depth=\"5\"" \ + "stack info-depth 99" + + mi_gdb_test "231-stack-info-depth 99 99" \ + "231\\^error,msg=\"mi_cmd_stack_info_depth: Usage: .MAX_DEPTH.\"" \ + "stack info-depth wrong usage" +} + +proc test_stack_locals_listing {} { + global mi_gdb_prompt + global hex + + # Obtain lists for locals for the stack frames + # Tests: + # -stack-list-locals 0 + # -stack-list-locals 1 + # -stack-list-arguments + + mi_gdb_test "232-stack-list-locals 0" \ + "232\\^done,locals=\\\[name=\"A\",name=\"B\",name=\"C\"\\\]" \ + "stack locals listing 0" + +# step until A, B, C, have some reasonable values. +send_gdb "-exec-next 3\n" +gdb_expect { + -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"callee4\",args=\\\[\\\],file=\".*basics.c\",line=\"13\"\}\r\n$mi_gdb_prompt$" { + pass "next's in callee4" + } + timeout { fail "next in callee4 (timeout)" } +} + + mi_gdb_test "232-stack-list-locals 1" \ + "232\\^done,locals=\\\[\{name=\"A\",value=\"1\"\},\{name=\"B\",value=\"2\"\},\{name=\"C\",value=\"3\"\}\\\]" \ + "stack locals listing 1" + + mi_gdb_test "234-stack-list-locals" \ + "234\\^error,msg=\"mi_cmd_stack_list_locals: Usage.*PRINT_VALUES.*\"" \ + "stack locals listing wrong" + + mi_gdb_test "232-stack-select-frame 1" \ + "232\\^done" \ + "stack select frame 1" + + mi_gdb_test "232-stack-list-locals 1" \ + "232\\^done,locals=\\\[\\\]" \ + "stack locals listing for new frame" + +# this should be a no-op + + mi_gdb_test "232-stack-select-frame" \ + "232\\^done" \ + "stack select same frame" + + mi_gdb_test "232-stack-list-locals 1" \ + "232\\^done,locals=\\\[\\\]" \ + "stack locals for same frame (level 1)" + +} + +mi_runto callee4 +test_stack_frame_listing +test_stack_args_listing +test_stack_locals_listing +test_stack_info_depth + + +mi_gdb_exit +return 0 diff --git a/gdb/testsuite/gdb.mi/mi2-stepi.exp b/gdb/testsuite/gdb.mi/mi2-stepi.exp new file mode 100644 index 0000000..208b9e2 --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi2-stepi.exp @@ -0,0 +1,86 @@ +# Copyright 1999, 2000, 2002 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# Test Machine interface (MI) operations +# Verify that, using the MI, we can run a simple program and perform +# exec-step-instruction and exec-next-instruction. + +# The goal is not to +# test gdb functionality, which is done by other tests, but to verify +# the correct output response to MI operations. +# + +load_lib mi-support.exp +set MIFLAGS "-i=mi2" + +gdb_exit +if [mi_gdb_start] { + continue +} + +set testfile "basics" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +proc test_stepi_nexti {} { + global mi_gdb_prompt + global hex + + send_gdb "111-exec-step-instruction\n" + gdb_expect { + -re "111\\^running\r\n${mi_gdb_prompt}111\\*stopped,reason=\"end-stepping-range\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"main\",args=\\\[\\\],file=\".*basics.c\",line=\"3.\"\}\r\n$mi_gdb_prompt$" { + pass "step-instruction at main" + } + timeout { + fail "step-instruction at main (timeout)" + } + } + send_gdb "222-exec-next-instruction\n" + gdb_expect { + -re "222\\^running\r\n${mi_gdb_prompt}222\\*stopped,reason=\"end-stepping-range\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"main\",args=\\\[\\\],file=\".*basics.c\",line=\"3.\"\}\r\n$mi_gdb_prompt$" { + pass "next-instruction at main" + } + timeout { + fail "next-instruction at main (timeout)" + } + } + send_gdb "333-exec-next-instruction\n" + gdb_expect { + -re "333\\^running\r\n${mi_gdb_prompt}333\\*stopped,reason=\"end-stepping-range\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"main\",args=\\\[\\\],file=\".*basics.c\",line=\"3.\"\}\r\n$mi_gdb_prompt$" { + pass "next-instruction at main" + } + timeout { + fail "next-instruction at main (timeout)" + } + } +} + +mi_run_to_main +test_stepi_nexti + +mi_gdb_exit +return 0 diff --git a/gdb/testsuite/gdb.mi/mi2-syn-frame.exp b/gdb/testsuite/gdb.mi/mi2-syn-frame.exp new file mode 100644 index 0000000..263bb39 --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi2-syn-frame.exp @@ -0,0 +1,111 @@ +# Copyright 2002, 2003 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# Test MI output with synthetic frames on the stack (call dummies, +# signal handlers). + +if [target_info exists gdb,nosignals] { + verbose "Skipping mi-syn-frame.exp because of nosignals." + continue +} + +load_lib mi-support.exp +set MIFLAGS "-i=mi2" + +set testfile "mi-syn-frame" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +set my_mi_gdb_prompt "\\(gdb\\)\[ \]*\[\r\n\]*" + +mi_gdb_exit +mi_gdb_start +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} +mi_run_to_main + +mi_gdb_test "400-break-insert foo" "400\\^done,bkpt=\{number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"foo\",file=\".*mi-syn-frame.c\",line=\"$decimal\",times=\"0\"\}" + + +# +# Call foo() by hand, where we'll hit a breakpoint. +# + +mi_gdb_test "401-data-evaluate-expression foo()" "\\&\"The program being debugged stopped while in a function called from GDB.\\\\n\"\[\r\n\]+\\&\"When the function \\(foo\\) is done executing, GDB will silently\\\\n\"\[\r\n\]+\\&\"stop \\(instead of continuing to evaluate the expression containing\\\\n\"\[\r\n\]+\\&\"the function call\\).\\\\n\"\[\r\n\]+401\\^error,msg=\"The program being debugged stopped while in a function called from GDB.*\"" "call inferior's function with a breakpoint set in it" + +mi_gdb_test "402-stack-list-frames" "402\\^done,reason=\"breakpoint-hit\",bkptno=\"2\",thread-id=\"$decimal\",frame=\{addr=\"$hex\",func=\"foo\",args=\\\[\\\],file=\".*mi-syn-frame.c\",line=\"$decimal\"\},stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"foo\",file=\".*mi-syn-frame.c\",line=\"$decimal\"\},frame=\{level=\"1\",addr=\"$hex\",func=\"<function called from gdb>\"\},frame=\{level=\"2\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",line=\"$decimal\"\}.*\\\]" "backtrace from inferior function stopped at bp, showing gdb dummy frame" + +# +# Continue back to main() +# + +send_gdb "403-exec-continue\n" +gdb_expect { + -re "403\\^running\[\r\n\]+${my_mi_gdb_prompt}hi in foo\[\r\n\]+403\\\*stopped\[\r\n\]+${my_mi_gdb_prompt}$" { + pass "403-exec-continue" + } + timeout { + fail "403-exec-continue" + } +} + +mi_gdb_test "404-stack-list-frames 0 0" "404\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",line=\"$decimal\"\}.*\\\]" + + +# +# Call have_a_very_merry_interrupt() which will eventually raise a signal +# that's caught by handler() which calls subroutine(). + +mi_gdb_test "405-break-insert subroutine" "405\\^done,bkpt=\{number=\"3\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"subroutine\",file=\".*mi-syn-frame.c\",line=\"$decimal\",times=\"0\"\}" + +mi_gdb_test "406-data-evaluate-expression have_a_very_merry_interrupt()" "Waiting to get a signal\[\r\n\]+\\&\"The program being debugged stopped while in a function called from GDB.\\\\n\"\[\r\n\]+\\&\"When the function \\(have_a_very_merry_interrupt\\) is done executing, GDB will silently\\\\n\"\[\r\n\]+\\&\"stop \\(instead of continuing to evaluate the expression containing\\\\n\"\[\r\n\]+\\&\"the function call\\).\\\\n\"\[\r\n\]+406\\^error,msg=\"The program being debugged stopped while in a function called from GDB.\\\\nWhen the function \\(have_a_very_merry_interrupt\\) is done executing, GDB will silently\\\\nstop \\(instead of continuing to evaluate the expression containing\\\\nthe function call\\).\"" + +# We should have both a signal handler and a call dummy frame +# in this next output. + +mi_gdb_test "407-stack-list-frames" "407\\^done,reason=\"breakpoint-hit\",bkptno=\"3\",thread-id=\"$decimal\",frame=\{addr=\"$hex\",func=\"subroutine\",args=\\\[\{name=\"in\",value=\"$decimal\"\}\\\],file=\".*mi-syn-frame.c\",line=\"$decimal\"\},stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"subroutine\",file=\".*mi-syn-frame.c\",line=\"$decimal\"\},frame=\{level=\"1\",addr=\"$hex\",func=\"handler\",file=\".*mi-syn-frame.c\",line=\"$decimal\"\},frame=\{level=\"2\",addr=\"$hex\",func=\"<signal handler called>\"\},.*frame=\{level=\"$decimal\",addr=\"$hex\",func=\"have_a_very_merry_interrupt\",file=\".*mi-syn-frame.c\",line=\"$decimal\"\},frame=\{level=\"$decimal\",addr=\"$hex\",func=\"<function called from gdb>\"\},frame=\{level=\"$decimal\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",line=\"$decimal\"\}.*\\\]" + + +send_gdb "408-exec-continue\n" +gdb_expect { + -re "408\\^running\[\r\n\]+${my_mi_gdb_prompt}408\\\*stopped\[\r\n\]+${my_mi_gdb_prompt}$" { + pass "408-exec-continue" + } + timeout { + fail "408-exec-continue" + } +} + +mi_gdb_test "409-stack-list-frames 0 0" "409\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",line=\"$decimal\"\}.*\\\]" + +# +# Call bar() by hand, which should get an exception while running. +# + +mi_gdb_test "410-data-evaluate-expression bar()" "hi in bar\[\r\n\]+\\&\"The program being debugged was signaled while in a function called from GDB.\\\\n\"\[\r\n\]+\\&\"GDB remains in the frame where the signal was received.\\\\n\"\[\r\n\]+\\&\"To change this behavior use \\\\\"set unwindonsignal on\\\\\"\\\\n\"\[\r\n\]+\\&\"Evaluation of the expression containing the function \\(bar\\) will be abandoned.\\\\n\"\[\r\n\]+410\\^error,msg=\"The program being debugged was signaled while in a function called from GDB.\\\\nGDB remains in the frame where the signal was received.\\\\nTo change this behavior use \\\\\"set unwindonsignal on\\\\\"\\\\nEvaluation of the expression containing the function \\(bar\\) will be abandoned.\"" "call inferior function which raises exception" + +mi_gdb_test "411-stack-list-frames" "411\\^done,reason=\"signal-received\",signal-name=\".*\",signal-meaning=\".*\",thread-id=\"$decimal\",frame=\{addr=\"$hex\",func=\"bar\",args=\\\[\\\],file=\".*mi-syn-frame.c\",line=\"$decimal\"\},stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"bar\",file=\".*mi-syn-frame.c\",line=\"$decimal\"},frame=\{level=\"1\",addr=\"$hex\",func=\"<function called from gdb>\"\},frame=\{level=\"2\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",line=\"$decimal\"}.*\\\]" "backtrace from inferior function at exception" + +mi_gdb_exit + +return 0 diff --git a/gdb/testsuite/gdb.mi/mi2-until.exp b/gdb/testsuite/gdb.mi/mi2-until.exp new file mode 100644 index 0000000..4ef296c --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi2-until.exp @@ -0,0 +1,127 @@ +# Copyright 1999, 2000 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# Test Machine interface (MI) operations +# Verify that, using the MI, we can run a simple program and perform +# exec-until. + +# The goal is not to +# test gdb functionality, which is done by other tests, but to verify +# the correct output response to MI operations. +# + +load_lib mi-support.exp +set MIFLAGS "-i=mi2" + +gdb_exit +if [mi_gdb_start] { + continue +} + +set testfile "until" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +proc test_running_to_foo {} { + global mi_gdb_prompt + global hex + + mi_gdb_test "200-break-insert 10" \ + "200\\^done,bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"foo\",file=\".*until.c\",line=\"10\",times=\"0\"\}" \ + "break-insert operation" + + mi_run_cmd + + gdb_expect { + -re "000\\*stopped,reason=\"breakpoint-hit\",bkptno=\"1\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"foo\",args=\\\[\\\],file=\".*until.c\",line=\"10\"\}\r\n$mi_gdb_prompt$" { + pass "run to main" + } + -re ".*$mi_gdb_prompt$" { + fail "run to main (2)" + } + timeout { + fail "run to main (timeout)" + } + } + + mi_gdb_test "100-break-delete 1" "100\\^done" "break-delete 1" + +} + +proc test_until {} { + global mi_gdb_prompt + global hex + + send_gdb "111-exec-until\n" + gdb_expect { + -re "111\\^running\r\n${mi_gdb_prompt}111\\*stopped,reason=\"end-stepping-range\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"foo\",args=\\\[\\\],file=\".*until.c\",line=\"12\"\}\r\n$mi_gdb_prompt$" { + pass "until after while loop" + } + timeout { + fail "until after while loop (timeout)" + } + } + + send_gdb "222-exec-until 15\n" + gdb_expect { + -re "222\\^running\r\n${mi_gdb_prompt}222\\*stopped,reason=\"location-reached\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"foo\",args=\\\[\\\],file=\".*until.c\",line=\"15\"\}\r\n$mi_gdb_prompt$" { + pass "until line number" + } + timeout { + fail "until line number (timeout)" + } + } + + send_gdb "333-exec-until until.c:17\n" + gdb_expect { + -re "333\\^running\r\n${mi_gdb_prompt}333\\*stopped,reason=\"location-reached\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"foo\",args=\\\[\\\],file=\".*until.c\",line=\"17\"\}\r\n$mi_gdb_prompt$" { + pass "until line number:file" + } + timeout { + fail "until line number:file (timeout)" + } + } + + # This is supposed to NOT stop at line 25. It stops right after foo is over. + + send_gdb "444-exec-until until.c:25\n" + gdb_expect { + -re "444\\^running\r\n${mi_gdb_prompt}444\\*stopped,reason=\"location-reached\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"main\",args=\\\[\\\],file=\".*until.c\",line=\"24\"\}\r\n$mi_gdb_prompt$" { + pass "until after current function" + } + timeout { + fail "until after current function (timeout)" + } + } + +} + +test_running_to_foo +test_until + +mi_gdb_exit +return 0 diff --git a/gdb/testsuite/gdb.mi/mi2-var-block.exp b/gdb/testsuite/gdb.mi/mi2-var-block.exp new file mode 100644 index 0000000..84bc1ff --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi2-var-block.exp @@ -0,0 +1,173 @@ +# Copyright (C) 1999, 2000, 2002 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# Test essential Machine interface (MI) operations +# +# Verify that, using the MI, we can create, update, delete variables. +# + + +load_lib mi-support.exp +set MIFLAGS "-i=mi2" + +gdb_exit +if [mi_gdb_start] { + continue +} + +set testfile "var-cmd" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +mi_runto do_block_tests + +# Test: c_variable-3.2 +# Desc: create cb and foo +mi_gdb_test "-var-create cb * cb" \ + "\\^done,name=\"cb\",numchild=\"0\",type=\"int\"" \ + "create local variable cb" + +mi_gdb_test "-var-create foo * foo" \ + "&\"mi_cmd_var_create: unable to create variable object\\\\n\".*\\^error,msg=\"mi_cmd_var_create: unable to create variable object\"" \ + "create local variable foo" + +# step to "foo = 123;" +mi_step_to "do_block_tests" "" "var-cmd.c" "158" "step at do_block_test" + + +# Be paranoid and assume 3.2 created foo +mi_gdb_test "-var-delete foo" \ + "&\"Variable object not found\\\\n\".*\\^error,msg=\"Variable object not found\"" \ + "delete var foo" + + +# Test: c_variable-3.3 +# Desc: create foo +mi_gdb_test "-var-create foo * foo" \ + "\\^done,name=\"foo\",numchild=\"0\",type=\"int\"" \ + "create local variable foo" + +# step to "foo2 = 123;" +mi_step_to "do_block_tests" "" "var-cmd.c" "161" "step at do_block_test" + +# Test: c_variable-3.4 +# Desc: check foo, cb changed +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\\\[\{name=\"foo\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"cb\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \ + "update all vars: cb foo changed" + +# step to "foo = 321;" +mi_step_to "do_block_tests" "" "var-cmd.c" "164" "step at do_block_test" + +# Test: c_variable-3.5 +# Desc: create inner block foo +mi_gdb_test "-var-create inner_foo * foo" \ + "\\^done,name=\"inner_foo\",numchild=\"0\",type=\"int\"" \ + "create local variable inner_foo" + +# step to "foo2 = 0;" +mi_step_to "do_block_tests" "" "var-cmd.c" "166" "step at do_block_test" + +# Test: c_variable-3.6 +# Desc: create foo2 +mi_gdb_test "-var-create foo2 * foo2" \ + "\\^done,name=\"foo2\",numchild=\"0\",type=\"int\"" \ + "create local variable foo2" + +# Test: c_variable-3.7 +# Desc: check that outer foo in scope and inner foo out of scope +# Note: also a known gdb problem +setup_xfail *-*-* +mi_gdb_test "-var-update inner_foo" \ + "\\^done,changelist=\{FIXME\}" \ + "update inner_foo: should be out of scope: KNOWN PROBLEM" +clear_xfail *-*-* + +setup_xfail *-*-* +mi_gdb_test "-var-evaluate-expression inner_foo" \ + "\\^done,value=\{FIXME\}" \ + "evaluate inner_foo: should be out of scope: KNOWN PROBLEM" +clear_xfail *-*-* + +mi_gdb_test "-var-update foo" \ + "\\^done,changelist=\\\[\\\]" \ + "update foo: did not change" + +mi_gdb_test "-var-delete inner_foo" \ + "\\^done,ndeleted=\"1\"" \ + "delete var inner_foo" + +# step to "foo = 0;" +mi_step_to "do_block_tests" "" "var-cmd.c" "168" "step at do_block_test" + +# Test: c_variable-3.8 +# Desc: check that foo2 out of scope (known gdb problem) +setup_xfail *-*-* +mi_gdb_test "-var-update foo2" \ + "\\^done,changelist=\{FIXME\}" \ + "update foo2: should be out of scope: KNOWN PROBLEM" +clear_xfail *-*-* + +# step to "cb = 21;" +mi_step_to "do_block_tests" "" "var-cmd.c" "171" "step at do_block_test" + +# Test: c_variable-3.9 +# Desc: check that only cb is in scope (known gdb problem) +setup_xfail *-*-* +mi_gdb_test "-var-update foo2" \ + "\\^done,changelist=\\\[FIXME\\\]" \ + "update foo2 should be out of scope: KNOWN PROBLEM" +clear_xfail *-*-* +setup_xfail *-*-* +mi_gdb_test "-var-update foo" \ + "\\^done,changelist=\{FIXME\}" \ + "update foo should be out of scope: KNOWN PROBLEM" +clear_xfail *-*-* +mi_gdb_test "-var-update cb" \ + "\\^done,changelist=\\\[\\\]" \ + "update cb" + +# Test: c_variable-3.10 +# Desc: names of editable variables +#gdbtk_test c_variable-3.10 {names of editable variables} { +# editable_variables +#} {{foo cb foo2} {}} + +# Done with block tests +mi_gdb_test "-var-delete foo" \ + "\\^done,ndeleted=\"1\"" \ + "delete var foo" + +mi_gdb_test "-var-delete foo2" \ + "\\^done,ndeleted=\"1\"" \ + "delete var foo2" + +mi_gdb_test "-var-delete cb" \ + "\\^done,ndeleted=\"1\"" \ + "delete var cb" + +mi_gdb_exit +return 0 diff --git a/gdb/testsuite/gdb.mi/mi2-var-child.exp b/gdb/testsuite/gdb.mi/mi2-var-child.exp new file mode 100644 index 0000000..3f6a3fd --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi2-var-child.exp @@ -0,0 +1,1203 @@ +# Copyright (C) 1999, 2000, 2002 Free Software Foundation + +# 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# Test essential Machine interface (MI) operations +# +# Verify that, using the MI, we can create, update, delete variables. +# + + +load_lib mi-support.exp +set MIFLAGS "-i=mi2" + +gdb_exit +if [mi_gdb_start] { + continue +} + +set testfile "var-cmd" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +mi_runto do_children_tests + +##### ##### +# # +# children tests # +# # +##### ##### + + +# Test: c_variable-4.2 +# Desc: create variable "struct_declarations" +mi_gdb_test "-var-create struct_declarations * struct_declarations" \ + "\\^done,name=\"struct_declarations\",numchild=\"11\",type=\"struct _struct_decl\"" \ + "create local variable struct_declarations" + +# Test: c_variable-4.3 +# Desc: children of struct_declarations +# STABS doesn't give us argument types for the func ptr structs, but +# Dwarf 2 does. +mi_gdb_test "-var-list-children struct_declarations" \ + "\\^done,numchild=\"11\",children=\\\[child=\{name=\"struct_declarations.integer\",exp=\"integer\",numchild=\"0\",type=\"int\"\},child=\{name=\"struct_declarations.character\",exp=\"character\",numchild=\"0\",type=\"char\"\},child={name=\"struct_declarations.char_ptr\",exp=\"char_ptr\",numchild=\"1\",type=\"char \\*\"\},child=\{name=\"struct_declarations.long_int\",exp=\"long_int\",numchild=\"0\",type=\"long int\"\},child=\{name=\"struct_declarations.int_ptr_ptr\",exp=\"int_ptr_ptr\",numchild=\"1\",type=\"int \\*\\*\"\},child=\{name=\"struct_declarations.long_array\",exp=\"long_array\",numchild=\"10\",type=\"long int \\\[10\\\]\"\},child=\{name=\"struct_declarations.func_ptr\",exp=\"func_ptr\",numchild=\"0\",type=\"void \\(\\*\\)\\((void)?\\)\"\},child=\{name=\"struct_declarations.func_ptr_struct\",exp=\"func_ptr_struct\",numchild=\"0\",type=\"struct _struct_decl \\(\\*\\)\\((int, char \\*, long int)?\\)\"\},child=\{name=\"struct_declarations.func_ptr_ptr\",exp=\"func_ptr_ptr\",numchild=\"0\",type=\"struct _struct_decl \\*\\(\\*\\)\\((int, char \\*, long int)?\\)\"\},child=\{name=\"struct_declarations.u1\",exp=\"u1\",numchild=\"4\",type=\"union \{\\.\\.\\.\}\"\},child=\{name=\"struct_declarations.s2\",exp=\"s2\",numchild=\"4\",type=\"struct \{\\.\\.\\.\}\"\}\\\]" \ + "get children of struct_declarations" + +#gdbtk_test c_variable-4.3 {children of struct_declarations} { +# get_children struct_declarations +#} {integer character char_ptr long_int int_ptr_ptr long_array func_ptr func_ptr_struct func_ptr_ptr u1 s2} + +# Test: c_variable-4.4 +# Desc: number of children of struct_declarations +mi_gdb_test "-var-info-num-children struct_declarations" \ + "\\^done,numchild=\"11\"" \ + "get number of children of struct_declarations" + +# Test: c_variable-4.5 +# Desc: children of struct_declarations.integer +mi_gdb_test "-var-list-children struct_declarations.integer" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.integer" + +# Test: c_variable-4.6 +# Desc: number of children of struct_declarations.integer +mi_gdb_test "-var-info-num-children struct_declarations.integer" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.integer" + +# Test: c_variable-4.7 +# Desc: children of struct_declarations.character +mi_gdb_test "-var-list-children struct_declarations.character" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.character" + +# Test: c_variable-4.8 +# Desc: number of children of struct_declarations.character +mi_gdb_test "-var-info-num-children struct_declarations.character" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.character" + +# Test: c_variable-4.9 +# Desc: children of struct_declarations.char_ptr +mi_gdb_test "-var-list-children struct_declarations.char_ptr" \ + "\\^done,numchild=\"1\",children=\\\[child=\{name=\"struct_declarations.char_ptr.\\*char_ptr\",exp=\"\\*char_ptr\",numchild=\"0\",type=\"char\"\}\\\]" \ + "get children of struct_declarations.char_ptr" + +# Test: c_variable-4.10 +# Desc: number of children of struct_declarations.char_ptr +mi_gdb_test "-var-info-num-children struct_declarations.char_ptr" \ + "\\^done,numchild=\"1\"" \ + "get number of children of struct_declarations.char_ptr" + +# Test: c_variable-4.11 +# Desc: children of struct_declarations.long_int +mi_gdb_test "-var-list-children struct_declarations.long_int" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.long_int" + +# Test: c_variable-4.12 +# Desc: number of children of struct_declarations.long_int +mi_gdb_test "-var-info-num-children struct_declarations.long_int" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.long_int" + +# Test: c_variable-4.13 +# Desc: children of int_ptr_ptr +mi_gdb_test "-var-list-children struct_declarations.int_ptr_ptr" \ + "\\^done,numchild=\"1\",children=\\\[child=\{name=\"struct_declarations.int_ptr_ptr.\\*int_ptr_ptr\",exp=\"\\*int_ptr_ptr\",numchild=\"1\",type=\"int \\*\"\}\\\]" \ + "get children of struct_declarations.int_ptr_ptr" + +#gdbtk_test c_variable-4.13 {children of int_ptr_ptr} { +# get_children struct_declarations.int_ptr_ptr +#} {*int_ptr_ptr} + +# Test: c_variable-4.14 +# Desc: number of children of int_ptr_ptr +mi_gdb_test "-var-info-num-children struct_declarations.int_ptr_ptr" \ + "\\^done,numchild=\"1\"" \ + "get number of children of struct_declarations.int_ptr_ptr" + + +# Test: c_variable-4.15 +# Desc: children of struct_declarations.long_array +mi_gdb_test "-var-list-children struct_declarations.long_array" \ + "\\^done,numchild=\"10\",children=\\\[child=\{name=\"struct_declarations.long_array.0\",exp=\"0\",numchild=\"0\",type=\"long int\"\},child=\{name=\"struct_declarations.long_array.1\",exp=\"1\",numchild=\"0\",type=\"long int\"\},child=\{name=\"struct_declarations.long_array.2\",exp=\"2\",numchild=\"0\",type=\"long int\"\},child=\{name=\"struct_declarations.long_array.3\",exp=\"3\",numchild=\"0\",type=\"long int\"\},child=\{name=\"struct_declarations.long_array.4\",exp=\"4\",numchild=\"0\",type=\"long int\"\},child=\{name=\"struct_declarations.long_array.5\",exp=\"5\",numchild=\"0\",type=\"long int\"\},child=\{name=\"struct_declarations.long_array.6\",exp=\"6\",numchild=\"0\",type=\"long int\"\},child=\{name=\"struct_declarations.long_array.7\",exp=\"7\",numchild=\"0\",type=\"long int\"\},child=\{name=\"struct_declarations.long_array.8\",exp=\"8\",numchild=\"0\",type=\"long int\"\},child=\{name=\"struct_declarations.long_array.9\",exp=\"9\",numchild=\"0\",type=\"long int\"\}\\\]" \ + "get children of struct_declarations.long_array" + +# Test: c_variable-4.16 +# Desc: number of children of struct_declarations.long_array +mi_gdb_test "-var-info-num-children struct_declarations.long_array" \ + "\\^done,numchild=\"10\"" \ + "get number of children of struct_declarations.long_array" + +# Test: c_variable-4.17 +# Desc: children of struct_declarations.func_ptr +mi_gdb_test "-var-list-children struct_declarations.func_ptr" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.func_ptr" + + +# Test: c_variable-4.18 +# Desc: number of children of struct_declarations.func_ptr +mi_gdb_test "-var-info-num-children struct_declarations.func_ptr" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.func_ptr" + + +# Test: c_variable-4.19 +# Desc: children of struct_declarations.func_ptr_struct +mi_gdb_test "-var-list-children struct_declarations.func_ptr_struct" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.func_ptr_struct" + +# Test: c_variable-4.20 +# Desc: number of children of struct_declarations.func_ptr_struct +mi_gdb_test "-var-info-num-children struct_declarations.func_ptr_struct" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.func_ptr_struct" + + +# Test: c_variable-4.21 +# Desc: children of struct_declarations.func_ptr_ptr +mi_gdb_test "-var-list-children struct_declarations.func_ptr_ptr" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.func_ptr_ptr" + +# Test: c_variable-4.22 +# Desc: number of children of struct_declarations.func_ptr_ptr +mi_gdb_test "-var-info-num-children struct_declarations.func_ptr_ptr" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.func_ptr_ptr" + + +# Test: c_variable-4.23 +# Desc: children of struct_declarations.u1 +mi_gdb_test "-var-list-children struct_declarations.u1" \ + "\\^done,numchild=\"4\",children=\\\[child=\{name=\"struct_declarations.u1.a\",exp=\"a\",numchild=\"0\",type=\"int\"\},child=\{name=\"struct_declarations.u1.b\",exp=\"b\",numchild=\"1\",type=\"char \\*\"\},child=\{name=\"struct_declarations.u1.c\",exp=\"c\",numchild=\"0\",type=\"long int\"\},child=\{name=\"struct_declarations.u1.d\",exp=\"d\",numchild=\"0\",type=\"enum foo\"\}\\\]" \ + "get children of struct_declarations.u1" + +# Test: c_variable-4.24 +# Desc: number of children of struct_declarations.u1 +mi_gdb_test "-var-info-num-children struct_declarations.u1" \ + "\\^done,numchild=\"4\"" \ + "get number of children of struct_declarations.u1" + +# Test: c_variable-4.25 +# Desc: children of struct_declarations.s2 +mi_gdb_test "-var-list-children struct_declarations.s2" \ + "\\^done,numchild=\"4\",children=\\\[child=\{name=\"struct_declarations.s2.u2\",exp=\"u2\",numchild=\"3\",type=\"union \{\\.\\.\\.\}\"\},child=\{name=\"struct_declarations.s2.g\",exp=\"g\",numchild=\"0\",type=\"int\"\},child=\{name=\"struct_declarations.s2.h\",exp=\"h\",numchild=\"0\",type=\"char\"\},child=\{name=\"struct_declarations.s2.i\",exp=\"i\",numchild=\"10\",type=\"long int \\\[10\\\]\"\}\\\]" \ + "get children of struct_declarations.s2" +#gdbtk_test c_variable-4.25 {children of struct_declarations.s2} { +# get_children struct_declarations.s2 +#} {u2 g h i} + +# Test: c_variable-4.26 +# Desc: number of children of struct_declarations.s2 +mi_gdb_test "-var-info-num-children struct_declarations.s2" \ + "\\^done,numchild=\"4\"" \ + "get number of children of struct_declarations.s2" + + +# Test: c_variable-4.27 +# Desc: children of struct_declarations.long_array.1 +mi_gdb_test "-var-list-children struct_declarations.long_array.1" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.long_array.1" + +# Test: c_variable-4.28 +# Desc: number of children of struct_declarations.long_array.1 +mi_gdb_test "-var-info-num-children struct_declarations.long_array.1" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.long_array.1" + +# Test: c_variable-4.29 +# Desc: children of struct_declarations.long_array.2 +mi_gdb_test "-var-list-children struct_declarations.long_array.2" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.long_array.2" + +# Test: c_variable-4.30 +# Desc: number of children of struct_declarations.long_array.2 +mi_gdb_test "-var-info-num-children struct_declarations.long_array.2" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.long_array.2" + +# Test: c_variable-4.31 +# Desc: children of struct_declarations.long_array.3 +mi_gdb_test "-var-list-children struct_declarations.long_array.3" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.long_array.3" + +# Test: c_variable-4.32 +# Desc: number of children of struct_declarations.long_array.3 +mi_gdb_test "-var-info-num-children struct_declarations.long_array.3" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.long_array.3" + +# Test: c_variable-4.33 +# Desc: children of struct_declarations.long_array.4 +mi_gdb_test "-var-list-children struct_declarations.long_array.4" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.long_array.4" + +# Test: c_variable-4.34 +# Desc: number of children of struct_declarations.long_array.4 +mi_gdb_test "-var-info-num-children struct_declarations.long_array.4" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.long_array.4" + +# Test: c_variable-4.35 +# Desc: children of struct_declarations.long_array.5 +mi_gdb_test "-var-list-children struct_declarations.long_array.5" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.long_array.5" + +# Test: c_variable-4.36 +# Desc: number of children of struct_declarations.long_array.5 +mi_gdb_test "-var-info-num-children struct_declarations.long_array.5" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.long_array.5" + +# Test: c_variable-4.37 +# Desc: children of struct_declarations.long_array.6 +mi_gdb_test "-var-list-children struct_declarations.long_array.6" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.long_array.6" + +# Test: c_variable-4.38 +# Desc: number of children of struct_declarations.long_array.6 +mi_gdb_test "-var-info-num-children struct_declarations.long_array.6" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.long_array.6" + +# Test: c_variable-4.39 +# Desc: children of struct_declarations.long_array.7 +mi_gdb_test "-var-list-children struct_declarations.long_array.7" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.long_array.7" + +# Test: c_variable-4.40 +# Desc: number of children of struct_declarations.long_array.7 +mi_gdb_test "-var-info-num-children struct_declarations.long_array.7" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.long_array.7" + +# Test: c_variable-4.41 +# Desc: children of struct_declarations.long_array.8 +mi_gdb_test "-var-list-children struct_declarations.long_array.8" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.long_array.8" + +# Test: c_variable-4.42 +# Desc: number of children of struct_declarations.long_array.8 +mi_gdb_test "-var-info-num-children struct_declarations.long_array.8" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.long_array.8" + + +# Test: c_variable-4.43 +# Desc: children of struct_declarations.long_array.9 +mi_gdb_test "-var-list-children struct_declarations.long_array.9" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.long_array.9" + +# Test: c_variable-4.44 +# Desc: number of children of struct_declarations.long_array.9 +mi_gdb_test "-var-info-num-children struct_declarations.long_array.9" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.long_array.9" + +# Test: c_variable-4.45 +# Desc: children of struct_declarations.u1.a +mi_gdb_test "-var-list-children struct_declarations.u1.a" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.u1.a" + +# Test: c_variable-4.46 +# Desc: number of children of struct_declarations.u1.a +mi_gdb_test "-var-info-num-children struct_declarations.u1.a" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.u1.a" + +# Test: c_variable-4.47 +# Desc: children of struct_declarations.u1.b +mi_gdb_test "-var-list-children struct_declarations.u1.b" \ + "\\^done,numchild=\"1\",children=\\\[child=\{name=\"struct_declarations.u1.b.\\*b\",exp=\"\\*b\",numchild=\"0\",type=\"char\"\}\\\]" \ + "get children of struct_declarations.u1.b" + +# Test: c_variable-4.48 +# Desc: number of children of struct_declarations.u1.b +mi_gdb_test "-var-info-num-children struct_declarations.u1.b" \ + "\\^done,numchild=\"1\"" \ + "get number of children of struct_declarations.u1.b" + +# Test: c_variable-4.49 +# Desc: children of struct_declarations.u1.c +mi_gdb_test "-var-list-children struct_declarations.u1.c" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.u1.c" + +# Test: c_variable-4.50 +# Desc: number of children of struct_declarations.u1.c +mi_gdb_test "-var-info-num-children struct_declarations.u1.c" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.u1.c" + +# Test: c_variable-4.51 +# Desc: children of struct_declarations.u1.d +mi_gdb_test "-var-list-children struct_declarations.u1.d" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.u1.d" + + +# Test: c_variable-4.52 +# Desc: number of children of struct_declarations.u1.d +mi_gdb_test "-var-info-num-children struct_declarations.u1.d" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.u1.d" + + +# Test: c_variable-4.53 +# Desc: children of struct_declarations.s2.u2 +mi_gdb_test "-var-list-children struct_declarations.s2.u2" \ + "\\^done,numchild=\"3\",children=\\\[child=\{name=\"struct_declarations.s2.u2.u1s1\",exp=\"u1s1\",numchild=\"4\",type=\"struct \{\\.\\.\\.\}\"\},child=\{name=\"struct_declarations.s2.u2.f\",exp=\"f\",numchild=\"0\",type=\"long int\"\},child=\{name=\"struct_declarations.s2.u2.u1s2\",exp=\"u1s2\",numchild=\"2\",type=\"struct \{\\.\\.\\.\}\"\}\\\]" \ + "get children of struct_declarations.s2.u2" + +# Test: c_variable-4.54 +# Desc: number of children of struct_declarations.s2.u2 +mi_gdb_test "-var-info-num-children struct_declarations.s2.u2" \ + "\\^done,numchild=\"3\"" \ + "get number of children of struct_declarations.s2.u2" + +# Test: c_variable-4.55 +# Desc: children of struct_declarations.s2.g +mi_gdb_test "-var-list-children struct_declarations.s2.g" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.s2.g" + +# Test: c_variable-4.56 +# Desc: number of children of struct_declarations.s2.g +mi_gdb_test "-var-info-num-children struct_declarations.s2.g" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.s2.g" + + +# Test: c_variable-4.57 +# Desc: children of struct_declarations.s2.h +mi_gdb_test "-var-list-children struct_declarations.s2.h" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.s2.h" + +# Test: c_variable-4.58 +# Desc: number of children of struct_declarations.s2.h +mi_gdb_test "-var-info-num-children struct_declarations.s2.h" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.s2.h" + + +# Test: c_variable-4.59 +# Desc: children of struct_declarations.s2.i +mi_gdb_test "-var-list-children struct_declarations.s2.i" \ + "\\^done,numchild=\"10\",children=\\\[child=\{name=\"struct_declarations.s2.i.0\",exp=\"0\",numchild=\"0\",type=\"long int\"\},child=\{name=\"struct_declarations.s2.i.1\",exp=\"1\",numchild=\"0\",type=\"long int\"\},child=\{name=\"struct_declarations.s2.i.2\",exp=\"2\",numchild=\"0\",type=\"long int\"\},child=\{name=\"struct_declarations.s2.i.3\",exp=\"3\",numchild=\"0\",type=\"long int\"\},child=\{name=\"struct_declarations.s2.i.4\",exp=\"4\",numchild=\"0\",type=\"long int\"\},child=\{name=\"struct_declarations.s2.i.5\",exp=\"5\",numchild=\"0\",type=\"long int\"\},child=\{name=\"struct_declarations.s2.i.6\",exp=\"6\",numchild=\"0\",type=\"long int\"\},child=\{name=\"struct_declarations.s2.i.7\",exp=\"7\",numchild=\"0\",type=\"long int\"\},child=\{name=\"struct_declarations.s2.i.8\",exp=\"8\",numchild=\"0\",type=\"long int\"\},child=\{name=\"struct_declarations.s2.i.9\",exp=\"9\",numchild=\"0\",type=\"long int\"\}\\\]" \ + "get children of struct_declarations.s2.i" + +# Test: c_variable-4.60 +# Desc: number of children of struct_declarations.s2.i +mi_gdb_test "-var-info-num-children struct_declarations.s2.i" \ + "\\^done,numchild=\"10\"" \ + "get number of children of struct_declarations.s2.i" + +# Test: c_variable-4.61 +# Desc: children of struct_declarations.s2.u2.u1s1 +mi_gdb_test "-var-list-children struct_declarations.s2.u2.u1s1" \ + "\\^done,numchild=\"4\",children=\\\[child=\{name=\"struct_declarations.s2.u2.u1s1.d\",exp=\"d\",numchild=\"0\",type=\"int\"\},child=\{name=\"struct_declarations.s2.u2.u1s1.e\",exp=\"e\",numchild=\"10\",type=\"char \\\[10\\\]\"\},child=\{name=\"struct_declarations.s2.u2.u1s1.func\",exp=\"func\",numchild=\"0\",type=\"int \\*\\(\\*\\)\\((void)?\\)\"\},child=\{name=\"struct_declarations.s2.u2.u1s1.foo\",exp=\"foo\",numchild=\"0\",type=\"efoo\"\}\\\]" \ + "get children of struct_declarations.s2.u2.u1s1" + +# Test: c_variable-4.62 +# Desc: number of children of struct_declarations.s2.u2.u1s1 +mi_gdb_test "-var-info-num-children struct_declarations.s2.u2.u1s1" \ + "\\^done,numchild=\"4\"" \ + "get number of children of struct_declarations.s2.u2.u1s1" + +# Test: c_variable-4.63 +# Desc: children of struct_declarations.s2.u2.f +mi_gdb_test "-var-list-children struct_declarations.s2.u2.f" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.s2.u2.f" + +# Test: c_variable-4.64 +# Desc: number of children of struct_declarations.s2.u2.f +mi_gdb_test "-var-info-num-children struct_declarations.s2.u2.f" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.s2.u2.f" + +# Test: c_variable-4.65 +# Desc: children of struct_declarations.s2.u2.u1s2 +mi_gdb_test "-var-list-children struct_declarations.s2.u2.u1s2" \ + "\\^done,numchild=\"2\",children=\\\[child=\{name=\"struct_declarations.s2.u2.u1s2.array_ptr\",exp=\"array_ptr\",numchild=\"2\",type=\"char \\\[2\\\]\"\},child=\{name=\"struct_declarations.s2.u2.u1s2.func\",exp=\"func\",numchild=\"0\",type=\"int \\(\\*\\)\\((int, char \\*)?\\)\"\}\\\]" \ + "get children of struct_declarations.s2.u2.u1s2" + +# Test: c_variable-4.66 +# Desc: number of children of struct_declarations.s2.u2.u1s2 +mi_gdb_test "-var-info-num-children struct_declarations.s2.u2.u1s2" \ + "\\^done,numchild=\"2\"" \ + "get number of children of struct_declarations.s2.u2.u1s2" + +# Test: c_variable-4.67 +# Desc: children of struct_declarations.s2.u2.u1s1.d +mi_gdb_test "-var-list-children struct_declarations.s2.u2.u1s1.d" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.s2.u2.u1s1.d" + +# Test: c_variable-4.68 +# Desc: number of children of struct_declarations.s2.u2.u1s1.d +mi_gdb_test "-var-info-num-children struct_declarations.s2.u2.u1s1.d" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.s2.u2.u1s1.d" + +# Test: c_variable-4.69 +# Desc: children of struct_declarations.s2.u2.u1s1.e +mi_gdb_test "-var-list-children struct_declarations.s2.u2.u1s1.e" \ + "\\^done,numchild=\"10\",children=\\\[child=\{name=\"struct_declarations.s2.u2.u1s1.e.0\",exp=\"0\",numchild=\"0\",type=\"char\"\},child=\{name=\"struct_declarations.s2.u2.u1s1.e.1\",exp=\"1\",numchild=\"0\",type=\"char\"\},child=\{name=\"struct_declarations.s2.u2.u1s1.e.2\",exp=\"2\",numchild=\"0\",type=\"char\"\},child={name=\"struct_declarations.s2.u2.u1s1.e.3\",exp=\"3\",numchild=\"0\",type=\"char\"\},child=\{name=\"struct_declarations.s2.u2.u1s1.e.4\",exp=\"4\",numchild=\"0\",type=\"char\"\},child=\{name=\"struct_declarations.s2.u2.u1s1.e.5\",exp=\"5\",numchild=\"0\",type=\"char\"\},child=\{name=\"struct_declarations.s2.u2.u1s1.e.6\",exp=\"6\",numchild=\"0\",type=\"char\"\},child=\{name=\"struct_declarations.s2.u2.u1s1.e.7\",exp=\"7\",numchild=\"0\",type=\"char\"\},child=\{name=\"struct_declarations.s2.u2.u1s1.e.8\",exp=\"8\",numchild=\"0\",type=\"char\"\},child=\{name=\"struct_declarations.s2.u2.u1s1.e.9\",exp=\"9\",numchild=\"0\",type=\"char\"\}\\\]" \ + "get children of struct_declarations.s2.u2.u1s1.e" + +# Test: c_variable-4.70 +# Desc: number of children of struct_declarations.s2.u2.u1s1.e +mi_gdb_test "-var-info-num-children struct_declarations.s2.u2.u1s1.e" \ + "\\^done,numchild=\"10\"" \ + "get number of children of struct_declarations.s2.u2.u1s1.e" + + +# Test: c_variable-4.71 +# Desc: children of struct_declarations.s2.u2.u1s1.func +mi_gdb_test "-var-list-children struct_declarations.s2.u2.u1s1.func" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.s2.u2.u1s1.func" + +# Test: c_variable-4.72 +# Desc: number of children of struct_declarations.s2.u2.u1s1.func +mi_gdb_test "-var-info-num-children struct_declarations.s2.u2.u1s1.func" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.s2.u2.u1s1.func" + + +# Test: c_variable-4.73 +# Desc: children of struct_declarations.s2.u2.u1s1.foo +mi_gdb_test "-var-list-children struct_declarations.s2.u2.u1s1.foo" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.s2.u2.u1s1.foo" + +# Test: c_variable-4.74 +# Desc: number of children of struct_declarations.s2.u2.u1s1.foo +mi_gdb_test "-var-info-num-children struct_declarations.s2.u2.u1s1.foo" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.s2.u2.u1s1.foo" + + +# Test: c_variable-4.75 +# Desc: children of struct_declarations.s2.u2.u1s2.array_ptr +mi_gdb_test "-var-list-children struct_declarations.s2.u2.u1s2.array_ptr" \ + "\\^done,numchild=\"2\",children=\\\[child=\{name=\"struct_declarations.s2.u2.u1s2.array_ptr.0\",exp=\"0\",numchild=\"0\",type=\"char\"\},child={name=\"struct_declarations.s2.u2.u1s2.array_ptr.1\",exp=\"1\",numchild=\"0\",type=\"char\"\}\\\]" \ + "get children of struct_declarations.s2.u2.u1s2.array_ptr" + +# Test: c_variable-4.76 +# Desc: number of children of struct_declarations.s2.u2.u1s2.array_ptr +mi_gdb_test "-var-info-num-children struct_declarations.s2.u2.u1s2.array_ptr" \ + "\\^done,numchild=\"2\"" \ + "get number of children of struct_declarations.s2.u2.u1s2.array_ptr" + +# Test: c_variable-4.77 +# Desc: children of struct_declarations.s2.u2.u1s2.func +mi_gdb_test "-var-list-children struct_declarations.s2.u2.u1s2.func" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.s2.u2.u1s2.func" + +# Test: c_variable-4.78 +# Desc: number of children of struct_declarations.s2.u2.u1s2.func +mi_gdb_test "-var-info-num-children struct_declarations.s2.u2.u1s2.func" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.s2.u2.u1s2.func" + +# Test: c_variable-4.79 +# Desc: children of struct_declarations.int_ptr_ptr.*int_ptr_ptr +mi_gdb_test "-var-list-children struct_declarations.int_ptr_ptr.*int_ptr_ptr" \ + "\\^done,numchild=\"1\",children=\\\[child=\{name=\"struct_declarations.int_ptr_ptr.\\*int_ptr_ptr.\\*\\*int_ptr_ptr\",exp=\"\\*\\*int_ptr_ptr\",numchild=\"0\",type=\"int\"\}\\\]" \ + "get children of struct_declarations.int_ptr_ptr.*int_ptr_ptr" +#} {**int_ptr_ptr} + +# Test: c_variable-4.80 +# Desc: Number of children of struct_declarations.int_ptr_ptr.*int_ptr_ptr +mi_gdb_test "-var-info-num-children struct_declarations.int_ptr_ptr.*int_ptr_ptr" \ + "\\^done,numchild=\"1\"" \ + "get number of children of struct_declarations.int_ptr_ptr.*int_ptr_ptr" + + +# Step to "struct_declarations.integer = 123;" +set line 192 +mi_step_to do_children_tests {} {.*var-cmd.c} $line "step to line $line" + +# Test: c_variable-4.81 +# Desc: create local variable "weird" +mi_gdb_test "-var-create weird * weird" \ + "\\^done,name=\"weird\",numchild=\"11\",type=\"weird_struct \\*\"" \ + "create local variable weird" + +# Test: c_variable-4.82 +# Desc: children of weird +mi_gdb_test "-var-list-children weird" \ + "\\^done,numchild=\"11\",children=\\\[child=\{name=\"weird.integer\",exp=\"integer\",numchild=\"0\",type=\"int\"\},child=\{name=\"weird.character\",exp=\"character\",numchild=\"0\",type=\"char\"\},child=\{name=\"weird.char_ptr\",exp=\"char_ptr\",numchild=\"1\",type=\"char \\*\"\},child=\{name=\"weird.long_int\",exp=\"long_int\",numchild=\"0\",type=\"long int\"\},child=\{name=\"weird.int_ptr_ptr\",exp=\"int_ptr_ptr\",numchild=\"1\",type=\"int \\*\\*\"\},child=\{name=\"weird.long_array\",exp=\"long_array\",numchild=\"10\",type=\"long int \\\[10\\\]\"\},child=\{name=\"weird.func_ptr\",exp=\"func_ptr\",numchild=\"0\",type=\"void \\(\\*\\)\\((void)?\\)\"\},child=\{name=\"weird.func_ptr_struct\",exp=\"func_ptr_struct\",numchild=\"0\",type=\"struct _struct_decl \\(\\*\\)\\((int, char \\*, long int)?\\)\"\},child=\{name=\"weird.func_ptr_ptr\",exp=\"func_ptr_ptr\",numchild=\"0\",type=\"struct _struct_decl \\*\\(\\*\\)\\((int, char \\*, long int)?\\)\"\},child=\{name=\"weird.u1\",exp=\"u1\",numchild=\"4\",type=\"union \{\\.\\.\\.\}\"\},child=\{name=\"weird.s2\",exp=\"s2\",numchild=\"4\",type=\"struct \{\\.\\.\\.\}\"\}\\\]" \ + "get children of weird" + +# Test: c_variable-4.83 +# Desc: number of children of weird +mi_gdb_test "-var-info-num-children weird" \ + "\\^done,numchild=\"11\"" \ + "get number of children of weird" + + +# Test: c_variable-4.84 +# Desc: children of weird->long_array +mi_gdb_test "-var-list-children weird.long_array" \ + "\\^done,numchild=\"10\",children=\\\[child=\{name=\"weird.long_array.0\",exp=\"0\",numchild=\"0\",type=\"long int\"\},child=\{name=\"weird.long_array.1\",exp=\"1\",numchild=\"0\",type=\"long int\"\},child=\{name=\"weird.long_array.2\",exp=\"2\",numchild=\"0\",type=\"long int\"\},child=\{name=\"weird.long_array.3\",exp=\"3\",numchild=\"0\",type=\"long int\"\},child=\{name=\"weird.long_array.4\",exp=\"4\",numchild=\"0\",type=\"long int\"\},child=\{name=\"weird.long_array.5\",exp=\"5\",numchild=\"0\",type=\"long int\"\},child=\{name=\"weird.long_array.6\",exp=\"6\",numchild=\"0\",type=\"long int\"\},child=\{name=\"weird.long_array.7\",exp=\"7\",numchild=\"0\",type=\"long int\"\},child=\{name=\"weird.long_array.8\",exp=\"8\",numchild=\"0\",type=\"long int\"\},child=\{name=\"weird.long_array.9\",exp=\"9\",numchild=\"0\",type=\"long int\"\}\\\]" \ + "get children of weird.long_array" +#gdbtk_test c_variable-4.84 {children of weird->long_array} { +# get_children weird.long_array +#} {0 1 2 3 4 5 6 7 8 9} + +# Test: c_variable-4.85 +# Desc: number of children of weird.long_array +mi_gdb_test "-var-info-num-children weird.long_array" \ + "\\^done,numchild=\"10\"" \ + "get number of children of weird.long_array" + +# Test: c_variable-4.86 +# Desc: children of weird.int_ptr_ptr +mi_gdb_test "-var-list-children weird.int_ptr_ptr" \ + "\\^done,numchild=\"1\",children=\\\[child=\{name=\"weird.int_ptr_ptr.\\*int_ptr_ptr\",exp=\"\\*int_ptr_ptr\",numchild=\"1\",type=\"int \\*\"\}\\\]" \ + "get children of weird.int_ptr_ptr" +#gdbtk_test c_variable-4.86 {children of weird->int_ptr_ptr} { +# get_children weird.int_ptr_ptr +#} {*int_ptr_ptr} + +# Test: c_variable-4.87 +# Desc: number of children of weird.int_ptr_ptr +mi_gdb_test "-var-info-num-children weird.int_ptr_ptr" \ + "\\^done,numchild=\"1\"" \ + "get number of children of weird.int_ptr_ptr" + +# Test: c_variable-4.88 +# Desc: children of *weird->int_ptr_ptr +mi_gdb_test "-var-list-children weird.int_ptr_ptr.*int_ptr_ptr" \ + "\\^done,numchild=\"1\",children=\\\[child=\{name=\"weird.int_ptr_ptr.\\*int_ptr_ptr.\\*\\*int_ptr_ptr\",exp=\"\\*\\*int_ptr_ptr\",numchild=\"0\",type=\"int\"\}\\\]" \ + "get children of weird.int_ptr_ptr.*int_ptr_ptr" +#gdbtk_test c_variable-4.88 {children of *weird->int_ptr_ptr} { +# get_children weird.int_ptr_ptr.*int_ptr_ptr +#} {**int_ptr_ptr} + +# Test: c_variable-4.89 +# Desc: number of children *weird->int_ptr_ptr +mi_gdb_test "-var-info-num-children weird.int_ptr_ptr.*int_ptr_ptr" \ + "\\^done,numchild=\"1\"" \ + "get number of children of weird.int_ptr_ptr.*int_ptr_ptr" + +# Test: c_variable-4.90 +# Desc: create weird->int_ptr_ptr +mi_gdb_test "-var-create weird->int_ptr_ptr * weird->int_ptr_ptr" \ + "\\^done,name=\"weird->int_ptr_ptr\",numchild=\"1\",type=\"int \\*\\*\"" \ + "create local variable weird->int_ptr_ptr" + +# Test: c_variable-4.91 +# Desc: children of weird->int_ptr_ptr +mi_gdb_test "-var-list-children weird->int_ptr_ptr" \ + "\\^done,numchild=\"1\",children=\\\[child=\{name=\"weird->int_ptr_ptr.\\*weird->int_ptr_ptr\",exp=\"\\*weird->int_ptr_ptr\",numchild=\"1\",type=\"int \\*\"\}\\\]" \ + "get children of weird->int_ptr_ptr" + + +# Test: c_variable-4.92 +# Desc: number of children of (weird->int_ptr_ptr) +mi_gdb_test "-var-info-num-children weird->int_ptr_ptr" \ + "\\^done,numchild=\"1\"" \ + "get number of children of weird->int_ptr_ptr" + +# Test: c_variable-4.93 +# Desc: children of *(weird->int_ptr_ptr) +mi_gdb_test "-var-list-children weird->int_ptr_ptr.*weird->int_ptr_ptr" \ + "\\^done,numchild=\"1\",children=\\\[child=\{name=\"weird->int_ptr_ptr.\\*weird->int_ptr_ptr.\\*\\*weird->int_ptr_ptr\",exp=\"\\*\\*weird->int_ptr_ptr\",numchild=\"0\",type=\"int\"\}\\\]" \ + "get children of weird->int_ptr_ptr.*weird->int_ptr_ptr" + +# Test: c_variable-4.94 +# Desc: number of children of *(weird->int_ptr_ptr) +mi_gdb_test "-var-info-num-children weird->int_ptr_ptr.*weird->int_ptr_ptr" \ + "\\^done,numchild=\"1\"" \ + "get number of children of weird->int_ptr_ptr.*weird->int_ptr_ptr" + +# Test: c_variable-4.95 +# Desc: children of *(*(weird->int_ptr_ptr)) +mi_gdb_test "-var-list-children weird->int_ptr_ptr.*weird->int_ptr_ptr.**weird->int_ptr_ptr" \ + "\\^done,numchild=\"0\"" \ + "get children of weird->int_ptr_ptr.*weird->int_ptr_ptr.**weird->int_ptr_ptr" + +# Test: c_variable-4.96 +# Desc: number of children of *(*(weird->int_ptr_ptr)) +mi_gdb_test "-var-info-num-children weird->int_ptr_ptr.*weird->int_ptr_ptr.**weird->int_ptr_ptr" \ + "\\^done,numchild=\"0\"" \ + "get number of children of weird->int_ptr_ptr.*weird->int_ptr_ptr.**weird->int_ptr_ptr" + +# Test: c_variable-4.97 +# Desc: is weird editable +mi_gdb_test "-var-show-attributes weird" \ + "\\^done,attr=\"editable\"" \ + "is weird editable" + +# Test: c_variable-4.98 +# Desc: is weird->int_ptr_ptr editable +mi_gdb_test "-var-show-attributes weird->int_ptr_ptr" \ + "\\^done,attr=\"editable\"" \ + "is weird->int_ptr_ptr editable" + +# Test: c_variable-4.99 +# Desc: is *(weird->int_ptr_ptr) editable +mi_gdb_test "-var-show-attributes weird.int_ptr_ptr.*int_ptr_ptr" \ + "\\^done,attr=\"editable\"" \ + "is weird.int_ptr_ptr.*int_ptr_ptr editable" + +# Test: c_variable-4.100 +# Desc: is *(*(weird->int_ptr_ptr)) editable +mi_gdb_test "-var-show-attributes weird.int_ptr_ptr.*int_ptr_ptr.**int_ptr_ptr" \ + "\\^done,attr=\"editable\"" \ + "is weird.int_ptr_ptr.*int_ptr_ptr.**int_ptr_ptr editable" + +# Test: c_variable-4.101 +# Desc: is weird->u1 editable +mi_gdb_test "-var-show-attributes weird.u1" \ + "\\^done,attr=\"noneditable\"" \ + "is weird.u1 editable" + +# Test: c_variable-4.102 +# Desc: is weird->s2 editable +mi_gdb_test "-var-show-attributes weird.s2" \ + "\\^done,attr=\"noneditable\"" \ + "is weird.s2 editable" + +# Test: c_variable-4.103 +# Desc: is struct_declarations.u1.a editable +mi_gdb_test "-var-show-attributes struct_declarations.u1.a" \ + "\\^done,attr=\"editable\"" \ + "is struct_declarations.u1.a editable" + +# Test: c_variable-4.104 +# Desc: is struct_declarations.u1.b editable +mi_gdb_test "-var-show-attributes struct_declarations.u1.b" \ + "\\^done,attr=\"editable\"" \ + "is struct_declarations.u1.b editable" + +# Test: c_variable-4.105 +# Desc: is struct_declarations.u1.c editable +mi_gdb_test "-var-show-attributes struct_declarations.u1.c" \ + "\\^done,attr=\"editable\"" \ + "is struct_declarations.u1.c editable" + +# Test: c_variable-4.106 +# Desc: is struct_declarations.long_array editable +mi_gdb_test "-var-show-attributes struct_declarations.long_array" \ + "\\^done,attr=\"noneditable\"" \ + "is struct_declarations.long_array editable" + +# Test: c_variable-4.107 +# Desc: is struct_declarations.long_array[0] editable +mi_gdb_test "-var-show-attributes struct_declarations.long_array.0" \ + "\\^done,attr=\"editable\"" \ + "is struct_declarations.long_array.0 editable" + +# Test: c_variable-4.108 +# Desc: is struct_declarations editable +mi_gdb_test "-var-show-attributes struct_declarations" \ + "\\^done,attr=\"noneditable\"" \ + "is struct_declarations editable" + +mi_gdb_test "-var-delete weird" \ + "\\^done,ndeleted=\"24\"" \ + "delete var weird" + +##### ##### +# # +# children and update tests # +# # +##### ##### + +# Test: c_variable-5.1 +# Desc: check that nothing changed +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\\\[\\\]" \ + "update all vars. None changed" + +# Step over "struct_declarations.integer = 123;" +set line 193 +mi_step_to do_children_tests {} {.*var-cmd.c} $line "step $line" + +# Test: c_variable-5.2 +# Desc: check that integer changed +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\\\[\{name=\"struct_declarations.integer\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \ + "update all vars struct_declarations.integer" + +# Step over: +# weird->char_ptr = "hello"; +# bar = 2121; +# foo = &bar; +set line 196 +mi_execute_to "exec-step 3" "end-stepping-range" do_children_tests {} {.*var-cmd.c} $line {} "step $line" + +# Test: c_variable-5.3 +# Desc: check that char_ptr changed +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\\\[\{name=\"struct_declarations.char_ptr\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"struct_declarations.char_ptr.\\*char_ptr\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \ + "update all vars struct_declarations.char_ptr" + +# Step over "struct_declarations.int_ptr_ptr = &foo;" +set line 197 +mi_step_to do_children_tests {} {.*var-cmd.c} $line "step $line" + +# Test: c_variable-5.4 +# Desc: check that int_ptr_ptr and children changed +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\\\[\{name=\"weird->int_ptr_ptr\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"weird->int_ptr_ptr.\\*weird->int_ptr_ptr\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"weird->int_ptr_ptr.\\*weird->int_ptr_ptr.\\*\\*weird->int_ptr_ptr\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"struct_declarations.int_ptr_ptr\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"struct_declarations.int_ptr_ptr.\\*int_ptr_ptr\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"struct_declarations.int_ptr_ptr.\\*int_ptr_ptr.\\*\\*int_ptr_ptr\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \ + "update all vars int_ptr_ptr and children changed" + +# Step over "weird->long_array[0] = 1234;" +set line 198 +mi_step_to do_children_tests {} {.*var-cmd.c} $line "step $line" + +# Test: c_variable-5.5 +# Desc: check that long_array[0] changed +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\\\[\{name=\"struct_declarations.long_array.0\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \ + "update all vars struct_declarations.long_array.0 changed" + +# Step over "struct_declarations.long_array[1] = 2345;" +set line 199 +mi_step_to do_children_tests {} {.*var-cmd.c} $line "step $line" + +# Test: c_variable-5.6 +# Desc: check that long_array[1] changed +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\\\[\{name=\"struct_declarations.long_array.1\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \ + "update all vars struct_declarations.long_array.1 changed" + +# Step over "weird->long_array[2] = 3456;" +set line 200 +mi_step_to do_children_tests {} {.*var-cmd.c} $line "step $line" + +# Test: c_variable-5.7 +# Desc: check that long_array[2] changed +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\\\[\{name=\"struct_declarations.long_array.2\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \ + "update all vars struct_declarations.long_array.2 changed" + +# Step over: +# struct_declarations.long_array[3] = 4567; +# weird->long_array[4] = 5678; +# struct_declarations.long_array[5] = 6789; +# weird->long_array[6] = 7890; +# struct_declarations.long_array[7] = 8901; +# weird->long_array[8] = 9012; +# struct_declarations.long_array[9] = 1234; +set line 208 +mi_execute_to "exec-step 7" "end-stepping-range" do_children_tests {} {.*var-cmd.c} $line {} "step $line" + +# Test: c_variable-5.8 +# Desc: check that long_array[3-9] changed +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\\\[\{name=\"struct_declarations.long_array.3\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"struct_declarations.long_array.4\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"struct_declarations.long_array.5\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"struct_declarations.long_array.6\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"struct_declarations.long_array.7\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"struct_declarations.long_array.8\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"struct_declarations.long_array.9\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \ + "update all vars struct_declarations.long_array.3-9 changed" + + +# Step over "weird->func_ptr = nothing;" +set line 211 +mi_step_to do_children_tests {} {.*var-cmd.c} $line "step $line" + +# Test: c_variable-5.9 +# Desc: check that func_ptr changed +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\\\[\{name=\"struct_declarations.func_ptr\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \ + "update all vars struct_declarations.func_ptr changed" + +# Delete all variables +mi_gdb_test "-var-delete struct_declarations" \ + "\\^done,ndeleted=\"65\"" \ + "delete var struct_declarations" + +mi_gdb_test "-var-delete weird->int_ptr_ptr" \ + "\\^done,ndeleted=\"3\"" \ + "delete var weird->int_ptr_ptr" + +# Step over all lines: +# ... +# psnp = &snp0; +set line 254 +mi_execute_to "exec-step 43" "end-stepping-range" do_children_tests {} {.*var-cmd.c} $line {} "step $line" + +# Test: c_variable-5.10 +# Desc: create psnp->char_ptr +mi_gdb_test "-var-create psnp->char_ptr * psnp->char_ptr" \ + "\\^done,name=\"psnp->char_ptr\",numchild=\"1\",type=\"char \\*\\*\\*\\*\"" \ + "create local variable psnp->char_ptr" + +# Test: c_variable-5.11 +# Desc: children of psnp->char_ptr +mi_gdb_test "-var-list-children psnp->char_ptr" \ + "\\^done,numchild=\"1\",children=\\\[child=\{name=\"psnp->char_ptr.\\*psnp->char_ptr\",exp=\"\\*psnp->char_ptr\",numchild=\"1\",type=\"char \\*\\*\\*\"\}\\\]" \ + "get children of psnp->char_ptr" + +# Test: c_variable-5.12 +# Desc: number of children of psnp->char_ptr +mi_gdb_test "-var-info-num-children psnp->char_ptr" \ + "\\^done,numchild=\"1\"" \ + "get number of children of psnp->char_ptr" + +# Test: c_variable-5.13 +# Desc: children of *(psnp->char_ptr) +mi_gdb_test "-var-list-children psnp->char_ptr.*psnp->char_ptr" \ + "\\^done,numchild=\"1\",children=\\\[child=\{name=\"psnp->char_ptr.\\*psnp->char_ptr.\\*\\*psnp->char_ptr\",exp=\"\\*\\*psnp->char_ptr\",numchild=\"1\",type=\"char \\*\\*\"\}\\\]" \ + "get children of psnp->char_ptr.*psnp->char_ptr" + +# Test: c_variable-5.14 +# Desc: number of children of *(psnp->char_ptr) +mi_gdb_test "-var-info-num-children psnp->char_ptr.*psnp->char_ptr" \ + "\\^done,numchild=\"1\"" \ + "get number of children of psnp->char_ptr.*psnp->char_ptr" + +# Test: c_variable-5.15 +# Desc: children of *(*(psnp->char_ptr)) +mi_gdb_test "-var-list-children psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr" \ + "\\^done,numchild=\"1\",children=\\\[child=\{name=\"psnp->char_ptr.\\*psnp->char_ptr.\\*\\*psnp->char_ptr.\\*\\*\\*psnp->char_ptr\",exp=\"\\*\\*\\*psnp->char_ptr\",numchild=\"1\",type=\"char \\*\"\}\\\]" \ + "get children of psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr" + +# Test: c_variable-5.15B +# Desc: children of *(*(*(psnp->char_ptr))) +mi_gdb_test "-var-list-children psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr.***psnp->char_ptr" \ + "\\^done,numchild=\"1\",children=\\\[child=\{name=\"psnp->char_ptr.\\*psnp->char_ptr.\\*\\*psnp->char_ptr.\\*\\*\\*psnp->char_ptr.\\*\\*\\*\\*psnp->char_ptr\",exp=\"\\*\\*\\*\\*psnp->char_ptr\",numchild=\"0\",type=\"char\"\}\\\]" \ + "get children of psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr" + +# Test: c_variable-5.16 +# Desc: number of children of *(*(psnp->char_ptr)) +mi_gdb_test "-var-info-num-children psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr" \ + "\\^done,numchild=\"1\"" \ + "get number of children of psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr" + +# Test: c_variable-5.17 +# Desc: children of *(*(*(psnp->char_ptr))) +mi_gdb_test "-var-list-children psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr.***psnp->char_ptr" \ + "\\^done,numchild=\"1\",children=\\\[child=\{name=\"psnp->char_ptr.\\*psnp->char_ptr.\\*\\*psnp->char_ptr.\\*\\*\\*psnp->char_ptr.\\*\\*\\*\\*psnp->char_ptr\",exp=\"\\*\\*\\*\\*psnp->char_ptr\",numchild=\"0\",type=\"char\"\}\\\]" \ + "get children of psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr.***psnp->char_ptr" + +# Test: c_variable-5.18 +# Desc: number of children of *(*(*(psnp->char_ptr))) +mi_gdb_test "-var-info-num-children psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr.***psnp->char_ptr" \ + "\\^done,numchild=\"1\"" \ + "get number of children of psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr.***psnp->char_ptr" + +# Test: c_variable-5.17B +# Desc: children of *(*(*(*(psnp->char_ptr)))) +mi_gdb_test "-var-list-children psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr.***psnp->char_ptr.****psnp->char_ptr" \ + "\\^done,numchild=\"0\"" \ + "get children of psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr.***psnp->char_ptr.****psnp->char_ptr" + +# Test: c_variable-5.18B +# Desc: number of children of *(*(*(*(psnp->char_ptr)))) +mi_gdb_test "-var-info-num-children psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr.***psnp->char_ptr.****psnp->char_ptr" \ + "\\^done,numchild=\"0\"" \ + "get number of children of psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr.***psnp->char_ptr.****psnp->char_ptr" + + +# Test: c_variable-5.19 +# Desc: create psnp->long_ptr +mi_gdb_test "-var-create psnp->long_ptr * psnp->long_ptr" \ + "\\^done,name=\"psnp->long_ptr\",numchild=\"1\",type=\"long int \\*\\*\\*\\*\"" \ + "create local variable psnp->long_ptr" + +# Test: c_variable-5.20 +# Desc: children of psnp->long_ptr +mi_gdb_test "-var-list-children psnp->long_ptr" \ + "\\^done,numchild=\"1\",children=\\\[child=\{name=\"psnp->long_ptr.\\*psnp->long_ptr\",exp=\"\\*psnp->long_ptr\",numchild=\"1\",type=\"long int \\*\\*\\*\"\}\\\]" \ + "get children of psnp->long_ptr" + +# Test: c_variable-5.21 +# Desc: number of children of psnp->long_ptr +mi_gdb_test "-var-info-num-children psnp->long_ptr" \ + "\\^done,numchild=\"1\"" \ + "get number of children of psnp->long_ptr" + +# Test: c_variable-5.22 +# Desc: children of *(psnp->long_ptr) +mi_gdb_test "-var-list-children psnp->long_ptr.*psnp->long_ptr" \ + "\\^done,numchild=\"1\",children=\\\[child=\{name=\"psnp->long_ptr.\\*psnp->long_ptr.\\*\\*psnp->long_ptr\",exp=\"\\*\\*psnp->long_ptr\",numchild=\"1\",type=\"long int \\*\\*\"\}\\\]" \ + "get children of psnp->long_ptr.*psnp->long_ptr" + + +# Test: c_variable-5.23 +# Desc: number of children of *(psnp->long_ptr) +mi_gdb_test "-var-info-num-children psnp->long_ptr.*psnp->long_ptr" \ + "\\^done,numchild=\"1\"" \ + "get number of children of psnp->long_ptr.*psnp->long_ptr" + +# Test: c_variable-5.24 +# Desc: children of *(*(psnp->long_ptr)) +mi_gdb_test "-var-list-children psnp->long_ptr.*psnp->long_ptr.**psnp->long_ptr" \ + "\\^done,numchild=\"1\",children=\\\[child=\{name=\"psnp->long_ptr.\\*psnp->long_ptr.\\*\\*psnp->long_ptr.\\*\\*\\*psnp->long_ptr\",exp=\"\\*\\*\\*psnp->long_ptr\",numchild=\"1\",type=\"long int \\*\"\}\\\]" \ + "get children of psnp->long_ptr.*psnp->long_ptr.**psnp->long_ptr" + +# Test: c_variable-5.25 +# Desc: number of children of *(*(psnp->long_ptr)) +mi_gdb_test "-var-info-num-children psnp->long_ptr.*psnp->long_ptr.**psnp->long_ptr" \ + "\\^done,numchild=\"1\"" \ + "get number of children of psnp->long_ptr.*psnp->long_ptr.**psnp->long_ptr" + +# Test: c_variable-5.26 +# Desc: children of *(*(*(psnp->long_ptr))) +mi_gdb_test "-var-list-children psnp->long_ptr.*psnp->long_ptr.**psnp->long_ptr.***psnp->long_ptr" \ + "\\^done,numchild=\"1\",children=\\\[child=\{name=\"psnp->long_ptr.\\*psnp->long_ptr.\\*\\*psnp->long_ptr.\\*\\*\\*psnp->long_ptr.\\*\\*\\*\\*psnp->long_ptr\",exp=\"\\*\\*\\*\\*psnp->long_ptr\",numchild=\"0\",type=\"long int\"\}\\\]" \ + "get children of psnp->long_ptr.*psnp->long_ptr.**psnp->long_ptr.***psnp->long_ptr" + +# Test: c_variable-5.27 +# Desc: number of children of *(*(*(psnp->long_ptr))) +mi_gdb_test "-var-info-num-children psnp->long_ptr.*psnp->long_ptr.**psnp->long_ptr.***psnp->long_ptr" \ + "\\^done,numchild=\"1\"" \ + "get number of children of psnp->long_ptr.*psnp->long_ptr.**psnp->long_ptr.***psnp->long_ptr" + +# Test: c_variable-5.28 +# Desc: children of *(*(*(*(psnp->long_ptr)))) +mi_gdb_test "-var-list-children psnp->long_ptr.*psnp->long_ptr.**psnp->long_ptr.***psnp->long_ptr.****psnp->long_ptr" \ + "\\^done,numchild=\"0\"" \ + "get children of psnp->long_ptr.*psnp->long_ptr.**psnp->long_ptr.***psnp->long_ptr.****psnp->long_ptr" + +# Test: c_variable-5.29 +# Desc: number of children of *(*(*(*(psnp->long_ptr)))) +mi_gdb_test "-var-info-num-children psnp->long_ptr.*psnp->long_ptr.**psnp->long_ptr.***psnp->long_ptr.****psnp->long_ptr" \ + "\\^done,numchild=\"0\"" \ + "get number of children of psnp->long_ptr.*psnp->long_ptr.**psnp->long_ptr.***psnp->long_ptr.****psnp->long_ptr" + +# Test: c_variable-5.30 +# Desc: create psnp->ptrs +mi_gdb_test "-var-create psnp->ptrs * psnp->ptrs" \ + "\\^done,name=\"psnp->ptrs\",numchild=\"3\",type=\"struct _struct_n_pointer \\*\\\[3\\\]\"" \ + "create local variable psnp->ptrs" + +# Test: c_variable-5.31 +# Desc: children of psnp->ptrs +mi_gdb_test "-var-list-children psnp->ptrs" \ + "\\^done,numchild=\"3\",children=\\\[child=\{name=\"psnp->ptrs.0\",exp=\"0\",numchild=\"4\",type=\"struct _struct_n_pointer \\*\"\},child=\{name=\"psnp->ptrs.1\",exp=\"1\",numchild=\"4\",type=\"struct _struct_n_pointer \\*\"\},child=\{name=\"psnp->ptrs.2\",exp=\"2\",numchild=\"4\",type=\"struct _struct_n_pointer \\*\"\}\\\]" \ + "get children of psnp->ptrs" + +# Test: c_variable-5.32 +# Desc: number of children of psnp->ptrs +mi_gdb_test "-var-info-num-children psnp->ptrs" \ + "\\^done,numchild=\"3\"" \ + "get number of children of psnp->ptrs" + +# Test: c_variable-5.33 +# Desc: children of psnp->ptrs[0] +mi_gdb_test "-var-list-children psnp->ptrs.0" \ + "\\^done,numchild=\"4\",children=\\\[child=\{name=\"psnp->ptrs.0.char_ptr\",exp=\"char_ptr\",numchild=\"1\",type=\"char \\*\\*\\*\\*\"\},child=\{name=\"psnp->ptrs.0.long_ptr\",exp=\"long_ptr\",numchild=\"1\",type=\"long int \\*\\*\\*\\*\"\},child=\{name=\"psnp->ptrs.0.ptrs\",exp=\"ptrs\",numchild=\"3\",type=\"struct _struct_n_pointer \\*\\\[3\\\]\"\},child=\{name=\"psnp->ptrs.0.next\",exp=\"next\",numchild=\"4\",type=\"struct _struct_n_pointer \\*\"\}\\\]" \ + "get children of psnp->ptrs.0" + +# Test: c_variable-5.34 +# Desc: number of children of psnp->ptrs[0] +mi_gdb_test "-var-info-num-children psnp->ptrs.0" \ + "\\^done,numchild=\"4\"" \ + "get number of children of psnp->ptrs.0" + +# Test: c_variable-5.35 +# Desc: children of psnp->ptrs[0]->next +mi_gdb_test "-var-list-children psnp->ptrs.0.next" \ + "\\^done,numchild=\"4\",children=\\\[child=\{name=\"psnp->ptrs.0.next.char_ptr\",exp=\"char_ptr\",numchild=\"1\",type=\"char \\*\\*\\*\\*\"\},child=\{name=\"psnp->ptrs.0.next.long_ptr\",exp=\"long_ptr\",numchild=\"1\",type=\"long int \\*\\*\\*\\*\"\},child=\{name=\"psnp->ptrs.0.next.ptrs\",exp=\"ptrs\",numchild=\"3\",type=\"struct _struct_n_pointer \\*\\\[3\\\]\"\},child=\{name=\"psnp->ptrs.0.next.next\",exp=\"next\",numchild=\"4\",type=\"struct _struct_n_pointer \\*\"\}\\\]" \ + "get children of psnp->ptrs.0.next" + +#} {char_ptr long_ptr ptrs next} + +# Test: c_variable-5.36 +# Desc: number of children of psnp->ptrs[0]->next +mi_gdb_test "-var-info-num-children psnp->ptrs.0.next" \ + "\\^done,numchild=\"4\"" \ + "get number of children of psnp->ptrs.0.next" + + +# Test: c_variable-5.37 +# Desc: children of psnp->ptrs[0]->next->char_ptr +mi_gdb_test "-var-list-children psnp->ptrs.0.next.char_ptr" \ + "\\^done,numchild=\"1\",children=\\\[child=\{name=\"psnp->ptrs.0.next.char_ptr.\\*char_ptr\",exp=\"\\*char_ptr\",numchild=\"1\",type=\"char \\*\\*\\*\"\}\\\]" \ + "get children of psnp->ptrs.0.next.char_ptr" + +#gdbtk_test c_variable-5.37 {children of psnp->ptrs[0]->next->char_ptr} { +# get_children psnp->ptrs.0.next.char_ptr +#} {*char_ptr} + +# Test: c_variable-5.38 +# Desc: number of children of psnp->ptrs[0]->next->char_ptr +mi_gdb_test "-var-info-num-children psnp->ptrs.0.next.char_ptr" \ + "\\^done,numchild=\"1\"" \ + "get number of children of psnp->ptrs.0.next.char_ptr" + +# Test: c_variable-5.39 +# Desc: children of *psnp->ptrs[0]->next->char_ptr +mi_gdb_test "-var-list-children psnp->ptrs.0.next.char_ptr.*char_ptr" \ + "\\^done,numchild=\"1\",children=\\\[child=\{name=\"psnp->ptrs.0.next.char_ptr.\\*char_ptr.\\*\\*char_ptr\",exp=\"\\*\\*char_ptr\",numchild=\"1\",type=\"char \\*\\*\"\}\\\]" \ + "get children of psnp->ptrs.0.next.char_ptr.*char_ptr" + +# Test: c_variable-5.40 +# Desc: number of children of *psnp->ptrs[0]->next->char_ptr +mi_gdb_test "-var-info-num-children psnp->ptrs.0.next.char_ptr.*char_ptr" \ + "\\^done,numchild=\"1\"" \ + "get number of children of psnp->ptrs.0.next.char_ptr.*char_ptr" + +# Test: c_variable-5.41 +# Desc: children of **psnp->ptrs[0]->next->char_ptr +mi_gdb_test "-var-list-children psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr" \ + "\\^done,numchild=\"1\",children=\\\[child=\{name=\"psnp->ptrs.0.next.char_ptr.\\*char_ptr.\\*\\*char_ptr.\\*\\*\\*char_ptr\",exp=\"\\*\\*\\*char_ptr\",numchild=\"1\",type=\"char \\*\"\}\\\]" \ + "get children of psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr" + +# Test: c_variable-5.41B +# Desc: children of ***psnp->ptrs[0]->next->char_ptr +mi_gdb_test "-var-list-children psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr.***char_ptr" \ + "\\^done,numchild=\"1\",children=\\\[child=\{name=\"psnp->ptrs.0.next.char_ptr.\\*char_ptr.\\*\\*char_ptr.\\*\\*\\*char_ptr.\\*\\*\\*\\*char_ptr\",exp=\"\\*\\*\\*\\*char_ptr\",numchild=\"0\",type=\"char\"\}\\\]" \ + "get children of psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr" + +# Test: c_variable-5.42 +# Desc: number of children of **psnp->ptrs[0]->next->char_ptr +mi_gdb_test "-var-info-num-children psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr" \ + "\\^done,numchild=\"1\"" \ + "get number of children of psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr" + +# Test: c_variable-5.43 +# Desc: children of ***psnp->ptrs[0]->next->char_ptr +mi_gdb_test "-var-list-children psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr.***char_ptr" \ + "\\^done,numchild=\"1\",children=\\\[child=\{name=\"psnp->ptrs.0.next.char_ptr.\\*char_ptr.\\*\\*char_ptr.\\*\\*\\*char_ptr.\\*\\*\\*\\*char_ptr\",exp=\"\\*\\*\\*\\*char_ptr\",numchild=\"0\",type=\"char\"\}\\\]" \ + "get children of psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr.***char_ptr" + +# Test: c_variable-5.44 +# Desc: number of children of ***psnp->ptrs[0]->next->char_ptr +mi_gdb_test "-var-info-num-children psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr.***char_ptr" \ + "\\^done,numchild=\"1\"" \ + "get number of children of psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr.***char_ptr" + +# Test: c_variable-5.43B +# Desc: children of ****psnp->ptrs[0]->next->char_ptr +mi_gdb_test "-var-list-children psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr.***char_ptr.****char_ptr" \ + "\\^done,numchild=\"0\"" \ + "get children of psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr.***char_ptr" + +# Test: c_variable-5.44B +# Desc: number of children of ****psnp->ptrs[0]->next->char_ptr +mi_gdb_test "-var-info-num-children psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr.***char_ptr.****char_ptr" \ + "\\^done,numchild=\"0\"" \ + "get number of children of psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr.***char_ptr" + +# Test: c_variable-5.45 +# Desc: children of psnp->ptrs[0]->next->next +mi_gdb_test "-var-list-children psnp->ptrs.0.next.next" \ + "\\^done,numchild=\"4\",children=\\\[child=\{name=\"psnp->ptrs.0.next.next.char_ptr\",exp=\"char_ptr\",numchild=\"1\",type=\"char \\*\\*\\*\\*\"\},child=\{name=\"psnp->ptrs.0.next.next.long_ptr\",exp=\"long_ptr\",numchild=\"1\",type=\"long int \\*\\*\\*\\*\"\},child=\{name=\"psnp->ptrs.0.next.next.ptrs\",exp=\"ptrs\",numchild=\"3\",type=\"struct _struct_n_pointer \\*\\\[3\\\]\"\},child=\{name=\"psnp->ptrs.0.next.next.next\",exp=\"next\",numchild=\"4\",type=\"struct _struct_n_pointer \\*\"\}\\\]" \ + "get children of psnp->ptrs.0.next.next" + +# Test: c_variable-5.46 +# Desc: children of psnp->ptrs[0]->next->next->ptrs +mi_gdb_test "-var-list-children psnp->ptrs.0.next.next.ptrs" \ + "\\^done,numchild=\"3\",children=\\\[child=\{name=\"psnp->ptrs.0.next.next.ptrs.0\",exp=\"0\",numchild=\"4\",type=\"struct _struct_n_pointer \\*\"\},child=\{name=\"psnp->ptrs.0.next.next.ptrs.1\",exp=\"1\",numchild=\"4\",type=\"struct _struct_n_pointer \\*\"\},child=\{name=\"psnp->ptrs.0.next.next.ptrs.2\",exp=\"2\",numchild=\"4\",type=\"struct _struct_n_pointer \\*\"\}\\\]" \ + "get children of psnp->ptrs.0.next.next.ptrs" + +# Step over "snp0.char_ptr = &b3;" +set line 255 +mi_step_to do_children_tests {} {.*var-cmd.c} $line "step $line" + +# Test: c_variable-5.47 +# Desc: check that psnp->char_ptr (and [0].char_ptr) changed +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\\\[\{name=\"psnp->ptrs.0.char_ptr\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"psnp->char_ptr\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"psnp->char_ptr.\\*psnp->char_ptr\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"psnp->char_ptr.\\*psnp->char_ptr.\\*\\*psnp->char_ptr\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"psnp->char_ptr.\\*psnp->char_ptr.\\*\\*psnp->char_ptr.\\*\\*\\*psnp->char_ptr\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"psnp->char_ptr.\\*psnp->char_ptr.\\*\\*psnp->char_ptr.\\*\\*\\*psnp->char_ptr.\\*\\*\\*\\*psnp->char_ptr\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \ + "update all vars psnp->char_ptr (and 0.char_ptr) changed" + +# Step over "snp1.char_ptr = &c3;" +set line 256 +mi_step_to do_children_tests {} {.*var-cmd.c} $line "step $line" + +# Test: c_variable-5.48 +# Desc: check that psnp->next->char_ptr (and [1].char_ptr) changed +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\\\[\{name=\"psnp->ptrs.0.next.char_ptr\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"psnp->ptrs.0.next.char_ptr.\\*char_ptr\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"psnp->ptrs.0.next.char_ptr.\\*char_ptr.\\*\\*char_ptr\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"psnp->ptrs.0.next.char_ptr.\\*char_ptr.\\*\\*char_ptr.\\*\\*\\*char_ptr\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"psnp->ptrs.0.next.char_ptr.\\*char_ptr.\\*\\*char_ptr.\\*\\*\\*char_ptr.\\*\\*\\*\\*char_ptr\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \ + "update all vars psnp->next->char_ptr (and 1.char_ptr) changed" + + +# Step over "snp2.char_ptr = &a3;" +set line 257 +mi_step_to do_children_tests {} {.*var-cmd.c} $line "step $line" + +# Test: c_variable-5.49 +# Desc: check that psnp->next->next->char_ptr (and [2].char_ptr) changed +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\\\[\{name=\"psnp->ptrs.0.next.next.char_ptr\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \ + "update all vars psnp->next->next->char_ptr (and 2.char_ptr) changed" + + +# Step over "snp0.long_ptr = &y3;" +set line 258 +mi_step_to do_children_tests {} {.*var-cmd.c} $line "step $line" + +# Test: c_variable-5.50 +# Desc: check that psnp->long_ptr (and [0].long_ptr) changed +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\\\[\{name=\"psnp->ptrs.0.long_ptr\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"psnp->long_ptr\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"psnp->long_ptr.\\*psnp->long_ptr\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"psnp->long_ptr.\\*psnp->long_ptr.\\*\\*psnp->long_ptr\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"psnp->long_ptr.\\*psnp->long_ptr.\\*\\*psnp->long_ptr.\\*\\*\\*psnp->long_ptr\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"psnp->long_ptr.\\*psnp->long_ptr.\\*\\*psnp->long_ptr.\\*\\*\\*psnp->long_ptr.\\*\\*\\*\\*psnp->long_ptr\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \ + "update all vars psnp->long_ptr (and 0.long_ptr) changed" + + +# Step over "snp1.long_ptr = &x3;" +set line 259 +mi_step_to do_children_tests {} {.*var-cmd.c} $line "step $line" + +# Test: c_variable-5.51 +# Desc: check that psnp->next->long_ptr (and [1].long_ptr) changed +# Why does this have a FIXME? +setup_xfail *-*-* +mi_gdb_test "-var-update *" \ + "FIXME\\^done,changelist=\\\[\{name=\"psnp->ptrs.0.next.long_ptr\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \ + "update all vars psnp->next->long_ptr (and 1.long_ptr) changed" +clear_xfail *-*-* + +# This command produces this error message: +# &"warning: varobj_list: assertion failed - mycount <> 0\n" +# + +# Step over "snp2.long_ptr = &z3;" +set line 260 +mi_step_to do_children_tests {} {.*var-cmd.c} $line "step $line" + +# Test: c_variable-5.52 +# Desc: check that psnp->next->next->long_ptr (and [2].long_ptr) changed +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\\\[\{name=\"psnp->ptrs.0.next.next.long_ptr\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \ + "update all vars psnp->next->next->long_ptr (and 2.long_ptr) changed" + + + + +mi_gdb_exit +return 0 diff --git a/gdb/testsuite/gdb.mi/mi2-var-cmd.exp b/gdb/testsuite/gdb.mi/mi2-var-cmd.exp new file mode 100644 index 0000000..25326df --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi2-var-cmd.exp @@ -0,0 +1,560 @@ +# Copyright (C) 1999, 2000, 2002 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# Test essential Machine interface (MI) operations +# +# Verify that, using the MI, we can create, update, delete variables. +# + + +load_lib mi-support.exp +set MIFLAGS "-i=mi2" + +gdb_exit +if [mi_gdb_start] { + continue +} + +set testfile "var-cmd" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + + +##### ##### +# # +# Variable Creation tests # +# # +##### ##### + +# Test: c_variable-1.1 +# Desc: Create global variable + +mi_gdb_test "111-var-create global_simple * global_simple" \ + "111\\^done,name=\"global_simple\",numchild=\"6\",type=\"simpleton\"" \ + "create global variable" + +# Test: c_variable-1.2 +# Desc: Create non-existent variable + +mi_gdb_test "112-var-create bogus_unknown_variable * bogus_unknown_variable" \ + "&\"mi_cmd_var_create: unable to create variable object\\\\n\".*112\\^error,msg=\"mi_cmd_var_create: unable to create variable object\"" \ + "create non-existent variable" + +# Test: c_variable-1.3 +# Desc: Create out of scope variable + +mi_gdb_test "113-var-create argc * argc" \ + "&\"mi_cmd_var_create: unable to create variable object\\\\n\".*113\\^error,msg=\"mi_cmd_var_create: unable to create variable object\"" \ + "create out of scope variable" + +mi_runto do_locals_tests + +# Test: c_variable-1.4 +# Desc: create local variables + +mi_gdb_test "-var-create linteger * linteger" \ + "\\^done,name=\"linteger\",numchild=\"0\",type=\"int\"" \ + "create local variable linteger" + +mi_gdb_test "-var-create lpinteger * lpinteger" \ + "\\^done,name=\"lpinteger\",numchild=\"1\",type=\"int \\*\"" \ + "create local variable lpinteger" + +mi_gdb_test "-var-create lcharacter * lcharacter" \ + "\\^done,name=\"lcharacter\",numchild=\"0\",type=\"char\"" \ + "create local variablelcharacter " + +mi_gdb_test "-var-create lpcharacter * lpcharacter" \ + "\\^done,name=\"lpcharacter\",numchild=\"1\",type=\"char \\*\"" \ + "create local variable lpcharacter" + +mi_gdb_test "-var-create llong * llong" \ + "\\^done,name=\"llong\",numchild=\"0\",type=\"long int\"" \ + "create local variable llong" + +mi_gdb_test "-var-create lplong * lplong" \ + "\\^done,name=\"lplong\",numchild=\"1\",type=\"long int \\*\"" \ + "create local variable lplong" + +mi_gdb_test "-var-create lfloat * lfloat" \ + "\\^done,name=\"lfloat\",numchild=\"0\",type=\"float\"" \ + "create local variable lfloat" + +mi_gdb_test "-var-create lpfloat * lpfloat" \ + "\\^done,name=\"lpfloat\",numchild=\"1\",type=\"float \\*\"" \ + "create local variable lpfloat" + +mi_gdb_test "-var-create ldouble * ldouble" \ + "\\^done,name=\"ldouble\",numchild=\"0\",type=\"double\"" \ + "create local variable ldouble" + +mi_gdb_test "-var-create lpdouble * lpdouble" \ + "\\^done,name=\"lpdouble\",numchild=\"1\",type=\"double \\*\"" \ + "create local variable lpdouble" + +mi_gdb_test "-var-create lsimple * lsimple" \ + "\\^done,name=\"lsimple\",numchild=\"6\",type=\"struct _simple_struct\"" \ + "create local variable lsimple" + +mi_gdb_test "-var-create lpsimple * lpsimple" \ + "\\^done,name=\"lpsimple\",numchild=\"6\",type=\"struct _simple_struct \\*\"" \ + "create local variable lpsimple" + +mi_gdb_test "-var-create func * func" \ + "\\^done,name=\"func\",numchild=\"0\",type=\"void \\(\\*\\)\\((void|)\\)\"" \ + "create local variable func" + +# Test: c_variable-1.5 +# Desc: create lsimple.character +mi_gdb_test "-var-create lsimple.character * lsimple.character" \ + "\\^done,name=\"lsimple.character\",numchild=\"0\",type=\"char\"" \ + "create lsimple.character" + +# Test: c_variable-1.6 +# Desc: create lpsimple->integer +mi_gdb_test "-var-create lsimple->integer * lsimple->integer" \ + "\\^done,name=\"lsimple->integer\",numchild=\"0\",type=\"int\"" \ + "create lsimple->integer" + +# Test: c_variable-1.7 +# Desc: ceate lsimple.integer +mi_gdb_test "-var-create lsimple.integer * lsimple.integer" \ + "\\^done,name=\"lsimple.integer\",numchild=\"0\",type=\"int\"" \ + "create lsimple->integer" + + +# Test: c_variable-1.9 +# Desc: create type name +# Type names (like int, long, etc..) are all proper expressions to gdb. +# make sure variable code does not allow users to create variables, though. +mi_gdb_test "-var-create int * int" \ + "&\"Attempt to use a type name as an expression.mi_cmd_var_create: unable to create variable object\\\\n\".*\\^error,msg=\"mi_cmd_var_create: unable to create variable object\"" \ + "create int" + + +##### ##### +# # +# Value changed tests # +# # +##### ##### + +# Test: c_variable-2.1 +# Desc: check whether values changed at do_block_tests +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\\\[\\\]" \ + "update all vars" + +# Step over "linteger = 1234;" +mi_step_to "do_locals_tests" "" "var-cmd.c" "107" "step at do_locals_test" + +# Test: c_variable-2.2 +# Desc: check whether only linteger changed values +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\\\[\{name=\"linteger\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \ + "update all vars: linteger changed" + +# Step over "lpinteger = &linteger;" +mi_step_to "do_locals_tests" "" "var-cmd.c" 108 "step at do_locals_tests (2)" + +# Test: c_variable-2.3 +# Desc: check whether only lpinteger changed +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\\\[\{name=\"lpinteger\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \ + "update all vars: lpinteger changed" + +# Step over "lcharacter = 'a';" +mi_step_to "do_locals_tests" "" "var-cmd.c" "109" "step at do_locals_tests (3)" + +# Test: c_variable-2.4 +# Desc: check whether only lcharacter changed +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\\\[\{name=\"lcharacter\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \ + "update all vars: lcharacter changed" + +# Step over "lpcharacter = &lcharacter;" +mi_step_to "do_locals_tests" "" "var-cmd.c" "110" "step at do_locals_tests (4)" + +# Test: c_variable-2.5 +# Desc: check whether only lpcharacter changed +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\\\[\{name=\"lpcharacter\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \ + "update all vars: lpcharacter changed" + + +# Step over: +# llong = 2121L; +# lplong = &llong; +# lfloat = 2.1; +# lpfloat = &lfloat; +# ldouble = 2.718281828459045; +# lpdouble = &ldouble; +# lsimple.integer = 1234; +# lsimple.unsigned_integer = 255; +# lsimple.character = 'a'; + +mi_execute_to "exec-step 9" "end-stepping-range" "do_locals_tests" "" \ + "var-cmd.c" "119" "" "step at do_locals_tests (5)" + +# Test: c_variable-2.6 +# Desc: check whether llong, lplong, lfloat, lpfloat, ldouble, lpdouble, lsimple.integer, +# lsimple.unsigned_character lsimple.integer lsimple.character changed +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\\\[\{name=\"lsimple.integer\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lsimple->integer\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lsimple.character\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lpdouble\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"ldouble\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lpfloat\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lfloat\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lplong\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"llong\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \ + "update all vars: many changed" + +# Step over: +# lsimple.signed_character = 21; +# lsimple.char_ptr = &lcharacter; +# lpsimple = &lsimple; +# func = nothing; + +mi_execute_to "exec-step 4" "end-stepping-range" "do_locals_tests" "" \ + "var-cmd.c" "125" "" "step at do_locals_tests (6)" + +# Test: c_variable-2.7 +# Desc: check whether (lsimple.signed_character, lsimple.char_ptr) lpsimple, func changed +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\\\[\{name=\"func\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lpsimple\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \ + "update all vars: func and lpsimple changed" + +# Step over +# linteger = 4321; +# lcharacter = 'b'; +# llong = 1212L; +# lfloat = 1.2; +# ldouble = 5.498548281828172; +# lsimple.integer = 255; +# lsimple.unsigned_integer = 4321; +# lsimple.character = 'b'; + +mi_execute_to "exec-step 8" "end-stepping-range" "do_locals_tests" "" \ + "var-cmd.c" "133" "" "step at do_locals_tests (7)" + +# Test: c_variable-2.8 +# Desc: check whether linteger, lcharacter, llong, lfoat, ldouble, lsimple.integer, +# lpsimple.integer lsimple.character changed +# Note: this test also checks that lpsimple->integer and lsimple.integer have +# changed (they are the same) +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\\\[\{name=\"lsimple.integer\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lsimple->integer\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lsimple.character\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"ldouble\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lfloat\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"llong\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lcharacter\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"linteger\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \ + "update all vars: func and lpsimple changed" + + +### +# +# Test assignment to variables. More tests on assignment are in other files. +# +### +mi_gdb_test "-var-assign global_simple 0" \ + "&\"mi_cmd_var_assign: Variable object is not editable\\\\n\".*\\^error,msg=\"mi_cmd_var_assign: Variable object is not editable\"" \ + "assign to global_simple" + +mi_gdb_test "-var-assign linteger 3333" \ + "\\^done,value=\"3333\"" \ + "assign to linteger" + +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\\\[\{name=\"linteger\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \ + "update all vars: linteger changed after assign" + +mi_gdb_test "-var-assign linteger 3333" \ + "\\^done,value=\"3333\"" \ + "assign to linteger again, same value" + +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\\\[\\\]" \ + "update all vars: linteger not changed after same assign" + +mi_gdb_test "-var-evaluate-expression linteger" \ + "\\^done,value=\"3333\"" \ + "eval linteger" + +mi_gdb_test "-var-assign lpinteger \"&linteger + 3\"" \ + "\\^done,value=\"$hex\"" \ + "assign to lpinteger" + +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\\\[\{name=\"lpinteger\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \ + "update all vars: lpinteger changed after assign" + +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\\\[\\\]" \ + "update all vars: no changes on second update" + +mi_gdb_test "-var-evaluate-expression lpinteger" \ + "\\^done,value=\"$hex\"" \ + "eval lpinteger" + +# reset the values to the original ones so that the rest of the file doesn't suffer. + +mi_gdb_test "-var-assign linteger 4321" \ + "\\^done,value=\"4321\"" \ + "assign to linteger" + +mi_gdb_test "-var-assign lpinteger &linteger" \ + "\\^done,value=\"$hex\"" \ + "assign to lpinteger" + +mi_gdb_test "-var-assign lcharacter 'z'" \ + "\\^done,value=\"122 'z'\"" \ + "assign to lcharacter" + +mi_gdb_test "-var-evaluate-expression lcharacter" \ + "\\^done,value=\"122 'z'\"" \ + "eval lcharacter" + +mi_gdb_test "-var-assign llong 1313L" \ + "\\^done,value=\"1313\"" \ + "assign to llong" +mi_gdb_test "-var-evaluate-expression llong" \ + "\\^done,value=\"1313\"" \ + "eval llong" +mi_gdb_test "-var-assign llong 1212L" \ + "\\^done,value=\"1212\"" \ + "assign to llong" + +mi_gdb_test "-var-assign lplong &llong+4" \ + "\\^done,value=\"$hex\"" \ + "assign to lplong" +mi_gdb_test "-var-evaluate-expression lplong" \ + "\\^done,value=\"$hex\"" \ + "eval lplong" +mi_gdb_test "-var-assign lplong &llong" \ + "\\^done,value=\"$hex\"" \ + "assign to lplong" + +mi_gdb_test "-var-assign lfloat 3.4567" \ + "\\^done,value=\"3.45.*\"" \ + "assign to lfloat" +mi_gdb_test "-var-evaluate-expression lfloat" \ + "\\^done,value=\"3.45.*\"" \ + "eval lfloat" +mi_gdb_test "-var-assign lfloat 1.2345" \ + "\\^done,value=\"1.23.*\"" \ + "assign to lfloat" + +mi_gdb_test "-var-assign lpfloat &lfloat+4" \ + "\\^done,value=\"$hex\"" \ + "assign to lpfloat" + +mi_gdb_test "-var-assign ldouble 5.333318284590435" \ + "\\^done,value=\"5.333318284590435\"" \ + "assign to ldouble" + +mi_gdb_test "-var-assign func do_block_tests" \ + "\\^done,value=\"$hex <do_block_tests>\"" \ + "assign to func" + +mi_gdb_test "-var-assign lsimple.character 'd'" \ + "\\^done,value=\"100 'd'\"" \ + "assign to lsimple.character" + +mi_gdb_test "-var-assign lsimple->integer 222" \ + "\\^done,value=\"222\"" \ + "assign to lsimple->integer" + +mi_gdb_test "-var-assign lsimple.integer 333" \ + "\\^done,value=\"333\"" \ + "assign to lsimple.integer" + +###### +# End of assign tests +##### + +mi_gdb_test "-break-insert subroutine1" \ + "\\^done,bkpt=\{number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"subroutine1\",file=\".*var-cmd.c\",line=\"146\",times=\"0\"\}" \ + "break-insert subroutine1" +mi_continue_to "2" "subroutine1" \ + "\{name=\"i\",value=\"4321\"\},\{name=\"l\",value=\"$hex\"\}" \ + "var-cmd.c" "146" "continue to subroutine1" + +# Test: c_variable-2.10 +# Desc: create variable for locals i,l in subroutine1 +mi_gdb_test "-var-create i * i" \ + "\\^done,name=\"i\",numchild=\"0\",type=\"int\"" \ + "create i" + +mi_gdb_test "-var-create l * l" \ + "\\^done,name=\"l\",numchild=\"1\",type=\"long int \\*\"" \ + "create l" + +# Test: c_variable-2.11 +# Desc: create do_locals_tests local in subroutine1 +mi_gdb_test "-var-create linteger * linteger" \ + "&\"mi_cmd_var_create: unable to create variable object\\\\n\".*\\^error,msg=\"mi_cmd_var_create: unable to create variable object\"" \ + "create linteger" + +mi_step_to "subroutine1" "\{name=\"i\",value=\".*\"\},\{name=\"l\",value=\".*\"\}" \ + "var-cmd.c" "147" "step at subroutine1" + +# Test: c_variable-2.12 +# Desc: change global_simple.integer +# Note: This also tests whether we are reporting changes in structs properly. +# gdb normally would say that global_simple has changed, but we +# special case that, since it is not what a human expects to +# see. + +setup_xfail *-*-* +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\{FIXME: WHAT IS CORRECT HERE\}" \ + "update all vars: changed FIXME" +clear_xfail *-*-* + +mi_step_to "subroutine1" "\{name=\"i\",value=\".*\"\},\{name=\"l\",value=\".*\"\}" \ + "var-cmd.c" "148" "step at subroutine1 (2)" + +# Test: c_variable-2.13 +# Desc: change subroutine1 local i +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\\\[\{name=\"i\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \ + "update all vars: i changed" + +mi_step_to "subroutine1" "\{name=\"i\",value=\".*\"\},\{name=\"l\",value=\".*\"\}" \ + "var-cmd.c" "149" "step at subroutine1 (3)" + +# Test: c_variable-2.14 +# Desc: change do_locals_tests local llong +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\\\[\{name=\"llong\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \ + "update all vars: llong changed" + +mi_next_to "do_locals_tests" "" "var-cmd.c" "136" "next out of subroutine1" + +# Test: c_variable-2.15 +# Desc: check for out of scope subroutine1 locals +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\\\[\{name=\"l\",in_scope=\"false\"\},\{name=\"i\",in_scope=\"false\"\}\\\]" \ + "update all vars: all now out of scope" + +# Done with locals/globals tests. Erase all variables +#delete_all_variables +mi_gdb_test "-var-delete global_simple" \ + "\\^done,ndeleted=\"1\"" \ + "delete var" + +mi_gdb_test "-var-delete linteger" \ + "\\^done,ndeleted=\"1\"" \ + "delete var linteger" + +mi_gdb_test "-var-delete lpinteger" \ + "\\^done,ndeleted=\"1\"" \ + "delete var lpinteger" + +mi_gdb_test "-var-delete lcharacter" \ + "\\^done,ndeleted=\"1\"" \ + "delete var lcharacter" + +mi_gdb_test "-var-delete lpcharacter" \ + "\\^done,ndeleted=\"1\"" \ + "delete var lpcharacter" + +mi_gdb_test "-var-delete llong" \ + "\\^done,ndeleted=\"1\"" \ + "delete var llong" + +mi_gdb_test "-var-delete lplong" \ + "\\^done,ndeleted=\"1\"" \ + "delete var lplong" + +mi_gdb_test "-var-delete lfloat" \ + "\\^done,ndeleted=\"1\"" \ + "delete var lfloat" + +mi_gdb_test "-var-delete lpfloat" \ + "\\^done,ndeleted=\"1\"" \ + "delete var lpfloat" + +mi_gdb_test "-var-delete ldouble" \ + "\\^done,ndeleted=\"1\"" \ + "delete var ldouble" + +mi_gdb_test "-var-delete lpdouble" \ + "\\^done,ndeleted=\"1\"" \ + "delete var lpdouble" + +mi_gdb_test "-var-delete lsimple" \ + "\\^done,ndeleted=\"1\"" \ + "delete var lsimple" + +mi_gdb_test "-var-delete lpsimple" \ + "\\^done,ndeleted=\"1\"" \ + "delete var lpsimple" + +mi_gdb_test "-var-delete func" \ + "\\^done,ndeleted=\"1\"" \ + "delete var func" + +mi_gdb_test "-var-delete lsimple.character" \ + "\\^done,ndeleted=\"1\"" \ + "delete var lsimple.character" + +mi_gdb_test "-var-delete lsimple->integer" \ + "\\^done,ndeleted=\"1\"" \ + "delete var lsimple->integer" + +mi_gdb_test "-var-delete lsimple.integer" \ + "\\^done,ndeleted=\"1\"" \ + "delete var lsimple.integer" + +mi_gdb_test "-var-delete i" \ + "\\^done,ndeleted=\"1\"" \ + "delete var i" + +mi_gdb_test "-var-delete l" \ + "\\^done,ndeleted=\"1\"" \ + "delete var l" + +# Test whether we can follow the name of a variable through multiple +# stack frames. +mi_gdb_test "-break-insert do_special_tests" \ + {\^done,bkpt=.*} \ + "set breakpoint at do_special_tests" + +mi_continue_to {.*} do_special_tests {.*} {.*var-cmd.c} {.*} {stop in do_special_tests} + +mi_gdb_test "-var-create selected_a @ a" \ + {\^done,name="selected_a",numchild="0",type="int"} \ + "create selected_a" + +mi_gdb_test "-break-insert incr_a" \ + {\^done,bkpt=.*} \ + "set breakpoint at incr_a" + +mi_continue_to {.*} incr_a {.*} {.*var-cmd.c} {.*} {stop in incr_a} + +mi_gdb_test "-var-update selected_a" \ + "\\^done,changelist=\\\[\{name=\"selected_a\",in_scope=\"true\",new_type=\"char\",new_num_children=\"0\"\}\\\]" \ + "update selected_a in incr_a" + +mi_next "step a line in incr_a" +mi_next "return from incr_a to do_special_tests" + +mi_gdb_test "-var-update selected_a" \ + "\\^done,changelist=\\\[\{name=\"selected_a\",in_scope=\"true\",new_type=\"int\",new_num_children=\"0\"\}\\\]" \ + "update selected_a in do_special_tests" + +mi_gdb_exit +return 0 diff --git a/gdb/testsuite/gdb.mi/mi2-var-display.exp b/gdb/testsuite/gdb.mi/mi2-var-display.exp new file mode 100644 index 0000000..3b0990d --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi2-var-display.exp @@ -0,0 +1,627 @@ +# Copyright (C) 1999, 2000, 2002 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# Test essential Machine interface (MI) operations +# +# Verify that, using the MI, we can create, update, delete variables. +# + + +load_lib mi-support.exp +set MIFLAGS "-i=mi2" + +gdb_exit +if [mi_gdb_start] { + continue +} + +set testfile "var-cmd" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +mi_gdb_test "200-break-insert 260" \ + "200\\^done,bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"do_children_tests\",file=\".*var-cmd.c\",line=\"260\",times=\"0\"\}" \ + "break-insert operation" + +mi_run_cmd +# The running part has been checked already by mi_run_cmd +gdb_expect { + -re "\[\r\n\]*000\\*stopped,reason=\"breakpoint-hit\",bkptno=\"1\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"do_children_tests\",args=\\\[\\\],file=\".*var-cmd.c\",line=\"260\"\}\r\n$mi_gdb_prompt$" { + pass "run to do_children_tests" + } + -re ".*$mi_gdb_prompt$" {fail "run to do_children_tests (2)"} + timeout {fail "run to do_children_tests (timeout 2)"} +} + +##### ##### +# # +# Display tests # +# # +##### ##### + +# Test: c_variable-6.1 +# Desc: create variable bar +mi_gdb_test "-var-create bar * bar" \ + "\\^done,name=\"bar\",numchild=\"0\",type=\"int\"" \ + "create local variable bar" + +# Test: c_variable-6.2 +# Desc: type of variable bar +mi_gdb_test "-var-info-type bar" \ + "\\^done,type=\"int\"" \ + "info type variable bar" + +# Test: c_variable-6.3 +# Desc: format of variable bar +mi_gdb_test "-var-show-format bar" \ + "\\^done,format=\"natural\"" \ + "show format variable bar" + +# Test: c_variable-6.4 +# Desc: value of variable bar +mi_gdb_test "-var-evaluate-expression bar" \ + "\\^done,value=\"2121\"" \ + "eval variable bar" + +# Test: c_variable-6.5 +# Desc: change format of bar to hex +mi_gdb_test "-var-set-format bar hexadecimal" \ + "\\^done,format=\"hexadecimal\"" \ + "set format variable bar" + +# Test: c_variable-6.6 +# Desc: value of bar with new format +mi_gdb_test "-var-evaluate-expression bar" \ + "\\^done,value=\"0x849\"" \ + "eval variable bar with new format" + +# Test: c_variable-6.7 +# Desc: change value of bar +mi_gdb_test "-var-assign bar 3" \ + "\\^done,value=\"0x3\"" \ + "assing to variable bar" + +mi_gdb_test "-var-set-format bar decimal" \ + "\\^done,format=\"decimal\"" \ + "set format variable bar" + +mi_gdb_test "-var-evaluate-expression bar" \ + "\\^done,value=\"3\"" \ + "eval variable bar with new value" + +mi_gdb_test "-var-delete bar" \ + "\\^done,ndeleted=\"1\"" \ + "delete var bar" + +# Test: c_variable-6.11 +# Desc: create variable foo +mi_gdb_test "-var-create foo * foo" \ + "\\^done,name=\"foo\",numchild=\"1\",type=\"int \\*\"" \ + "create local variable foo" + +# Test: c_variable-6.12 +# Desc: type of variable foo +mi_gdb_test "-var-info-type foo" \ + "\\^done,type=\"int \\*\"" \ + "info type variable foo" + +# Test: c_variable-6.13 +# Desc: format of variable foo +mi_gdb_test "-var-show-format foo" \ + "\\^done,format=\"natural\"" \ + "show format variable foo" + +# Test: c_variable-6.14 +# Desc: value of variable foo +mi_gdb_test "-var-evaluate-expression foo" \ + "\\^done,value=\"$hex\"" \ + "eval variable foo" + +# Test: c_variable-6.15 +# Desc: change format of var to octal +mi_gdb_test "-var-set-format foo octal" \ + "\\^done,format=\"octal\"" \ + "set format variable foo" + +mi_gdb_test "-var-show-format foo" \ + "\\^done,format=\"octal\"" \ + "show format variable foo" + +# Test: c_variable-6.16 +# Desc: value of foo with new format +mi_gdb_test "-var-evaluate-expression foo" \ + "\\^done,value=\"\[0-7\]+\"" \ + "eval variable foo" + +# Test: c_variable-6.17 +# Desc: change value of foo +mi_gdb_test "-var-assign foo 3" \ + "\\^done,value=\"03\"" \ + "assing to variable foo" + +mi_gdb_test "-var-set-format foo decimal" \ + "\\^done,format=\"decimal\"" \ + "set format variable foo" + +# Test: c_variable-6.18 +# Desc: check new value of foo +mi_gdb_test "-var-evaluate-expression foo" \ + "\\^done,value=\"3\"" \ + "eval variable foo" + +mi_gdb_test "-var-delete foo" \ + "\\^done,ndeleted=\"1\"" \ + "delete var foo" + +# Test: c_variable-6.21 +# Desc: create variable weird and children +mi_gdb_test "-var-create weird * weird" \ + "\\^done,name=\"weird\",numchild=\"11\",type=\"weird_struct \\*\"" \ + "create local variable weird" + +mi_gdb_test "-var-list-children weird" \ + "\\^done,numchild=\"11\",children=\\\[child=\{name=\"weird.integer\",exp=\"integer\",numchild=\"0\",type=\"int\"\},child=\{name=\"weird.character\",exp=\"character\",numchild=\"0\",type=\"char\"\},child={name=\"weird.char_ptr\",exp=\"char_ptr\",numchild=\"1\",type=\"char \\*\"\},child=\{name=\"weird.long_int\",exp=\"long_int\",numchild=\"0\",type=\"long int\"\},child=\{name=\"weird.int_ptr_ptr\",exp=\"int_ptr_ptr\",numchild=\"1\",type=\"int \\*\\*\"\},child=\{name=\"weird.long_array\",exp=\"long_array\",numchild=\"10\",type=\"long int \\\[10\\\]\"\},child=\{name=\"weird.func_ptr\",exp=\"func_ptr\",numchild=\"0\",type=\"void \\(\\*\\)\\((void|)\\)\"\},child=\{name=\"weird.func_ptr_struct\",exp=\"func_ptr_struct\",numchild=\"0\",type=\"struct _struct_decl \\(\\*\\)\\((int, char \\*, long int|)\\)\"\},child=\{name=\"weird.func_ptr_ptr\",exp=\"func_ptr_ptr\",numchild=\"0\",type=\"struct _struct_decl \\*\\(\\*\\)\\((int, char \\*, long int|)\\)\"\},child=\{name=\"weird.u1\",exp=\"u1\",numchild=\"4\",type=\"union \{\\.\\.\\.\}\"\},child=\{name=\"weird.s2\",exp=\"s2\",numchild=\"4\",type=\"struct \{\\.\\.\\.\}\"\}\\\]" \ + "get children local variable weird" + + +# Test: c_variable-6.23 +# Desc: change format of weird.func_ptr and weird.func_ptr_ptr +mi_gdb_test "-var-set-format weird.func_ptr hexadecimal" \ + "\\^done,format=\"hexadecimal\"" \ + "set format variable weird.func_ptr" + +mi_gdb_test "-var-show-format weird.func_ptr" \ + "\\^done,format=\"hexadecimal\"" \ + "show format variable weird.func_ptr" + +mi_gdb_test "-var-set-format weird.func_ptr_ptr hexadecimal" \ + "\\^done,format=\"hexadecimal\"" \ + "set format variable weird.func_ptr_ptr" + +mi_gdb_test "-var-show-format weird.func_ptr_ptr" \ + "\\^done,format=\"hexadecimal\"" \ + "show format variable weird.func_ptr_ptr" + +# Test: c_variable-6.24 +# Desc: format of weird and children +mi_gdb_test "-var-set-format weird natural" \ + "\\^done,format=\"natural\"" \ + "set format variable weird" + +mi_gdb_test "-var-set-format weird.integer natural" \ + "\\^done,format=\"natural\"" \ + "set format variable weird.integer" + +mi_gdb_test "-var-set-format weird.character natural" \ + "\\^done,format=\"natural\"" \ + "set format variable weird.character" + +mi_gdb_test "-var-set-format weird.char_ptr natural" \ + "\\^done,format=\"natural\"" \ + "set format variable weird.char_ptr" + +mi_gdb_test "-var-set-format weird.long_int natural" \ + "\\^done,format=\"natural\"" \ + "set format variable weird.long_int" + +mi_gdb_test "-var-set-format weird.int_ptr_ptr natural" \ + "\\^done,format=\"natural\"" \ + "set format variable weird.int_ptr_ptr" + +mi_gdb_test "-var-set-format weird.long_array natural" \ + "\\^done,format=\"natural\"" \ + "set format variable weird.long_array" + +mi_gdb_test "-var-set-format weird.func_ptr hexadecimal" \ + "\\^done,format=\"hexadecimal\"" \ + "set format variable weird.func_ptr" + +mi_gdb_test "-var-set-format weird.func_ptr_struct hexadecimal" \ + "\\^done,format=\"hexadecimal\"" \ + "set format variable weird.func_ptr_struct" + +mi_gdb_test "-var-set-format weird.func_ptr_ptr natural" \ + "\\^done,format=\"natural\"" \ + "set format variable weird.func_ptr_ptr" + +mi_gdb_test "-var-set-format weird.u1 natural" \ + "\\^done,format=\"natural\"" \ + "set format variable weird.u1" + +mi_gdb_test "-var-set-format weird.s2 natural" \ + "\\^done,format=\"natural\"" \ + "set format variable weird.s2" + +# Test: c_variable-6.25 +# Desc: value of weird and children +#gdbtk_test c_variable-6.25 {value of weird and children} { +# set values {} +# foreach v [lsort [array names var]] f [list x "" "" x x x x d d d d d] { +# lappend values [value $v $f] +# } + +# set values +#} {ok ok ok ok ok ok ok ok weird.long_array ok weird.s2 weird.u1} + +# Test: c_variable-6.26 +# Desc: change format of weird and children to octal +#gdbtk_test c_variable-6.26 {change format of weird and children to octal} { +# set formats {} +# foreach v [lsort [array names var]] { +# $var($v) format octal +# lappend formats [$var($v) format] +# } + +# set formats +#} {octal octal octal octal octal octal octal octal octal octal octal octal} + +# Test: c_variable-6.27 +# Desc: value of weird and children with new format +#gdbtk_test c_variable-6.27 {value of foo with new format} { +# set values {} +# foreach v [lsort [array names var]] { +# lappend values [value $v o] +# } + +# set values +#} {ok ok ok ok ok ok ok ok weird.long_array ok weird.s2 weird.u1} + +# Test: c_variable-6.30 +# Desc: create more children of weird +#gdbtk_test c_variable-6.30 {create more children of weird} { +# foreach v [array names var] { +# get_children $v +# } + +# # Do it twice to get more children +# foreach v [array names var] { +# get_children $v +# } + +# lsort [array names var] +#} {weird weird.char_ptr weird.character weird.func_ptr weird.func_ptr_ptr weird.func_ptr_struct weird.int_ptr_ptr weird.int_ptr_ptr.*int_ptr_ptr weird.int_ptr_ptr.*int_ptr_ptr.**int_ptr_ptr weird.integer weird.long_array weird.long_array.0 weird.long_array.1 weird.long_array.2 weird.long_array.3 weird.long_array.4 weird.long_array.5 weird.long_array.6 weird.long_array.7 weird.long_array.8 weird.long_array.9 weird.long_int weird.s2 weird.s2.g weird.s2.h weird.s2.i weird.s2.i.0 weird.s2.i.1 weird.s2.i.2 weird.s2.i.3 weird.s2.i.4 weird.s2.i.5 weird.s2.i.6 weird.s2.i.7 weird.s2.i.8 weird.s2.i.9 weird.s2.u2 weird.s2.u2.f weird.s2.u2.u1s1 weird.s2.u2.u1s2 weird.u1 weird.u1.a weird.u1.b weird.u1.c weird.u1.d} + +# Test: c_variable-6.31 +# Desc: check that all children of weird change +# Ok, obviously things like weird.s2 and weird.u1 will not change! +#gdbtk_test *c_variable-6.31 {check that all children of weird change (ops, we are now reporting array names as changed in this case - seems harmless though)} { +# $var(weird) value 0x2121 +# check_update +#} {{weird.integer weird.character weird.char_ptr weird.long_int weird.int_ptr_ptr weird.int_ptr_ptr.*int_ptr_ptr weird.int_ptr_ptr.*int_ptr_ptr.**int_ptr_ptr weird.long_array.0 weird.long_array.1 weird.long_array.2 weird.long_array.3 weird.long_array.4 weird.long_array.5 weird.long_array.6 weird.long_array.7 weird.long_array.8 weird.long_array.9 weird.func_ptr weird.func_ptr_struct weird.func_ptr_ptr weird.u1.a weird.u1.b weird.u1.c weird.u1.d weird.s2.u2.f weird.s2.g weird.s2.h weird.s2.i.0 weird.s2.i.1 weird.s2.i.2 weird.s2.i.3 weird.s2.i.4 weird.s2.i.5 weird.s2.i.6 weird.s2.i.7 weird.s2.i.8 weird.s2.i.9} {weird.s2.i weird.s2.u2 weird weird.s2.u2.u1s1 weird.s2.u2.u1s2 weird.s2 weird.long_array weird.u1} {}} + +mi_gdb_test "-var-delete weird" \ + "\\^done,ndeleted=\"12\"" \ + "delete var weird" + + +##### ##### +# # +# Special Display Tests # +# # +##### ##### + +# Stop in "do_special_tests" +mi_gdb_test "200-break-insert do_special_tests" \ + "200\\^done,bkpt=\{number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"do_special_tests\",file=\".*var-cmd.c\",line=\"282\",times=\"0\"\}" \ + "break-insert operation" + +send_gdb "-exec-continue\n" +gdb_expect { + -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"breakpoint-hit\",bkptno=\"2\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"do_special_tests\",args=\\\[\\\],file=\".*var-cmd.c\",line=\"282\"\}\r\n$mi_gdb_prompt$" { + pass "continue to do_special_tests" + } + timeout { + fail "continue to do_special_tests (timeout)" + } +} + +# Test: c_variable-7.10 +# Desc: create union u +mi_gdb_test "-var-create u * u" \ + "\\^done,name=\"u\",numchild=\"2\",type=\"union named_union\"" \ + "create local variable u" + +# Test: c_variable-7.11 +# Desc: value of u +mi_gdb_test "-var-evaluate-expression u" \ + "\\^done,value=\"\{\\.\\.\\.\}\"" \ + "eval variable u" + +# Test: c_variable-7.12 +# Desc: type of u +mi_gdb_test "-var-info-type u" \ + "\\^done,type=\"union named_union\"" \ + "info type variable u" + +# Test: c_variable-7.13 +# Desc: is u editable +mi_gdb_test "-var-show-attributes u" \ + "\\^done,attr=\"noneditable\"" \ + "is u editable" + +# Test: c_variable-7.14 +# Desc: number of children of u +mi_gdb_test "-var-info-num-children u" \ + "\\^done,numchild=\"2\"" \ + "get number of children of u" + +# Test: c_variable-7.15 +# Desc: children of u +mi_gdb_test "-var-list-children u" \ + "\\^done,numchild=\"2\",children=\\\[child=\{name=\"u.integer\",exp=\"integer\",numchild=\"0\",type=\"int\"\},child=\{name=\"u.char_ptr\",exp=\"char_ptr\",numchild=\"1\",type=\"char \\*\"\}\\\]" \ + "get children of u" + +# Test: c_variable-7.20 +# Desc: create anonu +mi_gdb_test "-var-create anonu * anonu" \ + "\\^done,name=\"anonu\",numchild=\"3\",type=\"union \{\\.\\.\\.\}\"" \ + "create local variable anonu" + +# Test: c_variable-7.21 +# Desc: value of anonu +mi_gdb_test "-var-evaluate-expression anonu" \ + "\\^done,value=\"\{\\.\\.\\.\}\"" \ + "eval variable anonu" + +# Test: c_variable-7.22 +# Desc: type of anonu +mi_gdb_test "-var-info-type anonu" \ + "\\^done,type=\"union \{\\.\\.\\.\}\"" \ + "info type variable anonu" + +# Test: c_variable-7.23 +# Desc: is anonu editable +mi_gdb_test "-var-show-attributes anonu" \ + "\\^done,attr=\"noneditable\"" \ + "is anonu editable" + +# Test: c_variable-7.24 +# Desc: number of children of anonu +mi_gdb_test "-var-info-num-children anonu" \ + "\\^done,numchild=\"3\"" \ + "get number of children of anonu" + +# Test: c_variable-7.25 +# Desc: children of anonu +mi_gdb_test "-var-list-children anonu" \ + "\\^done,numchild=\"3\",children=\\\[child=\{name=\"anonu.a\",exp=\"a\",numchild=\"0\",type=\"int\"\},child=\{name=\"anonu.b\",exp=\"b\",numchild=\"0\",type=\"char\"\},child=\{name=\"anonu.c\",exp=\"c\",numchild=\"0\",type=\"long int\"\}\\\]" \ + "get children of anonu" + +# Test: c_variable-7.30 +# Desc: create struct s +mi_gdb_test "-var-create s * s" \ + "\\^done,name=\"s\",numchild=\"6\",type=\"struct _simple_struct\"" \ + "create local variable s" + + +# Test: c_variable-7.31 +# Desc: value of s +mi_gdb_test "-var-evaluate-expression s" \ + "\\^done,value=\"\{\\.\\.\\.\}\"" \ + "eval variable s" + +# Test: c_variable-7.32 +# Desc: type of s +mi_gdb_test "-var-info-type s" \ + "\\^done,type=\"struct _simple_struct\"" \ + "info type variable s" + +# Test: c_variable-7.33 +# Desc: is s editable +mi_gdb_test "-var-show-attributes s" \ + "\\^done,attr=\"noneditable\"" \ + "is s editable" + +# Test: c_variable-7.34 +# Desc: number of children of s +mi_gdb_test "-var-info-num-children s" \ + "\\^done,numchild=\"6\"" \ + "get number of children of s" + +# Test: c_variable-7.35 +# Desc: children of s +mi_gdb_test "-var-list-children s" \ + "\\^done,numchild=\"6\",children=\\\[child=\{name=\"s.integer\",exp=\"integer\",numchild=\"0\",type=\"int\"\},child=\{name=\"s.unsigned_integer\",exp=\"unsigned_integer\",numchild=\"0\",type=\"unsigned int\"\},child=\{name=\"s.character\",exp=\"character\",numchild=\"0\",type=\"char\"\},child=\{name=\"s.signed_character\",exp=\"signed_character\",numchild=\"0\",type=\"signed char\"\},child=\{name=\"s.char_ptr\",exp=\"char_ptr\",numchild=\"1\",type=\"char \\*\"\},child=\{name=\"s.array_of_10\",exp=\"array_of_10\",numchild=\"10\",type=\"int \\\[10\\\]\"\}\\\]" \ + "get children of s" +#} {integer unsigned_integer character signed_character char_ptr array_of_10} + +# Test: c_variable-7.40 +# Desc: create anons +mi_gdb_test "-var-create anons * anons" \ + "\\^done,name=\"anons\",numchild=\"3\",type=\"struct \{\\.\\.\\.\}\"" \ + "create local variable anons" + +# Test: c_variable-7.41 +# Desc: value of anons +mi_gdb_test "-var-evaluate-expression anons" \ + "\\^done,value=\"\{\\.\\.\\.\}\"" \ + "eval variable anons" + +# Test: c_variable-7.42 +# Desc: type of anons +mi_gdb_test "-var-info-type anons" \ + "\\^done,type=\"struct \{\\.\\.\\.\}\"" \ + "info type variable anons" + +# Test: c_variable-7.43 +# Desc: is anons editable +mi_gdb_test "-var-show-attributes anons" \ + "\\^done,attr=\"noneditable\"" \ + "is anons editable" + +# Test: c_variable-7.44 +# Desc: number of children of anons +mi_gdb_test "-var-info-num-children anons" \ + "\\^done,numchild=\"3\"" \ + "get number of children of anons" + +# Test: c_variable-7.45 +# Desc: children of anons +mi_gdb_test "-var-list-children anons" \ + "\\^done,numchild=\"3\",children=\\\[child=\{name=\"anons.a\",exp=\"a\",numchild=\"0\",type=\"int\"\},child=\{name=\"anons.b\",exp=\"b\",numchild=\"0\",type=\"char\"\},child=\{name=\"anons.c\",exp=\"c\",numchild=\"0\",type=\"long int\"\}\\\]" \ + "get children of anons" + + +# Test: c_variable-7.50 +# Desc: create enum e +mi_gdb_test "-var-create e * e" \ + "\\^done,name=\"e\",numchild=\"0\",type=\"enum foo\"" \ + "create local variable e" + +setup_xfail "*-*-*" +# Test: c_variable-7.51 +# Desc: value of e +mi_gdb_test "-var-evaluate-expression e" \ + "\\^done,value=\"FIXME\"" \ + "eval variable e" +clear_xfail "*-*-*" + +# Test: c_variable-7.52 +# Desc: type of e +mi_gdb_test "-var-info-type e" \ + "\\^done,type=\"enum foo\"" \ + "info type variable e" + +# Test: c_variable-7.53 +# Desc: is e editable +mi_gdb_test "-var-show-attributes e" \ + "\\^done,attr=\"editable\"" \ + "is e editable" + +# Test: c_variable-7.54 +# Desc: number of children of e +mi_gdb_test "-var-info-num-children e" \ + "\\^done,numchild=\"0\"" \ + "get number of children of e" + +# Test: c_variable-7.55 +# Desc: children of e +mi_gdb_test "-var-list-children e" \ + "\\^done,numchild=\"0\"" \ + "get children of e" + +# Test: c_variable-7.60 +# Desc: create anone +mi_gdb_test "-var-create anone * anone" \ + "\\^done,name=\"anone\",numchild=\"0\",type=\"enum \{\\.\\.\\.\}\"" \ + "create local variable anone" + +setup_xfail "*-*-*" +# Test: c_variable-7.61 +# Desc: value of anone +mi_gdb_test "-var-evaluate-expression anone" \ + "\\^done,value=\"A\"" \ + "eval variable anone" +clear_xfail "*-*-*" + + +# Test: c_variable-7.70 +# Desc: create anone +mi_gdb_test "-var-create anone * anone" \ + "&\"Duplicate variable object name\\\\n\".*\\^error,msg=\"Duplicate variable object name\"" \ + "create duplicate local variable anone" + + +# Test: c_variable-7.72 +# Desc: type of anone +mi_gdb_test "-var-info-type anone" \ + "\\^done,type=\"enum \{\\.\\.\\.\}\"" \ + "info type variable anone" + + +# Test: c_variable-7.73 +# Desc: is anone editable +mi_gdb_test "-var-show-attributes anone" \ + "\\^done,attr=\"editable\"" \ + "is anone editable" + +# Test: c_variable-7.74 +# Desc: number of children of anone +mi_gdb_test "-var-info-num-children anone" \ + "\\^done,numchild=\"0\"" \ + "get number of children of anone" + +# Test: c_variable-7.75 +# Desc: children of anone +mi_gdb_test "-var-list-children anone" \ + "\\^done,numchild=\"0\"" \ + "get children of anone" + + +# Record fp + +send_gdb "p/x \$fp\n" +gdb_expect { + -re ".*($hex).*\\^done\r\n$mi_gdb_prompt$" { + pass "print FP register" + set fp $expect_out(1,string) + } +# -re ".*" { fail "print FP register"} + timeout { fail "print FP register (timeout)"} +} + +mi_gdb_test "200-break-insert incr_a" \ + "200\\^done,bkpt=\{number=\"3\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"incr_a\",file=\".*var-cmd.c\",line=\"85\",times=\"0\"\}" \ + "break-insert operation" +send_gdb "-exec-continue\n" +gdb_expect { + -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"breakpoint-hit\",bkptno=\"3\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"incr_a\",args=\\\[\{name=\"a\",value=\"2\.*\"\}\\\],file=\".*var-cmd.c\",line=\"85\"\}\r\n$mi_gdb_prompt$" { + pass "continue to incr_a" + } + -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"breakpoint-hit\",bkptno=\"3\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"incr_a\",args=\\\[\{name=\"a\",value=\"\.*\"\}\\\],file=\".*var-cmd.c\",line=\"8\[345\]\"\}\r\n$mi_gdb_prompt$" { + fail "continue to incr_a (compiler debug info incorrect)" + } + -re "\\^running\r\n${mi_gdb_prompt}.*\r\n$mi_gdb_prompt$" { + fail "continue to incr_a (unknown output)" + } + timeout { + fail "continue to incr_a (timeout)" + } +} + +# Test: c_variable-7.81 +# Desc: Create variables in different scopes +mi_gdb_test "-var-create a1 * a" \ + "\\^done,name=\"a1\",numchild=\"0\",type=\"char\"" \ + "create local variable a1" + +mi_gdb_test "-var-create a2 $fp a" \ + "\\^done,name=\"a2\",numchild=\"0\",type=\"int\"" \ + "create variable a2 in different scope" + +#gdbtk_test c_variable-7.81 {create variables in different scopes} { +# set a1 [gdb_variable create -expr a] +# set a2 [gdb_variable create -expr a -frame $fp] + +# set vals {} +# lappend vals [$a1 value] +# lappend vals [$a2 value] +# set vals +#} {2 1} + + +mi_gdb_exit +return 0 diff --git a/gdb/testsuite/gdb.mi/mi2-watch.exp b/gdb/testsuite/gdb.mi/mi2-watch.exp new file mode 100644 index 0000000..ba7df2b --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi2-watch.exp @@ -0,0 +1,166 @@ +# Copyright 1999, 2000, 2002 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# +# Test essential Machine interface (MI) operations +# +# Verify that, using the MI, we can run a simple program and perform basic +# debugging activities like: insert breakpoints, run the program, +# step, next, continue until it ends and, last but not least, quit. +# +# The goal is not to test gdb functionality, which is done by other tests, +# but to verify the correct output response to MI operations. +# + +load_lib mi-support.exp +set MIFLAGS "-i=mi2" + +gdb_exit +if [mi_gdb_start] { + continue +} + +set testfile "basics" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +proc test_watchpoint_creation_and_listing {} { + global mi_gdb_prompt + global srcfile + global hex + + # Insert a watchpoint and list + # Tests: + # -break-watch C + # -break-list + + mi_gdb_test "111-break-watch C" \ + "111\\^done,wpt=\{number=\"2\",exp=\"C\"\}" \ + "break-watch operation" + + mi_gdb_test "222-break-list" \ + "222\\\^done,BreakpointTable=\{nr_rows=\".\",nr_cols=\".\",hdr=\\\[\{width=\".*\",alignment=\".*\",col_name=\"number\",colhdr=\"Num\"\}.*colhdr=\"Type\".*colhdr=\"Disp\".*colhdr=\"Enb\".*colhdr=\"Address\".*colhdr=\"What\".*\\\],body=\\\[bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"callee4\",file=\".*basics.c\",line=\"8\",times=\"1\"\},bkpt=\{number=\"2\",type=\".*watchpoint\",disp=\"keep\",enabled=\"y\",addr=\"\",what=\"C\",times=\"0\"\}\\\]\}" \ + "list of watchpoints" + +} + +# UNUSED at the time +proc test_awatch_creation_and_listing {} { + global mi_gdb_prompt + global srcfile + global hex + + # Insert an access watchpoint and list it + # Tests: + # -break-watch -a A + # -break-list + + mi_gdb_test "333-break-watch -a A" \ + "333\\^done,bkpt=\{number=\"1\",addr=\"$hex\",file=\".*basics.c\",line=\"32\"\}" \ + "break-watch -a operation" + + mi_gdb_test "444-break-list" \ + "444\\^done,BreakpointTable=\{.*,hdr=\\\[.*\\\],body=\\\[bkpt=\{number=\"3\",type=\"watchpoint\",disp=\"del\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*basics.c\",line=\"32\",times=\"0\"\},.*\}\\\]\}" \ + "list of watchpoints awatch" + + mi_gdb_test "777-break-delete 3" \ + "777\\^done" \ + "delete access watchpoint" +} + +# UNUSED at the time +proc test_rwatch_creation_and_listing {} { + global mi_gdb_prompt + global srcfile + global hex + + # Insert a read watchpoint and list it. + # Tests: + # -break-insert -r B + # -break-list + + mi_gdb_test "200-break-watch -r C" \ + "200\\^done,bkpt=\{number=\"5\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"callee4\",file=\".*basics.c\",line=\"32\",times=\"0\"\}" \ + "break-insert -r operation" + + mi_gdb_test "300-break-list" \ + "300\\^done,BreakpointTable=\{.*,hdr=\\\[.*\\\],body=\\\[bkpt=\{number=\"5\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*basics.c\",line=\"32\",times=\"0\"\},.*\}\\\}\}" \ + "list of breakpoints" + + mi_gdb_test "177-break-delete 4" \ + "177\\^done" \ + "delete read watchpoint" +} + +proc test_watchpoint_triggering {} { + global mi_gdb_prompt + global hex + + # Continue execution until the watchpoint is reached, continue again, + # to see the watchpoint go out of scope. + # Does: + # -exec-continue (Here wp triggers) + # -exec-continue (Here wp goes out of scope) + + send_gdb "222-exec-continue\n" + gdb_expect { + -re "222\\^running\r\n$mi_gdb_prompt" { + gdb_expect { + -re "222\\*stopped,reason=\"watchpoint-trigger\",wpt=\{number=\"2\",exp=\"C\"\},value=\{old=\".*\",new=\"3\"\},thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"callee4\",args=\\\[\\\],file=\".*basics.c\",line=\"13\"\}\r\n$mi_gdb_prompt$" { + pass "watchpoint trigger" + } + -re ".*$mi_gdb_prompt$" {fail "watchpoint trigger (2)"} + timeout {fail "watchpoint trigger (timeout 2)"} + } + } + -re ".*$mi_gdb_prompt$" {fail "watchpoint trigger (1)"} + timeout {fail "watchpoint trigger (timeout 1)"} + } + + send_gdb "223-exec-continue\n" + gdb_expect { + -re "223\\^running\r\n$mi_gdb_prompt" { + gdb_expect { + -re "\[\r\n\]*223\\*stopped,reason=\"watchpoint-scope\",wpnum=\"2\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"callee3\",args=\\\[.*\\\],file=\".*basics.c\",line=\"18\"\}\r\n$mi_gdb_prompt$" { + pass "wp out of scope" + } + -re ".*$mi_gdb_prompt$" {fail "wp out of scope (2)"} + timeout {fail "wp out of scope (timeout 2)"} + } + } + -re ".*$mi_gdb_prompt$" {fail "wp out of scope (1)"} + timeout {fail "wp out of scope (timeout 1)"} + } +} + +mi_runto callee4 +test_watchpoint_creation_and_listing +#test_rwatch_creation_and_listing +#test_awatch_creation_and_listing +test_watchpoint_triggering + +mi_gdb_exit +return 0 |