From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27896 invoked by alias); 2 Jul 2010 08:13:27 -0000 Received: (qmail 27824 invoked by uid 48); 2 Jul 2010 08:13:12 -0000 Date: Fri, 02 Jul 2010 08:13:00 -0000 Subject: [Bug gcov-profile/44779] New: The gcov library does not adequately handle functions with constructor/destructor attributes X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "jay dot vaughan at thalesgroup dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2010-07/txt/msg00162.txt.bz2 I am developing a software system which has the requirement (as it is safety-critical), that we report full coverage of our modules as part of the validation process. One aspect of this software system is the inclusion of a library - lets call it libguardian - which is wrapped around all applications being run on our custom system, using LD_PRELOAD. The purpose of libguardian is to obtain valid conditions for continued launch prior to the execution of main() by the runtime in the wrapped application. To this end, libguardian defines a constructor and destructor pair of functions that obtain the valid conditions required for continued launch, and clean up/report on exit of the application. This libguardian, and associated applications, works perfectly fine. However, it is not possible to capture coverage information for these functions due to limits in gcov. The constructor/destructor methods are defined thus: #define GUARDIAN_CONSTRUCTOR_DESTRUCTOR_PRIORITY 65535 /* NOTE: this priority can also be 101! */ void guardian_constructor(void) __attribute__ ((constructor(GUARDIAN_CONSTRUCTOR_DESTRUCTOR_PRIORITY))); void guardian_destructor(void) __attribute__ ((destructor(GUARDIAN_CONSTRUCTOR_DESTRUCTOR_PRIORITY))); If the guardian_constructor() finds conditions unsavory for continued execution in our environment, it exit()'s immediately. In this circumstance, coverage is lost (or not provided) by gcov's atexit/destructor methods, as it appears that *priority* of known constructors is not accounted for in the gcov library, nor is there an atexit() handler that can adequately sort these priorities. -- Summary: The gcov library does not adequately handle functions with constructor/destructor attributes Product: gcc Version: 4.1.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: gcov-profile AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jay dot vaughan at thalesgroup dot com GCC host triplet: i586-redhat-linux- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44779