Petr Hracek c88b79
diff --git a/lisp/emacs-lisp/find-gc.el b/lisp/emacs-lisp/find-gc.el
Petr Hracek c88b79
index 82b3e94..6bdb09d 100644
Petr Hracek c88b79
--- a/lisp/emacs-lisp/find-gc.el
Petr Hracek c88b79
+++ b/lisp/emacs-lisp/find-gc.el
Petr Hracek c88b79
@@ -23,14 +23,15 @@
Petr Hracek c88b79
 
Petr Hracek c88b79
 ;; Produce in find-gc-unsafe-list the set of all functions that may invoke GC.
Petr Hracek c88b79
 ;; This expects the Emacs sources to live in find-gc-source-directory.
Petr Hracek c88b79
-;; It creates a temporary working directory /tmp/esrc.
Petr Hracek c88b79
 
Petr Hracek c88b79
 ;;; Code:
Petr Hracek c88b79
 
Petr Hracek c88b79
 (defvar find-gc-unsafe-list nil
Petr Hracek c88b79
   "The list of unsafe functions is placed here by `find-gc-unsafe'.")
Petr Hracek c88b79
 
Petr Hracek c88b79
-(defvar find-gc-source-directory)
Petr Hracek c88b79
+(defvar find-gc-source-directory
Petr Hracek c88b79
+  (file-name-as-directory (expand-file-name "src" source-directory))
Petr Hracek c88b79
+  "Directory containing Emacs C sources.")
Petr Hracek c88b79
 
Petr Hracek c88b79
 (defvar find-gc-subrs-callers nil
Petr Hracek c88b79
   "Alist of users of subrs, from GC testing.
Petr Hracek c88b79
@@ -59,14 +60,14 @@ Each entry has the form (FUNCTION . FUNCTIONS-IT-CALLS).")
Petr Hracek c88b79
     "indent.c" "search.c" "regex.c" "undo.c"
Petr Hracek c88b79
     "alloc.c" "data.c" "doc.c" "editfns.c"
Petr Hracek c88b79
     "callint.c" "eval.c" "fns.c" "print.c" "lread.c"
Petr Hracek c88b79
-    "abbrev.c" "syntax.c" "unexcoff.c"
Petr Hracek c88b79
+    "syntax.c" "unexcoff.c"
Petr Hracek c88b79
     "bytecode.c" "process.c" "callproc.c" "doprnt.c"
Petr Hracek c88b79
-    "x11term.c" "x11fns.c"))
Petr Hracek c88b79
+    "xterm.c" "x11fns.c"))
Petr Hracek c88b79
 
Petr Hracek c88b79
 
