public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/3639: gcov .bb info incorrect for C++ static initialization
@ 2002-09-15 15:48 nathan
  0 siblings, 0 replies; 2+ messages in thread
From: nathan @ 2002-09-15 15:48 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, janis, nobody

Synopsis: gcov .bb info incorrect for C++ static initialization

State-Changed-From-To: open->closed
State-Changed-By: nathan
State-Changed-When: Sun Sep 15 15:48:05 2002
State-Changed-Why:
    appears fixed in CVS

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=3639


^ permalink raw reply	[flat|nested] 2+ messages in thread

* c++/3639: gcov .bb info incorrect for C++ static initialization
@ 2001-07-10 16:36 Janis Johnson
  0 siblings, 0 replies; 2+ messages in thread
From: Janis Johnson @ 2001-07-10 16:36 UTC (permalink / raw)
  To: gcc-gnats; +Cc: michelle.lorenz

>Number:         3639
>Category:       c++
>Synopsis:       gcov .bb info incorrect for C++ static initialization
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jul 10 16:36:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Janis Johnson
>Release:        3.1 20010707 (experimental)
>Organization:
IBM
>Environment:
System: Linux unknown.host 2.2.14 #5 SMP Sat Jun 24 15:44:37 PDT 2000 i686 unknown
Architecture: i686

	
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc-mainline/configure --prefix=/home/janis/gnu/tools/gcc-mainline --enable-languages=c,c++
>Description:

This provides further information about a problem reported in
http://gcc.gnu.org/ml/gcc-bugs/2001-04/msg00034.html by Michelle Lorenz
(limitations with gcov and STL).

This problem occurs with GCC 3.0 and the mainline (gcc version 3.1
20010707 (experimental)) but not with 2.95.3.

A C++ module that has a static object that needs a call to a constructor
or destructor generates code for
__static_initialization_and_destruction_0(int, int).  When an included
C++ file defines such a static object (as happens in libstdc++), the
information that branch_prob() puts into the sourcename.bb file for this
module confuses gcov.  The function is noted as being in the including
source file, with a line number for each file that contains a static
object definition.  If the number of lines in the original source file
is less than the line number of one of these definitions in an included
file then gcov aborts, as in the referenced message to gcc-bugs.  If the
including file is large enough then gcov reports counts for a call to
__static_initialization_and_destruction_0() at the line number for the
included file but in the report for the including file.

The file bb_bug1.C.gcov produced by the example is:
------------------------------------------------------------------------
		extern int foo();
		
		#ifndef NOINCL
		#include "bb_bug2.C"
		#endif
		
		struct S {
		  int i;
           4      S() { i = 0; }
		};
		
           1    S s;
branch 0 taken = 0%
branch 1 taken = 0%
branch 2 taken = 0%
		
		int
		main ()
           1    {
           1      return foo();
           1    }
		
		
		
		
		
		
		
		
		
		
		
		
           1    
branch 0 taken = 0%
branch 1 taken = 0%
branch 2 taken = 0%
		
		
		
		
		
------------------------------------------------------------------------

The set of numbers near the bottom should be in bb_bug2.C.gcov.  If
bb_bug1.C were shorter then gcov would abort.

(This was done using a compiler with my patch to profile.c submitted
on July 2, 2001.)

There are other problems here as well, but I'll try to describe (or fix)
them separately.

>How-To-Repeat:

To reproduce the problem, extract the souce files below and do:

  gcc -ftest-coverage -fprofile-arcs -o bb_bug1 bb_bug1.c
  bb_bug1
  gcov -b bb_bug1

-- bb_bug1.C -----------------------------------------------------------
extern int foo();

#ifndef NOINCL
#include "bb_bug2.C"
#endif

struct S {
  int i;
  S() { i = 0; }
};

S s;

int
main ()
{
  return foo();
}


















-- bb_bug2.C -----------------------------------------------------------

























struct T {
  int i;
  T() { i = 0; }
};

T t;

int foo()
{
  return t.i; 
}
------------------------------------------------------------------------
>Fix:
	
>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-09-15 22:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-15 15:48 c++/3639: gcov .bb info incorrect for C++ static initialization nathan
  -- strict thread matches above, loose matches on Subject: below --
2001-07-10 16:36 Janis Johnson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).