Sven Sandberg skrev:
> Hi Magnus!
>
> I committed an update to BUG#38817, which should allow printing stack
> traces on Pushbuild's Valgrind host (we discussed it on IRC, the problem
> was just that gdb printed backtick after the binary's filename on that
> host). Could you review it?
Yes, it looks fine except that you have a couple of paths where the
tempfile is not deleted. I think you better put back the autoremoving
dir you get with "my $dir = tempdir( CLEANUP => 1 );"
>
> /Sven
>
>
> Sven Sandberg wrote:
>> #At file:///home/sven/bzr/b38817-mtr_core/5.1-rpl/
>>
>> 2668 Sven Sandberg 2008-10-04
>> BUG#38817: please make mtr analyze crashes better
>> Post-push fixes making it work on pushbuild's valgrind host, and clarifying
> the output.
>> modified:
>> mysql-test/lib/My/CoreDump.pm
>>
>> per-file messages:
>> mysql-test/lib/My/CoreDump.pm
>> - Improved parsing of mtr output so that it works on pushbuild's "valgrind"
> host.
>> - Added stack trace for the thread that coredumped, to make output more
> readable when there are many threads.
>> - Added explanation of what the output consists of.
>> - Added early removal of temp file.
>> === modified file 'mysql-test/lib/My/CoreDump.pm'
>> --- a/mysql-test/lib/My/CoreDump.pm 2008-09-20 14:10:22 +0000
>> +++ b/mysql-test/lib/My/CoreDump.pm 2008-10-04 07:49:09 +0000
>> @@ -27,33 +27,33 @@ sub _gdb {
>>
>> return unless -f $core_name;
>>
>> - my $dir = tempdir( CLEANUP => 1 );
>> - my ($tmp, $tmp_name) = tempfile( DIR => $dir );
>> + # Find out name of binary that generated core
>> + `gdb -c '$core_name' -q --batch 2>&1` =~
>> + /Core was generated by `([^\s\'\`]+)/;
>> + my $binary= $1 or return;
>> + print "Core generated by '$binary'\n";
>>
>> + # Create tempfile containing gdb commands
>> + my ($tmp, $tmp_name) = tempfile();
>> print $tmp
>> + "bt\n",
>> "thread apply all bt\n",
>> "quit\n";
>> + close $tmp or die "Error closing $tmp_name: $!";
>>
>> - # Find out name of binary that generated core
>> - my $list= `gdb -c $core_name -x $tmp_name -q --batch 2>&1`
>> - or return;
>> -
>> - my $binary;
>> - foreach my $line (split('\n', $list))
>> - {
>> - $binary= $1
>> - if ($line =~ /Core was generated by `(\S+)/);
>> - }
>> -
>> - return unless $binary;
>> -
>> - print "Generated by '$binary'\n";
>> + # Run gdb
>> + my $gdb_output=
>> + `gdb '$binary' -c '$core_name' -x '$tmp_name' -q --batch 2>&1`;
>>
>> - my $list= `gdb $binary -c $core_name -x $tmp_name -q --batch 2>&1`
>> - or return;
>> + unlink $tmp_name or die "Error removing $tmp_name: $!";
>>
>> - print $list, "\n";
>> + return unless $gdb_output;
>>
>> + print <<EOF, $gdb_output, "\n";
>> +Output from gdb follows. The first stack trace is from the failing thread.
>> +The following stack traces are from all threads (so the failing one is
>> +duplicated).
>> +EOF
>> return 1;
>> }
>>
>>
>>
>
>