Debugging a crash in *rustc* using gdb

I’m working on a port of rust to another platform and I’m trying to debug a crash in one of the internal functions.

I built a copy of gdb 7.12.1 and was trying to figure out the syntax for specifying types when printing values.

This seems to work for the most part:

(gdb) ptype syntax::ast::Ident
type = struct syntax::ast::Ident {
  name: syntax::symbol::Symbol,
  ctxt: syntax::ext::hygiene::SyntaxContext,

However, some cases produce unexpected results:

(gdb) ptype syntax::ast::Mod  
type = struct syntax::ast::Mod {
  RUST$ENUM$DISR: syntax::ast::ItemKind,
  __0: syntax::ast::Mod,

Does not match what I expect from src/libsyntax/

pub struct Mod {
    /// A span from the first token past `{` to the last token until `}`.
    /// For `mod foo;`, the inner span ranges from the first token
    /// to the last token in the external file.
    pub inner: Span,
    pub items: Vec<P<Item>>,

Is this expected? What are the caveats when attempting to debug the rust compiler itself? The rust compiler was built with debug info and without optimizations enabled for debugging purposes.

Your ptype is showing the enum variant ItemKind::Mod and not the type Mod, both are from syntax::ast.

It looks like Rust should give the variants a name that includes the enum name, to keep the namespaces separate.

Yep, this looks like a bug in the rust gdb support then. Thanks for finding the matching type.

Right now, I'd like to find out if there's some workaround to disambiguate between the enum Mod and the struct Mod.

Please file bugs like this in gdb bugzilla. Feel free to CC me if you like. Thanks.

1 Like

I filed bug 21097 in the gdb bug tracker. Thanks.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.