Skip to content

Commit 61d416e

Browse files
committed
Add Linux support to find_typedefs, with help from Alvaro.
1 parent 0d49838 commit 61d416e

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/tools/find_typedef

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#!/bin/sh
22

3-
# $PostgreSQL: pgsql/src/tools/find_typedef,v 1.8 2007/12/21 21:02:41 momjian Exp $
3+
# $PostgreSQL: pgsql/src/tools/find_typedef,v 1.9 2008/03/18 22:45:11 momjian Exp $
44

55
# This script attempts to find all typedef's in the postgres binaries
66
# by using 'nm' to report all typedef debugging symbols.
77
#
88
# For this program to work, you must have compiled all binaries with
99
# debugging symbols.
1010
#
11-
# This is run on BSD/OS 4.0, so you may need to make changes.
11+
# This is run on BSD/OS 4.0 or Linux, so you may need to make changes.
1212
#
1313
# Ignore the nm errors about a file not being a binary file.
1414
#
@@ -37,10 +37,18 @@ fi
3737

3838
for DIR
3939
do
40-
objdump --stabs "$DIR"/* |
41-
awk ' $2 == "LSYM" && $7 ~ /:[tT]/ {sub(":.*", "", $7); print $7}' |
42-
grep -v ' ' # some typedefs have spaces, remove them
40+
if [ `objdump -W 2>&1 | wc -l` -eq 1 ]
41+
then # Linux
42+
# unfortunately the Linux version doesn't show unreferenced typedefs
43+
objdump -W "$DIR"/* |
44+
egrep -A3 '(DW_TAG_typedef|DW_TAG_structure_type|DW_TAG_union_type)' |
45+
awk ' $2 == "DW_AT_name" {print $NF}'
46+
else # BSD/OS
47+
objdump --stabs "$DIR"/* |
48+
awk ' $2 == "LSYM" && $7 ~ /:[tT]/ {sub(":.*", "", $7); print $7}'
49+
fi
4350
done |
51+
grep -v ' ' | # some typedefs have spaces, remove them
4452
sort |
4553
uniq |
4654
# these are used both for typedefs and variable names

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy