[COMMITTED,11/30] ada: Add Dump_Buffers hooks for code coverage

Message ID 20240620085321.2412421-11-poulhies@adacore.com
State Committed
Commit 7abf2222bed225e8b39bc2256eebb29692a8fde9
Headers
Series [COMMITTED,01/30] ada: Fix list of attributes defined by Ada 2022 |

Commit Message

Marc Poulhiès June 20, 2024, 8:53 a.m. UTC
  From: Ronan Desplanques <desplanques@adacore.com>

The purpose of this patch is to make it possible to set up code
coverage for the GNAT front end in gnat1 using GNATcoverage. It is
not obvious how to have GNATcoverage instrument gnat1's main function,
and since the front end has a clear entry point (Gnat1drv), we add
manual instrumentation annotations there.

gcc/ada/

	* gnat1drv.adb (Gnat1drv): Add coverage instrumentation
	annotations.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/gnat1drv.adb | 7 +++++++
 1 file changed, 7 insertions(+)
  

Patch

diff --git a/gcc/ada/gnat1drv.adb b/gcc/ada/gnat1drv.adb
index 754dab82862..9743dfd4c4c 100644
--- a/gcc/ada/gnat1drv.adb
+++ b/gcc/ada/gnat1drv.adb
@@ -1526,6 +1526,8 @@  begin
             Check_Rep_Info;
          end if;
 
+         pragma Annotate (Xcov, Dump_Buffers);
+
          return;
       end if;
 
@@ -1679,6 +1681,8 @@  begin
       Atree.Print_Statistics;
    end if;
 
+   pragma Annotate (Xcov, Dump_Buffers);
+
 --  The outer exception handler handles an unrecoverable error
 
 exception
@@ -1693,6 +1697,9 @@  exception
       Set_Standard_Output;
       Source_Dump;
       Tree_Dump;
+
+      pragma Annotate (Xcov, Dump_Buffers);
+
       Exit_Program (E_Errors);
 
 end Gnat1drv;