-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
gdb needs to know what traits a type implements #33014
Comments
It occurred to me later that for operator overloading, I could perhaps just compute the method name directly in gdb. For example, However, there doesn't seem to be a way to tell whether this is I think it is still necessary to have information about traits attached to types, for other calls via traits. |
I thought I would write up a plan here; I probably am going to stop working on this, but this can serve as a guide to anyone picking it up in the future. The basic idea is to represent a concrete I started on an LLVM patch here: https://github.com/tromey/llvm/tree/interface-type. However, this patch is incomplete, as it does not allow interfaces to be attached to subroutine types, pointer types, or scalar types. Adding those would require a bigger change. Maybe the cleanest way would be to let the type base class hold any interface types. However, this is a pain due to the way this part of LLVM has been written. So perhaps handling this case-by-case on the concrete subclasses is simpler in practice. This approach will also require a small DWARF extension. DWARF 5, section 5.7.3, says:
This language is specific to class/structure/interface types. However, for Rust, this restriction should be lifted. It would make sense to file this as a DWARF issue; however, it may be best to wait until any patches have landed in LLVM first. |
Not sure why this is a low priority item: I came across it as a result of trying to inspect Being able to debug basic variables is kind of a critical feature for any language, I would have thought. Or am I missing something? Is this bug report very narrow and is there another issue relating to the broader requirement to inspect variables in a debugger? |
This issue is specifically about traits. |
Thanks for the quick reply:
Examining self.parent.is_some() results in the error. |
I'd like to make operator overloading work for Rust in gdb. That is, I'd like something like
print x+y
to call the appropriate method on theAdd
trait. I'd also like to make ordinary method calls work, where the method is defined in some trait that is impl'd for the concrete type of the object.Right now I think this can't be done. There is no information in the debug info about what traits are implemented by a type.
Consider:
Here
i32
is described as just a base type:I think this might be a good spot to list all the impl'd traits. Perhaps they can be represented as DWARF interfaces; or maybe some Rust extension to DWARF would be preferable.
i32.What
is emitted as a namespace:... but this isn't directly useful as it would require an iteration over all the namespace DIEs looking for matches. Maybe I could do this; but I'd rather not as it is very inefficient.
The text was updated successfully, but these errors were encountered: