Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Patch: Dwarf2 reader -vs- DW_OP_piece
@ 2002-02-21 10:53 Tom Tromey
  2002-02-21 14:09 ` Jim Blandy
  0 siblings, 1 reply; 5+ messages in thread
From: Tom Tromey @ 2002-02-21 10:53 UTC (permalink / raw)
  To: gdb-patches

I just submitted a change that changes gcc's Dwarf-2 output.
It hasn't been approved yet, but of course I'm hoping it will be.
With this change gcc will now generate DW_OP_piece when a value spans
multiple registers.

I came up with a somewhat hacky gdb patch to ignore DW_OP_piece.

I'm hoping this patch is just a stopgap until someone adds real
Dwarf-2 location expression support to gdb.

Ok?

Tom


Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>

	* dwarf2read.c (decode_locdesc): Recognize DW_OP_piece.

Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.48
diff -u -r1.48 dwarf2read.c
--- dwarf2read.c 2002/02/15 22:42:33 1.48
+++ dwarf2read.c 2002/02/21 18:49:43
@@ -5808,6 +5808,7 @@
   int stacki;
   unsigned int bytes_read, unsnd;
   unsigned char op;
+  int last_was_piece = 0;
 
   i = 0;
   stacki = 0;
@@ -5891,8 +5892,13 @@
 	case DW_OP_reg29:
 	case DW_OP_reg30:
 	case DW_OP_reg31:
-	  isreg = 1;
-	  stack[++stacki] = op - DW_OP_reg0;
+	  if (last_was_piece)
+	    last_was_piece = 0;
+	  else
+	    {
+	      isreg = 1;
+	      stack[++stacki] = op - DW_OP_reg0;
+	    }
 	  break;
 
 	case DW_OP_regx:
@@ -6043,6 +6049,14 @@
 	     this using GDB's address_class enum.  */
 	  if (i < size)
 	    complain (&dwarf2_complex_location_expr);
+	  break;
+
+	case DW_OP_piece:
+	  /* For now we essentially ignore this.  We assume it only
+	     occurs when a value spans multiple registers.  */
+	  read_unsigned_leb128 (NULL, (data + i), &bytes_read);
+	  i += bytes_read;
+	  last_was_piece = 1;
 	  break;
 
 	default:


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

* Re: Patch: Dwarf2 reader -vs- DW_OP_piece
  2002-02-21 10:53 Patch: Dwarf2 reader -vs- DW_OP_piece Tom Tromey
@ 2002-02-21 14:09 ` Jim Blandy
  2002-02-21 14:58   ` Tom Tromey
  0 siblings, 1 reply; 5+ messages in thread
From: Jim Blandy @ 2002-02-21 14:09 UTC (permalink / raw)
  To: tromey; +Cc: gdb-patches


Can you explain what sorts of location expressions this is supposed to
help GDB handle?

Tom Tromey <tromey@redhat.com> writes:

> I just submitted a change that changes gcc's Dwarf-2 output.
> It hasn't been approved yet, but of course I'm hoping it will be.
> With this change gcc will now generate DW_OP_piece when a value spans
> multiple registers.
> 
> I came up with a somewhat hacky gdb patch to ignore DW_OP_piece.
> 
> I'm hoping this patch is just a stopgap until someone adds real
> Dwarf-2 location expression support to gdb.
> 
> Ok?
> 
> Tom
> 
> 
> Index: ChangeLog
> from  Tom Tromey  <tromey@redhat.com>
> 
> 	* dwarf2read.c (decode_locdesc): Recognize DW_OP_piece.
> 
> Index: dwarf2read.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/dwarf2read.c,v
> retrieving revision 1.48
> diff -u -r1.48 dwarf2read.c
> --- dwarf2read.c 2002/02/15 22:42:33 1.48
> +++ dwarf2read.c 2002/02/21 18:49:43
> @@ -5808,6 +5808,7 @@
>    int stacki;
>    unsigned int bytes_read, unsnd;
>    unsigned char op;
> +  int last_was_piece = 0;
>  
>    i = 0;
>    stacki = 0;
> @@ -5891,8 +5892,13 @@
>  	case DW_OP_reg29:
>  	case DW_OP_reg30:
>  	case DW_OP_reg31:
> -	  isreg = 1;
> -	  stack[++stacki] = op - DW_OP_reg0;
> +	  if (last_was_piece)
> +	    last_was_piece = 0;
> +	  else
> +	    {
> +	      isreg = 1;
> +	      stack[++stacki] = op - DW_OP_reg0;
> +	    }
>  	  break;
>  
>  	case DW_OP_regx:
> @@ -6043,6 +6049,14 @@
>  	     this using GDB's address_class enum.  */
>  	  if (i < size)
>  	    complain (&dwarf2_complex_location_expr);
> +	  break;
> +
> +	case DW_OP_piece:
> +	  /* For now we essentially ignore this.  We assume it only
> +	     occurs when a value spans multiple registers.  */
> +	  read_unsigned_leb128 (NULL, (data + i), &bytes_read);
> +	  i += bytes_read;
> +	  last_was_piece = 1;
>  	  break;
>  
>  	default:


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

* Re: Patch: Dwarf2 reader -vs- DW_OP_piece
  2002-02-21 14:09 ` Jim Blandy
