diff options
| author | Glenn Morris | 2014-05-05 20:53:31 -0700 |
|---|---|---|
| committer | Glenn Morris | 2014-05-05 20:53:31 -0700 |
| commit | 0c4decaeb1b14dbea8bf18b5ab2e52ca9c9c9d4c (patch) | |
| tree | 0cad76330e8684f16d1f286a2b4571e16a2d2334 | |
| parent | 088e020172e7cdbf75a94ab13a147ff9bb1dd7b4 (diff) | |
| download | emacs-0c4decaeb1b14dbea8bf18b5ab2e52ca9c9c9d4c.tar.gz emacs-0c4decaeb1b14dbea8bf18b5ab2e52ca9c9c9d4c.zip | |
find-gc.el misc fixes
The whole file looks obsolete and/or broken.
* lisp/emacs-lisp/find-gc.el (find-gc-source-directory): Give it a value.
(find-gc-source-files): Update some names.
(trace-call-tree): Simplify and update. Avoid predictable temp-file names.
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/emacs-lisp/find-gc.el | 80 |
2 files changed, 43 insertions, 44 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 6aabf022b7b..713d34dda8d 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2014-05-06 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | * emacs-lisp/find-gc.el (find-gc-source-directory): Give it a value. | ||
| 4 | (find-gc-source-files): Update some names. | ||
| 5 | (trace-call-tree): Simplify and update. | ||
| 6 | Avoid predictable temp-file names. (http://bugs.debian.org/747100) | ||
| 7 | |||
| 1 | 2014-05-05 Stefan Monnier <monnier@iro.umontreal.ca> | 8 | 2014-05-05 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 9 | ||
| 3 | * minibuffer.el (completion--try-word-completion): Revert fix for | 10 | * minibuffer.el (completion--try-word-completion): Revert fix for |
diff --git a/lisp/emacs-lisp/find-gc.el b/lisp/emacs-lisp/find-gc.el index ff9062150db..3608e7a0b70 100644 --- a/lisp/emacs-lisp/find-gc.el +++ b/lisp/emacs-lisp/find-gc.el | |||
| @@ -23,14 +23,15 @@ | |||
| 23 | 23 | ||
| 24 | ;; Produce in find-gc-unsafe-list the set of all functions that may invoke GC. | 24 | ;; Produce in find-gc-unsafe-list the set of all functions that may invoke GC. |
| 25 | ;; This expects the Emacs sources to live in find-gc-source-directory. | 25 | ;; This expects the Emacs sources to live in find-gc-source-directory. |
| 26 | ;; It creates a temporary working directory /tmp/esrc. | ||
| 27 | 26 | ||
| 28 | ;;; Code: | 27 | ;;; Code: |
| 29 | 28 | ||
| 30 | (defvar find-gc-unsafe-list nil | 29 | (defvar find-gc-unsafe-list nil |
| 31 | "The list of unsafe functions is placed here by `find-gc-unsafe'.") | 30 | "The list of unsafe functions is placed here by `find-gc-unsafe'.") |
| 32 | 31 | ||
| 33 | (defvar find-gc-source-directory) | 32 | (defvar find-gc-source-directory |
| 33 | (file-name-as-directory (expand-file-name "src" source-directory)) | ||
| 34 | "Directory containing Emacs C sources.") | ||
| 34 | 35 | ||
| 35 | (defvar find-gc-subrs-callers nil | 36 | (defvar find-gc-subrs-callers nil |
| 36 | "Alist of users of subrs, from GC testing. | 37 | "Alist of users of subrs, from GC testing. |
| @@ -59,14 +60,14 @@ Each entry has the form (FUNCTION . FUNCTIONS-IT-CALLS).") | |||
| 59 | "indent.c" "search.c" "regex.c" "undo.c" | 60 | "indent.c" "search.c" "regex.c" "undo.c" |
| 60 | "alloc.c" "data.c" "doc.c" "editfns.c" | 61 | "alloc.c" "data.c" "doc.c" "editfns.c" |
| 61 | "callint.c" "eval.c" "fns.c" "print.c" "lread.c" | 62 | "callint.c" "eval.c" "fns.c" "print.c" "lread.c" |
| 62 | "abbrev.c" "syntax.c" "unexcoff.c" | 63 | "syntax.c" "unexcoff.c" |
| 63 | "bytecode.c" "process.c" "callproc.c" "doprnt.c" | 64 | "bytecode.c" "process.c" "callproc.c" "doprnt.c" |
| 64 | "x11term.c" "x11fns.c")) | 65 | "xterm.c" "xfns.c")) |
| 65 | 66 | ||
| 66 | 67 | ||
| 67 | (defun find-gc-unsafe () | 68 | (defun find-gc-unsafe () |
| 68 | "Return a list of unsafe functions--that is, which can call GC. | 69 | "Return a list of unsafe functions--that is, which can call GC. |
| 69 | Also store it in `find-gc-unsafe'." | 70 | Also store it in `find-gc-unsafe-list'." |
| 70 | (trace-call-tree nil) | 71 | (trace-call-tree nil) |
| 71 | (trace-use-tree) | 72 | (trace-use-tree) |
| 72 | (find-unsafe-funcs 'Fgarbage_collect) | 73 | (find-unsafe-funcs 'Fgarbage_collect) |
| @@ -102,47 +103,38 @@ Also store it in `find-gc-unsafe'." | |||
| 102 | 103 | ||
| 103 | 104 | ||
| 104 | 105 | ||
| 105 | (defun trace-call-tree (&optional already-setup) | 106 | (defun trace-call-tree (&optional ignored) |
| 106 | (message "Setting up directories...") | 107 | (message "Setting up directories...") |
| 107 | (or already-setup | 108 | (setq find-gc-subrs-called nil) |
| 108 | (progn | 109 | (let ((case-fold-search nil) |
| 109 | ;; Gee, wouldn't a built-in "system" function be handy here. | 110 | (default-directory find-gc-source-directory) |
| 110 | (call-process "csh" nil nil nil "-c" "rm -rf /tmp/esrc") | 111 | (files find-gc-source-files) |
| 111 | (call-process "csh" nil nil nil "-c" "mkdir /tmp/esrc") | 112 | name entry rtlfile) |
| 112 | (call-process "csh" nil nil nil "-c" | 113 | (dolist (file files) |
| 113 | (format "ln -s %s/*.[ch] /tmp/esrc" | 114 | (message "Compiling %s..." file) |
| 114 | find-gc-source-directory)))) | 115 | (call-process "gcc" nil nil nil "-I" "." "-I" "../lib" |
| 115 | (with-current-buffer (get-buffer-create "*Trace Call Tree*") | 116 | "-fdump-rtl-expand" "-o" null-device "-c" file) |
| 116 | (setq find-gc-subrs-called nil) | 117 | (setq rtlfile |
| 117 | (let ((case-fold-search nil) | 118 | (file-expand-wildcards (format "%s.*.expand" file) t)) |
| 118 | (files find-gc-source-files) | 119 | (if (/= 1 (length rtlfile)) |
| 119 | name entry) | 120 | (message "Error compiling `%s'?" file) |
| 120 | (while files | 121 | (with-temp-buffer |
| 121 | (message "Compiling %s..." (car files)) | 122 | (insert-file-contents (setq rtlfile (car rtlfile))) |
| 122 | (call-process "csh" nil nil nil "-c" | 123 | (delete-file rtlfile) |
| 123 | (format "gcc -dr -c /tmp/esrc/%s -o /dev/null" | 124 | (while (re-search-forward ";; Function \\|(call_insn " nil t) |
| 124 | (car files))) | 125 | (if (= (char-after (- (point) 3)) ?o) |
| 125 | (erase-buffer) | ||
| 126 | (insert-file-contents (concat "/tmp/esrc/" (car files) ".rtl")) | ||
| 127 | (while (re-search-forward ";; Function \\|(call_insn " nil t) | ||
| 128 | (if (= (char-after (- (point) 3)) ?o) | ||
| 129 | (progn | ||
| 130 | (looking-at "[a-zA-Z0-9_]+") | ||
| 131 | (setq name (intern (buffer-substring (match-beginning 0) | ||
| 132 | (match-end 0)))) | ||
| 133 | (message "%s : %s" (car files) name) | ||
| 134 | (setq entry (list name) | ||
| 135 | find-gc-subrs-called (cons entry find-gc-subrs-called))) | ||
| 136 | (if (looking-at ".*\n?.*\"\\([A-Za-z0-9_]+\\)\"") | ||
| 137 | (progn | 126 | (progn |
| 138 | (setq name (intern (buffer-substring (match-beginning 1) | 127 | (looking-at "[a-zA-Z0-9_]+") |
| 139 | (match-end 1)))) | 128 | (setq name (intern (match-string 0))) |
| 140 | (or (memq name (cdr entry)) | 129 | (message "%s : %s" (car files) name) |
| 141 | (setcdr entry (cons name (cdr entry)))))))) | 130 | (setq entry (list name) |
| 142 | (delete-file (concat "/tmp/esrc/" (car files) ".rtl")) | 131 | find-gc-subrs-called |
| 143 | (setq files (cdr files))))) | 132 | (cons entry find-gc-subrs-called))) |
| 144 | ) | 133 | (if (looking-at ".*\n?.*\"\\([A-Za-z0-9_]+\\)\"") |
| 145 | 134 | (progn | |
| 135 | (setq name (intern (match-string 1))) | ||
| 136 | (or (memq name (cdr entry)) | ||
| 137 | (setcdr entry (cons name (cdr entry))))))))))))) | ||
| 146 | 138 | ||
| 147 | (defun trace-use-tree () | 139 | (defun trace-use-tree () |
| 148 | (setq find-gc-subrs-callers (mapcar 'list (mapcar 'car find-gc-subrs-called))) | 140 | (setq find-gc-subrs-callers (mapcar 'list (mapcar 'car find-gc-subrs-called))) |