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;
printf (" -h, --help Print this help\n");
printf (" -l, --long Dump record contents too\n");
printf (" -p, --positions Dump record positions\n");
- printf (" -r, --raw Print content records in raw format\n");
+ printf (" -r, --raw Print content records in raw format\n");
printf (" -v, --version Print version number\n");
printf ("\nFor bug reporting instructions, please see:\n%s.\n",
bug_report_url);
{
printf ("gcov-dump %s%s\n", pkgversion_string, version_string);
printf ("Copyright (C) 2020 Free Software Foundation, Inc.\n");
- printf ("This is free software; see the source for copying conditions.\n"
- "There is NO warranty; not even for MERCHANTABILITY or \n"
- "FITNESS FOR A PARTICULAR PURPOSE.\n\n");
+ printf ("This is free software; see the source for copying conditions. There is NO\n\
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n");
}
static void
while (1)
{
gcov_position_t base, position = gcov_position ();
+ int read_length;
unsigned tag, length;
tag_format_t const *format;
unsigned tag_depth;
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)
}
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)
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 ();
+ gcov_position_t pos = gcov_position ();
if (!length)
printf (" placeholder");
printf (", lineno_checksum=0x%08x", gcov_read_unsigned ());
printf (", cfg_checksum=0x%08x", gcov_read_unsigned ());
- if (gcov_position () - pos < length)
+ if (gcov_position () - pos < (gcov_position_t) length)
{
const char *name;
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 ());
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);
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)
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,
#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;
printf (VALUE_PADDING_PREFIX VALUE_PREFIX, ix);
}
- count = gcov_read_counter ();
+ count = has_zeros ? 0 : gcov_read_counter ();
printf ("%" PRId64 " ", count);
}
}
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;