You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DWARF specifies the location of a variable (local or global) with a "location description". See section 2.6 in the DWARF 5 specification. A location description is essentially a series of instructions that, when executed, gives the address or value of the desired variable. drgn has code that evaluates a location description and translates it into a drgn object: see drgn_object_from_dwarf_location() and drgn_eval_dwarf_expression().
DWARF location descriptions have an operation, DW_OP_implicit_pointer (section 2.6.1.1.4 in the DWARF 5 spec), which means that a pointer has been optimized out, but the value that it points to can still be described. DW_OP_implicit_pointer is a standardized version of a GNU extension, DW_OP_GNU_implicit_pointer. drgn does not yet support either of these operations.
Example
Consider the following (contrived) source file compiled with gcc -O2:
The compiler has no reason to actually allocate val on the stack, and therefore no meaningful address to assign to src. The DWARF information reflects that. The location list for val indicates that its location is not known but it has a value of 5:
As stated above, drgn does not support DW_OP_implicit_pointer or its GNU predecessor, DW_OP_GNU_implicit_pointer. This is mainly because drgn does not have a way to represent an "implicit pointer". So, this project has two parts:
Add the concept of an implicit pointer to drgn's object model. Specifically:
a. Add a new enum drgn_object_kind (named something like DRGN_OBJECT_IMPLICIT_POINTER).
b. Store the pointed-to value for implicit pointer objects in struct drgn_object::value.
c. Add a drgn_object_set_implicit_pointer() function to create implicit pointer objects.
d. Update all of the object operations to handle implicit pointer objects (e.g., you can't get the value of an implicit pointer object with drgn_object_read() or drgn_object_read_value(), but you can dereference it with drgn_object_dereference() or drgn_object_member_dereference()).
Implement support for DW_OP_implicit_pointer and DW_OP_GNU_implicit_pointer on top of implicit pointer objects.
The text was updated successfully, but these errors were encountered:
osandov
changed the title
Support DW_OP_implicit_pointer/DW_OP_GNU_implicit_pointer
Support DW_OP_implicit_pointer/DW_OP_GNU_implicit_pointerJul 3, 2023
Background
DWARF specifies the location of a variable (local or global) with a "location description". See section 2.6 in the DWARF 5 specification. A location description is essentially a series of instructions that, when executed, gives the address or value of the desired variable. drgn has code that evaluates a location description and translates it into a drgn object: see
drgn_object_from_dwarf_location()
anddrgn_eval_dwarf_expression()
.DWARF location descriptions have an operation,
DW_OP_implicit_pointer
(section 2.6.1.1.4 in the DWARF 5 spec), which means that a pointer has been optimized out, but the value that it points to can still be described.DW_OP_implicit_pointer
is a standardized version of a GNU extension,DW_OP_GNU_implicit_pointer
. drgn does not yet support either of these operations.Example
Consider the following (contrived) source file compiled with
gcc -O2
:And the generated assembly code:
The compiler has no reason to actually allocate
val
on the stack, and therefore no meaningful address to assign tosrc
. The DWARF information reflects that. The location list forval
indicates that its location is not known but it has a value of 5:The location list for
src
indicates that its pointer value is not known, but the value pointed to is DIE 5a (which isval
):Problem Statement
As stated above, drgn does not support
DW_OP_implicit_pointer
or its GNU predecessor,DW_OP_GNU_implicit_pointer
. This is mainly because drgn does not have a way to represent an "implicit pointer". So, this project has two parts:a. Add a new
enum drgn_object_kind
(named something likeDRGN_OBJECT_IMPLICIT_POINTER
).b. Store the pointed-to value for implicit pointer objects in
struct drgn_object::value
.c. Add a
drgn_object_set_implicit_pointer()
function to create implicit pointer objects.d. Update all of the object operations to handle implicit pointer objects (e.g., you can't get the value of an implicit pointer object with
drgn_object_read()
ordrgn_object_read_value()
, but you can dereference it withdrgn_object_dereference()
ordrgn_object_member_dereference()
).DW_OP_implicit_pointer
andDW_OP_GNU_implicit_pointer
on top of implicit pointer objects.The text was updated successfully, but these errors were encountered: