From a25eb0280d6ae5a791e0e613f42e3197c82d3030 Mon Sep 17 00:00:00 2001 From: "Maciej W. Rozycki" Date: Sat, 12 Jul 2014 01:22:25 +0100 Subject: [PATCH] gdb/testsuite: Add a way to send multiple init commands Right now we provide a board info entry, `gdb_init_command', that allows one to send a single command to GDB before the program to be debugged is started. This is useful e.g. for slow remote targets to change the default "remotetimeout" setting. Occasionally I found a need to send multiple commands instead, however this cannot be achieved with `gdb_init_command'. This change therefore extends the mechanism by adding a TCL list of GDB commands to send, via a board info entry called `gdb_init_commands'. There is no limit as to the number of commands put there. The old `gdb_init_command' mechanism remains supported for compatibility with existing people's environments. * lib/gdb-utils.exp: New file. * lib/gdb.exp (gdb_run_cmd): Call gdb_init_commands, replacing inline `gdb_init_command' processing. (gdb_start_cmd): Likewise. * lib/mi-support.exp (mi_run_cmd): Likewise. * README: Document `gdb_init_command' and `gdb_init_commands'. --- gdb/testsuite/ChangeLog | 10 ++++++++++ gdb/testsuite/README | 10 ++++++++++ gdb/testsuite/lib/gdb-utils.exp | 30 ++++++++++++++++++++++++++++++ gdb/testsuite/lib/gdb.exp | 9 +++++---- gdb/testsuite/lib/mi-support.exp | 6 ++++-- 5 files changed, 59 insertions(+), 6 deletions(-) create mode 100644 gdb/testsuite/lib/gdb-utils.exp diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 253eeeb1f35..06522303aac 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,13 @@ +2014-07-12 Maciej W. Rozycki + Maciej W. Rozycki + + * lib/gdb-utils.exp: New file. + * lib/gdb.exp (gdb_run_cmd): Call gdb_init_commands, replacing + inline `gdb_init_command' processing. + (gdb_start_cmd): Likewise. + * lib/mi-support.exp (mi_run_cmd): Likewise. + * README: Document `gdb_init_command' and `gdb_init_commands'. + 2014-07-11 Jan Kratochvil Fix false FAIL running under a very long directory name. diff --git a/gdb/testsuite/README b/gdb/testsuite/README index eadab57a7a3..466993d4f06 100644 --- a/gdb/testsuite/README +++ b/gdb/testsuite/README @@ -271,6 +271,16 @@ gdb,use_precord The board supports process record. +gdb_init_command +gdb_init_commands + + Commands to send to GDB every time a program is about to be run. The + first of these settings defines a single command as a string. The + second defines a TCL list of commands being a string each. The commands + are sent one by one in a sequence, first from `gdb_init_command', if any, + followed by individual commands from `gdb_init_command', if any, in this + list's order. + gdb_server_prog The location of GDBserver. If GDBserver somewhere other than its diff --git a/gdb/testsuite/lib/gdb-utils.exp b/gdb/testsuite/lib/gdb-utils.exp new file mode 100644 index 00000000000..7e03cbf33d9 --- /dev/null +++ b/gdb/testsuite/lib/gdb-utils.exp @@ -0,0 +1,30 @@ +# Copyright 2014 Free Software Foundation, Inc. + +# 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 +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Utility procedures, shared between test suite domains. + +# A helper procedure to retrieve commands to send to GDB before a program +# is started. + +proc gdb_init_commands {} { + set commands "" + if [target_info exists gdb_init_command] { + lappend commands [target_info gdb_init_command] + } + if [target_info exists gdb_init_commands] { + set commands [concat $commands [target_info gdb_init_commands]] + } + return $commands +} diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 30463a97fda..3388e1f1407 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -27,6 +27,7 @@ if {$tool == ""} { load_lib libgloss.exp load_lib cache.exp +load_lib gdb-utils.exp global GDB @@ -209,8 +210,8 @@ proc delete_breakpoints {} { proc gdb_run_cmd {args} { global gdb_prompt use_gdb_stub - if [target_info exists gdb_init_command] { - send_gdb "[target_info gdb_init_command]\n" + foreach command [gdb_init_commands] { + send_gdb "$command\n" gdb_expect 30 { -re "$gdb_prompt $" { } default { @@ -311,8 +312,8 @@ proc gdb_run_cmd {args} { proc gdb_start_cmd {args} { global gdb_prompt use_gdb_stub - if [target_info exists gdb_init_command] { - send_gdb "[target_info gdb_init_command]\n" + foreach command [gdb_init_commands] { + send_gdb "$command\n" gdb_expect 30 { -re "$gdb_prompt $" { } default { diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp index f1b57497312..204f1e8f01c 100644 --- a/gdb/testsuite/lib/mi-support.exp +++ b/gdb/testsuite/lib/mi-support.exp @@ -17,6 +17,8 @@ # Test setup routines that work with the MI interpreter. +load_lib gdb-utils.exp + # The variable mi_gdb_prompt is a regexp which matches the gdb mi prompt. # Set it if it is not already set. global mi_gdb_prompt @@ -859,8 +861,8 @@ proc mi_run_cmd_full {use_mi_command args} { set run_match "" } - if [target_info exists gdb_init_command] { - send_gdb "[target_info gdb_init_command]\n" + foreach command [gdb_init_commands] { + send_gdb "$command\n" gdb_expect 30 { -re "$mi_gdb_prompt$" { } default { -- 2.30.2