postgresql/src/tools/find_typedef

57 lines
1.8 KiB
Plaintext
Raw Normal View History

1997-09-08 06:14:01 +02:00
#!/bin/sh
# $PostgreSQL: pgsql/src/tools/find_typedef,v 1.9 2008/03/18 22:45:11 momjian Exp $
1997-09-08 06:14:01 +02:00
# This script attempts to find all typedef's in the postgres binaries
# by using 'nm' to report all typedef debugging symbols.
#
# For this program to work, you must have compiled all binaries with
# debugging symbols.
#
# This is run on BSD/OS 4.0 or Linux, so you may need to make changes.
1997-09-08 06:14:01 +02:00
#
# Ignore the nm errors about a file not being a binary file.
#
# It gets typedefs by reading "STABS":
1997-09-08 06:14:01 +02:00
#
# http://www.informatik.uni-frankfurt.de/doc/texi/stabs_toc.html
#
# objdump:
# -G, --stabs Display (in raw form) any STABS info in the file
#
# --stabs
# Display the contents of the .stab, .stab.index, and
# .stab.excl sections from an ELF file. This is only
# useful on systems (such as Solaris 2.0) in which
# .stab debugging symbol-table entries are carried in
# an ELF section. In most other file formats, debug-
# ging symbol-table entries are interleaved with
# linkage symbols, and are visible in the --syms out-
# put.
1997-09-08 06:14:01 +02:00
if [ "$#" -eq 0 -o ! -d "$1" ]
then echo "Usage: $0 postgres_binary_directory [...]" 1>&2
1997-09-08 06:14:01 +02:00
exit 1
fi
for DIR
do
if [ `objdump -W 2>&1 | wc -l` -eq 1 ]
then # Linux
# unfortunately the Linux version doesn't show unreferenced typedefs
objdump -W "$DIR"/* |
egrep -A3 '(DW_TAG_typedef|DW_TAG_structure_type|DW_TAG_union_type)' |
awk ' $2 == "DW_AT_name" {print $NF}'
else # BSD/OS
objdump --stabs "$DIR"/* |
awk ' $2 == "LSYM" && $7 ~ /:[tT]/ {sub(":.*", "", $7); print $7}'
fi
done |
grep -v ' ' | # some typedefs have spaces, remove them
1999-02-10 18:14:32 +01:00
sort |
uniq |
# these are used both for typedefs and variable names
# so do not include them
egrep -v '^(date|interval|timestamp|ANY)$'