Skip to content
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

No lldb/gdb pretty printers for HashMap #41082

Closed
jrmuizel opened this issue Apr 5, 2017 · 18 comments
Closed

No lldb/gdb pretty printers for HashMap #41082

jrmuizel opened this issue Apr 5, 2017 · 18 comments
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue.

Comments

@jrmuizel
Copy link
Contributor

jrmuizel commented Apr 5, 2017

These would be very handy to have.

@steveklabnik steveklabnik added C-enhancement Category: An issue proposing an enhancement or a PR with one. T-tools labels Apr 5, 2017
@michaelwoerister
Copy link
Member

PRs are always welcome! :)

@alexcrichton alexcrichton added T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. and removed T-tools labels May 22, 2017
@gilescope
Copy link
Contributor

If no one is on this I'll take a crack at it for lldb at least...

@gilescope
Copy link
Contributor

Am wondering if there's a better way to do the python lldb formatters... would it be a crazy idea to call out from python to a rust lib that bound to the std lib? That way you could cast the pointer to a hash table and not need to know what the structure of the hashmap was when pulling out the data for visualisation. In particular it wouldn't break if the internals were re-organised. Or would this be too recursive? @alexcrichton is it worth a shot?

@alexcrichton
Copy link
Member

I don't have much experience myself with how that'd be implemented, but I'd imagine that the overhead of trying to distribute a custom .so and dealing with cross-debugged situations that things could get hairy :(. I think it's fine though to just hardcode the layout into the gdb pretty printers, we'd just update it whenever we change libstd.

@gilescope
Copy link
Contributor

So close. I can identify the chunk of raw memory that holds the k/v pair (they're immediately after the array of hashes in memory), but LLDB doesn't know the type info so can't figure out where the key finishes and the value begins. Alas the marker is phantom and has a size of 0. The best I can do is print out that chunk of memory for each k/v pair as lldb doesn't seem to know anything about the types. All queries to SBType.GetTemplateArgumentType don't seem to do much for tuples... The unqualified type string shows the types of the pair as text, but mapping that to types LLDB understood would probably be unmaintainable.

@michaelwoerister
Copy link
Member

Maybe you can extract the pointee type out of the pointer type to the chunk of memory?

@gilescope
Copy link
Contributor

I think the pointer doesn't have the required type info as it's pointing to the start of the hashes rather than the pairs after that. Zooming out a little, is there an lldb branch where a rust plugin is being developed? I've checked out and built lldb and there's nothing rust specific at the moment. I'm hoping there's a c++ guru that's half way through an implementation, but its just not on trunk/head?

@tromey
Copy link
Contributor

tromey commented May 7, 2018

Zooming out a little, is there an lldb branch where a rust plugin is being developed?

https://github.com/tromey/lldb/tree/rust. Not ready for users yet but if you have specific issues you can file a bug to get it on my to-do list.

@artemmukhin
Copy link
Contributor

Is there any progress on this issue?

I suppose it is impossible to get the key (value) type from a HashMap, because it is even impossible to get a generic type from an empty struct S<T>. I'm not sure, but probably the compiler should use Substs from ty::Adt inside prepare_struct_metadata (from src/librustc_codegen_llvm/debuginfo/metadata.rs), like inside prepare_tuple_metadata?
@tromey could you please look at this?

@tromey
Copy link
Contributor

tromey commented Nov 9, 2018

@tromey could you please look at this?

I'm not totally sure which aspect you are thinking of here, but if you mean finding the actual types of generic parameters, I am working on that in #55010.

@estebank
Copy link
Contributor

estebank commented Nov 9, 2018

I believe that once that is merged, it should enable decoding the actual values using the type info, right? So this ticket would remain open until that work is done.

@tromey
Copy link
Contributor

tromey commented Nov 21, 2018

I believe that once that is merged, it should enable decoding the actual values using the type info, right? So this ticket would remain open until that work is done.

Yes, that's correct.

@ebkalderon
Copy link
Contributor

Looks like #55010 has been merged and seems to be available on stable. Has anyone started tackling this issue?

@artemmukhin
Copy link
Contributor

@ebkalderon Recently I've implemented pretty-printers for HashMap/HashSet for both lldb and gdb. I'm going to replace current rustc's pretty-printers with new ones which I develop for IntelliJ Rust, and hope I'll have enough time to make such PR soon.

@ebkalderon
Copy link
Contributor

@ortem Awesome! Thanks for the rapid response. Is there any way to help speed the implementation along?

@artemmukhin
Copy link
Contributor

@ebkalderon If you'd like to help me, I'd be happy to open a very draft PR right now :) I've never contributed rustc and don't know its architecture well, so it would be really helpful if someone checks code that new pretty-printers can affect.

#60826

@steveklabnik
Copy link
Member

Did #72357 close this?

@artemmukhin
Copy link
Contributor

@steveklabnik Yes, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

9 participants