[Bug gcov-profile/44779] New: The gcov library does not adequately handle functions with constructor/destructor attributes

2010-07-02 Thread jay dot vaughan at thalesgroup dot com
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



[Bug gcov-profile/44779] The gcov library does not adequately handle functions with constructor/destructor attributes

2010-07-02 Thread jay dot vaughan at thalesgroup dot com


--- Comment #2 from jay dot vaughan at thalesgroup dot com  2010-07-02 
11:29 ---
Created an attachment (id=21066)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21066&action=view)
Makefile for testcase.

This the Makefile for a testunit that will demonstrate this behaviour.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44779



[Bug gcov-profile/44779] The gcov library does not adequately handle functions with constructor/destructor attributes

2010-07-02 Thread jay dot vaughan at thalesgroup dot com


--- Comment #3 from jay dot vaughan at thalesgroup dot com  2010-07-02 
11:30 ---
Created an attachment (id=21067)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21067&action=view)
This is the test application program sources for the testunit. 

This file is the test application, to be wrapped by the test library, to
demonstrate the behaviour of this bug.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44779



[Bug gcov-profile/44779] The gcov library does not adequately handle functions with constructor/destructor attributes

2010-07-02 Thread jay dot vaughan at thalesgroup dot com


--- Comment #4 from jay dot vaughan at thalesgroup dot com  2010-07-02 
11:31 ---
Created an attachment (id=21068)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21068&action=view)
This is the test library sources for the testunit. 

This file is the test library, which is wrapped around the application, to
demonstrate the behaviour of this bug.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44779



[Bug gcov-profile/44779] The gcov library does not adequately handle functions with constructor/destructor attributes

2010-07-02 Thread jay dot vaughan at thalesgroup dot com


--- Comment #5 from jay dot vaughan at thalesgroup dot com  2010-07-02 
11:32 ---
To use the sources provided as a test unit:

1. First, 'make clean'.
2. Then, 'make test.app' - notice the coverage of the constructor/destructor
functions.
3. Then, 'make test.lib' - notice coverage.


-- 

jay dot vaughan at thalesgroup dot com changed:

   What|Removed |Added

 CC|                |jay dot vaughan at
   |            |thalesgroup dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44779