{"id":8,"date":"2009-01-18T15:41:55","date_gmt":"2009-01-18T23:41:55","guid":{"rendered":"http:\/\/blog.mozilla.org\/nnethercote\/?p=8"},"modified":"2009-01-20T11:18:57","modified_gmt":"2009-01-20T00:18:57","slug":"me-valgrind-and-mac-os-x","status":"publish","type":"post","link":"https:\/\/blog.mozilla.org\/nnethercote\/2009\/01\/18\/me-valgrind-and-mac-os-x\/","title":{"rendered":"Me, Valgrind, and Mac OS X"},"content":{"rendered":"<p>Welcome to my blog, where I&#8217;ll be discussing some of the work I&#8217;m doing for Mozilla.<\/p>\n<h2>A little about me<\/h2>\n<p>I&#8217;m Australian. I live in Melbourne. I&#8217;ve also lived in Cambridge, England and Austin, Texas, and so I am fluent in at least three dialects of English. I like spending time with my wife Phoebe and baby daughter Keira, eating food, riding my bike, and following US presidential elections obsessively. Two weeks ago I left the academic\/research world and started working for Mozilla.<\/p>\n<h2>Valgrind<\/h2>\n<p>My first big task for Mozilla is to improve support for Mac OS X in <a title=\"Valgrind website\" href=\"http:\/\/www.valgrind.org\">Valgrind<\/a>. I&#8217;ve been involved with Valgrind since before the 1.0 release in 2002, and have done lots of work on it, including writing two tools that are in the Valgrind distribution: Cachegrind, a cache profiler, and Massif, a memory profiler. I even wrote a <a title=\"Nick's PhD dissertation\" href=\"http:\/\/www.valgrind.org\/docs\/phd2004.pdf\">PhD dissertation<\/a> about it.<\/p>\n<p>And it seems that lots of Mozilla people find Valgrind useful, which is nice. However, it currently only runs on Linux. (Well, it also runs on AIX, but not many people care about that.)<\/p>\n<h2>Valgrind on Mac OS X<\/h2>\n<p>More than four years ago, on December 16, 2004, an Apple employee named <a title=\"Greg Parker's blog\" href=\"http:\/\/www.sealiesoftware.com\/blog\/\">Greg Parker<\/a> wrote to the Valgrind developers mailing list to tell us that he was working on a port of Valgrind for Mac OS X.\u00a0 He&#8217;s been working on it ever since then. (This must be why Mac OS 10.5 shipped late.)<\/p>\n<p>After such a long time, I&#8217;m happy to report that there is now a branch holding Greg&#8217;s port in the Valgrind SVN repository.\u00a0 If you want to check it out, do this:<\/p>\n<pre>  svn co svn:\/\/svn.valgrind.org\/valgrind\/branches\/DARWIN &lt;workspace-name&gt;\r\n  cd &lt;workspace-name&gt;<\/pre>\n<p>and then build it according to the instructions in the README file.\u00a0 The branch is called DARWIN because Darwin is the name of the Mac OS &#8220;core&#8221;, which consists of a Mach-based microkernel and a few other bits and pieces.<\/p>\n<p>However, please note that the port currently is, in Greg&#8217;s words: <strong>&#8220;UNSUPPORTED<\/strong> and <strong>INCOMPLETE<\/strong> and <strong>BUGGY<\/strong>&#8230; It may not find bugs in your program, or run your       program correctly, or run your program at all.&#8221; What Greg has done is very impressive, and goes an awfully long way towards having a complete port of Valgrind on Mac OS X.\u00a0 But it&#8217;s not the cleanest patch ever.\u00a0 To give you an idea&#8230;<\/p>\n<ul>\n<li>The patch I imported was 31,144 lines, just over 1MB of text.<\/li>\n<li>The patch initially didn&#8217;t work on 32-bit Macs.<\/li>\n<li>The patch broke Valgrind on Linux.\u00a0 This took me a couple of days to fix, mostly involving the addition of appropriate #if statements.<\/li>\n<li>The patch broke the regression test system;\u00a0 they wouldn&#8217;t even build, let alone run. After fixing them to run again, more than half of the tests failed on Linux, and almost three-quarters failed on Mac.<\/li>\n<li>There are lots of compiler warnings.\u00a0 (The Valgrind trunk has none).<\/li>\n<li>Much of the code in the patch has 4 space indenting;\u00a0 the rest of Valgrind code has 3 space indenting.<\/li>\n<\/ul>\n<p>So there&#8217;s plenty of work to be done to get the branch into a state where it will be suitable for merging with the trunk.\u00a0 It&#8217;s hard to estimate how long this will take, it will just be a matter of fixing things one piece at a time.\u00a0 My guess is that three months might suffice, but it&#8217;s really just a guess.\u00a0 But here are some metrics I can use to judge progress, and their values just after I got the the system and regression tests building and running again on Mac and Linux:<\/p>\n<ul>\n<li>The number of regression test failures on Linux: 477 tests, 220 stderr failures, 53 stdout failures, 25 post failures.\u00a0 (&#8220;stderr&#8221; failures generally indicate that Valgrind&#8217;s output had a problem, &#8220;stdout&#8221; failures generally indicate that the test program&#8217;s output had a problem, and &#8220;post&#8221; failures indicate that the output of a Valgrind post-processing step had a problem.)\u00a0 These numbers roughly indicate how much existing functionality has been broken on Linux by the Darwin changes, and should be fairly easy to get down.<\/li>\n<li>The number of regression test failures on Mac:\u00a0 419 tests, 293 stderr failures, 58 stdout failures, 29 post failures.\u00a0 These numbers are the most important, as they roughly indicate how complete the Mac functionality is, and will be much more work to get down.<\/li>\n<li>The number of compiler warnings: 186.\u00a0 This number should be easy to reduce.\u00a0\u00a0 (<strong>Update, Jan 20:<\/strong> That&#8217;s on Linux. On Darwin it was 461.)<\/li>\n<li>The size of the diff between the branch and the trunk: 55,852 lines, 1.9MB.\u00a0 This is larger than the original patch because some files have been moved on the branch but not yet moved on the trunk, including some tests that are large and have large expected outputs.\u00a0 This number will go down in fits and starts;\u00a0 it will never get to zero, as the final merge will happen when there are many differences between the branch and trunk.<\/li>\n<\/ul>\n<p>I&#8217;ll occasionally post updates to these numbers so people can track progress.<\/p>\n<p>If Valgrind-on-Mac is of interest to you, please try out the new branch and let me know how it goes. Note that I&#8217;m working on an old MacBook Pro which is only 32-bit, so it&#8217;s possible that I&#8217;ve broken the 64-bit Mac support, but have no way to determine this.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Welcome to my blog, where I&#8217;ll be discussing some of the work I&#8217;m doing for Mozilla. A little about me I&#8217;m Australian. I live in Melbourne. I&#8217;ve also lived in Cambridge, England and Austin, Texas, and so I am fluent in at least three dialects of English. I like spending time with my wife Phoebe [&hellip;]<\/p>\n","protected":false},"author":139,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[487,118,484],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/posts\/8"}],"collection":[{"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/users\/139"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/comments?post=8"}],"version-history":[{"count":0,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/posts\/8\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/media?parent=8"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/categories?post=8"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/tags?post=8"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}