adagdb

Mac OS X 10.5.8, Xcode 3.1.2

$ gnat -v
GNAT 4.3.4 20090606 (prerelease) [gcc-4_3-branch revision 148236]
Copyright 1996-2007, Free Software Foundation, Inc.
$ gnatmake -g atest
gcc -c -g atest.adb
gnatbind -x atest.ali
gnatlink atest.ali -g
$ gdb atest
GNU gdb 6.3.50-20050815 (Apple version gdb-962) (Sat Jul 26 08:14:40 UTC 2008)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-apple-darwin"
...Reading symbols for shared libraries .. done

(gdb) set args 10
(gdb) break atest.adb:49
Breakpoint 1 at 0x2173: file atest.adb, line 49.
(gdb) r
Starting program: atest 10
Reading symbols for shared libraries +. done
[Switching to process 31205 thread 0x1103]

Breakpoint 1, atest.consumer (<_task>=0xbffff41c) at atest.adb:49
49        Ada.Text_IO.Put_Line
(gdb) info task
Inferior task 0x2c03 has a suspend count of 2.
The task has 3 threads:
Thread 0x813 (local 0x2d03) has current state "WAITING"
Thread 0x813 has a suspend count of 0.
Thread 0x313 (local 0x3503) has current state "WAITING"
Thread 0x313 has a suspend count of 0.
Thread 0x1103 (local 0x3403) has current state "WAITING"
Thread 0x1103 has a suspend count of 0.
Current language:  auto; currently ada
Cf. Ubuntu: (gdb) info task
  ID       TID P-ID Pri State                  Name
   1   804e008    0  48 Child Termination Wait main_task
*  2   8051890    1  48 Runnable               consumer
   3   804e838    1  48 Terminated             producer
(gdb) p x
$1 = true
(gdb) p count
$2 = 10
(gdb) c
Continuing.
Executed  10 iterations

Program exited normally.
(gdb) q
$

with Ada.Command_Line;
with Ada.Text_IO;

procedure ATest is

   Iterations : Positive := Positive'Value
     (Ada.Command_Line.Argument (1));

   protected Buffer is
      entry Put (X : in Boolean);
      entry Get (X : out Boolean);
   private
      Value : Boolean;
      Full : Boolean := False;
   end Buffer;

   protected body Buffer is
      entry Put (X : in Boolean) when not Full is
      begin
         Value := X;
         Full := True;
      end Put;
      entry Get (X : out Boolean) when Full is
      begin
         X := Value;
         Full := False;
      end Get;
   end Buffer;

   task Producer;
   task body Producer is
   begin
      for I in 1 .. Iterations - 1 loop
         Buffer.Put (False);
      end loop;
      Buffer.Put (True);
   end Producer;

   task Consumer;
   task body Consumer is
      X : Boolean;
      Count : Natural := 0;
   begin
      loop
         Buffer.Get (X);
         Count := Count + 1;
         exit when X;
      end loop;
      Ada.Text_IO.Put_Line("Executed " & Natural'Image (Count) & " iterations"); -- line 49
   end Consumer;

begin
   null;
end ATest;

$ gnatmake -g testnest
gcc -c -g testnest.adb
gnatbind -x testnest.ali
gnatlink testnest.ali -g
$ gdb testnest
GNU gdb 6.3.50-20050815 (Apple version gdb-962) (Sat Jul 26 08:14:40 UTC 2008)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-apple-darwin"
...Reading symbols for shared libraries .. done

(gdb) break testnest.adb:35
Breakpoint 1 at 0x1ea5: file testnest.adb, line 35.
(gdb) r
Starting program: testnest 
Reading symbols for shared libraries +. done
Outer Test string
Outer Test string
Local Test String
Outer Test string
Inner Test String
Inner Test String
Really Local String
Outer Test string

Breakpoint 1, testnest.test3 (s=0x19193) at testnest.adb:35
35        Put_line (s);
(gdb) p my_string
Multiple matches for my_string
[0] cancel
[1] my_string at ?
[2] my_string at ?
[3] my_string at ?
> 1
$1 = "Really Local String"
Current language:  auto; currently ada
(gdb) p my_string
Multiple matches for my_string
[0] cancel
[1] my_string at ?
[2] my_string at ?
[3] my_string at ?
> 2
$2 = "Inner Test String"
(gdb) p my_string
Multiple matches for my_string
[0] cancel
[1] my_string at ?
[2] my_string at ?
[3] my_string at ?
> 3
$3 = "Local Test String"
(gdb) c
Continuing.
Outer Test string
Outer Test string
Hello World. Welcome to GNAT

Program exited normally.
(gdb) q
$ 

with Ada.Text_IO; use Ada.Text_IO;

procedure TestNest is

   My_String: String := "Outer Test string";
   My_Const: constant String := "Constant String";

   procedure Test2 (s: in String) is
   begin
      Put_line (My_String);
      Put_line (s);
   end Test2;

   procedure Test3 (s: in String) is
      My_String: string := "Local Test String";
      my_i: integer := 0;
   begin
      my_i := my_i + 1;
      Put_line (My_String);
      Put_line (testnest.My_String);

      Inner:
      declare
         My_String: String := "Inner Test String";
      begin
         Put_Line (My_String);
         declare
            My_String: String := "Really Local String";
         begin
            Put_line (Inner.My_String);
            Put_line (My_String);
            Put_line (testnest.My_String);
         end;
      end Inner;
      Put_line (s); -- line35
   end Test3;

begin
   Test2(My_String);
   Test3(My_String);
   Put_Line (My_String);
   Put_Line ("Hello World. Welcome to GNAT");
end;