Last active
December 24, 2015 05:09
-
-
Save luqmana/6748487 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-> % rustc foo.rs --lib -Z extra-debug-info | |
-> % ls | |
foo.c foo.rs libfoo-102129e09d96658-0.0.so | |
-> % gcc foo.c -g -L. -lfoo-102129e09d96658-0.0 -o foo | |
-> % LD_LIBRARY_PATH=. ./foo | |
[1] 30770 segmentation fault LD_LIBRARY_PATH=. ./foo | |
-> % LD_LIBRARY_PATH=. gdb ./foo | |
GNU gdb (GDB) 7.4.1-debian | |
Reading symbols from /tmp/foo...done. | |
(gdb) r | |
Starting program: /tmp/foo | |
Program received signal SIGSEGV, Segmentation fault. | |
0x00007ffff7259ad6 in rt::crate_map::do_iter_crate_map::h6b1c6179b73ad9aU::v0.9$x2dpre () from /usr/lib/rustc/x86_64-unknown-linux-gnu/lib/libstd-6c65cf4b443341b1-0.9-pre.so | |
(gdb) bt | |
#0 0x00007ffff7259ad6 in rt::crate_map::do_iter_crate_map::h6b1c6179b73ad9aU::v0.9$x2dpre () from /usr/lib/rustc/x86_64-unknown-linux-gnu/lib/libstd-6c65cf4b443341b1-0.9-pre.so | |
#1 0x00007ffff72592e1 in rt::crate_map::iter_crate_map::hbc873f29d5cd8e2eab::v0.9$x2dpre () from /usr/lib/rustc/x86_64-unknown-linux-gnu/lib/libstd-6c65cf4b443341b1-0.9-pre.so | |
#2 0x00007ffff7259024 in rt::logging::update_log_settings::h96b0e2f2fcfa63baG::v0.9$x2dpre () from /usr/lib/rustc/x86_64-unknown-linux-gnu/lib/libstd-6c65cf4b443341b1-0.9-pre.so | |
#3 0x00007ffff7261186 in rt::init::h37a1594521261df4a1::v0.9$x2dpre () from /usr/lib/rustc/x86_64-unknown-linux-gnu/lib/libstd-6c65cf4b443341b1-0.9-pre.so | |
#4 0x00007ffff72081c8 in rt::start::h58116eb259fa490aR::v0.9$x2dpre () from /usr/lib/rustc/x86_64-unknown-linux-gnu/lib/libstd-6c65cf4b443341b1-0.9-pre.so | |
#5 0x00007ffff7bd9b80 in foo::do_stuff () at foo.rs:7 | |
#6 0x00007ffff7bd9af7 in do_stuff () from ./libfoo-102129e09d96658-0.0.so | |
#7 0x00000000004006dc in main (argc=1, argv=0x7fffffffe7c8) at foo.c:5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern int do_stuff(int argc, char** argv); | |
int main(int argc, char** argv) { | |
do_stuff(argc, argv); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[link(name = "foo", vers = "0.0")]; | |
extern mod std; | |
#[no_mangle] | |
pub extern fn do_stuff(argc: int, argv: **u8) -> int { | |
std::rt::start(argc, argv, stuff) | |
} | |
fn stuff() { | |
// stuff | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment