~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to lib/GenTest/Reporter/Backtrace.pm

initial import from internal tree

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package GenTest::Reporter::Backtrace;
 
2
 
 
3
require Exporter;
 
4
@ISA = qw(GenTest::Reporter);
 
5
 
 
6
use strict;
 
7
use GenTest;
 
8
use GenTest::Constants;
 
9
use GenTest::Reporter;
 
10
use GenTest::Incident;
 
11
 
 
12
sub report {
 
13
        my $reporter = shift;
 
14
        my $datadir = $reporter->serverVariable('datadir');
 
15
        say("datadir is $datadir");
 
16
        my $binary = $reporter->serverInfo('binary');
 
17
        my $bindir = $reporter->serverInfo('bindir');
 
18
 
 
19
        my $pid = $reporter->serverInfo('pid');
 
20
        my $core = <$datadir/core*>;
 
21
        $core = </cores/core.$pid> if $^O eq 'darwin';
 
22
        say("Core file appears to be $core");
 
23
 
 
24
        my @commands;
 
25
 
 
26
        if (windows()) {
 
27
                $bindir =~ s{/}{\\}sgio;
 
28
                my $cdb_cmd = "!sym prompts off; !analyze -v; .ecxr; !for_each_frame dv /t;~*k;q";              
 
29
                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.'"';
 
30
        } else {
 
31
                push @commands, "gdb --batch --se=$binary --core=$core --command=backtrace.gdb";
 
32
                push @commands, "gdb --batch --se=$binary --core=$core --command=backtrace-all.gdb";
 
33
        }
 
34
        
 
35
        if ($^O eq 'solaris') {
 
36
                push @commands, "echo '::stack' | mdb $core | c++filt";
 
37
        }
 
38
 
 
39
        my @debugs;
 
40
 
 
41
        foreach my $command (@commands) {
 
42
                my $output = `$command`;
 
43
                say("$output");
 
44
                push @debugs, [$command, $output];
 
45
        }
 
46
 
 
47
 
 
48
        my $incident = GenTest::Incident->new(
 
49
                corefile => $core,
 
50
                debugs => \@debugs
 
51
        );
 
52
 
 
53
        return STATUS_OK, $incident;
 
54
}
 
55
 
 
56
sub type {
 
57
        return REPORTER_TYPE_CRASH | REPORTER_TYPE_DEADLOCK;
 
58
}
 
59
 
 
60
1;