aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/lib
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@efficios.com>2020-11-23 17:26:00 -0500
committerSimon Marchi <simon.marchi@efficios.com>2020-11-23 17:26:00 -0500
commit15a491af3cdc4d7487e848bd9648a15ac3a2d28f (patch)
treeab53cc2b6dace943d74de90510816b776e49f25c /gdb/testsuite/lib
parent891615f060ff6cf8ea5497fd5f07138a52fe4ede (diff)
downloadgdb-15a491af3cdc4d7487e848bd9648a15ac3a2d28f.zip
gdb-15a491af3cdc4d7487e848bd9648a15ac3a2d28f.tar.gz
gdb-15a491af3cdc4d7487e848bd9648a15ac3a2d28f.tar.bz2
gdb/testsuite: show evaluation errors in gdb_assert
Let's say you put this gdb_assert in a test: gdb_assert "some invalid tcl code" You just get: FAIL: gdb.base/template.exp: some invalid tcl code That's not very easy to debug, since you don't know what's invalid in your code. Change gdb_assert to print the error message when catch's return code is 1 (TCL_ERROR). The "warning" is shown both on stdout and in the log file. Mark the test as unresolved, because the evaluation error means we couldn't reach a valid pass/fail conclusion. gdb/testsuite/ChangeLog: * lib/gdb.exp (gdb_assert): Show error message on error. Change-Id: Ie6477859554e909ed8d07fb2769c6f2f55e7cce6
Diffstat (limited to 'gdb/testsuite/lib')
-rw-r--r--gdb/testsuite/lib/gdb.exp9
1 files changed, 8 insertions, 1 deletions
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index c42933b..f2954fd 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -1728,7 +1728,14 @@ proc gdb_assert { condition {message ""} } {
}
set code [catch {uplevel 1 expr $condition} res]
- if {$code != 0 || !$res} {
+ if {$code == 1} {
+ # If code is 1 (TCL_ERROR), it means evaluation failed and res contains
+ # an error message. Print the error message, and set res to 0 since we
+ # want to return a boolean.
+ warning "While evaluating expression in gdb_assert: $res"
+ unresolved $message
+ set res 0
+ } elseif { !$res } {
fail $message
} else {
pass $message