OSDN Git Service

* doc/install.texi (Specific, i?86-*-solaris2.10): Fix grammar.
[pf3gnuchains/gcc-fork.git] / gcc / ada / s-tasdeb.adb
index 8b6f272..9fb0cd6 100644 (file)
@@ -1,75 +1,53 @@
 ------------------------------------------------------------------------------
 --                                                                          --
---                 GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS              --
+--                  GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS                --
 --                                                                          --
 --                  S Y S T E M . T A S K I N G . D E B U G                 --
 --                                                                          --
 --                                  B o d y                                 --
 --                                                                          --
---                             $Revision$
---                                                                          --
---          Copyright (C) 1997-2002 Free Software Foundation, Inc.          --
+--          Copyright (C) 1997-2009, Free Software Foundation, Inc.         --
 --                                                                          --
 -- GNARL is free software; you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
--- ware  Foundation;  either version 2,  or (at your option) any later ver- --
--- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
+-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
+-- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
--- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
--- for  more details.  You should have  received  a copy of the GNU General --
--- Public License  distributed with GNARL; see file COPYING.  If not, write --
--- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
--- MA 02111-1307, USA.                                                      --
+-- or FITNESS FOR A PARTICULAR PURPOSE.                                     --
+--                                                                          --
+-- As a special exception under Section 7 of GPL version 3, you are granted --
+-- additional permissions described in the GCC Runtime Library Exception,   --
+-- version 3.1, as published by the Free Software Foundation.               --
 --                                                                          --
--- As a special exception,  if other files  instantiate  generics from this --
--- unit, or you link  this unit with other files  to produce an executable, --
--- this  unit  does not  by itself cause  the resulting  executable  to  be --
--- covered  by the  GNU  General  Public  License.  This exception does not --
--- however invalidate  any other reasons why  the executable file  might be --
--- covered by the  GNU Public License.                                      --
+-- You should have received a copy of the GNU General Public License and    --
+-- a copy of the GCC Runtime Library Exception along with this program;     --
+-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
+-- <http://www.gnu.org/licenses/>.                                          --
 --                                                                          --
