Alvaro Herrera wrote:
Tom Lane wrote:
I wonder whether there's any way to get the buildfarm script to report a
stack trace automatically if it finds a core file left behind in the
$PGDATA directory after running the tests. Would something like this
be adequately portable?
if [ -f $PGDATA/core* ]
then
echo bt | gdb $installdir/bin/postgres $PGDATA/core*
fi
gdb has a "batch mode" which can be useful:
if [ -f $PGDATA/core* ]
then
gdb -ex "bt" --batch $installdir/bin/postgres $PGDATA/core*
fi
here's a quick untested patch for buildfarm that Stefan might like to try.
cheers
andrew
--- run_build.pl.orig 2006-12-28 17:32:14.000000000 -0500
+++ run_build.pl.new 2006-12-28 17:58:51.000000000 -0500
@@ -795,6 +795,29 @@
$dbstarted=undef;
}
+
+sub get_stack_trace
+{
+ my $bindir = shift;
+ my $pgdata = shift;
+
+ # no core = no result
+ return () unless -f "$pgdata/core";
+
+ # no gdb = no result
+ system "gdb --version > /dev/null 2>&1";
+ my $status = $? >>8;
+ return () if $status;
+
+ my @trace = `gdb -ex bt --batch $bindir/postgres $pgdata/core 2>&1`;
+
+ unshift(@trace,
+ "\n\n================== stack trace
==================\n");
+
+ return @trace;
+
+}
+
sub make_install_check
{
my @checkout = `cd $pgsql/src/test/regress && $make installcheck 2>&1`;
@@ -814,6 +837,11 @@
}
close($handle);
}
+ if ($status)
+ {
+ my @trace =
get_stack_trace("$installdir/bin","$installdir/data");
+ push(@checkout,@trace);
+ }
writelog('install-check',[EMAIL PROTECTED]);
print "======== make installcheck log ===========\n",@checkout
if ($verbose > 1);
@@ -839,6 +867,11 @@
}
close($handle);
}
+ if ($status)
+ {
+ my @trace =
get_stack_trace("$installdir/bin","$installdir/data");
+ push(@checkout,@trace);
+ }
writelog('contrib-install-check',[EMAIL PROTECTED]);
print "======== make contrib installcheck log ===========\n",@checkout
if ($verbose > 1);
@@ -864,6 +897,11 @@
}
close($handle);
}
+ if ($status)
+ {
+ my @trace =
get_stack_trace("$installdir/bin","$installdir/data");
+ push(@checkout,@trace);
+ }
writelog('pl-install-check',[EMAIL PROTECTED]);
print "======== make pl installcheck log ===========\n",@checkout
if ($verbose > 1);
@@ -892,6 +930,13 @@
}
close($handle);
}
+ if ($status)
+ {
+ my @trace =
+
get_stack_trace("$pgsql/src/test/regress/install$installdir/bin",
+
"$pgsql/src/test/regress/tmp_check/data");
+ push(@makeout,@trace);
+ }
writelog('check',[EMAIL PROTECTED]);
print "======== make check logs ===========\n",@makeout
if ($verbose > 1);
---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster