From: Sebastian Huber <sebastian.huber@embedded-brains.de>
To: gcc-patches@gcc.gnu.org
Subject: [RFC/gcov 03/12] gcov: Add open mode parameter to gcov_do_dump()
Date: Thu, 31 Mar 2022 13:35:06 +0200 [thread overview]
Message-ID: <20220331113515.35764-4-sebastian.huber@embedded-brains.de> (raw)
In-Reply-To: <20220331113515.35764-1-sebastian.huber@embedded-brains.de>
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.
---
gcc/gcov-tool.cc | 4 ++--
libgcc/libgcov-driver-system.c | 7 ++++---
libgcc/libgcov-driver.c | 12 ++++++------
3 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/gcc/gcov-tool.cc b/gcc/gcov-tool.cc
index 2e4083a664d..d712715cf7e 100644
--- a/gcc/gcov-tool.cc
+++ b/gcc/gcov-tool.cc
@@ -46,7 +46,7 @@ extern int gcov_profile_overlap (struct gcov_info*, struct gcov_info*);
extern int gcov_profile_normalize (struct gcov_info*, gcov_type);
extern int gcov_profile_scale (struct gcov_info*, float, int, int);
extern struct gcov_info* gcov_read_profile_dir (const char*, int);
-extern void gcov_do_dump (struct gcov_info *, int);
+extern void gcov_do_dump (struct gcov_info *, int, int);
extern const char *gcov_get_filename (struct gcov_info *list);
extern void gcov_set_verbose (void);
@@ -124,7 +124,7 @@ gcov_output_files (const char *out, struct gcov_info *profile)
fatal_error (input_location, "output file %s already exists in folder %s",
filename, out);
- gcov_do_dump (profile, 0);
+ gcov_do_dump (profile, 0, 0);
ret = chdir (pwd);
if (ret)
diff --git a/libgcc/libgcov-driver-system.c b/libgcc/libgcov-driver-system.c
index 9abb2fe7f74..ac405c38e3a 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 7e52c5676e5..10831e84b61 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;
--
2.34.1
next prev parent reply other threads:[~2022-03-31 11:35 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-31 11:35 [RFC/gcov 00/12] Add merge-stream subcommand to gcov-tool Sebastian Huber
2022-03-31 11:35 ` [RFC/gcov 01/12] gcov-tool: Allow merging of empty profile lists Sebastian Huber
2022-03-31 11:35 ` [RFC/gcov 02/12] gcov: Add mode to all gcov_open() Sebastian Huber
2022-03-31 11:35 ` Sebastian Huber [this message]
2022-03-31 11:35 ` [RFC/gcov 04/12] gcov: Make gcov_seek() static Sebastian Huber
2022-03-31 11:35 ` [RFC/gcov 05/12] gcov: Add __gcov_filename_to_gcfn() Sebastian Huber
2022-03-31 11:35 ` [RFC/gcov 06/12] gcov-tool: Support file input from stdin Sebastian Huber
2022-04-07 8:32 ` Martin Liška
2022-03-31 11:35 ` [RFC/gcov 07/12] gcov: Use xstrdup() Sebastian Huber
2022-03-31 11:35 ` [RFC/gcov 08/12] gcov: Move prepend to list to read_gcda_file() Sebastian Huber
2022-04-07 8:33 ` Martin Liška
2022-03-31 11:35 ` [RFC/gcov 09/12] gcov: Move gcov_open() to caller of read_gcda_file() Sebastian Huber
2022-03-31 11:35 ` [RFC/gcov 10/12] gcov: Fix integer types in ftw_read_file() Sebastian Huber
2022-03-31 11:35 ` [RFC/gcov 11/12] gcov: Record EOF error during read Sebastian Huber
2022-04-07 8:34 ` Martin Liška
2022-03-31 11:35 ` [RFC/gcov 12/12] gcov-tool: Add merge-stream subcommand Sebastian Huber
2022-04-07 8:36 ` Martin Liška
2022-04-07 8:38 ` [RFC/gcov 00/12] Add merge-stream subcommand to gcov-tool Martin Liška
2022-04-07 9:05 ` Sebastian Huber
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=20220331113515.35764-4-sebastian.huber@embedded-brains.de \
--to=sebastian.huber@embedded-brains.de \
--cc=gcc-patches@gcc.gnu.org \
/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).