Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd debug representation of trait objects #1563
Comments
ghost
assigned
jdm
Apr 12, 2012
This comment has been minimized.
This comment has been minimized.
|
What would a debug representation of a Trait be? I think of a Trait as a purely compile-time entity that is erased by the time you get to runtime. @jdm Is this specifically for @trait objects (in which case, yes, I agree we would want to expose the vtable to the debugger?) If so, then I'll clear up the bug title and description. |
This comment has been minimized.
This comment has been minimized.
|
Yes, I think scoping this to cover trait objects (of the ~ and @ variety) would be fine. |
This comment has been minimized.
This comment has been minimized.
|
According to i.e. this is still valid, properly tagged and milestoned, 2013-06-19. |
This comment has been minimized.
This comment has been minimized.
|
Triage visit; deferring to @michaelwoerister. |
This comment has been minimized.
This comment has been minimized.
It is still NYI but should be tackled some time this month. |
This comment has been minimized.
This comment has been minimized.
Update:As of PR #9168 there is some basic support for trait objects. A trait object pointer is described as a struct with the correct size (two pointers) and the correct name ({sigil}{mutability}{trait name}) and is placed in the correct namespace. The interior of this "fat pointer" is not described any further yet. What is missing is the description of the trait's methods. I don't know enough about how they are actually implemented to say much about that. |
This comment has been minimized.
This comment has been minimized.
|
Not 1.0, but high |
This comment has been minimized.
This comment has been minimized.
|
@michaelwoerister: By the way, the new vtable layout is |
This comment has been minimized.
This comment has been minimized.
|
This has got more complicated with DST since you can have objects like |
thestinger
removed
the
I-completion
label
Sep 16, 2014
This comment has been minimized.
This comment has been minimized.
|
Triage bump: unsure what the status is of this today. |
This comment has been minimized.
This comment has been minimized.
|
still needs doing |
This comment has been minimized.
This comment has been minimized.
|
We could do the following: (2) Describe trait pointers ( (3) Implement custom GDB/LLDB commands in Python that, given a fat pointer, use the pointer value and type information to print the vtable. That's not perfect but could be done with the current means available. The symbol names of the functions pointed to by the vtable should also indicate the actual runtime type of the trait object. |
This comment has been minimized.
This comment has been minimized.
|
Only in builds with debug info (i.e., not release builds) and only by a pretty tiny amount |
brson
added
C-enhancement
T-compiler
labels
Jul 14, 2016
This comment has been minimized.
This comment has been minimized.
|
Triage: still needs doing. cc @Manishearth @tromey P-low |
brson
added
the
P-low
label
Jul 14, 2016
This comment has been minimized.
This comment has been minimized.
|
This is both |
alexcrichton
removed
the
P-medium
label
Jul 14, 2016
This comment has been minimized.
This comment has been minimized.
|
Removing P-medium |
This comment has been minimized.
This comment has been minimized.
|
I looked into this a bit recently. What I hope to do is:
Then a debugger can do the following to print a trait object pointer: if a value's type has a vtable, fetch the vtable from the inferior, look up the vtable's address in the DWARF to find the vtable type, and then use the concrete type to decode the payload pointer. |
Mark-Simulacrum
added
C-feature-request
and removed
C-enhancement
labels
Jun 23, 2017
This comment has been minimized.
This comment has been minimized.
|
I'm working on this. I have an LLVM patch to let rustc emit a small DWARF extension (the |
This comment has been minimized.
This comment has been minimized.
|
First success today:
|
This comment has been minimized.
This comment has been minimized.
|
Exciting! |
This comment has been minimized.
This comment has been minimized.
|
LLVM patch is here: http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20171016/495458.html |
This comment has been minimized.
This comment has been minimized.
|
Moved to phabricator; might be simpler to follow there as well: https://reviews.llvm.org/D39503 |
tromey
added a commit
to tromey/rust
that referenced
this issue
Nov 9, 2017
tromey
added a commit
to tromey/rust
that referenced
this issue
Nov 13, 2017
tromey
added a commit
to tromey/rust
that referenced
this issue
Nov 13, 2017
tromey
added a commit
to tromey/rust
that referenced
this issue
Nov 15, 2017
This comment has been minimized.
This comment has been minimized.
|
gdb patch for printing trait objects is here: https://sourceware.org/ml/gdb-patches/2017-11/msg00289.html |
This comment has been minimized.
This comment has been minimized.
|
Part 2 can be done by describing the fields of the vtable. I haven't looked at the rustc bits to see how difficult this is yet. The |
This comment has been minimized.
This comment has been minimized.
|
Version 2 of the gdb patch is here: https://sourceware.org/ml/gdb-patches/2017-11/msg00369.html |
This comment has been minimized.
This comment has been minimized.
|
The gdb patch is in now, but I think this issue should be left open, as there's still the other vtable task to implement. |
This comment has been minimized.
This comment has been minimized.
|
@tromey does the "vtable task" require gdb changes or just rustc changes? |
This comment has been minimized.
This comment has been minimized.
Ideally I think it would require both; however just doing the rustc bits would be a good start (and this has to come first anyhow). The task here is to have rustc emit a full description of the vtable in the DWARF -- so, the type and name of each member. |
jdm commentedJan 19, 2012
Updated descrption
Trait objects (
~Tand@TwhereTis a trait) are objects that hide their implementation and carry a virtual method dispatch table (i.e. vtable).So, two things:
info vtblor perhapsinfo vtable). It would be cool if we could massage our debug info so that gdb can just print out our vtables too, the same way.Original description
There is none.