comp.lang.ada
 help / color / mirror / Atom feed
From: Nige <nigel.scott@uk.thalesgroup.com>
Subject: Using controlled types to trace program execution
Date: Tue, 26 Feb 2002 13:39:19 +0000
Date: 2002-02-26T13:37:38+00:00	[thread overview]
Message-ID: <3C7B9007.FB5F257D@uk.thalesgroup.com> (raw)

Hi all,

I am trying to come up with a way of tracing program execution using
controlled types. Ie, I want to be able to declare an object as a
procedure or function is entered, which would add itself to some sort of
stack during it's initialization and remove itself once it goes out of
scope.

The benfit of this is that I would not have to explicitly have some sort
of enter and exit calls whenever a subprogram is called.

The problem is, that however I try to identify the declaration of the
object, the compiler throws it out.

The approaches I have tried are:

* A controlled object with an access to a string as a discriminant.

* A generic package containing a controlled type with a discrete type as
a discriminant.

* extending the type with a string/string access to identify it.

Does anyone have any ideas how I could acomplish this or even if it is
possible? I may be trying to do something that is not sensible/possible
of course...

Ideally I'd simply like to have:

procedure Something is

  Here : Trace.Location ("Something");

begin
  null;
end Something;

 ... where the package Trace would store the string "Something" until
the object Here goes out of scope. Then at any time I can examine the
contents of the stack in the package Trace...

The nearest I have got is to use new to allocate strings as the objects
are declared, but then the strings can't be deallocated explicitly,
because the strings are not variables.
eg

  Here : Trace.Location (new String'("Something"));

Hope I've made some sense,

Nige



             reply	other threads:[~2002-02-26 13:39 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-26 13:39 Nige [this message]
2002-02-26 18:26 ` Using controlled types to trace program execution tmoran
2002-02-27 11:44   ` Nige
2002-03-06 15:20 ` Matthew Heaney
2002-03-07  8:56   ` Nige
2002-03-07 16:43     ` Jeffrey Carter
  -- strict thread matches above, loose matches on Subject: below --
2002-02-27 11:55 Christoph Grein
2002-02-27 17:59 ` Jeffrey Carter
2002-02-28 15:24   ` Nige
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox