1 /* Routines required for instrumenting a program. */
2 /* Compile this one with gcc. */
3 /* Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
4 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009, 2010, 2011
5 Free Software Foundation, Inc.
7 This file is part of GCC.
9 GCC is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License as published by the Free
11 Software Foundation; either version 3, or (at your option) any later
14 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 Under Section 7 of GPL version 3, you are granted additional
20 permissions described in the GCC Runtime Library Exception, version
21 3.1, as published by the Free Software Foundation.
23 You should have received a copy of the GNU General Public License and
24 a copy of the GCC Runtime Library Exception along with this program;
25 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
26 <http://www.gnu.org/licenses/>. */
30 #include "coretypes.h"
32 #include "libgcc_tm.h"
34 #if defined(inhibit_libc)
35 #define IN_LIBGCOV (-1)
37 #undef NULL /* Avoid errors if stdio.h and our stddef.h mismatch. */
41 #define GCOV_LINKAGE /* nothing */
46 #if defined(inhibit_libc)
47 /* If libc and its header files are not available, provide dummy functions. */
50 void __gcov_init (struct gcov_info *p __attribute__ ((unused))) {}
51 void __gcov_flush (void) {}
54 #ifdef L_gcov_merge_add
55 void __gcov_merge_add (gcov_type *counters __attribute__ ((unused)),
56 unsigned n_counters __attribute__ ((unused))) {}
59 #ifdef L_gcov_merge_single
60 void __gcov_merge_single (gcov_type *counters __attribute__ ((unused)),
61 unsigned n_counters __attribute__ ((unused))) {}
64 #ifdef L_gcov_merge_delta
65 void __gcov_merge_delta (gcov_type *counters __attribute__ ((unused)),
66 unsigned n_counters __attribute__ ((unused))) {}
81 /* Chain of per-object gcov structures. */
82 static struct gcov_info *gcov_list;
84 /* A program checksum allows us to distinguish program data for an
85 object file included in multiple programs. */
86 static gcov_unsigned_t gcov_crc32;
88 /* Size of the longest file name. */
89 static size_t gcov_max_filename = 0;
91 /* Make sure path component of the given FILENAME exists, create
92 missing directories. FILENAME must be writable.
93 Returns zero on success, or -1 if an error occurred. */
96 create_file_directory (char *filename)
98 #if !defined(TARGET_POSIX_IO) && !defined(_WIN32)
106 if (HAS_DRIVE_SPEC(s))
108 if (IS_DIR_SEPARATOR(*s))
110 for (; *s != '\0'; s++)
111 if (IS_DIR_SEPARATOR(*s))
116 /* Try to make directory if it doesn't already exist. */
117 if (access (filename, F_OK) == -1
118 #ifdef TARGET_POSIX_IO
119 && mkdir (filename, 0755) == -1
121 && mkdir (filename) == -1
123 /* The directory might have been made by another process. */
126 fprintf (stderr, "profiling:%s:Cannot create directory\n",
138 /* Check if VERSION of the info block PTR matches libgcov one.
139 Return 1 on success, or zero in case of versions mismatch.
140 If FILENAME is not NULL, its value used for reporting purposes
141 instead of value from the info block. */
144 gcov_version (struct gcov_info *ptr, gcov_unsigned_t version,
145 const char *filename)
147 if (version != GCOV_VERSION)
151 GCOV_UNSIGNED2STRING (v, version);
152 GCOV_UNSIGNED2STRING (e, GCOV_VERSION);
155 "profiling:%s:Version mismatch - expected %.4s got %.4s\n",
156 filename? filename : ptr->filename, e, v);
162 /* Dump the coverage counts. We merge with existing counts when
163 possible, to avoid growing the .da files ad infinitum. We use this
164 program's checksum to make sure we only accumulate whole program
165 statistics to the correct summary. An object file might be embedded
166 in two separate programs, and we must keep the two program
167 summaries separate. */
172 struct gcov_info *gi_ptr;
173 struct gcov_summary this_program;
174 struct gcov_summary all;
175 struct gcov_ctr_summary *cs_ptr;
176 const struct gcov_ctr_info *ci_ptr;
178 gcov_unsigned_t c_num;
179 const char *gcov_prefix;
180 int gcov_prefix_strip = 0;
181 size_t prefix_length;
182 char *gi_filename, *gi_filename_up;
184 memset (&all, 0, sizeof (all));
185 /* Find the totals for this execution. */
186 memset (&this_program, 0, sizeof (this_program));
187 for (gi_ptr = gcov_list; gi_ptr; gi_ptr = gi_ptr->next)
189 ci_ptr = gi_ptr->counts;
190 for (t_ix = 0; t_ix < GCOV_COUNTERS_SUMMABLE; t_ix++)
192 if (!((1 << t_ix) & gi_ptr->ctr_mask))
195 cs_ptr = &this_program.ctrs[t_ix];
196 cs_ptr->num += ci_ptr->num;
197 for (c_num = 0; c_num < ci_ptr->num; c_num++)
199 cs_ptr->sum_all += ci_ptr->values[c_num];
200 if (cs_ptr->run_max < ci_ptr->values[c_num])
201 cs_ptr->run_max = ci_ptr->values[c_num];
208 /* Check if the level of dirs to strip off specified. */
209 char *tmp = getenv("GCOV_PREFIX_STRIP");
212 gcov_prefix_strip = atoi (tmp);
213 /* Do not consider negative values. */
214 if (gcov_prefix_strip < 0)
215 gcov_prefix_strip = 0;
218 /* Get file name relocation prefix. Non-absolute values are ignored. */
219 gcov_prefix = getenv("GCOV_PREFIX");
222 prefix_length = strlen(gcov_prefix);
224 /* Remove an unnecessary trailing '/' */
225 if (IS_DIR_SEPARATOR (gcov_prefix[prefix_length - 1]))
231 /* If no prefix was specified and a prefix stip, then we assume
233 if (gcov_prefix_strip != 0 && prefix_length == 0)
238 /* Allocate and initialize the filename scratch space plus one. */
239 gi_filename = (char *) alloca (prefix_length + gcov_max_filename + 2);
241 memcpy (gi_filename, gcov_prefix, prefix_length);
242 gi_filename_up = gi_filename + prefix_length;
244 /* Now merge each file. */
245 for (gi_ptr = gcov_list; gi_ptr; gi_ptr = gi_ptr->next)
247 struct gcov_summary this_object;
248 struct gcov_summary object, program;
249 gcov_type *values[GCOV_COUNTERS];
250 const struct gcov_fn_info *fi_ptr;
252 unsigned c_ix, f_ix, n_counts;
253 struct gcov_ctr_summary *cs_obj, *cs_tobj, *cs_prg, *cs_tprg, *cs_all;
255 gcov_unsigned_t tag, length;
256 gcov_position_t summary_pos = 0;
257 gcov_position_t eof_pos = 0;
258 const char *fname, *s;
260 fname = gi_ptr->filename;
262 memset (&this_object, 0, sizeof (this_object));
263 memset (&object, 0, sizeof (object));
265 /* Avoid to add multiple drive letters into combined path. */
266 if (prefix_length != 0 && HAS_DRIVE_SPEC(fname))
269 /* Build relocated filename, stripping off leading
270 directories from the initial filename if requested. */
271 if (gcov_prefix_strip > 0)
275 if (IS_DIR_SEPARATOR(*s))
278 /* Skip selected directory levels. */
279 for (; (*s != '\0') && (level < gcov_prefix_strip); s++)
280 if (IS_DIR_SEPARATOR(*s))
286 /* Update complete filename with stripped original. */
287 if (prefix_length != 0 && !IS_DIR_SEPARATOR (*fname))
289 /* If prefix is given, add directory separator. */
290 strcpy (gi_filename_up, "/");
291 strcpy (gi_filename_up + 1, fname);
294 strcpy (gi_filename_up, fname);
296 /* Totals for this object file. */
297 ci_ptr = gi_ptr->counts;
298 for (t_ix = 0; t_ix < GCOV_COUNTERS_SUMMABLE; t_ix++)
300 if (!((1 << t_ix) & gi_ptr->ctr_mask))
303 cs_ptr = &this_object.ctrs[t_ix];
304 cs_ptr->num += ci_ptr->num;
305 for (c_num = 0; c_num < ci_ptr->num; c_num++)
307 cs_ptr->sum_all += ci_ptr->values[c_num];
308 if (cs_ptr->run_max < ci_ptr->values[c_num])
309 cs_ptr->run_max = ci_ptr->values[c_num];
316 for (t_ix = 0; t_ix < GCOV_COUNTERS; t_ix++)
317 if ((1 << t_ix) & gi_ptr->ctr_mask)
319 values[c_ix] = gi_ptr->counts[c_ix].values;
323 /* Calculate the function_info stride. This depends on the
324 number of counter types being measured. */
325 fi_stride = sizeof (struct gcov_fn_info) + c_ix * sizeof (unsigned);
326 if (__alignof__ (struct gcov_fn_info) > sizeof (unsigned))
328 fi_stride += __alignof__ (struct gcov_fn_info) - 1;
329 fi_stride &= ~(__alignof__ (struct gcov_fn_info) - 1);
332 if (!gcov_open (gi_filename))
334 /* Open failed likely due to missed directory.
335 Create directory and retry to open file. */
336 if (create_file_directory (gi_filename))
338 fprintf (stderr, "profiling:%s:Skip\n", gi_filename);
341 if (!gcov_open (gi_filename))
343 fprintf (stderr, "profiling:%s:Cannot open\n", gi_filename);
348 tag = gcov_read_unsigned ();
351 /* Merge data from file. */
352 if (tag != GCOV_DATA_MAGIC)
354 fprintf (stderr, "profiling:%s:Not a gcov data file\n",
358 length = gcov_read_unsigned ();
359 if (!gcov_version (gi_ptr, length, gi_filename))
362 length = gcov_read_unsigned ();
363 if (length != gi_ptr->stamp)
364 /* Read from a different compilation. Overwrite the file. */
367 /* Merge execution counts for each function. */
368 for (f_ix = 0; f_ix < gi_ptr->n_functions; f_ix++)
370 fi_ptr = (const struct gcov_fn_info *)
371 ((const char *) gi_ptr->functions + f_ix * fi_stride);
372 tag = gcov_read_unsigned ();
373 length = gcov_read_unsigned ();
375 /* Check function. */
376 if (tag != GCOV_TAG_FUNCTION
377 || length != GCOV_TAG_FUNCTION_LENGTH
378 || gcov_read_unsigned () != fi_ptr->ident
379 || gcov_read_unsigned () != fi_ptr->lineno_checksum
380 || gcov_read_unsigned () != fi_ptr->cfg_checksum)
383 fprintf (stderr, "profiling:%s:Merge mismatch for %s\n",
385 f_ix + 1 ? "function" : "summaries");
390 for (t_ix = 0; t_ix < GCOV_COUNTERS; t_ix++)
394 if (!((1 << t_ix) & gi_ptr->ctr_mask))
397 n_counts = fi_ptr->n_ctrs[c_ix];
398 merge = gi_ptr->counts[c_ix].merge;
400 tag = gcov_read_unsigned ();
401 length = gcov_read_unsigned ();
402 if (tag != GCOV_TAG_FOR_COUNTER (t_ix)
403 || length != GCOV_TAG_COUNTER_LENGTH (n_counts))
405 (*merge) (values[c_ix], n_counts);
406 values[c_ix] += n_counts;
409 if ((error = gcov_is_error ()))
414 /* Check program & object summary */
419 eof_pos = gcov_position ();
420 tag = gcov_read_unsigned ();
424 length = gcov_read_unsigned ();
425 is_program = tag == GCOV_TAG_PROGRAM_SUMMARY;
426 if (length != GCOV_TAG_SUMMARY_LENGTH
427 || (!is_program && tag != GCOV_TAG_OBJECT_SUMMARY))
429 gcov_read_summary (is_program ? &program : &object);
430 if ((error = gcov_is_error ()))
432 if (is_program && program.checksum == gcov_crc32)
434 summary_pos = eof_pos;
442 fprintf (stderr, error < 0 ? "profiling:%s:Overflow merging\n"
443 : "profiling:%s:Error merging\n", gi_filename);
452 memset (&program, 0, sizeof (program));
454 /* Merge the summaries. */
456 for (t_ix = 0; t_ix < GCOV_COUNTERS_SUMMABLE; t_ix++)
458 cs_obj = &object.ctrs[t_ix];
459 cs_tobj = &this_object.ctrs[t_ix];
460 cs_prg = &program.ctrs[t_ix];
461 cs_tprg = &this_program.ctrs[t_ix];
462 cs_all = &all.ctrs[t_ix];
464 if ((1 << t_ix) & gi_ptr->ctr_mask)
467 cs_obj->num = cs_tobj->num;
468 else if (cs_obj->num != cs_tobj->num)
470 cs_obj->sum_all += cs_tobj->sum_all;
471 if (cs_obj->run_max < cs_tobj->run_max)
472 cs_obj->run_max = cs_tobj->run_max;
473 cs_obj->sum_max += cs_tobj->run_max;
476 cs_prg->num = cs_tprg->num;
477 else if (cs_prg->num != cs_tprg->num)
479 cs_prg->sum_all += cs_tprg->sum_all;
480 if (cs_prg->run_max < cs_tprg->run_max)
481 cs_prg->run_max = cs_tprg->run_max;
482 cs_prg->sum_max += cs_tprg->run_max;
484 else if (cs_obj->num || cs_prg->num)
487 if (!cs_all->runs && cs_prg->runs)
488 memcpy (cs_all, cs_prg, sizeof (*cs_all));
489 else if (!all.checksum
490 && (!GCOV_LOCKED || cs_all->runs == cs_prg->runs)
491 && memcmp (cs_all, cs_prg, sizeof (*cs_all)))
493 fprintf (stderr, "profiling:%s:Invocation mismatch - some data files may have been removed%s",
494 gi_filename, GCOV_LOCKED
495 ? "" : " or concurrent update without locking support");
501 for (t_ix = 0; t_ix < GCOV_COUNTERS; t_ix++)
502 if ((1 << t_ix) & gi_ptr->ctr_mask)
504 values[c_ix] = gi_ptr->counts[c_ix].values;
508 program.checksum = gcov_crc32;
510 /* Write out the data. */
511 gcov_write_tag_length (GCOV_DATA_MAGIC, GCOV_VERSION);
512 gcov_write_unsigned (gi_ptr->stamp);
514 /* Write execution counts for each function. */
515 for (f_ix = 0; f_ix < gi_ptr->n_functions; f_ix++)
517 fi_ptr = (const struct gcov_fn_info *)
518 ((const char *) gi_ptr->functions + f_ix * fi_stride);
520 /* Announce function. */
521 gcov_write_tag_length (GCOV_TAG_FUNCTION, GCOV_TAG_FUNCTION_LENGTH);
522 gcov_write_unsigned (fi_ptr->ident);
523 gcov_write_unsigned (fi_ptr->lineno_checksum);
524 gcov_write_unsigned (fi_ptr->cfg_checksum);
527 for (t_ix = 0; t_ix < GCOV_COUNTERS; t_ix++)
531 if (!((1 << t_ix) & gi_ptr->ctr_mask))
534 n_counts = fi_ptr->n_ctrs[c_ix];
536 gcov_write_tag_length (GCOV_TAG_FOR_COUNTER (t_ix),
537 GCOV_TAG_COUNTER_LENGTH (n_counts));
538 c_ptr = values[c_ix];
540 gcov_write_counter (*c_ptr++);
542 values[c_ix] = c_ptr;
547 /* Object file summary. */
548 gcov_write_summary (GCOV_TAG_OBJECT_SUMMARY, &object);
550 /* Generate whole program statistics. */
553 gcov_write_summary (GCOV_TAG_PROGRAM_SUMMARY, &program);
555 gcov_write_unsigned (0);
556 if ((error = gcov_close ()))
557 fprintf (stderr, error < 0 ?
558 "profiling:%s:Overflow writing\n" :
559 "profiling:%s:Error writing\n",
564 /* Add a new object file onto the bb chain. Invoked automatically
565 when running an object file's global ctors. */
568 __gcov_init (struct gcov_info *info)
572 if (gcov_version (info, info->version, 0))
574 const char *ptr = info->filename;
575 gcov_unsigned_t crc32 = gcov_crc32;
576 size_t filename_length = strlen(info->filename);
578 /* Refresh the longest file name information */
579 if (filename_length > gcov_max_filename)
580 gcov_max_filename = filename_length;
585 gcov_unsigned_t value = *ptr << 24;
587 for (ix = 8; ix--; value <<= 1)
589 gcov_unsigned_t feedback;
591 feedback = (value ^ crc32) & 0x80000000 ? 0x04c11db7 : 0;
603 info->next = gcov_list;
609 /* Called before fork or exec - write out profile information gathered so
610 far and reset it to zero. This avoids duplication or loss of the
611 profile information gathered so far. */
616 const struct gcov_info *gi_ptr;
619 for (gi_ptr = gcov_list; gi_ptr; gi_ptr = gi_ptr->next)
622 const struct gcov_ctr_info *ci_ptr;
624 for (t_ix = 0, ci_ptr = gi_ptr->counts; t_ix != GCOV_COUNTERS; t_ix++)
625 if ((1 << t_ix) & gi_ptr->ctr_mask)
627 memset (ci_ptr->values, 0, sizeof (gcov_type) * ci_ptr->num);
635 #ifdef L_gcov_merge_add
636 /* The profile merging function that just adds the counters. It is given
637 an array COUNTERS of N_COUNTERS old counters and it reads the same number
638 of counters from the gcov file. */
640 __gcov_merge_add (gcov_type *counters, unsigned n_counters)
642 for (; n_counters; counters++, n_counters--)
643 *counters += gcov_read_counter ();
645 #endif /* L_gcov_merge_add */
647 #ifdef L_gcov_merge_ior
648 /* The profile merging function that just adds the counters. It is given
649 an array COUNTERS of N_COUNTERS old counters and it reads the same number
650 of counters from the gcov file. */
652 __gcov_merge_ior (gcov_type *counters, unsigned n_counters)
654 for (; n_counters; counters++, n_counters--)
655 *counters |= gcov_read_counter ();
659 #ifdef L_gcov_merge_single
660 /* The profile merging function for choosing the most common value.
661 It is given an array COUNTERS of N_COUNTERS old counters and it
662 reads the same number of counters from the gcov file. The counters
663 are split into 3-tuples where the members of the tuple have
666 -- the stored candidate on the most common value of the measured entity
668 -- total number of evaluations of the value */
670 __gcov_merge_single (gcov_type *counters, unsigned n_counters)
672 unsigned i, n_measures;
673 gcov_type value, counter, all;
675 gcc_assert (!(n_counters % 3));
676 n_measures = n_counters / 3;
677 for (i = 0; i < n_measures; i++, counters += 3)
679 value = gcov_read_counter ();
680 counter = gcov_read_counter ();
681 all = gcov_read_counter ();
683 if (counters[0] == value)
684 counters[1] += counter;
685 else if (counter > counters[1])
688 counters[1] = counter - counters[1];
691 counters[1] -= counter;
695 #endif /* L_gcov_merge_single */
697 #ifdef L_gcov_merge_delta
698 /* The profile merging function for choosing the most common
699 difference between two consecutive evaluations of the value. It is
700 given an array COUNTERS of N_COUNTERS old counters and it reads the
701 same number of counters from the gcov file. The counters are split
702 into 4-tuples where the members of the tuple have meanings:
704 -- the last value of the measured entity
705 -- the stored candidate on the most common difference
707 -- total number of evaluations of the value */
709 __gcov_merge_delta (gcov_type *counters, unsigned n_counters)
711 unsigned i, n_measures;
712 gcov_type value, counter, all;
714 gcc_assert (!(n_counters % 4));
715 n_measures = n_counters / 4;
716 for (i = 0; i < n_measures; i++, counters += 4)
718 /* last = */ gcov_read_counter ();
719 value = gcov_read_counter ();
720 counter = gcov_read_counter ();
721 all = gcov_read_counter ();
723 if (counters[1] == value)
724 counters[2] += counter;
725 else if (counter > counters[2])
728 counters[2] = counter - counters[2];
731 counters[2] -= counter;
735 #endif /* L_gcov_merge_delta */
737 #ifdef L_gcov_interval_profiler
738 /* If VALUE is in interval <START, START + STEPS - 1>, then increases the
739 corresponding counter in COUNTERS. If the VALUE is above or below
740 the interval, COUNTERS[STEPS] or COUNTERS[STEPS + 1] is increased
744 __gcov_interval_profiler (gcov_type *counters, gcov_type value,
745 int start, unsigned steps)
747 gcov_type delta = value - start;
749 counters[steps + 1]++;
750 else if (delta >= steps)
757 #ifdef L_gcov_pow2_profiler
758 /* If VALUE is a power of two, COUNTERS[1] is incremented. Otherwise
759 COUNTERS[0] is incremented. */
762 __gcov_pow2_profiler (gcov_type *counters, gcov_type value)
764 if (value & (value - 1))
771 /* Tries to determine the most common value among its inputs. Checks if the
772 value stored in COUNTERS[0] matches VALUE. If this is the case, COUNTERS[1]
773 is incremented. If this is not the case and COUNTERS[1] is not zero,
774 COUNTERS[1] is decremented. Otherwise COUNTERS[1] is set to one and
775 VALUE is stored to COUNTERS[0]. This algorithm guarantees that if this
776 function is called more than 50% of the time with one value, this value
777 will be in COUNTERS[0] in the end.
779 In any case, COUNTERS[2] is incremented. */
782 __gcov_one_value_profiler_body (gcov_type *counters, gcov_type value)
784 if (value == counters[0])
786 else if (counters[1] == 0)
796 #ifdef L_gcov_one_value_profiler
798 __gcov_one_value_profiler (gcov_type *counters, gcov_type value)
800 __gcov_one_value_profiler_body (counters, value);
804 #ifdef L_gcov_indirect_call_profiler
806 /* By default, the C++ compiler will use function addresses in the
807 vtable entries. Setting TARGET_VTABLE_USES_DESCRIPTORS to nonzero
808 tells the compiler to use function descriptors instead. The value
809 of this macro says how many words wide the descriptor is (normally 2),
810 but it may be dependent on target flags. Since we do not have access
811 to the target flags here we just check to see if it is set and use
812 that to set VTABLE_USES_DESCRIPTORS to 0 or 1.
814 It is assumed that the address of a function descriptor may be treated
815 as a pointer to a function. */
817 #ifdef TARGET_VTABLE_USES_DESCRIPTORS
818 #define VTABLE_USES_DESCRIPTORS 1
820 #define VTABLE_USES_DESCRIPTORS 0
823 /* Tries to determine the most common value among its inputs. */
825 __gcov_indirect_call_profiler (gcov_type* counter, gcov_type value,
826 void* cur_func, void* callee_func)
828 /* If the C++ virtual tables contain function descriptors then one
829 function may have multiple descriptors and we need to dereference
830 the descriptors to see if they point to the same function. */
831 if (cur_func == callee_func
832 || (VTABLE_USES_DESCRIPTORS && callee_func
833 && *(void **) cur_func == *(void **) callee_func))
834 __gcov_one_value_profiler_body (counter, value);
839 #ifdef L_gcov_average_profiler
840 /* Increase corresponding COUNTER by VALUE. FIXME: Perhaps we want
844 __gcov_average_profiler (gcov_type *counters, gcov_type value)
846 counters[0] += value;
851 #ifdef L_gcov_ior_profiler
852 /* Increase corresponding COUNTER by VALUE. FIXME: Perhaps we want
856 __gcov_ior_profiler (gcov_type *counters, gcov_type value)
863 /* A wrapper for the fork function. Flushes the accumulated profiling data, so
864 that they are not counted twice. */
875 /* A wrapper for the execl function. Flushes the accumulated profiling data, so
876 that they are not lost. */
879 __gcov_execl (const char *path, char *arg, ...)
891 while (va_arg (ap, char *))
895 args = (char **) alloca (length * sizeof (void *));
897 for (i = 1; i < length; i++)
898 args[i] = va_arg (aq, char *);
901 return execv (path, args);
906 /* A wrapper for the execlp function. Flushes the accumulated profiling data, so
907 that they are not lost. */
910 __gcov_execlp (const char *path, char *arg, ...)
922 while (va_arg (ap, char *))
926 args = (char **) alloca (length * sizeof (void *));
928 for (i = 1; i < length; i++)
929 args[i] = va_arg (aq, char *);
932 return execvp (path, args);
937 /* A wrapper for the execle function. Flushes the accumulated profiling data, so
938 that they are not lost. */
941 __gcov_execle (const char *path, char *arg, ...)
954 while (va_arg (ap, char *))
958 args = (char **) alloca (length * sizeof (void *));
960 for (i = 1; i < length; i++)
961 args[i] = va_arg (aq, char *);
962 envp = va_arg (aq, char **);
965 return execve (path, args, envp);
970 /* A wrapper for the execv function. Flushes the accumulated profiling data, so
971 that they are not lost. */
974 __gcov_execv (const char *path, char *const argv[])
977 return execv (path, argv);
982 /* A wrapper for the execvp function. Flushes the accumulated profiling data, so
983 that they are not lost. */
986 __gcov_execvp (const char *path, char *const argv[])
989 return execvp (path, argv);
994 /* A wrapper for the execve function. Flushes the accumulated profiling data, so
995 that they are not lost. */
998 __gcov_execve (const char *path, char *const argv[], char *const envp[])
1001 return execve (path, argv, envp);
1004 #endif /* inhibit_libc */