Board index » delphi » Anyone have a reliable "traceback of called addresses" algorithm?

Anyone have a reliable "traceback of called addresses" algorithm?

Does anyone have, off the top of their heads, a correct algorithm for
producing a traceback of called addresses, given an exception-address?

Or, does the VCL/RTL have such a thing?

Basically, one would be tracing back through the program stack examining the
return-addresses pushed at each point.  I'm sure that weirdnesses like
"register" and other calling-conventions might play a role, but I'm not sure.  
I just need this and really don't want to write it if it's been done, by
Borland or otherwise.

 

Re:Anyone have a reliable "traceback of called addresses" algorithm?


In article <news-reply.6804.00774...@sundialservices.com>, news-
re...@sundialservices.com says...

Quote

> Does anyone have, off the top of their heads, a correct algorithm for
> producing a traceback of called addresses, given an exception-address?

Check out The Delphi Magazine at
(http://www.itecuk.com/delmag/index.htm). You can order back issues if
you need, and you can download the source.

Run-time location information in Delphi 2
Type: Article, Issue #22 (June 1997), Page #8
Summary: Vitaly has some neat tricks to allow you to determine the source
file and line number where an error occurred, at run time on your users'
machines!

M.

--
Author of several unknown utilities for DOS and Windows.
http://www.delfidata.no/users/~martin
mailto:martin.lars...@delfidata.no

Re:Anyone have a reliable "traceback of called addresses" algorithm?


: news-re...@sundialservices.com (Sundial Services) wrote:

Quote

>Does anyone have, off the top of their heads, a correct algorithm for
>producing a traceback of called addresses, given an exception-address?

Yes/No. It works (D1, D2, D3), but it does not work with exceptions -
simply because "the call stack is unwund up to the point where the
exception handler resides" (forgive me if I am quoting wrong from the
Object Pascal docs.)

Quote
>Or, does the VCL/RTL have such a thing?

No, but in order to get stack traces in case of *exceptions* you need
to modify the RTL.

Quote
>Basically, one would be tracing back through the program stack examining the
>return-addresses pushed at each point.  I'm sure that weirdnesses like
>"register" and other calling-conventions might play a role, but I'm not sure.  

No, they don't. Stack frames do.

Quote
>I just need this and really don't want to write it if it's been done, by
>Borland or otherwise.

--
mailto:Stefan.Hoffmeister (at) Uni-Passau.de
http://kakadu.rz.uni-passau.de/~w4hoff01/
   DIR: Delphi FAQs, KBs, docs
   PGP public key at homepage

Re:Anyone have a reliable "traceback of called addresses" algorithm?


In article <34c48655.5190...@news.rz.uni-passau.de> no.spam.ple...@see.signature (Stefan Hoffmeister) writes:

Quote
>>Does anyone have, off the top of their heads, a correct algorithm for
>>producing a traceback of called addresses, given an exception-address?
>Yes/No. It works (D1, D2, D3), but it does not work with exceptions -
>simply because "the call stack is unwund up to the point where the
>exception handler resides" (forgive me if I am quoting wrong from the
>Object Pascal docs.)
>>Or, does the VCL/RTL have such a thing?
>No, but in order to get stack traces in case of *exceptions* you need
>to modify the RTL.
>>Basically, one would be tracing back through the program stack examining the
>>return-addresses pushed at each point.  I'm sure that weirdnesses like
>>"register" and other calling-conventions might play a role, but I'm not sure.  
>No, they don't. Stack frames do.
>>I just need this and really don't want to write it if it's been done, by
>>Borland or otherwise.

Yes, Stefan, you're on to the fact that I'm not looking to map the address to
a source line (I can do that with the map-file), but rather to have a
traceback of the called routines [address only].

Your posting suggests that you have muddled with such code.  Could you
possibly post and/or e-mail some definite stuff?  Many thanks.

Re:Anyone have a reliable "traceback of called addresses" algorithm?


On Tue, 20 Jan 1998 21:06:52 GMT, no.spam.ple...@see.signature (Stefan

Quote
Hoffmeister) wrote:
>: news-re...@sundialservices.com (Sundial Services) wrote:
>>Does anyone have, off the top of their heads, a correct algorithm for
>>producing a traceback of called addresses, given an exception-address?

>Yes/No. It works (D1, D2, D3), but it does not work with exceptions -
>simply because "the call stack is unwund up to the point where the
>exception handler resides" (forgive me if I am quoting wrong from the
>Object Pascal docs.)

>>Or, does the VCL/RTL have such a thing?

>No, but in order to get stack traces in case of *exceptions* you need
>to modify the RTL.

Or you could patch the code at run-time. "Simply" re-route all calls
to Kernel32.RaiseException to your own routine. ExHook is a commercial
product that does this to produce a stack trace after and exception:
http://home.turbopower.com/~PerL/index.html.

--
Hallvard Vassbotn
Falcon R&D, Reuters Norge AS

Other Threads