This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

a mudflap experiment on freebsd


A customer expressed interest in mudflap, so I tried to see if I could
use it compile something large.  I used gcc itself for this test.  I've
attached my notes, and the patches I wrote as part of this.  I will
probably be able to generate a couple of bug reports and/or patches out
of this.
-- 
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com

Attachment: MUDFLAP_LOG
Description: Text document

diff -pr orig-gcc/fixincludes/Makefile.in gcc/fixincludes/Makefile.in
*** orig-gcc/fixincludes/Makefile.in	Fri Jan  7 19:16:09 2005
--- gcc/fixincludes/Makefile.in	Tue Feb 22 11:01:24 2005
*************** oneprocess : full-stamp
*** 102,116 ****
  twoprocess : test-stamp $(AF)
  
  full-stamp : $(ALLOBJ) $(LIBIBERTY)
! 	$(CC) $(LDFLAGS) -o $(FI) $(ALLOBJ) $(LIBIBERTY)
  	$(STAMP) $@
  
  test-stamp : $(TESTOBJ) $(LIBIBERTY)
! 	$(CC) $(LDFLAGS) -o $(FI) $(TESTOBJ) $(LIBIBERTY)
  	$(STAMP) $@
  
  $(AF): $(FIXOBJ) $(LIBIBERTY)
! 	$(CC) $(LDFLAGS) -o $@ $(FIXOBJ) $(LIBIBERTY)
  
  $(ALLOBJ)   : $(HDR)
  fixincl.o   : fixincl.c  $(srcdir)/fixincl.x
--- 102,116 ----
  twoprocess : test-stamp $(AF)
  
  full-stamp : $(ALLOBJ) $(LIBIBERTY)
! 	$(CC) $(CFLAGS) $(LDFLAGS) -o $(FI) $(ALLOBJ) $(LIBIBERTY)
  	$(STAMP) $@
  
  test-stamp : $(TESTOBJ) $(LIBIBERTY)
! 	$(CC) $(CFLAGS) $(LDFLAGS) -o $(FI) $(TESTOBJ) $(LIBIBERTY)
  	$(STAMP) $@
  
  $(AF): $(FIXOBJ) $(LIBIBERTY)
! 	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(FIXOBJ) $(LIBIBERTY)
  
  $(ALLOBJ)   : $(HDR)
  fixincl.o   : fixincl.c  $(srcdir)/fixincl.x
diff -pr orig-gcc/gcc/gcc.c gcc/gcc/gcc.c
*** orig-gcc/gcc/gcc.c	Sat Feb 19 14:56:21 2005
--- gcc/gcc/gcc.c	Tue Feb 22 10:51:05 2005
*************** proper position among the other output f
*** 612,618 ****
  }} %{fmudflap|fmudflapth: --wrap=main}"
  #endif
  #ifndef MFLIB_SPEC
! #define MFLIB_SPEC "%{fmudflap|fmudflapth: -export-dynamic}" 
  #endif
  
  /* config.h can define LIBGCC_SPEC to override how and when libgcc.a is
--- 612,618 ----
  }} %{fmudflap|fmudflapth: --wrap=main}"
  #endif
  #ifndef MFLIB_SPEC
! #define MFLIB_SPEC "%{fmudflap|fmudflapth: -export-dynamic -lmudflap}"
  #endif
  
  /* config.h can define LIBGCC_SPEC to override how and when libgcc.a is
diff -pr orig-gcc/gcc/gengtype.c gcc/gcc/gengtype.c
*** orig-gcc/gcc/gengtype.c	Mon Jan 24 14:38:27 2005
--- gcc/gcc/gengtype.c	Tue Feb 22 13:13:59 2005
*************** enum insn_note {
*** 367,373 ****
    NOTE_INSN_MAX
  };
  
! static const char *const note_insn_name[NOTE_INSN_MAX] = {
  #define DEF_INSN_NOTE(NAME) #NAME,
  #include "insn-notes.def"
  #undef DEF_INSN_NOTE
--- 367,375 ----
    NOTE_INSN_MAX
  };
  
! /* We must allocate one more entry here, as we use NOTE_INSN_MAX as the
!    default field for line number notes.  */
! static const char *const note_insn_name[NOTE_INSN_MAX+1] = {
  #define DEF_INSN_NOTE(NAME) #NAME,
  #include "insn-notes.def"
  #undef DEF_INSN_NOTE
diff -pr orig-gcc/libmudflap/mf-hooks1.c gcc/libmudflap/mf-hooks1.c
*** orig-gcc/libmudflap/mf-hooks1.c	Tue Jul  6 13:07:39 2004
--- gcc/libmudflap/mf-hooks1.c	Tue Feb 22 13:12:19 2005
*************** __mf_0fn_malloc (size_t c)
*** 85,90 ****
--- 85,92 ----
  #endif
  
  
+ static int in_malloc = 0;
+ 
  #undef malloc
  WRAPPER(void *, malloc, size_t c)
  {
*************** WRAPPER(void *, malloc, size_t c)
*** 96,102 ****
--- 98,106 ----
    size_with_crumple_zones = 
      CLAMPADD(c,CLAMPADD(__mf_opts.crumple_zone,
  			__mf_opts.crumple_zone));
+   in_malloc = 1;
    result = (char *) CALL_REAL (malloc, size_with_crumple_zones);
+   in_malloc = 0;
    
    if (LIKELY(result))
      {
*************** WRAPPER(void *, calloc, size_t c, size_t
*** 147,153 ****
--- 151,159 ----
      CLAMPADD((c * n), /* XXX: CLAMPMUL */
  	     CLAMPADD(__mf_opts.crumple_zone,
  		      __mf_opts.crumple_zone));  
+   in_malloc = 1;
    result = (char *) CALL_REAL (malloc, size_with_crumple_zones);
+   in_malloc = 0;
    
    if (LIKELY(result))
      memset (result, 0, size_with_crumple_zones);
*************** WRAPPER(void *, realloc, void *buf, size
*** 189,195 ****
--- 195,203 ----
    size_with_crumple_zones = 
      CLAMPADD(c, CLAMPADD(__mf_opts.crumple_zone,
  			 __mf_opts.crumple_zone));
+   in_malloc = 1;
    result = (char *) CALL_REAL (realloc, base, size_with_crumple_zones);
+   in_malloc = 0;
  
    /* Ensure heap wiping doesn't occur during this peculiar
       unregister/reregister pair.  */
*************** WRAPPER(void, free, void *buf)
*** 274,280 ****
--- 282,290 ----
  			     (void *) freeme,
  			     __mf_opts.crumple_zone);
  	    }
+ 	  in_malloc = 1;
  	  CALL_REAL (free, freeme);
+ 	  in_malloc = 0;
  	}
      } 
    else 
*************** WRAPPER(void, free, void *buf)
*** 289,295 ****
--- 299,307 ----
  			 (void *) buf, 
  			 __mf_opts.crumple_zone);
  	}
