33# src/tools/find_typedef
44
55# This script attempts to find all typedef's in the postgres binaries
6- # by using 'nm' to report all typedef debugging symbols.
6+ # by using 'objdump' or local equivalent to print typedef debugging symbols.
7+ # We need this because pgindent needs a list of typedef names.
78#
8- # For this program to work, you must have compiled all binaries with
9+ # For this program to work, you must have compiled all code with
910# debugging symbols.
1011#
11- # This is run on Linux, so you may need to make changes.
12+ # We intentionally examine all files in the targeted directories so as to
13+ # find both .o files and executables. Therefore, ignore error messages about
14+ # unsuitable files being fed to objdump.
1215#
13- # Ignore the nm errors about a file not being a binary file .
16+ # This is known to work on Linux and on some BSDen, including Mac OS X .
1417#
15- # It gets typedefs by reading "STABS":
18+ # Caution: on the platforms we use, this only prints typedefs that are used
19+ # to declare at least one variable or struct field. If you have say
20+ # "typedef struct foo { ... } foo;", and then the structure is only ever
21+ # referenced as "struct foo", "foo" will not be reported as a typedef,
22+ # causing pgindent to indent the typedef definition oddly. This is not a
23+ # huge problem, since by definition there's just the one misindented line.
1624#
25+ # We get typedefs by reading "STABS":
1726# http://www.informatik.uni-frankfurt.de/doc/texi/stabs_toc.html
18- #
19- # objdump:
20- # -G, --stabs Display (in raw form) any STABS info in the file
21- #
22- # --stabs
23- # Display the contents of the .stab, .stab.index, and
24- # .stab.excl sections from an ELF file. This is only
25- # useful on systems (such as Solaris 2.0) in which
26- # .stab debugging symbol-table entries are carried in
27- # an ELF section. In most other file formats, debug-
28- # ging symbol-table entries are interleaved with
29- # linkage symbols, and are visible in the --syms out-
30- # put.
3127
3228
3329if [ " $# " -eq 0 -o ! -d " $1 " ]
@@ -39,11 +35,6 @@ for DIR
3935do # if objdump -W is recognized, only one line of error should appear
4036 if [ ` objdump -W 2>&1 | wc -l` -eq 1 ]
4137 then # Linux
42- # Unfortunately the Linux version doesn't show unreferenced typedefs.
43- # The problem is that they are still in the source code so should be
44- # indented properly. However, I think pgindent only cares about
45- # the typedef references, not the definitions, so I think it might
46- # be fine
4738 objdump -W " $DIR " /* |
4839 egrep -A3 ' \(DW_TAG_typedef\)' |
4940 awk ' $2 == "DW_AT_name" {print $NF}'
0 commit comments