Re: [Dwarf-Discuss] dwarf stack operator for byte swap.

2019-12-27 Thread Cary Coutant via Dwarf-Discuss
> >>  DW_OP_byte_swap
> >>
> >> The DW_OP_byte_swap operation pops the top stack entry, 
> >> byte swaps the value
> >> and pushes back the swapped value on the dwarf stack.
> >> e.g. so 0x12345678 will become 0x78563412, useful to 
> >> change endianity of raw
> >> data.

While I can see the potential usefulness of a byte-swap operator, it's
not clear to me that it's the right approach for Chirag's case. In his
example, the __gbloffset__ variable has a DW_AT_type which is
explicitly given a DW_AT_endianity attribute. A DWARF consumer would
be expected to pay attention to the byte order when presenting the
value of that variable, but the DW_OP_call4 pushes just the address of
the variable as a value of "generic" type, and DW_OP_deref will
dereference it without knowing its type.

What we're missing is an operator to attach a type to the current
value on top of the stack; if we had that, we could do (DW_OP_call4,
DW_OP_attach_type, DW_OP_deref) and expect the DWARF consumer to honor
the byte order and do a byte swap implicitly when executing the
DW_OP_deref.

Or, we could specify that DW_OP_call* should not only push the result
of evaluating the DW_AT_location of the target DIE, but also attach
the DW_AT_type of the target DIE to that value.

Or, we could add DW_OP_call*_type operators, and leave the original
DW_OP_call* operators to deal with values of generic type only.

-cary
___
Dwarf-Discuss mailing list
Dwarf-Discuss@lists.dwarfstd.org
http://lists.dwarfstd.org/listinfo.cgi/dwarf-discuss-dwarfstd.org


Re: [Dwarf-Discuss] dwarf stack operator for byte swap.

2019-12-16 Thread Michael Eager via Dwarf-Discuss

Hi Chirag --

The DWARF Committee is currently on hiatus.  We will consider resuming 
meetings early next year.


On 12/16/19 4:30 AM, Chirag Patel wrote:

Hello Michael,

Thanks for opening the issue.
Can you kindly provide me with the details about what is the next step, 
till issue gets accepted/rejected or any modifications are needed?


Regards,

Chirag Patel
Software Engineer | Raincode Labs India
Tel: (+91) 080 41159811
Mob: (+91) 9049336744




*From:* Chirag Patel
*Sent:* 11 November 2019 13:07:19
*To:* Michael Eager ; Robinson, Paul 
; Ron Brender 

*Cc:* dwarf-discuss@lists.dwarfstd.org 
*Subject:* RE: [Dwarf-Discuss] dwarf stack operator for byte swap.
Hello Michael,

Thanks for the confirmation. Kindly inform me if anything needs to be 
updated from myside.


Regards,

Chirag Patel
Software Engineer | Raincode Labs India
Tel: (+91) 080 41159811
Mob: (+91) 9049336744
www.raincodelabs.com <http://www.raincodelabs.com>


-Original Message-
From: Michael Eager 
Sent: 08 November 2019 20:04
To: Chirag Patel ; Robinson, Paul 
; Ron Brender 

Cc: dwarf-discuss@lists.dwarfstd.org
Subject: Re: [Dwarf-Discuss] dwarf stack operator for byte swap.

Hi Chirag --

Thanks for your submission.  It was received.

I'm redesigning the DWARF website, in part to address the problem that 
it receives a lot of spam submissions.  Your issue will be posted soon.


On 11/7/19 10:51 PM, Chirag Patel wrote:

Hi all,

I have sent a comment through http://dwarfstd.org/Comment.php

But below is the body of the comment “

Section 2.5.1.7, pg 37

DW_OP_byte_swap to Byte Swap the data on top of the dwarf stack.

==
=

Overview



For debugging binary with bi-endian marked dwarf DIEs and the some 
calculation


depending at runtime, the data needs to be loaded at runtime and needs 
to be


byte swapped. the depended variable DIE here is marked as big-endian 
and the


host is little-endian. The DW_OP_byte_swap will byte swap the raw data 
stored


in top dwarf stack entry.

…

0x0057:   DW_TAG_variable

      DW_AT_name  ("__gbloffset__")

      DW_AT_type  (0x01e5 "int")

      DW_AT_external  (true)

      DW_AT_decl_file ("…")

      DW_AT_decl_line (8)

      DW_AT_location  (DW_OP_addr 0) // pre linkage

      DW_AT_linkage_name  ("_gblsection__")

      DW_AT_endianity (DW_END_big)

0x0170:   DW_TAG_variable

      DW_AT_name  ("VAR1")

      DW_AT_type  (0x010b "fixed.dec.display.72")

      DW_AT_decl_file ("…")

      DW_AT_decl_line (10)

      DW_AT_location  (DW_OP_addr 0x0, DW_OP_call4 0x57, 
DW_OP_deref_size, 4,


DW_OP_dup, DW_OP_constu 0xff, DW_OP_lit0, DW_OP_shl, DW_OP_and, 
DW_OP_lit24, DW_OP_shl, DW_OP_swap, DW_OP_dup, DW_OP_constu 0xff, 
DW_OP_lit8, DW_OP_shl, DW_OP_and, DW_OP_lit8, DW_OP_shl, DW_OP_swap, 
DW_OP_dup, DW_OP_constu 0xff, DW_OP_lit16, DW_OP_shl, DW_OP_and, 
DW_OP_lit8, DW_OP_shr, DW_OP_swap, DW_OP_constu 0xff, DW_OP_lit24, 
DW_OP_shl, DW_OP_and, DW_OP_lit24, DW_OP_shr, DW_OP_swap, DW_OP_or, 
DW_OP_or, DW_OP_or, DW_OP_plus)


      DW_AT_linkage_name  ("VAR1")

In above snippet, the DW_OP_byte_swap will replace,

DW_OP_dup, DW_OP_constu 0xff, DW_OP_lit0, DW_OP_shl, DW_OP_and, 
DW_OP_lit24, DW_OP_shl, DW_OP_swap, DW_OP_dup, DW_OP_constu 0xff, 
DW_OP_lit8, DW_OP_shl, DW_OP_and, DW_OP_lit8, DW_OP_shl, DW_OP_swap, 
DW_OP_dup, DW_OP_constu 0xff, DW_OP_lit16, DW_OP_shl, DW_OP_and, 
DW_OP_lit8, DW_OP_shr, DW_OP_swap, DW_OP_constu 0xff, DW_OP_lit24, 
DW_OP_shl, DW_OP_and, DW_OP_lit24, DW_OP_shr, DW_OP_swap, DW_OP_or, 
DW_OP_or, DW_OP_or number of operations.


Proposed changes to DWARF

---

2.5.1.7 Special Operation

Addition

 DW_OP_byte_swap

     The DW_OP_byte_swap operation pops the top stack 
entry, byte swaps the value


     and pushes back the swapped value on the dwarf stack.

     e.g. so 0x12345678 will become 0x78563412, useful to 
change endianity of raw


     data.

---

“

i did not received any confirmation on my mail. How can I check if it 
was sent correctly?


Kindly inform me if anything more needs to be done from myside.

Regards,

**

*Chirag Patel*

Software Engineer | Raincode Labs India

*Tel*: (+91) 080 41159811

*Mob*: (+91) 9049336744

_www.raincodelabs.com <http://www.raincodelabs.com/>_

linkedin-button <https://in.linkedin.com/in/chirag-patel->

*From:*Chirag Patel 
*Sent:* 29 October 2019 17:10
*To:* Michael Eager ; Robinson, Paul 
; Ron Brender 

*Cc:* dwarf-discuss@lists.dwarfstd.org
*Subject:* Re: [Dwar

Re: [Dwarf-Discuss] dwarf stack operator for byte swap.

2019-12-16 Thread Chirag Patel via Dwarf-Discuss
Hello Michael,

Thanks for opening the issue.
Can you kindly provide me with the details about what is the next step, till 
issue gets accepted/rejected or any modifications are needed?

Regards,

Chirag Patel
Software Engineer | Raincode Labs India
Tel: (+91) 080 41159811
Mob: (+91) 9049336744




From: Chirag Patel
Sent: 11 November 2019 13:07:19
To: Michael Eager ; Robinson, Paul 
; Ron Brender 
Cc: dwarf-discuss@lists.dwarfstd.org 
Subject: RE: [Dwarf-Discuss] dwarf stack operator for byte swap.

Hello Michael,

Thanks for the confirmation. Kindly inform me if anything needs to be updated 
from myside.

Regards,

Chirag Patel
Software Engineer | Raincode Labs India
Tel: (+91) 080 41159811
Mob: (+91) 9049336744
www.raincodelabs.com<http://www.raincodelabs.com>


-Original Message-
From: Michael Eager 
Sent: 08 November 2019 20:04
To: Chirag Patel ; Robinson, Paul 
; Ron Brender 
Cc: dwarf-discuss@lists.dwarfstd.org
Subject: Re: [Dwarf-Discuss] dwarf stack operator for byte swap.

Hi Chirag --

Thanks for your submission.  It was received.

I'm redesigning the DWARF website, in part to address the problem that it 
receives a lot of spam submissions.  Your issue will be posted soon.

On 11/7/19 10:51 PM, Chirag Patel wrote:
> Hi all,
>
> I have sent a comment through http://dwarfstd.org/Comment.php
>
> But below is the body of the comment “
>
> Section 2.5.1.7, pg 37
>
> DW_OP_byte_swap to Byte Swap the data on top of the dwarf stack.
>
> ==
> =
>
> Overview
>
> 
>
> For debugging binary with bi-endian marked dwarf DIEs and the some
> calculation
>
> depending at runtime, the data needs to be loaded at runtime and needs
> to be
>
> byte swapped. the depended variable DIE here is marked as big-endian
> and the
>
> host is little-endian. The DW_OP_byte_swap will byte swap the raw data
> stored
>
> in top dwarf stack entry.
>
> …
>
> 0x0057:   DW_TAG_variable
>
>  DW_AT_name  ("__gbloffset__")
>
>  DW_AT_type  (0x01e5 "int")
>
>  DW_AT_external  (true)
>
>  DW_AT_decl_file ("…")
>
>  DW_AT_decl_line (8)
>
>  DW_AT_location  (DW_OP_addr 0) // pre linkage
>
>  DW_AT_linkage_name  ("_gblsection__")
>
>  DW_AT_endianity (DW_END_big)
>
> 0x0170:   DW_TAG_variable
>
>  DW_AT_name  ("VAR1")
>
>  DW_AT_type  (0x010b "fixed.dec.display.72")
>
>  DW_AT_decl_file ("…")
>
>  DW_AT_decl_line (10)
>
>  DW_AT_location  (DW_OP_addr 0x0, DW_OP_call4 0x57,
> DW_OP_deref_size, 4,
>
> DW_OP_dup, DW_OP_constu 0xff, DW_OP_lit0, DW_OP_shl, DW_OP_and,
> DW_OP_lit24, DW_OP_shl, DW_OP_swap, DW_OP_dup, DW_OP_constu 0xff,
> DW_OP_lit8, DW_OP_shl, DW_OP_and, DW_OP_lit8, DW_OP_shl, DW_OP_swap,
> DW_OP_dup, DW_OP_constu 0xff, DW_OP_lit16, DW_OP_shl, DW_OP_and,
> DW_OP_lit8, DW_OP_shr, DW_OP_swap, DW_OP_constu 0xff, DW_OP_lit24,
> DW_OP_shl, DW_OP_and, DW_OP_lit24, DW_OP_shr, DW_OP_swap, DW_OP_or,
> DW_OP_or, DW_OP_or, DW_OP_plus)
>
>  DW_AT_linkage_name  ("VAR1")
>
> In above snippet, the DW_OP_byte_swap will replace,
>
> DW_OP_dup, DW_OP_constu 0xff, DW_OP_lit0, DW_OP_shl, DW_OP_and,
> DW_OP_lit24, DW_OP_shl, DW_OP_swap, DW_OP_dup, DW_OP_constu 0xff,
> DW_OP_lit8, DW_OP_shl, DW_OP_and, DW_OP_lit8, DW_OP_shl, DW_OP_swap,
> DW_OP_dup, DW_OP_constu 0xff, DW_OP_lit16, DW_OP_shl, DW_OP_and,
> DW_OP_lit8, DW_OP_shr, DW_OP_swap, DW_OP_constu 0xff, DW_OP_lit24,
> DW_OP_shl, DW_OP_and, DW_OP_lit24, DW_OP_shr, DW_OP_swap, DW_OP_or,
> DW_OP_or, DW_OP_or number of operations.
>
> Proposed changes to DWARF
>
> ---
>
> 2.5.1.7 Special Operation
>
> Addition
>
>  DW_OP_byte_swap
>
> The DW_OP_byte_swap operation pops the top stack
> entry, byte swaps the value
>
> and pushes back the swapped value on the dwarf stack.
>
> e.g. so 0x12345678 will become 0x78563412, useful to
> change endianity of raw
>
> data.
>
> ---
>
> “
>
> i did not received any confirmation on my mail. How can I check if it
> was sent correctly?
>
> Kindly inform me if anything more needs to be done from myside.
>
> Regards,
>
> **
>
> *Chirag Patel*
>
> Software Engineer | Raincode Labs India
>
> *Tel*: (+91) 080 41159811
>
> *Mob*: 

Re: [Dwarf-Discuss] dwarf stack operator for byte swap.

2019-11-10 Thread Chirag Patel via Dwarf-Discuss
Hello Michael,

Thanks for the confirmation. Kindly inform me if anything needs to be updated 
from myside.

Regards,

Chirag Patel
Software Engineer | Raincode Labs India 
Tel: (+91) 080 41159811
Mob: (+91) 9049336744
www.raincodelabs.com


-Original Message-
From: Michael Eager  
Sent: 08 November 2019 20:04
To: Chirag Patel ; Robinson, Paul 
; Ron Brender 
Cc: dwarf-discuss@lists.dwarfstd.org
Subject: Re: [Dwarf-Discuss] dwarf stack operator for byte swap.

Hi Chirag --

Thanks for your submission.  It was received.

I'm redesigning the DWARF website, in part to address the problem that it 
receives a lot of spam submissions.  Your issue will be posted soon.

On 11/7/19 10:51 PM, Chirag Patel wrote:
> Hi all,
> 
> I have sent a comment through http://dwarfstd.org/Comment.php
> 
> But below is the body of the comment "
> 
> Section 2.5.1.7, pg 37
> 
> DW_OP_byte_swap to Byte Swap the data on top of the dwarf stack.
> 
> ==
> =
> 
> Overview
> 
> 
> 
> For debugging binary with bi-endian marked dwarf DIEs and the some 
> calculation
> 
> depending at runtime, the data needs to be loaded at runtime and needs 
> to be
> 
> byte swapped. the depended variable DIE here is marked as big-endian 
> and the
> 
> host is little-endian. The DW_OP_byte_swap will byte swap the raw data 
> stored
> 
> in top dwarf stack entry.
> 
> .
> 
> 0x0057:   DW_TAG_variable
> 
>      DW_AT_name  ("__gbloffset__")
> 
>      DW_AT_type  (0x01e5 "int")
> 
>      DW_AT_external  (true)
> 
>      DW_AT_decl_file (".")
> 
>      DW_AT_decl_line (8)
> 
>      DW_AT_location  (DW_OP_addr 0) // pre linkage
> 
>      DW_AT_linkage_name  ("_gblsection__")
> 
>      DW_AT_endianity (DW_END_big)
> 
> 0x0170:   DW_TAG_variable
> 
>      DW_AT_name  ("VAR1")
> 
>      DW_AT_type  (0x010b "fixed.dec.display.72")
> 
>      DW_AT_decl_file (".")
> 
>      DW_AT_decl_line (10)
> 
>      DW_AT_location  (DW_OP_addr 0x0, DW_OP_call4 0x57, 
> DW_OP_deref_size, 4,
> 
> DW_OP_dup, DW_OP_constu 0xff, DW_OP_lit0, DW_OP_shl, DW_OP_and, 
> DW_OP_lit24, DW_OP_shl, DW_OP_swap, DW_OP_dup, DW_OP_constu 0xff, 
> DW_OP_lit8, DW_OP_shl, DW_OP_and, DW_OP_lit8, DW_OP_shl, DW_OP_swap, 
> DW_OP_dup, DW_OP_constu 0xff, DW_OP_lit16, DW_OP_shl, DW_OP_and, 
> DW_OP_lit8, DW_OP_shr, DW_OP_swap, DW_OP_constu 0xff, DW_OP_lit24, 
> DW_OP_shl, DW_OP_and, DW_OP_lit24, DW_OP_shr, DW_OP_swap, DW_OP_or, 
> DW_OP_or, DW_OP_or, DW_OP_plus)
> 
>      DW_AT_linkage_name  ("VAR1")
> 
> In above snippet, the DW_OP_byte_swap will replace,
> 
> DW_OP_dup, DW_OP_constu 0xff, DW_OP_lit0, DW_OP_shl, DW_OP_and, 
> DW_OP_lit24, DW_OP_shl, DW_OP_swap, DW_OP_dup, DW_OP_constu 0xff, 
> DW_OP_lit8, DW_OP_shl, DW_OP_and, DW_OP_lit8, DW_OP_shl, DW_OP_swap, 
> DW_OP_dup, DW_OP_constu 0xff, DW_OP_lit16, DW_OP_shl, DW_OP_and, 
> DW_OP_lit8, DW_OP_shr, DW_OP_swap, DW_OP_constu 0xff, DW_OP_lit24, 
> DW_OP_shl, DW_OP_and, DW_OP_lit24, DW_OP_shr, DW_OP_swap, DW_OP_or, 
> DW_OP_or, DW_OP_or number of operations.
> 
> Proposed changes to DWARF
> 
> ---
> 
> 2.5.1.7 Special Operation
> 
> Addition
> 
>  DW_OP_byte_swap
> 
>     The DW_OP_byte_swap operation pops the top stack 
> entry, byte swaps the value
> 
>     and pushes back the swapped value on the dwarf stack.
> 
>     e.g. so 0x12345678 will become 0x78563412, useful to 
> change endianity of raw
> 
>     data.
> 
> ---
> 
> "
> 
> i did not received any confirmation on my mail. How can I check if it 
> was sent correctly?
> 
> Kindly inform me if anything more needs to be done from myside.
> 
> Regards,
> 
> **
> 
> *Chirag Patel*
> 
> Software Engineer | Raincode Labs India
> 
> *Tel*: (+91) 080 41159811
> 
> *Mob*: (+91) 9049336744
> 
> _www.raincodelabs.com <http://www.raincodelabs.com/>_
> 
> linkedin-button <https://in.linkedin.com/in/chirag-patel->
> 
> *From:*Chirag Patel 
> *Sent:* 29 October 2019 17:10
> *To:* Michael Eager ; Robinson, Paul 
> ; Ron Brender 
> *Cc:* dwarf-discuss@lists.dwarfstd.org
> *Subject:* Re: [Dwarf-Discuss] dwarf stack operator for byte swap.
> 
> Hello,
> 
> Thank you all for prompt reply.
> 
> @Robin

Re: [Dwarf-Discuss] dwarf stack operator for byte swap.

2019-11-08 Thread Michael Eager via Dwarf-Discuss

Hi Chirag --

Thanks for your submission.  It was received.

I'm redesigning the DWARF website, in part to address the problem that 
it receives a lot of spam submissions.  Your issue will be posted soon.


On 11/7/19 10:51 PM, Chirag Patel wrote:

Hi all,

I have sent a comment through http://dwarfstd.org/Comment.php

But below is the body of the comment “

Section 2.5.1.7, pg 37

DW_OP_byte_swap to Byte Swap the data on top of the dwarf stack.

===

Overview



For debugging binary with bi-endian marked dwarf DIEs and the some 
calculation


depending at runtime, the data needs to be loaded at runtime and needs 
to be


byte swapped. the depended variable DIE here is marked as big-endian and the

host is little-endian. The DW_OP_byte_swap will byte swap the raw data 
stored


in top dwarf stack entry.

…

0x0057:   DW_TAG_variable

     DW_AT_name  ("__gbloffset__")

     DW_AT_type  (0x01e5 "int")

     DW_AT_external  (true)

     DW_AT_decl_file ("…")

     DW_AT_decl_line (8)

     DW_AT_location  (DW_OP_addr 0) // pre linkage

     DW_AT_linkage_name  ("_gblsection__")

     DW_AT_endianity (DW_END_big)

0x0170:   DW_TAG_variable

     DW_AT_name  ("VAR1")

     DW_AT_type  (0x010b "fixed.dec.display.72")

     DW_AT_decl_file ("…")

     DW_AT_decl_line (10)

     DW_AT_location  (DW_OP_addr 0x0, DW_OP_call4 0x57, 
DW_OP_deref_size, 4,


DW_OP_dup, DW_OP_constu 0xff, DW_OP_lit0, DW_OP_shl, DW_OP_and, 
DW_OP_lit24, DW_OP_shl, DW_OP_swap, DW_OP_dup, DW_OP_constu 0xff, 
DW_OP_lit8, DW_OP_shl, DW_OP_and, DW_OP_lit8, DW_OP_shl, DW_OP_swap, 
DW_OP_dup, DW_OP_constu 0xff, DW_OP_lit16, DW_OP_shl, DW_OP_and, 
DW_OP_lit8, DW_OP_shr, DW_OP_swap, DW_OP_constu 0xff, DW_OP_lit24, 
DW_OP_shl, DW_OP_and, DW_OP_lit24, DW_OP_shr, DW_OP_swap, DW_OP_or, 
DW_OP_or, DW_OP_or, DW_OP_plus)


     DW_AT_linkage_name  ("VAR1")

In above snippet, the DW_OP_byte_swap will replace,

DW_OP_dup, DW_OP_constu 0xff, DW_OP_lit0, DW_OP_shl, DW_OP_and, 
DW_OP_lit24, DW_OP_shl, DW_OP_swap, DW_OP_dup, DW_OP_constu 0xff, 
DW_OP_lit8, DW_OP_shl, DW_OP_and, DW_OP_lit8, DW_OP_shl, DW_OP_swap, 
DW_OP_dup, DW_OP_constu 0xff, DW_OP_lit16, DW_OP_shl, DW_OP_and, 
DW_OP_lit8, DW_OP_shr, DW_OP_swap, DW_OP_constu 0xff, DW_OP_lit24, 
DW_OP_shl, DW_OP_and, DW_OP_lit24, DW_OP_shr, DW_OP_swap, DW_OP_or, 
DW_OP_or, DW_OP_or number of operations.


Proposed changes to DWARF

---

2.5.1.7 Special Operation

Addition

 DW_OP_byte_swap

    The DW_OP_byte_swap operation pops the top stack entry, 
byte swaps the value


    and pushes back the swapped value on the dwarf stack.

    e.g. so 0x12345678 will become 0x78563412, useful to 
change endianity of raw


    data.

---

“

i did not received any confirmation on my mail. How can I check if it 
was sent correctly?


Kindly inform me if anything more needs to be done from myside.

Regards,

**

*Chirag Patel*

Software Engineer | Raincode Labs India

*Tel*: (+91) 080 41159811

*Mob*: (+91) 9049336744

_www.raincodelabs.com <http://www.raincodelabs.com/>_

linkedin-button <https://in.linkedin.com/in/chirag-patel->

*From:*Chirag Patel 
*Sent:* 29 October 2019 17:10
*To:* Michael Eager ; Robinson, Paul 
; Ron Brender 

*Cc:* dwarf-discuss@lists.dwarfstd.org
*Subject:* Re: [Dwarf-Discuss] dwarf stack operator for byte swap.

Hello,

Thank you all for prompt reply.

@Robinson, Paul <mailto:paul.robin...@sony.com>,

Thanks for the shorter list of operators, but as Michael has suggested, 
i have added a vendor specific operator for that in llvm/lldb(fork of 
our branch anyways).


the operator, pops the stack entry and byte reverses the value and 
pushes it back on the stack.


@Ron Brender <mailto:ron.bren...@gmail.com>

The operator that i was suggesting, pops the top of the stack, reverses 
the bytes and pushes it on the stack(like neg operator does for 
negation).(on second thought the byte_rev would be a better name)


About the other cases you suggested, i sure hope others can help to zero 
in for perfect


design to cover wide range.

@Michael Eager <mailto:ea...@eagercon.com>

Thanks, i have tried the same for our fork of llvm/lldb branch and it 
seems to be working well(for our case :). 
https://gitlab.phidani.be/Chirag.Patel


Thank you all for the helpful comments. i will open a dwarf enhancement 
request soon.


Best Regards.

*Chirag Patel*

Software Engineer*| *Raincode Labs India

Tel: (+91) 080 41159811

Mob: (+91) 9049336744

<https://www.linkedin.co

Re: [Dwarf-Discuss] dwarf stack operator for byte swap.

2019-11-08 Thread Chirag Patel via Dwarf-Discuss
Yes, the size of type I have in mind is generic, size of an address.

Regards,


Chirag Patel
Software Engineer | Raincode Labs India 
Tel: (+91) 080 41159811
Mob: (+91) 9049336744
www.raincodelabs.com


-Original Message-
From: Jakub Jelinek  
Sent: 08 November 2019 13:45
To: Chirag Patel 
Cc: Michael Eager ; Robinson, Paul 
; Ron Brender ; 
dwarf-discuss@lists.dwarfstd.org
Subject: Re: [Dwarf-Discuss] dwarf stack operator for byte swap.

On Fri, Nov 08, 2019 at 06:51:52AM +, Chirag Patel via Dwarf-Discuss wrote:
> Proposed changes to DWARF
> ---
> 
> 2.5.1.7 Special Operation
> 
> Addition
> 
>  DW_OP_byte_swap
> 
>The DW_OP_byte_swap operation pops the top stack entry, byte 
> swaps the value
>and pushes back the swapped value on the dwarf stack.
> 
>e.g. so 0x12345678 will become 0x78563412, useful to change 
> endianity of raw
>data.

With the typed DWARF stack it is clear, the types have well defined size, but 
when using the most common values, where the values have generic type, does 
that mean DW_OP_byte_swap there is bswap64 if address is 64-bit, or
bswap32 if address is 32-bit, or for 16-bit addresses bswap16 etc.?

Jakub

___
Dwarf-Discuss mailing list
Dwarf-Discuss@lists.dwarfstd.org
http://lists.dwarfstd.org/listinfo.cgi/dwarf-discuss-dwarfstd.org


Re: [Dwarf-Discuss] dwarf stack operator for byte swap.

2019-11-08 Thread Jakub Jelinek via Dwarf-Discuss
On Fri, Nov 08, 2019 at 06:51:52AM +, Chirag Patel via Dwarf-Discuss wrote:
> Proposed changes to DWARF
> ---
> 
> 2.5.1.7 Special Operation
> 
> Addition
> 
>  DW_OP_byte_swap
> 
>The DW_OP_byte_swap operation pops the top stack entry, byte 
> swaps the value
>and pushes back the swapped value on the dwarf stack.
> 
>e.g. so 0x12345678 will become 0x78563412, useful to change 
> endianity of raw
>data.

With the typed DWARF stack it is clear, the types have well defined size,
but when using the most common values, where the values have generic type,
does that mean DW_OP_byte_swap there is bswap64 if address is 64-bit, or
bswap32 if address is 32-bit, or for 16-bit addresses bswap16 etc.?

Jakub

___
Dwarf-Discuss mailing list
Dwarf-Discuss@lists.dwarfstd.org
http://lists.dwarfstd.org/listinfo.cgi/dwarf-discuss-dwarfstd.org


Re: [Dwarf-Discuss] dwarf stack operator for byte swap.

2019-11-07 Thread Chirag Patel via Dwarf-Discuss
Hi all,

I have sent a comment through http://dwarfstd.org/Comment.php


But below is the body of the comment "
Section 2.5.1.7, pg 37

DW_OP_byte_swap to Byte Swap the data on top of the dwarf stack.
===

Overview


For debugging binary with bi-endian marked dwarf DIEs and the some calculation
depending at runtime, the data needs to be loaded at runtime and needs to be
byte swapped. the depended variable DIE here is marked as big-endian and the
host is little-endian. The DW_OP_byte_swap will byte swap the raw data stored
in top dwarf stack entry.

...
0x0057:   DW_TAG_variable
DW_AT_name  ("__gbloffset__")
DW_AT_type  (0x01e5 "int")
DW_AT_external  (true)
DW_AT_decl_file ("...")
DW_AT_decl_line (8)
DW_AT_location  (DW_OP_addr 0) // pre linkage
DW_AT_linkage_name  ("_gblsection__")
DW_AT_endianity (DW_END_big)

0x0170:   DW_TAG_variable
DW_AT_name  ("VAR1")
DW_AT_type  (0x010b "fixed.dec.display.72")
DW_AT_decl_file ("...")
DW_AT_decl_line (10)
DW_AT_location  (DW_OP_addr 0x0, DW_OP_call4 0x57, 
DW_OP_deref_size, 4,
DW_OP_dup, DW_OP_constu 0xff, DW_OP_lit0, DW_OP_shl, DW_OP_and, DW_OP_lit24, 
DW_OP_shl, DW_OP_swap, DW_OP_dup, DW_OP_constu 0xff, DW_OP_lit8, DW_OP_shl, 
DW_OP_and, DW_OP_lit8, DW_OP_shl, DW_OP_swap, DW_OP_dup, DW_OP_constu 0xff, 
DW_OP_lit16, DW_OP_shl, DW_OP_and, DW_OP_lit8, DW_OP_shr, DW_OP_swap, 
DW_OP_constu 0xff, DW_OP_lit24, DW_OP_shl, DW_OP_and, DW_OP_lit24, DW_OP_shr, 
DW_OP_swap, DW_OP_or, DW_OP_or, DW_OP_or, DW_OP_plus)
DW_AT_linkage_name  ("VAR1")


In above snippet, the DW_OP_byte_swap will replace,
DW_OP_dup, DW_OP_constu 0xff, DW_OP_lit0, DW_OP_shl, DW_OP_and, DW_OP_lit24, 
DW_OP_shl, DW_OP_swap, DW_OP_dup, DW_OP_constu 0xff, DW_OP_lit8, DW_OP_shl, 
DW_OP_and, DW_OP_lit8, DW_OP_shl, DW_OP_swap, DW_OP_dup, DW_OP_constu 0xff, 
DW_OP_lit16, DW_OP_shl, DW_OP_and, DW_OP_lit8, DW_OP_shr, DW_OP_swap, 
DW_OP_constu 0xff, DW_OP_lit24, DW_OP_shl, DW_OP_and, DW_OP_lit24, DW_OP_shr, 
DW_OP_swap, DW_OP_or, DW_OP_or, DW_OP_or number of operations.


Proposed changes to DWARF
---

2.5.1.7 Special Operation

Addition

 DW_OP_byte_swap

   The DW_OP_byte_swap operation pops the top stack entry, byte 
swaps the value
   and pushes back the swapped value on the dwarf stack.

   e.g. so 0x12345678 will become 0x78563412, useful to change 
endianity of raw
   data.

---

"

i did not received any confirmation on my mail. How can I check if it was sent 
correctly?

Kindly inform me if anything more needs to be done from myside.

Regards,

Chirag Patel
Software Engineer | Raincode Labs India
Tel: (+91) 080 41159811
Mob: (+91) 9049336744
www.raincodelabs.com<http://www.raincodelabs.com/>
[linkedin-button]<https://in.linkedin.com/in/chirag-patel->

From: Chirag Patel 
Sent: 29 October 2019 17:10
To: Michael Eager ; Robinson, Paul 
; Ron Brender 
Cc: dwarf-discuss@lists.dwarfstd.org
Subject: Re: [Dwarf-Discuss] dwarf stack operator for byte swap.

Hello,

Thank you all for prompt reply.

@Robinson, Paul<mailto:paul.robin...@sony.com>,
Thanks for the shorter list of operators, but as Michael has suggested, i have 
added a vendor specific operator for that in llvm/lldb(fork of our branch 
anyways).
the operator, pops the stack entry and byte reverses the value and pushes it 
back on the stack.

@Ron Brender<mailto:ron.bren...@gmail.com>
The operator that i was suggesting, pops the top of the stack, reverses the 
bytes and pushes it on the stack(like neg operator does for negation).(on 
second thought the byte_rev would be a better name)
About the other cases you suggested, i sure hope others can help to zero in for 
perfect
design to cover wide range.

@Michael Eager<mailto:ea...@eagercon.com>
Thanks, i have tried the same for our fork of llvm/lldb branch and it seems to 
be working well(for our case :). https://gitlab.phidani.be/Chirag.Patel

Thank you all for the helpful comments. i will open a dwarf enhancement request 
soon.

Best Regards.






Chirag Patel

Software Engineer | Raincode Labs India

Tel: (+91) 080 41159811

Mob: (+91) 9049336744
<https://www.linkedin.com/in/chirag-patel-/>


<https://www.linkedin.com/in/chirag-patel-/>
[cid:image002.png@01D5962F.4FC9C430]<https://www.linkedin.com/in/chirag-patel-/>



From: Michael Eager mailto:ea...@eagercon.com>>
Sent: 28 October 2019 20:37
To: Robinson, Paul mailto:paul.robin...@sony.com>>; 
Chirag Patel mailto:chi...@rainc

Re: [Dwarf-Discuss] dwarf stack operator for byte swap.

2019-10-29 Thread Chirag Patel via Dwarf-Discuss
Hello,

Thank you all for prompt reply.

@Robinson, Paul<mailto:paul.robin...@sony.com>,
Thanks for the shorter list of operators, but as Michael has suggested, i have 
added a vendor specific operator for that in llvm/lldb(fork of our branch 
anyways).
the operator, pops the stack entry and byte reverses the value and pushes it 
back on the stack.

@Ron Brender<mailto:ron.bren...@gmail.com>
The operator that i was suggesting, pops the top of the stack, reverses the 
bytes and pushes it on the stack(like neg operator does for negation).(on 
second thought the byte_rev would be a better name)
About the other cases you suggested, i sure hope others can help to zero in for 
perfect
design to cover wide range.

@Michael Eager<mailto:ea...@eagercon.com>
Thanks, i have tried the same for our fork of llvm/lldb branch and it seems to 
be working well(for our case :). https://gitlab.phidani.be/Chirag.Patel

Thank you all for the helpful comments. i will open a dwarf enhancement request 
soon.

Best Regards.





Chirag Patel

Software Engineer | Raincode Labs India

Tel: (+91) 080 41159811

Mob: (+91) 9049336744

<http://www.raincodelabs.com/>
<https://www.linkedin.com/in/chirag-patel-/>

[cid:68b118f1-419e-4f8e-a7ba-1d94b0379f85]



From: Michael Eager 
Sent: 28 October 2019 20:37
To: Robinson, Paul ; Chirag Patel 
Cc: dwarf-discuss@lists.dwarfstd.org 
Subject: Re: [Dwarf-Discuss] dwarf stack operator for byte swap.

Hi Chirag --

A byte-swap operator would be a reasonable addition to the DWARF
interpreter.

In addition to writing a proposal as Paul suggests, one option I would
recommend you consider is to create a user-defined operation to perform
this byte-swap operation and give it a value in the range between
DW_OP_lo_user and DW_OP_hi_user.  Of course, this user-defined would
need to be implemented not only in the producer (i.e., compiler) but in
any consumers (i.e., debugger).

When a new version of the DWARF Standard is released, this operation
would be assigned a new value.

On 10/28/19 6:53 AM, Robinson, Paul via Dwarf-Discuss wrote:
> Hello Chirag,
>
> Regarding a byte-swap operation, it seems that you have a reasonable
> use-case on a bi-endian machine.  Feel free to request a new operator on
> the “public comments” page at http://dwarfstd.org/Comment.php
>
> Note that a byte-swap operator would swap all bytes in the top-of-stack
> value, which on your 64-bit machine would of course be a 64-bit value.
> As you want a 32-bit swapped value, you would still need to do a shift
> afterward, but even so, “DW_OP_byte_swap DW_OP_const1u 32 DW_OP_shr”
> would be considerably shorter than what you have to do now.
>
> Of course a new operator would be introduced in a new DWARF revision,
> which is likely to be years away.  In the meantime let me suggest a
> shorter expression for doing the byte-swap operation.  The book
> “Hacker’s Delight” shows a straightforward 32-bit byte swap with masks
> no wider than 16 bits, as follows:
>
> x = (x << 24) | ((x & 0xff00) << 8) | ((x >> 8) &
> 0xff00) | (x >> 24);
>
> Your 64-bit machine will of course use 64-bit values on the expression
> stack, so to keep the result “32-bit clean” we want to do one additional
> mask:
>
> x = ((x & 0xff) << 24) | ((x & 0xff00) << 8) | ((x >> 8)
> & 0xff00) | (x >> 24);
>
> Translating this into a DWARF expression, I get the following:
>
> DW_OP_dup, DW_OP_const1u 0xff, DW_OP_and, DW_OP_lit24,
> DW_OP_shl, DW_OP_swap, DW_OP_dup, DW_OP_const2u 0xff00, DW_OP_and,
> DW_OP_lit8, DW_OP_shl, DW_OP_swap, DW_OP_dup, DW_OP_lit8, DW_OP_shr,
> DW_OP_const2u 0xff00, DW_OP_and, DW_OP_swap, DW_OP_lit24, DW_OP_shr,
> DW_OP_or, DW_OP_or, DW_OP_or
>
> I hope this is helpful to you.
>
> --paulr
>
> *From:* Dwarf-Discuss  *On
> Behalf Of *Chirag Patel via Dwarf-Discuss
> *Sent:* Monday, October 28, 2019 12:47 AM
> *To:* dwarf-discuss@lists.dwarfstd.org
> *Subject:* [Dwarf-Discuss] dwarf stack operator for byte swap.
>
> Hello Dwarf experts.
>
> I am currently working trying to encode dwarf of binaries with having
> bi-endian variables marked with DW_AT_endianity attribute.
>
> The location calculation for some  variable depends on other variable
> with different endianity, also the value of this other variable is known
> at runtime.
>
> At the moment I am using location list to calculate the correct location
> of first variable and list of dwarf operators to reverse the endianity
> of variable “__gbloffset__” in below case (I only needed lower 32 bits
> on 64 bit machine).
>
> 0x01e5: DW_TAG_base_type
>
>   DW_AT_byte_size  (0x04)
>
>DW_AT_encoding  (DW_ATE_sig

Re: [Dwarf-Discuss] dwarf stack operator for byte swap.

2019-10-28 Thread Michael Eager via Dwarf-Discuss

Hi Chirag --

A byte-swap operator would be a reasonable addition to the DWARF 
interpreter.


In addition to writing a proposal as Paul suggests, one option I would 
recommend you consider is to create a user-defined operation to perform 
this byte-swap operation and give it a value in the range between 
DW_OP_lo_user and DW_OP_hi_user.  Of course, this user-defined would 
need to be implemented not only in the producer (i.e., compiler) but in 
any consumers (i.e., debugger).


When a new version of the DWARF Standard is released, this operation 
would be assigned a new value.


On 10/28/19 6:53 AM, Robinson, Paul via Dwarf-Discuss wrote:

Hello Chirag,

Regarding a byte-swap operation, it seems that you have a reasonable 
use-case on a bi-endian machine.  Feel free to request a new operator on 
the “public comments” page at http://dwarfstd.org/Comment.php


Note that a byte-swap operator would swap all bytes in the top-of-stack 
value, which on your 64-bit machine would of course be a 64-bit value.  
As you want a 32-bit swapped value, you would still need to do a shift 
afterward, but even so, “DW_OP_byte_swap DW_OP_const1u 32 DW_OP_shr” 
would be considerably shorter than what you have to do now.


Of course a new operator would be introduced in a new DWARF revision, 
which is likely to be years away.  In the meantime let me suggest a 
shorter expression for doing the byte-swap operation.  The book 
“Hacker’s Delight” shows a straightforward 32-bit byte swap with masks 
no wider than 16 bits, as follows:


    x = (x << 24) | ((x & 0xff00) << 8) | ((x >> 8) & 
0xff00) | (x >> 24);


Your 64-bit machine will of course use 64-bit values on the expression 
stack, so to keep the result “32-bit clean” we want to do one additional 
mask:


    x = ((x & 0xff) << 24) | ((x & 0xff00) << 8) | ((x >> 8) 
& 0xff00) | (x >> 24);


Translating this into a DWARF expression, I get the following:

    DW_OP_dup, DW_OP_const1u 0xff, DW_OP_and, DW_OP_lit24, 
DW_OP_shl, DW_OP_swap, DW_OP_dup, DW_OP_const2u 0xff00, DW_OP_and, 
DW_OP_lit8, DW_OP_shl, DW_OP_swap, DW_OP_dup, DW_OP_lit8, DW_OP_shr, 
DW_OP_const2u 0xff00, DW_OP_and, DW_OP_swap, DW_OP_lit24, DW_OP_shr, 
DW_OP_or, DW_OP_or, DW_OP_or


I hope this is helpful to you.

--paulr

*From:* Dwarf-Discuss  *On 
Behalf Of *Chirag Patel via Dwarf-Discuss

*Sent:* Monday, October 28, 2019 12:47 AM
*To:* dwarf-discuss@lists.dwarfstd.org
*Subject:* [Dwarf-Discuss] dwarf stack operator for byte swap.

Hello Dwarf experts.

I am currently working trying to encode dwarf of binaries with having 
bi-endian variables marked with DW_AT_endianity attribute.


The location calculation for some  variable depends on other variable 
with different endianity, also the value of this other variable is known 
at runtime.


At the moment I am using location list to calculate the correct location 
of first variable and list of dwarf operators to reverse the endianity 
of variable “__gbloffset__” in below case (I only needed lower 32 bits 
on 64 bit machine).


0x01e5: DW_TAG_base_type

  DW_AT_byte_size  (0x04)

   DW_AT_encoding  (DW_ATE_signed)

     DW_AT_name  ("int")

     DW_AT_endianity (DW_END_big)

…

0x0057:   DW_TAG_variable

     DW_AT_name  ("__gbloffset__")

     DW_AT_type  (0x01e5 "int")

     DW_AT_external  (true)

     DW_AT_decl_file ("…")

     DW_AT_decl_line (8)

     DW_AT_location  (DW_OP_addr 0) // pre linkage

     DW_AT_linkage_name  ("_gblsection__")

0x0170:   DW_TAG_variable

     DW_AT_name  ("VAR1")

     DW_AT_type  (0x010b "fixed.dec.display.72")

     DW_AT_decl_file ("…")

     DW_AT_decl_line (10)

     DW_AT_location  (DW_OP_addr 0x0, DW_OP_call4 0x57, 
DW_OP_deref_size, 4,


DW_OP_dup, DW_OP_constu 0xff, DW_OP_lit0, DW_OP_shl, DW_OP_and, 
DW_OP_lit24, DW_OP_shl, DW_OP_swap, DW_OP_dup, DW_OP_constu 0xff, 
DW_OP_lit8, DW_OP_shl, DW_OP_and, DW_OP_lit8, DW_OP_shl, DW_OP_swap, 
DW_OP_dup, DW_OP_constu 0xff, DW_OP_lit16, DW_OP_shl, DW_OP_and, 
DW_OP_lit8, DW_OP_shr, DW_OP_swap, DW_OP_constu 0xff, DW_OP_lit24, 
DW_OP_shl, DW_OP_and, DW_OP_lit24, DW_OP_shr, DW_OP_swap, DW_OP_or, 
DW_OP_or, DW_OP_or, DW_OP_plus)


     DW_AT_linkage_name  ("VAR1")

In above snippet of dwarf dump, I am using yellow highlighted list of 
operators to swap the bytes.


I think there should be a support for DW_OP_byte_swap simple operator to 
accomplice this simple task. Does this idea looks like it can be useful? 
Is there any specific reason why dwarf spec does not have it or I am 
missing something subtle.


I hope I conveyed the idea properly, apologies in adva

Re: [Dwarf-Discuss] dwarf stack operator for byte swap.

2019-10-28 Thread Robinson, Paul via Dwarf-Discuss
Hello Chirag,

Regarding a byte-swap operation, it seems that you have a reasonable use-case 
on a bi-endian machine.  Feel free to request a new operator on the "public 
comments" page at http://dwarfstd.org/Comment.php

Note that a byte-swap operator would swap all bytes in the top-of-stack value, 
which on your 64-bit machine would of course be a 64-bit value.  As you want a 
32-bit swapped value, you would still need to do a shift afterward, but even 
so, "DW_OP_byte_swap DW_OP_const1u 32 DW_OP_shr" would be considerably shorter 
than what you have to do now.

Of course a new operator would be introduced in a new DWARF revision, which is 
likely to be years away.  In the meantime let me suggest a shorter expression 
for doing the byte-swap operation.  The book "Hacker's Delight" shows a 
straightforward 32-bit byte swap with masks no wider than 16 bits, as follows:
   x = (x << 24) | ((x & 0xff00) << 8) | ((x >> 8) & 0xff00) | (x 
>> 24);
Your 64-bit machine will of course use 64-bit values on the expression stack, 
so to keep the result "32-bit clean" we want to do one additional mask:
   x = ((x & 0xff) << 24) | ((x & 0xff00) << 8) | ((x >> 8) & 
0xff00) | (x >> 24);
Translating this into a DWARF expression, I get the following:
   DW_OP_dup, DW_OP_const1u 0xff, DW_OP_and, DW_OP_lit24, 
DW_OP_shl, DW_OP_swap, DW_OP_dup, DW_OP_const2u 0xff00, DW_OP_and, DW_OP_lit8, 
DW_OP_shl, DW_OP_swap, DW_OP_dup, DW_OP_lit8, DW_OP_shr, DW_OP_const2u 0xff00, 
DW_OP_and, DW_OP_swap, DW_OP_lit24, DW_OP_shr, DW_OP_or, DW_OP_or, DW_OP_or

I hope this is helpful to you.
--paulr

From: Dwarf-Discuss  On Behalf Of 
Chirag Patel via Dwarf-Discuss
Sent: Monday, October 28, 2019 12:47 AM
To: dwarf-discuss@lists.dwarfstd.org
Subject: [Dwarf-Discuss] dwarf stack operator for byte swap.

Hello Dwarf experts.

I am currently working trying to encode dwarf of binaries with having bi-endian 
variables marked with DW_AT_endianity attribute.
The location calculation for some  variable depends on other variable with 
different endianity, also the value of this other variable is known at runtime.

At the moment I am using location list to calculate the correct location of 
first variable and list of dwarf operators to reverse the endianity of variable 
"__gbloffset__" in below case (I only needed lower 32 bits on 64 bit machine).

0x01e5: DW_TAG_base_type
 DW_AT_byte_size  (0x04)
  DW_AT_encoding  (DW_ATE_signed)
DW_AT_name  ("int")
DW_AT_endianity (DW_END_big)
...
0x0057:   DW_TAG_variable
DW_AT_name  ("__gbloffset__")
DW_AT_type  (0x01e5 "int")
DW_AT_external  (true)
DW_AT_decl_file ("...")
DW_AT_decl_line (8)
DW_AT_location  (DW_OP_addr 0) // pre linkage
DW_AT_linkage_name  ("_gblsection__")

0x0170:   DW_TAG_variable
DW_AT_name  ("VAR1")
DW_AT_type  (0x010b "fixed.dec.display.72")
DW_AT_decl_file ("...")
DW_AT_decl_line (10)
DW_AT_location  (DW_OP_addr 0x0, DW_OP_call4 0x57, 
DW_OP_deref_size, 4,
DW_OP_dup, DW_OP_constu 0xff, DW_OP_lit0, DW_OP_shl, DW_OP_and, DW_OP_lit24, 
DW_OP_shl, DW_OP_swap, DW_OP_dup, DW_OP_constu 0xff, DW_OP_lit8, DW_OP_shl, 
DW_OP_and, DW_OP_lit8, DW_OP_shl, DW_OP_swap, DW_OP_dup, DW_OP_constu 0xff, 
DW_OP_lit16, DW_OP_shl, DW_OP_and, DW_OP_lit8, DW_OP_shr, DW_OP_swap, 
DW_OP_constu 0xff, DW_OP_lit24, DW_OP_shl, DW_OP_and, DW_OP_lit24, DW_OP_shr, 
DW_OP_swap, DW_OP_or, DW_OP_or, DW_OP_or, DW_OP_plus)
DW_AT_linkage_name  ("VAR1")


In above snippet of dwarf dump, I am using yellow highlighted list of operators 
to swap the bytes.
I think there should be a support for DW_OP_byte_swap simple operator to 
accomplice this simple task. Does this idea looks like it can be useful? Is 
there any specific reason why dwarf spec does not have it or I am missing 
something subtle.

I hope I conveyed the idea properly, apologies in advanced as English is not my 
first language.

Thanks and regards,

Chirag Patel
Software Engineer | Raincode Labs India
Tel: (+91) 080 41159811
Mob: (+91) 9049336744
www.raincodelabs.com<http://www.raincodelabs.com/>
[linkedin-button]<https://in.linkedin.com/in/chirag-patel->

___
Dwarf-Discuss mailing list
Dwarf-Discuss@lists.dwarfstd.org
http://lists.dwarfstd.org/listinfo.cgi/dwarf-discuss-dwarfstd.org


[Dwarf-Discuss] dwarf stack operator for byte swap.

2019-10-28 Thread Chirag Patel via Dwarf-Discuss
Hello Dwarf experts.

I am currently working trying to encode dwarf of binaries with having bi-endian 
variables marked with DW_AT_endianity attribute.
The location calculation for some  variable depends on other variable with 
different endianity, also the value of this other variable is known at runtime.

At the moment I am using location list to calculate the correct location of 
first variable and list of dwarf operators to reverse the endianity of variable 
"__gbloffset__" in below case (I only needed lower 32 bits on 64 bit machine).

0x01e5: DW_TAG_base_type
 DW_AT_byte_size  (0x04)
  DW_AT_encoding  (DW_ATE_signed)
DW_AT_name  ("int")
DW_AT_endianity (DW_END_big)
...
0x0057:   DW_TAG_variable
DW_AT_name  ("__gbloffset__")
DW_AT_type  (0x01e5 "int")
DW_AT_external  (true)
DW_AT_decl_file ("...")
DW_AT_decl_line (8)
DW_AT_location  (DW_OP_addr 0) // pre linkage
DW_AT_linkage_name  ("_gblsection__")

0x0170:   DW_TAG_variable
DW_AT_name  ("VAR1")
DW_AT_type  (0x010b "fixed.dec.display.72")
DW_AT_decl_file ("...")
DW_AT_decl_line (10)
DW_AT_location  (DW_OP_addr 0x0, DW_OP_call4 0x57, 
DW_OP_deref_size, 4,
DW_OP_dup, DW_OP_constu 0xff, DW_OP_lit0, DW_OP_shl, DW_OP_and, DW_OP_lit24, 
DW_OP_shl, DW_OP_swap, DW_OP_dup, DW_OP_constu 0xff, DW_OP_lit8, DW_OP_shl, 
DW_OP_and, DW_OP_lit8, DW_OP_shl, DW_OP_swap, DW_OP_dup, DW_OP_constu 0xff, 
DW_OP_lit16, DW_OP_shl, DW_OP_and, DW_OP_lit8, DW_OP_shr, DW_OP_swap, 
DW_OP_constu 0xff, DW_OP_lit24, DW_OP_shl, DW_OP_and, DW_OP_lit24, DW_OP_shr, 
DW_OP_swap, DW_OP_or, DW_OP_or, DW_OP_or, DW_OP_plus)
DW_AT_linkage_name  ("VAR1")


In above snippet of dwarf dump, I am using yellow highlighted list of operators 
to swap the bytes.
I think there should be a support for DW_OP_byte_swap simple operator to 
accomplice this simple task. Does this idea looks like it can be useful? Is 
there any specific reason why dwarf spec does not have it or I am missing 
something subtle.

I hope I conveyed the idea properly, apologies in advanced as English is not my 
first language.

Thanks and regards,

Chirag Patel
Software Engineer | Raincode Labs India
Tel: (+91) 080 41159811
Mob: (+91) 9049336744
www.raincodelabs.com
[linkedin-button]

___
Dwarf-Discuss mailing list
Dwarf-Discuss@lists.dwarfstd.org
http://lists.dwarfstd.org/listinfo.cgi/dwarf-discuss-dwarfstd.org