--- GNARL was developed by the GNARL team at Florida State University. It is --
--- now maintained by Ada Core Technologies, Inc. (http://www.gnat.com).     --
+-- GNARL was developed by the GNARL team at Florida State University.       --
+-- Extensive contributions were provided by Ada Core Technologies, Inc.     --
 --                                                                          --
 ------------------------------------------------------------------------------
 
 --  This package encapsulates all direct interfaces to task debugging services
---  that are needed by gdb with gnat mode (1.13 and higher)
+--  that are needed by gdb with gnat mode.
 
 --  Note : This file *must* be compiled with debugging information
 
 --  Do not add any dependency to GNARL packages since this package is used
 --  in both normal and restricted (ravenscar) environments.
 
-with System.Task_Info,
-     System.Task_Primitives.Operations,
-     Unchecked_Conversion;
+with System.CRTL;
+with System.Task_Primitives;
+with System.Task_Primitives.Operations;
+with Ada.Unchecked_Conversion;
 
 package body System.Tasking.Debug is
 
-   use Interfaces.C;
-
    package STPO renames System.Task_Primitives.Operations;
 
-   type Integer_Address is mod 2 ** Standard'Address_Size;
-
-   function "+" is new
-     Unchecked_Conversion (Task_ID, Integer_Address);
-
-   Hex_Address_Width : constant := (Standard'Address_Size / 4);
-
-   Hex_Digits : constant array (0 .. Integer_Address'(15)) of Character :=
-                  "0123456789abcdef";
-
-   subtype Buf_Range is Integer range 1 .. 80;
-   type Buf_Array is array (Buf_Range) of aliased Character;
-
-   type Buffer is record
-      Next  : Buf_Range := Buf_Range'First;
-      Chars : Buf_Array := (Buf_Range => ' ');
-   end record;
-
-   type Buffer_Ptr is access all Buffer;
+   function To_Integer is new
+     Ada.Unchecked_Conversion (Task_Id, System.Task_Primitives.Task_Address);
 
    type Trace_Flag_Set is array (Character) of Boolean;
 
@@ -79,98 +57,52 @@ package body System.Tasking.Debug is
    -- Local Subprograms --
    -----------------------
 
-   procedure Put
-     (T      : ST.Task_ID;
-      Width  : Integer;
-      Buffer : Buffer_Ptr);
-   --  Put TCB pointer T, (coded in hexadecimal) into Buffer
-   --  right-justified in Width characters.
-
-   procedure Put
-     (N      : Integer_Address;
-      Width  : Integer;
-      Buffer : Buffer_Ptr);
-   --  Put N (coded in decimal) into Buf right-justified in Width
-   --  characters starting at Buf (Next).
-
-   procedure Put
-     (S      : String;
-      Width  : Integer;
-      Buffer : Buffer_Ptr);
-   --  Put string S into Buf left-justified in Width characters
-   --  starting with space in Buf (Next), truncated as necessary.
-
-   procedure Put
-     (C      : Character;
-      Buffer : Buffer_Ptr);
-   --  Put character C into Buf, left-justified, starting at Buf (Next)
-
-   procedure Space (Buffer : Buffer_Ptr);
-   --  Increment Next, resulting in a space
-
-   procedure Space
-     (N      : Integer;
-      Buffer : Buffer_Ptr);
-   --  Increment Next by N, resulting in N spaces
-
-   procedure Clear (Buffer : Buffer_Ptr);
-   --  Clear Buf and reset Next to 1
-
-   procedure Write_Buf (Buffer : Buffer_Ptr);
-   --  Write contents of Buf (1 .. Next) to standard output
-
-   -----------
-   -- Clear --
-   -----------
+   procedure Write (Fd : Integer; S : String; Count : Integer);
 
-   procedure Clear (Buffer : Buffer_Ptr) is
-      Next : Buf_Range renames Buffer.Next;
-      Buf  : Buf_Array renames Buffer.Chars;
+   procedure Put (S : String);
+   --  Display S on standard output
 
-   begin
-      Buf := (Buf_Range => ' ');
-      Next := 1;
-   end Clear;
+   procedure Put_Line (S : String := "");
+   --  Display S on standard output with an additional line terminator
 
-   -----------
-   -- Image --
-   -----------
+   ------------------------
+   -- Continue_All_Tasks --
+   ------------------------
 
-   function Image (T : ST.Task_ID) return String is
-      Buf    : aliased Buffer;
-      Result : String (1 .. Hex_Address_Width + 21);
+   procedure Continue_All_Tasks is
+      C : Task_Id;
 
-      use type System.Task_Info.Task_Image_Type;
+      Dummy : Boolean;
+      pragma Unreferenced (Dummy);
 
    begin
-      Clear (Buf'Unchecked_Access);
-      Put (T, Hex_Address_Width, Buf'Unchecked_Access);
-      Put (':', Buf'Unchecked_Access);
-      Put (Integer_Address (T.Serial_Number), 4, Buf'Unchecked_Access);
-      Space (Buf'Unchecked_Access);
-
-      if T.Common.Task_Image = null then
-         Put ("", 15, Buf'Unchecked_Access);
-      else
-         Put (T.Common.Task_Image.all, 15, Buf'Unchecked_Access);
-      end if;
+      STPO.Lock_RTS;
 
-      for J in Result'Range loop
-         Result (J) := Buf.Chars (J);
+      C := All_Tasks_List;
+      while C /= null loop
+         Dummy := STPO.Continue_Task (C);
+         C := C.Common.All_Tasks_Link;
       end loop;
 
-      return Result;
-   end Image;
+      STPO.Unlock_RTS;
+   end Continue_All_Tasks;
+
+   --------------------
+   -- Get_User_State --
+   --------------------
+
+   function Get_User_State return Long_Integer is
+   begin
+      return STPO.Self.User_State;
+   end Get_User_State;
 
    ----------------
    -- List_Tasks --
    ----------------
 
    procedure List_Tasks is
-      C : ST.Task_ID;
-
+      C : Task_Id;
    begin
-      Print_Task_Info_Header;
       C := All_Tasks_List;
 
       while C /= null loop
@@ -179,29 +111,6 @@ package body System.Tasking.Debug is
       end loop;
    end List_Tasks;
 
-   -----------------------
-   -- Print_Accept_Info --
-   -----------------------
-
-   procedure Print_Accept_Info (T : ST.Task_ID) is
-      Buf : aliased Buffer;
-
-   begin
-      if T.Open_Accepts = null then
-         return;
-      end if;
-
-      Clear (Buf'Unchecked_Access);
-      Space (10, Buf'Unchecked_Access);
-      Put ("accepting:", 11, Buf'Unchecked_Access);
-
-      for J in T.Open_Accepts.all'Range loop
-         Put (Integer_Address (T.Open_Accepts (J).S), 3, Buf'Unchecked_Access);
-      end loop;
-
-      Write_Buf (Buf'Unchecked_Access);
-   end Print_Accept_Info;
-
    ------------------------
    -- Print_Current_Task --
    ------------------------
@@ -215,311 +124,115 @@ package body System.Tasking.Debug is
    -- Print_Task_Info --
    ---------------------
 
-   procedure Print_Task_Info (T : ST.Task_ID) is
+   procedure Print_Task_Info (T : Task_Id) is
       Entry_Call : Entry_Call_Link;
-      Buf        : aliased Buffer;
-
-      use type System.Task_Info.Task_Image_Type;
+      Parent     : Task_Id;
 
    begin
-      Clear (Buf'Unchecked_Access);
-      Put (T, Hex_Address_Width, Buf'Unchecked_Access);
-      Put (':', Buf'Unchecked_Access);
-      Put (' ', Buf'Unchecked_Access);
-      Put (':', Buf'Unchecked_Access);
-
       if T = null then
-         Put (" null task", 10, Buf'Unchecked_Access);
-         Write_Buf (Buf'Unchecked_Access);
+         Put_Line ("null task");
          return;
       end if;
 
-      Put (Integer_Address (T.Serial_Number), 4, Buf'Unchecked_Access);
-      Space (Buf'Unchecked_Access);
-
-      if T.Common.Task_Image = null then
-         Put ("", 15, Buf'Unchecked_Access);
-      else
-         Put (T.Common.Task_Image.all, 15, Buf'Unchecked_Access);
-      end if;
+      Put (T.Common.Task_Image (1 .. T.Common.Task_Image_Len) & ": " &
+           Task_States'Image (T.Common.State));
 
-      Space (Buf'Unchecked_Access);
-      Put (Task_States'Image (T.Common.State), 10, Buf'Unchecked_Access);
-      Space (Buf'Unchecked_Access);
+      Parent := T.Common.Parent;
 
-      if T.Callable then
-         Put ('C', Buf'Unchecked_Access);
+      if Parent = null then
+         Put (", parent: <none>");
       else
-         Space (Buf'Unchecked_Access);
+         Put (", parent: " &
+              Parent.Common.Task_Image (1 .. Parent.Common.Task_Image_Len));
       end if;
 
-      if T.Open_Accepts /= null then
-         Put ('A', Buf'Unchecked_Access);
-      else
-         Space (Buf'Unchecked_Access);
-      end if;
-
-      if T.Common.Call /= null then
-         Put ('C', Buf'Unchecked_Access);
-      else
-         Space (Buf'Unchecked_Access);
-      end if;
+      Put (", prio:" & T.Common.Current_Priority'Img);
 
-      if T.Terminate_Alternative then
-         Put ('T', Buf'Unchecked_Access);
-      else
-         Space (Buf'Unchecked_Access);
+      if not T.Callable then
+         Put (", not callable");
       end if;
 
       if T.Aborting then
-         Put ('A', Buf'Unchecked_Access);
-      else
-         Space (Buf'Unchecked_Access);
+         Put (", aborting");
       end if;
 
-      if T.Deferral_Level = 0 then
-         Space (3, Buf'Unchecked_Access);
-      else
-         Put ('D', Buf'Unchecked_Access);
-         if T.Deferral_Level < 0 then
-            Put ("<0", 2, Buf'Unchecked_Access);
-         elsif T.Deferral_Level > 1 then
-            Put (Integer_Address (T.Deferral_Level), 2, Buf'Unchecked_Access);
-         else
-            Space (2, Buf'Unchecked_Access);
-         end if;
+      if T.Deferral_Level /= 0 then
+         Put (", abort deferred");
       end if;
 
-      Space (Buf'Unchecked_Access);
-      Put (Integer_Address (T.Master_of_Task), 1, Buf'Unchecked_Access);
-      Space (Buf'Unchecked_Access);
-      Put (Integer_Address (T.Master_Within), 1, Buf'Unchecked_Access);
-      Put (',', Buf'Unchecked_Access);
-      Space (Buf'Unchecked_Access);
-      Put (Integer_Address (T.Awake_Count), 1, Buf'Unchecked_Access);
-      Space (Buf'Unchecked_Access);
-      Put (Integer_Address (T.Alive_Count), 1, Buf'Unchecked_Access);
-      Put (',', Buf'Unchecked_Access);
-      Space (Buf'Unchecked_Access);
-      Put (Integer_Address (T.ATC_Nesting_Level), 1, Buf'Unchecked_Access);
-      Space (Buf'Unchecked_Access);
-      Put (Integer_Address (T.Pending_ATC_Level), 1, Buf'Unchecked_Access);
-      Put (',', Buf'Unchecked_Access);
-      Space (Buf'Unchecked_Access);
-      Put (Integer_Address (T.Common.Wait_Count), 1, Buf'Unchecked_Access);
-      Put (',', Buf'Unchecked_Access);
-      Space (Buf'Unchecked_Access);
-      Put (Integer_Address (T.User_State), 1, Buf'Unchecked_Access);
-      Write_Buf (Buf'Unchecked_Access);
-
       if T.Common.Call /= null then
          Entry_Call := T.Common.Call;
-         Clear (Buf'Unchecked_Access);
-         Space (10, Buf'Unchecked_Access);
-         Put ("serving:", 8, Buf'Unchecked_Access);
+         Put (", serving:");
 
          while Entry_Call /= null loop
-            Put (Integer_Address
-              (Entry_Call.Self.Serial_Number), 5, Buf'Unchecked_Access);
+            Put (To_Integer (Entry_Call.Self)'Img);
             Entry_Call := Entry_Call.Acceptor_Prev_Call;
          end loop;
-
-         Write_Buf (Buf'Unchecked_Access);
       end if;
 
-      Print_Accept_Info (T);
-   end Print_Task_Info;
-
-   ----------------------------
-   -- Print_Task_Info_Header --
-   ----------------------------
-
-   procedure Print_Task_Info_Header is
-      Buf : aliased Buffer;
-
-   begin
-      Clear (Buf'Unchecked_Access);
-      Put ("TASK_ID", Hex_Address_Width, Buf'Unchecked_Access);
-      Put (':', Buf'Unchecked_Access);
-      Put ('F', Buf'Unchecked_Access);
-      Put (':', Buf'Unchecked_Access);
-      Put ("SERIAL_NUMBER", 4, Buf'Unchecked_Access);
-      Space (Buf'Unchecked_Access);
-      Put (" NAME", 15, Buf'Unchecked_Access);
-      Put (" STATE", 10, Buf'Unchecked_Access);
-      Space (11, Buf'Unchecked_Access);
-      Put ("MAST", 5, Buf'Unchecked_Access);
-      Put ("AWAK", 5, Buf'Unchecked_Access);
-      Put ("ATC", 5, Buf'Unchecked_Access);
-      Put ("WT", 3, Buf'Unchecked_Access);
-      Put ("DBG", 3, Buf'Unchecked_Access);
-      Write_Buf (Buf'Unchecked_Access);
-   end Print_Task_Info_Header;
-
-   ---------
-   -- Put --
-   ---------
-
-   procedure Put
-     (T      : ST.Task_ID;
-      Width  : Integer;
-      Buffer : Buffer_Ptr)
-   is
-      J     : Integer;
-      X     : Integer_Address := +T;
-      Next  : Buf_Range renames Buffer.Next;
-      Buf   : Buf_Array renames Buffer.Chars;
-      First : constant Integer := Next;
-      Wdth  : Integer := Width;
-
-   begin
-      if Wdth > Buf'Last - Next then
-         Wdth := Buf'Last - Next;
-      end if;
-
-      J := Next + (Wdth - 1);
-
-      if X = 0 then
-         Buf (J) := '0';
-
-      else
-         while X > 0 loop
-            Buf (J) := Hex_Digits (X rem 16);
-            J := J - 1;
-            X := X / 16;
-
-            --  Check for overflow
-
-            if J < First and then X > 0 then
-               Buf (J + 1) := '*';
-               exit;
-            end if;
+      if T.Open_Accepts /= null then
+         Put (", accepting:");
 
+         for J in T.Open_Accepts'Range loop
+            Put (T.Open_Accepts (J).S'Img);
          end loop;
-      end if;
-
-      Next := Next + Wdth;
-   end Put;
 
-   procedure Put
-     (N      : Integer_Address;
-      Width  : Integer;
-      Buffer : Buffer_Ptr)
-   is
-      J     : Integer;
-      X     : Integer_Address := N;
-      Next  : Buf_Range renames Buffer.Next;
-      Buf   : Buf_Array renames Buffer.Chars;
-      First : constant Integer := Next;
-      Wdth  : Integer := Width;
-
-   begin
-      if Wdth > Buf'Last - Next then
-         Wdth := Buf'Last - Next;
+         if T.Terminate_Alternative then
+            Put (" or terminate");
+         end if;
       end if;
 
-      J := Next + (Wdth - 1);
-
-      if N = 0 then
-         Buf (J) := '0';
-
-      else
-         while X > 0 loop
-            Buf (J) := Hex_Digits (X rem 10);
-            J := J - 1;
-            X := X / 10;
-
-            --  Check for overflow
-
-            if J < First and then X > 0 then
-               Buf (J + 1) := '*';
-               exit;
-            end if;
-         end loop;
+      if T.User_State /= 0 then
+         Put (", state:" & T.User_State'Img);
       end if;
 
-      Next := Next + Wdth;
-   end Put;
+      Put_Line;
+   end Print_Task_Info;
 
-   procedure Put
-     (S      : String;
-      Width  : Integer;
-      Buffer : Buffer_Ptr)
-   is
-      Next  : Buf_Range renames Buffer.Next;
-      Buf   : Buf_Array renames Buffer.Chars;
-      Bound : constant Integer := Integer'Min (Next + Width, Buf'Last);
-      J     : Integer := Next;
+   ---------
+   -- Put --
+   ---------
 
+   procedure Put (S : String) is
    begin
-      for K in S'Range loop
-
-         --  Check overflow
-
-         if J >= Bound then
-            Buf (J - 1) := '*';
-            exit;
-         end if;
-
-         Buf (J) := S (K);
-         J := J + 1;
-      end loop;
-
-      Next := Bound;
+      Write (2, S, S'Length);
    end Put;
 
-   procedure Put
-     (C      : Character;
-      Buffer : Buffer_Ptr)
-   is
-      Next : Buf_Range renames Buffer.Next;
-      Buf  : Buf_Array renames Buffer.Chars;
+   --------------
+   -- Put_Line --
+   --------------
 
+   procedure Put_Line (S : String := "") is
    begin
-      if Next >= Buf'Last then
-         Buf (Next) := '*';
-      else Buf (Next) := C;
-         Next := Next + 1;
-      end if;
-   end Put;
+      Write (2, S & ASCII.LF, S'Length + 1);
+   end Put_Line;
 
    ----------------------
    -- Resume_All_Tasks --
    ----------------------
 
    procedure Resume_All_Tasks (Thread_Self : OS_Interface.Thread_Id) is
-      C : ST.Task_ID;
-      R : Boolean;
+      C     : Task_Id;
+      Dummy : Boolean;
+      pragma Unreferenced (Dummy);
 
    begin
       STPO.Lock_RTS;
       C := All_Tasks_List;
 
       while C /= null loop
-         R := STPO.Resume_Task (C, Thread_Self);
+         Dummy := STPO.Resume_Task (C, Thread_Self);
          C := C.Common.All_Tasks_Link;
       end loop;
 
       STPO.Unlock_RTS;
    end Resume_All_Tasks;
 
-   ----------
-   -- Self --
-   ----------
-
-   function Self return Task_ID is
-   begin
-      return STPO.Self;
-   end Self;
-
    ---------------
    -- Set_Trace --
    ---------------
 
-   procedure Set_Trace
-     (Flag  : Character;
-      Value : Boolean := True)
-   is
+   procedure Set_Trace (Flag  : Character; Value : Boolean := True) is
    begin
       Trace_On (Flag) := Value;
    end Set_Trace;
@@ -528,56 +241,69 @@ package body System.Tasking.Debug is
    -- Set_User_State --
    --------------------
 
-   procedure Set_User_State (Value : Integer) is
+   procedure Set_User_State (Value : Long_Integer) is
    begin
       STPO.Self.User_State := Value;
    end Set_User_State;
 
-   -----------
-   -- Space --
-   -----------
+   ------------------------
+   -- Signal_Debug_Event --
+   ------------------------
 
-   procedure Space (Buffer : Buffer_Ptr) is
-      Next : Buf_Range renames Buffer.Next;
-      Buf  : Buf_Array renames Buffer.Chars;
+   procedure Signal_Debug_Event
+     (Event_Kind : Event_Kind_Type;
+      Task_Value : Task_Id)
+   is
+   begin
+      null;
+   end Signal_Debug_Event;
+
+   --------------------
+   -- Stop_All_Tasks --
+   --------------------
+
+   procedure Stop_All_Tasks is
+      C : Task_Id;
+
+      Dummy : Boolean;
+      pragma Unreferenced (Dummy);
 
    begin
-      if Next >= Buf'Last then
-         Buf (Next) := '*';
-      else
-         Next := Next + 1;
-      end if;
-   end Space;
+      STPO.Lock_RTS;
 
-   procedure Space
-     (N      : Integer;
-      Buffer : Buffer_Ptr)
-   is
-      Next : Buf_Range renames Buffer.Next;
-      Buf  : Buf_Array renames Buffer.Chars;
+      C := All_Tasks_List;
+      while C /= null loop
+         Dummy := STPO.Stop_Task (C);
+         C := C.Common.All_Tasks_Link;
+      end loop;
+
+      STPO.Unlock_RTS;
+   end Stop_All_Tasks;
+
+   ----------------------------
+   -- Stop_All_Tasks_Handler --
+   ----------------------------
 
+   procedure Stop_All_Tasks_Handler is
    begin
-      if Next + N > Buf'Last then
-         Buf (Next) := '*';
-      else
-         Next := Next + N;
-      end if;
-   end Space;
+      STPO.Stop_All_Tasks;
+   end Stop_All_Tasks_Handler;
 
    -----------------------
    -- Suspend_All_Tasks --
    -----------------------
 
    procedure Suspend_All_Tasks (Thread_Self : OS_Interface.Thread_Id) is
-      C : ST.Task_ID;
-      R : Boolean;
+      C     : Task_Id;
+      Dummy : Boolean;
+      pragma Unreferenced (Dummy);
 
    begin
       STPO.Lock_RTS;
       C := All_Tasks_List;
 
       while C /= null loop
-         R := STPO.Suspend_Task (C, Thread_Self);
+         Dummy := STPO.Suspend_Task (C, Thread_Self);
          C := C.Common.All_Tasks_Link;
       end loop;
 
@@ -611,95 +337,36 @@ package body System.Tasking.Debug is
    -----------
 
    procedure Trace
-     (Self_ID  : ST.Task_ID;
+     (Self_Id  : Task_Id;
       Msg      : String;
-      Other_ID : ST.Task_ID;
-      Flag     : Character)
+      Flag     : Character;
+      Other_Id : Task_Id := null)
    is
-      Buf : aliased Buffer;
-      use type System.Task_Info.Task_Image_Type;
-
    begin
       if Trace_On (Flag) then
-         Clear (Buf'Unchecked_Access);
-         Put (Self_ID, Hex_Address_Width, Buf'Unchecked_Access);
-         Put (':', Buf'Unchecked_Access);
-         Put (Flag, Buf'Unchecked_Access);
-         Put (':', Buf'Unchecked_Access);
-         Put
-           (Integer_Address (Self_ID.Serial_Number),
-            4, Buf'Unchecked_Access);
-         Space (Buf'Unchecked_Access);
-
-         if Self_ID.Common.Task_Image = null then
-            Put ("", 15, Buf'Unchecked_Access);
-         else
-            Put (Self_ID.Common.Task_Image.all, 15, Buf'Unchecked_Access);
-         end if;
-
-         Space (Buf'Unchecked_Access);
+         Put (To_Integer (Self_Id)'Img &
+              ':' & Flag & ':' &
+              Self_Id.Common.Task_Image (1 .. Self_Id.Common.Task_Image_Len) &
+              ':');
 
-         if Other_ID /= null then
-            Put
-              (Integer_Address (Other_ID.Serial_Number),
-               4, Buf'Unchecked_Access);
-            Space (Buf'Unchecked_Access);
+         if Other_Id /= null then
+            Put (To_Integer (Other_Id)'Img & ':');
          end if;
 
-         Put (Msg, Buf.Chars'Last - Buf.Next + 1, Buf'Unchecked_Access);
-         Write_Buf (Buf'Unchecked_Access);
+         Put_Line (Msg);
       end if;
    end Trace;
 
-   procedure Trace
-     (Self_ID : ST.Task_ID;
-      Msg     : String;
-      Flag    : Character)
-   is
-   begin
-      Trace (Self_ID, Msg, null, Flag);
-   end Trace;
-
-   procedure Trace
-     (Msg : String;
-      Flag : Character)
-   is
-      Self_ID : constant ST.Task_ID := STPO.Self;
-
-   begin
-      Trace (Self_ID, Msg, null, Flag);
-   end Trace;
-
-   procedure Trace
-     (Msg      : String;
-      Other_ID : ST.Task_ID;
-      Flag     : Character)
-   is
-      pragma Warnings (Off, Other_ID);
-
-      Self_ID : constant ST.Task_ID := STPO.Self;
-
-   begin
-      Trace (Self_ID, Msg, null, Flag);
-   end Trace;
-
-   ---------------
-   -- Write_Buf --
-   ---------------
-
-   procedure Write_Buf (Buffer : Buffer_Ptr) is
-      Next : Buf_Range renames Buffer.Next;
-      Buf  : Buf_Array renames Buffer.Chars;
-
-      procedure put_char (C : Integer);
-      pragma Import (C, put_char, "put_char");
+   -----------
+   -- Write --
+   -----------
 
+   procedure Write (Fd : Integer; S : String; Count : Integer) is
+      Discard : Integer;
+      pragma Unreferenced (Discard);
    begin
-      for J in 1 .. Next - 1 loop
-         put_char (Character'Pos (Buf (J)));
-      end loop;
-
-      put_char (Character'Pos (ASCII.LF));
-   end Write_Buf;
+      Discard := System.CRTL.write (Fd, S (S'First)'Address, Count);
+      --  Is it really right to ignore write errors here ???
+   end Write;
 
 end System.Tasking.Debug;