diff mbox

gcov name cleanup

Message ID 53D0AB85.8010603@acm.org
State New
Headers show

Commit Message

Nathan Sidwell July 24, 2014, 6:45 a.m. UTC
This second patch cleans up some more global names.  the three functions should 
not be visible to the user.  I'm not sure if they're attempting to export an 
interface to the user but they're (a) undocumented and (b) don't follow existing 
gcov naming.

I'm a little confused as to why the gcov library was split into libgcov-driver 
and libgcov-interface, as each subsection's protected by an appropriate 
L_<SYMBOL> #ifdef, this appears to serve no purpose.

I have another cleanup coming, and then I'll consider David's patch -- I can see 
how to do what it wants without adding another interface (hurrah!)

nathan
2014-07-24  Nathan Sidwell  <nathan@acm.org>

	* libgcov-driver.c (set_gcov_dump_complete,
	reset_gcov_dump_complete, get_gcov_dump_complete): Remove global
	functions polluting user's namespace.
	(gcov_exit): Set variable directly.
	(gcov_clear): Reset variable directly.
	* libgcov-interface.c (get_gcov_dymp_complete,
	reset_gov_dump_complete): Remove declarations.
	(__gcov_reset, __gcov_dump): Don't call them.

Comments

Xinliang David Li July 24, 2014, 7:12 a.m. UTC | #1
On Wed, Jul 23, 2014 at 11:45 PM, Nathan Sidwell <nathan@acm.org> wrote:
> This second patch cleans up some more global names.  the three functions
> should not be visible to the user.  I'm not sure if they're attempting to
> export an interface to the user but they're (a) undocumented and (b) don't
> follow existing gcov naming.
>
> I'm a little confused as to why the gcov library was split into
> libgcov-driver and libgcov-interface, as each subsection's protected by an
> appropriate L_<SYMBOL> #ifdef, this appears to serve no purpose.
>

libgcov-interfaces.c define public APIs which user can invoke
programmatically in their program. One example use case is through
http handlers for server programs.  On the other hand,
liggcov-driver.c defines internal functions and actual implementations

Before the refactoring, libgcov.c was huge and hard to read/maintain.

> I have another cleanup coming, and then I'll consider David's patch -- I can
> see how to do what it wants without adding another interface (hurrah!)

Ok. For cleanup code, Teresa can help with review.

thanks,

David
>
> nathan
diff mbox

Patch

Index: libgcc/libgcov-driver.c
===================================================================
--- libgcc/libgcov-driver.c	(revision 212942)
+++ libgcc/libgcov-driver.c	(working copy)
@@ -51,9 +51,6 @@  static int gcov_error (const char *, ...
 /* The following functions can be called from outside of this file.  */
 extern void gcov_clear (void) ATTRIBUTE_HIDDEN;
 extern void gcov_exit (void) ATTRIBUTE_HIDDEN;
-extern void set_gcov_dump_complete (void) ATTRIBUTE_HIDDEN;
-extern void reset_gcov_dump_complete (void) ATTRIBUTE_HIDDEN;
-extern int get_gcov_dump_complete (void) ATTRIBUTE_HIDDEN;
 
 struct gcov_fn_buffer
 {
@@ -86,32 +83,6 @@  size_t gcov_max_filename = 0;
 /* Flag when the profile has already been dumped via __gcov_dump().  */
 static int gcov_dump_complete;
 
-/* A global function that get the vaule of gcov_dump_complete.  */
-
-int
-get_gcov_dump_complete (void)
-{
-  return gcov_dump_complete;
-}
-
-/* A global functino that set the vaule of gcov_dump_complete. Will
-   be used in __gcov_dump() in libgcov-interface.c.  */
-
-void
-set_gcov_dump_complete (void)
-{
-  gcov_dump_complete = 1;
-}
-
-/* A global functino that set the vaule of gcov_dump_complete. Will
-   be used in __gcov_reset() in libgcov-interface.c.  */
-
-void
-reset_gcov_dump_complete (void)
-{
-  gcov_dump_complete = 0;
-}
-
 static struct gcov_fn_buffer *
 free_fn_data (const struct gcov_info *gi_ptr, struct gcov_fn_buffer *buffer,
               unsigned limit)
@@ -795,6 +766,8 @@  gcov_exit (void)
   if (gcov_dump_complete)
     return;
 
+  gcov_dump_complete = 1;
+  
   crc32 = gcov_exit_compute_summary (&this_prg);
 
   allocate_filename_struct (&gf);
@@ -818,6 +791,7 @@  gcov_clear (void)
 {
   const struct gcov_info *gi_ptr;
 
+  gcov_dump_complete = 0;
   for (gi_ptr = gcov_list; gi_ptr; gi_ptr = gi_ptr->next)
     {
       unsigned f_ix;
Index: libgcc/libgcov-interface.c
===================================================================
--- libgcc/libgcov-interface.c	(revision 212942)
+++ libgcc/libgcov-interface.c	(working copy)
@@ -44,8 +44,6 @@  void __gcov_dump (void) {}
 
 extern void gcov_clear (void) ATTRIBUTE_HIDDEN;
 extern void gcov_exit (void) ATTRIBUTE_HIDDEN;
-extern void set_gcov_dump_complete (void) ATTRIBUTE_HIDDEN;
-extern void reset_gcov_dump_complete (void) ATTRIBUTE_HIDDEN;
 
 #ifdef L_gcov_flush
 
@@ -95,9 +93,6 @@  void
 __gcov_reset (void)
 {
   gcov_clear ();
-  /* Re-enable dumping to support collecting profile in multiple regions
-     of interest.  */
-  reset_gcov_dump_complete ();
 }
 
 #endif /* L_gcov_reset */
@@ -111,8 +106,6 @@  void
 __gcov_dump (void)
 {
   gcov_exit ();
-  /* Prevent profile from being dumped a second time on application exit.  */
-  set_gcov_dump_complete ();
 }
 
 #endif /* L_gcov_dump */