diff --git a/src/backend/cdb/cdbvars.c b/src/backend/cdb/cdbvars.c index 4269282bc847276bb9cfaaaceb02fee91715e3a1..509a310c11f44888651d809e70474c9ecf636a77 100644 --- a/src/backend/cdb/cdbvars.c +++ b/src/backend/cdb/cdbvars.c @@ -280,9 +280,6 @@ int gp_hashjoin_bloomfilter = 0; /* Analyzing aid */ int gp_motion_slice_noop = 0; -#ifdef ENABLE_LTRACE -int gp_ltrace_flag = 0; -#endif /* Greenplum Database Experimental Feature GUCs */ int gp_distinct_grouping_sets_threshold = 32; diff --git a/src/backend/utils/error/Makefile b/src/backend/utils/error/Makefile index fabaec3d02b73219a2e72a33e5df38bd01891078..cb02c1ca178421947b1e016c262b24df398a5089 100644 --- a/src/backend/utils/error/Makefile +++ b/src/backend/utils/error/Makefile @@ -12,6 +12,6 @@ subdir = src/backend/utils/error top_builddir = ../../../.. include $(top_builddir)/src/Makefile.global -OBJS = assert.o debugbreak.o debugutils.o elog.o faultinject.o pg_ltrace.o +OBJS = assert.o debugbreak.o debugutils.o elog.o faultinject.o include $(top_srcdir)/src/backend/common.mk diff --git a/src/backend/utils/error/pg_ltrace.c b/src/backend/utils/error/pg_ltrace.c deleted file mode 100644 index f9bfb4974070c9c1c256d963bda99887e4c0f1f9..0000000000000000000000000000000000000000 --- a/src/backend/utils/error/pg_ltrace.c +++ /dev/null @@ -1,127 +0,0 @@ -/*------------------------------------------------------------------------- - * - * pg_ltrace.c - * Poor linux's tracing facility. - * - * Portions Copyright (c) 2008, Greenplum Inc. - * Portions Copyright (c) 2012-Present Pivotal Software, Inc. - * - * - * IDENTIFICATION - * src/backend/utils/error/pg_ltrace.c - *------------------------------------------------------------------------- - */ - -#include -#ifdef ENABLE_LTRACE -#include - -#include -#include -#include - -extern int gp_ltrace_flag; - -struct pg_trace_data_t -{ - long val[9]; -}; - -/* - * Poor linux tracing facility. - * - * Unlike dtrace, linux tracing (SystemTap) at this moment - * does not support user space tracing. We use the following - * HACK to get some tracing. - * - * The write is strange. Postgres will redirect fd 0 (stdin) to - * read from /dev/null. We are writing to stdin, a string of 0 bytes. - * it will fail, as stdin is readonly, but, it is still a system call. - * In system tap, we can catch at syscall.write and test $fd == 0 and - * $count == 0. The constructed buffer can be accessed by $buf. - * - * Note that the $fd = 0 and $count = 0 hack is kind of "Needed". - * If the fd is not valid, then actually the systemtap syscalls tapset - * will not catch it. Count set to 0 is safe. - * - * NOTE: At this moment, SystemTap cannot even display user stack. - * if we really want the stack, we can construct the stack using backtrace() - * and put the string as the str arg. - * - * filename and funcname can be used a quick dirty depth 1 stack. - * - * The stp script need to match the t.val layout. Right now, - * 0 family - * 1 filename - * 2 funcname - * 3 line number - * 4-9 5 args - */ - -#if 0 ---------------------- BEGIN EXAMPLE STP --------------------------------- -#! /usr/bin/env stap - -/* - * Example stap. The stp must be run as root because it uses embeded C. - * - * sudo stap -g my.stp - */ - -function pgtrace_decode_val:long(pgtrace_data:long, fieldnum:long) -%{ - struct pg_trace_data_t { - long iv[9]; - }; - - struct pg_trace_data_t *p = (struct pg_trace_data_t *) (long) THIS->pgtrace_data; - if(p && THIS->fieldnum >= 0 && THIS->fieldnum < 9) - THIS->__retvalue = kread(&(p->iv[THIS->fieldnum])); - else - THIS->__retvalue = 0; - - CATCH_DEREF_FAULT(); -%} - -probe syscall.write { - /* We have $fd, $count, and $buf. Need to access $buf with user_string($buf) */ - if($fd == 0 && $count == 0) - { - printf("PGTrace family %d, file %s, func %s line %d: args: %d, %d, %d, %d, %d\n", - pgtrace_decode_val($buf, 0), - user_string(pgtrace_decode_val($buf, 1)), - user_string(pgtrace_decode_val($buf, 2)), - pgtrace_decode_val($buf, 3), - pgtrace_decode_val($buf, 4), - pgtrace_decode_val($buf, 5), - pgtrace_decode_val($buf, 6), - pgtrace_decode_val($buf, 7), - pgtrace_decode_val($buf, 8) - ) - } -} ---------------------- END EXAMPLE STP ----------------------------------------- -#endif - -void LTRACE_PROBE_FIRE(long family, - const char *filename, const char *funcname, long line, - long i1, long i2, long i3, long i4, long i5 - ) -{ - if(gp_ltrace_flag) - { - struct pg_trace_data_t t; - t.val[0] = family; - t.val[1] = (long) filename; - t.val[2] = (long) funcname; - t.val[3] = line; - t.val[4] = i1; - t.val[5] = i2; - t.val[6] = i3; - t.val[7] = i4; - t.val[8] = i5; - - write(0, (char *) &t, 0); - } -} -#endif diff --git a/src/backend/utils/misc/guc_gp.c b/src/backend/utils/misc/guc_gp.c index 653a5fe8432decc4c8a32c017a501ac3121df76c..f6c1490bfb25ce90c30df4c1bfef336f4c0ebb6e 100644 --- a/src/backend/utils/misc/guc_gp.c +++ b/src/backend/utils/misc/guc_gp.c @@ -4226,18 +4226,6 @@ struct config_int ConfigureNamesInt_gp[] = 0, 0, INT_MAX, NULL, NULL }, -#ifdef ENABLE_LTRACE - { - {"gp_ltrace_flag", PGC_USERSET, GP_ARRAY_TUNING, - gettext_noop("Linux Tracing flag"), - gettext_noop("Linux Tracing flag"), - GUC_NOT_IN_SAMPLE | GUC_NO_SHOW_ALL | GUC_GPDB_ADDOPT - }, - &gp_ltrace_flag, - 0, 0, INT_MAX, NULL, NULL - }, -#endif - { {"gp_reject_percent_threshold", PGC_USERSET, GP_ERROR_HANDLING, gettext_noop("Reject limit in percent starts calculating after this number of rows processed"), diff --git a/src/include/cdb/cdbvars.h b/src/include/cdb/cdbvars.h index cb0124145fa2bf2030f0615f2fba248d3627f6e9..bd401fa018726fd82b75e58eb7f8d3fbe119d3f4 100644 --- a/src/include/cdb/cdbvars.h +++ b/src/include/cdb/cdbvars.h @@ -893,9 +893,6 @@ extern double gp_statistics_sampling_threshold; /* Analyze tools */ extern int gp_motion_slice_noop; -#ifdef ENABLE_LTRACE -extern int gp_ltrace_flag; -#endif /* Disable setting of hint-bits while reading db pages */ extern bool gp_disable_tuple_hints; diff --git a/src/include/pg_trace.h b/src/include/pg_trace.h index 67478007676ee1faa278f24d5e20fe7ec83cd4e8..28b6e8ead643baa3aaa0900d361d663e7afb6538 100644 --- a/src/include/pg_trace.h +++ b/src/include/pg_trace.h @@ -13,7 +13,6 @@ #define PG_TRACE_H #ifdef ENABLE_DTRACE -#define PGTRACE_ENABLED #include @@ -37,78 +36,8 @@ 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 */ -#define LTRACE_PROBE(family, fn, fc, l, i1, i2, i3, i4, i5) - -#else -#ifdef ENABLE_LTRACE -#define PGTRACE_ENABLED -enum -{ - /* Postgres dtrace family, 1 to 999,999 */ - /* See src/backend/utils/probes.d */ - transaction__start = 1, - transaction__commit, - transaction__abort, - lwlock__acquire, - lwlock__release, - lwlock__startwait, - lwlock__endwait, - lwlock__condacquire, - lwlock__condacquire__fail, - lock__startwait, - lock__endwait, - - memctxt__alloc, - memctxt__free, - memctxt__realloc, - - execprocnode__enter, - execprocnode__exit, - - tuplesort__begin, - tuplesort__end, - tuplesort__perform__sort, - tuplesort__mergeonerun, - tuplesort__dumptuples, - tuplesort__switch__external, - - /* Internal test and debug use */ - LTR_DEBUG_START = 1000000, - - /* Internal test and debug, very verbose */ - LTR_DEBUG_VERBOSE = 2000000, -}; - -extern int gp_ltrace_flag; -extern void LTRACE_PROBE_FIRE(long family, - const char *filen, const char *func, long line, - long i1, long i2, long i3, long i4, long i5 - ); -static inline void LTRACE_PROBE(long family, - const char *filen, const char *func, long line, - long i1, long i2, long i3, long i4, long i5 - ) -{ - if(family < gp_ltrace_flag) - LTRACE_PROBE_FIRE(family, filen, func, line, - i1, i2, i3, i4, i5); -} - -#define PG_TRACE(name) \ - LTRACE_PROBE(name, __FILE__, PG_FUNCNAME_MACRO, __LINE__, 0, 0, 0, 0, 0) -#define PG_TRACE1(name, arg1) \ - LTRACE_PROBE(name, __FILE__, PG_FUNCNAME_MACRO, __LINE__, arg1, 0, 0, 0, 0) -#define PG_TRACE2(name, arg1, arg2) \ - LTRACE_PROBE(name, __FILE__, PG_FUNCNAME_MACRO, __LINE__, arg1, arg2, 0, 0, 0) -#define PG_TRACE3(name, arg1, arg2, arg3) \ - LTRACE_PROBE(name, __FILE__, PG_FUNCNAME_MACRO, __LINE__, arg1, arg2, arg3, 0, 0) -#define PG_TRACE4(name, arg1, arg2, arg3, arg4) \ - LTRACE_PROBE(name, __FILE__, PG_FUNCNAME_MACRO, __LINE__, arg1, arg2, arg3, arg4, 0) -#define PG_TRACE5(name, arg1, arg2, arg3, arg4, arg5) \ - LTRACE_PROBE(name, __FILE__, PG_FUNCNAME_MACRO, __LINE__, arg1, arg2, arg3, arg4, arg5) - -#else /* No tracing */ /* * Unless DTrace is explicitly enabled with --enable-dtrace, the PG_TRACE * macros will expand to no-ops. @@ -120,8 +49,6 @@ static inline void LTRACE_PROBE(long family, #define PG_TRACE3(name, arg1, arg2, arg3) #define PG_TRACE4(name, arg1, arg2, arg3, arg4) #define PG_TRACE5(name, arg1, arg2, arg3, arg4, arg5) -#define LTRACE_PROBE(family, fn, fc, l, i1, i2, i3, i4, i5) - -#endif /* not ENABLE_LTRACE */ #endif /* not ENABLE_DTRACE */ + #endif /* PG_TRACE_H */