This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [RFA] gdb.base/call-rt-st.*: Add char bitfield and short bitfield tests
- From: Elena Zannoni <ezannoni at redhat dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Fri, 10 Oct 2003 14:10:59 -0400
- Subject: Re: [RFA] gdb.base/call-rt-st.*: Add char bitfield and short bitfield tests
- References: <20031010171831.GO14344@cygbert.vinschen.de>
Corinna Vinschen writes:
> 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.
Yes, if MichaelC sends it through his test harness and says so as well.
elena
>
> 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.