Click here to Skip to main content
15,670,097 members
Please Sign up or sign in to vote.
2.33/5 (3 votes)
See more:
I saw a simple calling stack on Turbo C 3.0

But I am wandering for a that simple calling stack. I am working on a multi-threading application and I am having a error in the query, so when I run it stuck in certain function. then I want to see the bad boy who called that individual function with improper query. I know if i debug carefully i will find that individual function. but i want to see it on the calling stack, someone guide me :)

p.s.: The question can be shorter than this, but I could not make it. :(
Updated 30-May-12 17:45pm

While this won't help if it's a timing issue you could log who's making the call and what the parameters are. If you flush the log before each call you know who's making the crap call AND what the parameters are. If you wrap the lot up in a macro it shouldn't be too hard to instrument your code this way (I know, I don't have to do it... :-) ).

If more than one thread calls the offending item then you'll have to create a log for each thread but hopefully it's just one thread messing up.

Another option would be to wrap your offending function in another one that does parameter validation and calls DebugBreak when something dodgy is passed. Then if you run it under a debugger it'll break when it gets the dodgy data, you can examine the call stack, find the offending caller AND see what its state is at the time.

Edit: Dodgy English Alert!!
Share this answer
Mohibur Rashid 31-May-12 3:47am    
so, it seems that VISUAL Studio cant help :(
Aescleal 31-May-12 3:55am    
It can help, you just have to give it a bit of help by telling it when to break - either by telling it where to break explicitly or when a certain data condition occurs. As it can help with other stuff the DebugBreak thing I've done a lot, even in production code. Messing up a functions parameters is a fairly fatal logic error so I throw an exception and in debug builds I DebugBreak first.
Mohibur Rashid 31-May-12 4:08am    
I already found the error and fixed it. but I am not worried about the bug. I am just asking how to trace call stack. there should be a option
You may want to ship a .pdb file for each .dll.

The articles refer to VC6, but the Windows API is still there.

Hope this helps,

Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900