Re: This can't be done in Ada...or?

From: Peter Amey (peter.amey_at_praxis-cs.co.uk)
Date: 02/14/05


Date: Mon, 14 Feb 2005 15:21:22 +0000


Per Lindquist wrote:
> Hi, this question has already sort of been discussed in topics about
> multiple target platforms, conditional compilation, preprocessors and
> build strategies. Before giving up I thought I'd give it a try one last
> time...
>
> My impression from reading some threads is that Ada DOES NOT offer a
> decent way to implement trace printouts (log messages), at least not
> with the features stated below.
>
> The problem
> -----------
>
> We want to be able to output log messages, or traces as we call it,
> from an Ada program. There will be a few trace categories like Error,
> Warning, Note etc. The messages (strings) can be sent to a file or
> stdout or whatever (not important).
>
> A call might look something like this:
>
> Trace.Error(Package_Name, Subprogram_Name, "Woops, V=" &
> Some_Type'Image(V));
>
> How do we write a tracing utility in Ada that:
> 1. has different behaviour on different target platforms
> 2. can disable some categories depending on target platform at
> compile-time.
> 3. does *not* cause any execution overhead if disabled.
> 4. does not need yucky "if Trace_Wanted then ... end if;" around all
> calls
> 5. does not need preprocessing (some of you say it's never needed in
> Ada...)
>
> I say it can't be done in Ada. Please prove me wrong!
>

One useful approach I have used is to make us of subunits. Each of the
reporting routines in your package Trace can be made a subunit of Trace.
  The subunit itself, e.g. Error, can have two implementations, one
that reports the error and one which is just a null body. The compiler
"make" system and library manager can be used to build different
variants with different levels of reporting. If the stub is marked as
in_line then there is no overhead when the null version is called.

Peter



Relevant Pages

  • Re: This cant be done in Ada...or?
    ... > multiple target platforms, conditional compilation, preprocessors and ... > from an Ada program. ... has different behaviour on different target platforms ... inside the logging procedures. ...
    (comp.lang.ada)
  • Re: Trace debug for every method in code
    ... private void button1_Click(object sender, EventArgs e) ... Although the EL let's you turn on and off the trace at runtime, ... deployment code. ... be avoided by turning off the TRACE in the "Conditional Compilation ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Help removing a reference in a web site
    ... Set compilation debug="true" to enable ASPX debugging. ... "On" Always display custom messages ... Application-level tracing enables trace log output for every ... belong to a particular session. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Fujitsu cobol debugging
    ... In Microfocus I can do SET TRACE and the READY TRACE and it will tell me ... Certainly, I use remote compilation for generated COBOL programs, but it is ... on the local machine, along with the executables. ...
    (comp.lang.cobol)
  • Re: Kernel marker has no performance impact on ia64.
    ... The trace point need not be concerned with which data, ... But that is tracer specific - I might write a scheduler tracer that ... In systemtap, we try to give people useful ... C code compilation is quite some way removed and is ...
    (Linux-Kernel)