1
0
mirror of https://github.com/postgres/postgres.git synced 2025-10-16 17:07:43 +03:00
Files
postgres/src/tools/find_static
Alvaro Herrera 3d53b9ef1a Fix trap in a few shell scripts
The original `trap` lines in these scripts are incomplete: in case of
any signal, they delete the working directory but let the script run to
completion, which is useless because it will only proceed to complain
about the working directory being removed.  Add `exit` there, with the
original exit value (not rm's).

Since this is mostly just cosmetic, no backpatch.

Discussion: https://postgr.es/m/20220913181002.hzsosy7qkemb7ky7@alvherre.pgsql
2022-09-20 18:50:16 +02:00

51 lines
1.2 KiB
Bash
Executable File

#!/bin/sh
# src/tools/find_static
trap "ret=$?; rm -rf /tmp/$$; exit $ret" 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