From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,400766bdbcd86f7c X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local1.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail NNTP-Posting-Date: Fri, 11 Feb 2005 11:02:40 -0600 Date: Fri, 11 Feb 2005 12:02:57 -0500 From: Jeff C User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: This can't be done in Ada...or? References: <1108139611.709714.36170@o13g2000cwo.googlegroups.com> In-Reply-To: <1108139611.709714.36170@o13g2000cwo.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 24.147.74.171 X-Trace: sv3-Xg7mVhN9UOgxYxOMrehxCqjGpQ4dqMjYJ8TogVjNVcGnj+3dQB3w9MCEd4lmwgZ4Ghgm+u2frzIUVIP!INff02wsnh8KsaYIt8lw2KrMu+QeO6VPDEy7IVv9GYtNk2Z/OQDNh9zNHJwCxw== X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.23 Xref: g2news1.google.com comp.lang.ada:8247 Date: 2005-02-11T12:02:57-05:00 List-Id: 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