{"id":7078,"date":"2004-12-18T23:00:00","date_gmt":"2004-12-18T13:00:00","guid":{"rendered":"http:\/\/michael.ellerman.id.au\/blog\/2004\/12\/18\/well-that-was-easy\/"},"modified":"2007-10-25T14:09:51","modified_gmt":"2007-10-25T04:09:51","slug":"well-that-was-easy","status":"publish","type":"post","link":"https:\/\/michael.ellerman.id.au\/blog\/2004\/12\/18\/well-that-was-easy\/","title":{"rendered":"Well that was easy"},"content":{"rendered":"<p>Last week we were visited at Ozlabs and then treated to a seminar at the ANU by Nick Nethercote, one of the principal authors of <a href=\"http:\/\/valgrind.kde.org\">Valgrind<\/a>. I haven&#8217;t had much to do with Valgrind myself, and although I had a general idea of what it did, it was great to have it explained by Nick.<\/p>\n<p>Ben decided that his &#8220;Christmas hacking project&#8221; would be to add a coverage analyser &#8220;skin&#8221; to Valgrind. With an hour or so to myself on Saturday I thought I&#8217;d have a quick poke around, and see if I could come up with anything. I was pleasantly surprised.<\/p>\n<p>With 80 lines of C I could to a quick and dirty coverage analysis of a program&#8217;s execution. With another 65 lines of python I could take the coverage info and use it to markup the source into HTML:<\/p>\n<pre>\r\nint main(int argc, char *argv[])\r\n<span style=\"background: #fff090 none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial\">{<\/span>\r\n<span style=\"background: #fff090 none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial\">    if (argc &gt; 3) {<\/span>\r\n<span style=\"background: #fff090 none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial\">        printf(\"argc was greater than 3\\n\");<\/span>\r\n    } else {\r\n        printf(\"argc was less than 3\\n\");\r\n    }\r\n<span style=\"background: #fff090 none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial\">    printf(\"argc was something\\n\");<\/span>\r\n\r\n    return 0;\r\n}<\/pre>\n<p>There&#8217;s a bug in that the <code>return 0<\/code> is supposedly never executed, and a real coverage tool will have to do a lot more, but it was still nice for a morning&#8217;s work. My only gripe is all the <code>VG_(foo)<\/code> business, but I guess every codebase has it&#8217;s quirks.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last week we were visited at Ozlabs and then treated to a seminar at the ANU by Nick Nethercote, one of the principal authors of Valgrind. I haven&#8217;t had much to do with Valgrind myself, and although I had a general idea of what it did, it was great to have it explained by Nick. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[12],"tags":[17,28],"_links":{"self":[{"href":"https:\/\/michael.ellerman.id.au\/blog\/wp-json\/wp\/v2\/posts\/7078"}],"collection":[{"href":"https:\/\/michael.ellerman.id.au\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/michael.ellerman.id.au\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/michael.ellerman.id.au\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/michael.ellerman.id.au\/blog\/wp-json\/wp\/v2\/comments?post=7078"}],"version-history":[{"count":0,"href":"https:\/\/michael.ellerman.id.au\/blog\/wp-json\/wp\/v2\/posts\/7078\/revisions"}],"wp:attachment":[{"href":"https:\/\/michael.ellerman.id.au\/blog\/wp-json\/wp\/v2\/media?parent=7078"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/michael.ellerman.id.au\/blog\/wp-json\/wp\/v2\/categories?post=7078"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/michael.ellerman.id.au\/blog\/wp-json\/wp\/v2\/tags?post=7078"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}