Building Postgres with SystemTap static user markers enabled

configure postgres with the --enable-dtrace option:

configure --enable-dtrace

Postgres sources which use tracing need to be built with debugging information. Run configure with CFLAGS=-g or:

sed -i -e 's/^CFLAGS = /CFLAGS = -g /' <postgres-build-dir>/src/Makefile.global

If postgres has not previously been run then it is necessary to initialize it:

/usr/local/pgsql/bin/initdb <initdb-location>

Run postgres under the control of stap

stap -c /usr/local/pgsql/bin/postgres -D <initdb-location> postgres.stp

This starts the postgres server. Now postgres application like psql can be run.

An example of postgres.stp is:

probe process("/usr/local/pgsql/bin/postgres").mark("transaction__start")
{
  printf("%s %#x\n", "transaction__start", $arg1);
}
probe process("/usr/local/pgsql/bin/postgres").mark("transaction__commit")
{
  printf("%s %#x\n", "transaction__commit", $arg1);
}
probe process("/usr/local/pgsql/bin/postgres").mark("transaction__abort")
{
  printf("%s %#x\n", "transaction__abort", $arg1);
}
probe process("/usr/local/pgsql/bin/postgres").mark("lock__startwait")
{
  printf("%s %#x %#x\n", "lock__startwait", $arg1, $arg2);
}
probe process("/usr/local/pgsql/bin/postgres").mark("lock__endwait")
{
  printf("%s %#x %#x\n", "lock__endwait", $arg1, $arg2);
}
probe process("/usr/local/pgsql/bin/postgres").mark("lwlock__endwait")
{
  printf("%s %#x %#x\n", "lwlock__endwait", $arg1, $arg2);
}
probe process("/usr/local/pgsql/bin/postgres").mark("lwlock__acquire")
{
  printf("%s %#x %#x\n", "lwlock__acquire", $arg1, $arg2);
}
probe process("/usr/local/pgsql/bin/postgres").mark("lwlock__condacquire__fail")
{
  printf("%s %#x %#x\n", "lwlock__condacquire__fail", 
         $arg1, $arg2);
}
probe process("/usr/local/pgsql/bin/postgres").mark("lwlock__condacquire")
{
  printf("%s %#x %#x\n", "lwlock__condacquire", $arg1, $arg2);
}
probe process("/usr/local/pgsql/bin/postgres").mark("lwlock__release")
{
  printf("%s %#x\n", "lwlock__release", $arg1);
}

None: UsingStaticUserMarkers (last edited 2009-11-12 16:41:49 by nat-pool-rdu)