From: Gautier <gautier@fakeaddress.nil>
Subject: Re: Conditional compilation of debug traces without cpp
Date: Tue, 04 Jul 2006 22:24:44 +0200
Date: 2006-07-04T22:24:44+02:00 [thread overview]
Message-ID: <44aacee4$1_3@news.bluewin.ch> (raw)
In-Reply-To: <44aaae35$0$5389$626a54ce@news.free.fr>
At least this works, with GNAT 3.15p and ObjectAda 7.2.2 SE:
package Debug is
procedure Put_Line (M : in String);
pragma Inline(Put_Line);
procedure Put_Line (M : in String; I: Integer);
pragma Inline(Put_Line);
end Debug;
with Ada.Text_IO;
package body Debug is
Enabled : constant Boolean := False;
procedure Put_Line (M : in String) is
begin
if Enabled then
Ada.Text_IO.Put_Line (M);
end if;
end;
procedure Put_Line (M : in String; I: Integer) is
begin
if Enabled then
Ada.Text_IO.Put_Line (M & Integer'Image(I));
end if;
end;
end Debug;
with Debug, Ada.Text_IO;
procedure Test_debug is
begin
for I in 1..1234 loop
Ada.Text_IO.Put_Line("[a]");
Debug.Put_Line ("(0) PC was here"); -- (0)
Debug.Put_Line ("(1) PC was here, I = ", I); -- (1)
Ada.Text_IO.Put_Line("[b]");
end loop;
end;
gcc -O2 -S -gnatpN test_debug.adb
.file "test_debug.adb"
gcc2_compiled.:
___gnu_compiled_ada:
.text
LC0:
.ascii "[a]"
.align 4
LC1:
.long 1
.long 3
LC2:
.ascii "(0) PC was here"
_C7b.0:
.ascii "(1) PC was here, I = "
LC3:
.ascii "[b]"
.align 4
.globl __ada_test_debug
__ada_test_debug:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movl $1,%ebx
.align 2,0x90
L37:
movl $LC0,%eax
movl $LC1,%edx
pushl %edx
pushl %eax
call _ada__text_io__put_line$2
movl $LC3,%eax
movl $LC1,%edx
pushl %edx
pushl %eax
call _ada__text_io__put_line$2
addl $16,%esp
incl %ebx
cmpl $1234,%ebx
jle L37
movl -4(%ebp),%ebx
movl %ebp,%esp
popl %ebp
ret
As you see, it does nothing else than writing the [a] and [b].
Similar thing for ObjectAda (Release mode).
When you have concatenations and/or a function call in the parameter
it doesn't work with these compilers - maybe, as you guess, they can't
skip the computation of parameters. Or they may, or newer versions do.
Perhaps it is a question of having a pragma Pure for the function.
HTH, Gautier
_______________________________________________________________
Ada programming -- http://www.mysunrise.ch/users/gdm/gsoft.htm
NB: For a direct answer, e-mail address on the Web site!
next prev parent reply other threads:[~2006-07-04 20:24 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-04 18:06 Conditional compilation of debug traces without cpp guillaume.portail
2006-07-04 19:07 ` Ludovic Brenta
2006-07-04 19:14 ` guillaume.portail
2006-07-04 21:39 ` Björn Persson
2006-07-04 21:43 ` guillaume.portail
2006-07-04 22:01 ` Björn Persson
2006-07-05 3:10 ` Matthew Goulet
2006-07-04 20:24 ` Gautier [this message]
2006-07-04 20:54 ` Simon Wright
2006-07-05 13:03 ` Jean-Pierre Rosen
2006-07-05 19:39 ` guillaume.portail
2006-07-06 5:53 ` Martin Krischik
2006-07-07 10:32 ` Stephen Leake
2006-07-07 14:08 ` M E Leypold
2006-07-06 7:59 ` Jean-Pierre Rosen
2006-07-06 20:25 ` guillaume.portail
2006-07-07 5:00 ` Matthew Goulet
2006-07-07 13:57 ` Thierry Bernier
2006-07-07 21:08 ` Randy Brukardt
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox