index 1b0930ca358b921d99673aafc6a512e26749c6f0..26715777a3dec7a78f019f60367a55847cdd1d7b 100755 (executable)
#!/bin/sh
-# $PostgreSQL: pgsql/src/tools/find_typedef,v 1.8 2007年12月21日 21:02:41 momjian Exp $
+# $PostgreSQL: pgsql/src/tools/find_typedef,v 1.9 2008年03月18日 22:45:11 momjian Exp $
# 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, so you may need to make changes.
+# This is run on BSD/OS 4.0 or Linux, so you may need to make changes.
#
# Ignore the nm errors about a file not being a binary file.
#
for DIR
do
- objdump --stabs "$DIR"/* |
- awk ' 2ドル == "LSYM" && 7ドル ~ /:[tT]/ {sub(":.*", "", 7ドル); print 7ドル}' |
- grep -v ' ' # some typedefs have spaces, remove them
+ 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
sort |
uniq |
# these are used both for typedefs and variable names