-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvalgrind.el
More file actions
52 lines (40 loc) · 1.71 KB
/
valgrind.el
File metadata and controls
52 lines (40 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
; From http://www.suspectclass.com/sgifford/abandoned/emacs/valgrind.el
; Based on compile.el included with Emacs
; and ideas from http://tromey.com/blog/?p=342
; compile.el is GPL, so this is too.
; FILCAB: I'll make some changes soon...
(require 'compile "compile")
(defgroup valgrind nil
"Run valgrind as inferior of Emacs, parse error messages."
:group 'tools
:group 'processes)
(defcustom valgrind-command "valgrind --leak-check=full "
"*Last shell command used to run valgrind; default for next valgrind run.
Sometimes it is useful for files to supply local values for this variable.
You might also use mode hooks to specify it in certain modes, like this:
(add-hook 'c-mode-hook
(lambda ()
(unless (or (file-exists-p \"makefile\")
(file-exists-p \"Makefile\"))
(set (make-local-variable 'valgrind-command)
(concat \"make -k \"
(file-name-sans-extension buffer-file-name))))))"
:type 'string
:group 'valgrind)
;; History of compile commands.
(defvar valgrind-history nil)
(defun valgrind (command)
"Run valgrind.
Runs COMMAND, a shell command, in a separate process asynchronously
with output going to the buffer `*valgrind*'.
You can then use the command \\[next-error] to find the next error message
and move to the source code that caused it."
(interactive
(if (or compilation-read-command current-prefix-arg)
(list (read-from-minibuffer "Valgrind command: "
(eval valgrind-command) nil nil
'(valgrind-history . 1)))
(list (eval valgrind-command))))
(unless (equal command (eval valgrind-command))
(setq valgrind-command command))
(compile-internal command "No more errors" "valgrind"))