aboutsummaryrefslogtreecommitdiff
path: root/libgcc
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2022-03-31 11:37:56 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2022-04-28 20:46:49 +0200
commit1a6314b040877842ac71e6d9d786fe7a452e51e2 (patch)
tree7fe7a84ae4991b50d62030080634245de82fbb4f /libgcc
parentd170ecc9fcb386bd5f62eb86dd6e411e6fcb4cef (diff)
downloadgcc-1a6314b040877842ac71e6d9d786fe7a452e51e2.zip
gcc-1a6314b040877842ac71e6d9d786fe7a452e51e2.tar.gz
gcc-1a6314b040877842ac71e6d9d786fe7a452e51e2.tar.bz2
gcov: Add open mode parameter to gcov_do_dump()
gcc/ * gcov-tool.cc (gcov_do_dump): Add mode parameter. (gcov_output_files): Open files for reading and writing. libgcc/ * libgcov-driver-system.c (gcov_exit_open_gcda_file): Add mode parameter. Pass mode to gcov_open() calls. * libgcov-driver.c (dump_one_gcov): Add mode parameter. Pass mode to gcov_exit_open_gcda_file() call. (gcov_do_dump): Add mode parameter. Pass mode to dump_one_gcov() calls. (__gcov_dump_one): Open file for reading and writing.
Diffstat (limited to 'libgcc')
-rw-r--r--libgcc/libgcov-driver-system.c7
-rw-r--r--libgcc/libgcov-driver.c12
2 files changed, 10 insertions, 9 deletions
diff --git a/libgcc/libgcov-driver-system.c b/libgcc/libgcov-driver-system.c
index 9abb2fe..ac405c3 100644
--- a/libgcc/libgcov-driver-system.c
+++ b/libgcc/libgcov-driver-system.c
@@ -261,7 +261,8 @@ allocate_filename_struct (struct gcov_filename *gf)
static int
gcov_exit_open_gcda_file (struct gcov_info *gi_ptr,
- struct gcov_filename *gf)
+ struct gcov_filename *gf,
+ int mode)
{
int append_slash = 0;
const char *fname = gi_ptr->filename;
@@ -309,7 +310,7 @@ gcov_exit_open_gcda_file (struct gcov_info *gi_ptr,
gf->filename = replace_filename_variables (gf->filename);
- if (!gcov_open (gf->filename, 0))
+ if (!gcov_open (gf->filename, mode))
{
/* Open failed likely due to missed directory.
Create directory and retry to open file. */
@@ -318,7 +319,7 @@ gcov_exit_open_gcda_file (struct gcov_info *gi_ptr,
fprintf (stderr, "profiling:%s:Skip\n", gf->filename);
return -1;
}
- if (!gcov_open (gf->filename, 0))
+ if (!gcov_open (gf->filename, mode))
{
fprintf (stderr, "profiling:%s:Cannot open\n", gf->filename);
return -1;
diff --git a/libgcc/libgcov-driver.c b/libgcc/libgcov-driver.c
index 7e52c56..10831e8 100644
--- a/libgcc/libgcov-driver.c
+++ b/libgcc/libgcov-driver.c
@@ -595,14 +595,14 @@ write_one_data (const struct gcov_info *gi_ptr,
static void
dump_one_gcov (struct gcov_info *gi_ptr, struct gcov_filename *gf,
unsigned run_counted ATTRIBUTE_UNUSED,
- gcov_type run_max ATTRIBUTE_UNUSED)
+ gcov_type run_max ATTRIBUTE_UNUSED, int mode)
{
struct gcov_summary summary = {};
int error;
gcov_unsigned_t tag;
fn_buffer = 0;
- error = gcov_exit_open_gcda_file (gi_ptr, gf);
+ error = gcov_exit_open_gcda_file (gi_ptr, gf, mode);
if (error == -1)
return;
@@ -649,13 +649,13 @@ read_fatal:;
/* Dump all the coverage counts for the program. It first computes program
summary and then traverses gcov_list list and dumps the gcov_info
- objects one by one. */
+ objects one by one. Use MODE to open files. */
#if !IN_GCOV_TOOL
static
#endif
void
-gcov_do_dump (struct gcov_info *list, int run_counted)
+gcov_do_dump (struct gcov_info *list, int run_counted, int mode)
{
struct gcov_info *gi_ptr;
struct gcov_filename gf;
@@ -678,7 +678,7 @@ gcov_do_dump (struct gcov_info *list, int run_counted)
/* Now merge each file. */
for (gi_ptr = list; gi_ptr; gi_ptr = gi_ptr->next)
{
- dump_one_gcov (gi_ptr, &gf, run_counted, run_max);
+ dump_one_gcov (gi_ptr, &gf, run_counted, run_max, mode);
free (gf.filename);
}
@@ -701,7 +701,7 @@ __gcov_dump_one (struct gcov_root *root)
if (root->dumped)
return;
- gcov_do_dump (root->list, root->run_counted);
+ gcov_do_dump (root->list, root->run_counted, 0);
root->dumped = 1;
root->run_counted = 1;