-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support C++ references #81
Comments
On second thought, there's more to it. Adding the type definition is easy, but the tricky part is Although references are physically basically a pointer, logically they are used like the object they refer to. This means that an We'll also need good documentation about the difference between an |
I finally got around to writing up more details on how to go about this. Problem Statementdrgn was originally developed for C, so it's still missing lots of C++ features. One of those missing features is references. The mechanism for implementing references is not specified by the C++ standard. However, they are typically implemented like a pointer: the compiler stores an address which it transparently dereferences when the reference is used. See here and here for some discussions. DWARF seems to assume this implementation; search for "reference type" in the DWARF standard. The goal of this issue is to support reference types and objects with a reference type in drgn. ImplementationTypesdrgn represents types with the Representing reference types in drgn should be fairly straightforward and mostly boilerplate along the lines of how we represent pointer types. The first step is allowing
Then, we need to support parsing reference types from DWARF. Reference types are represented the same as pointer types in DWARF, except that they use the Objectsdrgn represents variables and values with the Objects with a reference type are the trickier part of this task. In some respects, these objects should behave like pointers, and in others, they should behave like the referenced type. BackgroundA
Storing Objects with Reference TypeI think we want to store objects with reference type the same way as we store objects with pointer type: encoded as
Operations on Objects with Reference TypeThere are a couple of fundamental operations that we need to support on objects with reference type:
The remaining operations on references are mostly built on top of these fundamental operations and should behave like in C++:
These operators are mostly defined in There are a couple of extra operations that we may want to support:
The hard part for both of these is defining and naming the API. Pretty-Printing
|
E.g.,
type& foo
. This should be a matter of adding the boilerplate for a new "reference" type kind and parsing it from DWARF. It will be almost identical to a pointer type. The only difference that comes to mind is that a reference type may not refer to a void type (in C++, at least, but maybe we can be more permissive).The text was updated successfully, but these errors were encountered: