Quantcast
Channel: VBForums - CodeBank - Visual Basic 6 and earlier
Viewing all articles
Browse latest Browse all 1466

My CallStack Class (Working Demo - Updated code (again))

$
0
0
=====================

CallStack Demo3.zip

=====================

OK, I think I'm done working on this demo. I've changed it so that it doesn't create an endless list of files. You can can specify a maximum number of callstack logs as well as number of callstacks per log.

So if you want you can specify a max of 1,000 logs with one call per log or one log with 10000 stacks in it or whatever you want as long as you stay within the limits of a long integer data type, the maximum size of a file your system can handle and of course disk space.

A little more polishing was done.

If you have MZTools or something like it you can create a macro that automatically inserts the callstack stuff into any procedure with the correct information.

I really like MZTools.

=====================

What it does:

It counts every call to every procedure that adds to the call stack. When the program exits (only if it's enabled at exit) it provides a list of every procedure called, how many times it was called and the deepest call stack.

Every single call is logged to file. The file is opened and when the max number of entries (specified in the cCallStack Initialize Sub) is reached it closes the file and opens a new one.

So if you look at one of the callstack files you see that the stack increases one call at a time and then backs out one call at a time until the stack has nothing left on it. (Edit: I just looked a callstack file and it doesn't look like I added logging when it backs out. I'll have to check it again.)

When the program exits on purpose the current active callstack file is closed.

if the program crashes when a file is open then we count on Windows to close the file and hopefully you'll be able to look at the last callstack in the last file and see the stack that led up to the crash.

In my real app, all the totals are put into an application log file. In the demo it's put into the immediate window.

If you do too much with the demo then all the stats will be scrolled off the top of the immediate window so you just want to type a little bit, click a few things and then exit.

You could also just write that to the Windows Clipboard instead and then paste it into a text document instead.

You will find that in the CloseLogFile Function in the ErrorHandler bas module.

Where this really shines is that if you're in the IDE and something is going on and you set a breakpoint AND you have some kind of API thing going on, such as changing the color of a toolbar or SSTab or whatever, the program might crash and bring down the entire IDE even if the API call wasn't the problem.

This allows you to keep running and figure out what's going on without hitting CTRL+ Break to pause program execution which can sometimes kill everything for reasons other than whatever actual problem you're trying to sort out.

I'd appreciate any feedback you can give me.


=====================
Attached Files

Viewing all articles
Browse latest Browse all 1466

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>