+2019-07-11 Hristian Kirtchev <kirtchev@adacore.com>
+
+ * bindo.adb: Update the section of switches and debugging
+ elaboration issues.
+ * bindo.ads: Add type Elaboration_Phase.
+ * bindo-augmentors.adb: Add use clause for
+ Bindo.Writers.Phase_Writers.
+ (Augment_Library_Graph): Signal the start and end of the
+ aubmentation phase.
+ * bindo-builders.adb: Add with and use clause for Bindo.Writers.
+ Add use clause for Bindo.Writers.Phase_Writers.
+ (Build_Invocation_Graph): Signal the start and end of the
+ invocation graph construction phase.
+ (Build_Library_Graph): Signal the start and end of the library
+ graph construction phase.
+ * bindo-diagnostics.adb: Add use clause for
+ Bindo.Writers.Phase_Writers.
+ (Diagnose_Cycle): Signal the start and end of the cycle
+ diagnostic phase.
+ * bindo-elaborators.adb: Add use clause for
+ Bindo.Writers.Phase_Writers.
+ (Elaborate_Units): Signal the start and end of the unit
+ elaboration phase.
+ * bindo-graphs.adb: Add use clause for
+ Bindo.Writers.Phase_Writers.
+ (Find_Components): Signal the start and end of the component
+ discovery phase.
+ (Find_Cycles): Signal the start and end of the cycle discovery
+ phase.
+ * bindo-units.adb: Add with and use clause for Bindo.Writers.
+ Add use clause for Bindo.Writers.Phase_Writers.
+ (Collect_Elaborable_Units): Signal the start and end of the unit
+ collection phase.
+ * bindo-validators.adb: Add with and use clause for
+ Bindo.Writers. Add use clause for Bindo.Writers.Phase_Writers.
+ (Validate_Cycles, Validate_Elaboration_Order,
+ Validate_Invocation_Graph, Validate_Library_Graph): Signal the
+ start and end of the libray graph validation phase.
+ * bindo-writers.ads, bindo-writers.adb: Add new nested package
+ Phase_Writers.
+ * debug.adb: Update the documentation of switch d_S.
+
2019-07-11 Yannick Moy <moy@adacore.com>
* sem_res.adb (Check_Argument_Order): Special case calls to
with Output; use Output;
with Types; use Types;
-with Bindo.Writers; use Bindo.Writers;
+with Bindo.Writers;
+use Bindo.Writers;
+use Bindo.Writers.Phase_Writers;
package body Bindo.Augmentors is
return;
end if;
+ Start_Phase (Library_Graph_Augmentation);
+
-- Prepare the statistics data
Longest_Path := 0;
Visit_Elaboration_Roots (Inv_Graph, Lib_Graph);
Write_Statistics;
+
+ End_Phase (Library_Graph_Augmentation);
end Augment_Library_Graph;
----------------------------
use Bindo.Validators.Invocation_Graph_Validators;
use Bindo.Validators.Library_Graph_Validators;
+with Bindo.Writers;
+use Bindo.Writers;
+use Bindo.Writers.Phase_Writers;
+
with GNAT; use GNAT;
with GNAT.Dynamic_HTables; use GNAT.Dynamic_HTables;
begin
pragma Assert (Present (Lib_G));
+ Start_Phase (Invocation_Graph_Construction);
+
-- Prepare the global data
Inv_Graph :=
For_Each_Elaborable_Unit (Create_Edges'Access);
Validate_Invocation_Graph (Inv_Graph);
+ End_Phase (Invocation_Graph_Construction);
return Inv_Graph;
end Build_Invocation_Graph;
function Build_Library_Graph return Library_Graph is
begin
+ Start_Phase (Library_Graph_Construction);
+
-- Prepare the global data
Lib_Graph :=
Create_Forced_Edges;
Validate_Library_Graph (Lib_Graph);
+ End_Phase (Library_Graph_Construction);
return Lib_Graph;
end Build_Library_Graph;
with Bindo.Writers;
use Bindo.Writers;
use Bindo.Writers.Cycle_Writers;
+use Bindo.Writers.Phase_Writers;
package body Bindo.Diagnostics is
Next_Edge : Library_Graph_Edge_Id;
begin
+ Start_Phase (Cycle_Diagnostics);
+
First_Edge := No_Library_Graph_Edge;
-- Inspect the edges of the cycle in pairs, emitting diagnostics based
(G => Lib_Graph,
Cycle => Cycle,
First_Edge => First_Edge);
+
+ End_Phase (Cycle_Diagnostics);
end Diagnose_Cycle;
--------------------------------------
use Bindo.Writers.Elaboration_Order_Writers;
use Bindo.Writers.Invocation_Graph_Writers;
use Bindo.Writers.Library_Graph_Writers;
+use Bindo.Writers.Phase_Writers;
use Bindo.Writers.Unit_Closure_Writers;
with GNAT; use GNAT;
Status : Elaboration_Order_Status;
begin
+ Start_Phase (Unit_Elaboration);
+
-- Initialize all unit-related data structures and gather all units
-- that need elaboration.
-- Destroy all unit-related data structures
Finalize_Units;
+ End_Phase (Unit_Elaboration);
-- Halt the bind when there is no satisfactory elaboration order
with Bindo.Writers;
use Bindo.Writers;
+use Bindo.Writers.Phase_Writers;
package body Bindo.Graphs is
begin
pragma Assert (Present (G));
+ Start_Phase (Component_Discovery);
+
-- Initialize or reinitialize the components of the graph
Initialize_Components (G);
-- before they can be elaborated.
Update_Pending_Predecessors_Of_Components (G);
+ End_Phase (Component_Discovery);
end Find_Components;
-----------------
begin
pragma Assert (Present (G));
+ Start_Phase (Cycle_Discovery);
+
-- The cycles of graph G are discovered using Tarjan's enumeration
-- of the elementary circuits of a directed-graph algorithm. Do not
-- modify this code unless you intimately understand the algorithm.
Cycle_Count => Cycle_Count,
Cycle_Limit => All_Cycle_Limit);
end loop;
+
+ End_Phase (Cycle_Discovery);
end Find_Cycles;
--------------------------------
-- --
------------------------------------------------------------------------------
+with Bindo.Writers;
+use Bindo.Writers;
+use Bindo.Writers.Phase_Writers;
+
package body Bindo.Units is
-------------------
procedure Collect_Elaborable_Units is
begin
+ Start_Phase (Unit_Collection);
+
for U_Id in ALI.Units.First .. ALI.Units.Last loop
Process_Unit (U_Id);
end loop;
+
+ End_Phase (Unit_Collection);
end Collect_Elaborable_Units;
------------------------
with Output; use Output;
with Types; use Types;
-with Bindo.Units; use Bindo.Units;
+with Bindo.Units;
+use Bindo.Units;
+
+with Bindo.Writers;
+use Bindo.Writers;
+use Bindo.Writers.Phase_Writers;
package body Bindo.Validators is
return;
end if;
+ Start_Phase (Cycle_Validation);
+
Iter := Iterate_All_Cycles (G);
while Has_Next (Iter) loop
Next (Iter, Cycle);
Validate_Cycle (G, Cycle);
end loop;
+ End_Phase (Cycle_Validation);
+
if Has_Invalid_Cycle then
raise Invalid_Cycle;
end if;
return;
end if;
+ Start_Phase (Elaboration_Order_Validation);
+
Validate_Units (Order);
+ End_Phase (Elaboration_Order_Validation);
+
if Has_Invalid_Data then
raise Invalid_Elaboration_Order;
end if;
return;
end if;
+ Start_Phase (Invocation_Graph_Validation);
+
Validate_Invocation_Graph_Vertices (G);
- Validate_Invocation_Graph_Edges (G);
+ Validate_Invocation_Graph_Edges (G);
+
+ End_Phase (Invocation_Graph_Validation);
if Has_Invalid_Data then
raise Invalid_Invocation_Graph;
return;
end if;
+ Start_Phase (Library_Graph_Validation);
+
Validate_Library_Graph_Vertices (G);
- Validate_Library_Graph_Edges (G);
+ Validate_Library_Graph_Edges (G);
+
+ End_Phase (Library_Graph_Validation);
if Has_Invalid_Data then
raise Invalid_Library_Graph;
end Write_Statistics;
end Library_Graph_Writers;
+ -------------------
+ -- Phase_Writers --
+ -------------------
+
+ package body Phase_Writers is
+
+ subtype Phase_Message is String (1 .. 32);
+
+ -- The following table contains the phase-specific messages for phase
+ -- completion.
+
+ End_Messages : constant array (Elaboration_Phase) of Phase_Message :=
+ (Component_Discovery => "components discovered. ",
+ Cycle_Diagnostics => "cycle diagnosed. ",
+ Cycle_Discovery => "cycles discovered. ",
+ Cycle_Validation => "cycles validated. ",
+ Elaboration_Order_Validation => "elaboration order validated. ",
+ Invocation_Graph_Construction => "invocation graph constructed. ",
+ Invocation_Graph_Validation => "invocation graph validated. ",
+ Library_Graph_Augmentation => "library graph augmented. ",
+ Library_Graph_Construction => "library graph constructed. ",
+ Library_Graph_Elaboration => "library graph elaborated. ",
+ Library_Graph_Validation => "library graph validated. ",
+ Unit_Collection => "units collected. ",
+ Unit_Elaboration => "units elaborated. ");
+
+ -- The following table contains the phase-specific messages for phase
+ -- commencement.
+
+ Start_Messages : constant array (Elaboration_Phase) of Phase_Message :=
+ (Component_Discovery => "discovering components... ",
+ Cycle_Diagnostics => "diagnosing cycle... ",
+ Cycle_Discovery => "discovering cycles... ",
+ Cycle_Validation => "validating cycles... ",
+ Elaboration_Order_Validation => "validating elaboration order... ",
+ Invocation_Graph_Construction => "constructing invocation graph...",
+ Invocation_Graph_Validation => "validating invocation graph... ",
+ Library_Graph_Augmentation => "augmenting library graph... ",
+ Library_Graph_Construction => "constructing library graph... ",
+ Library_Graph_Elaboration => "elaborating library graph... ",
+ Library_Graph_Validation => "validating library graph... ",
+ Unit_Collection => "collecting units... ",
+ Unit_Elaboration => "elaborating units... ");
+
+ -----------------------
+ -- Local subprograms --
+ -----------------------
+
+ procedure Write_Phase_Message (Msg : Phase_Message);
+ pragma Inline (Write_Phase_Message);
+ -- Write elaboration phase-related message Msg to standard output
+
+ ---------------
+ -- End_Phase --
+ ---------------
+
+ procedure End_Phase (Phase : Elaboration_Phase) is
+ begin
+ Write_Phase_Message (End_Messages (Phase));
+ end End_Phase;
+
+ -----------------
+ -- Start_Phase --
+ -----------------
+
+ procedure Start_Phase (Phase : Elaboration_Phase) is
+ begin
+ Write_Phase_Message (Start_Messages (Phase));
+ end Start_Phase;
+
+ -------------------------
+ -- Write_Phase_Message --
+ -------------------------
+
+ procedure Write_Phase_Message (Msg : Phase_Message) is
+ begin
+ -- Nothing to do when switch -d_S (output elaboration order status)
+ -- is not in effect.
+
+ if not Debug_Flag_Underscore_SS then
+ return;
+ end if;
+
+ Write_Str (Msg);
+ Write_Eol;
+ end Write_Phase_Message;
+ end Phase_Writers;
+
--------------------------
-- Unit_Closure_Writers --
--------------------------
end Library_Graph_Writers;
+ -------------------
+ -- Phase_Writers --
+ -------------------
+
+ package Phase_Writers is
+ procedure End_Phase (Phase : Elaboration_Phase);
+ pragma Inline (End_Phase);
+ -- Write the end message associated with elaboration phase Phase to
+ -- standard output.
+
+ procedure Start_Phase (Phase : Elaboration_Phase);
+ pragma Inline (Start_Phase);
+ -- Write the start message associated with elaboration phase Phase to
+ -- standard output.
+
+ end Phase_Writers;
+
--------------------------
-- Unit_Closure_Writers --
--------------------------
--
-- GNATbind output the cycle paths in text format to standard output
--
+ -- -d_S Output elaboration-order status information
+ --
+ -- GNATbind outputs trace information concerning the status of its
+ -- various phases to standard output.
+ --
-- -d_T Output elaboration-order trace information
--
-- GNATbind outputs trace information on elaboration-order detection
-- plgv -- print library-graph vertex
-- pu -- print units
--
+ -- * Apparent infinite loop
+ --
+ -- The elaboration order mechanism appears to be stuck in an infinite
+ -- loop. Use switch -d_S to output the status of each elaboration phase.
+ --
-- * Invalid elaboration order
--
-- The elaboration order is invalid when:
package Bindo is
+ -- The following type represents the various phases of the elaboration
+ -- order mechanism.
+
+ type Elaboration_Phase is
+ (Component_Discovery,
+ Cycle_Diagnostics,
+ Cycle_Discovery,
+ Cycle_Validation,
+ Elaboration_Order_Validation,
+ Invocation_Graph_Construction,
+ Invocation_Graph_Validation,
+ Library_Graph_Augmentation,
+ Library_Graph_Construction,
+ Library_Graph_Elaboration,
+ Library_Graph_Validation,
+ Unit_Collection,
+ Unit_Elaboration);
+
-- The following type represents the various kinds of precedence between
-- two items.
-- d_P Output cycle paths
-- d_Q
-- d_R
- -- d_S
- -- d_T Output elaboration order trace information
+ -- d_S Output elaboration-order status
+ -- d_T Output elaboration-order trace information
-- d_U
-- d_V Validate bindo cycles, graphs, and order
-- d_W
-- d_P GNATBIND outputs the cycle paths to standard output
+ -- d_S GNATBIND outputs trace information concerning the status of its
+ -- various phases to standard output.
+
-- d_T GNATBIND outputs trace information of elaboration order detection
-- activities to standard output.