If the extern crate is compiled with debug symbols, this should just work. Unfortunately, I don't think there is a 'configure' setting for enabling debug symbols for librand and the other 'post-extra' crates yet. It might be worth filing an issue for. Using --disable-optimize is not strictly necessary but debugging certainly works better for un-optimized code.

On 11.04.2014 16:05, Artella Coding wrote:
Suppose I have the following code :

****************************************
extern crate rand;
use rand::{task_rng, Rng};

fn main() {
    let names = ["Alice", "Bob", "Carol"];
    for name in names.iter() {
        let v = task_rng().shuffle(~[1,2,3]);
        for num in v.iter() {
            println!("{:s} says: {:d}", *name, *num);
        }
    }
}
****************************************

Then I can put a breakpoint at shuffle by doing :

rustc -g prog1.rs <http://prog1.rs>
gdb ./prog1
rbreak shuffle
run

However at this point if I try to step into the shuffle function and list the code I get something like :

****************************************
(gdb) where
#0  0x0000000000404fe0 in Rng::shuffle_mut::h20bb47036b05fab8lja::v0.0 ()
#1  0x0000000000404f58 in Rng::shuffle::h5fded7dc864fa562Uia::v0.0 ()
#2  0x0000000000404634 in prog1::main () at prog1.rs:7 <http://prog1.rs:7>
#3  0x000000000043e453 in start::closure.7865 ()
#4  0x00000000004d9263 in rt::task::Task::run::closure.41627 ()
#5  0x00000000004e47dc in rust_try ()
#6 0x00000000004d90c2 in rt::task::Task::run::h50a26072019a80d2fs9::v0.10 ()
#7  0x000000000043e244 in start::h4be0315ccbf00887zvd::v0.10 ()
#8  0x000000000043e034 in lang_start::he9dd0a0b44e890dcTud::v0.10 ()
#9  0x00000000004048bf in main ()
(gdb) list
Line number 13 out of range; prog1.rs <http://prog1.rs> has 12 lines.
****************************************

How can I step through the source of Rng::shuffle? I downloaded the source and when I did "./configure --help" I saw "--disable-optimize don't build optimized rust code". So do I need to build the source with this option? Thanks.


_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to