Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


callstack trace in c


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • This topic is locked This topic is locked
25 replies to this topic

#1 fir   Members   -  Reputation: -456

Like
0Likes
Like

Posted 17 June 2014 - 05:53 AM

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)

 



Sponsor:

#2 Tribad   Members   -  Reputation: 887

Like
7Likes
Like

Posted 17 June 2014 - 06:40 AM

use a debugger.



#3 KnolanCross   Members   -  Reputation: 1364

Like
5Likes
Like

Posted 17 June 2014 - 07:16 AM

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).


#4 Álvaro   Crossbones+   -  Reputation: 13929

Like
4Likes
Like

Posted 17 June 2014 - 07:32 AM

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

#5 fir   Members   -  Reputation: -456

Like
0Likes
Like

Posted 17 June 2014 - 09:05 AM

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?



#6 fir   Members   -  Reputation: -456

Like
0Likes
Like

Posted 17 June 2014 - 09:07 AM

use a debugger.

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


Edited by fir, 17 June 2014 - 09:08 AM.


#7 Tribad   Members   -  Reputation: 887

Like
2Likes
Like

Posted 17 June 2014 - 09:17 AM

gdb

#8 KnolanCross   Members   -  Reputation: 1364

Like
0Likes
Like

Posted 17 June 2014 - 10:54 AM

 

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, 17 June 2014 - 10:54 AM.

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


#9 fir   Members   -  Reputation: -456

Like
-19Likes
Like

Posted 17 June 2014 - 11:07 AM

 

 

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)



#10 KnolanCross   Members   -  Reputation: 1364

Like
1Likes
Like

Posted 17 June 2014 - 11:22 AM

 

 

 

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).


#11 fir   Members   -  Reputation: -456

Like
0Likes
Like

Posted 17 June 2014 - 11:29 AM

 

 

 

 

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)



#12 Tribad   Members   -  Reputation: 887

Like
3Likes
Like

Posted 17 June 2014 - 11:48 AM

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.

#13 KnolanCross   Members   -  Reputation: 1364

Like
3Likes
Like

Posted 17 June 2014 - 12:01 PM

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


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


#14 Paradigm Shifter   Crossbones+   -  Reputation: 5438

Like
3Likes
Like

Posted 17 June 2014 - 12:05 PM

Which is handy because you can assert in destructors which would be illegal if it called exit.
"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

#15 Tribad   Members   -  Reputation: 887

Like
0Likes
Like

Posted 17 June 2014 - 12:06 PM

Ok hit.
But for fir I say now. Break on abort and you can inspect the application state

#16 Tribad   Members   -  Reputation: 887

Like
0Likes
Like

Posted 17 June 2014 - 12:12 PM

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.

#17 Aardvajk   Crossbones+   -  Reputation: 6239

Like
15Likes
Like

Posted 17 June 2014 - 12:14 PM

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.

#18 fir   Members   -  Reputation: -456

Like
-19Likes
Like

Posted 17 June 2014 - 12:35 PM

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.



#19 phil_t   Crossbones+   -  Reputation: 4109

Like
8Likes
Like

Posted 17 June 2014 - 12:37 PM


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.



#20 fir   Members   -  Reputation: -456

Like
-9Likes
Like

Posted 17 June 2014 - 12:44 PM

 


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))   )






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS