Sign in to follow this  

callstack trace in c

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

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

 

 

 

 

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.

 

okay, i never needed a debugger (seemed always unhandy as some tools are unhendy - also this gnu profiler gprof - i tested that but it was far more worse than my hand profiling) but maybe i will try later if thic can help in such cases, tnx for info)

Share this post


Link to post
Share on other sites
An assert contains a call to exit, not an exception. With a debugger you can simply set a breakpoint on the exit function even it is somewhere hidden in the libraries. If the assert failed, exit is called and the executions stops because of the breakpoint. Afterward you can inspect the state of your application.

You are very lame because you do not even try to use the simpliest tools, because they are not "handy", but all time asks for help. You can even try ddd as debugger frontend or may qt-creator for debugging or one of the other dozen of debuggers and analyzistools available.

Share this post


Link to post
Share on other sites

An assert contains a call to exit, not an exception. With a debugger you can simply set a breakpoint on the exit function even it is somewhere hidden in the libraries. If the assert failed, exit is called and the executions stops because of the breakpoint. Afterward you can inspect the state of your application.

You are very lame because you do not even try to use the simpliest tools, because they are not "handy", but all time asks for help. You can even try ddd as debugger frontend or may qt-creator for debugging or one of the other dozen of debuggers and analyzistools available.

 

Actually, assert has a call to abort, not exit, this is the reason it will create core. wink.png

Share this post


Link to post
Share on other sites
If you would use a web search engine and searches for "debugging assert failed" gives you tons of answers. But it ist mostly not handy.

Share this post


Link to post
Share on other sites

You post here with a question you could trivially google, then when someone is kind enough to answer you insult them and say you don't believe them.

Grow the f**k up.

 

googlin is not talking - talking can drive you to some thoughts and has many nice properties tat googling dont have - if you dont understand it Grow the f**k up.

Share this post


Link to post
Share on other sites

 


okay, i never needed a debugger (seemed always unhandy as some tools are unhendy - also this gnu profiler gprof - i tested that but it was far more worse than my hand profiling) but maybe i will try later if thic can help in such cases, tnx for info)

 

How on earth do you code/write games without a debugger? You must be wasting tons and tons of your own time.

 

its easy - i do not debug

 

(95% if not 99.5% of my errors is localized in the last edition place so i dont need to debug (if by debug you understand 'localize' (the error))   )

Share this post


Link to post
Share on other sites
Debugging means change the software from a behaviuor that has not been requested to one that has been requested. No need for debugging would me you never fail. That I surely do not believe :D

Share this post


Link to post
Share on other sites

Debugging means change the software from a behaviuor that has not been requested to one that has been requested. No need for debugging would me you never fail. That I surely do not believe biggrin.png

debugging is localizing, if you got it localized this is just coding

(there is also element of reading / reverse engineering something - something close to debugging*)

 

* but this (i mean sensoring the unspoiled code) I do yet more rare than debuging - debugging is like fever for programmer - should be avoided

Edited by fir

Share this post


Link to post
Share on other sites
Anyways. Only if you never make a mistake you never must localize. You may minimize the area by only search the last changes. But you must localize. I name it debugging.

Share this post


Link to post
Share on other sites

Anyways. Only if you never make a mistake you never must localize. You may minimize the area by only search the last changes. But you must localize. I name it debugging.

this is called compile error not debugging

 

sometimes it is wrong runtime behavior - but i do not need to localize it - this is not debugging there

 

real debugging is more rare thing, sometimes i need to do that but this is rare (dont know how often but for sure it is not todays activity maybe not even not one in a whole week (dont rememver) (today i got such damn fatal case. lost whole damn hour on this - but it is not often, and this was becouse i was doing reshaping an larger amount

of code, not normal building up)

Share this post


Link to post
Share on other sites
How many lines of code you think you create in a week error free? Sounds that you never make mistakes and everything works as you wanted it to.

Share this post


Link to post
Share on other sites

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