Patchwork [Ada] Skip frontend when option -gnatd.H is present

login
register
mail settings
Submitter Arnaud Charlet
Date Aug. 29, 2011, 9:37 a.m.
Message ID <20110829093707.GA25559@adacore.com>
Download mbox | patch
Permalink /patch/112000/
State New
Headers show

Comments

Arnaud Charlet - Aug. 29, 2011, 9:37 a.m.
If the option -gnatd.H is present (Standard Package mode for gnat2why), skip
the frontend, except the call to Create_Standard, and call the backend
directly.

Tested on x86_64-pc-linux-gnu, committed on trunk

2011-08-29  Johannes Kanig  <kanig@adacore.com>

	* frontend.adb (Frontend): Exit after creating Standard package when
	-gnatd.H is present.
	* gnat1drv.adb (Gnat1drv): Call Backend right away when -gnatd.H is
	present.

Patch

Index: frontend.adb
===================================================================
--- frontend.adb	(revision 178155)
+++ frontend.adb	(working copy)
@@ -98,6 +98,12 @@ 
 
    CStand.Create_Standard;
 
+   --  If the -gnatd.H flag is present, we are only interested in the Standard
+   --  package, so the frontend has done its job here.
+   if Debug_Flag_Dot_HH then
+      return;
+   end if;
+
    --  Check possible symbol definitions specified by -gnateD switches
 
    Prepcomp.Process_Command_Line_Symbol_Definitions;
Index: gnat1drv.adb
===================================================================
--- gnat1drv.adb	(revision 178163)
+++ gnat1drv.adb	(working copy)
@@ -771,8 +771,23 @@ 
       Frontend;
 
       --  Exit with errors if the main source could not be parsed
-
+      --  Also, when -gnatd.H is present, the source file is not set.
       if Sinput.Main_Source_File = No_Source_File then
+         if Debug_Flag_Dot_HH then
+            --  We lock all the tables to keep the convention that the backend
+            --  needs to unlock the tables it wants to touch.
+            Atree.Lock;
+            Elists.Lock;
+            Fname.UF.Lock;
+            Inline.Lock;
+            Lib.Lock;
+            Nlists.Lock;
+            Sem.Lock;
+            Sinput.Lock;
+            Namet.Lock;
+            Stringt.Lock;
+            Back_End.Call_Back_End (Back_End.Generate_Object);
+         end if;
          Errout.Finalize (Last_Call => True);
          Errout.Output_Messages;
          Exit_Program (E_Errors);