Skip to content

Investigate replacing most of the debugger pretty-printing scripts with traits. #65564

Open
@eddyb

Description

@eddyb

In the case of Vec<T> and String, it would be possible to have e.g.:

impl<'a, T> DebuggerView<'a> for Vec<T> {
    type View = &'a [T];
    fn debugger_view(&'a self) -> Self::View { &self[..] }
}
impl<'a> DebuggerView<'a> for String {
    type View = &'a str;
    fn debugger_view(&'a self) -> Self::View { &self[..] }
}

We would then need:

  • support for pretty-printing &[T] and &str
  • a way to encode <X as DebuggerView>::debugger_view in X's debuginfo
    • i.e. a symbol name, or maybe we can make symbol names based on DWARF type IDs?
  • support for going through <X as DebuggerView>::debugger_view for pretty-printing
    • the method signature above should be relatively simple to call

I suspect there are better APIs that could accommodate more complex data structures, but I'm not sure what the limitation of the pretty-printer scripts are, around being able to call arbitrary functions.

There's also the possibility that we could encode this sort of information as data, instead of compiling it into functions, but that's probably a lot more work.

cc @michaelwoerister

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-debuginfoArea: Debugging information in compiled programs (DWARF, PDB, etc.)E-hardCall for participation: Hard difficulty. Experience needed to fix: A lot.E-needs-designThis issue needs exploration and design to see how and if we can fix/implement itE-needs-investigationCall for partcipation: This issues needs some investigation to determine current statusP-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.WG-debuggingWorking group: Bad Rust debugging experiences

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions