* [RFA/testsuite] ptype of structs with anonymous type fields
@ 2007-08-28 17:51 Joel Brobecker
2007-12-21 6:52 ` ping: " Joel Brobecker
0 siblings, 1 reply; 4+ messages in thread
From: Joel Brobecker @ 2007-08-28 17:51 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 925 bytes --]
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 <brobecker@adacore.com>
* 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
[-- Attachment #2: ptype-exp.diff --]
[-- Type: text/plain, Size: 2255 bytes --]
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
^ permalink raw reply [flat|nested] 4+ messages in thread* ping: [RFA/testsuite] ptype of structs with anonymous type fields
2007-08-28 17:51 [RFA/testsuite] ptype of structs with anonymous type fields Joel Brobecker
@ 2007-12-21 6:52 ` Joel Brobecker
2007-12-21 13:24 ` Daniel Jacobowitz
0 siblings, 1 reply; 4+ messages in thread
From: Joel Brobecker @ 2007-12-21 6:52 UTC (permalink / raw)
To: gdb-patches
Hello,
I never received any comments regarding the test addition below.
The idea is to add a test that verifies how GDB handles structs
that have a large nesting level.
Currently, the behavior appears to be as documented (at least in
the code). For the following code:
struct highest
{
int a;
struct
{
int b;
struct { int c; } anonymous_level_2;
} anonymous_level_1;
} the_highest;
GDB currently shows:
(gdb) ptype the_highest
type = struct highest {
int a;
struct {
int b;
struct {...} anonymous_level_2;
} anonymous_level_1;
}
Or in other words, the contents of anonymous_level_2 is eluded,
because of the nesting level.
(gdb) ptype the_highest.anonymous_level_1
type = struct {
int b;
struct {
int c;
} anonymous_level_2;
}
In this case, we're printing one field of our struct, so field
anonymous_level_2 becomes less "deep", and thus gets printed.
Do we agree that this is the expected behavior? If yes, then I think
I can commit the testsuite change, since this part is relatively
straightforward. But I want to make sure that we do have the correct
behavior!
I'm thinking that this would deserve some extra documentation, but
I'm not sure where to put it. Maybe together with the rest of the
"ptype" documentation... Eli?
Thanks!
> 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 <brobecker@adacore.com>
>
> * 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
> 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
>
--
Joel
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: ping: [RFA/testsuite] ptype of structs with anonymous type fields
2007-12-21 6:52 ` ping: " Joel Brobecker
@ 2007-12-21 13:24 ` Daniel Jacobowitz
2007-12-22 6:02 ` Joel Brobecker
0 siblings, 1 reply; 4+ messages in thread
From: Daniel Jacobowitz @ 2007-12-21 13:24 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches
On Fri, Dec 21, 2007 at 10:27:50AM +0400, Joel Brobecker wrote:
> Do we agree that this is the expected behavior? If yes, then I think
> I can commit the testsuite change, since this part is relatively
> straightforward. But I want to make sure that we do have the correct
> behavior!
Expected, certainly. Test looks fine to me.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: ping: [RFA/testsuite] ptype of structs with anonymous type fields
2007-12-21 13:24 ` Daniel Jacobowitz
@ 2007-12-22 6:02 ` Joel Brobecker
0 siblings, 0 replies; 4+ messages in thread
From: Joel Brobecker @ 2007-12-22 6:02 UTC (permalink / raw)
To: gdb-patches
> > Do we agree that this is the expected behavior? If yes, then I think
> > I can commit the testsuite change, since this part is relatively
> > straightforward. But I want to make sure that we do have the correct
> > behavior!
>
> Expected, certainly. Test looks fine to me.
Cool, thanks for confirming it. I checked the patch in.
--
Joel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-12-22 5:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-28 17:51 [RFA/testsuite] ptype of structs with anonymous type fields Joel Brobecker
2007-12-21 6:52 ` ping: " Joel Brobecker
2007-12-21 13:24 ` Daniel Jacobowitz
2007-12-22 6:02 ` Joel Brobecker
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox