public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] GDB/testsuite: Add a way to send multiple init commands
@ 2014-06-10 18:24 Maciej W. Rozycki
  2014-06-10 18:52 ` Keith Seitz
  2014-06-11 15:39 ` Tom Tromey
  0 siblings, 2 replies; 13+ messages in thread
From: Maciej W. Rozycki @ 2014-06-10 18:24 UTC (permalink / raw)
  To: gdb-patches

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  <macro@mips.com>
            Maciej W. Rozycki  <macro@codesourcery.com>

	* 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

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2014-07-12  0:42 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-10 18:24 [PATCH] GDB/testsuite: Add a way to send multiple init commands Maciej W. Rozycki
2014-06-10 18:52 ` Keith Seitz
2014-06-11 15:39 ` Tom Tromey
2014-06-11 18:41   ` Maciej W. Rozycki
2014-06-19 23:39     ` [PING][PATCH] " Maciej W. Rozycki
2014-06-20  7:14       ` Eli Zaretskii
2014-06-20 22:53         ` Maciej W. Rozycki
2014-06-21  7:14           ` Eli Zaretskii
2014-06-23 14:03             ` Joel Brobecker
2014-06-20  8:50     ` [PATCH] " Pedro Alves
2014-07-10  0:17       ` [PATCH v2] " Maciej W. Rozycki
2014-07-10 16:15         ` Pedro Alves
2014-07-12  4:38           ` Maciej W. Rozycki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).