Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita7b7b07

Browse files
committed
Enable probes to work with Mac OS X Leopard and other OSes that will
support DTrace in the future.Switch from using DTRACE_PROBEn macros to the dynamically generated macros.Use "dtrace -h" to create a header file that contains the dynamicallygenerated macros to be used in the source code instead of the DTRACE_PROBEnmacros. A dummy header file is generated for builds without DTrace support.Author: Robert Lor <Robert.Lor@sun.com>
1 parente7115a2 commita7b7b07

File tree

9 files changed

+64
-62
lines changed

9 files changed

+64
-62
lines changed

‎src/backend/Makefile

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
66
# Portions Copyright (c) 1994, Regents of the University of California
77
#
8-
# $PostgreSQL: pgsql/src/backend/Makefile,v 1.127 2008/02/26 14:42:27 petere Exp $
8+
# $PostgreSQL: pgsql/src/backend/Makefile,v 1.128 2008/03/17 19:44:40 petere Exp $
99
#
1010
#-------------------------------------------------------------------------
1111

@@ -20,9 +20,11 @@ SUBDIRS = access bootstrap catalog parser commands executor lib libpq \
2020

2121
include$(srcdir)/common.mk
2222

23+
ifeq ($(PORTNAME), solaris)
2324
ifeq ($(enable_dtrace), yes)
2425
LOCALOBJS += utils/probes.o
2526
endif
27+
endif
2628

2729
OBJS =$(SUBDIROBJS)$(LOCALOBJS)$(top_builddir)/src/port/libpgport_srv.a
2830

@@ -103,7 +105,7 @@ endif
103105
endif# aix
104106

105107
# Update the commonly used headers before building the subdirectories
106-
$(SUBDIRS:%=%-recursive):$(top_builddir)/src/include/parser/parse.h$(top_builddir)/src/include/utils/fmgroids.h
108+
$(SUBDIRS:%=%-recursive):$(top_builddir)/src/include/parser/parse.h$(top_builddir)/src/include/utils/fmgroids.h$(top_builddir)/src/include/utils/probes.h
107109

108110

109111
# The postgres.o target is needed by the rule in Makefile.global that
@@ -122,6 +124,9 @@ $(srcdir)/parser/parse.h: parser/gram.y
122124
utils/fmgroids.h: utils/Gen_fmgrtab.sh$(top_srcdir)/src/include/catalog/pg_proc.h
123125
$(MAKE) -C utils fmgroids.h
124126

127+
utils/probes.h: utils/probes.d
128+
$(MAKE) -C utils probes.h
129+
125130
# Make symlinks for these headers in the include directory. That way
126131
# we can cut down on the -I options. Also, a symlink is automatically
127132
# up to date when we update the base file.
@@ -135,9 +140,15 @@ $(top_builddir)/src/include/utils/fmgroids.h: utils/fmgroids.h
135140
cd$(dir$@)&& rm -f$(notdir$@)&&\
136141
$(LN_S) ../../../$(subdir)/utils/fmgroids.h.
137142

143+
$(top_builddir)/src/include/utils/probes.h: utils/probes.h
144+
cd$(dir$@)&& rm -f$(notdir$@)&&\
145+
$(LN_S) ../../../$(subdir)/utils/probes.h.
138146

147+
148+
ifeq ($(PORTNAME), solaris)
139149
utils/probes.o: utils/probes.d$(SUBDIROBJS)
140150
$(DTRACE)$(DTRACEFLAGS) -G -s$(call expand_subsys,$^) -o$@
151+
endif
141152

142153

143154
##########################################################################

‎src/backend/access/transam/xact.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.259 2008/03/1702:18:55 tgl Exp $
13+
* $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.260 2008/03/1719:44:41 petere Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -46,6 +46,7 @@
4646
#include"utils/memutils.h"
4747
#include"utils/relcache.h"
4848
#include"utils/xml.h"
49+
#include"pg_trace.h"
4950

5051