@ 2002-02-21 14:58   ` Tom Tromey
  2002-02-23 22:15     ` Jim Blandy
  0 siblings, 1 reply; 5+ messages in thread
From: Tom Tromey @ 2002-02-21 14:58 UTC (permalink / raw)
  To: Jim Blandy; +Cc: gdb-patches

>>>>> "Jim" == Jim Blandy <jimb@redhat.com> writes:

Jim> Can you explain what sorts of location expressions this is
Jim> supposed to help GDB handle?

Yes, sorry.

Suppose a value spans multiple registers.  Currently gcc encodes this
as DW_OP_reg for the first register.  However, I believe that is not
fully correct according to the Dwarf-2 spec.

The gcc patch changes the output in this case to a series of
DW_OP_reg/DW_OP_piece instructions.

So previously gcc could generate this for a `long long' value (on x86
Linux):

    DW_OP_reg1

With the patch gcc will now generate:

    DW_OP_reg1
    DW_OP_piece 4
    DW_OP_reg2
    DW_OP_piece 4

Tom


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

* Re: Patch: Dwarf2 reader -vs- DW_OP_piece
  2002-02-21 14:58   ` Tom Tromey
@ 2002-02-23 22:15     ` Jim Blandy
  2002-02-24  9:12       ` Andrew Cagney
  0 siblings, 1 reply; 5+ messages in thread
From: Jim Blandy @ 2002-02-23 22:15 UTC (permalink / raw)
  To: tromey; +Cc: gdb-patches


That makes sense.

Could you change your patch to detect that pattern, verify that the
register numbers are consecutive (according to DWARF2_REG_TO_REGNUM),
return the number of the first register if everything seems right, and
give a dwarf2_complex_location_expr complaint otherwise?

This is a bit more work, but it's more correct.


Tom Tromey <tromey@redhat.com> writes:

> >>>>> "Jim" == Jim Blandy <jimb@redhat.com> writes:
> 
> Jim> Can you explain what sorts of location expressions this is
> Jim> supposed to help GDB handle?
> 
> Yes, sorry.
> 
> Suppose a value spans multiple registers.  Currently gcc encodes this
> as DW_OP_reg for the first register.  However, I believe that is not
> fully correct according to the Dwarf-2 spec.
> 
> The gcc patch changes the output in this case to a series of
> DW_OP_reg/DW_OP_piece instructions.
> 
> So previously gcc could generate this for a `long long' value (on x86
> Linux):
> 
>     DW_OP_reg1
> 
> With the patch gcc will now generate:
> 
>     DW_OP_reg1
>     DW_OP_piece 4
>     DW_OP_reg2
>     DW_OP_piece 4
> 
> Tom


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

* Re: Patch: Dwarf2 reader -vs- DW_OP_piece
  2002-02-23 22:15     ` Jim Blandy
@ 2002-02-24  9:12       ` Andrew Cagney
  0 siblings, 0 replies; 5+ messages in thread
From: Andrew Cagney @ 2002-02-24  9:12 UTC (permalink / raw)
  To: Jim Blandy; +Cc: tromey, gdb-patches

> That makes sense.
> 
> Could you change your patch to detect that pattern, verify that the
> register numbers are consecutive (according to DWARF2_REG_TO_REGNUM),
> return the number of the first register if everything seems right, and
> give a dwarf2_complex_location_expr complaint otherwise?
> 
> This is a bit more work, but it's more correct.

BTW, this assumption is one of the two origins of our good friend (not) 
read_register_bytes().  Sigh.

Andrew




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

end of thread, other threads:[~2002-02-24 17:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-21 10:53 Patch: Dwarf2 reader -vs- DW_OP_piece Tom Tromey
2002-02-21 14:09 ` Jim Blandy
2002-02-21 14:58   ` Tom Tromey
2002-02-23 22:15     ` Jim Blandy
2002-02-24  9:12       ` Andrew Cagney

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