Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] bitfield-parent-optimized-out: Fix struct definition
@ 2016-11-11 19:37 Andreas Arnez
  2016-11-11 23:27 ` Luis Machado
  0 siblings, 1 reply; 4+ messages in thread
From: Andreas Arnez @ 2016-11-11 19:37 UTC (permalink / raw)
  To: gdb-patches

The "struct S" type in bitfield-parent-optimized-out.exp is declared to
have a size of 4 bytes but to hold two 4-byte members: an int-based
bitfield and a 4-byte int.  Also, both members have the same
data_member_location 2, causing them to overlap and to reach 2 bytes
beyond the structure's boundary.

This is fixed by increasing the structure size to 8 and setting the
first and second member's data_member_location to 0 and 4, respectively.

gdb/testsuite/ChangeLog:

	* gdb.dwarf2/bitfield-parent-optimized-out.exp: Fix DWARF code for
	the definition of struct S.
---
 gdb/testsuite/gdb.dwarf2/bitfield-parent-optimized-out.exp | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/gdb/testsuite/gdb.dwarf2/bitfield-parent-optimized-out.exp b/gdb/testsuite/gdb.dwarf2/bitfield-parent-optimized-out.exp
index 27d8044..b789970 100644
--- a/gdb/testsuite/gdb.dwarf2/bitfield-parent-optimized-out.exp
+++ b/gdb/testsuite/gdb.dwarf2/bitfield-parent-optimized-out.exp
@@ -43,19 +43,18 @@ Dwarf::assemble $asm_file {
 
 	    struct_label: structure_type {
 		{name S}
-		{byte_size 4 DW_FORM_sdata}
+		{byte_size 8 DW_FORM_sdata}
 	    } {
 		member {
 		    {name bitfield}
 		    {type :$int_label}
 		    {bit_size 12 DW_FORM_sdata}
 		    {bit_offset 20 DW_FORM_sdata}
-		    {data_member_location 2 DW_FORM_sdata}
 		}
 		member {
 		    {name intfield}
 		    {type :$int_label}
-		    {data_member_location 2 DW_FORM_sdata}
+		    {data_member_location 4 DW_FORM_sdata}
 		}
 	    }
 
-- 
2.3.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] bitfield-parent-optimized-out: Fix struct definition
  2016-11-11 19:37 [PATCH] bitfield-parent-optimized-out: Fix struct definition Andreas Arnez
@ 2016-11-11 23:27 ` Luis Machado
  2016-11-15 18:12   ` Pedro Alves
  0 siblings, 1 reply; 4+ messages in thread
From: Luis Machado @ 2016-11-11 23:27 UTC (permalink / raw)
  To: Andreas Arnez, gdb-patches, Pedro Alves

On 11/11/2016 01:37 PM, Andreas Arnez wrote:
> The "struct S" type in bitfield-parent-optimized-out.exp is declared to
> have a size of 4 bytes but to hold two 4-byte members: an int-based
> bitfield and a 4-byte int.  Also, both members have the same
> data_member_location 2, causing them to overlap and to reach 2 bytes
> beyond the structure's boundary.
>
> This is fixed by increasing the structure size to 8 and setting the
> first and second member's data_member_location to 0 and 4, respectively.
>
> gdb/testsuite/ChangeLog:
>
> 	* gdb.dwarf2/bitfield-parent-optimized-out.exp: Fix DWARF code for
> 	the definition of struct S.
> ---
>  gdb/testsuite/gdb.dwarf2/bitfield-parent-optimized-out.exp | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/gdb/testsuite/gdb.dwarf2/bitfield-parent-optimized-out.exp b/gdb/testsuite/gdb.dwarf2/bitfield-parent-optimized-out.exp
> index 27d8044..b789970 100644
> --- a/gdb/testsuite/gdb.dwarf2/bitfield-parent-optimized-out.exp
> +++ b/gdb/testsuite/gdb.dwarf2/bitfield-parent-optimized-out.exp
> @@ -43,19 +43,18 @@ Dwarf::assemble $asm_file {
>
>  	    struct_label: structure_type {
>  		{name S}
> -		{byte_size 4 DW_FORM_sdata}
> +		{byte_size 8 DW_FORM_sdata}
>  	    } {
>  		member {
>  		    {name bitfield}
>  		    {type :$int_label}
>  		    {bit_size 12 DW_FORM_sdata}
>  		    {bit_offset 20 DW_FORM_sdata}
> -		    {data_member_location 2 DW_FORM_sdata}
>  		}
>  		member {
>  		    {name intfield}
>  		    {type :$int_label}
> -		    {data_member_location 2 DW_FORM_sdata}
> +		    {data_member_location 4 DW_FORM_sdata}
>  		}
>  	    }
>
>

The patch looks good to me, but i'm wondering if Pedro meant for both 
members to overlap (a union) instead of being two separate members?


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] bitfield-parent-optimized-out: Fix struct definition
  2016-11-11 23:27 ` Luis Machado