5152
/*
@@ -1547,7 +1548,7 @@ StartTransaction(void)
15471548
Assert(MyProc->backendId==vxid.backendId);
15481549
MyProc->lxid=vxid.localTransactionId;
15491550

1550-
PG_TRACE1(transaction__start,vxid.localTransactionId);
1551+
TRACE_POSTGRESQL_TRANSACTION_START(vxid.localTransactionId);
15511552

15521553
/*
15531554
* set transaction_timestamp() (a/k/a now()). We want this to be the same
@@ -1674,7 +1675,7 @@ CommitTransaction(void)
16741675
*/
16751676
latestXid=RecordTransactionCommit();
16761677

1677-
PG_TRACE1(transaction__commit,MyProc->lxid);
1678+
TRACE_POSTGRESQL_TRANSACTION_COMMIT(MyProc->lxid);
16781679

16791680
/*
16801681
* Let others know about no transaction in progress by me. Note that this
@@ -2084,7 +2085,7 @@ AbortTransaction(void)
20842085
*/
20852086
latestXid=RecordTransactionAbort(false);
20862087

2087-
PG_TRACE1(transaction__abort,MyProc->lxid);
2088+
TRACE_POSTGRESQL_TRANSACTION_ABORT(MyProc->lxid);
20882089

20892090
/*
20902091
* Let others know about no transaction in progress by me. Note that this

‎src/backend/storage/lmgr/lock.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lock.c,v 1.182 2008/03/04 19:54:06 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lock.c,v 1.183 2008/03/17 19:44:41 petere Exp $
1212
*
1313
* NOTES
1414
* A lock table is a shared memory hash table. When
@@ -40,6 +40,7 @@
4040
#include"utils/memutils.h"
4141
#include"utils/ps_status.h"
4242
#include"utils/resowner.h"
43+
#include"pg_trace.h"
4344

4445

4546
/* This configuration variable is used to set the lock table size */
@@ -786,11 +787,11 @@ LockAcquire(const LOCKTAG *locktag,
786787
* Sleep till someone wakes me up.
787788
*/
788789

789-
PG_TRACE2(lock__startwait,locktag->locktag_field2,lockmode);
790+
TRACE_POSTGRESQL_LOCK_STARTWAIT(locktag->locktag_field2,lockmode);
790791

791792
WaitOnLock(locallock,owner);
792793

793-
PG_TRACE2(lock__endwait,locktag->locktag_field2,lockmode);
794+
TRACE_POSTGRESQL_LOCK_ENDWAIT(locktag->locktag_field2,lockmode);
794795

795796
/*
796797
* NOTE: do not do any material change of state between here and

‎src/backend/storage/lmgr/lwlock.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* Portions Copyright (c) 1994, Regents of the University of California
1616
*
1717
* IDENTIFICATION
18-
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lwlock.c,v 1.50 2008/01/01 19:45:52 momjian Exp $
18+
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lwlock.c,v 1.51 2008/03/17 19:44:41 petere Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -28,6 +28,7 @@
2828
#include"storage/ipc.h"
2929
#include"storage/proc.h"
3030
#include"storage/spin.h"
31+
#include"pg_trace.h"
3132

3233

3334
/* We use the ShmemLock spinlock to protect LWLockAssign */
@@ -447,7 +448,7 @@ LWLockAcquire(LWLockId lockid, LWLockMode mode)
447448
block_counts[lockid]++;
448449
#endif
449450

450-
PG_TRACE2(lwlock__startwait,lockid,mode);
451+
TRACE_POSTGRESQL_LWLOCK_STARTWAIT(lockid,mode);
451452

452453
for (;;)
453454
{
@@ -458,7 +459,7 @@ LWLockAcquire(LWLockId lockid, LWLockMode mode)
458459
extraWaits++;
459460
}
460461

461-
PG_TRACE2(lwlock__endwait,lockid,mode);
462+
TRACE_POSTGRESQL_LWLOCK_ENDWAIT(lockid,mode);
462463

463464
LOG_LWDEBUG("LWLockAcquire",lockid,"awakened");
464465

@@ -469,7 +470,7 @@ LWLockAcquire(LWLockId lockid, LWLockMode mode)
469470
/* We are done updating shared state of the lock itself. */
470471
SpinLockRelease(&lock->mutex);
471472

472-
PG_TRACE2(lwlock__acquire,lockid,mode);
473+
TRACE_POSTGRESQL_LWLOCK_ACQUIRE(lockid,mode);
473474

474475
/* Add lock to list of locks held by this backend */
475476
held_lwlocks[num_held_lwlocks++]=lockid;
@@ -540,13 +541,13 @@ LWLockConditionalAcquire(LWLockId lockid, LWLockMode mode)
540541
/* Failed to get lock, so release interrupt holdoff */
541542
RESUME_INTERRUPTS();
542543
LOG_LWDEBUG("LWLockConditionalAcquire",lockid,"failed");
543-
PG_TRACE2(lwlock__condacquire__fail,lockid,mode);
544+
TRACE_POSTGRESQL_LWLOCK_CONDACQUIRE_FAIL(lockid,mode);
544545
}
545546
else
546547
{
547548
/* Add lock to list of locks held by this backend */
548549
held_lwlocks[num_held_lwlocks++]=lockid;
549-
PG_TRACE2(lwlock__condacquire,lockid,mode);
550+
TRACE_POSTGRESQL_LWLOCK_CONDACQUIRE(lockid,mode);
550551
}
551552

