addition of vendor dwarf operator extension.

Hello all,

There is one enhancement request open for dwarfv5, http://dwarfstd.org/ShowIssue.php?issue=191107.1

The request is for addition of dwarf expression operator to swap the top of the dwarf stack, the response seems positive but it may take some time till v6.

I like to add that operator as vendor extension but I am not sure how to go about it for llvm/lldb. Currently I am using it as vendor specific extension on our local fork.

Does adding it as vender specific extension seems like a good idea? If yes please provide me the details about adding specific vendor.

Regards,

Chirag Patel

Software Engineer | Raincode Labs India

Tel: (+91) 080 41159811

Mob: (+91) 9049336744

www.raincodelabs.com

image003.png

There are some vendor extensions already in LLVM/LLDB, though I guess the main question would be: what’s the motivation?

image003.png

Hello,

Thanks for prompt reply.

Motivation,

In case of debugging of bi-endian dwarf and value known at runtime some of the raw values needs to be byte swapped to change the endianity. We have a llvm based compiler which generates such dwarf, TAG_variable marked as big endian and debugging on little endian host using lldb. The listed operator on dwarf issues does that, one operator instead of list of operators.

Proposal,

Addition of listed dwarf operator as vender extension in llvm/lldb till it gets released.

Regards,

Chirag Patel

Software Engineer | Raincode Labs India

Tel: (+91) 080 41159811

Mob: (+91) 9049336744

www.raincodelabs.com

image001.png

image002.png

Does this have a significant impact on total DWARF size or performance that you’ve observed/have data about?

image001.png

image002.png

Below is a snippet of the dwarf info that we generate,

0x00000057: DW_TAG_variable

DW_AT_name (“gbloffset”)

DW_AT_type (0x000001e5 “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)

0x00000170: DW_TAG_variable

DW_AT_name (“VAR1”)

DW_AT_type (0x0000010b “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 code for location calculation of “VAR1” we change the endianity of “gbloffset” var, it is 32 bit value on 64-bit machine.

image003.png

image002.png

image003.png

I understand the specific savings, but do you have a sense of how much this occurs overall for DWARF of some non-trivial program (like the clang binary)?

I know it’s verbose - but it’s not especially expensive to maintain the emission of all those bytes (they’d be in a constant array you’d copy into the location expression, I assume - written once) so if there’s not much overall size savings and not much parsing savings I’d be inclined to wait until such a thing were standardized rather than introducing an extension.

That’s just my tendency on that - quite possible other folks (CC’d) feel differently.

image003.png

image002.png

image003.png

In addition to a number of things on the thread I’d like to see this supported in gdb as well if we’re going to emit it.

Thanks!

-eric

image003.png