@ 2016-11-15 18:12   ` Pedro Alves
  2016-11-15 19:53     ` Andreas Arnez
  0 siblings, 1 reply; 4+ messages in thread
From: Pedro Alves @ 2016-11-15 18:12 UTC (permalink / raw)
  To: Luis Machado, Andreas Arnez, gdb-patches

On 11/11/2016 11:26 PM, Luis Machado wrote:
> On 11/11/2016 01:37 PM, Andreas Arnez wrote:
>> The "struct S" type in bitfield-parent-optimized-out.exp is declared to
>> have a size of 4 bytes but to hold two 4-byte members: an int-based
>> bitfield and a 4-byte int.  Also, both members have the same
>> data_member_location 2, causing them to overlap and to reach 2 bytes
>> beyond the structure's boundary.
>>
>> This is fixed by increasing the structure size to 8 and setting the
>> first and second member's data_member_location to 0 and 4, respectively.
>>
>> gdb/testsuite/ChangeLog:
>>
>>     * gdb.dwarf2/bitfield-parent-optimized-out.exp: Fix DWARF code for
>>     the definition of struct S.
>> ---
>>  gdb/testsuite/gdb.dwarf2/bitfield-parent-optimized-out.exp | 5 ++---
>>  1 file changed, 2 insertions(+), 3 deletions(-)
>>
>> diff --git
>> a/gdb/testsuite/gdb.dwarf2/bitfield-parent-optimized-out.exp
>> b/gdb/testsuite/gdb.dwarf2/bitfield-parent-optimized-out.exp
>> index 27d8044..b789970 100644
>> --- a/gdb/testsuite/gdb.dwarf2/bitfield-parent-optimized-out.exp
>> +++ b/gdb/testsuite/gdb.dwarf2/bitfield-parent-optimized-out.exp
>> @@ -43,19 +43,18 @@ Dwarf::assemble $asm_file {
>>
>>          struct_label: structure_type {
>>          {name S}
>> -        {byte_size 4 DW_FORM_sdata}
>> +        {byte_size 8 DW_FORM_sdata}
>>          } {
>>          member {
>>              {name bitfield}
>>              {type :$int_label}
>>              {bit_size 12 DW_FORM_sdata}
>>              {bit_offset 20 DW_FORM_sdata}
>> -            {data_member_location 2 DW_FORM_sdata}
>>          }
>>          member {
>>              {name intfield}
>>              {type :$int_label}
>> -            {data_member_location 2 DW_FORM_sdata}
>> +            {data_member_location 4 DW_FORM_sdata}
>>          }
>>          }
>>
>>
> 
> The patch looks good to me, but i'm wondering if Pedro meant for both
> members to overlap (a union) instead of being two separate members?

Possibly; I don't remember.  If the changed test would still trigger
the old GDB bug, then I'm fine with the change.

Thanks,
Pedro Alves


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] bitfield-parent-optimized-out: Fix struct definition
  2016-11-15 18:12   ` Pedro Alves
@ 2016-11-15 19:53     ` Andreas Arnez
  0 siblings, 0 replies; 4+ messages in thread
From: Andreas Arnez @ 2016-11-15 19:53 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Luis Machado, gdb-patches

On Tue, Nov 15 2016, Pedro Alves wrote:

> On 11/11/2016 11:26 PM, Luis Machado wrote:

>> The patch looks good to me, but i'm wondering if Pedro meant for both
>> members to overlap (a union) instead of being two separate members?
>
> Possibly; I don't remember.  If the changed test would still trigger
> the old GDB bug, then I'm fine with the change.

Yes, the bug is triggered both with the old and new version of
bitfield-parent-optimized-out.exp:

  p var.bitfield
  ERROR: Process no longer exists
  UNRESOLVED: gdb.dwarf2/bitfield-parent-optimized-out.exp: p var.bitfield
  ERROR: Couldn't send p var.intfield to GDB.
  UNRESOLVED: gdb.dwarf2/bitfield-parent-optimized-out.exp: p var.intfield

Thanks, pushed.

--
Andreas


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-11-15 19:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-11 19:37 [PATCH] bitfield-parent-optimized-out: Fix struct definition Andreas Arnez
2016-11-11 23:27 ` Luis Machado
2016-11-15 18:12   ` Pedro Alves
2016-11-15 19:53     ` Andreas Arnez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox