aboutsummaryrefslogtreecommitdiff
path: root/libgcc/libgcov-driver.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2022-03-30 21:45:23 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2022-04-28 20:46:49 +0200
commit39d80300b3c769c3a7805a46ee5facc6adf1a4d0 (patch)
tree2c8609ca844a90b8006e39f11c2735a91fe73dff /libgcc/libgcov-driver.c
parent68a4673fe25e067df74373a45180d80c70da102f (diff)
downloadgcc-39d80300b3c769c3a7805a46ee5facc6adf1a4d0.zip
gcc-39d80300b3c769c3a7805a46ee5facc6adf1a4d0.tar.gz
gcc-39d80300b3c769c3a7805a46ee5facc6adf1a4d0.tar.bz2
gcov: Add __gcov_filename_to_gcfn()
gcc/ * doc/invoke.texi (fprofile-info-section): Mention __gcov_filename_to_gcfn(). Use "freestanding" to match with C11 standard language. Fix minor example code issues. * gcov-io.h (GCOV_FILENAME_MAGIC): Define and document. gcc/testsuite/ * gcc.dg/gcov-info-to-gcda.c: Test __gcov_filename_to_gcfn(). libgcc/ * gcov.h (__gcov_info_to_gcda): Mention __gcov_filename_to_gcfn(). (__gcov_filename_to_gcfn): Declare and document. * libgcov-driver.c (dump_string): New. (__gcov_filename_to_gcfn): Likewise. (__gcov_info_to_gcda): Adjust comment to match C11 standard language.
Diffstat (limited to 'libgcc/libgcov-driver.c')
-rw-r--r--libgcc/libgcov-driver.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/libgcc/libgcov-driver.c b/libgcc/libgcov-driver.c
index 10831e8..d4517d2 100644
--- a/libgcc/libgcov-driver.c
+++ b/libgcc/libgcov-driver.c
@@ -410,6 +410,23 @@ dump_counter (gcov_type counter,
dump_unsigned (0, dump_fn, arg);
}
+/* Dump the STRING using the DUMP handler called with ARG. */
+
+static inline void
+dump_string (const char *string,
+ void (*dump_fn) (const void *, unsigned, void *),
+ void *arg)
+{
+ unsigned length = 0;
+
+ if (string)
+ length = strlen (string) + 1;
+
+ dump_unsigned (length, dump_fn, arg);
+ if (string)
+ (*dump_fn) (string, length, arg);
+}
+
#define MAX(X,Y) ((X) > (Y) ? (X) : (Y))
/* Store all TOP N counters where each has a dynamic length. */
@@ -768,7 +785,7 @@ __gcov_init (struct gcov_info *info)
#ifdef NEED_L_GCOV_INFO_TO_GCDA
/* Convert the gcov info to a gcda data stream. It is intended for
- free-standing environments which do not support the C library file I/O. */
+ freestanding environments which do not support the C library file I/O. */
void
__gcov_info_to_gcda (const struct gcov_info *gi_ptr,
@@ -780,4 +797,17 @@ __gcov_info_to_gcda (const struct gcov_info *gi_ptr,
(*filename_fn) (gi_ptr->filename, arg);
write_one_data (gi_ptr, NULL, dump_fn, allocate_fn, arg);
}
+
+/* Convert the filename to a gcfn data stream. It is intended for
+ freestanding environments which do not support the C library file I/O. */
+
+void
+__gcov_filename_to_gcfn (const char *filename,
+ void (*dump_fn) (const void *, unsigned, void *),
+ void *arg)
+{
+ dump_unsigned (GCOV_FILENAME_MAGIC, dump_fn, arg);
+ dump_unsigned (GCOV_VERSION, dump_fn, arg);
+ dump_string (filename, dump_fn, arg);
+}
#endif /* NEED_L_GCOV_INFO_TO_GCDA */