提交 d994b38e 编写于 作者: H Heikki Linnakangas

Remove unused ENABLE_LTRACE code.

Although I'm not too familiar with SystemTap, I'm pretty sure that recent
versions can do user space tracing better. I don't think anyone is using
these hacks anymore, so remove them.
上级 d145bd11
......@@ -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;
......
......@@ -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
/*-------------------------------------------------------------------------
*
* 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 <pg_config.h>
#ifdef ENABLE_LTRACE
#include <sys/types.h>
#include <unistd.h>
#include <pg_trace.h>
#include <stdio.h>
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
......@@ -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"),
......
......@@ -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;
......
......@@ -13,7 +13,6 @@
#define PG_TRACE_H
#ifdef ENABLE_DTRACE
#define PGTRACE_ENABLED
#include <sys/sdt.h>
......@@ -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 */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册