DataMuseum.dk

Presents historical artifacts from the history of:

Rational R1000/400 Tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Rational R1000/400 Tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: B T

⟦d7c1c1c6a⟧ TextFile

    Length: 21254 (0x5306)
    Types: TextFile
    Names: »B«

Derivation

└─⟦180fe333a⟧ Bits:30000405 8mm tape, Rational 1000, SW CATALOG, 10_20_0
└─⟦180fe333a⟧ Bits:30000537 8mm tape, Rational 1000, SW Catalog 10_20_0
    └─⟦5cb1d1d7f⟧ »DATA« 
        └─⟦3b1ee7bd8⟧ 
            └─⟦this⟧ 

TextFile

with Text_Io;
use Text_Io;
with Implementation_Dependencies;
with String_Pkg;
use String_Pkg;

package body User_Interface is

    --|  Overview
    --|
    --|  This package performs the user interface for the source instrumenter.
    --|  The procedures are used to return the statement trace level and
    --|  variable trace mode for the unit. The first procedure gets the options
    --|  for a compilation unit and the second gets any optins needed for an
    --|  individual program unit.

    Input_Line : String (1 .. Implementation_Dependencies.Line_Length);
    --|  Used to hold the users input.

    Length_Of_Input : Natural;
    --|  The number of characters in the users input

    Trace_Mode : Trace_Modes := Decision_Point;
    --|  The tracing level for the compilation unit.  If the tracing mode
    --|  for the compilation unit is mixed.  Then the user is asked for
    --|  the tracing mode for each nested unit.

    Do_Type_Tracing : Boolean;
    --|  Indicates whether type tracing is being done for the current
    --|  compilation unit.

    --------------------------------------------------------------------
    --  Local Procedure Definitions
    --------------------------------------------------------------------

    procedure Get_User_Options (Tracing_Mode : out Trace_Modes;
                                Type_Tracing_Mode : out Boolean);
    --|  Get user options when he wants to supply his own optins

    --------------------------------------------------------------------

    procedure Print_Instrumenting_Help;
    --|  Prints an explantion of tracing options

    --------------------------------------------------------------------

    procedure Print_Tracing_Help;
    --|  Prints an explanation of statement tracing options for a
    --|  compilation unit.

    --------------------------------------------------------------------

    procedure Print_Unit_Tracing_Help;
    --|  Prints an explanation of statement tracing options for a
    --|  program unit.

    --------------------------------------------------------------------

    procedure Print_Type_Help;
    --|  Prints an explanation of type tracing.

    --------------------------------------------------------------------
    --  External Procedures
    --------------------------------------------------------------------

    procedure Get_Instrumenting_Instructions
                 (Tracing_Mode : out Trace_Modes;
                  Type_Tracing_Mode : out Boolean) is

        --|  Effects
        --|
        --|  This procedure will get the instrumenting instructions from the user
        --|  for the current compilation unit.  The variables TRACE_MODE and
        --|  DO_TYPE_TRACING are set to indeicate the user selected options for
        --|  the compilation unit.  These options are also returned to the
        --|  calling procedure.

        Valid_Input : Boolean := False;
        --|  Used to loop until the user supplies a valid input.


        procedure Display_Options is

            --|  Effects
            --|
            --|  This procedure will display the menu for selecting trace options
            --|  for a compilation unit.

        begin
            Put_Line ("Instrumenting Options are:");
            New_Line;
            Put_Line ("1 - Path/Autopath Analyzer Defaults");
            Put_Line ("2 - Performance Analyzer Defaults");
            Put_Line ("3 - Self Metric Defaults");
            Put_Line ("4 - User Supplied Options");
            New_Line;
            Put ("Enter option (1, 2, 3, 4, ?, or <cr> for default of 1): ");
        end Display_Options;


    begin
        -- GET_INSTRUMENTING_INSTRUCTIONS
        New_Line;
        Put_Line ("       Source Instrumenter Version 1.0");
        New_Line;
        New_Line;
        Display_Options;

        --  Loop until the user provides a valid input.

        while not Valid_Input loop
            Get_Line (Text_Io.Standard_Input, Input_Line, Length_Of_Input);
            if Length_Of_Input < 1 then
                -- no input, use defaults
                Trace_Mode := Decision_Point;
                Do_Type_Tracing := False;
                Valid_Input := True;
            else
                -- determine users input and set appropriate trace modes
                case Input_Line (1) is
                    when '1' =>
                        Trace_Mode := Decision_Point;
                        Do_Type_Tracing := False;
                        Valid_Input := True;
                    when '2' =>
                        Trace_Mode := Entry_Exit;
                        Do_Type_Tracing := False;
                        Valid_Input := True;
                    when '3' =>
                        Trace_Mode := Decision_Point;
                        Do_Type_Tracing := True;
                        Valid_Input := True;
                    when '4' =>
                        --  user doesn't want defaults, so prompt for input
                        Get_User_Options (Trace_Mode, Do_Type_Tracing);
                        Valid_Input := True;
                    when '?' =>
                        Print_Instrumenting_Help;
                        Display_Options;
                    when others =>
                        -- bad input, repeat loop
                        Put_Line ("Invalid input, try again:  ");
                        New_Line;
                        Display_Options;
                end case;
            end if;
        end loop;

        -- Set the TRACING_MODE and TYPE_TRACING_MODE for the compilation unit.
        -- These will be used in determining what to prompt the user for, for
        -- nested unit.

        Tracing_Mode := Trace_Mode;
        Type_Tracing_Mode := Do_Type_Tracing;
    end Get_Instrumenting_Instructions;

    --------------------------------------------------------------------

    procedure Get_Unit_Instructions (Current_Unit : in Unit_Specification;
                                     Is_Package_Spec : in Boolean;
                                     Requested_Trace_Level : out Trace_Level;
                                     Scope_Name : in String;
                                     List_Of_Variables : out String_List) is

        --|  Effects
        --|
        --|  This procedure gets the instrumenting instruction for a nested unit.
        --|  It determines whether it needs to ask for statement trace level, type
        --|  tracing level, or both,by looking at the modes for the compilation
        --|  unit.  The current units name is displayed and then the user is
        --|  prompted for the required inputs

        Valid_Input : Boolean := False;
        --|  Used to loop until user supplies valid input

        Temp_List : String_List := String_Lists.Create;
        --|  Used to contain the list of variables the user wants to trace

        procedure Display_Unit_Trace_Options is

            --|  Effects
            --|
            --|  This procedure displays the menu of statement trace options for
            --|  a program unit.

        begin
            New_Line;
            New_Line;
            Put_Line ("Available trace levels are:");
            Put_Line ("1 - Entry/Exit only");
            Put_Line ("2 - Entry/Exit and Decision Point");
            Put_Line ("3 - Every statement");
            New_Line;
            Put ("Enter option ( default is 2): ");
        end Display_Unit_Trace_Options;

        procedure Display_Unit (Unit_To_Display : in Unit_Specification) is

            --|  Effects
            --|
            --|  This program displays the Name of the current unit.

        begin
            New_Line;
            New_Line;
            Put_Line ("Current Unit Being Instrumented is:");
            New_Line;
            for Index in 1 .. Unit_To_Display'Last loop
                Put (Unit_To_Display (Index));
                if Unit_To_Display (Index) = ';' then
                    New_Line;
                    Put ("       ");
                end if;
            end loop;
            New_Line;
            New_Line;
        end Display_Unit;

        procedure Strip_Blanks (From : in out String; Len : in out Natural) is

            --|  Effects
            --|
            --|  This procedure strips all of the blanks out of a string. It
            --|  returns the string padded with blank on the right, and it
            --|  returns the length of the string.

            Index : Natural := 1;
            --|  Used to index into the string.

        begin
            while Index <= Len loop
                -- loop through the string
                if From (Index) = ' ' then
                    From (Index .. Len - 1) := From (Index + 1 .. Len);
                    Len := Len - 1;
                else
                    Index := Index + 1;
                end if;
            end loop;
        end Strip_Blanks;

    begin

        -- Display current unit
        Display_Unit (Current_Unit);

        -- Determine if statement trace level needs to be prompted for

        if not Is_Package_Spec then
            -- package specs have no statements
            if Trace_Mode = Mixed then
                -- only need to get if in mixed mode
                Display_Unit_Trace_Options;
                while not Valid_Input loop
                    -- loop until valid statement trace option
                    Get_Line (Text_Io.Standard_Input,
                              Input_Line, Length_Of_Input);
                    if Length_Of_Input < 1 then
                        -- no input, use defaults
                        Requested_Trace_Level := Decision_Point;
                        Valid_Input := True;
                    else
                        -- determine user response
                        case Input_Line (1) is
                            when '1' =>
                                Requested_Trace_Level := Entry_Exit;
                                Valid_Input := True;
                            when '2' =>
                                Requested_Trace_Level := Decision_Point;
                                Valid_Input := True;
                            when '3' =>
                                Requested_Trace_Level := All_Statements;
                                Valid_Input := True;
                            when '?' =>
                                Print_Unit_Tracing_Help;
                                Display_Unit_Trace_Options;
                            when others =>
                                Put_Line ("Invalid input, try again:  ");
                                Display_Unit_Trace_Options;
                        end case;
                    end if;
                end loop;
            else
                --  trace mode is not mixed
                Requested_Trace_Level :=
                   Trace_Mode;   -- return trace level for comp
            end if;
        end if;

        -- Do we need to prompt for variables to trace?

        if Do_Type_Tracing then
            Put_Line
               ("Enter variables to trace.  Enter one variable per line ");
            Put_Line ("or *ALL to trace all variables in the scope.");
            Put_Line ("Terminate the list with a blank line");
            loop
                -- loop until blank line encountered
                Put (">> ");
                Get_Line (Text_Io.Standard_Input, Input_Line, Length_Of_Input);
                exit when Length_Of_Input < 1;

                -- strip blanks out of user requested variable name and then add
                -- the variable name to the list with its scope name prepended

                Strip_Blanks (Input_Line (1 .. Length_Of_Input),
                              Length_Of_Input);
                if Scope_Name = "" then
                    String_Lists.Attach
                       (Temp_List, Create (Input_Line (1 .. Length_Of_Input)));
                else
                    String_Lists.Attach (Temp_List,
                                         Create (Scope_Name) & "." &
                                            Input_Line (1 .. Length_Of_Input));
                end if;
            end loop;
        end if;
        List_Of_Variables := Temp_List; -- return the list of variables
    end Get_Unit_Instructions;


    --------------------------------------------------------------
    --  Local Procedure Bodies
    --------------------------------------------------------------

    procedure Get_User_Options (Tracing_Mode : out Trace_Modes;
                                Type_Tracing_Mode : out Boolean) is

        --|  Effects
        --|
        --|  This procedure is called when the user specifies that she wants to
        --|  select her own instrumenting options instead of using one of
        --|  the predefined options.  The procedure will prompt the user for
        --|  the statement trace level and whether to do type tracing.

        Valid_Input : Boolean := False;
        --|  used to loop until valid user input

        procedure Display_Trace_Options is

            --|  Effects
            --|
            --|  This procedure displays the possible trace modes for a compilation unit.

        begin
            New_Line;
            New_Line;
            Put_Line ("Available trace levels are:");
            Put_Line ("1 - Entry/Exit only");
            Put_Line ("2 - Entry/Exit and Decision Point");
            Put_Line ("3 - Every statement");
            Put_Line ("4 - Mixed (Each program unit has its own trace level)");
            New_Line;
            Put ("Enter option ( default is 2): ");
        end Display_Trace_Options;

    begin

        -- Prompt user for statement trace mode and loop until he responds
        -- with a valid input

        Display_Trace_Options;
        while not Valid_Input loop
            Get_Line (Text_Io.Standard_Input, Input_Line, Length_Of_Input);
            if Length_Of_Input < 1 then
                Tracing_Mode := Decision_Point;
                Valid_Input := True;
            else
                case Input_Line (1) is
                    when '1' =>
                        Tracing_Mode := Entry_Exit;
                        Valid_Input := True;
                    when '2' =>
                        Tracing_Mode := Decision_Point;
                        Valid_Input := True;
                    when '3' =>
                        Tracing_Mode := All_Statements;
                        Valid_Input := True;
                    when '4' =>
                        Tracing_Mode := Mixed;
                        Valid_Input := True;
                    when '?' =>
                        Print_Tracing_Help;
                        Display_Trace_Options;
                    when others =>
                        Put_Line ("Invalid input, try again:  ");
                        Display_Trace_Options;
                end case;
            end if;
        end loop;

        -- now determine whether the user wants to do type tracing

        Valid_Input := False;
        New_Line;
        New_Line;
        Put ("Do you want to do type tracing (default is no): ");
        while not Valid_Input loop
            Get_Line (Text_Io.Standard_Input, Input_Line, Length_Of_Input);
            if Length_Of_Input < 1 then
                Type_Tracing_Mode := False;
                Valid_Input := True;
            elsif Input_Line (1) = 'y' or Input_Line (1) = 'Y' then
                Type_Tracing_Mode := True;
                Valid_Input := True;
            elsif Input_Line (1) = 'n' or Input_Line (1) = 'N' then
                Type_Tracing_Mode := False;
                Valid_Input := True;
            elsif Input_Line (1) = '?' then
                Print_Type_Help;
                Put ("Do you want to do type tracing (default is no): ");
            else
                Put_Line ("Invalid input, try again: ");
                New_Line;
                New_Line;
                Put ("Do you want to do type tracing (default is no): ");
            end if;
        end loop;
    end Get_User_Options;

    --------------------------------------------------------------

    procedure Print_Instrumenting_Help is

        --|  Effects
        --|
        --|  This procedure displays help on selecting trace modes

    begin
        New_Line;
        New_Line;
        Put_Line ("When instrumenting code two options need to be specified.");
        Put_Line ("The user can use the defaults provided for one of the");
        Put_Line ("tools (options 1 to 3) or may supply his own options.");
        New_Line;
        Put_Line ("The first option determines where breakpoints are put.");
        Put_Line ("There are four choices for this option: ");
        Put_Line
           ("   Entry/Exit       - breakpoints are placed at entry exit only");
        Put_Line
           ("   Decision Point   - breakpoints are also placed at decision points");
        Put_Line
           ("   Every Statement  - A breakpoint is placed at each statement");
        Put_Line
           ("   Mixed            - Each program unit gets its own trace level");
        New_Line;
        Put_Line
           ("The second option determines whether variables and types are");
        Put_Line ("traced.  This option is either on or off.");
        New_Line;
        Put_Line ("When selecting options, the user can use either one of the");
        Put_Line
           ("sets of predefined defaults or specify his own options.  The");
        Put_Line ("predefined defaults are as follows:");
        New_Line;
        Put_Line ("DEFAULT                      TRACE                   TYPE");
        Put_Line
           ("NAME                         LEVEL                  TRACING");
        Put_Line
           ("-------------------------------------------------------------");
        New_Line;
        Put_Line ("Path/Autopath Analyzer      Decision point           No");
        Put_Line ("Performance Analyzer        Entry/Exit               No");
        Put_Line ("Self Metric                 Decision point           Yes");
        New_Line;
    end Print_Instrumenting_Help;

    --------------------------------------------------------------

    procedure Print_Tracing_Help is

        --|  Effects
        --|
        --|  Display information about trace modes

    begin
        New_Line;
        New_Line;
        Put_Line ("There are four possible trace modes.  The four modes are:");
        New_Line;
        Put_Line
           ("Entry/Exit      - This mode provides breakpoints at entry to");
        Put_Line ("                  and exit from each program unit");
        Put_Line ("Decision Point  - This mode provides breakpoints at every ");
        Put_Line
           ("                  decision point as well as at entry to and");
        Put_Line ("                  exit from each program unit");
        Put_Line ("Every Statement - This mode provides breakpoints at every");
        Put_Line ("                  statement");
        Put_Line ("Mixed           - This mode allows the user to instrument");
        Put_Line
           ("                  each program unit at any level.  The user");
        Put_Line ("                  will be prompted to provide the desired");
        Put_Line ("                  trace level for each program unit in the");
        Put_Line ("                  compilation");
        New_Line;
    end Print_Tracing_Help;

    --------------------------------------------------------------

    procedure Print_Unit_Tracing_Help is

        --|  Effects
        --|
        --|  Display possible trace modes for a unit

    begin
        New_Line;
        New_Line;
        Put_Line ("There are three possible trace modes.  They are:");
        New_Line;
        Put_Line
           ("Entry/Exit      - This mode provides breakpoints at entry to");
        Put_Line ("                  and exit from each program unit");
        Put_Line ("Decision Point  - This mode provides breakpoints at every ");
        Put_Line
           ("                  decision point as well as at entry to and");
        Put_Line ("                  exit from each program unit");
        Put_Line ("Every Statement - This mode provides breakpoints at every");
        Put_Line ("                  statement");
        New_Line;
    end Print_Unit_Tracing_Help;

    --------------------------------------------------------------

    procedure Print_Type_Help is

        --|  Effects
        --|
        --|  Displays informatin about type tracing

    begin
        New_Line;
        New_Line;
        Put_Line ("The user can enable or disable type and variable tracing. ");
        Put_Line
           ("If the user responds yes to this question then type tracing");
        Put_Line ("will be enabled, and the user will be prompted to provide");
        Put_Line ("the variables to be traced.");
        New_Line;
        Put_Line ("NOTE:  If a package specification is instrumented without");
        Put_Line ("type tracing, then all modules that with that package must");
        Put_Line ("also be instrumented without type tracing");
        New_Line;
    end Print_Type_Help;

end User_Interface;