Wednesday, May 18, 2005

Another example why I love the JCL 

I've been using both the JCL and JVCL from the wonderful folks at JEDI for a few years now, and was recently reminded why.

I had an unreproducible bug which I had to track down with some debug logging. While there were only one or two points in the code which could cause this particular bug, there were literally hundreds of places in the code which called these routines. With a bit of help from the stack tracing routines in the JCL, I was able to quickly pin down exactly where the problem was originiating. Below is all it took to get the stack trace I required to pinpoint the culprit:

function BuildStackTrace(const ALevel: Integer = 0): string;
sl: TStringList;
locInfo: TJclLocationInfo;
procAddr: Pointer;
i: Integer;
sl := TStringList.Create;
i := ALevel;
procAddr := Caller(i);
while procAddr <> nil do
if GetLocationInfo(procAddr, locInfo) then
'[$%s] %s.%s Line %d',
[IntToHex(Integer(locInfo.Address), 8), locInfo.UnitName, locInfo.ProcedureName, locInfo.LineNumber]));
procAddr := Caller(i);
Result := sl.Text;

For any Delphi developers who haven't checked out what the JEDI projects have to offer, I strongly recommend you check them out now. And to any JEDI contributors who may be reading this, thanks a bunch and if you're ever in Auckland, look me up and I'll shout you a drink of your favourite poison (with full source code, of course).

> if you're ever in Auckland, look me up and I'll shout you a drink of your favourite poison

I will remember that ;)

Never been to NZ yet.
You should definately look me up, Hallvard. I owe you one for some help you gave me a few years ago to assist in setting up exception logging with stack trace info, based on a The Delpi Magazine article you wrote.

I couldn't get it to work reliably with D2, and you promptly responded to my e-mail request for assistance, allowing me to successfully implement the stack tracing.

I just wanted to say that I really enjoyed your blog and this post. You make some very informative points. Keep up the great work!

Delphi development
Post a Comment

This page is powered by Blogger. Isn't yours?