Patchwork [v3,testsuite] gdb-test.exp: catch error running gdb command

login
register
mail settings
Submitter Janis Johnson
Date Jan. 3, 2013, 11:57 p.m.
Message ID <50E61ADE.9040407@mentor.com>
Download mbox | patch
Permalink /patch/209339/
State New
Headers show

Comments

Janis Johnson - Jan. 3, 2013, 11:57 p.m.
The libstdc++ prettyprinter tests require a certain level of support
from GDB, and the check for that GDB support runs a command that
includes a quoted string.  This causes an error from the testsuite
infrastructure for embedded processors whose board support passes
commands through additional levels of procedures that lose the
backslashes that escape the quotes.  Adding more backslashes wouldn't
work because it would prevent the command from working for the majority
of boards.  I can't figure out a real solution to the problem.

Rather than gdb_version_check resulting in an error for boards that
pass a command through additional levels of procedure calls, this
patch lets it catch the error so that it can fail gracefully and the
tests will be reported as UNSUPPORTED.  This will skip the tests for
a relatively small number of test setups.

OK for trunk?

Janis
2013-01-03  Janis Johnson  <janisjo@codesourcery.com>

	* testsuite/lib/gdb-test.exp (gdb_batch_check): Catch error running
	gdb command.
Mike Stump - Jan. 6, 2013, 8:45 p.m.
On Jan 3, 2013, at 3:57 PM, Janis Johnson <janis_johnson@mentor.com> wrote:
> The libstdc++ prettyprinter tests require a certain level of support
> from GDB, and the check for that GDB support runs a command that
> includes a quoted string.  This causes an error from the testsuite
> infrastructure for embedded processors whose board support passes
> commands through additional levels of procedures that lose the
> backslashes that escape the quotes.  Adding more backslashes wouldn't
> work because it would prevent the command from working for the majority
> of boards.  I can't figure out a real solution to the problem.
> 
> Rather than gdb_version_check resulting in an error for boards that
> pass a command through additional levels of procedure calls, this
> patch lets it catch the error so that it can fail gracefully and the
> tests will be reported as UNSUPPORTED.  This will skip the tests for
> a relatively small number of test setups.
> 
> OK for trunk?

Ok.  If one wants to fix the real problem, just track down call chain and find who does what with quoting.  I usually do this by mixing in spaces, tabs, newlines, backslashes, single quotes and double quotes into the content and then ensue identity at the bottom.  At each step, the content should be preserved.  If anything strips content, that is wrong, and can be fixed by adding:

string=add_quotes(string)

before the thing that strips.  The exact form of add_quote is dependent upon the thing that does the stripped (interpretation).

Patch

Index: libstdc++-v3/testsuite/lib/gdb-test.exp
===================================================================
--- libstdc++-v3/testsuite/lib/gdb-test.exp	(revision 194619)
+++ libstdc++-v3/testsuite/lib/gdb-test.exp	(working copy)
@@ -219,7 +219,9 @@ 
     set gdb_name $::env(GUALITY_GDB_NAME)
     set cmd "$gdb_name -nw -nx -quiet -batch -ex \"$command\""
     send_log "Spawning: $cmd\n"
-    set res [remote_spawn target "$cmd"]
+    if [catch { set res [remote_spawn target "$cmd"] } ] {
+	return 0
+    }
     if { $res < 0 || $res == "" } {
 	return 0
     }