summaryrefslogtreecommitdiff
path: root/gcc/gcov-dump.c
diff options
context:
space:
mode:
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2003-04-07 19:37:12 +0000
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2003-04-07 19:37:12 +0000
commit9219dd0a97690c85202ee9f576b49b58b9659bcf (patch)
tree544c50187f4dba610ef1e5aca2d2179d3211968b /gcc/gcov-dump.c
parent38d1018aa87ac7321c0bb9cad97e6fb2d42f2225 (diff)
downloadlinaro-gcc-9219dd0a97690c85202ee9f576b49b58b9659bcf.tar.gz
linaro-gcc-9219dd0a97690c85202ee9f576b49b58b9659bcf.tar.bz2
linaro-gcc-9219dd0a97690c85202ee9f576b49b58b9659bcf.zip
Change gcov file interface to single file at a time.
* gcov-io.h: Replace IN_LIBGCC1 with IN_LIBGCOV. Use IN_GCOV. Convert to C89 prototypes. (gcov_file, gcov_length, gcov_position, gcov_buffer, gcov_alloc, gcov_error, gcov_modified): New static variables. (gcov_open, gcov_close, gcov_read_bytes, gcov_write_bytes): New functions. (gcov_write_unsigned, gcov_write_counter, gcov_write_string, gcov_read_unsigned, gcov_read_counter, gcov_read_string): Adjust. (gcov_read_summary, gcov_write_summary): Adjust. (gcov_save_position, gcov_reserve_length, gcov_write_length): Adjust. (gcov_resync, gcov_skip, gcov_skip_string): Adjust. (da_file_open, da_file_close, da_file_eof, da_file_error): Remove. (da_file_position, da_file_seek, da_file_write, da_file_read): Remove. (gcov_error, gcov_eof, gcov_ok, gcov_time): New functions. * gcov.c (gcov_type): Don't typedef here. (IN_GCOV): #define (read_graph_file, read_count_file): Adjust. * gcov-dump.c (gcov_type): Don't typedef here. (IN_GCOV): #define. (tag_function, tag_blocks, tag_arcs, tag_lines, tag_arc_counts): Remove FILE parameter, adjust. (struct tag_format): Adjust proc member. (dump_file): Adjust. * libgcov.c (IN_LIBGCOV): #define. (gcov_exit): Adjust. * loop-init.c: Don't #include gcov-io.h * profile.c (struct counts_entry): New structure to hold counter values. (struct section_reference, struct da_index_entry): Remove. (bbg_file, da_file): Remove. (htab_counts_index_hash, htab_counts_index_eq, htab_counts_index_del): Replace with ... (htab_counts_entry_hash, htab_counts_entry_eq, htab_counts_entry_del): ... these. (cleanup_counts_index, index_counts_file): Remove. (read_counts_file): New function. (get_exec_counts): Adjust. (compute_branch_probabilities): Don't free the exec counts here. (branch_prob): Adjust. (init_branch_prob): Adjust. (end_branch_prob): Adjust. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@65338 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gcov-dump.c')
-rw-r--r--gcc/gcov-dump.c101
1 files changed, 51 insertions, 50 deletions
diff --git a/gcc/gcov-dump.c b/gcc/gcov-dump.c
index acea56d9d64..5ca64a4f6cf 100644
--- a/gcc/gcov-dump.c
+++ b/gcc/gcov-dump.c
@@ -23,26 +23,26 @@ Boston, MA 02111-1307, USA. */
#include "tm.h"
#include "version.h"
#include <getopt.h>
-typedef HOST_WIDEST_INT gcov_type;
+#define IN_GCOV (-1)
#include "gcov-io.h"
static void dump_file PARAMS ((const char *));
static void print_prefix PARAMS ((const char *, unsigned));
static void print_usage PARAMS ((void));
static void print_version PARAMS ((void));
-static int tag_function PARAMS ((const char *, FILE *, unsigned, unsigned));
-static int tag_blocks PARAMS ((const char *, FILE *, unsigned, unsigned));
-static int tag_arcs PARAMS ((const char *, FILE *, unsigned, unsigned));
-static int tag_lines PARAMS ((const char *, FILE *, unsigned, unsigned));
-static int tag_arc_counts PARAMS ((const char *, FILE *, unsigned, unsigned));
-static int tag_summary PARAMS ((const char *, FILE *, unsigned, unsigned));
+static int tag_function PARAMS ((const char *, unsigned, unsigned));
+static int tag_blocks PARAMS ((const char *, unsigned, unsigned));
+static int tag_arcs PARAMS ((const char *, unsigned, unsigned));
+static int tag_lines PARAMS ((const char *, unsigned, unsigned));
+static int tag_arc_counts PARAMS ((const char *, unsigned, unsigned));
+static int tag_summary PARAMS ((const char *, unsigned, unsigned));
extern int main PARAMS ((int, char **));
typedef struct tag_format
{
unsigned tag;
char const *name;
- int (*proc) (const char *, FILE *, unsigned, unsigned);
+ int (*proc) (const char *, unsigned, unsigned);
} tag_format_t;
static int flag_dump_contents = 0;
@@ -138,24 +138,22 @@ static void
dump_file (filename)
const char *filename;
{
- FILE *file = fopen (filename, "rb");
unsigned tags[4];
unsigned depth = 0;
unsigned magic, version;
unsigned tag, length;
- if (!file)
+ if (!gcov_open (filename, 1))
{
fprintf (stderr, "%s:cannot open\n", filename);
return;
}
- if (gcov_read_unsigned (file, &magic)
- || gcov_read_unsigned (file, &version))
+ if (gcov_read_unsigned (&magic) || gcov_read_unsigned (&version))
{
read_error:;
- printf ("%s:read error at %ld\n", filename, ftell (file));
- fclose (file);
+ printf ("%s:read error at %lu\n", filename, gcov_save_position ());
+ gcov_close ();
return;
}
@@ -174,7 +172,7 @@ dump_file (filename)
else
{
printf ("%s:not a gcov file\n", filename);
- fclose (file);
+ gcov_close ();
return;
}
for (ix = 4; ix--; expected >>= 8, version >>= 8, magic >>= 8)
@@ -189,14 +187,13 @@ dump_file (filename)
printf ("%s:warning:current version is `%.4s'\n", filename, e);
}
- while (!gcov_read_unsigned (file, &tag)
- && !gcov_read_unsigned (file, &length))
+ while (!gcov_read_unsigned (&tag) && !gcov_read_unsigned (&length))
{
tag_format_t const *format;
unsigned tag_depth;
long base, end;
- base = gcov_save_position (file);
+ base = gcov_save_position ();
if (!tag)
tag_depth = depth;
@@ -234,11 +231,11 @@ dump_file (filename)
print_prefix (filename, tag_depth);
printf ("%08x:%4u:%s", tag, length, format->name);
if (format->proc)
- if ((*format->proc) (filename, file, tag, length))
+ if ((*format->proc) (filename, tag, length))
goto read_error;
printf ("\n");
- end = gcov_save_position (file);
- gcov_resync (file, base, length);
+ end = gcov_save_position ();
+ gcov_resync (base, length);
if (format->proc && end != base + (long)length)
{
if (end > base + (long)length)
@@ -249,35 +246,44 @@ dump_file (filename)
filename, length - (end - base));
}
}
- if (!feof (file))
+ if (!gcov_eof ())
goto read_error;
- fclose (file);
+ gcov_close ();
}
static int
-tag_function (filename, file, tag, length)
+tag_function (filename, tag, length)
const char *filename ATTRIBUTE_UNUSED;
- FILE *file ATTRIBUTE_UNUSED;
unsigned tag ATTRIBUTE_UNUSED;
unsigned length ATTRIBUTE_UNUSED;
{
char *name = NULL;
unsigned checksum;
+ char *src = NULL;
+ unsigned lineno = 0;
+ unsigned long pos = gcov_save_position ();
+
+ if (gcov_read_string (&name)
+ || gcov_read_unsigned (&checksum))
+ return 1;
- if (gcov_read_string (file, &name, NULL)
- || gcov_read_unsigned (file, &checksum))
+ if (gcov_save_position () - pos != length
+ && (gcov_read_string (&src)
+ || gcov_read_unsigned (&lineno)))
return 1;
printf (" `%s' checksum=0x%08x", name, checksum);
+ if (src)
+ printf (" %s:%u", src, lineno);
free (name);
+ free (src);
return 0;
}
static int
-tag_blocks (filename, file, tag, length)
+tag_blocks (filename, tag, length)
const char *filename ATTRIBUTE_UNUSED;
- FILE *file ATTRIBUTE_UNUSED;
unsigned tag ATTRIBUTE_UNUSED;
unsigned length ATTRIBUTE_UNUSED;
{
@@ -292,7 +298,7 @@ tag_blocks (filename, file, tag, length)
for (ix = 0; ix != n_blocks; ix++)
{
unsigned flags;
- if (gcov_read_unsigned (file, &flags))
+ if (gcov_read_unsigned (&flags))
return 1;
if (!(ix & 7))
printf ("\n%s:\t\t%u", filename, ix);
@@ -301,15 +307,14 @@ tag_blocks (filename, file, tag, length)
}
else
- gcov_skip (file, n_blocks * 4);
+ gcov_skip (n_blocks * 4);
return 0;
}
static int
-tag_arcs (filename, file, tag, length)
+tag_arcs (filename, tag, length)
const char *filename ATTRIBUTE_UNUSED;
- FILE *file ATTRIBUTE_UNUSED;
unsigned tag ATTRIBUTE_UNUSED;
unsigned length ATTRIBUTE_UNUSED;
{
@@ -321,15 +326,14 @@ tag_arcs (filename, file, tag, length)
unsigned ix;
unsigned blockno;
- if (gcov_read_unsigned (file, &blockno))
+ if (gcov_read_unsigned (&blockno))
return 1;
for (ix = 0; ix != n_arcs; ix++)
{
unsigned dst, flags;
- if (gcov_read_unsigned (file, &dst)
- || gcov_read_unsigned (file, &flags))
+ if (gcov_read_unsigned (&dst) || gcov_read_unsigned (&flags))
return 1;
if (!(ix & 3))
printf ("\n%s:\t\t%u:", filename, blockno);
@@ -337,15 +341,14 @@ tag_arcs (filename, file, tag, length)
}
}
else
- gcov_skip (file, 4 + n_arcs * 8);
+ gcov_skip (4 + n_arcs * 8);
return 0;
}
static int
-tag_lines (filename, file, tag, length)
+tag_lines (filename, tag, length)
const char *filename ATTRIBUTE_UNUSED;
- FILE *file ATTRIBUTE_UNUSED;
unsigned tag ATTRIBUTE_UNUSED;
unsigned length ATTRIBUTE_UNUSED;
{
@@ -355,21 +358,21 @@ tag_lines (filename, file, tag, length)
unsigned blockno;
char const *sep = NULL;
- if (gcov_read_unsigned (file, &blockno))
+ if (gcov_read_unsigned (&blockno))
return 1;
while (1)
{
unsigned lineno;
- if (gcov_read_unsigned (file, &lineno))
+ if (gcov_read_unsigned (&lineno))
{
free (source);
return 1;
}
if (!lineno)
{
- if (gcov_read_string (file, &source, NULL))
+ if (gcov_read_string (&source))
return 1;
if (!source)
break;
@@ -394,15 +397,14 @@ tag_lines (filename, file, tag, length)
}
}
else
- gcov_skip (file, length);
+ gcov_skip (length);
return 0;
}
static int
-tag_arc_counts (filename, file, tag, length)
+tag_arc_counts (filename, tag, length)
const char *filename ATTRIBUTE_UNUSED;
- FILE *file ATTRIBUTE_UNUSED;
unsigned tag ATTRIBUTE_UNUSED;
unsigned length ATTRIBUTE_UNUSED;
{
@@ -417,7 +419,7 @@ tag_arc_counts (filename, file, tag, length)
{
gcov_type count;
- if (gcov_read_counter (file, &count))
+ if (gcov_read_counter (&count))
return 1;
if (!(ix & 7))
printf ("\n%s:\t\t%u", filename, ix);
@@ -426,21 +428,20 @@ tag_arc_counts (filename, file, tag, length)
}
}
else
- gcov_skip (file, n_counts * 8);
+ gcov_skip (n_counts * 8);
return 0;
}
static int
-tag_summary (filename, file, tag, length)
+tag_summary (filename, tag, length)
const char *filename ATTRIBUTE_UNUSED;
- FILE *file ATTRIBUTE_UNUSED;
unsigned tag ATTRIBUTE_UNUSED;
unsigned length ATTRIBUTE_UNUSED;
{
struct gcov_summary summary;
- if (gcov_read_summary (file, &summary))
+ if (gcov_read_summary (&summary))
return 1;
printf (" checksum=0x%08x", summary.checksum);