552553
return !mustwait;
@@ -631,7 +632,7 @@ LWLockRelease(LWLockId lockid)
631632
/* We are done updating shared state of the lock itself. */
632633
SpinLockRelease(&lock->mutex);
633634

634-
PG_TRACE1(lwlock__release,lockid);
635+
TRACE_POSTGRESQL_LWLOCK_RELEASE(lockid);
635636

636637
/*
637638
* Awaken any waiters I removed from the queue.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#-------------------------------------------------------------------------
2+
# sed script to create dummy probes.h file when dtrace is not available
3+
#
4+
# Copyright (c) 2008, PostgreSQL Global Development Group
5+
#
6+
# $PostgreSQL: pgsql/src/backend/utils/Gen_dummy_probes.sed,v 1.1 2008/03/17 19:44:41 petere Exp $
7+
#-------------------------------------------------------------------------
8+
9+
/^probe/!d
10+
s/^probe\([^(]*\)\(.*\);/\1\2/
11+
s/__/_/g
12+
y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/
13+
s/^/#define TRACE_POSTGRESQL_/
14+
s/(INT, INT)/(INT1, INT2)/
15+
P
16+
s/(.*$/_ENABLED() (0)/

‎src/backend/utils/Makefile

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#
22
# Makefile for utils
33
#
4-
# $PostgreSQL: pgsql/src/backend/utils/Makefile,v 1.26 2008/02/19 10:30:08 petere Exp $
4+
# $PostgreSQL: pgsql/src/backend/utils/Makefile,v 1.27 2008/03/17 19:44:41 petere Exp $
55
#
66

77
subdir = src/backend/utils
@@ -13,12 +13,22 @@ SUBDIRS = adt cache error fmgr hash init mb misc mmgr resowner sort time
1313

1414
include$(top_srcdir)/src/backend/common.mk
1515

16-
all: fmgroids.h
16+
all: fmgroids.h probes.h
1717

1818
$(SUBDIRS:%=%-recursive): fmgroids.h
1919

2020
fmgroids.hfmgrtab.c: Gen_fmgrtab.sh$(top_srcdir)/src/include/catalog/pg_proc.h
2121
AWK='$(AWK)'$(SHELL)$<$(top_srcdir)/src/include/catalog/pg_proc.h
2222

23+
probes.h: probes.d
24+
ifeq ($(enable_dtrace), yes)
25+
$(DTRACE) -h -s $< -o $@.tmp
26+
sed -e 's/POSTGRESQL_/TRACE_POSTGRESQL_/g' $@.tmp >$@
27+
rm $@.tmp
28+
else
29+
sed -f $(srcdir)/Gen_dummy_probes.sed $< >$@
30+
endif
31+
32+
2333
clean:
24-
rm -f fmgroids.h fmgrtab.c
34+
rm -f fmgroids.h fmgrtab.c probes.h

‎src/include/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# 'make install' installs whole contents of src/include.
66
#
7-
# $PostgreSQL: pgsql/src/include/Makefile,v 1.23 2007/10/14 17:07:51 tgl Exp $
7+
# $PostgreSQL: pgsql/src/include/Makefile,v 1.24 2008/03/17 19:44:41 petere Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -60,7 +60,7 @@ uninstall:
6060

6161

6262
clean:
63-
rm -f utils/fmgroids.h parser/parse.h
63+
rm -f utils/fmgroids.h parser/parse.h utils/probes.h
6464

6565
distcleanmaintainer-clean: clean
6666
rm -f pg_config.h dynloader.h pg_config_os.h stamp-h

‎src/include/c.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
1313
* Portions Copyright (c) 1994, Regents of the University of California
1414
*
15-
* $PostgreSQL: pgsql/src/include/c.h,v 1.223 2008/02/23 19:11:45 tgl Exp $
15+
* $PostgreSQL: pgsql/src/include/c.h,v 1.224 2008/03/17 19:44:41 petere Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -57,7 +57,6 @@
5757
#include"pg_config_os.h"/* must be before any system header files */
5858
#endif
5959
#include"postgres_ext.h"
60-
#include"pg_trace.h"
6160

