The document describes a couple of main issues found when using the
current DWARF 5 version to describe optimized code for SIMD and SIMT
architectures.
Without going much into details described in the document, the main
point is that DWARF version 5 does not allow a proper support for
address spaces and it does not allow a location description to be part
of a DWARF expression, unless it is a leaf node of that expression.
Both issues can be solved in a clean way by introducing a new set of
classes that describe all entry types which can be placed on a DWARF
stack, while keeping a full backward compatibility with the previous
standard version. These entry types can now be either a typed value
or any location description.
Currently, the result of an expression evaluation is kept in a separate
data structure, while with the new approach, it will be always found as
a top element of the DWARF stack. The reason why this approach is
backward compatible is because in version 5, a location description
is only allowed to be a leaf node of the expression or a composite
piece.
Question here is, why do we need a new set of classes and why not just
use the struct value instead?
As it stands, there are couple of issues with using the struct value to
describe a DWARF stack element:
- It is not designed to represent a DWARF location description
specifically, instead it behaves more like unified debug information
format that represents an actual target resource. One example of this
is accessing data of a struct value register location description,
where if the amount of data accessed is larger then the register,
results in accessing more then one register. In DWARF this is not a
valid behavior and locations that span more then one register should be
described as a composite location description.
- There is a tight coupling between struct value and it's type
information, regardless if the data represented is describing a value
(not_lval) or a location description. While the type information
dictates how the data is accessed for a struct value case, in DWARF,
location description doesn't have a type so data access is not bound by
it.
- DWARF values only support much simpler base types, while struct value
can be linked to any type. Admittedly, new classes are still using the
same struct value infrastructure for a value based operations at the
moment, but that is planned to change in the near future.
- struct value register location description requires a frame id
information which makes them unsuitable for CFA expression evaluation.
So, there seems to be a lack of separation of concerns in the design
of a struct value infrastructure, while the new classes are handling
one specific purpose and are completely encapsulated in the expr.c.
Additional benefit of this design is that it makes a step in a
right direction for being able to evaluate DWARF expressions on a
gdbserver side in the near future, which sounds like a desirable thing.
It is also worth mentioning that this new location description
representation is based on a bit granularity (the bit_suboffset class
member) even though the DWARF standard has a very limited support for
it (mostly used for DW_OP_bit_piece operation).
By allowing any location description to define a bit sub-offset of the
location, we are able to give more options for supporting of new
concepts (like the existing packed arrays in Ada language).
In this patch, a new set of classes that describe a DWARF stack element
are added. The new classes are:
- Value - describes a numerical value with a DWARF base type.
- Location description - describes a DWARF location description.
- Undefined location - describes a location that is not defined.
- Memory location - describes a location in memory.
- Register location - describes a register location in a frame
context.
- Implicit location - describes a location that implicitly holds a
value that it describes.
- Implicit pointer - describes a concept of an implicit pointer to
a source variable.
- Composite location - describes a location that is composed from
pieces of other location descriptions.
For now, these classes are just defined, and they are planned to be
used by the following patches.
gdb/ChangeLog:
* dwarf2/expr.c (class dwarf_entry): New class.
(class dwarf_value): New class.
(class dwarf_location): New class.
(class dwarf_undefined): New class.
(class dwarf_memory): New class.
(class dwarf_register): New class.
(class dwarf_implicit): New class.
(class dwarf_implicit_pointer): New class.
(class dwarf_composite): New class.
* value.c (pack_unsigned_long): Expose function.
* value.h (pack_unsigned_long): Expose function.