Skip to content

Commit 8292c06

Browse files
committed
Add a README and Makefile recipe for Gen_dummy_probes.pl
Discussion: https://postgr.es/m/20210506035602.3akutfvvojngj3nb@alap3.anarazel.de
1 parent 9f989a8 commit 8292c06

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

src/backend/utils/Makefile

+10
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,16 @@ $(top_builddir)/src/include/utils/probes.h: probes.h
8888
cd '$(dir $@)' && rm -f $(notdir $@) && \
8989
$(LN_S) "../../../$(subdir)/probes.h" .
9090

91+
# Recipe for rebuilding the Perl version of Gen_dummy_probes
92+
# Nothing depends on it, so it will never be called unless explicitly requested
93+
# The last two lines of the recipe format the script according to our
94+
# standard and put back some blank lines for improved readability.
95+
Gen_dummy_probes.pl: Gen_dummy_probes.sed
96+
perl -ni -e ' print; exit if /^\$$0/;' $@
97+
s2p -f $< | sed -e 1,4d -e '/# #/d' -e '$$d' >> $@
98+
perltidy --profile=../../tools/pgindent/perltidyrc $@
99+
perl -pi -e '!$$lb && ( /^\t+#/ || /^# prototypes/ ) && print qq{\n};'\
100+
-e '$$lb = m/^\n/; ' $@
91101

92102
.PHONY: install-data
93103
install-data: errcodes.txt installdirs
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Generating dummy probes
2+
3+
If Postgres isn't configured with dtrace enabled, we need to generate
4+
dummy probes for the entries in probes.d, that do nothing.
5+
6+
This is accomplished in Unix via the sed script `Gen_dummy_probes.sed`. We
7+
used to use this in MSVC builds using the perl utility `psed`, which mimicked
8+
sed. However, that utility disappeared from Windows perl distributions and so
9+
we converted the sed script to a perl script to be used in MSVC builds.
10+
11+
We still keep the sed script as the authoritative source for generating
12+
these dummy probes because except on Windows perl is not a hard requirement
13+
when building from a tarball.
14+
15+
So, if you need to change the way dummy probes are generated, first change
16+
the sed script, and when it's working generate the perl script. This can
17+
be accomplished by using the perl utility s2p.
18+
19+
s2p is no longer part of the perl core, so it might not be on your system,
20+
but it is available on CPAN and also in many package systems. e.g.
21+
on Fedora it can be installed using `cpan App::s2p` or
22+
`dnf install perl-App-s2p`.
23+
24+
The Makefile contains a recipe for regenerating Gen_dummy_probes.pl, so all
25+
you need to do is once you have s2p installed is `make Gen_dummy_probes.pl`

0 commit comments

Comments
 (0)