* [RFC] Testsuite: permit simple transformation of gdb_expect code
@ 2010-06-02 12:41 Pierre Muller
2010-06-02 21:29 ` Joel Brobecker
0 siblings, 1 reply; 6+ messages in thread
From: Pierre Muller @ 2010-06-02 12:41 UTC (permalink / raw)
To: gdb-patches
Following the long discussion about
the problem of newlines on some systems,
http://sourceware.org/ml/gdb-patches/2009-06/msg00346.html
I would like to insert a no-op
change to lib/gdb.exp that allows easily to
write a transformation function (that can be
inside the target board file).
The idea is to simply add a global variable named
`transform_gdb_expect_code'
that defaults to empty.
If not empty this variable must expand to the named of a
procedure that will take exp_code value and transform it in order
to cope with target oddities like the newline problem.
This patch was tested on gcc16 without any change in
the testuite output.
The performance impact should be negligible.
Are there objections to this idea?
Is this patch likely to be accepted?
Pierre Muller
Pascal language support maintainer for GDB
PS: I do have procedures that try to cope with the newline
problems on djgpp or mingw* targets,
but nothing works perfectly, thus I would rather
like to wait more until I really submit those to gdb-patches.
Of course, if it is of interest to some of you,
I can email the current status of that part.
2010-06-02 Pierre Muller <muller@ics.u-strasbg.fr>
* testsuite/lib/gdb.exp (transform_gdb_expect_code): New global
variable, defauting to empty string.
(gdb_expect): Call TRANSFORM_GDB_EXPECT_CODE procedure
if not empty.
Index: src/gdb/testsuite/lib/gdb.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/gdb.exp,v
retrieving revision 1.148
diff -u -p -r1.148 gdb.exp
--- src/gdb/testsuite/lib/gdb.exp 20 May 2010 19:18:58 -0000
1.148
+++ src/gdb/testsuite/lib/gdb.exp 2 Jun 2010 09:06:10 -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
+global transform_gdb_expect_code
+set transform_gdb_expect_code ""
+
### Only procedures should come after this point.
#
@@ -2168,6 +2174,10 @@ proc gdb_expect { args } {
}
}
+ global transform_gdb_expect_code;
+ if { "$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] 6+ messages in thread
* Re: [RFC] Testsuite: permit simple transformation of gdb_expect code
2010-06-02 12:41 [RFC] Testsuite: permit simple transformation of gdb_expect code Pierre Muller
@ 2010-06-02 21:29 ` Joel Brobecker
2010-06-03 6:40 ` Pierre Muller
[not found] ` <14482.3657036342$1275547225@news.gmane.org>
0 siblings, 2 replies; 6+ messages in thread
From: Joel Brobecker @ 2010-06-02 21:29 UTC (permalink / raw)
To: Pierre Muller; +Cc: gdb-patches
> I would like to insert a no-op change to lib/gdb.exp that allows
> easily to write a transformation function (that can be inside the
> target board file). The idea is to simply add a global variable
> named `transform_gdb_expect_code' that defaults to empty.
No objection from my end in principle; I guess there is no way to
make that decision automatic? In AdaCore's testsuite, we get
the version information in GDB and determine from there the host
and target, and that allows to whether or not certain features
are available, etc.
In terms of implementation, rather than having an empty global,
perhaps it'd be just as simple to test its existence? Just thinking
out loud...
--
Joel
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [RFC] Testsuite: permit simple transformation of gdb_expect code
2010-06-02 21:29 ` Joel Brobecker
@ 2010-06-03 6:40 ` Pierre Muller
[not found] ` <14482.3657036342$1275547225@news.gmane.org>
1 sibling, 0 replies; 6+ messages in thread
From: Pierre Muller @ 2010-06-03 6:40 UTC (permalink / raw)
To: 'Joel Brobecker'; +Cc: gdb-patches
> -----Message d'origine-----
> De : gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] De la part de Joel Brobecker
> Envoyé : Wednesday, June 02, 2010 11:29 PM
> À : Pierre Muller
> Cc : gdb-patches@sourceware.org
> Objet : Re: [RFC] Testsuite: permit simple transformation of gdb_expect
> code
>
> > I would like to insert a no-op change to lib/gdb.exp that allows
> > easily to write a transformation function (that can be inside the
> > target board file). The idea is to simply add a global variable
> > named `transform_gdb_expect_code' that defaults to empty.
>
> No objection from my end in principle; I guess there is no way to
> make that decision automatic? In AdaCore's testsuite, we get
> the version information in GDB and determine from there the host
> and target, and that allows to whether or not certain features
> are available, etc.
>
> In terms of implementation, rather than having an empty global,
> perhaps it'd be just as simple to test its existence? Just thinking
> out loud...
Do you mean the variable or the procedure itself?
I thought about it, but I still didn't really
understand all the tcl command details:
info exists VAR_NAME
will return 1 if VAR_NAME exists
as either a global or a local variable,
but it seems that
info proc PROC_NAME
works as a regular expression,
and can thus return a list containing both PROC_NAME and PROC_NAME_VERSION_2
procedures ...
But I might be wrong.
I am still not very skilled in tcl in general:
does
global VAR;
already create that variable?
or does it just say that that name VAR should be looked up
in global namespace?
If it does not create the variable then
using
global gdb_transform_expect_code;
and
if [info exists gdb_transform_expect_code] {
would be cleaner probably.
I am still so new to tcl that I didn't even
try it out, out of fear that I would not really
correctly interpret the results I see!
Pierre
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFC] Testsuite: permit simple transformation of gdb_expect code
[not found] ` <14482.3657036342$1275547225@news.gmane.org>
@ 2010-06-03 15:40 ` Tom Tromey
2010-06-04 7:35 ` Pierre Muller
[not found] ` <12215.5377561741$1275636939@news.gmane.org>
0 siblings, 2 replies; 6+ messages in thread
From: Tom Tromey @ 2010-06-03 15:40 UTC (permalink / raw)
To: Pierre Muller; +Cc: 'Joel Brobecker', gdb-patches
>>>>> "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...
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*".
Pierre> I am still not very skilled in tcl in general:
Pierre> does
Pierre> global VAR;
Pierre> already create that variable?
Pierre> or does it just say that that name VAR should be looked up
Pierre> in global namespace?
The latter.
Pierre> I am still so new to tcl that I didn't even
Pierre> try it out, out of fear that I would not really
Pierre> correctly interpret the results I see!
:-)
Tom
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [RFC] Testsuite: permit simple transformation of gdb_expect code
2010-06-03 15:40 ` Tom Tromey
@ 2010-06-04 7:35 ` Pierre Muller
[not found] ` <12215.5377561741$1275636939@news.gmane.org>
1 sibling, 0 replies; 6+ messages in thread
From: Pierre Muller @ 2010-06-04 7:35 UTC (permalink / raw)
To: tromey; +Cc: 'Joel Brobecker', gdb-patches
> -----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...
Thats 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] 6+ messages in thread
* Re: [RFC] Testsuite: permit simple transformation of gdb_expect code
[not found] ` <12215.5377561741$1275636939@news.gmane.org>
@ 2010-06-04 16:48 ` Tom Tromey
0 siblings, 0 replies; 6+ messages in thread
From: Tom Tromey @ 2010-06-04 16:48 UTC (permalink / raw)
To: Pierre Muller; +Cc: 'Joel Brobecker', gdb-patches
>>>>> "Pierre" == Pierre Muller <pierre.muller@ics-cnrs.unistra.fr> writes:
Tom> They both work using a glob-like syntax, not regular expressions...
Pierre> That’s not what tcl 8.5 doc says...
Oops, sorry, I confused info exists and info vars.
The former just takes a name, the latter takes a glob.
Tom
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-06-04 16:48 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-02 12:41 [RFC] Testsuite: permit simple transformation of gdb_expect code Pierre Muller
2010-06-02 21:29 ` Joel Brobecker
2010-06-03 6:40 ` Pierre Muller
[not found] ` <14482.3657036342$1275547225@news.gmane.org>
2010-06-03 15:40 ` Tom Tromey
2010-06-04 7:35 ` Pierre Muller
[not found] ` <12215.5377561741$1275636939@news.gmane.org>
2010-06-04 16:48 ` Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox