diff mbox

[RFC] gcov: dump in a static dtor instead of in an atexit handler

Message ID 694b3602-e18d-7749-c6a6-6af6831b6b2c@suse.cz
State New
Headers show

Commit Message

Martin Liška Sept. 29, 2016, 1:41 p.m. UTC
On 09/29/2016 03:00 PM, Nathan Sidwell wrote:
> On 09/29/16 08:54, Nathan Sidwell wrote:
>> On 09/29/16 08:49, Martin Liška wrote:
>>> Ideally we should have a macro for each target telling whether it supports
>>> priorities or not.
>>> However, we probably don't have? I would suggest to make the test conditional
>>> just for main
>>> targets which support priorities?
>>
>> or a dg_effective_target test.  Probably overkill if there's exactly one target
>> impacted.
> 
> already there : effective_target_init_priority

Nice that we have it. Looks it's going to be very first usage of the effective target.
I'm suggesting patch which also changes debugging messages to make it more readable.

Ready for trunk?
Thanks,
Martin
diff mbox

Patch

From cd66f6f9b9c68267698720dcf350b140d86f4201 Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Thu, 29 Sep 2016 15:39:08 +0200
Subject: [PATCH] Use effective target for pr16855

gcc/testsuite/ChangeLog:

2016-09-29  Martin Liska  <mliska@suse.cz>

	* g++.dg/gcov/pr16855.C: Add init_priority as an effective
	target.
---
 gcc/testsuite/g++.dg/gcov/pr16855.C | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/gcc/testsuite/g++.dg/gcov/pr16855.C b/gcc/testsuite/g++.dg/gcov/pr16855.C
index 91801d4..8167176 100644
--- a/gcc/testsuite/g++.dg/gcov/pr16855.C
+++ b/gcc/testsuite/g++.dg/gcov/pr16855.C
@@ -1,13 +1,15 @@ 
 /* { dg-options "-fprofile-arcs -ftest-coverage" } */
 /* { dg-do run { target native } } */
+/* { dg-require-effective-target init_priority  } */
 
 #include <stdlib.h>
+#include <stdio.h>
 
 int a;
 
 void foo()
 {
-  a = 123;						  /* count(1) */
+  fprintf (stderr, "atexit handler foo()\n"); 		  /* count(1) */
 }
 
 #include <iostream>
@@ -15,10 +17,10 @@  using namespace std;
 class Test {
 public:
 	Test(void){
-	cout<< "In Test ctor" << endl;			  /* count(1) */
+	fprintf (stderr, "In Test ctor\n");		  /* count(1) */
 	}
 	~Test(void){
-	cout<< "In Test dtor" << endl;			  /* count(1) */
+	fprintf (stderr, "In Test dtor\n");		  /* count(1) */
 	}
 }T1;
 
@@ -27,8 +29,7 @@  void uncalled(void){
 }
 int main(void){
 atexit (&foo);
-// Test T2;
-cout<< "In main" << endl;				  /* count(1) */
+fprintf (stderr, "In main\n");				  /* count(1) */
 return 0;
 }
 
@@ -36,12 +37,12 @@  return 0;
 
 __attribute__((constructor))
 static void construct_navigationBarImages() {
-  fprintf (stderr,  "((construct_navigationBarImages))"); /* count(1) */
+  fprintf (stderr,  "((construct_navigationBarImages))\n"); /* count(1) */
 }
 
 __attribute__((destructor))
 static void destroy_navigationBarImages() {
-  fprintf (stderr,  "((destroy_navigationBarImages))");	  /* count(1) */
+  fprintf (stderr,  "((destroy_navigationBarImages))\n");  /* count(1) */
 }
 
 /* { dg-final { run-gcov branches { -b pr16855.C } } } */
-- 
2.9.2