Skip to main content
gamedev.net
🔒 Locked

C Stack Probe

Started by jwalker Aug 6, 2002 at 2:15 AM 6 replies 1.1k views
Original Post
jwalker
jwalker
what exactly is a stack probe? is there any benefit turning of stack probes? Its my duty, to please that booty ! - John Shaft
Void
Void
I seen an article that uses stack probes to insert code that do a log of the functions called at runtime (a stackwalk actually). If I can find the link at home, I will post it.

Other than that, never seen it being mentioned elsewhere.
LessBread
LessBread
From what I gather a stack probe tests if a variable is declared on the stack or on the heap. And calling free/delete on objects on the stack can lead to troubles. Here''s a snippet: Object On The Stack

There''s a win32 stackwalk program here: Stackwalk

"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
jwalker
jwalker
why would anyone want to call delete on a variable on the stack??
my understanding is that when you call new, the pointer returned is on a heap.

if i dont want to use the stack probe, is there any performance gain if i remove stack probes?

Its my duty, to please that booty ! - John Shaft
Void
Void
My bad, it was profiling, not stackwalking.

http://www.fengyuan.com/article/profile.html
jwalker
jwalker
other than profiling and ''walking the stack'' whats the benefit of leaving in the stack probe in release mode ?

Its my duty, to please that booty ! - John Shaft
LessBread
LessBread
quote:
Original post by jwalker
why would anyone want to call delete on a variable on the stack??
my understanding is that when you call new, the pointer returned is on a heap.

That was the gist of the intro, the ensuing discussion touches on that point. Use of the crt memory debugging functions is invoked.

quote:
Original post by jwalker
if i dont want to use the stack probe, is there any performance gain if i remove stack probes?

I would think so, but if it''s just a compiler setting, try it and test the result.

That profiling code is tasty. Too bad it''s compiler dependent.

"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
LessBread
LessBread
quote:
Original post by jwalker
other than profiling and ''walking the stack'' whats the benefit of leaving in the stack probe in release mode ?


Limit the use of the stack probe to responding to an unhandled exception. If one occurs, performance is already affected, walking the stack isn''t going to change that. Dump the callstack and register values to an error log. The next time the program is started, you can prompt the user to email you the report. Format the text for email and pass it along to the default mail handler. The extra code doesn''t add much to the app - 10 Kb. Having a little bit of error data is better than having none at all. There''s an "under the hood" column that addresses logging a stack walk in this fashion. The article doesn''t cover the email part.


"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.