------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- Cheddar is a GNU GPL real-time scheduling analysis tool. -- This program provides services to automatically check schedulability and -- other performance criteria of real-time architecture models. -- -- Copyright (C) 2002-2023, Frank Singhoff, Alain Plantec, Jerome Legrand, -- Hai Nam Tran, Stephane Rubini -- -- The Cheddar project was started in 2002 by -- Frank Singhoff, Lab-STICC UMR 6285, Université de Bretagne Occidentale -- -- Cheddar has been published in the "Agence de Protection des Programmes/France" in 2008. -- Since 2008, Ellidiss technologies also contributes to the development of -- Cheddar and provides industrial support. -- -- The full list of contributors and sponsors can be found in README.md -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 2 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -- -- -- Contact : cheddar@listes.univ-brest.fr -- ------------------------------------------------------------------------------ -- Last update : -- $Rev$ -- $Date$ -- $Author: singhoff $ ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ with Ada.Text_IO; use Ada.Text_IO; with Ada.IO_Exceptions; use Ada.IO_Exceptions; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with GNAT.Command_Line; use GNAT.Command_Line; with GNAT.Current_Exception; use GNAT.Current_Exception; with GNAT.OS_Lib; use GNAT.OS_Lib; with unbounded_strings; use unbounded_strings; with unbounded_strings; use unbounded_strings.unbounded_string_list_package; with framework; use framework; with initialize_framework; use initialize_framework; with framework_config; use framework_config; with framework_config.extended; use framework_config.extended; with editor_config; use editor_config; with call_framework; use call_framework; with call_scheduling_framework; use call_scheduling_framework; with io_tools; use io_tools; with translate; use translate; with version; use version; with xml_generic_parsers; use xml_generic_parsers; with xml_generic_parsers.architecture; use xml_generic_parsers.architecture; with aadl_parsers; use aadl_parsers; with systems; use systems; with debug; use debug; with processors; use processors; with cache_set; use cache_set; with cache_block_set; use cache_block_set; with cache_access_profile_set; use cache_access_profile_set; with task_group_set; use task_group_set; with message_set; use message_set; with network_set; use network_set; with event_analyzer_set; use event_analyzer_set; with cfg_set; use cfg_set; with cfg_node_set; use cfg_node_set; with cfg_edge_set; use cfg_edge_set; with processor_set; use processor_set; with buffer_set; use buffer_set; with resource_set; use resource_set; with address_space_set; use address_space_set; with scheduler_interface; use scheduler_interface; with task_set; use task_set; with multiprocessor_services; use multiprocessor_services; with multiprocessor_services_interface; use multiprocessor_services_interface; use multiprocessor_services_interface.scheduling_result_per_processor_package; with multiprocessor_services; use multiprocessor_services; with Gtk; use Gtk; with Gtk.Menu_Item; use Gtk.Menu_Item; with Gtk.Main; use Gtk.Main; with glib; use glib; with Glib.Error; use Glib.Error; with Gtk.Text_Buffer; use Gtk.Text_Buffer; with Gtk.Text_Tag_Table; use Gtk.Text_Tag_Table; with Gtk.Widget; use Gtk.Widget; with Gtk.Window; use Gtk.Window; with Gtk.Drawing_Area; use Gtk.Drawing_Area; with Gtkada.Dialogs; use Gtkada.Dialogs; with Gtkada.Builder; use Gtkada.Builder; with graphical_editor; use graphical_editor; with graphical_editor.message_text; use graphical_editor.message_text; with graphical_editor.draw_scheduling; use graphical_editor.draw_scheduling; procedure cheddar is procedure usage is begin Put_Line ("Cheddar is a GPL real-time scheduling analysis tool."); Put_Line ("This program provides services to automatically check temporal constraints of an architecture models composed of tasks/processors/cores/buffers/..."); New_Line; Put_Line ("Check Cheddar home page for details : http://beru.univ-brest.fr/cheddar"); New_Line; New_Line; Put_Line ("Usage : cheddar [switches] foo"); Put_Line (" where foo can be : "); Put_Line (" - an unique XML file "); Put_Line (" - one or several AADL files"); New_Line; Put_Line (" Switches can be :"); Put_Line (" -u get this help"); Put_Line (" -l select a language : ""fr"" for français; ""en"" for english ; default is english"); Put (" Default language is "); if (current_language = english) then Put ("English."); else Put ("Français."); end if; New_Line; Put (" -a the file names given to cheddar contain AADL descriptions instead of an XML file"); Put_Line (" Only one XML file can be provided to Cheddar but several AADL files can be sent to Cheddar."); Put_Line (" -I directory-name : gives an extra directory name where to look for XML or AADL files. By default, Cheddar only looks for project files into the Cheddar's current directory."); Put_Line (" -d activate Cheddar's debug mode "); Put_Line (" -i directory of glades files "); Put_Line (" -f font-name to select a new font to be used in the Cheddar editor"); Put_Line (" -c put the current Cheddar's configuration at the screen"); end usage; error : aliased Glib.Error.gerror; diag : guint; aadl_file : Boolean; a_dir_name : unbounded_string_ptr; project_file_name : unbounded_string_ptr; project_file_list : unbounded_string_list; begin -------------------------------------------------------- -- Initialize Cheddar -- Manage command lines -- Load files AADL/XML files -- Manage exception raised during AADL/XML files loading -------------------------------------------------------- copyright ("cheddar"); initialize_framework.set_initialize; initialize (sys); initialize (sched.all); initialize (project_file_list); event_table_file_name := empty_string; initialize (aadl_project_file_name); xml_event_table_file_name := To_Unbounded_String ("default_event_table.xml"); aadl_file := False; is_saved := False; is_new := True; begin loop case Getopt ("c d u l: a i I: f:") is when ASCII.NUL => exit; when 'c' => framework_config.extended.put; when 'a' => aadl_file := True; when 'd' => cheddar_debug := very_verbose; when 'f' => put_debug (" Selected font : " & Parameter); selected_font := To_Unbounded_String (Parameter); when 'i' => put_debug (" Install path : " & Parameter); install_path := To_Unbounded_String (Parameter); when 'I' => a_dir_name := new Unbounded_String; a_dir_name.all := To_Unbounded_String (Parameter); put_debug (" Project file directory : " & To_String (a_dir_name.all)); add (project_file_dir_list, a_dir_name); when 'u' => usage; OS_Exit (0); when 'l' => if (Parameter /= "fr") and (Parameter /= "en") then Put_Line ("cheddar.adb : invalid language parameter"); New_Line; usage; OS_Exit (0); else if Parameter = "fr" then current_language := francais; else current_language := english; end if; end if; when others => usage; OS_Exit (0); end case; end loop; loop project_file_name := new Unbounded_String; project_file_name.all := To_Unbounded_String (Get_Argument (Do_Expansion => True)); exit when project_file_name.all = empty_string; put_debug ("Project file to load : " & To_String (project_file_name.all)); add (project_file_list, project_file_name); end loop; if (get_number_of_elements (project_file_list) > 1) and (not aadl_file) then Put_Line ("cheddar.adb : can not load more than one XML file at the same time "); OS_Exit (0); end if; call_framework.initialize (aadl_file); glade_path := install_path & "glade_files/"; if (get_number_of_elements (project_file_list) > 0) then is_new := False; is_saved := True; if (aadl_file) then duplicate (project_file_list, aadl_project_file_name); systems.read_from_aadl_file (sys, project_file_dir_list, aadl_project_file_name); else project_file_name := get_head (project_file_list); xml_project_file_name := project_file_name.all; systems.read_from_xml_file (sys, project_file_dir_list, xml_project_file_name); end if; end if; exception when cache_not_found => Put_Line ("cheddar.adb : cache not found ; " & Exception_Message); OS_Exit (0); when address_space_not_found => Put_Line ("cheddar.adb : address space not found ; " & Exception_Message); OS_Exit (0); when buffer_not_found => Put_Line ("cheddar.adb : buffer not found ; " & Exception_Message); OS_Exit (0); when processor_not_found => Put_Line ("cheddar.adb : processor not found ; " & Exception_Message); OS_Exit (0); when network_not_found => Put_Line ("cheddar.adb : network not found ; " & Exception_Message); OS_Exit (0); when event_analyzer_not_found => Put_Line ("cheddar.adb : event analyzer not found ; " & Exception_Message); OS_Exit (0); when message_not_found => Put_Line ("cheddar.adb : message not found ; " & Exception_Message); OS_Exit (0); when core_unit_not_found => Put_Line ("cheddar.adb : core unit not found ; " & Exception_Message); OS_Exit (0); when task_not_found => Put_Line ("cheddar.adb : task not found ; " & Exception_Message); OS_Exit (0); when resource_not_found => Put_Line ("cheddar.adb : resource not found ; " & Exception_Message); OS_Exit (0); when task_group_not_found => Put_Line ("cheddar.adb : task group not found ; " & Exception_Message); OS_Exit (0); when cfg_node_not_found => Put_Line ("cheddar.adb : cfg node not found ; " & Exception_Message); OS_Exit (0); when cfg_edge_not_found => Put_Line ("cheddar.adb : cfg edge not found ; " & Exception_Message); OS_Exit (0); when cfg_not_found => Put_Line ("cheddar.adb : cfg not found ; " & Exception_Message); OS_Exit (0); when cache_access_profile_not_found => Put_Line ("cheddar.adb : cache access profile not found ; " & Exception_Message); OS_Exit (0); when systems.invalid_parameter => Put_Line ("cheddar.adb : invalid system attribute ; " & Exception_Message); OS_Exit (0); when cache_set.invalid_parameter => Put_Line ("cheddar.adb : invalid cache attribute ; " & Exception_Message); OS_Exit (0); when task_group_set.invalid_parameter => Put_Line ("cheddar.adb : invalid task_group attribute ; " & Exception_Message); OS_Exit (0); when network_set.invalid_parameter => Put_Line ("cheddar.adb : invalid network attribute ; " & Exception_Message); OS_Exit (0); when message_set.invalid_parameter => Put_Line ("cheddar.adb : invalid message attribute ; " & Exception_Message); OS_Exit (0); when event_analyzer_set.invalid_parameter => Put_Line ("cheddar.adb : invalid event_analyzer attribute ; " & Exception_Message); OS_Exit (0); when cfg_set.invalid_parameter => Put_Line ("cheddar.adb : invalid cfg attribute ; " & Exception_Message); OS_Exit (0); when cfg_node_set.invalid_parameter => Put_Line ("cheddar.adb : invalid cfg node attribute ; " & Exception_Message); OS_Exit (0); when cfg_edge_set.invalid_parameter => Put_Line ("cheddar.adb : invalid cfg edge attribute ; " & Exception_Message); OS_Exit (0); when task_set.invalid_parameter => if (aadl_file = True) then Put_Line ("Invalid thread component attribute ; " & Exception_Message); else Put_Line ("cheddar.adb : invalid task attribute ; " & Exception_Message); end if; OS_Exit (0); when address_space_set.invalid_parameter => if (aadl_file = True) then Put_Line ("Invalid process component attribute ; " & Exception_Message); else Put_Line ("cheddar.adb : invalid address space attribute ; " & Exception_Message); end if; OS_Exit (0); when processor_set.invalid_parameter => if (aadl_file = True) then Put_Line ("Invalid processor component attribute ; " & Exception_Message); else Put_Line ("cheddar.adb : invalid processor attribute ; " & Exception_Message); end if; OS_Exit (0); when buffer_set.invalid_parameter => if (aadl_file = True) then Put_Line ("Invalid event data port attribute ; " & Exception_Message); else Put_Line ("cheddar.adb : invalid buffer attribute ; " & Exception_Message); end if; OS_Exit (0); when resource_set.invalid_parameter => if (aadl_file = True) then Put_Line ("Invalid data component attribute ; " & Exception_Message); else Put_Line ("cheddar.adb : invalid resource attribute ; " & Exception_Message); end if; OS_Exit (0); when GNAT.Command_Line.Invalid_Switch => Put_Line ("cheddar.adb : invalid Switch ; " & Full_Switch); usage; OS_Exit (0); when GNAT.Command_Line.Invalid_Parameter => Put_Line ("cheddar.adb : missing parameter for switch ; " & Full_Switch); usage; OS_Exit (0); when xml_read_error => Put_Line ("cheddar.adb : Can not read project file ; Xml Fatal Error ; " & Exception_Message); OS_Exit (0); when aadl_read_error => Put_Line ("cheddar.adb : Can not read project files ; AADL parsing Error ; " & Exception_Message); OS_Exit (0); when Ada.IO_Exceptions.Name_Error => Put_Line ("cheddar.adb : Can not open project files, Name_Error"); OS_Exit (0); when Ada.IO_Exceptions.Status_Error => Put_Line ("cheddar.adb : Can not open project files, Status_Error"); OS_Exit (0); when Ada.IO_Exceptions.Mode_Error => Put_Line ("cheddar.adb : Can not open project files, Mode_Error"); OS_Exit (0); when Ada.IO_Exceptions.Use_Error => Put_Line ("cheddar.adb : Can not open project files, Use_Error"); OS_Exit (0); when Ada.IO_Exceptions.Device_Error => Put_Line ("cheddar.adb : Can not open project files, Device_Error"); OS_Exit (0); when Ada.IO_Exceptions.End_Error => Put_Line ("cheddar.adb : Can not open project files, End_Error"); OS_Exit (0); when Ada.IO_Exceptions.Data_Error => Put_Line ("cheddar.adb : Can not open project files, Data_Error"); OS_Exit (0); when Ada.IO_Exceptions.Layout_Error => Put_Line ("cheddar.adb : Can not open project files, Layout_Error"); OS_Exit (0); when others => Put_Line ("cheddar.adb : Can not load XML/AADL/SC file "); Put_Line ("Exception name : " & Exception_Name); Put_Line ("Exception message : " & Exception_Message); OS_Exit (0); end; -------------------------------------------------------- -- Initialize Machine man interface -- Manage exception raises during machine man interface use -------------------------------------------------------- Gtk.Main.Init; Gtk_New (builder_cheddar); diag := Add_From_File (builder_cheddar, To_String (glade_path) & "cheddar.glade", error'access); if diag = 0 then Ada.Text_IO.Put_Line ("Error : " & Get_Message (error)); Error_Free (Error); return; end if; -- Initialize widgets of the main window -- buffer_editor_cheddar := gtk_text_buffer (Get_Object (builder_cheddar, "textbuffer2")); initialize_message_text_properties; starting_text; drawing_area_cheddar := gtk_drawing_area(Get_Object (builder_cheddar, "drawingarea1")); graphical_editor.draw_scheduling.initialize; graphical_editor.draw_scheduling.clear_time_line; window_cheddar := gtk_window (Get_Object (builder_cheddar, "window1")); zoom_level_entry := gtk_text_buffer (Get_Object (builder_cheddar, "textbuffer1")); Set_Text (zoom_level_entry, To_String (display_zoom)); model_file_name_entry := gtk_text_buffer (Get_Object (builder_cheddar, "textbuffer3")); Set_Text (model_file_name_entry, To_String (simple_name (project_file_name.all))); -- Connect all event handlers -- connect_callbacks; -- Launch the GUI -- Do_Connect (builder_cheddar); declare Custom_Widget : constant Gtk.Widget.Gtk_Widget := Gtk.Widget.Gtk_Widget (Get_Object (Builder_cheddar, "window1")); begin Gtk.Widget.Show_All (Custom_Widget); end; Gtk.Main.Main; exception when others => Put_Line ("This is an internal Cheddar bug ... sorry"); Put_Line ("WARNING : your project was saved in the file cheddar_bug.xml"); Put_Line ("Exception name : " & Exception_Name); Put_Line ("Exception message : " & Exception_Message); systems.write_to_xml_file (sys, To_Unbounded_String ("cheddar_bug.xml")); Put_Line ("Please, send a bug report to cheddar@listes.univ-brest.fr"); Put_Line ("Do not forget to join your AADL/XML/SC Cheddar project files with your bug report"); end cheddar;