Jump to content
  • Advertisement
Sign in to follow this  
SW INC

Function Backtrace

This topic is 4863 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

with out using a debugger does any one know how to get a function backtrace? or know of an article talking about how this is done? i'm using devcpp and c++ but all my debuggers are crap and i want to have this done within my program ps any one know a good debugger?

Share this post


Link to post
Share on other sites
Advertisement
There is an interesting article at C/C++ User's Journal (http://www.cuj.com/documents/s=9153/cuj0311antony/cuj0311antony.htm).
ELF which logs exceptions for you and provides a backtracing option. Interesting article. Tho you will need an account to actually read it all Oo.

Share this post


Link to post
Share on other sites
I use Eclipse with the CDT plugin which has a great debugger. It runs atop the same compiler as DevC++ (the MinGW port of GCC). You can even use the debugger directly:

void crash() {
int * invalid = 0;
*invalid = 3; //access 0x00000000 to cause a segfault/access violation
}

int main () {
crash();
}




**** Incremental build of configuration Debug for project test.28 ****

make -k all
'Building file: ../main.cc'
g++ -O0 -g3 -Wall -c -fmessage-length=0 -omain.o ../main.cc
'Finished building: ../main.cc'
' '
'Building target: test.28.exe'
g++ -o test.28.exe main.o
'Finished building: test.28.exe'
Build complete for project test.28


Key flags here: -O0 turns off optimizations, -g3 turns on full line/function debugging info.

C:\eclipse\workspace\test.28>gdb Debug\test.28
GNU gdb 5.2.1
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i686-pc-mingw32"...
(gdb) run
Starting program: C:\eclipse\workspace\test.28/Debug\test.28.exe

Program received signal SIGSEGV, Segmentation fault.
0x004012e0 in crash() () at ../main.cc:3 # "address in function at file:line"
3 *invalid = 3;
(gdb) bt # This prints out a full backtrace
#0 0x004012e0 in crash() () at ../main.cc:3
#1 0x00401317 in main () at ../main.cc:7
(gdb) quit
The program is running. Exit anyway? (y or n) y

C:\eclipse\workspace\test.28>_

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!