From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17752 invoked by alias); 28 Aug 2007 17:51:45 -0000 Received: (qmail 17624 invoked by uid 22791); 28 Aug 2007 17:51:44 -0000 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 28 Aug 2007 17:51:36 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 616AA2AABE0 for ; Tue, 28 Aug 2007 13:51:34 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id hE5xcD0uO0XB for ; Tue, 28 Aug 2007 13:51:34 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 01D402AA176 for ; Tue, 28 Aug 2007 13:51:34 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 73FCBE7B58; Tue, 28 Aug 2007 10:51:28 -0700 (PDT) Date: Tue, 28 Aug 2007 17:51:00 -0000 From: Joel Brobecker To: gdb-patches@sourceware.org Subject: [RFA/testsuite] ptype of structs with anonymous type fields Message-ID: <20070828175128.GC3874@adacore.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="/NkBOFFp2J2Af1nK" Content-Disposition: inline User-Agent: Mutt/1.4.2.2i Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2007-08/txt/msg00498.txt.bz2 --/NkBOFFp2J2Af1nK Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 925 In case I made the subject of this message so short that it doesn't make any sense anymore, the purpose of this message is to add a new test in printing a structure that contains a field whose type is anonymous. More particularly, the purpose of this test is to verify what GDB prints for a field that is directly inside the structure, and a field that is one level deeper. The test itself is pretty straightforward, but I'm asking for approval because I want to make sure that the current behavior is indeed the expected behavior. See http://www.sourceware.org/ml/gdb-patches/2007-08/msg00494.html for the inspiration for this new test. 2007-08-28 Joel Brobecker * gdb.base/ptype.c (highest): New struct type. (the_highest): New variable of that type. (main): Add dummy assignment to a field of variable the_highest. Tested on x86-linux. OK to apply? Thanks, -- Joel --/NkBOFFp2J2Af1nK Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="ptype-exp.diff" Content-length: 2255 Index: gdb.base/ptype.c =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.base/ptype.c,v retrieving revision 1.4 diff -u -p -r1.4 ptype.c --- gdb.base/ptype.c 4 Jan 2006 14:46:17 -0000 1.4 +++ gdb.base/ptype.c 28 Aug 2007 17:43:28 -0000 @@ -198,6 +198,16 @@ struct outer_struct { long outer_long; } nested_su; +struct highest +{ + int a; + struct + { + int b; + struct { int c; } anonymous_level_2; + } anonymous_level_1; +} the_highest; + /**** Enumerations *******/ enum @@ -352,6 +362,8 @@ int main () nested_su.outer_int = 0; v_t_struct_p = 0; + the_highest.a = 0; + v_boolean = FALSE; v_boolean2 = my_false; return 0; Index: gdb.base/ptype.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.base/ptype.exp,v retrieving revision 1.11 diff -u -p -r1.11 ptype.exp --- gdb.base/ptype.exp 23 Aug 2007 18:14:17 -0000 1.11 +++ gdb.base/ptype.exp 28 Aug 2007 17:43:28 -0000 @@ -532,6 +532,22 @@ gdb_test "ptype nested_su.inner_struct_i gdb_test "ptype nested_su.inner_union_instance" "type = union ${outer}inner_union \{.*\[\r\n\] int inner_union_int;.*\[\r\n\] (long|long int|int) inner_union_long;.*\[\r\n\]\}.*" "ptype nested union" +# Print the type description of variable the_highest, and verify that +# the type description for the fields whose type is anonymous are +# correctly printed (at nesting level 1 and 2). + +gdb_test "ptype the_highest" \ + "type = struct highest \{.*\[\r\n\] *int a;.*\[\r\n\] *struct \{.*\[\r\n\] *int b;.*\[\r\n\] *struct \{\.\.\.\} anonymous_level_2;.*\[\r\n\] *\} anonymous_level_1;.*\[\r\n\]}.*" \ + "ptype the_highest" + +# Print the type descrption for one of the fields of variable the_highest. +# The purpose is to verify that the type of a field that was printed above +# as "struct {...}" is now printed in a more descriptive way (because the +# nesting level is now one level less). + +gdb_test "ptype the_highest.anonymous_level_1" \ + "type = struct \{.*\[\r\n\] *int b;.*\[\r\n\] *struct \{.*\[\r\n\] *int c;.*\[\r\n\] *\} anonymous_level_2;.*\[\r\n\]}.*" \ + "ptype the_highest" get_debug_format --/NkBOFFp2J2Af1nK--