summaryrefslogtreecommitdiffstats
path: root/src/tools/find_static
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 12:15:05 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 12:15:05 +0000
commit46651ce6fe013220ed397add242004d764fc0153 (patch)
tree6e5299f990f88e60174a1d3ae6e48eedd2688b2b /src/tools/find_static
parentInitial commit. (diff)
downloadpostgresql-14-46651ce6fe013220ed397add242004d764fc0153.tar.xz
postgresql-14-46651ce6fe013220ed397add242004d764fc0153.zip
Adding upstream version 14.5.upstream/14.5upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/find_static')
-rwxr-xr-xsrc/tools/find_static50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/tools/find_static b/src/tools/find_static
new file mode 100755
index 0000000..1cc9ec3
--- /dev/null
+++ b/src/tools/find_static
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+# src/tools/find_static
+
+trap "rm -f /tmp/$$" 0 1 2 3 15
+
+# This script finds functions that are either never called, or
+# should be static.
+# Some functions, like library functions and debug_print functions,
+# should remain unchanged.
+
+# Run on a compiled source tree, from the top of the source tree
+
+# My nm utility has 9 characters of address which I strip, then a 'type'
+# character, with T as a text function, and U as an undefined function
+# symbol, then the function name.
+
+find . -name '[a-z]*.o' -type f -print | while read FILE
+do nm $FILE | cut -c17-100 |awk '{printf "%s\t%s\t%s\n", "'"$FILE"'",$1,$2}'
+done >/tmp/$$
+dropdb debug
+createdb debug
+echo "
+ create table debug (file text, scope char, func text);
+
+ copy debug from '/tmp/"$$"';
+
+ select *
+ into table debug2
+ from debug;
+
+ create index idebug on debug(scope,func);
+ create index idebug2 on debug2(func,scope);
+ vacuum debug;
+ vacuum debug2;
+
+ update debug2
+ set scope = '_'
+ from debug
+ where debug2.func = debug.func and
+ debug2.scope = 'T' and debug.scope = 'U';
+
+ delete from debug2
+ where scope = '_';
+
+ select *
+ from debug2
+ where scope = 'T' and func != 'main'
+ order by file, func;
+" |psql -X debug