callstack trace in c

Started by
24 comments, last by ApochPiQ 9 years, 10 months ago

Is there some way to obtain it in c - sometimes (not even every month but sometimes) i got mysterious div by zero or null pointer and then this callstack could be usable to localize where it is - if no i know only that i got division by zero as a one of my 1000 divisions somewhere and is troublesome to check it "is it here or is it there and so on) ... ? (I dont even remember if come c debbugger shows that as i got no one)

Advertisement

use a debugger.

What you want is called core dump file. It is a file with a stack and all the memory used in your program when it died.

Remember to compile your program with debug flag; removing optimization flags may be a good idea too.

Currently working on a scene editor for ORX (http://orx-project.org), using kivy (http://kivy.org).

If you are programming in Linux or Mac OS X, you can use `backtrace'.

What you want is called core dump file. It is a file with a stack and all the memory used in your program when it died.

Remember to compile your program with debug flag; removing optimization flags may be a good idea too.

it not necessary dies, often it is my assertion alert for example in the function normalize for a given vector or check for a null string pointer in my base drawing routine - if vector length is zero then i got an assertion in normalize function but still got no idea who is the parent of that - co c debuggers show this info?

use a debugger.

which one? (i am using 32 bit mingw) will this debugger show this info?

gdb

use a debugger.

which one? (i am using 32 bit mingw) will this debugger show this info?

Are you using code blocks? If so F5 places breakpoints and and F8 starts the Debug mode.

You can replace the exception handling with an assetion, the program will die in the assertion when it fails, though it is easier to use a breakpoint if you know it will happen soon.

Currently working on a scene editor for ORX (http://orx-project.org), using kivy (http://kivy.org).

use a debugger.

which one? (i am using 32 bit mingw) will this debugger show this info?

Are you using code blocks? If so F5 places breakpoints and and F8 starts the Debug mode.

You can replace the exception handling with an assetion, the program will die in the assertion when it fails, though it is easier to use a breakpoint if you know it will happen soon.

tribad suggests that gdb can do print call stack but im not sure if i should belive it as this man is providing exceptionaly lame answers usually

breakpoints will not help me as i understand (or if i set the breakpoint on my alert the callstack will show?)

also asserts in normalize() will not help me to localize parent - I mean if i would help if i would pass the parrent name down to normalize but this is strange - not to do

I feel need for this callstack rarely and some environments imo make id bad to show it all thetime but it would be helpful from time to time

(it seems so)

use a debugger.

which one? (i am using 32 bit mingw) will this debugger show this info?

Are you using code blocks? If so F5 places breakpoints and and F8 starts the Debug mode.

You can replace the exception handling with an assetion, the program will die in the assertion when it fails, though it is easier to use a breakpoint if you know it will happen soon.

tribad suggests that gdb can do print call stack but im not sure if i should belive it as this man is providing exceptionaly lame answers usually

breakpoints will not help me as i understand (or if i set the breakpoint on my alert the callstack will show?)

also asserts in normalize() will not help me to localize parent - I mean if i would help if i would pass the parrent name down to normalize but this is strange - not to do

I feel need for this callstack rarely and some environments imo make id bad to show it all thetime but it would be helpful from time to time

(it seems so)

GDB is debugger, it can freeze your program in a certain state and allow you to inspect the value of each variable, as well as the stack. While the program is frozen you can go up and down the stack to check for any value, including parents.

Currently working on a scene editor for ORX (http://orx-project.org), using kivy (http://kivy.org).

This topic is closed to new replies.

Advertisement