summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2017-03-14 08:36:57 +0100
committerAndreas Rumpf <rumpf_a@web.de>2017-03-14 08:36:57 +0100
commit15a8996d57eb201cdc1db2e1e79faba4a3530636 (patch)
tree80942fcfed23e1211f934005197dcfed8e2eae38
parentd59441340dcc3b131c984def530084da93796775 (diff)
downloadNim-15a8996d57eb201cdc1db2e1e79faba4a3530636.tar.gz
valgrind support for nim
-rw-r--r--koch.nim9
-rw-r--r--tools/nimgrind.supp14
2 files changed, 23 insertions, 0 deletions
diff --git a/koch.nim b/koch.nim
index 7c0193917..37b33c5ac 100644
--- a/koch.nim
+++ b/koch.nim
@@ -512,6 +512,14 @@ proc pushCsources() =
   finally:
     setCurrentDir(cwd)
 
+proc valgrind(cmd: string) =
+  exec("nim c " & cmd)
+  var i = cmd.len-1
+  while i >= 0 and cmd[i] != ' ': dec i
+  let file = if i >= 0: substr(cmd, i+1) else: cmd
+  let supp = getAppDir() / "tools" / "nimgrind.supp"
+  exec("valgrind --suppressions=" & supp & " " & changeFileExt(file, ""))
+
 proc showHelp() =
   quit(HelpText % [VersionAsString & spaces(44-len(VersionAsString)),
                    CompileDate, CompileTime], QuitSuccess)
@@ -548,5 +556,6 @@ of cmdArgument:
   of "nimsuggest": bundleNimsuggest(buildExe=true)
   of "tools": buildTools(existsDir(".git"))
   of "pushcsource", "pushcsources": pushCsources()
+  of "valgrind": valgrind(op.cmdLineRest)
   else: showHelp()
 of cmdEnd: showHelp()
diff --git a/tools/nimgrind.supp b/tools/nimgrind.supp
new file mode 100644
index 000000000..44499ebc7
--- /dev/null
+++ b/tools/nimgrind.supp
@@ -0,0 +1,14 @@
+{
+    markstackandregisters_Cond
+    Memcheck:Cond
+    ...
+    fun:markStackAndRegisters*
+    ...
+}
+{
+    markstackandregisters_Value8
+    Memcheck:Value8
+    ...
+    fun:markStackAndRegisters*
+    ...
+}