This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFC] Testsuite: permit simple transformation of gdb_expect code
- From: "Pierre Muller" <pierre dot muller at ics-cnrs dot unistra dot fr>
- To: <gdb-patches at sourceware dot org>
- Date: Wed, 2 Jun 2010 14:41:15 +0200
- Subject: [RFC] Testsuite: permit simple transformation of gdb_expect code
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] {