]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix Darwin: -v does not show kernel version
authorRhys Kidd <rhyskidd@gmail.com>
Wed, 1 Apr 2015 12:15:49 +0000 (12:15 +0000)
committerRhys Kidd <rhyskidd@gmail.com>
Wed, 1 Apr 2015 12:15:49 +0000 (12:15 +0000)
bz#201435

Before:

== 590 tests, 237 stderr failures, 22 stdout failures, 0 stderrB failures, 0 stdoutB failures, 31 post failures ==

After:

== 590 tests, 237 stderr failures, 22 stdout failures, 0 stderrB failures, 0 stdoutB failures, 31 post failures ==

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15056

NEWS
coregrind/m_libcproc.c
coregrind/m_main.c
include/pub_tool_libcproc.h

diff --git a/NEWS b/NEWS
index 4d7100301483ae2ae72c9b5d60fcee1329394dd5..657fa9da50c7b7688629515b8b064c60f9514332 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -62,6 +62,7 @@ where XXXXXX is the bug number as listed below.
 116002  VG_(printf): Problems with justification of strings and integers
 155125  avoid cutting away file:lineno after long function name
 197259  Unsupported arch_prtctl PR_SET_GS option
+201435  Fix Darwin: -v does not show kernel version
 211926  Avoid compilation warnings in valgrind.h with -pedantic
 226609  Crediting upstream authors in man page
 269360  s390x: Fix addressing mode selection for compare-and-swap
index f69d74084a2c5774e8ef8260c6530eedd5c369ee..f3f40704cc4e0fbb91cf5adfcaecfb56bf7b2a7b 100644 (file)
@@ -387,6 +387,18 @@ Int VG_(system) ( const HChar* cmd )
    }
 }
 
+Int VG_(sysctl)(Int *name, UInt namelen, void *oldp, SizeT *oldlenp, void *newp, SizeT newlen)
+{
+   SysRes res;
+#  if defined(VGO_darwin)
+   res = VG_(do_syscall6)(__NR___sysctl,
+                           name, namelen, oldp, oldlenp, newp, newlen);
+#  else
+   res = VG_(mk_SysRes_Error)(VKI_ENOSYS);
+#  endif
+   return sr_isError(res) ? -1 : sr_Res(res);
+}
+
 /* ---------------------------------------------------------------------
    Resource limits
    ------------------------------------------------------------------ */
index 365bb8212e3b991580552a6bf67e729d88b33d05..732e60e14a8be8da3e034085e3afe924e8a598f0 100644 (file)
@@ -1444,7 +1444,9 @@ static void print_preamble ( Bool logging_to_fd,
       VG_(umsg)("\n");
 
    if (VG_(clo_verbosity) > 1) {
+# if !defined(VGO_darwin)
       SysRes fd;
+# endif
       VexArch vex_arch;
       VexArchInfo vex_archinfo;
       if (!logging_to_fd)
@@ -1456,6 +1458,7 @@ static void print_preamble ( Bool logging_to_fd,
                      * (HChar**) VG_(indexXA)( VG_(args_for_valgrind), i ));
       }
 
+# if !defined(VGO_darwin)
       VG_(message)(Vg_DebugMsg, "Contents of /proc/version:\n");
       fd = VG_(open) ( "/proc/version", VKI_O_RDONLY, 0 );
       if (sr_isError(fd)) {
@@ -1477,6 +1480,18 @@ static void print_preamble ( Bool logging_to_fd,
          VG_(message)(Vg_DebugMsg, "\n");
          VG_(close)(fdno);
       }
+# else
+      VG_(message)(Vg_DebugMsg, "Output from sysctl({CTL_KERN,KERN_VERSION}):\n");
+      /* Note: preferable to use sysctlbyname("kern.version", kernelVersion, &len, NULL, 0)
+         however that syscall is OS X 10.10+ only. */
+      Int mib[] = {CTL_KERN, KERN_VERSION};
+      SizeT len;
+      VG_(sysctl)(mib, sizeof(mib)/sizeof(Int), NULL, &len, NULL, 0);
+      HChar *kernelVersion = VG_(malloc)("main.pp.1", len);
+      VG_(sysctl)(mib, sizeof(mib)/sizeof(Int), kernelVersion, &len, NULL, 0);
+      VG_(message)(Vg_DebugMsg, "  %s\n", kernelVersion);
+      VG_(free)( kernelVersion );
+# endif
 
       VG_(machine_get_VexArchInfo)( &vex_arch, &vex_archinfo );
       VG_(message)(
index cbd159f13312027c815af9574bf3534b1a4cb876..0e2afdccfa4d970d67034ed347b073d8416589ac 100644 (file)
@@ -59,6 +59,7 @@ extern Int  VG_(waitpid)( Int pid, Int *status, Int options );
 extern Int  VG_(system) ( const HChar* cmd );
 extern Int  VG_(fork)   ( void);
 extern void VG_(execv)  ( const HChar* filename, HChar** argv );
+extern Int  VG_(sysctl) ( Int *name, UInt namelen, void *oldp, SizeT *oldlenp, void *newp, SizeT newlen );
 
 /* ---------------------------------------------------------------------
    Resource limits and capabilities