annotate lisp/emacs-lisp/find-gc.el @ 92937:9b852833cd26

(emacs-lisp-mode-map): Add menu entries for checkdoc and profiling.
author Dan Nicolaescu <dann@ics.uci.edu>
date Fri, 14 Mar 2008 16:09:39 +0000
parents 78ee6fae0e41
children 606f2d163a64 1e3a407766b9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
39027
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1 ;;; find-gc.el --- detect functions that call the garbage collector
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2
74466
1d4b1a32fd66 Update copyright years.
Glenn Morris <rgm@gnu.org>
parents: 68648
diff changeset
3 ;; Copyright (C) 1992, 2001, 2002, 2003, 2004, 2005,
79704
78ee6fae0e41 Add 2008 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 78217
diff changeset
4 ;; 2006, 2007, 2008 Free Software Foundation, Inc.
39027
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
5
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
6 ;; Maintainer: FSF
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
7
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
9
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
78217
935157c0b596 Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents: 75346
diff changeset
12 ;; the Free Software Foundation; either version 3, or (at your option)
39027
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
13 ;; any later version.
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
14
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
19
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
64085
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 52401
diff changeset
22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 52401
diff changeset
23 ;; Boston, MA 02110-1301, USA.
39027
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
24
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
25 ;;; Commentary:
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
26
64380
ce8784010c3c (find-gc-unsafe-list, find-gc-source-directory, find-gc-subrs-used)
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
27 ;; Produce in find-gc-unsafe-list the set of all functions that may invoke GC.
ce8784010c3c (find-gc-unsafe-list, find-gc-source-directory, find-gc-subrs-used)
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
28 ;; This expects the Emacs sources to live in find-gc-source-directory.
39027
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
29 ;; It creates a temporary working directory /tmp/esrc.
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
30
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
31 ;;; Code:
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
32
64380
ce8784010c3c (find-gc-unsafe-list, find-gc-source-directory, find-gc-subrs-used)
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
33 (defvar find-gc-unsafe-list nil
ce8784010c3c (find-gc-unsafe-list, find-gc-source-directory, find-gc-subrs-used)
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
34 "The list of unsafe functions is placed here by `find-gc-unsafe'.")
ce8784010c3c (find-gc-unsafe-list, find-gc-source-directory, find-gc-subrs-used)
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
35
ce8784010c3c (find-gc-unsafe-list, find-gc-source-directory, find-gc-subrs-used)
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
36 (defvar find-gc-source-directory)
ce8784010c3c (find-gc-unsafe-list, find-gc-source-directory, find-gc-subrs-used)
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
37
64403
db69241fec2b (find-gc-subrs-callers): Renamed from find-gc-subrs-used.
Richard M. Stallman <rms@gnu.org>
parents: 64380
diff changeset
38 (defvar find-gc-subrs-callers nil
db69241fec2b (find-gc-subrs-callers): Renamed from find-gc-subrs-used.
Richard M. Stallman <rms@gnu.org>
parents: 64380
diff changeset
39 "Alist of users of subrs, from GC testing.
db69241fec2b (find-gc-subrs-callers): Renamed from find-gc-subrs-used.
Richard M. Stallman <rms@gnu.org>
parents: 64380
diff changeset
40 Each entry has the form (FUNCTION . FUNCTIONS-THAT-CALL-IT).")
db69241fec2b (find-gc-subrs-callers): Renamed from find-gc-subrs-used.
Richard M. Stallman <rms@gnu.org>
parents: 64380
diff changeset
41
db69241fec2b (find-gc-subrs-callers): Renamed from find-gc-subrs-used.
Richard M. Stallman <rms@gnu.org>
parents: 64380
diff changeset
42 (defvar find-gc-subrs-called nil
db69241fec2b (find-gc-subrs-callers): Renamed from find-gc-subrs-used.
Richard M. Stallman <rms@gnu.org>
parents: 64380
diff changeset
43 "Alist of subrs called, in GC testing.
db69241fec2b (find-gc-subrs-callers): Renamed from find-gc-subrs-used.
Richard M. Stallman <rms@gnu.org>
parents: 64380
diff changeset
44 Each entry has the form (FUNCTION . FUNCTIONS-IT-CALLS).")
db69241fec2b (find-gc-subrs-callers): Renamed from find-gc-subrs-used.
Richard M. Stallman <rms@gnu.org>
parents: 64380
diff changeset
45
64380
ce8784010c3c (find-gc-unsafe-list, find-gc-source-directory, find-gc-subrs-used)
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
46
ce8784010c3c (find-gc-unsafe-list, find-gc-source-directory, find-gc-subrs-used)
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
47 ;;; Functions on this list are safe, even if they appear to be able
ce8784010c3c (find-gc-unsafe-list, find-gc-source-directory, find-gc-subrs-used)
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
48 ;;; to call the target.
ce8784010c3c (find-gc-unsafe-list, find-gc-source-directory, find-gc-subrs-used)
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
49
ce8784010c3c (find-gc-unsafe-list, find-gc-source-directory, find-gc-subrs-used)
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
50 (defvar find-gc-noreturn-list '(Fsignal Fthrow wrong_type_argument))
ce8784010c3c (find-gc-unsafe-list, find-gc-source-directory, find-gc-subrs-used)
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
51
ce8784010c3c (find-gc-unsafe-list, find-gc-source-directory, find-gc-subrs-used)
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
52 ;;; This was originally generated directory-files, but there were
ce8784010c3c (find-gc-unsafe-list, find-gc-source-directory, find-gc-subrs-used)
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
53 ;;; too many files there that were not actually compiled. The
ce8784010c3c (find-gc-unsafe-list, find-gc-source-directory, find-gc-subrs-used)
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
54 ;;; list below was created for a HP-UX 7.0 system.
ce8784010c3c (find-gc-unsafe-list, find-gc-source-directory, find-gc-subrs-used)
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
55
ce8784010c3c (find-gc-unsafe-list, find-gc-source-directory, find-gc-subrs-used)
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
56 (defvar find-gc-source-files
ce8784010c3c (find-gc-unsafe-list, find-gc-source-directory, find-gc-subrs-used)
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
57 '("dispnew.c" "scroll.c" "xdisp.c" "window.c"
ce8784010c3c (find-gc-unsafe-list, find-gc-source-directory, find-gc-subrs-used)
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
58 "term.c" "cm.c" "emacs.c" "keyboard.c" "macros.c"
ce8784010c3c (find-gc-unsafe-list, find-gc-source-directory, find-gc-subrs-used)
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
59 "keymap.c" "sysdep.c" "buffer.c" "filelock.c"
ce8784010c3c (find-gc-unsafe-list, find-gc-source-directory, find-gc-subrs-used)
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
60 "insdel.c" "marker.c" "minibuf.c" "fileio.c"
ce8784010c3c (find-gc-unsafe-list, find-gc-source-directory, find-gc-subrs-used)
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
61 "dired.c" "filemode.c" "cmds.c" "casefiddle.c"
ce8784010c3c (find-gc-unsafe-list, find-gc-source-directory, find-gc-subrs-used)
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
62 "indent.c" "search.c" "regex.c" "undo.c"
ce8784010c3c (find-gc-unsafe-list, find-gc-source-directory, find-gc-subrs-used)
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
63 "alloc.c" "data.c" "doc.c" "editfns.c"
ce8784010c3c (find-gc-unsafe-list, find-gc-source-directory, find-gc-subrs-used)
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
64 "callint.c" "eval.c" "fns.c" "print.c" "lread.c"
ce8784010c3c (find-gc-unsafe-list, find-gc-source-directory, find-gc-subrs-used)
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
65 "abbrev.c" "syntax.c" "unexec.c"
ce8784010c3c (find-gc-unsafe-list, find-gc-source-directory, find-gc-subrs-used)
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
66 "bytecode.c" "process.c" "callproc.c" "doprnt.c"
ce8784010c3c (find-gc-unsafe-list, find-gc-source-directory, find-gc-subrs-used)
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
67 "x11term.c" "x11fns.c"))
ce8784010c3c (find-gc-unsafe-list, find-gc-source-directory, find-gc-subrs-used)
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
68
ce8784010c3c (find-gc-unsafe-list, find-gc-source-directory, find-gc-subrs-used)
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
69
39027
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
70 (defun find-gc-unsafe ()
64380
ce8784010c3c (find-gc-unsafe-list, find-gc-source-directory, find-gc-subrs-used)
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
71 "Return a list of unsafe functions--that is, which can call GC.
ce8784010c3c (find-gc-unsafe-list, find-gc-source-directory, find-gc-subrs-used)
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
72 Also store it in `find-gc-unsafe'."
39027
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
73 (trace-call-tree nil)
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
74 (trace-use-tree)
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
75 (find-unsafe-funcs 'Fgarbage_collect)
64380
ce8784010c3c (find-gc-unsafe-list, find-gc-source-directory, find-gc-subrs-used)
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
76 (setq find-gc-unsafe-list
ce8784010c3c (find-gc-unsafe-list, find-gc-source-directory, find-gc-subrs-used)
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
77 (sort find-gc-unsafe-list
ce8784010c3c (find-gc-unsafe-list, find-gc-source-directory, find-gc-subrs-used)
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
78 (function (lambda (x y)
ce8784010c3c (find-gc-unsafe-list, find-gc-source-directory, find-gc-subrs-used)
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
79 (string-lessp (car x) (car y))))))
39027
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
80 )
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
81
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
82 ;;; This does a depth-first search to find all functions that can
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
83 ;;; ultimately call the function "target". The result is an a-list
64380
ce8784010c3c (find-gc-unsafe-list, find-gc-source-directory, find-gc-subrs-used)
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
84 ;;; in find-gc-unsafe-list; the cars are the unsafe functions, and the cdrs
39027
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
85 ;;; are (one of) the unsafe functions that these functions directly
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
86 ;;; call.
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
87
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
88 (defun find-unsafe-funcs (target)
64380
ce8784010c3c (find-gc-unsafe-list, find-gc-source-directory, find-gc-subrs-used)
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
89 (setq find-gc-unsafe-list (list (list target)))
39027
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
90 (trace-unsafe target)
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
91 )
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
92
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
93 (defun trace-unsafe (func)
64403
db69241fec2b (find-gc-subrs-callers): Renamed from find-gc-subrs-used.
Richard M. Stallman <rms@gnu.org>
parents: 64380
diff changeset
94 (let ((used (assq func find-gc-subrs-callers)))
39027
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
95 (or used
64403
db69241fec2b (find-gc-subrs-callers): Renamed from find-gc-subrs-used.
Richard M. Stallman <rms@gnu.org>
parents: 64380
diff changeset
96 (error "No find-gc-subrs-callers for %s" (car find-gc-unsafe-list)))
39027
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
97 (while (setq used (cdr used))
64380
ce8784010c3c (find-gc-unsafe-list, find-gc-source-directory, find-gc-subrs-used)
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
98 (or (assq (car used) find-gc-unsafe-list)
ce8784010c3c (find-gc-unsafe-list, find-gc-source-directory, find-gc-subrs-used)
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
99 (memq (car used) find-gc-noreturn-list)
39027
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
100 (progn
64380
ce8784010c3c (find-gc-unsafe-list, find-gc-source-directory, find-gc-subrs-used)
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
101 (push (cons (car used) func) find-gc-unsafe-list)
39027
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
102 (trace-unsafe (car used))))))
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
103 )
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
104
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
105
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
106
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
107
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
108 (defun trace-call-tree (&optional already-setup)
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
109 (message "Setting up directories...")
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
110 (or already-setup
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
111 (progn
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
112 ;; Gee, wouldn't a built-in "system" function be handy here.
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
113 (call-process "csh" nil nil nil "-c" "rm -rf /tmp/esrc")
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
114 (call-process "csh" nil nil nil "-c" "mkdir /tmp/esrc")
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
115 (call-process "csh" nil nil nil "-c"
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
116 (format "ln -s %s/*.[ch] /tmp/esrc"
64380
ce8784010c3c (find-gc-unsafe-list, find-gc-source-directory, find-gc-subrs-used)
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
117 find-gc-source-directory))))
39027
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
118 (save-excursion
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
119 (set-buffer (get-buffer-create "*Trace Call Tree*"))
64403
db69241fec2b (find-gc-subrs-callers): Renamed from find-gc-subrs-used.
Richard M. Stallman <rms@gnu.org>
parents: 64380
diff changeset
120 (setq find-gc-subrs-called nil)
39027
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
121 (let ((case-fold-search nil)
64380
ce8784010c3c (find-gc-unsafe-list, find-gc-source-directory, find-gc-subrs-used)
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
122 (files find-gc-source-files)
39027
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
123 name entry)
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
124 (while files
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
125 (message "Compiling %s..." (car files))
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
126 (call-process "csh" nil nil nil "-c"
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
127 (format "gcc -dr -c /tmp/esrc/%s -o /dev/null"
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
128 (car files)))
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
129 (erase-buffer)
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
130 (insert-file-contents (concat "/tmp/esrc/" (car files) ".rtl"))
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
131 (while (re-search-forward ";; Function \\|(call_insn " nil t)
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
132 (if (= (char-after (- (point) 3)) ?o)
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
133 (progn
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
134 (looking-at "[a-zA-Z0-9_]+")
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
135 (setq name (intern (buffer-substring (match-beginning 0)
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
136 (match-end 0))))
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
137 (message "%s : %s" (car files) name)
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
138 (setq entry (list name)
64403
db69241fec2b (find-gc-subrs-callers): Renamed from find-gc-subrs-used.
Richard M. Stallman <rms@gnu.org>
parents: 64380
diff changeset
139 find-gc-subrs-called (cons entry find-gc-subrs-called)))
39027
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
140 (if (looking-at ".*\n?.*\"\\([A-Za-z0-9_]+\\)\"")
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
141 (progn
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
142 (setq name (intern (buffer-substring (match-beginning 1)
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
143 (match-end 1))))
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
144 (or (memq name (cdr entry))
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
145 (setcdr entry (cons name (cdr entry))))))))
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
146 (delete-file (concat "/tmp/esrc/" (car files) ".rtl"))
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
147 (setq files (cdr files)))))
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
148 )
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
149
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
150
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
151 (defun trace-use-tree ()
64403
db69241fec2b (find-gc-subrs-callers): Renamed from find-gc-subrs-used.
Richard M. Stallman <rms@gnu.org>
parents: 64380
diff changeset
152 (setq find-gc-subrs-callers (mapcar 'list (mapcar 'car find-gc-subrs-called)))
db69241fec2b (find-gc-subrs-callers): Renamed from find-gc-subrs-used.
Richard M. Stallman <rms@gnu.org>
parents: 64380
diff changeset
153 (let ((ptr find-gc-subrs-called)
39027
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
154 p2 found)
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
155 (while ptr
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
156 (setq p2 (car ptr))
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
157 (while (setq p2 (cdr p2))
64403
db69241fec2b (find-gc-subrs-callers): Renamed from find-gc-subrs-used.
Richard M. Stallman <rms@gnu.org>
parents: 64380
diff changeset
158 (if (setq found (assq (car p2) find-gc-subrs-callers))
39027
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
159 (setcdr found (cons (car (car ptr)) (cdr found)))))
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
160 (setq ptr (cdr ptr))))
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
161 )
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
162
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
163 (provide 'find-gc)
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
164
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 42269
diff changeset
165 ;;; arch-tag: 4a26a538-a008-40d9-a1ef-23bb6dbecef4
39027
d5b2cd9aadf2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
166 ;;; find-gc.el ends here