new files -- part of HP merge.

This commit is contained in:
David Taylor 1999-01-08 23:40:55 +00:00
parent e2fb40b3b6
commit 7e745333bb
6 changed files with 2272 additions and 10 deletions

View File

@ -42,9 +42,13 @@ break.exp
callfuncs.c
callfuncs.exp
callfuncs2.c
call-array-struct.c
call-return-struct.c
call-strings.c
callfuncs2.exp
call-ar-st.c
call-ar-st.exp
call-rt-st.c
call-rt-st.exp
call-strs.c
call-strs.exp
commands.exp
compiler.c
completion.exp
@ -54,6 +58,7 @@ condbreak.exp
configure
configure.in
constvars.c
constvars.exp
corefile.exp
coremaker.c
crossload.exp
@ -64,9 +69,10 @@ define.exp
display.c
dollar.exp
echo.exp
enable-disable-break.exp
ena-dis-br.exp
ending-run.c
environment.exp
ending-run.exp
environ.exp
eval-skip.exp
exprs.c
exprs.exp
@ -105,6 +111,7 @@ mips-ecoff.u
mips_pro.c
mips_pro.exp
miscexprs.c
miscexprs.exp
nodebug.c
nodebug.exp
opaque.exp
@ -138,12 +145,12 @@ run.c
scope.exp
scope0.c
scope1.c
section_command.exp
sect-cmd.exp
setshow.c
setshow.exp
setvar.c
setvar.exp
shlib-call2.exp
shlib-cl2.exp
shmain.c
shr1.c
shr2.c
@ -152,11 +159,15 @@ sigall.exp
signals.c
signals.exp
smoke.c
smoke.cc
smoke.exp
solib.c
solib1.c
solib2.c
solib_implicitly_loaded.c
solib_indirect_call.c
so-impl-ld.c
so-impl-ld.exp
so-indr-cl.c
so-indr-cl.exp
sparc-aout.u
sparc-elf.u
ss.h
@ -167,11 +178,13 @@ term.exp
twice.c
twice.exp
varargs.c
varargs.exp
volatile.exp
watchpoint.c
watchpoint.exp
whatis.c
whatis.exp
whatis-expr.exp
whatis-exp.exp
Things-to-lose:
structs.c

View File

@ -0,0 +1,530 @@
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
/**************************************************************************
* TESTS :
* function returning large structures, which go on the stack
* functions returning varied sized structs which go on in the registers.
***************************************************************************/
/* A large structure (> 64 bits) used to test passing large structures as
* parameters
*/
struct array_rep_info_t {
int next_index[10];
int values[10];
int head;
};
/*****************************************************************************
* Small structures ( <= 64 bits). These are used to test passing small
* structures as parameters and test argument size promotion.
*****************************************************************************/
/* 64 bits
*/
struct small_rep_info_t {
int value;
int head;
};
/* 6 bits : really fits in 8 bits and is promoted to 32 bits
*/
struct bit_flags_t {
unsigned alpha :1;
unsigned beta :1;
unsigned gamma :1;
unsigned delta :1;
unsigned epsilon :1;
unsigned omega :1;
};
/* 22 bits : really fits in 40 bits and is promoted to 64 bits
*/
struct bit_flags_combo_t {
unsigned alpha :1;
unsigned beta :1;
char ch1;
unsigned gamma :1;
unsigned delta :1;
char ch2;
unsigned epsilon :1;
unsigned omega :1;
};
/* 64 bits
*/
struct one_double_t {
double double1;
};
/* 64 bits
*/
struct two_floats_t {
float float1;
float float2;
};
/* 24 bits : promoted to 32 bits
*/
struct three_char_t {
char ch1;
char ch2;
char ch3;
};
/* 40 bits : promoted to 64 bits
*/
struct five_char_t {
char ch1;
char ch2;
char ch3;
char ch4;
char ch5;
};
/* 40 bits : promoted to 64 bits
*/
struct int_char_combo_t {
int int1;
char ch1;
};
/*****************************************************************
* LOOP_COUNT :
* A do nothing function. Used to provide a point at which calls can be made.
*****************************************************************/
void loop_count () {
int index;
for (index=0; index<4; index++);
}
/*****************************************************************
* INIT_BIT_FLAGS :
* Initializes a bit_flags_t structure. Can call this function see
* the call command behavior when integer arguments do not fit into
* registers and must be placed on the stack.
* OUT struct bit_flags_t *bit_flags -- structure to be filled
* IN unsigned a -- 0 or 1
* IN unsigned b -- 0 or 1
* IN unsigned g -- 0 or 1
* IN unsigned d -- 0 or 1
* IN unsigned e -- 0 or 1
* IN unsigned o -- 0 or 1
*****************************************************************/
void init_bit_flags (bit_flags,a,b,g,d,e,o)
struct bit_flags_t *bit_flags;
unsigned a;
unsigned b;
unsigned g;
unsigned d;
unsigned e;
unsigned o;
{
bit_flags->alpha = a;
bit_flags->beta = b;
bit_flags->gamma = g;
bit_flags->delta = d;
bit_flags->epsilon = e;
bit_flags->omega = o;
}
/*****************************************************************
* INIT_BIT_FLAGS_COMBO :
* Initializes a bit_flags_combo_t structure. Can call this function
* to see the call command behavior when integer and character arguments
* do not fit into registers and must be placed on the stack.
* OUT struct bit_flags_combo_t *bit_flags_combo -- structure to fill
* IN unsigned a -- 0 or 1
* IN unsigned b -- 0 or 1
* IN char ch1
* IN unsigned g -- 0 or 1
* IN unsigned d -- 0 or 1
* IN char ch2
* IN unsigned e -- 0 or 1
* IN unsigned o -- 0 or 1
*****************************************************************/
void init_bit_flags_combo (bit_flags_combo, a, b, ch1, g, d, ch2, e, o)
struct bit_flags_combo_t *bit_flags_combo;
unsigned a;
unsigned b;
char ch1;
unsigned g;
unsigned d;
char ch2;
unsigned e;
unsigned o;
{
bit_flags_combo->alpha = a;
bit_flags_combo->beta = b;
bit_flags_combo->ch1 = ch1;
bit_flags_combo->gamma = g;
bit_flags_combo->delta = d;
bit_flags_combo->ch2 = ch2;
bit_flags_combo->epsilon = e;
bit_flags_combo->omega = o;
}
/*****************************************************************
* INIT_ONE_DOUBLE :
* OUT struct one_double_t *one_double -- structure to fill
* IN double init_val
*****************************************************************/
void init_one_double (one_double, init_val)
struct one_double_t *one_double;
double init_val;
{
one_double->double1 = init_val;
}
/*****************************************************************
* INIT_TWO_FLOATS :
* OUT struct two_floats_t *two_floats -- structure to be filled
* IN float init_val1
* IN float init_val2
*****************************************************************/
void init_two_floats (two_floats, init_val1, init_val2)
struct two_floats_t *two_floats;
float init_val1;
float init_val2;
{
two_floats->float1 = init_val1;
two_floats->float2 = init_val2;
}
/*****************************************************************
* INIT_THREE_CHARS :
* OUT struct three_char_t *three_char -- structure to be filled
* IN char init_val1
* IN char init_val2
* IN char init_val3
*****************************************************************/
void init_three_chars ( three_char, init_val1, init_val2, init_val3)
struct three_char_t *three_char;
char init_val1;
char init_val2;
char init_val3;
{
three_char->ch1 = init_val1;
three_char->ch2 = init_val2;
three_char->ch3 = init_val3;
}
/*****************************************************************
* INIT_FIVE_CHARS :
* OUT struct five_char_t *five_char -- structure to be filled
* IN char init_val1
* IN char init_val2
* IN char init_val3
* IN char init_val4
* IN char init_val5
*****************************************************************/
void init_five_chars ( five_char, init_val1, init_val2, init_val3, init_val4, init_val5)
struct five_char_t *five_char;
char init_val1;
char init_val2;
char init_val3;
char init_val4;
char init_val5;
{
five_char->ch1 = init_val1;
five_char->ch2 = init_val2;
five_char->ch3 = init_val3;
five_char->ch4 = init_val4;
five_char->ch5 = init_val5;
}
/*****************************************************************
* INIT_INT_CHAR_COMBO :
* OUT struct int_char_combo_t *combo -- structure to be filled
* IN int init_val1
* IN char init_val2
*****************************************************************/
void init_int_char_combo ( combo, init_val1, init_val2)
struct int_char_combo_t *combo;
int init_val1;
char init_val2;
{
combo->int1 = init_val1;
combo->ch1 = init_val2;
}
/*****************************************************************
* INIT_STRUCT_REP :
* OUT struct small_rep_into_t *small_struct -- structure to be filled
* IN int seed
*****************************************************************/
void init_struct_rep( small_struct, seed)
struct small_rep_info_t *small_struct;
int seed;
{
small_struct->value = 2 + (seed*2);
small_struct->head = 0;
}
/*****************************************************************
* PRINT_BIT_FLAGS :
* IN struct bit_flags_t bit_flags
****************************************************************/
struct bit_flags_t print_bit_flags ( bit_flags)
struct bit_flags_t bit_flags;
{
if (bit_flags.alpha) printf("alpha\n");
if (bit_flags.beta) printf("beta\n");
if (bit_flags.gamma) printf("gamma\n");
if (bit_flags.delta) printf("delta\n");
if (bit_flags.epsilon) printf("epsilon\n");
if (bit_flags.omega) printf("omega\n");
return bit_flags;
}
/*****************************************************************
* PRINT_BIT_FLAGS_COMBO :
* IN struct bit_flags_combo_t bit_flags_combo
****************************************************************/
struct bit_flags_combo_t print_bit_flags_combo ( bit_flags_combo )
struct bit_flags_combo_t bit_flags_combo;
{
if (bit_flags_combo.alpha) printf("alpha\n");
if (bit_flags_combo.beta) printf("beta\n");
if (bit_flags_combo.gamma) printf("gamma\n");
if (bit_flags_combo.delta) printf("delta\n");
if (bit_flags_combo.epsilon) printf("epsilon\n");
if (bit_flags_combo.omega) printf("omega\n");
printf("ch1: %c\tch2: %c\n", bit_flags_combo.ch1, bit_flags_combo.ch2);
return bit_flags_combo;
}
/*****************************************************************
* PRINT_ONE_DOUBLE :
* IN struct one_double_t one_double
****************************************************************/
struct one_double_t print_one_double ( one_double )
struct one_double_t one_double;
{
printf("Contents of one_double_t: \n\n");
printf("%f\n", one_double.double1);
return one_double;
}
/*****************************************************************
* PRINT_TWO_FLOATS :
* IN struct two_floats_t two_floats
****************************************************************/
struct two_floats_t print_two_floats ( two_floats )
struct two_floats_t two_floats;
{
printf("Contents of two_floats_t: \n\n");
printf("%f\t%f\n", two_floats.float1, two_floats.float2);
return two_floats;
}
/*****************************************************************
* PRINT_THREE_CHARS :
* IN struct three_char_t three_char
****************************************************************/
struct three_char_t print_three_chars ( three_char )
struct three_char_t three_char;
{
printf("Contents of three_char_t: \n\n");
printf("%c\t%c\t%c\n", three_char.ch1, three_char.ch2, three_char.ch3);
return three_char;
}
/*****************************************************************
* PRINT_FIVE_CHARS :
* IN struct five_char_t five_char
****************************************************************/
struct five_char_t print_five_chars ( five_char )
struct five_char_t five_char;
{
printf("Contents of five_char_t: \n\n");
printf("%c\t%c\t%c\t%c\t%c\n", five_char.ch1, five_char.ch2,
five_char.ch3, five_char.ch4,
five_char.ch5);
return five_char;
}
/*****************************************************************
* PRINT_INT_CHAR_COMBO :
* IN struct int_char_combo_t int_char_combo
****************************************************************/
struct int_char_combo_t print_int_char_combo ( int_char_combo )
struct int_char_combo_t int_char_combo;
{
printf("Contents of int_char_combo_t: \n\n");
printf("%d\t%c\n", int_char_combo.int1, int_char_combo.ch1);
return int_char_combo;
}
/*****************************************************************
* PRINT_STRUCT_REP :
****************************************************************/
struct small_rep_info_t print_struct_rep( struct1 )
struct small_rep_info_t struct1;
{
printf("Contents of struct1: \n\n");
printf("%10d%10d\n", struct1.value, struct1.head);
struct1.value =+5;
return struct1;
}
struct array_rep_info_t print_one_large_struct( linked_list1 )
struct array_rep_info_t linked_list1;
{
printf("%10d%10d\n", linked_list1.values[0],
linked_list1.next_index[0]);
return linked_list1;
}
/*****************************************************************
* INIT_ARRAY_REP :
* IN struct array_rep_info_t *linked_list
* IN int seed
****************************************************************/
void init_array_rep( linked_list, seed )
struct array_rep_info_t *linked_list;
int seed;
{
int index;
for (index = 0; index < 10; index++) {
linked_list->values[index] = (2*index) + (seed*2);
linked_list->next_index[index] = index + 1;
}
linked_list->head = 0;
}
int main () {
/* variables for large structure testing
*/
int number = 10;
struct array_rep_info_t *list1;
/* variables for testing a small structures and a very long argument list
*/
struct small_rep_info_t *struct1;
struct bit_flags_t *flags;
struct bit_flags_combo_t *flags_combo;
struct three_char_t *three_char;
struct five_char_t *five_char;
struct int_char_combo_t *int_char_combo;
struct one_double_t *d1;
struct two_floats_t *f3;
/* Allocate space for large structures
*/
list1 = (struct array_rep_info_t *)malloc(sizeof(struct array_rep_info_t));
/* Initialize large structures
*/
init_array_rep(list1, 2);
/* Print large structures
*/
print_one_large_struct(*list1);
/* Allocate space for small structures
*/
struct1 = (struct small_rep_info_t *)malloc(sizeof(struct small_rep_info_t));
flags = (struct bit_flags_t *)malloc(sizeof(struct bit_flags_t));
flags_combo = (struct bit_flags_combo_t *)malloc(sizeof(struct bit_flags_combo_t));
three_char = (struct three_char_t *)malloc(sizeof(struct three_char_t));
five_char = (struct five_char_t *)malloc(sizeof(struct five_char_t));
int_char_combo = (struct int_char_combo_t *)malloc(sizeof(struct int_char_combo_t));
d1 = (struct one_double_t *)malloc(sizeof(struct one_double_t));
f3 = (struct two_floats_t *)malloc(sizeof(struct two_floats_t));
/* Initialize small structures
*/
init_one_double ( d1, 1.11111);
init_two_floats ( f3, -2.345, 1.0);
init_bit_flags(flags, (unsigned)1, (unsigned)0, (unsigned)1,
(unsigned)0, (unsigned)1, (unsigned)0 );
init_bit_flags_combo(flags_combo, (unsigned)1, (unsigned)0, 'y',
(unsigned)1, (unsigned)0, 'n',
(unsigned)1, (unsigned)0 );
init_three_chars(three_char, 'x', 'y', 'z');
init_five_chars(five_char, 'h', 'e', 'l', 'l', 'o');
init_int_char_combo(int_char_combo, 13, '!');
init_struct_rep(struct1, 10);
/* Print small structures
*/
print_one_double(*d1);
print_two_floats(*f3);
print_bit_flags(*flags);
print_bit_flags_combo(*flags_combo);
print_three_chars(*three_char);
print_five_chars(*five_char);
print_int_char_combo(*int_char_combo);
print_struct_rep(*struct1);
loop_count();
return 0;
}

View File

@ -0,0 +1,276 @@
# Copyright (C) 1997, 1998 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)
# SAME tests as in callfuncs.exp but here the inferior program does not call malloc.
if $tracelevel then {
strace $tracelevel
}
set prms_id 0
set bug_id 0
set testfile "callfuncs2"
set srcfile ${testfile}.c
set binfile ${objdir}/${subdir}/${testfile}
set prototypes 1
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
set prototypes 0;
# built the second test case since we can't use prototypes
warning "Prototypes not supported, rebuilding with -DNO_PROTOTYPES"
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DNO_PROTOTYPES}] != "" } {
gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
}
}
# Create and source the file that provides information about the compiler
# used to compile the test case.
if [get_compiler_info ${binfile}] {
return -1;
}
# The a29k can't call functions, so don't even bother with this test.
if [target_info exists gdb,cannot_call_functions] {
setup_xfail "*-*-*" 2416
fail "This target can not call functions"
continue
}
# Set the current language to C. This counts as a test. If it
# fails, then we skip the other tests.
proc set_lang_c {} {
global gdb_prompt
send_gdb "set language c\n"
gdb_expect {
-re ".*$gdb_prompt $" {}
timeout { fail "set language c (timeout)" ; return 0 }
}
send_gdb "show language\n"
gdb_expect {
-re ".* source language is \"c\".*$gdb_prompt $" {
pass "set language to \"c\""
return 1
}
-re ".*$gdb_prompt $" {
fail "setting language to \"c\""
return 0
}
timeout {
fail "can't show language (timeout)"
return 0
}
}
}
# FIXME: Before calling this proc, we should probably verify that
# we can call inferior functions and get a valid integral value
# returned.
# Note that it is OK to check for 0 or 1 as the returned values, because C
# specifies that the numeric value of a relational or logical expression
# (computed in the inferior) is 1 for true and 0 for false.
proc do_function_calls {} {
global prototypes
global gcc_compiled
# We need to up this because this can be really slow on some boards.
set timeout 60;
gdb_test "p t_char_values(0,0)" " = 0"
gdb_test "p t_char_values('a','b')" " = 1"
gdb_test "p t_char_values(char_val1,char_val2)" " = 1"
gdb_test "p t_char_values('a',char_val2)" " = 1"
gdb_test "p t_char_values(char_val1,'b')" " = 1"
gdb_test "p t_short_values(0,0)" " = 0"
gdb_test "p t_short_values(10,-23)" " = 1"
gdb_test "p t_short_values(short_val1,short_val2)" " = 1"
gdb_test "p t_short_values(10,short_val2)" " = 1"
gdb_test "p t_short_values(short_val1,-23)" " = 1"
gdb_test "p t_int_values(0,0)" " = 0"
gdb_test "p t_int_values(87,-26)" " = 1"
gdb_test "p t_int_values(int_val1,int_val2)" " = 1"
gdb_test "p t_int_values(87,int_val2)" " = 1"
gdb_test "p t_int_values(int_val1,-26)" " = 1"
gdb_test "p t_long_values(0,0)" " = 0"
gdb_test "p t_long_values(789,-321)" " = 1"
gdb_test "p t_long_values(long_val1,long_val2)" " = 1"
gdb_test "p t_long_values(789,long_val2)" " = 1"
gdb_test "p t_long_values(long_val1,-321)" " = 1"
if ![target_info exists gdb,skip_float_tests] {
gdb_test "p t_float_values(0.0,0.0)" " = 0"
# These next four tests fail on the mn10300.
# The first value is passed in regs, the other in memory.
# Gcc emits different stabs for the two parameters; the first is
# claimed to be a float, the second a double.
# dbxout.c in gcc claims this is the desired behavior.
setup_xfail "mn10300-*-*"
gdb_test "p t_float_values(3.14159,-2.3765)" " = 1"
setup_xfail "mn10300-*-*"
gdb_test "p t_float_values(float_val1,float_val2)" " = 1"
setup_xfail "mn10300-*-*"
gdb_test "p t_float_values(3.14159,float_val2)" " = 1"
setup_xfail "mn10300-*-*"
gdb_test "p t_float_values(float_val1,-2.3765)" " = 1"
# Test passing of arguments which might not be widened.
gdb_test "p t_float_values2(0.0,0.0)" " = 0"
# Although PR 5318 mentions SunOS specifically, this seems
# to be a generic problem on quite a few platforms.
if $prototypes then {
setup_xfail "hppa*-*-*" "sparc-*-*" "mips*-*-*" 5318
if {!$gcc_compiled} then {
setup_xfail "alpha-dec-osf2*" "i*86-*-sysv4*" 5318
}
}
gdb_test "p t_float_values2(3.14159,float_val2)" " = 1"
gdb_test "p t_small_values(1,2,3,4,5,6,7,8,9,10)" " = 55"
gdb_test "p t_double_values(0.0,0.0)" " = 0"
gdb_test "p t_double_values(45.654,-67.66)" " = 1"
gdb_test "p t_double_values(double_val1,double_val2)" " = 1"
gdb_test "p t_double_values(45.654,double_val2)" " = 1"
gdb_test "p t_double_values(double_val1,-67.66)" " = 1"
}
gdb_test "p t_string_values(string_val2,string_val1)" " = 0"
gdb_test "p t_string_values(string_val1,string_val2)" " = 1"
gdb_test "p t_string_values(\"string 1\",\"string 2\")" " = 1"
gdb_test "p t_string_values(\"string 1\",string_val2)" " = 1"
gdb_test "p t_string_values(string_val1,\"string 2\")" " = 1"
gdb_test "p t_char_array_values(char_array_val2,char_array_val1)" " = 0"
gdb_test "p t_char_array_values(char_array_val1,char_array_val2)" " = 1"
gdb_test "p t_char_array_values(\"carray 1\",\"carray 2\")" " = 1"
gdb_test "p t_char_array_values(\"carray 1\",char_array_val2)" " = 1"
gdb_test "p t_char_array_values(char_array_val1,\"carray 2\")" " = 1"
gdb_test "p doubleit(4)" " = 8"
gdb_test "p add(4,5)" " = 9"
gdb_test "p t_func_values(func_val2,func_val1)" " = 0"
gdb_test "p t_func_values(func_val1,func_val2)" " = 1"
# On the rs6000, we need to pass the address of the trampoline routine,
# not the address of add itself. I don't know how to go from add to
# the address of the trampoline. Similar problems exist on the HPPA,
# and in fact can present an unsolvable problem as the stubs may not
# even exist in the user's program. We've slightly recoded t_func_values
# to avoid such problems in the common case. This may or may not help
# the RS6000.
setup_xfail "rs6000*-*-*"
setup_xfail "powerpc*-*-*"
if {!$gcc_compiled && [istarget hppa*-*-hpux*]} then {
gdb_test "p t_func_values(add,func_val2)" "You cannot.*ignored.*"
} else {
gdb_test "p t_func_values(add,func_val2)" " = 1"
}
setup_xfail "rs6000*-*-*"
setup_xfail "powerpc*-*-*"
if {!$gcc_compiled && [istarget hppa*-*-hpux*]} then {
gdb_test "p t_func_values(func_val1,doubleit)" "You cannot.*ignored.*"
} else {
gdb_test "p t_func_values(func_val1,doubleit)" " = 1"
}
gdb_test "p t_call_add(func_val1,3,4)" " = 7"
setup_xfail "rs6000*-*-*"
setup_xfail "powerpc*-*-*"
if {!$gcc_compiled && [istarget hppa*-*-hpux*]} then {
gdb_test "p t_call_add(add,3,4)" "You cannot.*ignored.*"
} else {
gdb_test "p t_call_add(add,3,4)" " = 7"
}
gdb_test "p t_enum_value1(enumval1)" " = 1"
gdb_test "p t_enum_value1(enum_val1)" " = 1"
gdb_test "p t_enum_value1(enum_val2)" " = 0"
gdb_test "p t_enum_value2(enumval2)" " = 1"
gdb_test "p t_enum_value2(enum_val2)" " = 1"
gdb_test "p t_enum_value2(enum_val1)" " = 0"
gdb_test "p sum_args(1,{2})" " = 2"
gdb_test "p sum_args(2,{2,3})" " = 5"
gdb_test "p sum_args(3,{2,3,4})" " = 9"
gdb_test "p sum_args(4,{2,3,4,5})" " = 14"
gdb_test "p sum10 (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)" " = 55"
gdb_test "p t_structs_c(struct_val1)" "= 120 'x'" \
"call inferior func with struct - returns char"
gdb_test "p t_structs_s(struct_val1)" "= 87" \
"call inferior func with struct - returns short"
gdb_test "p t_structs_i(struct_val1)" "= 76" \
"call inferior func with struct - returns int"
gdb_test "p t_structs_l(struct_val1)" "= 51" \
"call inferior func with struct - returns long"
setup_xfail "i*86-*-*"
gdb_test "p t_structs_f(struct_val1)" "= 2.12.*" \
"call inferior func with struct - returns float"
setup_xfail "i*86-*-*"
gdb_test "p t_structs_d(struct_val1)" "= 9.87.*" \
"call inferior func with struct - returns double"
gdb_test "p t_structs_a(struct_val1)" "= (.unsigned char .. )?\"foo\"" \
"call inferior func with struct - returns char *"
}
# Start with a fresh gdb.
gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
gdb_test "set print sevenbit-strings" ""
gdb_test "set print address off" ""
gdb_test "set width 0" ""
if { ![set_lang_c] } {
gdb_suppress_tests;
} else {
if { ![runto_main] } {
gdb_suppress_tests;
}
}
gdb_test "next" ".*"
do_function_calls
return 0

View File

@ -0,0 +1,963 @@
# Copyright (C) 1997, 1998 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 (elz@apollo.hp.com)
#
# This file is part of the gdb testsuite
#
# tests for const variables
# const pointers to vars
# pointers to const variables
# const pointers to const vars
# with mixed types
if $tracelevel then {
strace $tracelevel
}
#
# test running programs
#
set prms_id 0
set bug_id 0
set testfile "constvars"
set srcfile ${testfile}.c
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
}
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 $" {}
timeout { fail "up from marker1" }
}
}
-re "Break.* marker1__.* \\(\\) at .*:$decimal.*$gdb_prompt $" {
fail "continue to marker1 (demangling)"
send_gdb "up\n"
gdb_expect {
-re ".*$gdb_prompt $" {}
timeout { fail "up from marker1" }
}
}
-re "$gdb_prompt $" { fail "continue to marker1" }
timeout { fail "(timeout) continue to marker1" }
}
# test function parameters
send_gdb "ptype qux1\n"
gdb_expect {
-re "type = int \\(const char, const char &, const char \\*, char \\* const\\).*$gdb_prompt $" {
pass "ptype qux1"
}
-re ".*$gdb_prompt $" { fail "ptype qux1" }
timeout { fail "(timeout) ptype qux1" }
}
# test vars and pointers
send_gdb "print lave\n"
gdb_expect {
-re ".\[0-9\]* = 66 \'B\'.*$gdb_prompt $" {
pass "print value of lave"
}
-re ".*$gdb_prompt $" { fail "print value of lave" }
timeout { fail "(timeout) print value of lave" }
}
send_gdb "ptype lave\n"
gdb_expect {
-re "type = char.*$gdb_prompt $" { pass "ptype lave" }
-re ".*$gdb_prompt $" { fail "ptype lave" }
timeout { fail "(timeout) ptype lave" }
}
send_gdb "print lavish\n"
gdb_expect {
-re ".\[0-9\]* = 10 \'\\\\n\'.*$gdb_prompt $" {
pass "print value of lavish"
}
-re ".*$gdb_prompt $" { fail "print value of lavish" }
timeout { fail "(timeout) print value of lavish" }
}
send_gdb "ptype lavish\n"
gdb_expect {
-re "type = unsigned char.*$gdb_prompt $" { pass "ptype lavish" }
-re ".*$gdb_prompt $" { fail "ptype lavish " }
timeout { fail "(timeout) ptype lavish " }
}
send_gdb "print lax\n"
gdb_expect {
-re ".\[0-9\]* = 20.*$gdb_prompt $" {
pass "print value of lax"
}
-re ".*$gdb_prompt $" { fail "print value of lax" }
timeout { fail "(timeout) print value of lax" }
}
send_gdb "ptype lax\n"
gdb_expect {
-re "type = short.*$gdb_prompt $" { pass "ptype lax" }
-re ".*$gdb_prompt $" { fail "ptype lax" }
timeout { fail "(timeout) ptype lax" }
}
send_gdb "print lecherous\n"
gdb_expect {
-re ".\[0-9\]* = 30.*$gdb_prompt $" {
pass "print value of lecherous"
}
-re ".*$gdb_prompt $" { fail "print value of lecherous" }
timeout { fail "(timeout) print value of lecherous" }
}
send_gdb "ptype lecherous\n"
gdb_expect {
-re "type = unsigned short.*$gdb_prompt $" { pass "ptype lecherous" }
-re "type = short unsigned.*$gdb_prompt $" { pass "ptype lecherous" }
-re ".*$gdb_prompt $" { fail "ptype lecherous" }
timeout { fail "(timeout) ptype lecherous" }
}
send_gdb "print lechery\n"
gdb_expect {
-re ".\[0-9\]* = 40.*$gdb_prompt $" {
pass "print value of lechery"
}
-re ".*$gdb_prompt $" { fail "print value of lechery" }
timeout { fail "(timeout) print value of lechery" }
}
send_gdb "ptype lechery\n"
gdb_expect {
-re "type = long.*$gdb_prompt $" { pass "ptype lechery" }
-re ".*$gdb_prompt $" { fail "ptype lechery" }
timeout { fail "(timeout) ptype lechery" }
}
send_gdb "print lectern\n"
gdb_expect {
-re ".\[0-9\]* = 50.*$gdb_prompt $" {
pass "print value of lectern"
}
-re ".*$gdb_prompt $" { fail "print value of lectern" }
timeout { fail "(timeout) print value of lectern " }
}
send_gdb "ptype lectern\n"
gdb_expect {
-re "type = unsigned long.*$gdb_prompt $" { pass "ptype lectern" }
-re "type = long unsigned.*$gdb_prompt $" { pass "ptype lectern" }
-re ".*$gdb_prompt $" { fail "ptype lectern" }
timeout { fail "(timeout) ptype lectern" }
}
send_gdb "print leeway\n"
gdb_expect {
-re ".\[0-9\]* = 60.*$gdb_prompt $" {
pass "print value of leeway"
}
-re ".*$gdb_prompt $" { fail "print value of leeway" }
timeout { fail "(timeout) print value of leeway" }
}
send_gdb "ptype leeway\n"
gdb_expect {
-re "type = float.*$gdb_prompt $" { pass "ptype leeway" }
-re ".*$gdb_prompt $" { fail "ptype leeway" }
timeout { fail "(timeout) ptype leeway" }
}
send_gdb "print legacy\n"
gdb_expect {
-re ".\[0-9\]* = 70.*$gdb_prompt $" {
pass "print value of legacy"
}
-re ".*$gdb_prompt $" { fail "print value of legacy" }
timeout { fail "(timeout) print value of legacy" }
}
send_gdb "ptype legacy\n"
gdb_expect {
-re "type = double.*$gdb_prompt $" { pass "ptype legacy" }
-re ".*$gdb_prompt $" { fail "ptype legacy" }
timeout { fail "(timeout) ptype legacy" }
}
send_gdb "print laconic\n"
gdb_expect {
-re ".\[0-9\]* = 65 \'A\'.*$gdb_prompt $" {
pass "print value of laconic"
}
-re ".*$gdb_prompt $" { fail "print value of laconic" }
timeout { fail "(timeout) print value of laconic" }
}
send_gdb "ptype laconic\n"
gdb_expect {
-re "type = const char.*$gdb_prompt $" { pass "ptype laconic" }
-re ".*$gdb_prompt $" { fail "ptype laconic" }
timeout { fail "(timeout) ptype laconic" }
}
send_gdb "print laggard\n"
gdb_expect {
-re ".\[0-9\]* = 1 \'.001\'.*$gdb_prompt $" {
pass "print value of laggard"
}
-re ".*$gdb_prompt $" { fail "print value of laggard" }
timeout { fail "(timeout) print value of laggard" }
}
send_gdb "ptype laggard\n"
gdb_expect {
-re "type = const unsigned char.*$gdb_prompt $" { pass "ptype laggard" }
-re ".*$gdb_prompt $" { fail "ptype laggard" }
timeout { fail "(timeout) ptype laggard" }
}
send_gdb "print lagoon\n"
gdb_expect {
-re ".\[0-9\]* = 2.*$gdb_prompt $" {
pass "print value of lagoon"
}
-re ".*$gdb_prompt $" { fail "print value of lagoon" }
timeout { fail "(timeout) print value of lagoon" }
}
send_gdb "ptype lagoon\n"
gdb_expect {
-re "type = const short.*$gdb_prompt $" { pass "ptype lagoon" }
-re ".*$gdb_prompt $" { fail "ptype lagoon" }
timeout { fail "(timeout) ptype lagoon" }
}
send_gdb "print laity\n"
gdb_expect {
-re ".\[0-9\]* = 3.*$gdb_prompt $" {
pass "print value of laity"
}
-re ".*$gdb_prompt $" { fail "print value of laity" }
timeout { fail "(timeout) print value of laity" }
}
send_gdb "ptype laity\n"
gdb_expect {
-re "type = const unsigned short.*$gdb_prompt $" { pass "ptype laity" }
-re ".*$gdb_prompt $" { fail "ptype laity" }
timeout { fail "(timeout) ptype "laity }
}
send_gdb "print lambent\n"
gdb_expect {
-re ".\[0-9\]* = 4.*$gdb_prompt $" {
pass "print value of lambent"
}
-re ".*$gdb_prompt $" { fail "print value of lambent" }
timeout { fail "(timeout) print value of lambent" }
}
send_gdb "ptype lambent\n"
gdb_expect {
-re "type = const long.*$gdb_prompt $" { pass "ptype lambent" }
-re ".*$gdb_prompt $" { fail "ptype lambent" }
timeout { fail "(timeout) ptype lambent" }
}
send_gdb "print laminated\n"
gdb_expect {
-re ".\[0-9\]* = 5.*$gdb_prompt $" {
pass "print value of laminated"
}
-re ".*$gdb_prompt $" { fail "print value of laminated" }
timeout { fail "(timeout) print value of laminated" }
}
send_gdb "ptype laminated\n"
gdb_expect {
-re "type = const unsigned long.*$gdb_prompt $" { pass "ptype laminated" }
-re ".*$gdb_prompt $" { fail "ptype laminated" }
timeout { fail "(timeout) ptype laminated" }
}
send_gdb "print lampoon\n"
gdb_expect {
-re ".\[0-9\]* = 6.*$gdb_prompt $" {
pass "print value of lampoon"
}
-re ".*$gdb_prompt $" { fail "print value of lampoon" }
timeout { fail "(timeout) print value of lampoon" }
}
send_gdb "ptype lampoon\n"
gdb_expect {
-re "type = const float.*$gdb_prompt $" { pass "ptype lampoon" }
-re ".*$gdb_prompt $" { fail "ptype lampoon" }
timeout { fail "(timeout) ptype lampoon" }
}
send_gdb "print languid\n"
gdb_expect {
-re ".\[0-9\]* = 7.*$gdb_prompt $" {
pass "print value of languid"
}
-re ".*$gdb_prompt $" { fail "print value of languid" }
timeout { fail "(timeout) print value of languid" }
}
send_gdb "ptype languid\n"
gdb_expect {
-re "type = const double.*$gdb_prompt $" { pass "ptype languid" }
-re ".*$gdb_prompt $" { fail "ptype languid" }
timeout { fail "(timeout) ptype languid" }
}
send_gdb "print *legend\n"
gdb_expect {
-re ".\[0-9\]* = 66 \'B\'.*$gdb_prompt $" {
pass "print value of *legend"
}
-re ".*$gdb_prompt $" { fail "print value of *legend" }
timeout { fail "(timeout) print value of *legend" }
}
send_gdb "ptype legend\n"
gdb_expect {
-re "type = const char \\*.*$gdb_prompt $" { pass "ptype legend" }
-re ".*$gdb_prompt $" { fail "ptype legend" }
timeout { fail "(timeout) ptype legend" }
}
send_gdb "print *legerdemain\n"
gdb_expect {
-re ".\[0-9\]* = 10 \'\\\\n\'.*$gdb_prompt $" {
pass "print value of *legerdemain"
}
-re ".*$gdb_prompt $" { fail "print value of *legerdemain" }
timeout { fail "(timeout) print value of *legerdemain" }
}
send_gdb "ptype legerdemain\n"
gdb_expect {
-re "type = const unsigned char \\*.*$gdb_prompt $" { pass "ptype legerdemain" }
-re ".*$gdb_prompt $" { fail "ptype legerdemain" }
timeout { fail "(timeout) ptype legerdemain" }
}
send_gdb "print *leniency\n"
gdb_expect {
-re ".\[0-9\]* = 20.*$gdb_prompt $" {
pass "print value of *leniency"
}
-re ".*$gdb_prompt $" { fail "print value of *leniency" }
timeout { fail "(timeout) print value of *leniency" }
}
send_gdb "ptype leniency\n"
gdb_expect {
-re "type = const short \\*.*$gdb_prompt $" { pass "ptype leniency" }
-re ".*$gdb_prompt $" { fail "ptype leniency " }
timeout { fail "(timeout) ptype leniency" }
}
send_gdb "print *leonine\n"
gdb_expect {
-re ".\[0-9\]* = 30.*$gdb_prompt $" {
pass "print value of *leonine"
}
-re ".*$gdb_prompt $" { fail "print value of *leonine" }
timeout { fail "(timeout) print value of *leonine" }
}
send_gdb "ptype leonine\n"
gdb_expect {
-re "type = const unsigned short \\*.*$gdb_prompt $" { pass "ptype leonine" }
-re ".*$gdb_prompt $" { fail "ptype leonine" }
timeout { fail "(timeout) ptype leonine" }
}
send_gdb "print *lesion\n"
gdb_expect {
-re ".\[0-9\]* = 40.*$gdb_prompt $" {
pass "print value of *lesion"
}
-re ".*$gdb_prompt $" { fail "print value of *lesion" }
timeout { fail "(timeout) print value of *lesion" }
}
send_gdb "ptype lesion\n"
gdb_expect {
-re "type = const long \\*.*$gdb_prompt $" { pass "ptype lesion" }
-re ".*$gdb_prompt $" { fail "ptype lesion" }
timeout { fail "(timeout) ptype lesion" }
}
send_gdb "print *lethal\n"
gdb_expect {
-re ".\[0-9\]* = 50.*$gdb_prompt $" {
pass "print value of *lethal"
}
-re ".*$gdb_prompt $" { fail "print value of *lethal" }
timeout { fail "(timeout) print value of *lethal" }
}
send_gdb "ptype lethal\n"
gdb_expect {
-re "type = const unsigned long \\*.*$gdb_prompt $" { pass "ptype lethal" }
-re ".*$gdb_prompt $" { fail "ptype lethal" }
timeout { fail "(timeout) ptype lethal" }
}
send_gdb "print *lethargic\n"
gdb_expect {
-re ".\[0-9\]* = 60.*$gdb_prompt $" {
pass "print value of *lethargic"
}
-re ".*$gdb_prompt $" { fail "print value of *lethargic" }
timeout { fail "(timeout) print value of *lethargic" }
}
send_gdb "ptype lethargic\n"
gdb_expect {
-re "type = const float \\*.*$gdb_prompt $" { pass "ptype lethargic" }
-re ".*$gdb_prompt $" { fail "ptype lethargic" }
timeout { fail "(timeout) ptype lethargic" }
}
send_gdb "print *levity\n"
gdb_expect {
-re ".\[0-9\]* = 70.*$gdb_prompt $" {
pass "print value of *levity"
}
-re ".*$gdb_prompt $" { fail "print value of *levity" }
timeout { fail "(timeout) print value of *levity" }
}
send_gdb "ptype levity\n"
gdb_expect {
-re "type = const double \\*.*$gdb_prompt $" { pass "ptype levity" }
-re ".*$gdb_prompt $" { fail "ptype levity" }
timeout { fail "(timeout) ptype levity" }
}
send_gdb "print *lewd\n"
gdb_expect {
-re ".\[0-9\]* = 65 \'A\'.*$gdb_prompt $" {
pass "print value of *lewd"
}
-re ".*$gdb_prompt $" { fail "print value of *lewd" }
timeout { fail "(timeout) print value of *lewd" }
}
send_gdb "ptype lewd\n"
gdb_expect {
-re "type = const char \\* const.*$gdb_prompt $" { pass "ptype lewd" }
-re ".*$gdb_prompt $" { fail "ptype lewd" }
timeout { fail "(timeout) ptype lewd" }
}
send_gdb "print *lexicographer\n"
gdb_expect {
-re ".\[0-9\]* = 1 \'.001\'.*$gdb_prompt $" {
pass "print value of *lexicographer"
}
-re ".*$gdb_prompt $" { fail "print value of *lexicographer" }
timeout { fail "(timeout) print value of *lexicographer" }
}
send_gdb "ptype lexicographer\n"
gdb_expect {
-re "type = const unsigned char \\* const.*$gdb_prompt $" { pass "ptype lexicographer" }
-re ".*$gdb_prompt $" { fail "ptype lexicographer" }
timeout { fail "(timeout) ptype lexicographer" }
}
send_gdb "print *lexicon\n"
gdb_expect {
-re ".\[0-9\]* = 2.*$gdb_prompt $" {
pass "print value of *lexicon"
}
-re ".*$gdb_prompt $" { fail "print value of *lexicon" }
timeout { fail "(timeout) print value of *lexicon" }
}
send_gdb "ptype lexicon\n"
gdb_expect {
-re "type = const short \\* const.*$gdb_prompt $" { pass "ptype lexicon" }
-re ".*$gdb_prompt $" { fail "ptype lexicon" }
timeout { fail "(timeout) ptype lexicon" }
}
send_gdb "print *liaison\n"
gdb_expect {
-re ".\[0-9\]* = 3.*$gdb_prompt $" {
pass "print value of *liaison"
}
-re ".*$gdb_prompt $" { fail "print value of *liaison" }
timeout { fail "(timeout) print value of *liaison" }
}
send_gdb "ptype liaison\n"
gdb_expect {
-re "type = const unsigned short \\* const.*$gdb_prompt $" { pass "ptype liaison" }
-re ".*$gdb_prompt $" { fail "ptype liaison" }
timeout { fail "(timeout) ptype liaison" }
}
send_gdb "print *libation\n"
gdb_expect {
-re ".\[0-9\]* = 4.*$gdb_prompt $" {
pass "print value of *libation"
}
-re ".*$gdb_prompt $" { fail "print value of *libation" }
timeout { fail "(timeout) print value of *libation" }
}
send_gdb "ptype libation\n"
gdb_expect {
-re "type = const long \\* const.*$gdb_prompt $" { pass "ptype libation" }
-re ".*$gdb_prompt $" { fail "ptype libation" }
timeout { fail "(timeout) ptype libation" }
}
send_gdb "print *libelous\n"
gdb_expect {
-re ".\[0-9\]* = 5.*$gdb_prompt $" {
pass "print value of *libelous"
}
-re ".*$gdb_prompt $" { fail "print value of *libelous" }
timeout { fail "(timeout) print value of *libelous" }
}
send_gdb "ptype libelous\n"
gdb_expect {
-re "type = const unsigned long \\* const.*$gdb_prompt $" { pass "ptype libelous" }
-re ".*$gdb_prompt $" { fail "ptype libelous" }
timeout { fail "(timeout) ptype libelous" }
}
send_gdb "print *libertine\n"
gdb_expect {
-re ".\[0-9\]* = 6.*$gdb_prompt $" {
pass "print value of *libertine"
}
-re ".*$gdb_prompt $" { fail "print value of *libertine" }
timeout { fail "(timeout) print value of *libertine" }
}
send_gdb "ptype libertine\n"
gdb_expect {
-re "type = const float \\* const.*$gdb_prompt $" { pass "ptype libertine" }
-re ".*$gdb_prompt $" { fail "ptype libertine" }
timeout { fail "(timeout) ptype libertine" }
}
send_gdb "print *libidinous\n"
gdb_expect {
-re ".\[0-9\]* = 7.*$gdb_prompt $" {
pass "print value of *libidinous"
}
-re ".*$gdb_prompt $" { fail "print value of *libidinous" }
timeout { fail "(timeout) print value of *libidinous" }
}
send_gdb "ptype libidinous\n"
gdb_expect {
-re "type = const double \\* const.*$gdb_prompt $" { pass "ptype libidinous" }
-re ".*$gdb_prompt $" { fail "ptype libidinous" }
timeout { fail "(timeout) ptype libidinous" }
}
send_gdb "print *languish\n"
gdb_expect {
-re ".\[0-9\]* = 65 \'A\'.*$gdb_prompt $" {
pass "print value of *languish"
}
-re ".*$gdb_prompt $" { fail "print value of *languish" }
timeout { fail "(timeout) print value of *languish" }
}
send_gdb "ptype languish\n"
gdb_expect {
-re "type = const char \\*.*$gdb_prompt $" { pass "ptype languish" }
-re ".*$gdb_prompt $" { fail "ptype languish" }
timeout { fail "(timeout) ptype languish" }
}
send_gdb "print *languor\n"
gdb_expect {
-re ".\[0-9\]* = 1 \'.001\'.*$gdb_prompt $" {
pass "print value of *languor"
}
-re ".*$gdb_prompt $" { fail "print value of *languor" }
timeout { fail "(timeout) print value of *languor" }
}
send_gdb "ptype languor\n"
gdb_expect {
-re "type = const unsigned char \\*.*$gdb_prompt $" { pass "ptype languor" }
-re ".*$gdb_prompt $" { fail "ptype languor" }
timeout { fail "(timeout) ptype languor" }
}
send_gdb "print *lank\n"
gdb_expect {
-re ".\[0-9\]* = 2.*.*$gdb_prompt $" {
pass "print value of *lank"
}
-re ".*$gdb_prompt $" { fail "print value of *lank" }
timeout { fail "(timeout) print value of *lank" }
}
send_gdb "ptype lank\n"
gdb_expect {
-re "type = const short \\*.*$gdb_prompt $" { pass "ptype lank" }
-re ".*$gdb_prompt $" { fail "ptype lank" }
timeout { fail "(timeout) ptype lank" }
}
send_gdb "print *lapidary\n"
gdb_expect {
-re ".\[0-9\]* = 3.*$gdb_prompt $" {
pass "print value of *lapidary"
}
-re ".*$gdb_prompt $" { fail "print value of *lapidary" }
timeout { fail "(timeout) print value of *lapidary" }
}
send_gdb "ptype lapidary\n"
gdb_expect {
-re "type = const unsigned short \\*.*$gdb_prompt $" { pass "ptype lapidary" }
-re ".*$gdb_prompt $" { fail "ptype lapidary" }
timeout { fail "(timeout) ptype lapidary" }
}
send_gdb "print *larceny\n"
gdb_expect {
-re ".\[0-9\]* = 4.*$gdb_prompt $" {
pass "print value of *larceny"
}
-re ".*$gdb_prompt $" { fail "print value of *larceny" }
timeout { fail "(timeout) print value of *larceny" }
}
send_gdb "ptype larceny\n"
gdb_expect {
-re "type = const long \\*.*$gdb_prompt $" { pass "ptype larceny" }
-re ".*$gdb_prompt $" { fail "ptype larceny" }
timeout { fail "(timeout) ptype larceny" }
}
send_gdb "print *largess\n"
gdb_expect {
-re ".\[0-9\]* = 5.*$gdb_prompt $" {
pass "print value of *largess"
}
-re ".*$gdb_prompt $" { fail "print value of *largess" }
timeout { fail "(timeout) print value of *largess" }
}
send_gdb "ptype largess\n"
gdb_expect {
-re "type = const unsigned long \\*.*$gdb_prompt $" { pass "ptype largess" }
-re ".*$gdb_prompt $" { fail "ptype largess" }
timeout { fail "(timeout) ptype largess" }
}
send_gdb "print *lascivious\n"
gdb_expect {
-re ".\[0-9\]* = 6.*$gdb_prompt $" {
pass "print value of *lascivious"
}
-re ".*$gdb_prompt $" { fail "print value of *lascivious" }
timeout { fail "(timeout) print value of *lascivious" }
}
send_gdb "ptype lascivious\n"
gdb_expect {
-re "type = const float \\*.*$gdb_prompt $" { pass "ptype lascivious" }
-re ".*$gdb_prompt $" { fail "ptype lascivious" }
timeout { fail "(timeout) ptype lascivious" }
}
send_gdb "print *lassitude\n"
gdb_expect {
-re ".\[0-9\]* = 7.*$gdb_prompt $" {
pass "print value of *lassitude"
}
-re ".*$gdb_prompt $" { fail "print value of *lassitude" }
timeout { fail "(timeout) print value of *lassitude" }
}
send_gdb "ptype lassitude\n"
gdb_expect {
-re "type = const double \\*.*$gdb_prompt $" { pass "ptype lassitude" }
-re ".*$gdb_prompt $" { fail "ptype lassitude" }
timeout { fail "(timeout) ptype lassitude" }
}
send_gdb "print *lamprey\n"
gdb_expect {
-re ".\[0-9\]* = 66 \'B\'.*$gdb_prompt $" {
pass "print value of *lamprey"
}
-re ".*$gdb_prompt $" { fail "print value of *lamprey" }
timeout { fail "(timeout) print value of *lamprey" }
}
send_gdb "ptype lamprey\n"
gdb_expect {
-re "type = char \\* const.*$gdb_prompt $" { pass "ptype lamprey" }
-re ".*$gdb_prompt $" { fail "ptype lamprey" }
timeout { fail "(timeout) ptype lamprey" }
}
send_gdb "print *lariat\n"
gdb_expect {
-re ".\[0-9\]* = 10 \'\\\\n\'.*$gdb_prompt $" {
pass "print value of *lariat"
}
-re ".*$gdb_prompt $" { fail "print value of *lariat" }
timeout { fail "(timeout) print value of *lariat" }
}
send_gdb "ptype lariat\n"
gdb_expect {
-re "type = unsigned char \\* const.*$gdb_prompt $" { pass "ptype lariat" }
-re ".*$gdb_prompt $" { fail "ptype lariat" }
timeout { fail "(timeout) ptype lariat" }
}
send_gdb "print *laudanum\n"
gdb_expect {
-re ".\[0-9\]* = 20.*$gdb_prompt $" {
pass "print value of *laudanum"
}
-re ".*$gdb_prompt $" { fail "print value of *laudanum" }
timeout { fail "(timeout) print value of *laudanum" }
}
send_gdb "ptype laudanum\n"
gdb_expect {
-re "type = short \\* const.*$gdb_prompt $" { pass "ptype laudanum" }
-re ".*$gdb_prompt $" { fail "ptype laudanum" }
timeout { fail "(timeout) ptype laudanum" }
}
send_gdb "print *lecithin\n"
gdb_expect {
-re ".\[0-9\]* = 30.*$gdb_prompt $" {
pass "print value of *lecithin"
}
-re ".*$gdb_prompt $" { fail "print value of *lecithin" }
timeout { fail "(timeout) print value of *lecithin" }
}
send_gdb "ptype lecithin\n"
gdb_expect {
-re "type = unsigned short \\* const.*$gdb_prompt $" { pass "ptype lecithin" }
-re ".*$gdb_prompt $" { fail "ptype lecithin" }
timeout { fail "(timeout) ptype lecithin" }
}
send_gdb "print *leviathan\n"
gdb_expect {
-re ".\[0-9\]* = 40.*$gdb_prompt $" {
pass "print value of *leviathan"
}
-re ".*$gdb_prompt $" { fail "print value of *leviathan" }
timeout { fail "(timeout) print value of *leviathan" }
}
send_gdb "ptype leviathan\n"
gdb_expect {
-re "type = long \\* const.*$gdb_prompt $" { pass "ptype leviathan" }
-re ".*$gdb_prompt $" { fail "ptype leviathan" }
timeout { fail "(timeout) ptype leviathan" }
}
send_gdb "print *libretto\n"
gdb_expect {
-re ".\[0-9\]* = 50.*$gdb_prompt $" {
pass "print value of *libretto"
}
-re ".*$gdb_prompt $" { fail "print value of *libretto" }
timeout { fail "(timeout) print value of *libretto" }
}
send_gdb "ptype libretto\n"
gdb_expect {
-re "type = unsigned long \\* const.*$gdb_prompt $" { pass "ptype libretto" }
-re ".*$gdb_prompt $" { fail "ptype libretto" }
timeout { fail "(timeout) ptype libretto" }
}
send_gdb "print *lissome\n"
gdb_expect {
-re ".\[0-9\]* = 60.*$gdb_prompt $" {
pass "print value of *lissome"
}
-re ".*$gdb_prompt $" { fail "print value of *lissome" }
timeout { fail "(timeout) print value of *lissome" }
}
send_gdb "ptype lissome\n"
gdb_expect {
-re "type = float \\* const.*$gdb_prompt $" { pass "ptype lissome" }
-re ".*$gdb_prompt $" { fail "ptype lissome" }
timeout { fail "(timeout) ptype lissome" }
}
send_gdb "print *locust\n"
gdb_expect {
-re ".\[0-9\]* = 70.*$gdb_prompt $" {
pass "print value of *locust"
}
-re ".*$gdb_prompt $" { fail "print value of *locust" }
timeout { fail "(timeout) print value of *locust" }
}
send_gdb "ptype locust\n"
gdb_expect {
-re "type = double \\* const.*$gdb_prompt $" { pass "ptype locust" }
-re ".*$gdb_prompt $" { fail "ptype locust" }
timeout { fail "(timeout) ptype locust" }
}
send_gdb "ptype radiation\n"
gdb_expect {
-re "type = const char &.*$gdb_prompt $" { pass "ptype radiation" }
-re ".*$gdb_prompt $" { fail "ptype radiation" }
timeout { fail "(timeout) ptype radiation" }
}

View File

@ -0,0 +1,480 @@
// Test various -*- C++ -*- things.
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;
};
// ========================= 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)
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 ();
}
// ======================== 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 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;
}
int
main()
{
#ifdef usestubs
set_debug_traps();
breakpoint();
#endif
inheritance1 ();
inheritance3 ();
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;
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;