GetStackTrace in Delphi 7?
Asked Answered
V

4

10

Using Delphi 7, how can I get a string representing the stack-trace from an Exception?

try
  SomethingDodgy();
except
  on E:Exception do begin
    // print stack trace
    Log.Write(/* ??? */);
  end;
end;

I hear there's a GetStackTrace function in the latest delphi, but I can't find anything for delphi 7. No, upgrading is not an option :)

Voice answered 16/11, 2009 at 5:33 Comment(2)
Note that the GetStackTrace method in newer Delphi versions does not actually return a stack trace. You do need an external exception framework anyway.Leshia
You can have JCL set up in minutes. I posted an example on this SO question: #1260063Pervasive
C
15

You could try using madExcept, a wonderful Exception handling framework.

madshi has heaps of sample code in there; I'm sure I've used the stack-trace stuff in there before.

As Dmitriy noted, the JCL also has stack-trace code; an old sample is here.

Calhoun answered 16/11, 2009 at 6:10 Comment(4)
Yeah, madExcept is awesome - but this is commercial code I'm writing, and I don't think I can get the company to buy madExcept right now. JCL sounds good too though, I will take a look..Voice
It's not all that expensive. How many hours of work should you spend working around this??Tumblebug
Yeah - but the stack trace is a nice-to-have in this project, so I won't spend much time trying to work around it.Voice
Detailed JCL tutorial: robstechcorner.blogspot.com/2009/04/…Transportation
L
5

I throw EurekaLog in the game. It's a great tool and not expensive at all.

Leshia answered 16/11, 2009 at 12:23 Comment(0)
B
1

MemChk is pretty easy to use (especially to search/find memory leaks) and knows how to render a stack trace from a code address.

Burger answered 16/11, 2009 at 7:38 Comment(0)
S
-1

The stack-trace in Win32 is not as good as .NET's or Java's (and the latest versoin of Delphi uses .NET stack trace).
Anyway, I found one link that provides more information on it here (It is at ExeEx so to allow to view that solution click the first link on the search).

See the bottom of the page there.

Swan answered 16/11, 2009 at 5:53 Comment(9)
-1. Experts Exchange: "All comments and solutions are available to Premium Service Members only."Northwestwards
I told you read at the BOTTOM! There are solutions. Please read properly before downvoting!Swan
@Dmitriy: No there are no solutions. Not at the bottom and not anywhere else.Leshia
ExEx is sneaky. If you google for the URL, and then click the link from google, your referer will be google, and they will show you the solutions.Voice
The sooner SO kills them, the better.Voice
@Blorgbeard, thanks for pointing that out. SO is already killing it :)Swan
@Dmitriy - EE will only display the answers at the bottom in certain web browsers (ie, not IE ;)Calhoun
@moobaa, ohh my ... That is so ridiculous!Swan
I just tried it with Firefox and IE7 - I get different pages but both show the answers at the bottom. Re "killing EE": +1 :-)Phan

© 2022 - 2024 — McMap. All rights reserved.