From: magnus.blaudd Date: November 12 2012 12:44pm Subject: bzr push into mysql-5.5-cluster-7.2 branch (magnus.blaudd:4079 to 4080) List-Archive: http://lists.mysql.com/commits/145215 Message-Id: <20121112124457.27151.41601.4080@wholphin> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 4080 magnus.blaudd@stripped 2012-11-12 [merge] Merge modified: storage/ndb/cmake/os/Windows.cmake storage/ndb/compile-cluster storage/ndb/test/ndbapi/testInterpreter.cpp 4079 Frazer Clement 2012-11-09 [merge] Merge 7.1->7.2 modified: storage/ndb/src/kernel/blocks/backup/Backup.cpp === modified file 'storage/ndb/cmake/os/Windows.cmake' --- a/storage/ndb/cmake/os/Windows.cmake 2011-05-24 08:45:38 +0000 +++ b/storage/ndb/cmake/os/Windows.cmake 2012-11-12 10:58:00 +0000 @@ -21,3 +21,9 @@ GET_FILENAME_COMPONENT(_SCRIPT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) INCLUDE(${_SCRIPT_DIR}/WindowsCache.cmake) +IF(MSVC) + # Enable "Full Path of Source Code File in Diagnostics" to avoid + # "guessing" which file was causing warnings or error + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /FC") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /FC") +ENDIF() === modified file 'storage/ndb/compile-cluster' --- a/storage/ndb/compile-cluster 2012-11-02 12:55:01 +0000 +++ b/storage/ndb/compile-cluster 2012-11-12 12:21:47 +0000 @@ -1,6 +1,6 @@ #!/usr/bin/perl -# Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -35,6 +35,8 @@ my $opt_build_type; my $opt_build = 1; my $opt_just_print; my $opt_vanilla; +my $opt_autotest; +my $opt_parse_log; Getopt::Long::Configure("pass_through"); GetOptions( @@ -46,6 +48,12 @@ GetOptions( 'c|just-configure' => sub { $opt_build = 0; }, 'n|just-print' => \$opt_just_print, 'vanilla' => \$opt_vanilla, + + 'autotest' => \$opt_autotest, + + # Special switch --parse-log= which reads a log file (from build) and + # parses it for warnings + 'parse-log=s' => \$opt_parse_log, ) or exit(1); # Find source root directory, assume this script is @@ -59,6 +67,23 @@ if ($^O eq "cygwin") { chomp $opt_srcdir; } +# Parse given log file for warnings +if ($opt_parse_log) +{ + use IO::File; + my $file = IO::File->new($opt_parse_log, 'r') + or die "Failed to open file $opt_parse_log: $!"; + my $parser = WarningParser->new(srcdir => $opt_srcdir, + unified => 1, + verbose => 1); + while (my $line = <$file>) + { + $parser->parse_line($line); + } + $parser->report($0); + exit(0); +} + # Check that cmake exists and figure out it's version my $cmake_version_id; { @@ -110,6 +135,12 @@ my $cmake_version_id; push(@args, "-DWITH_NDB_TEST=1"); } + if ($opt_autotest) + { + print("compile-cluster: autotest build requested, extra everything\n"); + push(@args, "-DWITH_NDB_CCFLAGS='-DERROR_INSERT'"); + } + # The cmake generator to use if ($opt_build_type) { @@ -330,7 +361,7 @@ if (!$opt_build) push(@args, $config); } - cmd("cmake", @args); + build_cmd("cmake", @args); } else @@ -339,22 +370,331 @@ if (!$opt_build) die "You need to install cmake with version > 2.8" if ($^O eq "cygwin" or $^O eq "MSWin32"); - cmd("make"); + build_cmd("make"); } } +exit(0); + + sub cmd { my ($cmd, @a)= @_; - - if ($opt_just_print){ - print "$cmd ", join(' ', @a), "\n"; - return; - } - - print "compile-cluster: calling '$cmd ", join(' ', @a), "'\n"; + my $cmd_str = join(' ', $cmd, @a); + print "compile-cluster: '$cmd_str'\n"; + return if ($opt_just_print); system($cmd, @a) - and print("command failed: $!\n") - and exit(1); + and print("command '$cmd_str' failed\n") + and exit(1); } -exit(0); +use IPC::Open2; +sub build_cmd { + my ($cmd, @args) = @_; + my $cmd_str = join(' ', $cmd, @args); + print "compile-cluster: '$cmd_str'\n"; + return if ($opt_just_print); + $cmd_str.= " 2>&1"; + my ($chld_out, $chld_in); + my $pid = open2($chld_out, $chld_in, $cmd_str) or die $!; + # Create warning parser and pass every ouput line through it + my $parser = WarningParser->new(srcdir => $opt_srcdir, + unified => 1, + verbose => 1); + while (my $line = <$chld_out>) + { + if (!$parser->parse_line($line)) + { + # Warning parser didn't print the line, print it + print $line; + } + } + waitpid($pid, 0); + my $exit_status = $?; + my $exit_code = ($exit_status >> 8); + print "Build completed with exit_code: $exit_code(status: $exit_status)\n"; + if ($exit_code) + { + print("command '$cmd_str' failed: $!\n"); + exit(1); + } + $parser->report($0); +} + + +# Perl class used by WarningParser for keeping +# track of one individual warning +# +package WarningParser::Warning; +use strict; + +sub new { + my ($class, $file, $line, $text)= @_; + my $self= bless { + FILE => $file, + LINE => $line, + TEXT => $text, + }, $class; + return $self; +} + +sub file { + my ($self) = @_; + return $self->{FILE}; +} + +sub line { + my ($self) = @_; + return $self->{LINE}; +} + +sub text { + my ($self) = @_; + return $self->{TEXT}; +} + +# Print the warning in verbose format for easier debugging +sub print_verbose { + my ($self) = @_; + + print "{\n"; + foreach my $key (keys %$self) + { + print " $key => '$self->{$key}'\n"; + } + print "}\n"; +} + +# Print the warning in unified format(easy for automated build system to parse) +# emulate gcc +sub print_unified { + my ($self) = @_; + my $file = $self->file(); + my $line = $self->line(); + my $text = $self->text(); + print "$file:$line: warning: $text\n"; +} + +sub suppress { + my ($self, $message) = @_; + die if exists $self->{SUPPRESSED}; # Already suppressed + die unless $message; # No message + $self->{SUPPRESSED} = $message; +} + +sub is_suppressed { + my ($self) = @_; + return exists $self->{SUPPRESSED}; +} + +sub is_cluster_warning { + my ($self) = @_; + my $file = $self->{FILE}; + # Have the string ndb in the file name(including + # directory so everything below storage/ndb is + # automatically included) + if ($file =~ /ndb/) + { + return 1; + } + return 0; +} + + +package WarningParser; +use strict; + +sub new { + my $class= shift; + my %opts= ( @_ ); + my $srcdir = $opts{srcdir} || die "Must supply srcdir"; + my $verbose = $opts{verbose} || 0; + my $unified = $opts{unified} || 0; + my $track_dirs = $opts{track_dirs} || 0; + + my $self= bless { + # empty array of warnings + WARNINGS => [], + + # print each warning object as they are accumulated + VERBOSE => $verbose, + + # print warnings in unified format(i.e the format + # is converted to look like standard gcc). This makes it + # easy for higher level tools to parse the warnings + # regardless of compiler. + UNIFIED => $unified, + + # Need to keep track of current dir since file name in + # warnings does not include directory(this is normal + # in makefiles generated by automake) + TRACK_DIRS => $track_dirs, + + # Location of source + SRCDIR => $srcdir, + + }, $class; + return $self; +} + +sub new_warning { + my ($self, $file, $line, $text) = @_; + if ($self->{TRACK_DIRS}) + { + # file does not contain directory, add currently + # tracked dir + my $dir = $self->{DIR}; + my $srcdir = $self->{SRCDIR}; + $dir =~ s/^$srcdir//; # Remove leading srcdir + $dir =~ s:^\/::; # Remove leading slash + $file= "$dir/$file"; + } + return WarningParser::Warning->new($file, $line, $text); +} + +sub parse_warning { + my ($self, $line) = @_; + + if ($self->{TRACK_DIRS}) + { + # Track current directory by parsing makes + # "Entering/Leaving directory" messages + if ($line =~ /Entering directory \`(.*)\'/) + { + my $dir= $1; + # Push previous dir onto stack before setting new + push(@{$self->{DIRSTACK}}, $self->{DIR}); + $self->{DIR}= $dir; + } + + if ($line =~ /Leaving directory \`(.*)\'/) + { + # Pop previous dir from stack and set it as current + my $prevdir= pop(@{$self->{DIRSTACK}}); + $self->{DIR}= $prevdir; + } + } + + # cmake and Visual Studio 10(seems to use msbuild) + if ($line =~ /^\s*(.*)\((\d+)\): warning ([^ ]*:.*)$/) + { + return $self->new_warning($1, $2, $3); + } + + # cmake and Visual Studio 9 + if ($line =~ /^(\d+>)?(?:[a-z]:)?([^:()]*)\((\d+)\) : warning ([^ ]*:.*)$/) + { + my ($project, $file, $lineno, $text) = ($1, $2, $3, $4); + return $self->new_warning($file, $lineno, $text); + } + + # cmake and gcc with line number AND column + if ($line =~ /([^ ]+\.(c|h|cc|cpp|hpp|ic|i|y|l)):([0-9]+):([0-9]+):[ \t]*warning:[ \t]*(.*)$/) + { + my ($file, $junk, $lineno, $colno, $text) = ($1, $2, $3, $4, $5); + return $self->new_warning($file, $lineno, $text); + } + + # cmake and gcc + if ($line =~ /([^ ]+\.(c|h|cc|cpp|hpp|ic|i|y|l)):[ \t]*([0-9]+):[ \t]*warning:[ \t]*(.*)$/) + { + return $self->new_warning($1, $3, $4); + } + + return undef; +} + +sub suppress_warning { + my ($self, $w) = @_; + + # Ignore files not owned by cluster team + if (!$w->is_cluster_warning()) + { + $w->suppress('Warning in file not owned by cluster team'); + return 1; + } + + # List of supressions consisting of one regex for the dir+file name + # and one for the warning text. The suppression is stored as a + # list of arrays, where each array contains two precompiled + # regexes. If both expressions match, the warning is suppressed. + my @suppressions = ( + # [ qr//, qr// ], + ); + + foreach my $sup ( @suppressions ) + { + my $file_pat = $sup->[0]; + my $text_pat = $sup->[1]; + if ($w->file() =~ /$file_pat/ and + $w->text() =~ /$text_pat/) + { + $w->suppress("Suppressed by file suppression: '$file_pat, $text_pat'"); + return 1; + } + } + + return 0; +} + +# Parse a line for warnings and return 1 if warning was +# found(even if it was suppressed) +# +sub parse_line { + my ($self, $line) = @_; + $self->{LINES}++; + + # Remove trailing line feed and new line + $line =~ s/[\r]+$//g; + $line =~ s/[\n]+$//g; + + my $w = $self->parse_warning($line); + if (defined $w) + { + if (!$self->suppress_warning($w)) + { + if ($self->{UNIFIED}) + { + # Print the warning in UNIFIED format + $w->print_unified(); + } + else + { + # Just echo the line verbatim + print "\n$line\n"; + } + } + # Print the warning object in verbose mode + $w->print_verbose() if $self->{VERBOSE}; + + # Save the warning for final report + push(@{$self->{WARNINGS}}, $w); + + return 1; + } + + return 0; +} + +sub report { + my ($self, $prefix) = @_; + my $lines = $self->{LINES}; + + my $warnings = 0; + my $suppressed= 0; + + foreach my $w (@{$self->{WARNINGS}}) + { + if ($w->is_suppressed()) + { + $suppressed++; + } + else + { + $warnings++; + } + } + my $total = $warnings + $suppressed; + print "$prefix: $warnings warnings found(suppressed $suppressed of total $total)\n"; +} + +1; === modified file 'storage/ndb/test/ndbapi/testInterpreter.cpp' --- a/storage/ndb/test/ndbapi/testInterpreter.cpp 2011-07-05 12:46:07 +0000 +++ b/storage/ndb/test/ndbapi/testInterpreter.cpp 2012-11-12 12:21:47 +0000 @@ -210,8 +210,8 @@ int runTestBug19537(NDBT_Context* ctx, N // write from register 1 to 32-bit column KOL2 const Uint64 reg_val = 0x0102030405060708ULL; Uint32 reg_ptr32[2]; - memcpy(reg_ptr32+0, (Uint8*)®_val, sizeof(Uint32)); - memcpy(reg_ptr32+1, ((Uint8*)®_val)+4, sizeof(Uint32)); + memcpy(&(reg_ptr32[0]), (Uint8*)®_val, sizeof(Uint32)); + memcpy(&(reg_ptr32[1]), ((Uint8*)®_val)+4, sizeof(Uint32)); if (reg_ptr32[0] == 0x05060708 && reg_ptr32[1] == 0x01020304) { g_err << "runTestBug19537: platform is LITTLE endian" << endl; } else if (reg_ptr32[0] == 0x01020304 && reg_ptr32[1] == 0x05060708) { No bundle (reason: useless for push emails).