1 ;; Verify that preprocessor symbols are defined in config.in.
3 ;; Copyright (C) 2020-2023 Free Software Foundation, Inc.
5 ;; This file is part of GDB.
7 ;; This program is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 3 of the License, or
10 ;; (at your option) any later version.
12 ;; This program is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
22 ;; emacs --script check-defines.el
26 (setq-default case-fold-search nil
)
28 ;; The currently recognized macros.
29 (defconst check-regexp
"\\_<\\(\\(HAVE\\|PTRACE_TYPE\\|SIZEOF\\)_[a-zA-Z0-9_]+\\)\\_>")
33 ;; Whitelist. These are things that have names like autoconf-created
34 ;; macros, but that are managed directly in the code.
35 (put (intern "HAVE_USEFUL_SBRK") :check-ok t
)
36 (put (intern "HAVE_SOCKETS") :check-ok t
)
37 (put (intern "HAVE_F_GETFD") :check-ok t
)
38 (put (intern "HAVE_IS_TRIVIALLY_COPYABLE") :check-ok t
)
39 (put (intern "HAVE_IS_TRIVIALLY_CONSTRUCTIBLE") :check-ok t
)
40 (put (intern "HAVE_DOS_BASED_FILE_SYSTEM") :check-ok t
)
42 (defun check-read-config.in
(file)
44 (find-file-read-only file
)
45 (goto-char (point-min))
46 (while (re-search-forward "^#undef \\(.+\\)$" nil t
)
47 (let ((name (match-string 1)))
48 (put (intern name
) :check-ok t
)))))
50 (defun check-one-file (file)
52 (find-file-read-only file
)
53 (goto-char (point-min))
54 (while (re-search-forward check-regexp nil t
)
55 (let ((name (match-string 1)))
56 (unless (get (intern name
) :check-ok
)
58 (goto-char (match-beginning 0))
60 (message "%s:%d:%d: error: name %s not defined"
66 (defun check-directory (dir)
67 (dolist (file (directory-files dir t
"\\.[ch]$"))
68 (check-one-file file
)))
70 (check-read-config.in
"config.in")
71 (check-read-config.in
"../gnulib/config.in")
73 (check-directory "../gdb/nat")
74 (check-directory "../gdb/target")
76 (when (> check-seen
0)
77 (message "%d errors seen" check-seen
))