From: Rhys Kidd Date: Wed, 1 Apr 2015 12:15:49 +0000 (+0000) Subject: Fix Darwin: -v does not show kernel version X-Git-Tag: svn/VALGRIND_3_11_0~536 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=537b3dfeeb59c91ed464f3240d0b21d3e6fafec1;p=thirdparty%2Fvalgrind.git Fix Darwin: -v does not show kernel version 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 --- diff --git a/NEWS b/NEWS index 4d71003014..657fa9da50 100644 --- 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 diff --git a/coregrind/m_libcproc.c b/coregrind/m_libcproc.c index f69d74084a..f3f40704cc 100644 --- a/coregrind/m_libcproc.c +++ b/coregrind/m_libcproc.c @@ -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 ------------------------------------------------------------------ */ diff --git a/coregrind/m_main.c b/coregrind/m_main.c index 365bb8212e..732e60e14a 100644 --- a/coregrind/m_main.c +++ b/coregrind/m_main.c @@ -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)( diff --git a/include/pub_tool_libcproc.h b/include/pub_tool_libcproc.h index cbd159f133..0e2afdccfa 100644 --- a/include/pub_tool_libcproc.h +++ b/include/pub_tool_libcproc.h @@ -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