public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: Janis Johnson <janis@us.ibm.com>
To: gcc-gnats@gcc.gnu.org
Cc: michelle.lorenz@dialogic.com
Subject: c++/3639: gcov .bb info incorrect for C++ static initialization
Date: Tue, 10 Jul 2001 16:36:00 -0000	[thread overview]
Message-ID: <200107102334.f6ANYY923529@eng2.sequent.com> (raw)

>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:


             reply	other threads:[~2001-07-10 16:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-10 16:36 Janis Johnson [this message]
2002-09-15 15:48 nathan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200107102334.f6ANYY923529@eng2.sequent.com \
    --to=janis@us.ibm.com \
    --cc=gcc-gnats@gcc.gnu.org \
    --cc=michelle.lorenz@dialogic.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).