old-cross-binutils/gdb/testsuite/gdb.base/structs.c

458 lines
9.7 KiB
C
Raw Normal View History

/* This testcase is part of GDB, the GNU debugger.
Copyright 1996, 1999, 2003, 2007-2012 Free Software Foundation, Inc.
1999-06-28 23:04:32 +00:00
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
1999-06-28 23:04:32 +00:00
(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.
1999-06-28 23:04:32 +00:00
You should have received a copy of the GNU General Public License
Fix for PR gdb/1543. * gdb.base/sep.exp: `sep-proc.c' absolute line numbers replaced with $LOCATION. (location): New variable. * config/cfdbug.exp, config/d10v.exp, config/dve.exp, config/i960.exp, config/m32r.exp, config/mn10300-eval.exp, config/proelf.exp, config/rom68k.exp, config/sh.exp, config/unix.exp, config/vr4300.exp, config/vr5000.exp, config/vxworks.exp, gdb.arch/altivec-regs.exp, gdb.arch/e500-abi.exp, gdb.arch/e500-regs.exp, gdb.asm/asm-source.exp, gdb.base/a2-run.exp, gdb.base/advance.exp, gdb.base/all-bin.exp, gdb.base/args.exp, gdb.base/arithmet.exp, gdb.base/assign.exp, gdb.base/async.exp, gdb.base/auxv.exp, gdb.base/bigcore.c, gdb.base/bigcore.exp, gdb.base/bitfields.exp, gdb.base/bitops.exp, gdb.base/break.c, gdb.base/break.exp, gdb.base/break1.c, gdb.base/call-ar-st.exp, gdb.base/call-rt-st.exp, gdb.base/call-strs.exp, gdb.base/callfuncs.c, gdb.base/callfuncs.exp, gdb.base/checkpoint.exp, gdb.base/chng-syms.exp, gdb.base/code-expr.exp, gdb.base/commands.exp, gdb.base/completion.exp, gdb.base/complex.exp, gdb.base/cond-expr.exp, gdb.base/condbreak.exp, gdb.base/consecutive.exp, gdb.base/corefile.exp, gdb.base/cvexpr.c, gdb.base/cvexpr.exp, gdb.base/dbx.exp, gdb.base/default.exp, gdb.base/define.exp, gdb.base/del.c, gdb.base/detach.exp, gdb.base/display.exp, gdb.base/dump.exp, gdb.base/echo.exp, gdb.base/environ.exp, gdb.base/eval-skip.exp, gdb.base/exprs.exp, gdb.base/fileio.exp, gdb.base/find.exp, gdb.base/finish.exp, gdb.base/funcargs.exp, gdb.base/gcore-buffer-overflow.exp, gdb.base/gcore.exp, gdb.base/gdb1555.exp, gdb.base/gdbvars.exp, gdb.base/help.exp, gdb.base/huge.exp, gdb.base/info-proc.exp, gdb.base/interrupt.exp, gdb.base/jump.exp, gdb.base/langs.exp, gdb.base/lineinc.exp, gdb.base/list.exp, gdb.base/macscp.exp, gdb.base/maint.exp, gdb.base/mips_pro.exp, gdb.base/miscexprs.exp, gdb.base/nodebug.exp, gdb.base/nofield.c, gdb.base/opaque.exp, gdb.base/overlays.exp, gdb.base/page.exp, gdb.base/pc-fp.exp, gdb.base/pending.c, gdb.base/pendshr.c, gdb.base/pointers.exp, gdb.base/psymtab.exp, gdb.base/ptype.exp, gdb.base/randomize.c, gdb.base/readline.exp, gdb.base/recurse.exp, gdb.base/regs.exp, gdb.base/relational.exp, gdb.base/relocate.exp, gdb.base/remote.exp, gdb.base/reread.exp, gdb.base/return.exp, gdb.base/return2.exp, gdb.base/scope.exp, gdb.base/sect-cmd.exp, gdb.base/sep-proc.c, gdb.base/sep.c, gdb.base/sep.exp, gdb.base/sepdebug.c, gdb.base/sepdebug.exp, gdb.base/setshow.exp, gdb.base/shlib-call.exp, gdb.base/sigaltstack.c, gdb.base/so-indr-cl.exp, gdb.base/solib.exp, gdb.base/source.exp, gdb.base/start.c, gdb.base/step-bt.c, gdb.base/step-line.exp, gdb.base/structs.c, gdb.base/structs.exp, gdb.base/structs2.exp, gdb.base/term.exp, gdb.base/twice.exp, gdb.base/type-opaque.exp, gdb.base/until.exp, gdb.base/value-double-free.c, gdb.base/varargs.exp, gdb.base/watchpoint.exp, gdb.base/whatis-exp.exp, gdb.disasm/am33.exp, gdb.disasm/h8300s.exp, gdb.disasm/hppa.exp, gdb.disasm/mn10300.exp, gdb.disasm/sh3.exp, gdb.disasm/t01_mov.exp, gdb.disasm/t02_mova.exp, gdb.disasm/t03_add.exp, gdb.disasm/t04_sub.exp, gdb.disasm/t05_cmp.exp, gdb.disasm/t06_ari2.exp, gdb.disasm/t07_ari3.exp, gdb.disasm/t08_or.exp, gdb.disasm/t09_xor.exp, gdb.disasm/t10_and.exp, gdb.disasm/t11_logs.exp, gdb.disasm/t12_bit.exp, gdb.disasm/t13_otr.exp, gdb.fortran/exprs.exp, gdb.fortran/types.exp, gdb.hp/gdb.aCC/exception.exp, gdb.hp/gdb.aCC/optimize.exp, gdb.hp/gdb.aCC/watch-cmd.exp, gdb.hp/gdb.base-hp/callfwmall.exp, gdb.hp/gdb.base-hp/dollar.exp, gdb.hp/gdb.base-hp/hwwatchbus.exp, gdb.hp/gdb.base-hp/pxdb.exp, gdb.hp/gdb.base-hp/reg-pa64.exp, gdb.hp/gdb.base-hp/reg.exp, gdb.hp/gdb.base-hp/sized-enum.exp, gdb.hp/gdb.base-hp/so-thresh.exp, gdb.hp/gdb.compat/xdb1.exp, gdb.hp/gdb.compat/xdb2.exp, gdb.hp/gdb.compat/xdb3.exp, gdb.java/jmisc.exp, gdb.java/jv-exp.exp, gdb.java/jv-print.exp, gdb.mi/gdb669.exp, gdb.mi/gdb680.exp, gdb.mi/gdb701.exp, gdb.mi/gdb792.exp, gdb.mi/mi-basics.exp, gdb.mi/mi-console.exp, gdb.mi/mi-hack-cli.exp, gdb.mi/mi-pending.c, gdb.mi/mi-pendshr.c, gdb.mi/mi-pthreads.exp, gdb.mi/mi-read-memory.exp, gdb.mi/mi-regs.exp, gdb.mi/mi-syn-frame.exp, gdb.mi/mi-until.exp, gdb.mi/mi2-basics.exp, gdb.mi/mi2-console.exp, gdb.mi/mi2-hack-cli.exp, gdb.mi/mi2-pthreads.exp, gdb.mi/mi2-read-memory.exp, gdb.mi/mi2-regs.exp, gdb.mi/mi2-syn-frame.exp, gdb.mi/mi2-until.exp, gdb.pascal/types.exp, gdb.stabs/weird.exp, gdb.threads/gcore-thread.exp, gdb.threads/manythreads.exp, gdb.threads/print-threads.exp, gdb.threads/pthreads.exp, gdb.threads/schedlock.exp, gdb.threads/step.exp, gdb.threads/step2.exp, gdb.threads/switch-threads.exp, gdb.threads/thread-specific.exp, gdb.threads/thread_check.exp, gdb.threads/thread_events.exp, gdb.threads/tls-nodebug.exp, gdb.threads/tls-shared.exp, gdb.threads/tls.exp, gdb.trace/actions.exp, gdb.trace/backtrace.exp, gdb.trace/circ.exp, gdb.trace/collection.exp, gdb.trace/deltrace.exp, gdb.trace/infotrace.exp, gdb.trace/limits.exp, gdb.trace/packetlen.exp, gdb.trace/passc-dyn.exp, gdb.trace/passcount.exp, gdb.trace/report.exp, gdb.trace/save-trace.exp, gdb.trace/tfind.exp, gdb.trace/tracecmd.exp, gdb.trace/while-dyn.exp, gdb.trace/while-stepping.exp, lib/mi-support.exp, lib/trace-support.exp: Remove reference to bug-gdb@prep.ai.mit.edu .
2008-08-06 12:52:08 +00:00
along with this program. If not, see <http://www.gnu.org/licenses/>. */
1999-06-28 23:04:32 +00:00
/* Useful abreviations. */
typedef void t;
typedef char tc;
typedef short ts;
typedef int ti;
typedef long tl;
typedef long long tll;
typedef float tf;
typedef double td;
typedef long double tld;
/* Force the type of each field. */
#ifndef tA
typedef t tA;
#endif
#ifndef tB
typedef tA tB;
#endif
#ifndef tC
typedef tB tC;
#endif
#ifndef tD
typedef tC tD;
#endif
#ifndef tE
typedef tD tE;
#endif
#ifndef tF
typedef tE tF;
#endif
#ifndef tG
typedef tF tG;
#endif
#ifndef tH
typedef tG tH;
#endif
#ifndef tI
typedef tH tI;
#endif
#ifndef tJ
typedef tI tJ;
#endif
#ifndef tK
typedef tJ tK;
#endif
#ifndef tL
typedef tK tL;
#endif
#ifndef tM
typedef tL tM;
#endif
#ifndef tN
typedef tM tN;
#endif
#ifndef tO
typedef tN tO;
#endif
#ifndef tP
typedef tO tP;
#endif
#ifndef tQ
typedef tP tQ;
#endif
#ifndef tR
typedef tQ tR;
#endif
struct struct1 {tA a;};
struct struct2 {tA a; tB b;};
struct struct3 {tA a; tB b; tC c; };
struct struct4 {tA a; tB b; tC c; tD d; };
struct struct5 {tA a; tB b; tC c; tD d; tE e; };
struct struct6 {tA a; tB b; tC c; tD d; tE e; tF f; };
struct struct7 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; };
struct struct8 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; };
struct struct9 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; };
struct struct10 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; tJ j; };
struct struct11 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; };
struct struct12 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; tL l; };
struct struct13 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; tL l; tM m; };
struct struct14 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; tL l; tM m; tN n; };
struct struct15 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; tL l; tM m; tN n; tO o; };
struct struct16 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; tL l; tM m; tN n; tO o; tP p; };
struct struct17 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; tL l; tM m; tN n; tO o; tP p; tQ q; };
struct struct18 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; tL l; tM m; tN n; tO o; tP p; tQ q; tR r; };
struct struct1 foo1 = {'1'}, L1;
struct struct2 foo2 = {'a','2'}, L2;
struct struct3 foo3 = {'1','b','3'}, L3;
struct struct4 foo4 = {'a','2','c','4'}, L4;
struct struct5 foo5 = {'1','b','3','d','5'}, L5;
struct struct6 foo6 = {'a','2','c','4','e','6'}, L6;
struct struct7 foo7 = {'1','b','3','d','5','f','7'}, L7;
struct struct8 foo8 = {'a','2','c','4','e','6','g','8'}, L8;
struct struct9 foo9 = {'1','b','3','d','5','f','7','h','9'}, L9;
struct struct10 foo10 = {'a','2','c','4','e','6','g','8','i','A'}, L10;
struct struct11 foo11 = {'1','b','3','d','5','f','7','h','9','j','B'}, L11;
struct struct12 foo12 = {'a','2','c','4','e','6','g','8','i','A','k','C'}, L12;
struct struct13 foo13 = {'1','b','3','d','5','f','7','h','9','j','B','l','D'}, L13;
struct struct14 foo14 = {'a','2','c','4','e','6','g','8','i','A','k','C','m','E'}, L14;
struct struct15 foo15 = {'1','b','3','d','5','f','7','h','9','j','B','l','D','n','F'}, L15;
struct struct16 foo16 = {'a','2','c','4','e','6','g','8','i','A','k','C','m','E','o','G'}, L16;
struct struct17 foo17 = {'1','b','3','d','5','f','7','h','9','j','B','l','D','n','F','p','H'}, L17;
struct struct18 foo18 = {'a','2','c','4','e','6','g','8','i','A','k','C','m','E','o','G','q','I'}, L18;
1999-06-28 23:04:32 +00:00
struct struct1 fun1()
{
return foo1;
}
struct struct2 fun2()
{
return foo2;
}
struct struct3 fun3()
{
return foo3;
}
struct struct4 fun4()
{
return foo4;
}
struct struct5 fun5()
{
return foo5;
}
struct struct6 fun6()
{
return foo6;
}
struct struct7 fun7()
{
return foo7;
}
struct struct8 fun8()
{
return foo8;
}
struct struct9 fun9()
{
return foo9;
}
struct struct10 fun10()
{
return foo10;
}
struct struct11 fun11()
{
return foo11;
}
struct struct12 fun12()
{
return foo12;
}
struct struct13 fun13()
{
return foo13;
}
struct struct14 fun14()
{
return foo14;
}
struct struct15 fun15()
{
return foo15;
}
1999-06-28 23:04:32 +00:00
struct struct16 fun16()
{
return foo16;
}
struct struct17 fun17()
{
return foo17;
}
struct struct18 fun18()
{
return foo18;
}
1999-06-28 23:04:32 +00:00
1999-08-02 23:48:37 +00:00
#ifdef PROTOTYPES
void Fun1(struct struct1 foo1)
#else
1999-06-28 23:04:32 +00:00
void Fun1(foo1)
struct struct1 foo1;
1999-08-02 23:48:37 +00:00
#endif
1999-06-28 23:04:32 +00:00
{
L1 = foo1;
}
1999-08-02 23:48:37 +00:00
#ifdef PROTOTYPES
void Fun2(struct struct2 foo2)
#else
1999-06-28 23:04:32 +00:00
void Fun2(foo2)
struct struct2 foo2;
1999-08-02 23:48:37 +00:00
#endif
1999-06-28 23:04:32 +00:00
{
L2 = foo2;
}
1999-08-02 23:48:37 +00:00
#ifdef PROTOTYPES
void Fun3(struct struct3 foo3)
#else
1999-06-28 23:04:32 +00:00
void Fun3(foo3)
struct struct3 foo3;
1999-08-02 23:48:37 +00:00
#endif
1999-06-28 23:04:32 +00:00
{
L3 = foo3;
}
1999-08-02 23:48:37 +00:00
#ifdef PROTOTYPES
void Fun4(struct struct4 foo4)
#else
1999-06-28 23:04:32 +00:00
void Fun4(foo4)
struct struct4 foo4;
1999-08-02 23:48:37 +00:00
#endif
1999-06-28 23:04:32 +00:00
{
L4 = foo4;
}
1999-08-02 23:48:37 +00:00
#ifdef PROTOTYPES
void Fun5(struct struct5 foo5)
#else
1999-06-28 23:04:32 +00:00
void Fun5(foo5)
struct struct5 foo5;
1999-08-02 23:48:37 +00:00
#endif
1999-06-28 23:04:32 +00:00
{
L5 = foo5;
}
1999-08-02 23:48:37 +00:00
#ifdef PROTOTYPES
void Fun6(struct struct6 foo6)
#else
1999-06-28 23:04:32 +00:00
void Fun6(foo6)
struct struct6 foo6;
1999-08-02 23:48:37 +00:00
#endif
1999-06-28 23:04:32 +00:00
{
L6 = foo6;
}
1999-08-02 23:48:37 +00:00
#ifdef PROTOTYPES
void Fun7(struct struct7 foo7)
#else
1999-06-28 23:04:32 +00:00
void Fun7(foo7)
struct struct7 foo7;
1999-08-02 23:48:37 +00:00
#endif
1999-06-28 23:04:32 +00:00
{
L7 = foo7;
}
1999-08-02 23:48:37 +00:00
#ifdef PROTOTYPES
void Fun8(struct struct8 foo8)
#else
1999-06-28 23:04:32 +00:00
void Fun8(foo8)
struct struct8 foo8;
1999-08-02 23:48:37 +00:00
#endif
1999-06-28 23:04:32 +00:00
{
L8 = foo8;
}
1999-08-02 23:48:37 +00:00
#ifdef PROTOTYPES
void Fun9(struct struct9 foo9)
#else
1999-06-28 23:04:32 +00:00
void Fun9(foo9)
struct struct9 foo9;
1999-08-02 23:48:37 +00:00
#endif
1999-06-28 23:04:32 +00:00
{
L9 = foo9;
}
1999-08-02 23:48:37 +00:00
#ifdef PROTOTYPES
void Fun10(struct struct10 foo10)
#else
1999-06-28 23:04:32 +00:00
void Fun10(foo10)
struct struct10 foo10;
1999-08-02 23:48:37 +00:00
#endif
1999-06-28 23:04:32 +00:00
{
L10 = foo10;
}
1999-08-02 23:48:37 +00:00
#ifdef PROTOTYPES
void Fun11(struct struct11 foo11)
#else
1999-06-28 23:04:32 +00:00
void Fun11(foo11)
struct struct11 foo11;
1999-08-02 23:48:37 +00:00
#endif
1999-06-28 23:04:32 +00:00
{
L11 = foo11;
}
1999-08-02 23:48:37 +00:00
#ifdef PROTOTYPES
void Fun12(struct struct12 foo12)
#else
1999-06-28 23:04:32 +00:00
void Fun12(foo12)
struct struct12 foo12;
1999-08-02 23:48:37 +00:00
#endif
1999-06-28 23:04:32 +00:00
{
L12 = foo12;
}
1999-08-02 23:48:37 +00:00
#ifdef PROTOTYPES
void Fun13(struct struct13 foo13)
#else
void Fun13(foo13)
struct struct13 foo13;
#endif
{
L13 = foo13;
}
#ifdef PROTOTYPES
void Fun14(struct struct14 foo14)
#else
void Fun14(foo14)
struct struct14 foo14;
#endif
{
L14 = foo14;
}
#ifdef PROTOTYPES
void Fun15(struct struct15 foo15)
#else
void Fun15(foo15)
struct struct15 foo15;
#endif
{
L15 = foo15;
}
#ifdef PROTOTYPES
1999-08-02 23:48:37 +00:00
void Fun16(struct struct16 foo16)
#else
1999-06-28 23:04:32 +00:00
void Fun16(foo16)
struct struct16 foo16;
1999-08-02 23:48:37 +00:00
#endif
1999-06-28 23:04:32 +00:00
{
L16 = foo16;
}
#ifdef PROTOTYPES
void Fun17(struct struct17 foo17)
#else
void Fun17(foo17)
struct struct17 foo17;
#endif
{
L17 = foo17;
}
#ifdef PROTOTYPES
void Fun18(struct struct18 foo18)
#else
void Fun18(foo18)
struct struct18 foo18;
#endif
{
L18 = foo18;
}
zed ()
{
L1.a = L2.a = L3.a = L4.a = L5.a = L6.a = L7.a = L8.a = L9.a = L10.a = L11.a = L12.a = L13.a = L14.a = L15.a = L16.a = L17.a = L18.a = 'Z';
L2.b = L3.b = L4.b = L5.b = L6.b = L7.b = L8.b = L9.b = L10.b = L11.b = L12.b = L13.b = L14.b = L15.b = L16.b = L17.b = L18.b = 'Z';
L3.c = L4.c = L5.c = L6.c = L7.c = L8.c = L9.c = L10.c = L11.c = L12.c = L13.c = L14.c = L15.c = L16.c = L17.c = L18.c = 'Z';
L4.d = L5.d = L6.d = L7.d = L8.d = L9.d = L10.d = L11.d = L12.d = L13.d = L14.d = L15.d = L16.d = L17.d = L18.d = 'Z';
L5.e = L6.e = L7.e = L8.e = L9.e = L10.e = L11.e = L12.e = L13.e = L14.e = L15.e = L16.e = L17.e = L18.e = 'Z';
L6.f = L7.f = L8.f = L9.f = L10.f = L11.f = L12.f = L13.f = L14.f = L15.f = L16.f = L17.f = L18.f = 'Z';
L7.g = L8.g = L9.g = L10.g = L11.g = L12.g = L13.g = L14.g = L15.g = L16.g = L17.g = L18.g = 'Z';
L8.h = L9.h = L10.h = L11.h = L12.h = L13.h = L14.h = L15.h = L16.h = L17.h = L18.h = 'Z';
L9.i = L10.i = L11.i = L12.i = L13.i = L14.i = L15.i = L16.i = L17.i = L18.i = 'Z';
L10.j = L11.j = L12.j = L13.j = L14.j = L15.j = L16.j = L17.j = L18.j = 'Z';
L11.k = L12.k = L13.k = L14.k = L15.k = L16.k = L17.k = L18.k = 'Z';
L12.l = L13.l = L14.l = L15.l = L16.l = L17.l = L18.l = 'Z';
L13.m = L14.m = L15.m = L16.m = L17.m = L18.m = 'Z';
L14.n = L15.n = L16.n = L17.n = L18.n = 'Z';
L15.o = L16.o = L17.o = L18.o = 'Z';
L16.p = L17.p = L18.p = 'Z';
L17.q = L18.q = 'Z';
L18.r = 'Z';
}
1999-06-28 23:04:32 +00:00
static struct { char c; } chartest[256];
1999-06-28 23:04:32 +00:00
int main()
{
int i;
1999-06-28 23:04:32 +00:00
for (i = 0; i < 256; i++)
chartest[i].c = i;
chartest[0].c = 0; /* chartest-done */
1999-06-28 23:04:32 +00:00
Fun1(foo1);
Fun2(foo2);
Fun3(foo3);
Fun4(foo4);
Fun5(foo5);
Fun6(foo6);
Fun7(foo7);
Fun8(foo8);
Fun9(foo9);
Fun10(foo10);
Fun11(foo11);
Fun12(foo12);
Fun13(foo13);
Fun14(foo14);
Fun15(foo15);
1999-06-28 23:04:32 +00:00
Fun16(foo16);
Fun17(foo17);
Fun18(foo18);
/* An infinite loop that first clears all the variables and then
calls each function. This "hack" is to make testing random
functions easier - "advance funN" is guaranteed to have always
been preceded by a global variable clearing zed call. */
while (1)
{
zed ();
L1 = fun1();
L2 = fun2();
L3 = fun3();
L4 = fun4();
L5 = fun5();
L6 = fun6();
L7 = fun7();
L8 = fun8();
L9 = fun9();
L10 = fun10();
L11 = fun11();
L12 = fun12();
L13 = fun13();
L14 = fun14();
L15 = fun15();
L16 = fun16();
L17 = fun17();
L18 = fun18();
}
1999-06-28 23:04:32 +00:00
return 0;
}