Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 23 Oct 2008 08:35:50 GMT
From:      Peter Wemm <peter@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 151793 for review
Message-ID:  <200810230835.m9N8Zo3j070632@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=151793

Change 151793 by peter@peter_cheese on 2008/10/23 08:35:38

	Checkpoint.  Compiles and links.  That's it though.

Affected files ...

.. //depot/projects/valgrind/Makefile.core.am#4 edit
.. //depot/projects/valgrind/Makefile.flags.am#4 edit
.. //depot/projects/valgrind/Makefile.tool.am#4 edit
.. //depot/projects/valgrind/coregrind/Makefile.am#5 edit
.. //depot/projects/valgrind/coregrind/launcher-freebsd.c#2 edit
.. //depot/projects/valgrind/coregrind/launcher-linux.c#3 edit
.. //depot/projects/valgrind/coregrind/m_aspacemgr/aspacemgr-freebsd.c#2 edit
.. //depot/projects/valgrind/coregrind/m_debuginfo/debuginfo.c#4 edit
.. //depot/projects/valgrind/coregrind/m_libcbase.c#3 edit
.. //depot/projects/valgrind/coregrind/m_replacemalloc/vg_replace_malloc.c#3 edit
.. //depot/projects/valgrind/coregrind/m_ume.c#4 edit
.. //depot/projects/valgrind/coregrind/pub_core_debuginfo.h#3 edit
.. //depot/projects/valgrind/memcheck/mc_replace_strmem.c#3 edit

Differences ...

==== //depot/projects/valgrind/Makefile.core.am#4 (text+ko) ====

@@ -95,5 +95,3 @@
 		-DVGP_ppc64_aix5=1
 
 include $(top_srcdir)/Makefile.flags.am
-PRELOAD_LDFLAGS_X86_FREEBSD = $(PRELOAD_LDFLAGS_COMMON) @FLAG_M32@
-PRELOAD_LDFLAGS_AMD64_FREEBSD = $(PRELOAD_LDFLAGS_COMMON) -m64

==== //depot/projects/valgrind/Makefile.flags.am#4 (text+ko) ====

@@ -78,9 +78,12 @@
 # Baseline link flags for making dynamic shared objects.
 #
 PRELOAD_LDFLAGS_COMMON_LINUX = -nodefaultlibs -shared -Wl,-z,interpose,-z,initfirst
+PRELOAD_LDFLAGS_COMMON_FREEBSD = -nodefaultlibs -shared -Wl,-z,interpose,-z,initfirst
 PRELOAD_LDFLAGS_COMMON_AIX5  = -nodefaultlibs -shared -Wl,-G -Wl,-bnogc
 PRELOAD_LDFLAGS_X86_LINUX   = $(PRELOAD_LDFLAGS_COMMON_LINUX) @FLAG_M32@
 PRELOAD_LDFLAGS_AMD64_LINUX = $(PRELOAD_LDFLAGS_COMMON_LINUX) @FLAG_M64@
+PRELOAD_LDFLAGS_X86_FREEBSD   = $(PRELOAD_LDFLAGS_COMMON_FREEBSD) @FLAG_M32@
+PRELOAD_LDFLAGS_AMD64_FREEBSD = $(PRELOAD_LDFLAGS_COMMON_FREEBSD) @FLAG_M64@
 PRELOAD_LDFLAGS_PPC32_LINUX = $(PRELOAD_LDFLAGS_COMMON_LINUX) @FLAG_M32@
 PRELOAD_LDFLAGS_PPC64_LINUX = $(PRELOAD_LDFLAGS_COMMON_LINUX) @FLAG_M64@
 PRELOAD_LDFLAGS_PPC32_AIX5  = $(PRELOAD_LDFLAGS_COMMON_AIX5)  @FLAG_MAIX32@

==== //depot/projects/valgrind/Makefile.tool.am#4 (text+ko) ====

@@ -117,17 +117,20 @@
 TOOL_LDFLAGS_COMMON_LINUX = -static \
 	-Wl,-defsym,valt_load_address=@VALT_LOAD_ADDRESS@ \
 	-nodefaultlibs -nostartfiles -u _start
+TOOL_LDFLAGS_COMMON_FREEBSD = -static \
+	-Wl,-defsym,valt_load_address=@VALT_LOAD_ADDRESS@ \
+	-nodefaultlibs -nostartfiles -u _start
 TOOL_LDFLAGS_COMMON_AIX5 = -static -Wl,-e_start_valgrind
 
 
 TOOL_LDADD_X86_FREEBSD = $(COREGRIND_LIBS_X86_FREEBSD) $(TOOL_LDADD_COMMON)
 TOOL_LDFLAGS_X86_FREEBSD = \
-	$(TOOL_LDFLAGS_COMMON_X86_FREEBSD) @FLAG_M32@ \
+	$(TOOL_LDFLAGS_COMMON_FREEBSD) @FLAG_M32@ \
 	-Wl,-T,$(top_builddir)/valt_load_address_x86_freebsd.lds
 
 TOOL_LDADD_AMD64_FREEBSD = $(COREGRIND_LIBS_AMD64_FREEBSD) $(TOOL_LDADD_COMMON)
 TOOL_LDFLAGS_AMD64_FREEBSD = \
-	$(TOOL_LDFLAGS_COMMON_AMD64_FREEBSD) -m64 \
+	$(TOOL_LDFLAGS_COMMON_FREEBSD) -m64 \
 	-Wl,-T,$(top_builddir)/valt_load_address_amd64_freebsd.lds
 
 TOOL_LDADD_X86_LINUX = $(COREGRIND_LIBS_X86_LINUX) $(TOOL_LDADD_COMMON)

==== //depot/projects/valgrind/coregrind/Makefile.am#5 (text+ko) ====

@@ -57,11 +57,17 @@
 	launcher-aix5.c \
 	m_debuglog.c \
 	m_vkiscnums.c
-else
+endif
+if VGO_LINUX
 valgrind_SOURCES = \
 	launcher-linux.c \
 	m_debuglog.c
 endif
+if VGO_FREEBSD
+valgrind_SOURCES = \
+	launcher-freebsd.c \
+	m_debuglog.c
+endif
 
 valgrind_CPPFLAGS  = $(AM_CPPFLAGS_PRI)
 valgrind_CFLAGS    = $(AM_CFLAGS_PRI)

==== //depot/projects/valgrind/coregrind/launcher-freebsd.c#2 (text+ko) ====

@@ -150,13 +150,7 @@
          if (header[EI_DATA] == ELFDATA2LSB) {
             if (ehdr->e_machine == EM_386 &&
                 ehdr->e_ident[EI_OSABI] == ELFOSABI_SYSV) {
-               platform = "x86-linux";
-            }
-         }
-         else if (header[EI_DATA] == ELFDATA2MSB) {
-            if (ehdr->e_machine == EM_PPC &&
-                ehdr->e_ident[EI_OSABI] == ELFOSABI_SYSV) {
-               platform = "ppc32-linux";
+               platform = "x86-freebsd";
             }
          }
       } else if (header[EI_CLASS] == ELFCLASS64) {
@@ -165,13 +159,8 @@
          if (header[EI_DATA] == ELFDATA2LSB) {
             if (ehdr->e_machine == EM_X86_64 &&
                 ehdr->e_ident[EI_OSABI] == ELFOSABI_SYSV) {
-               platform = "amd64-linux";
+               platform = "amd64-freebsd";
             }
-         } else if (header[EI_DATA] == ELFDATA2MSB) {
-            if (ehdr->e_machine == EM_PPC64 &&
-                ehdr->e_ident[EI_OSABI] == ELFOSABI_SYSV) {
-               platform = "ppc64-linux";
-            }
          }
       }
    }
@@ -239,18 +228,10 @@
       target, because on most ppc64-linux setups, the basic /bin,
       /usr/bin, etc, stuff is built in 32-bit mode, not 64-bit
       mode. */
-   if (0==strcmp(VG_PLATFORM,"x86-linux"))
-      default_platform = "x86-linux";
-   else if (0==strcmp(VG_PLATFORM,"x86-freebsd"))
+   if (0==strcmp(VG_PLATFORM,"x86-freebsd"))
       default_platform = "x86-freebsd";
    else if (0==strcmp(VG_PLATFORM,"amd64-freebsd"))
       default_platform = "amd64-freebsd";
-   else if (0==strcmp(VG_PLATFORM,"amd64-linux"))
-      default_platform = "amd64-linux";
-   else if (0==strcmp(VG_PLATFORM,"ppc32-linux"))
-      default_platform = "ppc32-linux";
-   else if (0==strcmp(VG_PLATFORM,"ppc64-linux"))
-      default_platform = "ppc32-linux";
    else
       barf("Unknown VG_PLATFORM '%s'", VG_PLATFORM);
 
@@ -274,27 +255,14 @@
       we can tell stage2.  stage2 will use the name for recursive
       invokations of valgrind on child processes. */
    memset(launcher_name, 0, PATH_MAX+1);
-#if defined(VGO_linux)
-   r = readlink("/proc/self/exe", launcher_name, PATH_MAX);
-#elif defined(VGO_freebsd)
    r = readlink("/proc/curproc/file", launcher_name, PATH_MAX);
-#else
-#error "unknown OS"
-#endif
    if (r == -1) {
       /* If /proc/self/exe can't be followed, don't give up.  Instead
          continue with an empty string for VALGRIND_LAUNCHER.  In the
          sys_execve wrapper, this is tested, and if found to be empty,
          fail the execve. */
-#if defined(VGO_linux)
       fprintf(stderr, "valgrind: warning (non-fatal): "
-                      "readlink(\"/proc/self/exe\") failed.\n");
-#elif defined(VGO_freebsd)
-      fprintf(stderr, "valgrind: warning (non-fatal): "
                       "readlink(\"/proc/curproc/file\") failed.\n");
-#else
-#error "unknown OS"
-#endif
       fprintf(stderr, "valgrind: continuing, however --trace-children=yes "
                       "will not work.\n");
    }

==== //depot/projects/valgrind/coregrind/launcher-linux.c#3 (text+ko) ====

@@ -241,10 +241,6 @@
       mode. */
    if (0==strcmp(VG_PLATFORM,"x86-linux"))
       default_platform = "x86-linux";
-   else if (0==strcmp(VG_PLATFORM,"x86-freebsd"))
-      default_platform = "x86-freebsd";
-   else if (0==strcmp(VG_PLATFORM,"amd64-freebsd"))
-      default_platform = "amd64-freebsd";
    else if (0==strcmp(VG_PLATFORM,"amd64-linux"))
       default_platform = "amd64-linux";
    else if (0==strcmp(VG_PLATFORM,"ppc32-linux"))
@@ -274,27 +270,14 @@
       we can tell stage2.  stage2 will use the name for recursive
       invokations of valgrind on child processes. */
    memset(launcher_name, 0, PATH_MAX+1);
-#if defined(VGO_linux)
    r = readlink("/proc/self/exe", launcher_name, PATH_MAX);
-#elif defined(VGO_freebsd)
-   r = readlink("/proc/curproc/file", launcher_name, PATH_MAX);
-#else
-#error "unknown OS"
-#endif
    if (r == -1) {
       /* If /proc/self/exe can't be followed, don't give up.  Instead
          continue with an empty string for VALGRIND_LAUNCHER.  In the
          sys_execve wrapper, this is tested, and if found to be empty,
          fail the execve. */
-#if defined(VGO_linux)
       fprintf(stderr, "valgrind: warning (non-fatal): "
                       "readlink(\"/proc/self/exe\") failed.\n");
-#elif defined(VGO_freebsd)
-      fprintf(stderr, "valgrind: warning (non-fatal): "
-                      "readlink(\"/proc/curproc/file\") failed.\n");
-#else
-#error "unknown OS"
-#endif
       fprintf(stderr, "valgrind: continuing, however --trace-children=yes "
                       "will not work.\n");
    }

==== //depot/projects/valgrind/coregrind/m_aspacemgr/aspacemgr-freebsd.c#2 (text+ko) ====

@@ -352,22 +352,6 @@
 /* Given a file descriptor, attempt to deduce its filename.  To do
    this, we use /proc/self/fd/<FD>.  If this doesn't point to a file,
    or if it doesn't exist, we return False. */
-#if defined(VGO_linux)
-static
-Bool get_name_for_fd ( Int fd, /*OUT*/HChar* buf, Int nbuf )
-{
-   Int   i;
-   HChar tmp[64];
-
-   ML_(am_sprintf)(tmp, "/proc/self/fd/%d", fd);
-   for (i = 0; i < nbuf; i++) buf[i] = 0;
-   
-   if (ML_(am_readlink)(tmp, buf, nbuf) > 0 && buf[0] == '/')
-      return True;
-   else
-      return False;
-}
-#elif defined(VGO_freebsd)
 static
 Bool get_name_for_fd ( Int fd, HChar* buf, Int nbuf )
 {
@@ -407,9 +391,6 @@
    else
       return False;
 }
-#else
-#error undefined os
-#endif
 
 
 /*-----------------------------------------------------------------*/
@@ -1005,17 +986,7 @@
          seg_prot |= VKI_PROT_EXEC;
       }
 
-      same = same
-             && seg_prot == prot
-#ifndef VGO_freebsd
-             && (cmp_devino
-                   ? (nsegments[i].dev == dev && nsegments[i].ino == ino)
-                   : True)
-             && (cmp_offsets 
-                   ? nsegments[i].start-nsegments[i].offset == addr-offset
-                   : True)
-#endif
-	     ;
+      same = same && seg_prot == prot;
       if (!same) {
          sync_check_ok = False;
          VG_(debugLog)(
@@ -1539,9 +1510,7 @@
    if (dev != 0 && ino != 0) 
       seg.kind = SkFileV;
    if (filename) {
-#if defined(VGO_freebsd)
       seg.kind = SkFileV;
-#endif
       seg.fnIdx = allocate_segname( filename );
    }
 
@@ -1658,18 +1627,10 @@
 
    VG_(am_show_nsegments)(2, "Initial layout");
 
-#ifdef VGO_freebsd
    VG_(debugLog)(2, "aspacem", "Reading /proc/curproc/map\n");
-#else
-   VG_(debugLog)(2, "aspacem", "Reading /proc/self/maps\n");
-#endif
    parse_procselfmaps( read_maps_callback, NULL );
 
-#ifdef VGO_freebsd
    VG_(am_show_nsegments)(2, "With contents of /proc/curproc/map");
-#else
-   VG_(am_show_nsegments)(2, "With contents of /proc/self/maps");
-#endif
 
    AM_SANITY_CHECK;
    return suggested_clstack_top;
@@ -3088,9 +3049,7 @@
    UInt	  prot;
    UWord  maj, min;
    ULong  foffset, dev, ino;
-#ifdef VGO_freebsd
-   UInt   junk;
-#endif
+   ULong  junk64;
 
    foffset = ino = 0; /* keep gcc-4.1.0 happy */
 
@@ -3107,51 +3066,6 @@
    while (True) {
       if (i >= buf_n_tot) break;
 
-#if defined(VGO_linux)
-      /* Read (without fscanf :) the pattern %16x-%16x %c%c%c%c %16x %2x:%2x %d */
-      j = readhex(&procmap_buf[i], &start);
-      if (j > 0) i += j; else goto syntaxerror;
-      j = readchar(&procmap_buf[i], &ch);
-      if (j == 1 && ch == '-') i += j; else goto syntaxerror;
-      j = readhex(&procmap_buf[i], &endPlusOne);
-      if (j > 0) i += j; else goto syntaxerror;
-
-      j = readchar(&procmap_buf[i], &ch);
-      if (j == 1 && ch == ' ') i += j; else goto syntaxerror;
-
-      j = readchar(&procmap_buf[i], &rr);
-      if (j == 1 && (rr == 'r' || rr == '-')) i += j; else goto syntaxerror;
-      j = readchar(&procmap_buf[i], &ww);
-      if (j == 1 && (ww == 'w' || ww == '-')) i += j; else goto syntaxerror;
-      j = readchar(&procmap_buf[i], &xx);
-      if (j == 1 && (xx == 'x' || xx == '-')) i += j; else goto syntaxerror;
-      /* This field is the shared/private flag */
-      j = readchar(&procmap_buf[i], &pp);
-      if (j == 1 && (pp == 'p' || pp == '-' || pp == 's')) 
-                                              i += j; else goto syntaxerror;
-
-      j = readchar(&procmap_buf[i], &ch);
-      if (j == 1 && ch == ' ') i += j; else goto syntaxerror;
-
-      j = readhex64(&procmap_buf[i], &foffset);
-      if (j > 0) i += j; else goto syntaxerror;
-
-      j = readchar(&procmap_buf[i], &ch);
-      if (j == 1 && ch == ' ') i += j; else goto syntaxerror;
-
-      j = readhex(&procmap_buf[i], &maj);
-      if (j > 0) i += j; else goto syntaxerror;
-      j = readchar(&procmap_buf[i], &ch);
-      if (j == 1 && ch == ':') i += j; else goto syntaxerror;
-      j = readhex(&procmap_buf[i], &min);
-      if (j > 0) i += j; else goto syntaxerror;
-
-      j = readchar(&procmap_buf[i], &ch);
-      if (j == 1 && ch == ' ') i += j; else goto syntaxerror;
-
-      j = readdec64(&procmap_buf[i], &ino);
-      if (j > 0) i += j; else goto syntaxerror;
-#elif defined(VGO_freebsd)
       /* Read (without fscanf :) the pattern %8x %8x %d %d %8x %c%c%c%c %d %d %8x .* .* .* */
       /* 0x38000000 0x38119000 281 748 0xd76df8a0 r-x 2 1 0x0 COW NC vnode */
       j = readhex(&procmap_buf[i], &start);
@@ -3164,15 +3078,15 @@
       j = readchar(&procmap_buf[i], &ch);
       if (j == 1 && ch == ' ') i += j; else goto syntaxerror;
 
-      j = readdec(&procmap_buf[i], &junk);
+      j = readdec64(&procmap_buf[i], &junk64);
       if (j > 0) i += j; else goto syntaxerror;
       j = readchar(&procmap_buf[i], &ch);
       if (j == 1 && ch == ' ') i += j; else goto syntaxerror;
-      j = readdec(&procmap_buf[i], &junk);
+      j = readdec64(&procmap_buf[i], &junk64);
       if (j > 0) i += j; else goto syntaxerror;
       j = readchar(&procmap_buf[i], &ch);
       if (j == 1 && ch == ' ') i += j; else goto syntaxerror;
-      j = readhex(&procmap_buf[i], &junk);
+      j = readhex64(&procmap_buf[i], &junk64);
       if (j > 0) i += j; else goto syntaxerror;
       j = readchar(&procmap_buf[i], &ch);
       if (j == 1 && ch == ' ') i += j; else goto syntaxerror;
@@ -3187,16 +3101,16 @@
       j = readchar(&procmap_buf[i], &ch);
       if (j == 1 && ch == ' ') i += j; else goto syntaxerror;
 
-      j = readdec(&procmap_buf[i], &junk);
+      j = readdec64(&procmap_buf[i], &junk64);
       if (j > 0) i += j; else goto syntaxerror;
       j = readchar(&procmap_buf[i], &ch);
       if (j == 1 && ch == ' ') i += j; else goto syntaxerror;
-      j = readdec(&procmap_buf[i], &junk);
+      j = readdec64(&procmap_buf[i], &junk64);
       if (j > 0) i += j; else goto syntaxerror;
       j = readchar(&procmap_buf[i], &ch);
       if (j == 1 && ch == ' ') i += j; else goto syntaxerror;
 
-      j = readhex(&procmap_buf[i], &junk);
+      j = readhex64(&procmap_buf[i], &junk64);
       if (j > 0) i += j; else goto syntaxerror;
 
       j = readchar(&procmap_buf[i], &ch);
@@ -3252,20 +3166,12 @@
               if (j == 1 && ch == 'e') i += j; else goto syntaxerror;
       }
       foffset = 0;
-#else
-#error "Unknown OS"
-#endif
  
       goto read_line_ok;
 
     syntaxerror:
-#ifdef VGO_freebsd
       VG_(debugLog)(0, "Valgrind:", 
                        "FATAL: syntax error reading /proc/curproc/map\n");
-#else
-      VG_(debugLog)(0, "Valgrind:", 
-                       "FATAL: syntax error reading /proc/self/maps\n");
-#endif
       { Int k, m;
         HChar buf50[51];
         m = 0;
@@ -3308,11 +3214,9 @@
       }
 
 #if 0
-#ifdef VGO_freebsd
       if (!filename)
          filename = find_path(start);
 #endif
-#endif
 
       prot = 0;
       if (rr == 'r') prot |= VKI_PROT_READ;

==== //depot/projects/valgrind/coregrind/m_debuginfo/debuginfo.c#4 (text+ko) ====

@@ -57,7 +57,7 @@
 #include "priv_storage.h"
 #include "priv_readdwarf.h"
 #include "priv_readstabs.h"
-#if defined(VGO_linux)
+#if defined(VGO_linux) || defined(VGO_freebsd)
 # include "priv_readelf.h"
 # include "priv_readdwarf3.h"
 #elif defined(VGO_aix5)
@@ -485,7 +485,7 @@
 /*---                                                        ---*/
 /*--------------------------------------------------------------*/
 
-#if defined(VGO_linux)
+#if defined(VGO_linux) || defined(VGO_freebsd)
 
 /* The debug info system is driven by notifications that a text
    segment has been mapped in, or unmapped.  When that happens it

==== //depot/projects/valgrind/coregrind/m_libcbase.c#3 (text+ko) ====

@@ -501,6 +501,14 @@
    return dest;
 }
 
+#ifdef VGO_freebsd
+/* Gcc generates internal inline calls for struct copies */
+void* memcpy ( void *dest, const void *src, SizeT sz )
+{
+	return VG_(memcpy)(dest, src, sz);
+}
+#endif
+
 void* VG_(memmove)(void *dest, const void *src, SizeT sz)
 {
    SizeT i;

==== //depot/projects/valgrind/coregrind/m_replacemalloc/vg_replace_malloc.c#3 (text+ko) ====

@@ -57,7 +57,7 @@
 
 /* --- Soname of the standard C library. --- */
 
-#if defined(VGO_linux)
+#if defined(VGO_linux) || defined(VGO_freebsd)
 #  define  m_libc_soname     libcZdsoZa              // libc.so*
 #elif defined(VGP_ppc32_aix5)
    /* AIX has both /usr/lib/libc.a and /usr/lib/libc_r.a. */

==== //depot/projects/valgrind/coregrind/m_ume.c#4 (text+ko) ====

@@ -33,7 +33,7 @@
 #include "pub_core_basics.h"
 #include "pub_core_vki.h"
 
-#if defined(VGO_linux)
+#if defined(VGO_linux) || defined(VGO_freebsd)
 
 #include "pub_core_aspacemgr.h"   // various mapping fns
 #include "pub_core_debuglog.h"

==== //depot/projects/valgrind/coregrind/pub_core_debuginfo.h#3 (text+ko) ====

@@ -53,7 +53,7 @@
    in later queries to m_debuginfo.  In this case the handle value
    will be one or above.  If the returned value is zero, no debug info
    was read. */
-#if defined(VGO_linux)
+#if defined(VGO_linux) || defined(VGO_freebsd)
 extern ULong VG_(di_notify_mmap)( Addr a, Bool allow_SkFileV );
 
 extern void VG_(di_notify_munmap)( Addr a, SizeT len );

==== //depot/projects/valgrind/memcheck/mc_replace_strmem.c#3 (text+ko) ====

@@ -101,7 +101,7 @@
 
 /* --- Soname of the standard C library. --- */
 
-#if defined(VGO_linux)
+#if defined(VGO_linux) || defined(VGO_freebsd)
 #  define  m_libc_soname     libcZdsoZa              // libc.so*
 #elif defined(VGP_ppc32_aix5)
    /* AIX has both /usr/lib/libc.a and /usr/lib/libc_r.a. */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200810230835.m9N8Zo3j070632>