Jump to content
  • Advertisement
Sign in to follow this  
fir

callstack trace in c

This topic is 1493 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

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)

 

Share this post


Link to post
Share on other sites
Advertisement

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?

Share this post


Link to post
Share on other sites

use a debugger.

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

Edited by fir

Share this post


Link to post
Share on other sites

 

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.

Edited by KnolanCross

Share this post


Link to post
Share on other sites

 

 

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)

Share this post


Link to post
Share on other sites

 

 

 

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.

Share this post


Link to post
Share on other sites

This topic is 1493 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.

Guest
This topic is now closed to further replies.
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!