Petr Hracek c88b79
 (defun find-gc-unsafe ()
Petr Hracek c88b79
   "Return a list of unsafe functions--that is, which can call GC.
Petr Hracek c88b79
-Also store it in `find-gc-unsafe'."
Petr Hracek c88b79
+Also store it in `find-gc-unsafe-list'."
Petr Hracek c88b79
   (trace-call-tree nil)
Petr Hracek c88b79
   (trace-use-tree)
Petr Hracek c88b79
   (find-unsafe-funcs 'Fgarbage_collect)
Petr Hracek c88b79
@@ -102,47 +103,38 @@ Also store it in `find-gc-unsafe'."
Petr Hracek c88b79
 
Petr Hracek c88b79
 
Petr Hracek c88b79
 
Petr Hracek c88b79
-(defun trace-call-tree (&optional already-setup)
Petr Hracek c88b79
+(defun trace-call-tree (&optional ignored)
Petr Hracek c88b79
   (message "Setting up directories...")
Petr Hracek c88b79
-  (or already-setup
Petr Hracek c88b79
-      (progn
Petr Hracek c88b79
-	;; Gee, wouldn't a built-in "system" function be handy here.
Petr Hracek c88b79
-	(call-process "csh" nil nil nil "-c" "rm -rf /tmp/esrc")
Petr Hracek c88b79
-	(call-process "csh" nil nil nil "-c" "mkdir /tmp/esrc")
Petr Hracek c88b79
-	(call-process "csh" nil nil nil "-c"
Petr Hracek c88b79
-		      (format "ln -s %s/*.[ch] /tmp/esrc"
Petr Hracek c88b79
-			      find-gc-source-directory))))
Petr Hracek c88b79
-  (with-current-buffer (get-buffer-create "*Trace Call Tree*")
Petr Hracek c88b79
-    (setq find-gc-subrs-called nil)
Petr Hracek c88b79
-    (let ((case-fold-search nil)
Petr Hracek c88b79
-	  (files find-gc-source-files)
Petr Hracek c88b79
-	  name entry)
Petr Hracek c88b79
-      (while files
Petr Hracek c88b79
-	(message "Compiling %s..." (car files))
Petr Hracek c88b79
-	(call-process "csh" nil nil nil "-c"
Petr Hracek c88b79
-		      (format "gcc -dr -c /tmp/esrc/%s -o /dev/null"
Petr Hracek c88b79
-			      (car files)))
Petr Hracek c88b79
-	(erase-buffer)
Petr Hracek c88b79
-	(insert-file-contents (concat "/tmp/esrc/" (car files) ".rtl"))
Petr Hracek c88b79
-	(while (re-search-forward ";; Function \\|(call_insn " nil t)
Petr Hracek c88b79
-	  (if (= (char-after (- (point) 3)) ?o)
Petr Hracek c88b79
-	      (progn
Petr Hracek c88b79
-		(looking-at "[a-zA-Z0-9_]+")
Petr Hracek c88b79
-		(setq name (intern (buffer-substring (match-beginning 0)
Petr Hracek c88b79
-						     (match-end 0))))
Petr Hracek c88b79
-		(message "%s : %s" (car files) name)
Petr Hracek c88b79
-		(setq entry (list name)
Petr Hracek c88b79
-		      find-gc-subrs-called (cons entry find-gc-subrs-called)))
Petr Hracek c88b79
-	    (if (looking-at ".*\n?.*\"\\([A-Za-z0-9_]+\\)\"")
Petr Hracek c88b79
-		(progn
Petr Hracek c88b79
-		  (setq name (intern (buffer-substring (match-beginning 1)
Petr Hracek c88b79
-						       (match-end 1))))
Petr Hracek c88b79
-		  (or (memq name (cdr entry))
Petr Hracek c88b79
-		      (setcdr entry (cons name (cdr entry))))))))
Petr Hracek c88b79
-	(delete-file (concat "/tmp/esrc/" (car files) ".rtl"))
Petr Hracek c88b79
-	(setq files (cdr files)))))
Petr Hracek c88b79
-)
Petr Hracek c88b79
-
Petr Hracek c88b79
+  (setq find-gc-subrs-called nil)
Petr Hracek c88b79
+  (let ((case-fold-search nil)
Petr Hracek c88b79
+       (default-directory find-gc-source-directory)
Petr Hracek c88b79
+       (files find-gc-source-files)
Petr Hracek c88b79
+       name entry rtlfile)
Petr Hracek c88b79
+    (dolist (file files)
Petr Hracek c88b79
+      (message "Compiling %s..." file)
Petr Hracek c88b79
+      (call-process "gcc" nil nil nil "-I" "." "-I" "../lib"
Petr Hracek c88b79
+                   "-fdump-rtl-expand" "-o" null-device "-c" file)
Petr Hracek c88b79
+      (setq rtlfile
Petr Hracek c88b79
+           (file-expand-wildcards (format "%s.*.expand" file) t))
Petr Hracek c88b79
+      (if (/= 1 (length rtlfile))
Petr Hracek c88b79
+         (message "Error compiling `%s'?" file)
Petr Hracek c88b79
+       (with-temp-buffer
Petr Hracek c88b79
+         (insert-file-contents (setq rtlfile (car rtlfile)))
Petr Hracek c88b79
+         (delete-file rtlfile)
Petr Hracek c88b79
+         (while (re-search-forward ";; Function \\|(call_insn " nil t)
Petr Hracek c88b79
+           (if (= (char-after (- (point) 3)) ?o)
Petr Hracek c88b79
+            (progn
Petr Hracek c88b79
+                 (looking-at "[a-zA-Z0-9_]+")
Petr Hracek c88b79
+                 (setq name (intern (match-string 0)))
Petr Hracek c88b79
+                 (message "%s : %s" (car files) name)
Petr Hracek c88b79
+                 (setq entry (list name)
Petr Hracek c88b79
+                       find-gc-subrs-called
Petr Hracek c88b79
+                       (cons entry find-gc-subrs-called)))
Petr Hracek c88b79
+             (if (looking-at ".*\n?.*\"\\([A-Za-z0-9_]+\\)\"")
Petr Hracek c88b79
+                 (progn
Petr Hracek c88b79
+                   (setq name (intern (match-string 1)))
Petr Hracek c88b79
+                   (or (memq name (cdr entry))
Petr Hracek c88b79
+                       (setcdr entry (cons name (cdr entry)))))))))))))
Petr Hracek c88b79
 
Petr Hracek c88b79
 (defun trace-use-tree ()
Petr Hracek c88b79
   (setq find-gc-subrs-callers (mapcar 'list (mapcar 'car find-gc-subrs-called)))