diff --git a/src/backend/Makefile b/src/backend/Makefile index bb4064238bddbfd8c2e7766cc5420498be5d0bc2..597ec8d8eb023583856d2687dc409a38925b51bb 100644 --- a/src/backend/Makefile +++ b/src/backend/Makefile @@ -5,7 +5,7 @@ # Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group # Portions Copyright (c) 1994, Regents of the University of California # -# $PostgreSQL: pgsql/src/backend/Makefile,v 1.127 2008/02/26 14:42:27 petere Exp $ +# $PostgreSQL: pgsql/src/backend/Makefile,v 1.128 2008/03/17 19:44:40 petere Exp $ # #------------------------------------------------------------------------- @@ -20,9 +20,11 @@ SUBDIRS = access bootstrap catalog parser commands executor lib libpq \ include $(srcdir)/common.mk +ifeq ($(PORTNAME), solaris) ifeq ($(enable_dtrace), yes) LOCALOBJS += utils/probes.o endif +endif OBJS = $(SUBDIROBJS) $(LOCALOBJS) $(top_builddir)/src/port/libpgport_srv.a @@ -103,7 +105,7 @@ endif endif # aix # Update the commonly used headers before building the subdirectories -$(SUBDIRS:%=%-recursive): $(top_builddir)/src/include/parser/parse.h $(top_builddir)/src/include/utils/fmgroids.h +$(SUBDIRS:%=%-recursive): $(top_builddir)/src/include/parser/parse.h $(top_builddir)/src/include/utils/fmgroids.h $(top_builddir)/src/include/utils/probes.h # The postgres.o target is needed by the rule in Makefile.global that @@ -122,6 +124,9 @@ $(srcdir)/parser/parse.h: parser/gram.y utils/fmgroids.h: utils/Gen_fmgrtab.sh $(top_srcdir)/src/include/catalog/pg_proc.h $(MAKE) -C utils fmgroids.h +utils/probes.h: utils/probes.d + $(MAKE) -C utils probes.h + # Make symlinks for these headers in the include directory. That way # we can cut down on the -I options. Also, a symlink is automatically # up to date when we update the base file. @@ -135,9 +140,15 @@ $(top_builddir)/src/include/utils/fmgroids.h: utils/fmgroids.h cd $(dir $@) && rm -f $(notdir $@) && \ $(LN_S) ../../../$(subdir)/utils/fmgroids.h . +$(top_builddir)/src/include/utils/probes.h: utils/probes.h + cd $(dir $@) && rm -f $(notdir $@) && \ + $(LN_S) ../../../$(subdir)/utils/probes.h . + +ifeq ($(PORTNAME), solaris) utils/probes.o: utils/probes.d $(SUBDIROBJS) $(DTRACE) $(DTRACEFLAGS) -G -s $(call expand_subsys,$^) -o $@ +endif ########################################################################## diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index 79158d8d71e2650ebad2ae45d9558d0223458325..9af53a5953f09e2b2726fc7efa8ad4fcc1f2b9ab 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.259 2008/03/17 02:18:55 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.260 2008/03/17 19:44:41 petere Exp $ * *------------------------------------------------------------------------- */ @@ -46,6 +46,7 @@ #include "utils/memutils.h" #include "utils/relcache.h" #include "utils/xml.h" +#include "pg_trace.h" /* @@ -1547,7 +1548,7 @@ StartTransaction(void) Assert(MyProc->backendId == vxid.backendId); MyProc->lxid = vxid.localTransactionId; - PG_TRACE1(transaction__start, vxid.localTransactionId); + TRACE_POSTGRESQL_TRANSACTION_START(vxid.localTransactionId); /* * set transaction_timestamp() (a/k/a now()). We want this to be the same @@ -1674,7 +1675,7 @@ CommitTransaction(void) */ latestXid = RecordTransactionCommit(); - PG_TRACE1(transaction__commit, MyProc->lxid); + TRACE_POSTGRESQL_TRANSACTION_COMMIT(MyProc->lxid); /* * Let others know about no transaction in progress by me. Note that this @@ -2084,7 +2085,7 @@ AbortTransaction(void) */ latestXid = RecordTransactionAbort(false); - PG_TRACE1(transaction__abort, MyProc->lxid); + TRACE_POSTGRESQL_TRANSACTION_ABORT(MyProc->lxid); /* * Let others know about no transaction in progress by me. Note that this diff --git a/src/backend/storage/lmgr/lock.c b/src/backend/storage/lmgr/lock.c index c8ba3538cf581f6f1ee5bc784336c25f33d9796f..fbd1be586bb949e0c1646b831cea80fe16a232b2 100644 --- a/src/backend/storage/lmgr/lock.c +++ b/src/backend/storage/lmgr/lock.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/storage/lmgr/lock.c,v 1.182 2008/03/04 19:54:06 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/storage/lmgr/lock.c,v 1.183 2008/03/17 19:44:41 petere Exp $ * * NOTES * A lock table is a shared memory hash table. When @@ -40,6 +40,7 @@ #include "utils/memutils.h" #include "utils/ps_status.h" #include "utils/resowner.h" +#include "pg_trace.h" /* This configuration variable is used to set the lock table size */ @@ -786,11 +787,11 @@ LockAcquire(const LOCKTAG *locktag, * Sleep till someone wakes me up. */ - PG_TRACE2(lock__startwait, locktag->locktag_field2, lockmode); + TRACE_POSTGRESQL_LOCK_STARTWAIT(locktag->locktag_field2, lockmode); WaitOnLock(locallock, owner); - PG_TRACE2(lock__endwait, locktag->locktag_field2, lockmode); + TRACE_POSTGRESQL_LOCK_ENDWAIT(locktag->locktag_field2, lockmode); /* * NOTE: do not do any material change of state between here and diff --git a/src/backend/storage/lmgr/lwlock.c b/src/backend/storage/lmgr/lwlock.c index 036c32fad026eaba08e6abbb102cdd81a1133249..5fcad46f2fad51711adeeefa5428b25a8a6829d8 100644 --- a/src/backend/storage/lmgr/lwlock.c +++ b/src/backend/storage/lmgr/lwlock.c @@ -15,7 +15,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/storage/lmgr/lwlock.c,v 1.50 2008/01/01 19:45:52 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/storage/lmgr/lwlock.c,v 1.51 2008/03/17 19:44:41 petere Exp $ * *------------------------------------------------------------------------- */ @@ -28,6 +28,7 @@ #include "storage/ipc.h" #include "storage/proc.h" #include "storage/spin.h" +#include "pg_trace.h" /* We use the ShmemLock spinlock to protect LWLockAssign */ @@ -447,7 +448,7 @@ LWLockAcquire(LWLockId lockid, LWLockMode mode) block_counts[lockid]++; #endif - PG_TRACE2(lwlock__startwait, lockid, mode); + TRACE_POSTGRESQL_LWLOCK_STARTWAIT(lockid, mode); for (;;) { @@ -458,7 +459,7 @@ LWLockAcquire(LWLockId lockid, LWLockMode mode) extraWaits++; } - PG_TRACE2(lwlock__endwait, lockid, mode); + TRACE_POSTGRESQL_LWLOCK_ENDWAIT(lockid, mode); LOG_LWDEBUG("LWLockAcquire", lockid, "awakened"); @@ -469,7 +470,7 @@ LWLockAcquire(LWLockId lockid, LWLockMode mode) /* We are done updating shared state of the lock itself. */ SpinLockRelease(&lock->mutex); - PG_TRACE2(lwlock__acquire, lockid, mode); + TRACE_POSTGRESQL_LWLOCK_ACQUIRE(lockid, mode); /* Add lock to list of locks held by this backend */ held_lwlocks[num_held_lwlocks++] = lockid; @@ -540,13 +541,13 @@ LWLockConditionalAcquire(LWLockId lockid, LWLockMode mode) /* Failed to get lock, so release interrupt holdoff */ RESUME_INTERRUPTS(); LOG_LWDEBUG("LWLockConditionalAcquire", lockid, "failed"); - PG_TRACE2(lwlock__condacquire__fail, lockid, mode); + TRACE_POSTGRESQL_LWLOCK_CONDACQUIRE_FAIL(lockid, mode); } else { /* Add lock to list of locks held by this backend */ held_lwlocks[num_held_lwlocks++] = lockid; - PG_TRACE2(lwlock__condacquire, lockid, mode); + TRACE_POSTGRESQL_LWLOCK_CONDACQUIRE(lockid, mode); } return !mustwait; @@ -631,7 +632,7 @@ LWLockRelease(LWLockId lockid) /* We are done updating shared state of the lock itself. */ SpinLockRelease(&lock->mutex); - PG_TRACE1(lwlock__release, lockid); + TRACE_POSTGRESQL_LWLOCK_RELEASE(lockid); /* * Awaken any waiters I removed from the queue. diff --git a/src/backend/utils/Gen_dummy_probes.sed b/src/backend/utils/Gen_dummy_probes.sed new file mode 100644 index 0000000000000000000000000000000000000000..db29e4188f27bed4d68567922f29bc7d89f9d482 --- /dev/null +++ b/src/backend/utils/Gen_dummy_probes.sed @@ -0,0 +1,16 @@ +#------------------------------------------------------------------------- +# sed script to create dummy probes.h file when dtrace is not available +# +# Copyright (c) 2008, PostgreSQL Global Development Group +# +# $PostgreSQL: pgsql/src/backend/utils/Gen_dummy_probes.sed,v 1.1 2008/03/17 19:44:41 petere Exp $ +#------------------------------------------------------------------------- + +/^probe /!d +s/^probe \([^(]*\)\(.*\);/\1\2/ +s/__/_/g +y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/ +s/^/#define TRACE_POSTGRESQL_/ +s/(INT, INT)/(INT1, INT2)/ +P +s/(.*$/_ENABLED() (0)/ diff --git a/src/backend/utils/Makefile b/src/backend/utils/Makefile index 0e3b9500f5bc657fb0157b9cd59a3319b944de99..f753016173153a6c5c3ab9f0324c2ab05cf8d572 100644 --- a/src/backend/utils/Makefile +++ b/src/backend/utils/Makefile @@ -1,7 +1,7 @@ # # Makefile for utils # -# $PostgreSQL: pgsql/src/backend/utils/Makefile,v 1.26 2008/02/19 10:30:08 petere Exp $ +# $PostgreSQL: pgsql/src/backend/utils/Makefile,v 1.27 2008/03/17 19:44:41 petere Exp $ # subdir = src/backend/utils @@ -13,12 +13,22 @@ SUBDIRS = adt cache error fmgr hash init mb misc mmgr resowner sort time include $(top_srcdir)/src/backend/common.mk -all: fmgroids.h +all: fmgroids.h probes.h $(SUBDIRS:%=%-recursive): fmgroids.h fmgroids.h fmgrtab.c: Gen_fmgrtab.sh $(top_srcdir)/src/include/catalog/pg_proc.h AWK='$(AWK)' $(SHELL) $< $(top_srcdir)/src/include/catalog/pg_proc.h +probes.h: probes.d +ifeq ($(enable_dtrace), yes) + $(DTRACE) -h -s $< -o $@.tmp + sed -e 's/POSTGRESQL_/TRACE_POSTGRESQL_/g' $@.tmp >$@ + rm $@.tmp +else + sed -f $(srcdir)/Gen_dummy_probes.sed $< >$@ +endif + + clean: - rm -f fmgroids.h fmgrtab.c + rm -f fmgroids.h fmgrtab.c probes.h diff --git a/src/include/Makefile b/src/include/Makefile index e21dc57641623dfaf20d24dc98b68eced7e2be38..01a046f4fccc30d1a10b3e1aa123424ce9bbbd43 100644 --- a/src/include/Makefile +++ b/src/include/Makefile @@ -4,7 +4,7 @@ # # 'make install' installs whole contents of src/include. # -# $PostgreSQL: pgsql/src/include/Makefile,v 1.23 2007/10/14 17:07:51 tgl Exp $ +# $PostgreSQL: pgsql/src/include/Makefile,v 1.24 2008/03/17 19:44:41 petere Exp $ # #------------------------------------------------------------------------- @@ -60,7 +60,7 @@ uninstall: clean: - rm -f utils/fmgroids.h parser/parse.h + rm -f utils/fmgroids.h parser/parse.h utils/probes.h distclean maintainer-clean: clean rm -f pg_config.h dynloader.h pg_config_os.h stamp-h diff --git a/src/include/c.h b/src/include/c.h index 07a29d9cdf4e1d0e1356a0d8e0170a384a61c27f..f9b0acf957131b8e3387ef8acbfc1854f2d8ff6c 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -12,7 +12,7 @@ * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/c.h,v 1.223 2008/02/23 19:11:45 tgl Exp $ + * $PostgreSQL: pgsql/src/include/c.h,v 1.224 2008/03/17 19:44:41 petere Exp $ * *------------------------------------------------------------------------- */ @@ -57,7 +57,6 @@ #include "pg_config_os.h" /* must be before any system header files */ #endif #include "postgres_ext.h" -#include "pg_trace.h" #if _MSC_VER >= 1400 #define errcode __msvc_errcode diff --git a/src/include/pg_trace.h b/src/include/pg_trace.h index 28b6e8ead643baa3aaa0900d361d663e7afb6538..bc5fc7563e74cf02d86f6c4fdd916b40f8d436dc 100644 --- a/src/include/pg_trace.h +++ b/src/include/pg_trace.h @@ -5,50 +5,13 @@ * * Copyright (c) 2006-2008, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/include/pg_trace.h,v 1.3 2008/01/02 02:42:06 momjian Exp $ + * $PostgreSQL: pgsql/src/include/pg_trace.h,v 1.4 2008/03/17 19:44:41 petere Exp $ * ---------- */ #ifndef PG_TRACE_H #define PG_TRACE_H -#ifdef ENABLE_DTRACE - -#include - -/* - * The PG_TRACE macros are mapped to the appropriate macros used by DTrace. - * - * Only one DTrace provider called "postgresql" will be used for PostgreSQL, - * so the name is hard-coded here to avoid having to specify it in the - * source code. - */ - -#define PG_TRACE(name) \ - DTRACE_PROBE(postgresql, name) -#define PG_TRACE1(name, arg1) \ - DTRACE_PROBE1(postgresql, name, arg1) -#define PG_TRACE2(name, arg1, arg2) \ - DTRACE_PROBE2(postgresql, name, arg1, arg2) -#define PG_TRACE3(name, arg1, arg2, arg3) \ - DTRACE_PROBE3(postgresql, name, arg1, arg2, arg3) -#define PG_TRACE4(name, arg1, arg2, arg3, arg4) \ - DTRACE_PROBE4(postgresql, name, arg1, arg2, arg3, arg4) -#define PG_TRACE5(name, arg1, arg2, arg3, arg4, arg5) \ - DTRACE_PROBE5(postgresql, name, arg1, arg2, arg3, arg4, arg5) -#else /* not ENABLE_DTRACE */ - -/* - * Unless DTrace is explicitly enabled with --enable-dtrace, the PG_TRACE - * macros will expand to no-ops. - */ - -#define PG_TRACE(name) -#define PG_TRACE1(name, arg1) -#define PG_TRACE2(name, arg1, arg2) -#define PG_TRACE3(name, arg1, arg2, arg3) -#define PG_TRACE4(name, arg1, arg2, arg3, arg4) -#define PG_TRACE5(name, arg1, arg2, arg3, arg4, arg5) -#endif /* not ENABLE_DTRACE */ +#include "utils/probes.h" #endif /* PG_TRACE_H */