* [PATCH]: ptype of pointer to typedef
@ 2012-09-03 9:46 Andrew Burgess
2012-09-03 10:49 ` Andrew Burgess
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Andrew Burgess @ 2012-09-03 9:46 UTC (permalink / raw)
To: gdb-patches
Given a test program like this:
typedef char (my_char_array) [4];
my_char_array array = {'a', 'b', 'c', 'd'};
my_char_array *array_p = &array;
typedef char my_char;
my_char array2 [4] = {'a', 'b', 'c', 'd'};
my_char (*array2_p)[4] = &array2;
int
main ( void )
{
return 0;
}
Then in gdb:
(gdb) ptype array2_p
type = char (*)[4]
(gdb) ptype array_p
type = char *)[4]
Notice in the array_p case, the missing "(" character.
Patch below include a fix, and a test case. The test case builds on an
existing test that was marked as xfail in a few cases, I've extended the
xfail to cover the new case I've added, but I have no way to check if
this is the right thing to do or not, I'm happy to change the patch if
anyone has an opinion.
Ok to commit?
Cheers,
Andrew
gdb/ChangeLog
2012-09-03 Andrew Bugess <aburgess@broadcom.com>
* c-typeprint.c (c_type_print_varspec_prefix): Pass through the
passed_a_ptr flag when displaying typedef types.
diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index c2a775a..b51ced8 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -306,7 +306,7 @@ c_type_print_varspec_prefix (struct type *type,
case TYPE_CODE_TYPEDEF:
c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type),
- stream, show, 0, 0);
+ stream, show, passed_a_ptr, 0);
break;
case TYPE_CODE_UNDEF:
gdb/testsuite/ChangeLog
2012-09-03 Andrew Burgess <aburgess@broadcom.com>
* gdb.base/ptype.exp: Test ptype on a pointer to a typedef.
diff --git a/gdb/testsuite/gdb.base/ptype.exp
b/gdb/testsuite/gdb.base/ptype.exp
index c7bede2..0eef17d 100644
--- a/gdb/testsuite/gdb.base/ptype.exp
+++ b/gdb/testsuite/gdb.base/ptype.exp
@@ -370,6 +370,10 @@ if {!$gcc_compiled} then { setup_xfail "rs6000-*-*"
"i*86-*
if {$hp_aCC_compiler} {setup_xfail "hppa*-*-*"}
gdb_test "ptype t_char_array" "type = (|unsigned )char \\\[0?\\\]"
+if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" "i*86-*-sysv4*" }
+if {$hp_aCC_compiler} {setup_xfail "hppa*-*-*"}
+gdb_test "ptype pv_char_array" "type = (|unsigned )char
\\(\\*\\)\\\[0?\\\]"
+
#
##
## test ptype command with pointers
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH]: ptype of pointer to typedef
2012-09-03 9:46 [PATCH]: ptype of pointer to typedef Andrew Burgess
@ 2012-09-03 10:49 ` Andrew Burgess
2012-09-10 9:54 ` Andrew Burgess
2012-09-10 15:44 ` Tom Tromey
2 siblings, 0 replies; 5+ messages in thread
From: Andrew Burgess @ 2012-09-03 10:49 UTC (permalink / raw)
To: gdb-patches
On 03/09/2012 10:45 AM, Andrew Burgess wrote:
> 2012-09-03 Andrew Bugess <aburgess@broadcom.com>
>
That's slightly embarrassing, apparently I can't spell my own name :(
Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH]: ptype of pointer to typedef
2012-09-03 9:46 [PATCH]: ptype of pointer to typedef Andrew Burgess
2012-09-03 10:49 ` Andrew Burgess
@ 2012-09-10 9:54 ` Andrew Burgess
2012-09-10 15:44 ` Tom Tromey
2 siblings, 0 replies; 5+ messages in thread
From: Andrew Burgess @ 2012-09-10 9:54 UTC (permalink / raw)
To: gdb-patches
Ping!
On 03/09/2012 10:45 AM, Andrew Burgess wrote:
> Given a test program like this:
>
> typedef char (my_char_array) [4];
> my_char_array array = {'a', 'b', 'c', 'd'};
> my_char_array *array_p = &array;
>
> typedef char my_char;
> my_char array2 [4] = {'a', 'b', 'c', 'd'};
> my_char (*array2_p)[4] = &array2;
>
> int
> main ( void )
> {
> return 0;
> }
>
> Then in gdb:
>
> (gdb) ptype array2_p
> type = char (*)[4]
> (gdb) ptype array_p
> type = char *)[4]
>
>
> Notice in the array_p case, the missing "(" character.
>
> Patch below include a fix, and a test case. The test case builds on an
> existing test that was marked as xfail in a few cases, I've extended the
> xfail to cover the new case I've added, but I have no way to check if
> this is the right thing to do or not, I'm happy to change the patch if
> anyone has an opinion.
>
> Ok to commit?
>
> Cheers,
> Andrew
>
> gdb/ChangeLog
>
> 2012-09-03 Andrew Bugess <aburgess@broadcom.com>
>
> * c-typeprint.c (c_type_print_varspec_prefix): Pass through the
> passed_a_ptr flag when displaying typedef types.
>
> diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
> index c2a775a..b51ced8 100644
> --- a/gdb/c-typeprint.c
> +++ b/gdb/c-typeprint.c
> @@ -306,7 +306,7 @@ c_type_print_varspec_prefix (struct type *type,
>
> case TYPE_CODE_TYPEDEF:
> c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type),
> - stream, show, 0, 0);
> + stream, show, passed_a_ptr, 0);
> break;
>
> case TYPE_CODE_UNDEF:
>
> gdb/testsuite/ChangeLog
>
> 2012-09-03 Andrew Burgess <aburgess@broadcom.com>
>
> * gdb.base/ptype.exp: Test ptype on a pointer to a typedef.
>
> diff --git a/gdb/testsuite/gdb.base/ptype.exp
> b/gdb/testsuite/gdb.base/ptype.exp
> index c7bede2..0eef17d 100644
> --- a/gdb/testsuite/gdb.base/ptype.exp
> +++ b/gdb/testsuite/gdb.base/ptype.exp
> @@ -370,6 +370,10 @@ if {!$gcc_compiled} then { setup_xfail "rs6000-*-*"
> "i*86-*
> if {$hp_aCC_compiler} {setup_xfail "hppa*-*-*"}
> gdb_test "ptype t_char_array" "type = (|unsigned )char \\\[0?\\\]"
>
> +if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" "i*86-*-sysv4*" }
> +if {$hp_aCC_compiler} {setup_xfail "hppa*-*-*"}
> +gdb_test "ptype pv_char_array" "type = (|unsigned )char
> \\(\\*\\)\\\[0?\\\]"
> +
> #
> ##
> ## test ptype command with pointers
>
>
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH]: ptype of pointer to typedef
2012-09-03 9:46 [PATCH]: ptype of pointer to typedef Andrew Burgess
2012-09-03 10:49 ` Andrew Burgess
2012-09-10 9:54 ` Andrew Burgess
@ 2012-09-10 15:44 ` Tom Tromey
2012-09-11 9:05 ` Andrew Burgess
2 siblings, 1 reply; 5+ messages in thread
From: Tom Tromey @ 2012-09-10 15:44 UTC (permalink / raw)
To: Andrew Burgess; +Cc: gdb-patches
>>>>> "Andrew" == Andrew Burgess <aburgess@broadcom.com> writes:
Andrew> The test case builds on an existing test that was marked as
Andrew> xfail in a few cases, I've extended the xfail to cover the new
Andrew> case I've added, but I have no way to check if this is the right
Andrew> thing to do or not, I'm happy to change the patch if anyone has
Andrew> an opinion.
I would just drop the xfails.
If they are needed, somebody with the affected environment can write them.
The patch is ok with that change.
Andrew> +gdb_test "ptype pv_char_array" "type = (|unsigned )char
Andrew> \\(\\*\\)\\\[0?\\\]"
Andrew> +
Your email got wrapped somehow.
Tom
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH]: ptype of pointer to typedef
2012-09-10 15:44 ` Tom Tromey
@ 2012-09-11 9:05 ` Andrew Burgess
0 siblings, 0 replies; 5+ messages in thread
From: Andrew Burgess @ 2012-09-11 9:05 UTC (permalink / raw)
To: gdb-patches
On 10/09/2012 4:44 PM, Tom Tromey wrote:
>>>>>> "Andrew" == Andrew Burgess <aburgess@broadcom.com> writes:
>
> Andrew> The test case builds on an existing test that was marked as
> Andrew> xfail in a few cases, I've extended the xfail to cover the new
> Andrew> case I've added, but I have no way to check if this is the right
> Andrew> thing to do or not, I'm happy to change the patch if anyone has
> Andrew> an opinion.
>
> I would just drop the xfails.
> If they are needed, somebody with the affected environment can write them.
Done.
>
> The patch is ok with that change.
>
> Andrew> +gdb_test "ptype pv_char_array" "type = (|unsigned )char
> Andrew> \\(\\*\\)\\\[0?\\\]"
> Andrew> +
>
> Your email got wrapped somehow.
Apologies.
Committed with the above change.
Thanks,
Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-09-11 9:05 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-03 9:46 [PATCH]: ptype of pointer to typedef Andrew Burgess
2012-09-03 10:49 ` Andrew Burgess
2012-09-10 9:54 ` Andrew Burgess
2012-09-10 15:44 ` Tom Tromey
2012-09-11 9:05 ` Andrew Burgess
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox