Associate source file position with closures #10350

Closed
orenbenkiki opened this Issue Nov 8, 2013 · 5 comments

Projects

None yet

4 participants

@orenbenkiki

Allow the source file and line number to be shown in stack traces (e.g. in GDB). See https://mail.mozilla.org/pipermail/rust-dev/2013-November/006356.html

@jdm
Contributor
jdm commented Nov 8, 2013

Are you building with -Z debug-info ? That should make source files and line numbers show up.

@cmr
Contributor
cmr commented Nov 8, 2013

This shouldn't be that hard, I don't think. gdb would just need to know to dereference the fn pointer and look for debuginfo where it points to.

@cmr
Contributor
cmr commented Nov 8, 2013

Given:

foo.rs:

pub fn bar(x: || -> int) -> int {
    x()
}

bar.rs:

extern mod foo;

fn main() {
    let mut y = 2;
    let x = || {
        42 * 7 + y
    };
    y = 5;
    foo::bar(x);
}

Compiling with rustc -Z extra-debug-info --lib foo.rs; rustc -L . -Z extra-debug-info bar.rs, and breaking on foo::bar, I do get file/line numbers in the stack trace for the closure.

@sanxiyn
Member
sanxiyn commented Nov 8, 2013

Does someone have a non-working case?

@orenbenkiki

My bad, I followed up on the thread not realizing -Z debug-info solves the problem. Now, if there was a flag to get stack trace outside GDB... but that's another issue.

Thanks and apologies for needlessly opening the issue.

@orenbenkiki orenbenkiki closed this Nov 8, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment