Commit cc53cbe0 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Dump models into dedicated files in debug mode

parent d06e0e9f
......@@ -4,9 +4,10 @@
-- LGPL license, see LICENSE file
with System.Assertions,
GNAT.Command_Line,
Ada.Exceptions,
Ada.Text_IO,
Ada.Directories,
GNAT.Command_Line,
Errors,
Locations,
Ocarina.Namet,
......@@ -18,6 +19,7 @@ with System.Assertions,
use Ada.Text_IO,
Ada.Exceptions,
Ada.Directories,
Locations,
Ocarina.Namet,
Ocarina;
......@@ -185,17 +187,44 @@ package body TASTE.AADL_Parser is
end Parse_Project;
procedure Dump (Model : TASTE_Model) is
Output_Path : constant String := Model.Configuration.Output_Dir.all
& "/Debug";
Output : File_Type;
begin
Put_Info ("==== Dump of the Interface View ====");
Model.Interface_View.Debug_Dump;
if Model.Configuration.Deployment_View.all'Length > 0 then
Put_Info ("==== Dump of the Deployment View ====");
Model.Deployment_View.Debug_Dump;
if Model.Configuration.Debug_Flag then
Create_Path (Output_Path);
Create (File => Output,
Mode => Out_File,
Name => Output_Path & "/InterfaceView.dump");
Put_Info ("Dump of the Interface View");
Model.Interface_View.Debug_Dump (Output);
Close (Output);
if Model.Configuration.Deployment_View.all'Length > 0 then
Create (File => Output,
Mode => Out_File,
Name => Output_Path & "/DeploymentView.dump");
Put_Info ("Dump of the Deployment View");
Model.Deployment_View.Debug_Dump (Output);
Close (Output);
end if;
Create (File => Output,
Mode => Out_File,
Name => Output_Path & "/DataView.dump");
Put_Info ("Dump of the Data View");
Model.Data_View.Debug_Dump;
Close (Output);
Create (File => Output,
Mode => Out_File,
Name => Output_Path & "/commandline.dump");
Put_Info ("Dump of the Command Line");
Model.Configuration.Debug_Dump;
Close (Output);
end if;
Put_Info ("==== Dump of the Data View ====");
Model.Data_View.Debug_Dump;
Put_Info ("==== Dump of the Command Line ====");
Model.Configuration.Debug_Dump;
exception
when Error : others =>
Put_Error ("Debug Dump : " & Exception_Message (Error));
raise Quit_Taste;
end Dump;
procedure Generate_Build_Script (Model : TASTE_Model) is
......@@ -210,8 +239,8 @@ package body TASTE.AADL_Parser is
when Error : TASTE.Backend.Skeletons.Skeleton_Error =>
Put_Error (Exception_Message (Error));
raise Quit_Taste;
when E : others =>
Errors.Display_Bug_Box (E);
when Error : others =>
Errors.Display_Bug_Box (Error);
raise Quit_Taste;
end Generate_Skeletons;
end TASTE.AADL_Parser;
with Text_IO,
with System.OS_Lib,
Text_IO,
Ada.Exceptions,
Ada.Directories,
Templates_Parser,
TASTE.Parser_Utils;
use Text_IO,
use System.OS_Lib,
Text_IO,
Ada.Exceptions,
Ada.Directories,
Templates_Parser,
TASTE.Parser_Utils;
......@@ -38,16 +44,41 @@ package body TASTE.Backend.Build_Script is
end loop;
Put_Info ("Generating build script");
declare
Template_Data : constant Translate_Table :=
(1 => Assoc ("Interface_View_Path",
Model.Configuration.Interface_View.all),
2 => Assoc ("Output_Path", Model.Configuration.Output_Dir.all),
3 => Assoc ("Generate_Code", Vec_Code),
4 => Assoc ("Zip_Code", Vec_Zip),
5 => Assoc ("Functions", Vec_Func),
6 => Assoc ("CodeCoverage", "# TODO"));
Template_Data : constant Translate_Set :=
+Assoc ("Interface_View_Path",
Model.Configuration.Interface_View.all)
& Assoc ("Output_Path", Model.Configuration.Output_Dir.all)
& Assoc ("Generate_Code", Vec_Code)
& Assoc ("Zip_Code", Vec_Zip)
& Assoc ("Functions", Vec_Func)
& Assoc ("CodeCoverage", "# TODO");
Result : constant String := Parse (Prefix & "build-script.tmplt",
Template_Data);
Output_Path : constant String := Model.Configuration.Output_Dir.all;
Filename : constant String := Output_Path & "/build-script.sh";
Output : File_Type;
Success : Boolean;
begin
Put_Line (Parse (Prefix & "build-script.tmplt", Template_Data));
Create_Path (Output_Path);
if Exists (Filename) then
Put_Info ("Making backup of build script (build-script.sh.old)");
Rename_File (Old_Name => Filename,
New_Name => Output_Path & "/build-script.sh.old",
Success => Success);
if not Success then
raise Backend_Error with "Impossible to rename build-script.sh";
end if;
end if;
Create (File => Output, Mode => Out_File, Name => Filename);
Put_Line (Output, Result);
Close (Output);
exception
when E : others =>
if Is_Open (Output) then
Close (Output);
end if;
raise Backend_Error with "Generation of build script failed: "
& Exception_Message (E);
end;
end Generate;
end TASTE.Backend.Build_Script;
......@@ -5,6 +5,8 @@ package TASTE.Backend is
use Ocarina.Backends.Properties,
Interface_View;
Backend_Error : exception;
function Language_Spelling (Func : Taste_Terminal_Function) return String is
(case Func.Language is
when Language_Ada_95 => "Ada",
......
......@@ -4,8 +4,7 @@
-- Deployment View parser
with Ada.Text_IO,
Ada.Exceptions,
with Ada.Exceptions,
Ada.Strings.Fixed,
System.Assertions,
Ocarina.Instances.Queries,
......@@ -23,8 +22,7 @@ with Ada.Text_IO,
package body TASTE.Deployment_View is
use Ada.Text_IO,
Ada.Exceptions,
use Ada.Exceptions,
Ada.Strings.Fixed,
System.Assertions,
Ocarina.Instances.Queries,
......@@ -387,7 +385,7 @@ package body TASTE.Deployment_View is
(Corresponding_Declaration (P_CI)))));
exception
when Assert_Failure =>
Put_Line ("Detected DV from TASTE version 1.2");
Put_Info ("Detected DV from TASTE version 1.2");
Result.Bound_Functions.Append
(Get_Name_String (Name (Identifier (Processes))));
end;
......@@ -423,7 +421,7 @@ package body TASTE.Deployment_View is
end Parse_Node;
begin
Put_Line ("Parsing deployment view");
Put_Info ("Parsing deployment view");
My_Root_System := Initialize (System);
if Is_Empty (Subcomponents (My_Root_System)) then
......@@ -461,79 +459,86 @@ package body TASTE.Deployment_View is
Busses => Busses);
end Parse_Deployment_View;
procedure Dump_Nodes (DV : Complete_Deployment_View) is
procedure Dump_Nodes (DV : Complete_Deployment_View; Output : File_Type) is
begin
for Each of DV.Nodes loop
Put_Line ("Node : " & White_Bold & To_String (Each.Name) & No_Color);
Put_Line (Output, "Node : " & To_String (Each.Name));
for Partition of Each.Partitions loop
Put_Line (" |_ Partition : " & To_String (Partition.Name));
Put_Line (" |_ Coverage : " & Partition.Coverage'Img);
Put_Line (" |_ Package : "
Put_Line (Output, " |_ Partition : "
& To_String (Partition.Name));
Put_Line (Output, " |_ Coverage : "
& Partition.Coverage'Img);
Put_Line (Output, " |_ Package : "
& To_String (Partition.Package_Name));
Put_Line (" |_ CPU Name : "
Put_Line (Output, " |_ CPU Name : "
& To_String (Partition.CPU_Name));
Put_Line (" |_ CPU Platform : " & Partition.CPU_Platform'Img);
Put_Line (" |_ CPU Classifier : "
Put_Line (Output, " |_ CPU Platform : "
& Partition.CPU_Platform'Img);
Put_Line (Output, " |_ CPU Classifier : "
& To_String (Partition.CPU_Classifier));
Put (" |_ Contains : ");
Put (Output, " |_ Contains : ");
for Bounded of Partition.Bound_Functions loop
Put (Bounded & " ");
Put (Output, Bounded & " ");
end loop;
Ada.Text_IO.New_Line;
New_Line (Output);
end loop;
for Driver of Each.Drivers loop
Put_Line (" |_ Driver : " & To_String (Driver.Name));
Put_Line (" |_ Package : "
Put_Line (Output, " |_ Driver : " & To_String (Driver.Name));
Put_Line (Output, " |_ Package : "
& To_String (Driver.Package_Name));
Put_Line (" |_ Classifier : "
Put_Line (Output, " |_ Classifier : "
& To_String (Driver.Device_Classifier));
Put_Line (" |_ Processor : "
Put_Line (Output, " |_ Processor : "
& To_String (Driver.Associated_Processor_Name));
Put_Line (" |_ Configuration : "
Put_Line (Output, " |_ Configuration : "
& To_String (Driver.Device_Configuration));
Put_Line (" |_ Bus_Name : "
Put_Line (Output, " |_ Bus_Name : "
& To_String (Driver.Accessed_Bus_Name));
Put_Line (" |_ Port_Name : "
Put_Line (Output, " |_ Port_Name : "
& To_String (Driver.Accessed_Port_Name));
Put_Line (" |_ ASN.1 File : "
Put_Line (Output, " |_ ASN.1 File : "
& To_String (Driver.ASN1_Filename));
Put_Line (" |_ ASN.1 Type : "
Put_Line (Output, " |_ ASN.1 Type : "
& To_String (Driver.ASN1_Typename));
Put_Line (" |_ ASN.1 Module : "
Put_Line (Output, " |_ ASN.1 Module : "
& To_String (Driver.ASN1_Module));
end loop;
end loop;
end Dump_Nodes;
procedure Dump_Connections (DV : Complete_Deployment_View) is
procedure Dump_Connections (DV : Complete_Deployment_View;
Output : File_Type) is
begin
for Each of DV.Connections loop
Put_Line ("Connection on bus : " & To_String (Each.Bus_Name));
Put_Line (" |_ Source Node : " & To_String (Each.Source_Node));
Put_Line (" |_ Source Port : " & To_String (Each.Source_Port));
Put_Line (" |_ Dest Node : " & To_String (Each.Dest_Node));
Put_Line (" |_ Dest Port : " & To_String (Each.Dest_Port));
Put_Line (Output, "Connection on bus : " & To_String (Each.Bus_Name));
Put_Line (Output, " |_ Source Node : "
& To_String (Each.Source_Node));
Put_Line (Output, " |_ Source Port : "
& To_String (Each.Source_Port));
Put_Line (Output, " |_ Dest Node : " & To_String (Each.Dest_Node));
Put_Line (Output, " |_ Dest Port : " & To_String (Each.Dest_Port));
end loop;
end Dump_Connections;
procedure Dump_Busses (DV : Complete_Deployment_View) is
procedure Dump_Busses (DV : Complete_Deployment_View; Output : File_Type) is
begin
for Each of DV.Busses loop
Put_Line ("Bus : " & To_String (Each.Name));
Put_Line (" |_ Package : " & To_String (Each.AADL_Package));
Put_Line (" |_ Classifier : " & To_String (Each.Classifier));
Put_Line (Output, "Bus : " & To_String (Each.Name));
Put_Line (Output, " |_ Package : "
& To_String (Each.AADL_Package));
Put_Line (Output, " |_ Classifier : " & To_String (Each.Classifier));
for Prop of Each.Properties loop
Put_Line (" |_ Property: " & To_String (Prop.Name)
Put_Line (Output, " |_ Property: " & To_String (Prop.Name)
& " = " & To_String (Prop.Value));
end loop;
end loop;
end Dump_Busses;
procedure Debug_Dump (DV : Complete_Deployment_View) is
procedure Debug_Dump (DV : Complete_Deployment_View; Output : File_Type) is
begin
DV.Dump_Nodes;
DV.Dump_Busses;
DV.Dump_Connections;
DV.Dump_Nodes (Output);
DV.Dump_Busses (Output);
DV.Dump_Connections (Output);
end Debug_Dump;
end TASTE.Deployment_View;
......@@ -4,19 +4,21 @@
-- Deployment View parser
with Ocarina,
Ocarina.Types,
Ada.Containers.Indefinite_Ordered_Maps,
with Ada.Containers.Indefinite_Ordered_Maps,
Ada.Containers.Indefinite_Vectors,
Ada.Strings.Unbounded,
Text_IO,
Ocarina,
Ocarina.Types,
Ocarina.Backends.Properties,
TASTE.Parser_Utils;
use Ocarina,
use Ada.Containers,
Ada.Strings.Unbounded,
Text_IO,
Ocarina,
Ocarina.Types,
Ocarina.Backends.Properties,
Ada.Containers,
Ada.Strings.Unbounded,
TASTE.Parser_Utils;
package TASTE.Deployment_View is
......@@ -123,9 +125,13 @@ package TASTE.Deployment_View is
function Parse_Deployment_View (System : Node_Id)
return Complete_Deployment_View
with Pre => System /= No_Node;
procedure Dump_Nodes (DV : Complete_Deployment_View);
procedure Dump_Connections (DV : Complete_Deployment_View);
procedure Dump_Busses (DV : Complete_Deployment_View);
procedure Debug_Dump (DV : Complete_Deployment_View);
procedure Dump_Nodes (DV : Complete_Deployment_View;
Output : File_Type);
procedure Dump_Connections (DV : Complete_Deployment_View;
Output : File_Type);
procedure Dump_Busses (DV : Complete_Deployment_View;
Output : File_Type);
procedure Debug_Dump (DV : Complete_Deployment_View;
Output : File_Type);
end TASTE.Deployment_View;
......@@ -4,8 +4,7 @@
-- Interface View parser
with Ada.Text_IO,
Ada.Exceptions,
with Ada.Exceptions,
Ocarina.Instances.Queries,
Ocarina.Analyzer,
Ocarina.Options,
......@@ -18,8 +17,7 @@ with Ada.Text_IO,
package body TASTE.Interface_View is
use Ada.Text_IO,
Ada.Exceptions,
use Ada.Exceptions,
Ocarina.Instances.Queries,
Ocarina.Namet,
Ocarina.Analyzer,
......@@ -782,75 +780,81 @@ package body TASTE.Interface_View is
end loop;
end Rename_Required_Interface;
procedure Debug_Dump (IV : Complete_Interface_View) is
procedure Debug_Dump (IV : Complete_Interface_View; Output : File_Type) is
procedure Dump_Interface (Ind : String := " ";
I : Taste_Interface) is
begin
Put_Line (" |_Name: " & To_String (I.Name) & " - in FV: "
Put_Line (Output, " |_Name: " & To_String (I.Name) & " - in FV: "
& To_String (I.Parent_Function));
Put_Line (Ind & " |_RCM Kind : " & I.RCM'Img);
Put_Line (Ind & " |_Period/MIAT : " & I.Period_Or_MIAT'Img);
Put_Line (Ind & " |_WCET (ms) : " & Value_Or (I.WCET_ms, 0)'Img);
Put_Line (Ind & " |_Queue Size : " & Value_Or (I.Queue_Size, 1)'Img);
Put_Line (Ind & " |_Parameters :");
Put_Line (Output, Ind & " |_RCM Kind : " & I.RCM'Img);
Put_Line (Output, Ind & " |_Period/MIAT : " & I.Period_Or_MIAT'Img);
Put_Line (Output, Ind & " |_WCET (ms) : "
& Value_Or (I.WCET_ms, 0)'Img);
Put_Line (Output, Ind & " |_Queue Size : "
& Value_Or (I.Queue_Size, 1)'Img);
Put_Line (Output, Ind & " |_Parameters :");
for Each of I.Params loop
Put_Line (Ind & " |_Name : " & To_String (Each.Name));
Put_Line (Ind & " |_Type : "
Put_Line (Output, Ind & " |_Name : "
& To_String (Each.Name));
Put_Line (Output, Ind & " |_Type : "
& To_String (Each.Sort));
Put_Line (Ind & " |_ASN.1 Module : "
Put_Line (Output, Ind & " |_ASN.1 Module : "
& To_String (Each.ASN1_Module));
Put_Line (Ind & " |_ASN.1 File : "
Put_Line (Output, Ind & " |_ASN.1 File : "
& To_String (Each.ASN1_File_Name));
Put_Line (Ind & " |_Basic type : "
Put_Line (Output, Ind & " |_Basic type : "
& Each.ASN1_Basic_Type'Img);
Put_Line (Ind & " |_Encoding : " & Each.Encoding'Img);
Put_Line (Ind & " |_Direction : " & Each.Direction'Img);
Put_Line (Output, Ind & " |_Encoding : "
& Each.Encoding'Img);
Put_Line (Output, Ind & " |_Direction : "
& Each.Direction'Img);
end loop;
Put_Line (Ind & " |_Connections :");
Put_Line (Output, Ind & " |_Connections :");
for Each of I.Remote_Interfaces loop
Put_Line (Ind & " |_Function " & To_String (Each.Function_Name)
Put_Line (Output, Ind & " |_Function "
& To_String (Each.Function_Name)
& ", interface " & To_String (Each.Interface_Name));
end loop;
end Dump_Interface;
begin
for Each of IV.Flat_Functions loop
Put_Line ("Function " & To_String (Each.Name)
Put_Line (Output, "Function " & To_String (Each.Name)
& " in context " & To_String (Each.Context));
Put_Line (" |_Full Prefix: " & To_String (Value_Or (Each.Full_Prefix,
US ("(none)"))));
Put_Line (" |_Language : " & Each.Language'Img);
Put_Line (" |_Zip file : " & To_String (Value_Or (Each.Zip_File,
US ("(none)"))));
Put_Line (" Cxtx Params:");
Put_Line (Output, " |_Full Prefix: "
& To_String (Value_Or (Each.Full_Prefix, US ("(none)"))));
Put_Line (Output, " |_Language : " & Each.Language'Img);
Put_Line (Output, " |_Zip file : "
& To_String (Value_Or (Each.Zip_File, US ("(none)"))));
Put_Line (Output, " Cxtx Params:");
for CP of Each.Context_Params loop
Put_Line (" |_" & To_String (CP.Name) & ":"
Put_Line (Output, " |_" & To_String (CP.Name) & ":"
& To_String (CP.Sort) & "- default: "
& To_String (CP.Default_Value) & " - asn1 module: "
& To_String (CP.ASN1_Module) & " - file:"
& To_String (Value_Or (CP.ASN1_File_Name,
US ("(none)"))));
New_Line;
New_Line (Output);
end loop;
Put_Line (" |_User properties:");
Put_Line (Output, " |_User properties:");
for Ppty of Each.User_Properties loop
Put_Line (" " & To_String (Ppty.Name) & " = "
Put_Line (Output, " " & To_String (Ppty.Name) & " = "
& To_String (Ppty.Value));
end loop;
Put_Line (" |_Timers:");
Put_Line (Output, " |_Timers:");
for Timer of Each.Timers loop
Put_Line (" |_" & Timer);
Put_Line (Output, " |_" & Timer);
end loop;
Put_Line (" |_Provided interfaces:");
Put_Line (Output, " |_Provided interfaces:");
for PI of Each.Provided loop
Dump_Interface (I => PI);
end loop;
New_Line;
Put_Line (" |_Required interfaces:");
New_Line (Output);
Put_Line (Output, " |_Required interfaces:");
for RI of Each.Required loop
Dump_Interface (I => RI);
end loop;
New_Line;
New_Line (Output);
end loop;
end Debug_Dump;
end TASTE.Interface_View;
......@@ -4,20 +4,22 @@
-- Interface View parser
with Ocarina,
Ocarina.Types,
Ocarina.Backends.Properties,
Ada.Containers.Indefinite_Ordered_Maps,
with Ada.Containers.Indefinite_Ordered_Maps,
Ada.Containers.Indefinite_Vectors,
Ada.Strings.Unbounded,
Text_IO,
Ocarina,
Ocarina.Types,
Ocarina.Backends.Properties,
Option_Type,
TASTE.Parser_Utils;
use Ocarina,
use Ada.Containers,
Ada.Strings.Unbounded,
Text_IO,
Ocarina,
Ocarina.Types,
Ocarina.Backends.Properties,
Ada.Containers,
Ada.Strings.Unbounded,
TASTE.Parser_Utils;
package TASTE.Interface_View is
......@@ -179,6 +181,6 @@ package TASTE.Interface_View is
Iface : String;
To : String);
procedure Debug_Dump (IV : Complete_Interface_View);
procedure Debug_Dump (IV : Complete_Interface_View; Output : File_Type);
end TASTE.Interface_View;
......@@ -6,6 +6,7 @@ test-parse:
$(AADL_PARSER) --gw \
-o output \
--glue \
--debug \
-i InterfaceView.aadl \
-c DeploymentView.aadl \
-d DataView.aadl \
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment