From patchwork Tue Jun 10 18:22:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Maciej W. Rozycki" X-Patchwork-Id: 1425 Received: (qmail 29566 invoked by alias); 10 Jun 2014 18:24:07 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 29445 invoked by uid 89); 10 Jun 2014 18:24:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 10 Jun 2014 18:24:04 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1WuQiH-0000LQ-9Y from Maciej_Rozycki@mentor.com for gdb-patches@sourceware.org; Tue, 10 Jun 2014 11:24:01 -0700 Received: from SVR-IES-FEM-01.mgc.mentorg.com ([137.202.0.104]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Tue, 10 Jun 2014 11:24:01 -0700 Received: from localhost (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server (TLS) id 14.2.247.3; Tue, 10 Jun 2014 19:23:59 +0100 Date: Tue, 10 Jun 2014 19:22:33 +0100 From: "Maciej W. Rozycki" To: Subject: [PATCH] GDB/testsuite: Add a way to send multiple init commands Message-ID: User-Agent: Alpine 1.10 (DEB 962 2008-03-14) MIME-Version: 1.0 Hi, We've been using this change since time immemorial, in fact our recorded original internal ChangeLog entry date is 2005-08-15. I've thought this piece might be useful for other people so I'm sharing it here. 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. I have a separate change for DejaGNU too, being posted right away, that adds an `add_board_info' procedure that makes it easy to append entries there; it's not strictly needed here or anywhere in our testsuite though. There's nothing really to regression-test here, beside checking that TCL doesn't choke on it (it doesn't), it's worked for me in real uses for years too. OK to apply? 2014-06-10 Maciej W. Rozycki Maciej W. Rozycki * lib/gdb.exp (gdb_run_cmd): Process `gdb_init_commands'. * lib/mi-support.exp (mi_run_cmd): Process `gdb_init_commands'. Maciej gdb-init-commands.diff Index: gdb-fsf-trunk-quilt/gdb/testsuite/lib/gdb.exp =================================================================== --- gdb-fsf-trunk-quilt.orig/gdb/testsuite/lib/gdb.exp 2014-06-06 15:04:15.000000000 +0100 +++ gdb-fsf-trunk-quilt/gdb/testsuite/lib/gdb.exp 2014-06-06 15:05:05.867648960 +0100 @@ -219,6 +219,19 @@ proc gdb_run_cmd {args} { } } } + if [target_info exists gdb_init_commands] { + set commands [target_info gdb_init_commands]; + for { set x 0; } { $x < [llength $commands] } { incr x } { + send_gdb "[lindex $commands $x]\n"; + gdb_expect 30 { + -re "$gdb_prompt $" { } + default { + perror "gdb_init_command for target failed"; + return; + } + } + } + } if $use_gdb_stub { if [target_info exists gdb,do_reload_on_run] { Index: gdb-fsf-trunk-quilt/gdb/testsuite/lib/mi-support.exp =================================================================== --- gdb-fsf-trunk-quilt.orig/gdb/testsuite/lib/mi-support.exp 2014-06-03 15:23:23.000000000 +0100 +++ gdb-fsf-trunk-quilt/gdb/testsuite/lib/mi-support.exp 2014-06-06 15:05:05.867648960 +0100 @@ -869,6 +869,19 @@ proc mi_run_cmd_full {use_mi_command arg } } } + if [target_info exists gdb_init_commands] { + set commands [target_info gdb_init_commands]; + for { set x 0; } { $x < [llength $commands] } { incr x } { + send_gdb "[lindex $commands $x]\n"; + gdb_expect 30 { + -re "$mi_gdb_prompt$" { } + default { + perror "gdb_init_command for target failed"; + return -1; + } + } + } + } if { [mi_gdb_target_load] < 0 } { return -1