|
302 | 302 | our $opt_valgrind= 0;
|
303 | 303 | my $opt_valgrind_mysqld= 0;
|
304 | 304 | my $opt_valgrind_mysqltest= 0;
|
305 |
| -my @default_valgrind_args= ("--show-reachable=yes"); |
306 | 305 | my @valgrind_args;
|
307 | 306 | my $opt_valgrind_path;
|
308 | 307 | my $valgrind_reports= 0;
|
@@ -1687,6 +1686,16 @@ sub command_line_setup {
|
1687 | 1686 | "for option --testsuite-timeout")
|
1688 | 1687 | if ($opt_suite_timeout <= 0);
|
1689 | 1688 |
|
| 1689 | + # -------------------------------------------------------------------------- |
| 1690 | + # Check trace protocol option |
| 1691 | + # -------------------------------------------------------------------------- |
| 1692 | + if ( $opt_trace_protocol ) |
| 1693 | + { |
| 1694 | + push(@opt_extra_mysqld_opt, "--optimizer_trace=enabled=on,one_line=off"); |
| 1695 | + # Some queries yield big traces: |
| 1696 | + push(@opt_extra_mysqld_opt, "--optimizer-trace-max-mem-size=1000000"); |
| 1697 | + } |
| 1698 | + |
1690 | 1699 | # --------------------------------------------------------------------------
|
1691 | 1700 | # Check valgrind arguments
|
1692 | 1701 | # --------------------------------------------------------------------------
|
@@ -1720,32 +1729,40 @@ sub command_line_setup {
|
1720 | 1729 | $opt_valgrind= 1;
|
1721 | 1730 | $opt_valgrind_mysqld= 1;
|
1722 | 1731 |
|
1723 |
| - # Set special valgrind options unless options passed on command line |
1724 |
| - push(@valgrind_args, "--trace-children=yes") |
1725 |
| - unless @valgrind_args; |
1726 |
| - } |
| 1732 | + push(@valgrind_args, "--tool=callgrind", "--trace-children=yes"); |
1727 | 1733 |
|
1728 |
| - if ( $opt_trace_protocol ) |
1729 |
| - { |
1730 |
| - push(@opt_extra_mysqld_opt, "--optimizer_trace=enabled=on,one_line=off"); |
1731 |
| - # some queries yield big traces: |
1732 |
| - push(@opt_extra_mysqld_opt, "--optimizer-trace-max-mem-size=1000000"); |
| 1734 | + # Increase the timeouts when running with callgrind |
| 1735 | + $opt_testcase_timeout*= 10; |
| 1736 | + $opt_suite_timeout*= 6; |
| 1737 | + $opt_start_timeout*= 10; |
| 1738 | + $opt_debug_sync_timeout*= 10; |
1733 | 1739 | }
|
1734 | 1740 |
|
1735 |
| - if ( $opt_valgrind ) |
| 1741 | + if ($opt_valgrind) |
1736 | 1742 | {
|
1737 |
| - # Set valgrind_options to default unless already defined |
1738 |
| - push(@valgrind_args, @default_valgrind_args) |
1739 |
| - unless @valgrind_args; |
| 1743 | + # Default to --tool=memcheck if no other tool has been explicitly |
| 1744 | + # specified. From >= 2.1.2, this option is needed |
| 1745 | + if (!@valgrind_args or !grep(/^--tool=/, @valgrind_args)) |
| 1746 | + { |
| 1747 | + # Set default valgrind options for memcheck, can be overriden by user |
| 1748 | + unshift(@valgrind_args, ("--tool=memcheck", "--num-callers=16", |
| 1749 | + "--show-reachable=yes")); |
| 1750 | + } |
1740 | 1751 |
|
1741 |
| - # Don't add --quiet; you will loose the summary reports. |
| 1752 | + # Add suppression file if not specified |
| 1753 | + if (!grep(/^--suppressions=/, @valgrind_args)) |
| 1754 | + { |
| 1755 | + push(@valgrind_args,"--suppressions=${glob_mysql_test_dir}/valgrind.supp") |
| 1756 | + if -f "$glob_mysql_test_dir/valgrind.supp"; |
| 1757 | + } |
1742 | 1758 |
|
| 1759 | + # Don't add --quiet; you will loose the summary reports. |
1743 | 1760 | mtr_report("Running valgrind with options \"",
|
1744 |
| - join(" ", @valgrind_args), "\""); |
1745 |
| - |
| 1761 | + join(" ", @valgrind_args), "\""); |
| 1762 | + |
1746 | 1763 | # Turn off check testcases to save time
|
1747 | 1764 | mtr_report("Turning off --check-testcases to save time when valgrinding");
|
1748 |
| - $opt_check_testcases = 0; |
| 1765 | + $opt_check_testcases = 0; |
1749 | 1766 | }
|
1750 | 1767 |
|
1751 | 1768 | if ($opt_debug_common)
|
@@ -5304,7 +5321,7 @@ ($$)
|
5304 | 5321 |
|
5305 | 5322 | if ( $opt_valgrind_mysqld )
|
5306 | 5323 | {
|
5307 |
| - valgrind_arguments($args, \$exe); |
| 5324 | + valgrind_arguments($args, \$exe, $mysqld->name()); |
5308 | 5325 | }
|
5309 | 5326 |
|
5310 | 5327 | mtr_add_arg($args, "--defaults-group-suffix=%s", $mysqld->after('mysqld'));
|
@@ -6335,19 +6352,23 @@ sub strace_server_arguments {
|
6335 | 6352 | sub valgrind_arguments {
|
6336 | 6353 | my $args= shift;
|
6337 | 6354 | my $exe= shift;
|
| 6355 | + my $report_prefix= shift; |
6338 | 6356 |
|
6339 |
| - if ( $opt_callgrind) |
| 6357 | + if (my @tool_list= grep(/^--tool=(memcheck|callgrind|massif)/, @valgrind_args)) |
6340 | 6358 | {
|
6341 |
| - mtr_add_arg($args, "--tool=callgrind"); |
6342 |
| - mtr_add_arg($args, "--base=$opt_vardir/log"); |
6343 |
| - } |
6344 |
| - else |
6345 |
| - { |
6346 |
| - mtr_add_arg($args, "--tool=memcheck"); # From >= 2.1.2 needs this option |
6347 |
| - mtr_add_arg($args, "--leak-check=yes"); |
6348 |
| - mtr_add_arg($args, "--num-callers=16"); |
6349 |
| - mtr_add_arg($args, "--suppressions=%s/valgrind.supp", $glob_mysql_test_dir) |
6350 |
| - if -f "$glob_mysql_test_dir/valgrind.supp"; |
| 6359 | + # Get the value of the last specified --tool=<> argument to valgrind |
| 6360 | + my ($tool_name)= $tool_list[-1] =~ /(memcheck|callgrind|massif)$/; |
| 6361 | + if ($tool_name=~ /memcheck/) |
| 6362 | + { |
| 6363 | + mtr_add_arg($args, "--leak-check=yes") ; |
| 6364 | + } |
| 6365 | + else |
| 6366 | + { |
| 6367 | + $$exe=~ /.*[\/](.*)$/; |
| 6368 | + my $report_prefix= defined $report_prefix ? $report_prefix : $1; |
| 6369 | + mtr_add_arg($args, "--$tool_name-out-file=$opt_vardir/log/". |
| 6370 | + "$report_prefix"."_$tool_name.out.%%p"); |
| 6371 | + } |
6351 | 6372 | }
|
6352 | 6373 |
|
6353 | 6374 | # Add valgrind options, can be overriden by user
|
|
0 commit comments