3 # $PostgreSQL: pgsql/src/tools/find_typedef,v 1.9 2008/03/18 22:45:11 momjian Exp $
5 # This script attempts to find all typedef's in the postgres binaries
6 # by using 'nm' to report all typedef debugging symbols.
8 # For this program to work, you must have compiled all binaries with
11 # This is run on BSD/OS 4.0 or Linux, so you may need to make changes.
13 # Ignore the nm errors about a file not being a binary file.
15 # It gets typedefs by reading "STABS":
17 # http://www.informatik.uni-frankfurt.de/doc/texi/stabs_toc.html
20 # -G, --stabs Display (in raw form) any STABS info in the file
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-
33 if [ "$#" -eq 0 -o ! -d "$1" ]
34 then echo "Usage: $0 postgres_binary_directory [...]" 1>&2
40 if [ `objdump -W 2>&1 | wc -l` -eq 1 ]
42 # unfortunately the Linux version doesn't show unreferenced typedefs
44 egrep -A3 '(DW_TAG_typedef|DW_TAG_structure_type|DW_TAG_union_type)' |
45 awk ' $2 == "DW_AT_name" {print $NF}'
47 objdump --stabs "$DIR"/* |
48 awk ' $2 == "LSYM" && $7 ~ /:[tT]/ {sub(":.*", "", $7); print $7}'
51 grep -v ' ' | # some typedefs have spaces, remove them
54 # these are used both for typedefs and variable names
55 # so do not include them
56 egrep -v '^(date|interval|timestamp|ANY)$'