aboutsummaryrefslogtreecommitdiff
path: root/gcc/gcov-dump.c
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2020-06-02 10:11:07 +0200
committerMartin Liska <mliska@suse.cz>2020-07-02 10:16:02 +0200
commitece21ff6ea9d969d3b6aae82136622a7126eefc1 (patch)
treead2d4be24aa0e4415a1caccbca083eed063194f0 /gcc/gcov-dump.c
parent8f8ea4a47f3ab0b44b2bbf1c77db6111325d4841 (diff)
downloadgcc-ece21ff6ea9d969d3b6aae82136622a7126eefc1.zip
gcc-ece21ff6ea9d969d3b6aae82136622a7126eefc1.tar.gz
gcc-ece21ff6ea9d969d3b6aae82136622a7126eefc1.tar.bz2
Do not stream all zeros for gcda files.
gcc/ChangeLog: PR gcov-profile/95348 * coverage.c (read_counts_file): Read only COUNTERS that are not all-zero. * gcov-dump.c (tag_function): Change signature from unsigned to signed integer. (tag_blocks): Likewise. (tag_arcs): Likewise. (tag_lines): Likewise. (tag_counters): Likewise. (tag_summary): Likewise. * gcov.c (read_count_file): Read all non-zero counters sensitively. libgcc/ChangeLog: PR gcov-profile/95348 * libgcov-driver.c (merge_one_data): Merge only profiles that are not of non-zero type. (write_one_data): Write counters only if there's one non-zero value. * libgcov-util.c (tag_function): Change signature from unsigned to int. (tag_blocks): Likewise. (tag_arcs): Likewise. (tag_counters): Likewise. (tag_summary): Likewise. (tag_lines): Read only if COUNTERS is non-zero. (read_gcda_file): Handle negative length for COUNTERS type.
Diffstat (limited to 'gcc/gcov-dump.c')
-rw-r--r--gcc/gcov-dump.c51
1 files changed, 27 insertions, 24 deletions
diff --git a/gcc/gcov-dump.c b/gcc/gcov-dump.c
index cfa771e4..97ff278 100644
--- a/gcc/gcov-dump.c
+++ b/gcc/gcov-dump.c
@@ -32,19 +32,19 @@ static void dump_gcov_file (const char *);
static void print_prefix (const char *, unsigned, gcov_position_t);
static void print_usage (void);
static void print_version (void);
-static void tag_function (const char *, unsigned, unsigned, unsigned);
-static void tag_blocks (const char *, unsigned, unsigned, unsigned);
-static void tag_arcs (const char *, unsigned, unsigned, unsigned);
-static void tag_lines (const char *, unsigned, unsigned, unsigned);
-static void tag_counters (const char *, unsigned, unsigned, unsigned);
-static void tag_summary (const char *, unsigned, unsigned, unsigned);
+static void tag_function (const char *, unsigned, int, unsigned);
+static void tag_blocks (const char *, unsigned, int, unsigned);
+static void tag_arcs (const char *, unsigned, int, unsigned);
+static void tag_lines (const char *, unsigned, int, unsigned);
+static void tag_counters (const char *, unsigned, int, unsigned);
+static void tag_summary (const char *, unsigned, int, unsigned);
extern int main (int, char **);
typedef struct tag_format
{
unsigned tag;
char const *name;
- void (*proc) (const char *, unsigned, unsigned, unsigned);
+ void (*proc) (const char *, unsigned, int, unsigned);
} tag_format_t;
static int flag_dump_contents = 0;
@@ -225,6 +225,7 @@ dump_gcov_file (const char *filename)
while (1)
{
gcov_position_t base, position = gcov_position ();
+ int read_length;
unsigned tag, length;
tag_format_t const *format;
unsigned tag_depth;
@@ -234,7 +235,8 @@ dump_gcov_file (const char *filename)
tag = gcov_read_unsigned ();
if (!tag)
break;
- length = gcov_read_unsigned ();
+ read_length = (int)gcov_read_unsigned ();
+ length = read_length > 0 ? read_length : 0;
base = gcov_position ();
mask = GCOV_TAG_MASK (tag) >> 1;
for (tag_depth = 4; mask; mask >>= 8)
@@ -264,9 +266,9 @@ dump_gcov_file (const char *filename)
}
print_prefix (filename, tag_depth, position);
- printf ("%08x:%4u:%s", tag, length, format->name);
+ printf ("%08x:%4u:%s", tag, abs (read_length), format->name);
if (format->proc)
- (*format->proc) (filename, tag, length, depth);
+ (*format->proc) (filename, tag, read_length, depth);
printf ("\n");
if (flag_dump_contents && format->proc)
@@ -294,10 +296,10 @@ dump_gcov_file (const char *filename)
static void
tag_function (const char *filename ATTRIBUTE_UNUSED,
- unsigned tag ATTRIBUTE_UNUSED, unsigned length,
+ unsigned tag ATTRIBUTE_UNUSED, int length,
unsigned depth ATTRIBUTE_UNUSED)
{
- unsigned long pos = gcov_position ();
+ long pos = gcov_position ();
if (!length)
printf (" placeholder");
@@ -330,7 +332,7 @@ tag_function (const char *filename ATTRIBUTE_UNUSED,
static void
tag_blocks (const char *filename ATTRIBUTE_UNUSED,
- unsigned tag ATTRIBUTE_UNUSED, unsigned length ATTRIBUTE_UNUSED,
+ unsigned tag ATTRIBUTE_UNUSED, int length ATTRIBUTE_UNUSED,
unsigned depth ATTRIBUTE_UNUSED)
{
printf (" %u blocks", gcov_read_unsigned ());
@@ -338,7 +340,7 @@ tag_blocks (const char *filename ATTRIBUTE_UNUSED,
static void
tag_arcs (const char *filename ATTRIBUTE_UNUSED,
- unsigned tag ATTRIBUTE_UNUSED, unsigned length ATTRIBUTE_UNUSED,
+ unsigned tag ATTRIBUTE_UNUSED, int length ATTRIBUTE_UNUSED,
unsigned depth)
{
unsigned n_arcs = GCOV_TAG_ARCS_NUM (length);
@@ -380,7 +382,7 @@ tag_arcs (const char *filename ATTRIBUTE_UNUSED,
static void
tag_lines (const char *filename ATTRIBUTE_UNUSED,
- unsigned tag ATTRIBUTE_UNUSED, unsigned length ATTRIBUTE_UNUSED,
+ unsigned tag ATTRIBUTE_UNUSED, int length ATTRIBUTE_UNUSED,
unsigned depth)
{
if (flag_dump_contents)
@@ -425,7 +427,7 @@ tag_lines (const char *filename ATTRIBUTE_UNUSED,
static void
tag_counters (const char *filename ATTRIBUTE_UNUSED,
- unsigned tag ATTRIBUTE_UNUSED, unsigned length ATTRIBUTE_UNUSED,
+ unsigned tag ATTRIBUTE_UNUSED, int length ATTRIBUTE_UNUSED,
unsigned depth)
{
#define DEF_GCOV_COUNTER(COUNTER, NAME, MERGE_FN) NAME,
@@ -433,15 +435,16 @@ tag_counters (const char *filename ATTRIBUTE_UNUSED,
#include "gcov-counter.def"
};
#undef DEF_GCOV_COUNTER
- unsigned n_counts = GCOV_TAG_COUNTER_NUM (length);
+ int n_counts = GCOV_TAG_COUNTER_NUM (length);
+ bool has_zeros = n_counts < 0;
+ n_counts = abs (n_counts);
- printf (" %s %u counts",
- counter_names[GCOV_COUNTER_FOR_TAG (tag)], n_counts);
+ printf (" %s %u counts%s",
+ counter_names[GCOV_COUNTER_FOR_TAG (tag)], n_counts,
+ has_zeros ? " (all zero)" : "");
if (flag_dump_contents)
{
- unsigned ix;
-
- for (ix = 0; ix != n_counts; ix++)
+ for (int ix = 0; ix != n_counts; ix++)
{
gcov_type count;
@@ -457,7 +460,7 @@ tag_counters (const char *filename ATTRIBUTE_UNUSED,
printf (VALUE_PADDING_PREFIX VALUE_PREFIX, ix);
}
- count = gcov_read_counter ();
+ count = has_zeros ? 0 : gcov_read_counter ();
printf ("%" PRId64 " ", count);
}
}
@@ -465,7 +468,7 @@ tag_counters (const char *filename ATTRIBUTE_UNUSED,
static void
tag_summary (const char *filename ATTRIBUTE_UNUSED,
- unsigned tag ATTRIBUTE_UNUSED, unsigned length ATTRIBUTE_UNUSED,
+ unsigned tag ATTRIBUTE_UNUSED, int length ATTRIBUTE_UNUSED,
unsigned depth ATTRIBUTE_UNUSED)
{
gcov_summary summary;