Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: "Maciej W. Rozycki" <macro@codesourcery.com>,
	       Tom Tromey <tromey@redhat.com>
Cc: Keith Seitz <keiths@redhat.com>, Eli Zaretskii <eliz@gnu.org>,
	       gdb-patches@sourceware.org
Subject: Re: [PATCH] GDB/testsuite: Add a way to send multiple init commands
Date: Fri, 20 Jun 2014 08:50:00 -0000	[thread overview]
Message-ID: <53A3F5BD.2030709@redhat.com> (raw)
In-Reply-To: <alpine.DEB.1.10.1406111821290.3047@tp.orcam.me.uk>

On 06/11/2014 07:39 PM, Maciej W. Rozycki wrote:

> 2014-06-11  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'.
> 	* README (Board Settings): Document `gdb_init_command' and 
> 	`gdb_init_commands'.

I don't particularly see much need for this -- I do this in my
boards instead:

 set GDBFLAGS ""
 set GDBFLAGS "${GDBFLAGS} -ex \"set breakpoint always-inserted on\""
 set GDBFLAGS "${GDBFLAGS} -ex \"set target-async 1\""

See:

https://sourceware.org/gdb/wiki/TestingGDB#Passing_an_option_to_GDB_.2BAC8_Running_the_whole_test_suite_in_a_non-default_mode

But, given gdb_init_command exists and this can be made
non-intrusive, it's fine with me to add the new option.

Thought, I'd much prefer if this code that appears twice:

> +    set commands ""
>      if [target_info exists gdb_init_command] {
> -	send_gdb "[target_info gdb_init_command]\n"
> +	lappend commands [target_info gdb_init_command]
> +    }
> +    if [target_info exists gdb_init_commands] {
> +	set commands [concat $commands [target_info gdb_init_commands]]
> +    }
> +    foreach command $commands {

was factored out to a procedure that returns the command list.  Like:

# Comment here
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
}

And then, both users can do

    foreach command [gdb_init_commands] {

-- 
Pedro Alves

> 
>   Maciej
> 
> gdb-init-commands.diff
> Index: gdb-fsf-trunk-quilt/gdb/testsuite/README
> ===================================================================
> --- gdb-fsf-trunk-quilt.orig/gdb/testsuite/README	2014-06-03 15:23:24.000000000 +0100
> +++ gdb-fsf-trunk-quilt/gdb/testsuite/README	2014-06-11 19:29:49.538972371 +0100
> @@ -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
> Index: gdb-fsf-trunk-quilt/gdb/testsuite/lib/gdb.exp
> ===================================================================
> --- gdb-fsf-trunk-quilt.orig/gdb/testsuite/lib/gdb.exp	2014-06-07 18:27:52.000000000 +0100
> +++ gdb-fsf-trunk-quilt/gdb/testsuite/lib/gdb.exp	2014-06-11 19:05:45.388928853 +0100
> @@ -209,8 +209,15 @@ proc delete_breakpoints {} {
>  proc gdb_run_cmd {args} {
>      global gdb_prompt use_gdb_stub
>  
> +    set commands ""
>      if [target_info exists gdb_init_command] {
> -	send_gdb "[target_info gdb_init_command]\n"
> +	lappend commands [target_info gdb_init_command]
> +    }
> +    if [target_info exists gdb_init_commands] {
> +	set commands [concat $commands [target_info gdb_init_commands]]
> +    }
> +    foreach command $commands {
> +	send_gdb "$command\n"
>  	gdb_expect 30 {
>  	    -re "$gdb_prompt $" { }
>  	    default {
> Index: gdb-fsf-trunk-quilt/gdb/testsuite/lib/mi-support.exp
> ===================================================================
> --- gdb-fsf-trunk-quilt.orig/gdb/testsuite/lib/mi-support.exp	2014-06-07 18:27:50.000000000 +0100
> +++ gdb-fsf-trunk-quilt/gdb/testsuite/lib/mi-support.exp	2014-06-11 19:06:27.888927573 +0100
> @@ -859,8 +859,15 @@ proc mi_run_cmd_full {use_mi_command arg
>  	set run_match ""
>      }
>  
> +    set commands ""
>      if [target_info exists gdb_init_command] {
> -	send_gdb "[target_info gdb_init_command]\n"
> +	lappend commands [target_info gdb_init_command]
> +    }
> +    if [target_info exists gdb_init_commands] {
> +	set commands [concat $commands [target_info gdb_init_commands]]
> +    }
> +    foreach command $commands {
> +	send_gdb "$command\n"
>  	gdb_expect 30 {
>  	    -re "$mi_gdb_prompt$" { }
>  	    default {
> 



  parent reply	other threads:[~2014-06-20  8:50 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-10 18:24 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     ` Pedro Alves [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53A3F5BD.2030709@redhat.com \
    --to=palves@redhat.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=keiths@redhat.com \
    --cc=macro@codesourcery.com \
    --cc=tromey@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox