From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4579 invoked by alias); 10 Oct 2003 17:18:39 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 4571 invoked from network); 10 Oct 2003 17:18:36 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sources.redhat.com with SMTP; 10 Oct 2003 17:18:36 -0000 Received: from int-mx2.corp.redhat.com (nat-pool-rdu-dmz.redhat.com [172.16.52.200] (may be forged)) by mx1.redhat.com (8.11.6/8.11.6) with ESMTP id h9AHIZM06304 for ; Fri, 10 Oct 2003 13:18:35 -0400 Received: from potter.sfbay.redhat.com (potter.sfbay.redhat.com [172.16.27.15]) by int-mx2.corp.redhat.com (8.11.6/8.11.6) with ESMTP id h9AHIYD01751 for ; Fri, 10 Oct 2003 13:18:34 -0400 Received: from cygbert.vinschen.de (vpn50-15.rdu.redhat.com [172.16.50.15]) by potter.sfbay.redhat.com (8.11.6/8.11.6) with ESMTP id h9AHIWi23013 for ; Fri, 10 Oct 2003 10:18:32 -0700 Received: by cygbert.vinschen.de (Postfix, from userid 500) id 2AE6D58047; Fri, 10 Oct 2003 19:18:31 +0200 (CEST) Date: Fri, 10 Oct 2003 17:18:00 -0000 From: Corinna Vinschen To: gdb-patches@sources.redhat.com Subject: [RFA] gdb.base/call-rt-st.*: Add char bitfield and short bitfield tests Message-ID: <20031010171831.GO14344@cygbert.vinschen.de> Reply-To: gdb-patches@sources.redhat.com Mail-Followup-To: gdb-patches@sources.redhat.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.1i X-SW-Source: 2003-10/txt/msg00362.txt.bz2 Hi, as talked about in the thread "[RFA] sh-tdep.c (sh_use_struct_convention): Restructure and fix", the call-rt-st.exp test has no test about correct handling of bitfields with base types char and short. The below patch basically just adds appropriate bitfields and functions, calls them in call-rt-st.exp and fixes the line numbering in call-rt-st.exp accordingly. Corinna * gdb.base/call-rt-st.c (struct bit_flags_char_t): New bitfield type, based on char type. (struct bit_flags_short_t): New bitfield type, based on short type. (init_bit_flags_char): New fuction. (init_bit_flags_short): Ditto. (print_bit_flags_char): Ditto. (print_bit_flags_short): Ditto. (main): Add handling for bit_flags_char_t and bit_flags_short_t. Index: gdb.base/call-rt-st.c =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.base/call-rt-st.c,v retrieving revision 1.1.1.2 diff -u -p -r1.1.1.2 call-rt-st.c --- gdb.base/call-rt-st.c 28 Jun 1999 16:02:47 -0000 1.1.1.2 +++ gdb.base/call-rt-st.c 10 Oct 2003 17:17:37 -0000 @@ -31,6 +31,28 @@ struct small_rep_info_t { int head; }; +/* 6 bits : really fits in 8 bits and is promoted to 8 bits + */ +struct bit_flags_char_t { + unsigned char alpha :1; + unsigned char beta :1; + unsigned char gamma :1; + unsigned char delta :1; + unsigned char epsilon :1; + unsigned char omega :1; +}; + +/* 6 bits : really fits in 8 bits and is promoted to 16 bits + */ +struct bit_flags_short_t { + unsigned short alpha :1; + unsigned short beta :1; + unsigned short gamma :1; + unsigned short delta :1; + unsigned short epsilon :1; + unsigned short omega :1; +}; + /* 6 bits : really fits in 8 bits and is promoted to 32 bits */ struct bit_flags_t { @@ -107,6 +129,90 @@ void loop_count () { } /***************************************************************** + * INIT_BIT_FLAGS_CHAR : + * Initializes a bit_flags_char_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_char_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 + *****************************************************************/ +#ifdef PROTOTYPES +void init_bit_flags_char ( +struct bit_flags_char_t *bit_flags, +unsigned a, +unsigned b, +unsigned g, +unsigned d, +unsigned e, +unsigned o) +#else +void init_bit_flags_char (bit_flags,a,b,g,d,e,o) +struct bit_flags_char_t *bit_flags; +unsigned a; +unsigned b; +unsigned g; +unsigned d; +unsigned e; +unsigned o; +#endif +{ + + 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_SHORT : + * Initializes a bit_flags_short_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_short_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 + *****************************************************************/ +#ifdef PROTOTYPES +void init_bit_flags_short ( +struct bit_flags_short_t *bit_flags, +unsigned a, +unsigned b, +unsigned g, +unsigned d, +unsigned e, +unsigned o) +#else +void init_bit_flags_short (bit_flags,a,b,g,d,e,o) +struct bit_flags_short_t *bit_flags; +unsigned a; +unsigned b; +unsigned g; +unsigned d; +unsigned e; +unsigned o; +#endif +{ + + 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 : * Initializes a bit_flags_t structure. Can call this function see * the call command behavior when integer arguments do not fit into @@ -345,6 +451,50 @@ int seed; } /***************************************************************** + * PRINT_BIT_FLAGS_CHAR : + * IN struct bit_flags_char_t bit_flags + ****************************************************************/ +#ifdef PROTOTYPES +struct bit_flags_char_t print_bit_flags_char (struct bit_flags_char_t bit_flags) +#else +struct bit_flags_char_t print_bit_flags_char ( bit_flags) +struct bit_flags_char_t bit_flags; +#endif +{ + + 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_SHORT : + * IN struct bit_flags_short_t bit_flags + ****************************************************************/ +#ifdef PROTOTYPES +struct bit_flags_short_t print_bit_flags_short (struct bit_flags_short_t bit_flags) +#else +struct bit_flags_short_t print_bit_flags_short ( bit_flags) +struct bit_flags_short_t bit_flags; +#endif +{ + + 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 : * IN struct bit_flags_t bit_flags ****************************************************************/ @@ -553,6 +703,8 @@ int main () { /* variables for testing a small structures and a very long argument list */ struct small_rep_info_t *struct1; + struct bit_flags_char_t *cflags; + struct bit_flags_short_t *sflags; struct bit_flags_t *flags; struct bit_flags_combo_t *flags_combo; struct three_char_t *three_char; @@ -577,6 +729,8 @@ int main () { /* Allocate space for small structures */ struct1 = (struct small_rep_info_t *)malloc(sizeof(struct small_rep_info_t)); + cflags = (struct bit_flags_char_t *)malloc(sizeof(struct bit_flags_char_t)); + sflags = (struct bit_flags_short_t *)malloc(sizeof(struct bit_flags_short_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)); @@ -590,6 +744,10 @@ int main () { */ init_one_double ( d1, 1.11111); init_two_floats ( f3, -2.345, 1.0); + init_bit_flags_char(cflags, (unsigned)1, (unsigned)0, (unsigned)1, + (unsigned)0, (unsigned)1, (unsigned)0 ); + init_bit_flags_short(sflags, (unsigned)1, (unsigned)0, (unsigned)1, + (unsigned)0, (unsigned)1, (unsigned)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', @@ -605,6 +763,8 @@ int main () { */ print_one_double(*d1); print_two_floats(*f3); + print_bit_flags_char(*cflags); + print_bit_flags_short(*sflags); print_bit_flags(*flags); print_bit_flags_combo(*flags_combo); print_three_chars(*three_char); Index: gdb.base/call-rt-st.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.base/call-rt-st.exp,v retrieving revision 1.12 diff -u -p -r1.12 call-rt-st.exp --- gdb.base/call-rt-st.exp 3 Apr 2003 16:34:48 -0000 1.12 +++ gdb.base/call-rt-st.exp 10 Oct 2003 17:17:37 -0000 @@ -114,13 +114,13 @@ if ![runto_main] then { gdb_test "break loop_count" \ - "Breakpoint.* file .*call-rt-st.c, line 106\\." \ + "Breakpoint.* file .*call-rt-st.c, line 128\\." \ "breakpoint loop_count" send_gdb "continue\n" gdb_expect { - -re "Continuing\\..*Breakpoint.*loop_count \\(\\) at.*call-rt-st.c:106\[ \t\r\n\]+106\[\t \]+for \\(index=0; index.4; index..\\);\[\r\n \]+$gdb_prompt $" { + -re "Continuing\\..*Breakpoint.*loop_count \\(\\) at.*call-rt-st.c:128\[ \t\r\n\]+128\[\t \]+for \\(index=0; index.4; index..\\);\[\r\n \]+$gdb_prompt $" { pass "continue to loop_count"} -re ".*$gdb_prompt $" { fail "continue to loop_count"} timeout { fail "(timeout) continue to loop_count"} @@ -128,11 +128,11 @@ gdb_expect { send_gdb "finish\n" gdb_expect { - -re "Run till exit from .0 loop_count \\(\\) at.*call-rt-st.c:106\[ \t\r\n\]+main \\(\\) at.*call-rt-st.c:617\[ \t\r\n\]+617\[\t \]+return 0;.*$gdb_prompt $" { - pass "finish out from loop_count (line 617)" + -re "Run till exit from .0 loop_count \\(\\) at.*call-rt-st.c:128\[ \t\r\n\]+main \\(\\) at.*call-rt-st.c:777\[ \t\r\n\]+777\[\t \]+return 0;.*$gdb_prompt $" { + pass "finish out from loop_count (line 777)" } - -re "Run till exit from .0 loop_count \\(\\) at.*call-rt-st.c:106\[ \t\r\n\]+main \\(\\) at.*call-rt-st.c:615\[ \t\r\n\]+615\[\t \]+loop_count.*$gdb_prompt $" { - pass "finish out from loop_count (line 615)" + -re "Run till exit from .0 loop_count \\(\\) at.*call-rt-st.c:128\[ \t\r\n\]+main \\(\\) at.*call-rt-st.c:775\[ \t\r\n\]+775\[\t \]+loop_count.*$gdb_prompt $" { + pass "finish out from loop_count (line 775)" } -re ".*$gdb_prompt $" { fail "finish out from loop_count" @@ -189,6 +189,16 @@ if {![gdb_skip_float_test "print print_t ![gdb_skip_stdio_test "print print_two_floats(*f3)"] } { print_struct_call "print_two_floats(*f3)" \ ".*Contents of two_floats_t:\[ \r\n\]+-2\\.345000\[ \t]+1\\.000000\[ \r\n\]+.\[0-9\]+ = \\{float1 = -2\\.34500003, float2 = 1\\}" +} + +if ![gdb_skip_stdio_test "print print_bit_flags_char(*flags)"] { + print_struct_call "print_bit_flags_char(*flags)" \ + ".*alpha\[ \r\n\]+gamma\[ \r\n\]+epsilon\[ \r\n\]+.\[0-9\]+ = \\{alpha = 1 '\\\\001', beta = 0 '\\\\0', gamma = 1 '\\\\001', delta = 0 '\\\\0', epsilon = 1 '\\\\001', omega = 0 '\\\\0'\\}" +} + +if ![gdb_skip_stdio_test "print print_bit_flags_short(*flags)"] { + print_struct_call "print_bit_flags(*flags)" \ + ".*alpha\[ \r\n\]+gamma\[ \r\n\]+epsilon\[ \r\n\]+.\[0-9\]+ = \\{alpha = 1, beta = 0, gamma = 1, delta = 0, epsilon = 1, omega = 0\\}" } if ![gdb_skip_stdio_test "print print_bit_flags(*flags)"] { -- Corinna Vinschen Cygwin Developer Red Hat, Inc.