Board index » delphi » How to tell name of procedure currently executing.

How to tell name of procedure currently executing.

        How do I know which event handler/method/procedure I am running in?  This
would be similar to the Params[0] property for the command line.  For the
purposes of debugging, I would like to be able to write a generic couple of
lines of code at the begining and ending of each procedure of the form;

procedure TForm.MethodName(<Params>);
begin
        LogToFile('Starting' + MethodName);
        .
 .      .
        .
        LogToFile('Exiting' + MethodName);
end;

--
Rob Tanner B.Eng., B.Sc.
Network Manager
rtan...@webster.sk.ca
Dasher Courier, Inc.

 

Re:How to tell name of procedure currently executing.


On Sat, 21 Jun 1997 04:04:44 GMT, geo...@cambria.com (George Mealer)
wrote:

Quote
>Basically, you don't.  The only class members for which information is
>saved at all are published members [snip]

Oops...and automated members.  Still won't help you.  :)

Geo

--
George Mealer                       geo...@cambria.com
Programmer/Systems Analyst          Office: (415) 328-9270
Cambria Corporation                 Fax:    (415) 328-8642

"A good programmer is someone who looks both ways before
 crossing a one-way street." -- Doug Linder

Re:How to tell name of procedure currently executing.


On 20 Jun 97 18:11:22 GMT, "Robby Tanner" <rtan...@webster.sk.ca>
wrote:

Quote
>    How do I know which event handler/method/procedure I am running in?  This
>would be similar to the Params[0] property for the command line.  For the
>purposes of debugging, I would like to be able to write a generic couple of
>lines of code at the begining and ending of each procedure of the form;

>procedure TForm.MethodName(<Params>);
>begin
>    LogToFile('Starting' + MethodName);
>    .
> .  .
>    .
>    LogToFile('Exiting' + MethodName);
>end;

>--
>Rob Tanner B.Eng., B.Sc.
>Network Manager
>rtan...@webster.sk.ca
>Dasher Courier, Inc.

Basically, you don't.  The only class members for which information is
saved at all are published members, and none of the info would be
useful for establishing location within the code.  You CAN figure out
what address in memory you're at (using the IP register, I would
assume) and compare it to the MAP file which you have the option of
generating.

I'm not particularly sure of the methodology behind doing all this,
but it's done enough that there may even be some sort of utility or
component to do it for you.  ::shrug::

Geo
--
George Mealer                       geo...@cambria.com
Programmer/Systems Analyst          Office: (415) 328-9270
Cambria Corporation                 Fax:    (415) 328-8642

"A good programmer is someone who looks both ways before
 crossing a one-way street." -- Doug Linder

Re:How to tell name of procedure currently executing.


Quote
"Robby Tanner" <rtan...@webster.sk.ca> wrote:
>    How do I know which event handler/method/procedure I am running in?  This
>would be similar to the Params[0] property for the command line.  For the
>purposes of debugging, I would like to be able to write a generic couple of
>lines of code at the begining and ending of each procedure of the form;
>procedure TForm.MethodName(<Params>);
>begin
>    LogToFile('Starting' + MethodName);
>    .
> .  .
>    .
>    LogToFile('Exiting' + MethodName);
>end;
>--

This may not help you Pascal programmers...but...
C++ has a macro that will expand into the current
program source line number.  The macro preprocessor
is not aware of functions but it does know about lines.

Other Threads