1
# Copyright (C) 2008-2010 Sun Microsystems, Inc. All rights reserved.
2
# Use is subject to license terms.
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; version 2 of the License.
8
# This program is distributed in the hope that it will be useful, but
9
# WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
# General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
18
package GenTest::Reporter::Backtrace;
21
@ISA = qw(GenTest::Reporter);
25
use GenTest::Constants;
26
use GenTest::Reporter;
27
use GenTest::Incident;
32
my $datadir = $reporter->serverVariable('datadir');
33
say("datadir is $datadir");
35
my $binary = $reporter->serverInfo('binary');
36
say("binary is $binary");
38
my $bindir = $reporter->serverInfo('bindir');
39
say("bindir is $bindir");
41
my $pid = $reporter->serverInfo('pid');
42
my $core = <$datadir/core*>;
43
$core = </cores/core.$pid> if $^O eq 'darwin';
49
$bindir =~ s{/}{\\}sgio;
50
my $cdb_cmd = "!sym prompts off; !analyze -v; .ecxr; !for_each_frame dv /t;~*k;q";
51
push @commands, 'cdb -i "'.$bindir.'" -y "'.$bindir.';srv*C:\\cdb_symbols*http://msdl.microsoft.com/download/symbols" -z "'.$datadir.'\mysqld.dmp" -lines -c "'.$cdb_cmd.'"';
52
} elsif (osSolaris()) {
53
## We don't want to run gdb on solaris since it may core-dump
54
## if the executable was generated with SunStudio.
56
## 1) First try to do it with dbx. dbx should work for both
57
## Sunstudio and GNU CC. This is a bit complicated since we
58
## need to first ask dbx which threads we have, and then dump
59
## the stack for each thread.
61
## The code below is "inspired by MTR
62
`echo | dbx - $core 2>&1` =~ m/Corefile specified executable: "([^"]+)"/;
64
## We do apparently have a working dbx
66
# First, identify all threads
67
my @threads = `echo threads | dbx $binary $core 2>&1` =~ m/t@\d+/g;
69
## Then we make a command for each thread (It would be
70
## more efficient and get nicer output to have all
71
## commands in one dbx-batch, TODO!)
73
my $traces = join("; ",map{"where ".$_} @threads);
75
push @commands, "echo \"$traces\" | dbx $binary $core";
77
## We'll attempt pstack and c++filt which should allways
78
## work and show all threads. c++filt from SunStudio
79
## should even be able to demangle GNU CC-compiled
81
push @commands, "pstack $core | c++filt";
83
say ("No core available");
86
## Assume all other systems are gdb-"friendly" ;-)
87
push @commands, "gdb --batch --se=$binary --core=$core --command=backtrace.gdb";
88
push @commands, "gdb --batch --se=$binary --core=$core --command=backtrace-all.gdb";
93
foreach my $command (@commands) {
94
my $output = `$command`;
96
push @debugs, [$command, $output];
100
my $incident = GenTest::Incident->new(
106
return STATUS_OK, $incident;
110
return REPORTER_TYPE_CRASH | REPORTER_TYPE_DEADLOCK;
1
# Copyright (C) 2008-2010 Sun Microsystems, Inc. All rights reserved.
2
# Use is subject to license terms.
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; version 2 of the License.
8
# This program is distributed in the hope that it will be useful, but
9
# WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
# General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
18
package GenTest::Reporter::Backtrace;
21
@ISA = qw(GenTest::Reporter);
25
use GenTest::Constants;
26
use GenTest::Reporter;
27
use GenTest::Incident;
32
my $datadir = $reporter->serverVariable('datadir');
33
say("datadir is $datadir");
35
my $binary = $reporter->serverInfo('binary');
36
say("binary is $binary");
38
my $bindir = $reporter->serverInfo('bindir');
39
say("bindir is $bindir");
41
my $pid = $reporter->serverInfo('pid');
42
my $core = <$datadir/core*>;
43
$core = </cores/core.$pid> if $^O eq 'darwin';
49
$bindir =~ s{/}{\\}sgio;
50
my $cdb_cmd = "!sym prompts off; !analyze -v; .ecxr; !for_each_frame dv /t;~*k;q";
51
push @commands, 'cdb -i "'.$bindir.'" -y "'.$bindir.';srv*C:\\cdb_symbols*http://msdl.microsoft.com/download/symbols" -z "'.$datadir.'\mysqld.dmp" -lines -c "'.$cdb_cmd.'"';
52
} elsif (osSolaris()) {
53
## We don't want to run gdb on solaris since it may core-dump
54
## if the executable was generated with SunStudio.
56
## 1) First try to do it with dbx. dbx should work for both
57
## Sunstudio and GNU CC. This is a bit complicated since we
58
## need to first ask dbx which threads we have, and then dump
59
## the stack for each thread.
61
## The code below is "inspired by MTR
62
`echo | dbx - $core 2>&1` =~ m/Corefile specified executable: "([^"]+)"/;
64
## We do apparently have a working dbx
66
# First, identify all threads
67
my @threads = `echo threads | dbx $binary $core 2>&1` =~ m/t@\d+/g;
69
## Then we make a command for each thread (It would be
70
## more efficient and get nicer output to have all
71
## commands in one dbx-batch, TODO!)
73
my $traces = join("; ",map{"where ".$_} @threads);
75
push @commands, "echo \"$traces\" | dbx $binary $core";
77
## We'll attempt pstack and c++filt which should allways
78
## work and show all threads. c++filt from SunStudio
79
## should even be able to demangle GNU CC-compiled
81
push @commands, "pstack $core | c++filt";
83
say ("No core available");
86
## Assume all other systems are gdb-"friendly" ;-)
87
push @commands, "gdb --batch --se=$binary --core=$core --command=backtrace.gdb";
88
push @commands, "gdb --batch --se=$binary --core=$core --command=backtrace-all.gdb";
93
foreach my $command (@commands) {
94
my $output = `$command`;
96
push @debugs, [$command, $output];
100
my $incident = GenTest::Incident->new(
106
return STATUS_OK, $incident;
110
return REPORTER_TYPE_CRASH | REPORTER_TYPE_DEADLOCK;