public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* PING [RFC] Testsuite: permit simple transformation of gdb_expect code
@ 2010-06-15  6:20 Pierre Muller
  2010-06-16 14:14 ` Jan Kratochvil
  0 siblings, 1 reply; 3+ messages in thread
From: Pierre Muller @ 2010-06-15  6:20 UTC (permalink / raw)
  To: gdb-patches; +Cc: drow

  I didn't really get any return on the
hart of the patch yet.

  As one of the main workers on the testsuite lately,
I will try to bug Daniel Jacobowitz.

  Daniel, could you please tell me
if this patch could be acceptable
and if it needs more changes?

Pierre Muller

> -----Message d'origine-----
> De : gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] De la part de Tom Tromey
> Envoyé : Thursday, June 03, 2010 5:40 PM
> À : Pierre Muller
> Cc : 'Joel Brobecker'; gdb-patches@sourceware.org
> Objet : Re: [RFC] Testsuite: permit simple transformation of gdb_expect
> code
> 
> >>>>> "Pierre" == Pierre Muller <pierre.muller@ics-cnrs.unistra.fr>
> writes:
> 
> Pierre> I thought about it, but I still didn't really
> Pierre> understand all the tcl command details:
> Pierre>   info exists VAR_NAME
> Pierre>   will return 1 if VAR_NAME exists
> Pierre> as either a global or a local variable,
> Pierre> but it seems that
> Pierre>   info proc PROC_NAME
> Pierre>    works as a regular expression,
> 
> They both work using a glob-like syntax, not regular expressions...

  That’s not what tcl 8.5 doc says...
and indeed
  [info exists transform_gdb_expect_code]
returns 1
while
  [info exists transform_gdb_expect_code*]
returns 0
 
> Pierre> and can thus return a list containing both PROC_NAME and
> Pierre> PROC_NAME_VERSION_2 procedures ...
> 
> ... so this happens only if you do "info proc PROC_NAME*".

  But of course you are right on that, 
which leaves us with two possibilities:
  use only a procedure, but this would mean
that there is no way to insert its code inside
gdb.exp itself.
 Thus I would still prefer that we do use a variable.

 So, here is a new proposal:
 - declare transform_gdb_expect_code as a global variable,
without setting it, and give some information in "gdb.exp"
about its use.
 - inside gdb_expect, test if the variable exists.
If it exists, also test that it does refer to an existing proc.
If the proc exists, call it, if not, issue a "perror"
unless the value of the variable is empty.
  This allows to use either 
unset transform_gdb_expect_code 
or
set transform_gdb_expect_code ""
to disable the transformation at any point
in the testsuite.
  
 Tested on gcc16, no changes found.

 Comments?

Pierre
 
2010-06-04  Pierre Muller  <muller@ics.u-strasbg.fr>

	* testsuite/lib/gdb.exp (transform_gdb_expect_code): New global 
	variable, not defined by default.
	(gdb_expect): Call TRANSFORM_GDB_EXPECT_CODE procedure
	if variable exists and refers to an existing procedure.

Index: src/gdb/testsuite/lib/gdb.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/gdb.exp,v
retrieving revision 1.149
diff -u -p -r1.149 gdb.exp
--- src/gdb/testsuite/lib/gdb.exp	3 Jun 2010 20:29:27 -0000
1.149
+++ src/gdb/testsuite/lib/gdb.exp	4 Jun 2010 07:09:01 -0000
@@ -98,6 +98,12 @@ if ![info exists env(EXEEXT)] {
 
 set octal "\[0-7\]+"
 
+# The variable transform_gdb_expect_code can be set to the name of
+# a procedure that will transform the code parameter of gdb_expect call
+# in order to cope for some target dependant problems
+# it can also be reset to an empty string to disable that operation
+global transform_gdb_expect_code
+
 ### Only procedures should come after this point.
 
 #
@@ -2171,6 +2177,14 @@ proc gdb_expect { args } {
 	}
     }
 
+    global transform_gdb_expect_code;
+    if [info exists transform_gdb_expect_code] {
+	if { "[info procs $transform_gdb_expect_code]" != "" } {
+	    set expcode [$transform_gdb_expect_code $expcode];
+	} elseif { "$transform_gdb_expect_code" != "" } {
+	    perror "Procedure $transform_gdb_expect_code unknown"
+	}
+    }
     global suppress_flag;
     global remote_suppress_flag;
     if [info exists remote_suppress_flag] {


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

* Re: PING [RFC] Testsuite: permit simple transformation of gdb_expect code
  2010-06-15  6:20 PING [RFC] Testsuite: permit simple transformation of gdb_expect code Pierre Muller
@ 2010-06-16 14:14 ` Jan Kratochvil
  2010-06-16 15:34   ` Pierre Muller
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Kratochvil @ 2010-06-16 14:14 UTC (permalink / raw)
  To: Pierre Muller; +Cc: gdb-patches, drow

On Tue, 15 Jun 2010 08:19:30 +0200, Pierre Muller wrote:
>   use only a procedure, but this would mean
> that there is no way to insert its code inside
> gdb.exp itself.

I do not understand this part.


>   This allows to use either 
> unset transform_gdb_expect_code 
> or
> set transform_gdb_expect_code ""
> to disable the transformation at any point
> in the testsuite.

With the patch proposed below one defines it using:
	proc transform_gdb_expect_code { expcode } {
	    verbose -log "code = <$expcode>"
	    return $expcode
	}
and undefines it using:
	rename transform_gdb_expect_code ""


Thanks,
Jan


2010-06-16  Pierre Muller  <muller@ics.u-strasbg.fr>
	    Jan Kratochvil  <jan.kratochvil@redhat.com>

	* lib/gdb.exp (gdb_expect): Call transform_gdb_expect_code procedure
	if it exists.

--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -2178,6 +2178,13 @@ proc gdb_expect { args } {
 	}
     }
 
+    # The global procedure transform_gdb_expect_code can transform the code
+    # parameter of gdb_expect call in order to cope for some target dependant
+    # problems.
+    if { "[info procs transform_gdb_expect_code]" != "" } {
+	set expcode [transform_gdb_expect_code $expcode]
+    }
+
     global suppress_flag;
     global remote_suppress_flag;
     if [info exists remote_suppress_flag] {

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

* RE: PING [RFC] Testsuite: permit simple transformation of gdb_expect code
  2010-06-16 14:14 ` Jan Kratochvil
@ 2010-06-16 15:34   ` Pierre Muller
  0 siblings, 0 replies; 3+ messages in thread
From: Pierre Muller @ 2010-06-16 15:34 UTC (permalink / raw)
  To: 'Jan Kratochvil'; +Cc: gdb-patches, drow



> -----Message d'origine-----
> De : gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] De la part de Jan Kratochvil
> Envoyé : Wednesday, June 16, 2010 4:14 PM
> À : Pierre Muller
> Cc : gdb-patches@sourceware.org; drow@false.org
> Objet : Re: PING [RFC] Testsuite: permit simple transformation of
> gdb_expect code
> 
> On Tue, 15 Jun 2010 08:19:30 +0200, Pierre Muller wrote:
> >   use only a procedure, but this would mean
> > that there is no way to insert its code inside
> > gdb.exp itself.
> 
> I do not understand this part.
 Once again, this is due to my lack of knowledge of
expect/tcl.
 
> >   This allows to use either
> > unset transform_gdb_expect_code
> > or
> > set transform_gdb_expect_code ""
> > to disable the transformation at any point
> > in the testsuite.
> 
> With the patch proposed below one defines it using:
> 	proc transform_gdb_expect_code { expcode } {
> 	    verbose -log "code = <$expcode>"
> 	    return $expcode
> 	}
> and undefines it using:
> 	rename transform_gdb_expect_code ""

 I didn't know about rename builtin command,
this means that we could define
proc gdb_allow_dos_type_readline { expcode} {
  which would translate the expcode to cope with the extra \n appearing in
that case,
and insert later

if { [istarget "*-*-mingw*"] || [istarget "*-*-*djgpp*"] } {
  rename gdb_allow_dos_type_readline transform_gdb_expect_code
}

  This is perfect for me!
 
> Thanks,
Thank you for this new simpler proposal!


> 2010-06-16  Pierre Muller  <muller@ics.u-strasbg.fr>
> 	    Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> 	* lib/gdb.exp (gdb_expect): Call transform_gdb_expect_code
> procedure
> 	if it exists.
> 
> --- a/gdb/testsuite/lib/gdb.exp
> +++ b/gdb/testsuite/lib/gdb.exp
> @@ -2178,6 +2178,13 @@ proc gdb_expect { args } {
>  	}
>      }
> 
> +    # The global procedure transform_gdb_expect_code can transform the
> code
> +    # parameter of gdb_expect call in order to cope for some target
> dependant
> +    # problems.
> +    if { "[info procs transform_gdb_expect_code]" != "" } {
> +	set expcode [transform_gdb_expect_code $expcode]
> +    }
> +
>      global suppress_flag;
>      global remote_suppress_flag;
>      if [info exists remote_suppress_flag] {

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

end of thread, other threads:[~2010-06-16 15:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-15  6:20 PING [RFC] Testsuite: permit simple transformation of gdb_expect code Pierre Muller
2010-06-16 14:14 ` Jan Kratochvil
2010-06-16 15:34   ` Pierre Muller

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).