I don't know about printing the stack, but you can use gdb to step through your code and find where the segmentation fault occurs. For this, you'll need to compile with g++'s -g option, which turns debugging symbols on or something (basically, it allows you to use gdb to debug). There's some info about gdb
here (and there's a tutorial on how to use it linked from that page).