diff options
author | Hristian Kirtchev <kirtchev@adacore.com> | 2019-07-03 08:14:57 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2019-07-03 08:14:57 +0000 |
commit | 69e6ee2f15f110f7f69554aa049a869f9d4dd556 (patch) | |
tree | 7c604261c0a82b7d002026e6d7f9081e8f559369 /gcc/ada/debug.adb | |
parent | 14bc12f0b188c847976c747e8c8389977a37187e (diff) | |
download | gcc-69e6ee2f15f110f7f69554aa049a869f9d4dd556.zip gcc-69e6ee2f15f110f7f69554aa049a869f9d4dd556.tar.gz gcc-69e6ee2f15f110f7f69554aa049a869f9d4dd556.tar.bz2 |
[Ada] ABE checks v3.0, foundations of Elaboration order v4.0
------------------------
-- Elaboration checks --
------------------------
The dynamic ABE checks model now emits the same diagnostics as those of the
static ABE checks model.
The ABE checks mechanism has been redesigned and refactored in the face of
increasing requirements. Most of the functionality can now be toggled, thus
allowing for various combinations of behavior. The combinations are defined
as "initial states" and may be further altered.
Scenarios and targets have been distinctly separated at the higher level,
instead of directly working with nodes and entitites. Scenarios and targets
now carry a representation which removes the need to constantly recompute
relevant attributes, and offers a common interface for the various processors.
Most processing has now been refactored into "services" which perform a single
ABE-related function.
-----------------------
-- Elaboration order --
-----------------------
A new elaboration order mechanism based on the use of an invocation graph to
provide extra information about the flow of execution at elaboration time has
been introduced.
The ABE checks mechanism has been altered to encode pieces of the invocation
graph in the associated ALI files of units.
The new elaboration order mechanism reconstructs the full invocation graph at
bind time, and coupled with the library item graph, determines the elaboration
order of units.
The new elaboration order mechanism is currently inaccessible.
------------
-- Source --
------------
-- pack.ads
package Pack is
procedure ABE_Proc;
procedure Safe_Proc;
end Pack;
-- pack.adb
with Ada.Text_IO; use Ada.Text_IO;
package body Pack is
function Call_Proc (ABE : Boolean) return Integer;
procedure Safe_Proc is
begin
Put_Line ("safe");
end Safe_Proc;
function Call_Proc (ABE : Boolean) return Integer is
begin
if ABE then
ABE_Proc;
else
Safe_Proc;
end if;
return 0;
end Call_Proc;
Elab_1 : constant Integer := Call_Proc (ABE => False);
Elab_2 : constant Integer := Call_Proc (ABE => True);
procedure ABE_Proc is
begin
Put_Line ("ABE");
end ABE_Proc;
end Pack;
-- main.adb
with Pack;
procedure Main is begin null; end Main;
----------------------------
-- Compilation and output --
----------------------------
$ gnatmake -f -q -gnatE main.adb
$ ./main
$ gnatmake -f -q -gnatE main.adb -gnatDG -gnatwL
$ grep -c "safeE" pack.adb.dg
pack.adb:14:10: warning: cannot call "ABE_Proc" before body seen
pack.adb:14:10: warning: Program_Error may be raised at run time
pack.adb:14:10: warning: body of unit "Pack" elaborated
pack.adb:14:10: warning: function "Call_Proc" called at line 22
pack.adb:14:10: warning: procedure "ABE_Proc" called at line 14
pack.adb:14:10: warning: cannot call "ABE_Proc" before body seen
pack.adb:14:10: warning: Program_Error may be raised at run time
pack.adb:14:10: warning: body of unit "Pack" elaborated
pack.adb:14:10: warning: function "Call_Proc" called at line 23
pack.adb:14:10: warning: procedure "ABE_Proc" called at line 14
safe
raised PROGRAM_ERROR : pack.adb:14 access before elaboration
0
2019-07-03 Hristian Kirtchev <kirtchev@adacore.com>
gcc/ada/
* ali.adb: Add with and use clauses for GNAT,
GNAT.Dynamic_HTables, and Snames. Add a map from invocation
signature records to invocation signature ids. Add various
encodings of invocation-related attributes. Sort and update
table Known_ALI_Lines.
(Add_Invocation_Construct, Add_Invocation_Relation,
Body_Placement_Kind_To_Code, Code_To_Body_Placement_Kind,
Code_To_Invocation_Construct_Kind, Code_To_Invocation_Kind,
Code_To_Invocation_Graph_Line_Kind, Destroy, Hash): New
routines.
(Initialize_ALI): Sort the initialization sequence. Add
initialization for all invocation-related tables.
(Invocation_Construct_Kind_To_Code,
Invocation_Graph_Line_Kind_To_Code, Invocation_Kind_To_Code,
Invocation_Signature_Of, Present): New routines.
(Scan_ALI): Add the default values for invocation-related ids.
Scan invocation graph lines.
(Scan_Invocation_Graph_Line): New routine.
* ali.ads: Add with clause for GNAT.Dynamic_Tables. Add types
for invocation constructs, relations, and signatures. Add
tables for invocation constructs, relations, and signatures.
Update Unit_Record to capture invocation-related ids. Relocate
table Unit_Id_Tables and subtypes Unit_Id_Table, Unit_Id_Array
from Binde.
(Add_Invocation_Construct, Add_Invocation_Relation,
Body_Placement_Kind_To_Code, Code_To_Body_Placement_Kind,
Code_To_Invocation_Construct_Kind, Code_To_Invocation_Kind,
Code_To_Invocation_Graph_Line_Kind,
Invocation_Construct_Kind_To_Code,
Invocation_Graph_Line_Kind_To_Code, Invocation_Kind_To_Code,
Invocation_Signature_Of, Present): New routines.
* binde.adb: Add with and use clause for Types. Add use clause
for ALI.Unit_Id_Tables;
* binde.ads: Relocate table Unit_Id_Tables and subtypes
Unit_Id_Table, Unit_Id_Array to ALI.
* bindgen.adb: Remove with and use clause for ALI.
* bindgen.ads: Remove with and use clause for Binde. Add with
and use clause for ALI.
* bindo.adb, bindo.ads, bindo-augmentors.adb,
bindo-augmentors.ads, bindo-builders.adb, bindo-builders.ads,
bindo-diagnostics.adb, bindo-diagnostics.ads,
bindo-elaborators.adb, bindo-elaborators.ads, bindo-graphs.adb,
bindo-graphs.ads, bindo-units.adb, bindo-units.ads,
bindo-validators.adb, bindo-validators.ads, bindo-writers.adb,
bindo-writers.ads: New units.
* debug.adb: Use and describe GNAT debug switches -gnatd_F and
-gnatd_G. Add GNATbind debug switches in the ranges dA .. dZ,
d.a .. d.z, d.A .. d.Z, d.1 .. d.9, d_a .. d_z, d_A .. d_Z, and
d_1 .. d_9. Use and describe GNATbind debug switches -d_A,
-d_I, -d_L, -d_N, -d_O, -d_T, and -d_V.
* exp_util.adb, exp_util.ads (Exceptions_OK): Relocate to
Sem_Util.
* gnatbind.adb: Add with and use clause for Bindo. Use the new
Bindo elaboration order only when -d_N is in effect.
* lib-writ.adb
(Column, Extra, Invoker, Kind, Line, Locations, Name, Placement,
Scope, Signature, Target): New routines.
(Write_ALI): Output all invocation-related data.
(Write_Invocation_Graph): New routine.
* lib-writ.ads: Document the invocation graph ALI line.
* namet.adb, namet.ads (Present): New routines.
* sem_ch8.adb (Find_Direct_Name): Capture the status of
elaboration checks and warnings of an identifier.
(Find_Expanded_Name): Capture the status of elaboration checks
and warnings of an expanded name.
* sem_ch12.adb (Analyze_Generic_Package_Declaration): Ensure
that invocation graph-related data within the body of the main
unit is encoded in the ALI file.
(Analyze_Generic_Subprogram_Declaration): Ensure that invocation
graph-related data within the body of the main unit is encoded
in the ALI file.
(Analyze_Package_Instantiation): Perform minimal decoration of
the instance entity.
(Analyze_Subprogram_Instantiation): Perform minimal decoration
of the instance entity.
* sem_elab.adb: Perform heavy refactoring of all code. The unit
is now split into "services" which specialize in one area of ABE
checks. Add processing in order to capture invocation-graph
related attributes of the main unit, and encode them in the ALI
file. The Processing phase can now operate in multiple modes,
all described by type Processing_Kind. Scenarios and targets
are now distinct at the higher level, and carry their own
representations. This eliminates the need to constantly
recompute their attributes, and offers the various processors a
uniform interface. The various initial states of the Processing
phase are now encoded using type Processing_In_State, and
xxx_State constants.
* sem_elab.ads: Update the literals of type
Enclosing_Level_Kind. Add Inline pragmas on several routines.
* sem_prag.adb (Process_Inline): Ensure that invocation
graph-related data within the body of the main unit is encoded
in the ALI file.
* sem_util.adb (Enclosing_Generic_Body, Enclosing_Generic_Unit):
Code clean up.
(Exceptions_OK): Relocated from Sem_Util.
(Mark_Save_Invocation_Graph_Of_Body): New routine.
* sem_util.ads (Exceptions_OK): Relocated from Sem_Util.
(Mark_Save_Invocation_Graph_Of_Body): New routine.
* sinfo.adb (Is_Elaboration_Checks_OK_Node): Now applicable to
N_Variable_Reference_Marker.
(Is_Elaboration_Warnings_OK_Node): Now applicable to
N_Expanded_Name, N_Identifier, N_Variable_Reference_Marker.
(Is_Read): Use Flag4.
(Is_SPARK_Mode_On_Node): New applicable to
N_Variable_Reference_Marker.
(Is_Write): Use Flag5.
(Save_Invocation_Graph_Of_Body): New routine.
(Set_Is_Elaboration_Checks_OK_Node): Now applicable to
N_Variable_Reference_Marker.
(Set_Is_Elaboration_Warnings_OK_Node): Now applicable to
N_Expanded_Name, N_Identifier, N_Variable_Reference_Marker.
(Set_Is_SPARK_Mode_On_Node): New applicable to
N_Variable_Reference_Marker.
(Set_Save_Invocation_Graph_Of_Body): New routine.
* sinfo.ads: Update the documentation of attributes
Is_Elaboration_Checks_OK_Node, Is_Elaboration_Warnings_OK_Node,
Is_SPARK_Mode_On_Node. Update the flag usage of attributes
Is_Read, Is_Write. Add attribute Save_Invocation_Graph_Of_Body
and update its occurrence in nodes.
(Save_Invocation_Graph_Of_Body): New routine along with pragma
Inline.
(Set_Save_Invocation_Graph_Of_Body): New routine along with
pragma Inline.
* switch-b.adb (Scan_Binder_Switches): Refactor the scanning of
debug switches.
(Scan_Debug_Switches): New routine.
* libgnat/g-dynhta.adb, libgnat/g-dynhta.ads (Contains): New routine.
* libgnat/g-graphs.adb (Associate_Vertices): Update the use of
Component_Vertex_Iterator.
(Contains_Component, Contains_Edge, Contains_Vertex, Has_Next):
Reimplemented.
(Iterate_Component_Vertices): New routine.
(Iterate_Vertices): Removed.
(Next): Update the parameter profile.
(Number_Of_Component_Vertices, Number_Of_Outgoing_Edges): New
routines.
* libgnat/g-graphs.ads: Update the initialization of
No_Component. Add type Component_Vertex_Iterator. Remove type
Vertex_Iterator.
(Has_Next): Add new versions and remove old ones.
(Iterate_Component_Vertices): New routine.
(Iterate_Vertices): Removed.
(Next): Add new versions and remove old ones.
(Number_Of_Component_Vertices, Number_Of_Outgoing_Edges): New
routines.
* libgnat/g-sets.adb (Contains): Reimplemented.
* gcc-interface/Make-lang.in (GNATBIND_OBJS): Add
GNAT.Dynamic_HTables, GNAT.Graphs and Bindo units.
* rtsfind.ads: Remove extra space.
From-SVN: r272976
Diffstat (limited to 'gcc/ada/debug.adb')
-rw-r--r-- | gcc/ada/debug.adb | 198 |
1 files changed, 190 insertions, 8 deletions
diff --git a/gcc/ada/debug.adb b/gcc/ada/debug.adb index e43174c..d76d93d 100644 --- a/gcc/ada/debug.adb +++ b/gcc/ada/debug.adb @@ -177,8 +177,8 @@ package body Debug is -- d_C -- d_D -- d_E - -- d_F - -- d_G + -- d_F Encode full invocation paths in ALI files + -- d_G Encode invocation graph in ALI files -- d_H -- d_I -- d_J @@ -191,7 +191,7 @@ package body Debug is -- d_Q -- d_R -- d_S - -- d_T + -- d_T Output trace information on invocation path recording -- d_U -- d_V -- d_W @@ -258,6 +258,160 @@ package body Debug is -- dy -- dz + -- dA + -- dB + -- dC + -- dD + -- dE + -- dF + -- dG + -- dH + -- dI + -- dJ + -- dK + -- dL + -- dM + -- dN + -- dO + -- dP + -- dQ + -- dR + -- dS + -- dT + -- dU + -- dV + -- dW + -- dX + -- dY + -- dZ + + -- d.a + -- d.b + -- d.c + -- d.d + -- d.e + -- d.f + -- d.g + -- d.h + -- d.i + -- d.j + -- d.k + -- d.l + -- d.m + -- d.n + -- d.o + -- d.p + -- d.q + -- d.r + -- d.s + -- d.t + -- d.u + -- d.v + -- d.w + -- d.x + -- d.y + -- d.z + + -- d.A + -- d.B + -- d.C + -- d.D + -- d.E + -- d.F + -- d.G + -- d.H + -- d.I + -- d.J + -- d.K + -- d.L + -- d.M + -- d.N + -- d.O + -- d.P + -- d.Q + -- d.R + -- d.S + -- d.T + -- d.U + -- d.V + -- d.W + -- d.X + -- d.Y + -- d.Z + + -- d.1 + -- d.2 + -- d.3 + -- d.4 + -- d.5 + -- d.6 + -- d.7 + -- d.8 + -- d.9 + + -- d_a + -- d_b + -- d_c + -- d_d + -- d_e + -- d_f + -- d_g + -- d_h + -- d_i + -- d_j + -- d_k + -- d_l + -- d_m + -- d_n + -- d_o + -- d_p + -- d_q + -- d_r + -- d_s + -- d_t + -- d_u + -- d_v + -- d_w + -- d_x + -- d_y + -- d_z + + -- d_A Output ALI invocation tables + -- d_B + -- d_C + -- d_D + -- d_F + -- d_G + -- d_H + -- d_I Output invocation graph + -- d_J + -- d_K + -- d_L Output library graph + -- d_M + -- d_N New bindo order + -- d_O Output elaboration order + -- d_P + -- d_Q + -- d_R + -- d_S + -- d_T Output elaboration order trace information + -- d_U + -- d_V Validate bindo graphs and order + -- d_W + -- d_X + -- d_Y + -- d_Z + + -- d_1 + -- d_2 + -- d_3 + -- d_4 + -- d_5 + -- d_6 + -- d_7 + -- d_8 + -- d_9 + -- Debug flags used in package Make and its clients (e.g. GNATMAKE) -- da @@ -850,11 +1004,21 @@ package body Debug is -- d_A Do not generate ALI files by setting Opt.Disable_ALI_File. + -- d_F The compiler encodes the full path from an invocation construct to + -- an external target, offering additional information to GNATBIND for + -- purposes of error diagnostics. + + -- d_G The compiler encodes the invocation graph of a unit in its ALI + -- file. + -- d_L Output trace information on elaboration checking. This debug switch -- causes output to be generated showing each call or instantiation as -- it is checked, and the progress of the recursive trace through -- elaboration calls at compile time. + -- d_T The compiler outputs trance information to standard output whenever + -- an invocation path is recorded. + -- d1 Error messages have node numbers where possible. Normally error -- messages have only source locations. This option is useful when -- debugging errors caused by expanded code, where the source location @@ -954,11 +1118,10 @@ package body Debug is -- dependencies) except that internal units are included in the -- listing. - -- di Normally gnatbind calls Read_Ali with Ignore_Errors set to - -- False, since the binder really needs correct version ALI - -- files to do its job. This debug flag causes Ignore_Errors - -- mode to be set for the binder (and is particularly useful - -- for testing ignore errors mode). + -- di Normally GNATBIND calls Read_Ali with Ignore_Errors set to False, + -- since the binder really needs correct version ALI files to do its + -- job. This debug flag causes Ignore_Errors mode to be set for the + -- binder (and is particularly useful for testing ignore errors mode). -- dn List details of manipulation of Num_Pred values during execution of -- the algorithm used to determine a correct order of elaboration. This @@ -985,6 +1148,25 @@ package body Debug is -- dx Force the binder to read (and then ignore) the xref information -- in ali files (used to check that read circuit is working OK). + -- d_A GNATBIND output the contents of all ALI invocation-related tables + -- in textual format to standard output. + -- + -- d_I GNATBIND outputs the contents of the invocation graph in textual + -- format to standard output. + -- + -- d_L GNATBIND outputs the contents of the library graph in textual + -- format to standard output. + -- + -- d_N GNATBIND utilizes the elaboration order provided by bindo + -- + -- d_O GNATBIND outputs the elaboration order of units to standard output + -- + -- d_T GNATBIND outputs trace information of elaboration order activities + -- to standard output. + -- + -- d_V GNATBIND validates the invocation graph, library graph, SCC graph + -- and elaboration order. + -------------------------------------------- -- Documentation for gnatmake Debug Flags -- -------------------------------------------- |