comp.lang.ada
 help / color / mirror / Atom feed
From: Jeff C <jcreem@yahoo.com>
Subject: Re: This can't be done in Ada...or?
Date: Fri, 11 Feb 2005 12:02:57 -0500
Date: 2005-02-11T12:02:57-05:00	[thread overview]
Message-ID: <xtadnQ1DlL2teJHfRVn-qw@comcast.com> (raw)
In-Reply-To: <1108139611.709714.36170@o13g2000cwo.googlegroups.com>

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!
> 
> Appendix
> --------
> I don't want to clutter the post with too much info but some additional
> stuff  may be of interest:
> 
> There are two target platforms:
> "target variant":
> HW: Sun workstation, OS: Solaris, Real-time: no, Compiler: gcc (gnat)
> 
> "host variant":
> HW: PowerPC, OS: Integrity 5, Real-time: yes, Compiler: Adamulti (Green
> Hills)
> 
> If we could get rid of those hardcoded constants
> 
>   Package_Name : constant String := "Some_Package";
>   ...
>   Subprogram_Name : constant String := "Some_Procedure1";
>   ...
>   Subprogram_Name : constant String := "Some_Procedure2";
> 
> it would be a great bonus, but I reckon it can't be done either..?
> 

1) Use different package bodies on different platforms..Or (if 
differences are small and don't really require target dependant 
packages) then have the main body be the same but key some branches of 
static constants in a separate spec.
2) Basically I'd go with a variant of #1 above. Have a Logging_Control 
package that just declares constants for what should be enabled. Rely on 
your revision control system to select the appropriate spec
3) Pragma Inline the procedure calls.  Put the "if Logging_Enabled" 
inside the logging procedures. Make the Logging_Enabled a static 
constant. Compiler should optimize away the entire procedure call if 
done properly (it does on GNAT and VADS for the cases I have tried)
4)See #3...This is only done inside the logging procedure. Same as the
#ifdef approach you are missing.
5) OK. Done.


I think the above approach gets you close enough that you should be 
happy. If it does not work for a particular vendor..Fire the vendor.

  Note that
I agree it would be nice to have some way to avoid your constants (Like 
GNAT.Source_Info)

Unfortuntely this is not seen as a priority and I dont think it will 
make it aven into Ada 2005

http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00282.TXT?rev=1.4







  parent reply	other threads:[~2005-02-11 17:02 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-11 16:33 This can't be done in Ada...or? Per Lindquist
2005-02-11 16:51 ` Duncan Sands
2005-02-12 19:55   ` Florian Weimer
2005-02-14  8:34     ` Per Lindquist
2005-02-14  8:17   ` Per Lindquist
2005-02-11 17:02 ` Jeff C [this message]
2005-02-11 18:27   ` Robert A Duff
2005-02-11 23:51     ` Ludovic Brenta
2005-02-11 23:52       ` Robert A Duff
2005-02-12 13:55     ` Duncan Sands
2005-02-12 14:58       ` Martin Krischik
2005-02-12 15:56         ` Martin Dowie
2005-02-12 19:02       ` Robert A Duff
2005-02-14  8:49     ` Per Lindquist
2005-02-11 17:08 ` Jerome Hugues
2005-02-14  9:05   ` Per Lindquist
2005-02-14 13:07     ` Georg Bauhaus
2005-02-12  1:10 ` Jeffrey Carter
2005-02-12 14:01   ` Duncan Sands
2005-02-13  0:27     ` Jeffrey Carter
2005-02-14  9:10       ` Per Lindquist
2005-02-15  0:40         ` Jeffrey Carter
2005-02-15  7:40           ` Per Lindquist
2005-02-15  8:39             ` OT: Google reply (Was: Re: This can't be done in Ada...or?) Adrien Plisson
2005-02-15  9:42               ` Per Lindquist
2005-02-15  8:27           ` This can't be done in Ada...or? Per Lindquist
2005-02-14 22:10             ` Manuel G. R.
2005-02-15  8:47             ` Mark Lorenzen
2005-02-15  9:09               ` Jacob Sparre Andersen
2005-02-15  9:31                 ` Mark Lorenzen
2005-02-15  9:48                   ` Jacob Sparre Andersen
2005-02-15 10:07                     ` Mark Lorenzen
2005-02-15 10:15                   ` Martin Dowie
2005-02-17 22:09                     ` Randy Brukardt
2005-02-18  6:53                       ` Martin Dowie
2005-02-15 13:46                   ` Robert A Duff
2005-02-15 13:41                 ` Robert A Duff
2005-02-15 16:30                   ` Per Lindquist
2005-02-15 19:38                     ` Martin Dowie
2005-02-15 20:20                     ` Robert A Duff
2005-02-17 21:52                   ` Simon Wright
2005-02-17 22:06               ` Randy Brukardt
2005-02-17 22:40                 ` Mark Lorenzen
2005-02-16  0:04             ` Jeffrey Carter
2005-02-16  0:09             ` Jeffrey Carter
2005-02-17  9:47               ` Per Lindquist
2005-02-17 22:36               ` Randy Brukardt
2005-02-14 15:21 ` Peter Amey
replies disabled

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