1. with Ada.Exceptions;                    use Ada.Exceptions; 
  2. with GNAT.Source_Info;                  use GNAT.Source_Info; 
  3. with Hashed_Strings;                    use Hashed_Strings; 
  4.  
  5. package Debugging is 
  6.  
  7.     ---------------------------------------------------------------------------- 
  8.     -- This package parses the command line arguments at elaboration time. The 
  9.     -- following are the recognized arguments: 
  10.     -- 
  11.     -- -DV=[verbosity]          (Debugging Verbosity) 
  12.     -- -DV[system]=[verbosity]  (Debugging Verbosity per system) 
  13.     -- 
  14.     --     Where: 
  15.     --     [verbosity] is the verbosity level. 
  16.     --         'e' : Errors only 
  17.     --         'w' : Warnings and errors only 
  18.     --         'i' : All info, warnings and errors 
  19.     -- 
  20.     --     [system] is the name of a specific debugging system. The standard 
  21.     --         systems names are predefined in the Engine_Debuggin package. 
  22.     -- 
  23.     -- -DD=[decoration]         (Debugging Decoration) 
  24.     -- 
  25.     --     [decoration] is the level of decoration for every line output by the 
  26.     --         debugging package. The decoration levels are: 
  27.     --         '0' : No decoration 
  28.     --         '1' : Prefixed with current task image 
  29.     --         '2' : Prefixed with calling source unit and current task image 
  30.     ---------------------------------------------------------------------------- 
  31.  
  32.     type Output_Proc is access procedure( str : String ); 
  33.  
  34.     -- Description of values: 
  35.     -- SILENT : Never ever display output with this level. 
  36.     -- ALWAYS : The default verbosity level, more verbose than SILENT but less 
  37.     --          verbose than displaying only error messages. This is used for 
  38.     --          temporary debugging output during source code development. 
  39.     -- ERROR  : Severe error messages and exceptions. 
  40.     -- WARNING: Minor warning messages that can be ignored. 
  41.     -- INFO   : Informational messages that describe what is happening. 
  42.     type Verbosity_Level is (SILENT, ALWAYS, ERROR, WARNING, INFO); 
  43.  
  44.     -- Description of values: 
  45.     -- NONE        : Display the text without decoration, as-is. 
  46.     -- TASK_IMAGE  : Prefix the text with the image of the current task. 
  47.     -- SOURCE_UNIT : Include the calling source unit with the task image. 
  48.     type Decoration_Level is (NONE, TASK_IMAGE, SOURCE_UNIT); 
  49.  
  50.     NO_SYSTEM : constant Hashed_String := To_Hashed_String( "" ); 
  51.  
  52.     ---------------------------------------------------------------------------- 
  53.  
  54.     -- Sends a line of text to the debugging output procedure. Do not specify 
  55.     -- entity and location; they are used to determine the calling location in 
  56.     -- the code. 
  57.     procedure Dbg( str      : String; 
  58.                    system   : Hashed_String := NO_SYSTEM; 
  59.                    level    : Verbosity_Level := ALWAYS; 
  60.                    entity   : String := GNAT.Source_Info.Enclosing_Entity; 
  61.                    location : String := GNAT.Source_Info.Source_Location ); 
  62.  
  63.     -- Sends debugging information from an exception to the output procedure. 
  64.     -- A stack traceback will also be displayed if available (Windows only.) Do 
  65.     -- not specify entity and location; they are used to determine the calling 
  66.     -- location in the code. 
  67.     procedure Dbg( e        : Exception_Occurrence; 
  68.                    system   : Hashed_String := NO_SYSTEM; 
  69.                    level    : Verbosity_Level := ALWAYS; 
  70.                    entity   : String := GNAT.Source_Info.Enclosing_Entity; 
  71.                    location : String := GNAT.Source_Info.Source_Location ); 
  72.  
  73.     -- Sets the global decoration level for output text. 
  74.     procedure Set_Decoration( level : Decoration_Level ); 
  75.  
  76.     -- Sets the procedure to receive debugging output. Passing a value of null 
  77.     -- will disable all debugging output, which is effectively the same as 
  78.     -- setting the global verbosity level to SILENT. 
  79.     procedure Set_Output( output : Output_Proc ); 
  80.  
  81.     -- Sets the global verbosity level. If an individual system has a higher 
  82.     -- level of verbosity set then it will be respected. The default global 
  83.     -- verbosity is WARNING for debug build and ALWAYS for a non-debug build. 
  84.     procedure Set_Verbosity( level : Verbosity_Level ); 
  85.  
  86.     -- Sets the maximum verbosity level per system. No output from 'system' with 
  87.     -- a verbosity level higher than this will be displayed unless it is still 
  88.     -- less than the global verbosity level. 
  89.     procedure Set_Verbosity( system : Hashed_String; level : Verbosity_Level ); 
  90.  
  91. end Debugging;