From 250c5aa02cd6d0dd68b5ae3f1ddc35be951c1349 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 30 Oct 2018 20:13:15 +0100 Subject: [PATCH] ./mtr --gdb='b mysql_parse;r' --gdb now accepts an argument, it will be passed to gdb as a command. multiple commands can be separated by a (non-standard and not escapable) delimiter - semicolon (;). Old usage with a bare --gdb continues to work too, of course. Cherry-picked c47c0ca50c4 5441bbd3b1f 339b9055791 --- mysql-test/mysql-test-run.pl | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index ade3f99104e..8253af5fbbd 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1140,7 +1140,7 @@ sub command_line_setup { 'debug' => \$opt_debug, 'debug-common' => \$opt_debug_common, 'debug-server' => \$opt_debug_server, - 'gdb' => \$opt_gdb, + 'gdb=s' => \$opt_gdb, 'client-gdb' => \$opt_client_gdb, 'manual-gdb' => \$opt_manual_gdb, 'manual-lldb' => \$opt_manual_lldb, @@ -1234,6 +1234,9 @@ sub command_line_setup { 'skip-test-list=s' => \@opt_skip_test_list ); + # fix options (that take an optional argument and *only* after = sign + my %fixopt = ( '--gdb' => '--gdb=#' ); + @ARGV = map { $fixopt{$_} or $_ } @ARGV; GetOptions(%options) or usage("Can't read options"); usage("") if $opt_usage; list_options(\%options) if $opt_list_options; @@ -5992,7 +5995,9 @@ sub gdb_arguments { # Put $args into a single string $input = $input ? "< $input" : ""; - if ($type ne 'client' and $opt_valgrind_mysqld) { + if ($type eq 'client') { + mtr_tofile($gdb_init_file, "set args @$$args $input"); + } elsif ($opt_valgrind_mysqld) { my $v = $$exe; my $vargs = []; valgrind_arguments($vargs, \$v); @@ -6002,7 +6007,11 @@ shell sleep 1 target remote | /usr/lib64/valgrind/../../bin/vgdb EOF } else { - mtr_tofile($gdb_init_file, "set args @$$args $input\n"); + mtr_tofile($gdb_init_file, + join("\n", + "set args @$$args $input", + split /;/, $opt_gdb || "" + )); } if ( $opt_manual_gdb )