+       in_malloc = 1;
        CALL_REAL (free, base);
+       in_malloc = 0;
      }
  }
  
*************** WRAPPER(void *, mmap, 
*** 323,329 ****
  		 (uintptr_t) result);
    */
  
!   if (result != (void *)-1)
      {
        /* Register each page as a heap object.  Why not register it all
  	 as a single segment?  That's so that a later munmap() call
--- 335,341 ----
  		 (uintptr_t) result);
    */
  
!   if (result != (void *)-1 && !in_malloc)
      {
        /* Register each page as a heap object.  Why not register it all
  	 as a single segment?  That's so that a later munmap() call
*************** WRAPPER(int , munmap, void *start, size_
*** 372,378 ****
  		 (uintptr_t) result);
    */
  
!   if (result == 0)
      {
        /* Unregister each page as a heap object.  */
        size_t ps = getpagesize ();
--- 384,390 ----
  		 (uintptr_t) result);
    */
  
!   if (result == 0 && !in_malloc)
      {
        /* Unregister each page as a heap object.  */
        size_t ps = getpagesize ();
*************** __mf_wrap_alloca_indirect (size_t c)
*** 422,429 ****
--- 434,443 ----
      {
        struct alloca_tracking *next = alloca_history->next;
        __mf_unregister (alloca_history->ptr, 0, __MF_TYPE_HEAP);
+       in_malloc = 1;
        CALL_REAL (free, alloca_history->ptr);
        CALL_REAL (free, alloca_history);
+       in_malloc = 0;
        alloca_history = next;
      }
  
*************** __mf_wrap_alloca_indirect (size_t c)
*** 431,444 ****
--- 445,464 ----
    result = NULL;
    if (LIKELY (c > 0)) /* alloca(0) causes no allocation.  */
      {
+       in_malloc = 1;
        track = (struct alloca_tracking *) CALL_REAL (malloc, 
  						    sizeof (struct alloca_tracking));
+       in_malloc = 0;
        if (LIKELY (track != NULL))
  	{
+ 	  in_malloc = 1;
  	  result = CALL_REAL (malloc, c);
+ 	  in_malloc = 0;
  	  if (UNLIKELY (result == NULL))
  	    {
+ 	      in_malloc = 1;
  	      CALL_REAL (free, track);
+ 	      in_malloc = 0;
  	      /* Too bad.  XXX: What about errno?  */
  	    }
  	  else
diff -pr orig-gcc/libmudflap/mf-hooks2.c gcc/libmudflap/mf-hooks2.c
*** orig-gcc/libmudflap/mf-hooks2.c	Mon Oct 18 17:50:37 2004
--- gcc/libmudflap/mf-hooks2.c	Tue Feb 22 12:33:46 2005
*************** WRAPPER2(struct tm*, gmtime, const time_
*** 544,550 ****
  /* The following indicate if the result of the corresponding function
   * should be explicitly un/registered by the wrapper
  */
! #undef  MF_REGISTER_fopen
  #define MF_RESULT_SIZE_fopen		(sizeof (FILE))
  #undef  MF_REGISTER_opendir
  #define MF_RESULT_SIZE_opendir		0	/* (sizeof (DIR)) */
--- 544,550 ----
  /* The following indicate if the result of the corresponding function
   * should be explicitly un/registered by the wrapper
  */
! #define MF_REGISTER_fopen		__MF_TYPE_STATIC
  #define MF_RESULT_SIZE_fopen		(sizeof (FILE))
  #undef  MF_REGISTER_opendir
  #define MF_RESULT_SIZE_opendir		0	/* (sizeof (DIR)) */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]