6261
#if_MSC_VER >=1400
6362
#defineerrcode __msvc_errcode

‎src/include/pg_trace.h

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,50 +5,13 @@
55
*
66
*Copyright (c) 2006-2008, PostgreSQL Global Development Group
77
*
8-
*$PostgreSQL: pgsql/src/include/pg_trace.h,v 1.3 2008/01/02 02:42:06 momjian Exp $
8+
*$PostgreSQL: pgsql/src/include/pg_trace.h,v 1.4 2008/03/17 19:44:41 petere Exp $
99
* ----------
1010
*/
1111

1212
#ifndefPG_TRACE_H
1313
#definePG_TRACE_H
1414

15-
#ifdefENABLE_DTRACE
16-
17-
#include<sys/sdt.h>
18-
19-
/*
20-
* The PG_TRACE macros are mapped to the appropriate macros used by DTrace.
21-
*
22-
* Only one DTrace provider called "postgresql" will be used for PostgreSQL,
23-
* so the name is hard-coded here to avoid having to specify it in the
24-
* source code.
25-
*/
26-
27-
#definePG_TRACE(name) \
28-
DTRACE_PROBE(postgresql, name)
29-
#definePG_TRACE1(name,arg1) \
30-
DTRACE_PROBE1(postgresql, name, arg1)
31-
#definePG_TRACE2(name,arg1,arg2) \
32-
DTRACE_PROBE2(postgresql, name, arg1, arg2)
33-
#definePG_TRACE3(name,arg1,arg2,arg3) \
34-
DTRACE_PROBE3(postgresql, name, arg1, arg2, arg3)
35-
#definePG_TRACE4(name,arg1,arg2,arg3,arg4) \
36-
DTRACE_PROBE4(postgresql, name, arg1, arg2, arg3, arg4)
37-
#definePG_TRACE5(name,arg1,arg2,arg3,arg4,arg5) \
38-
DTRACE_PROBE5(postgresql, name, arg1, arg2, arg3, arg4, arg5)
39-
#else/* not ENABLE_DTRACE */
40-
41-
/*
42-
* Unless DTrace is explicitly enabled with --enable-dtrace, the PG_TRACE
43-
* macros will expand to no-ops.
44-
*/
45-
46-
#definePG_TRACE(name)
47-
#definePG_TRACE1(name,arg1)
48-
#definePG_TRACE2(name,arg1,arg2)
49-
#definePG_TRACE3(name,arg1,arg2,arg3)
50-
#definePG_TRACE4(name,arg1,arg2,arg3,arg4)
51-
#definePG_TRACE5(name,arg1,arg2,arg3,arg4,arg5)
52-
#endif/* not ENABLE_DTRACE */
15+
#include"utils/probes.h"
5316

5417
#endif/* PG_TRACE_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp