diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index da7823fddf2..d6358dd8856 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2020-11-23 Simon Marchi + + * lib/gdb.exp (gdb_assert): Show error message on error. + 2020-11-23 Tom de Vries * gdb.ada/enum_idx_packed.exp: Limit setup_kfail to gnat 9 and 10. diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index c42933b3f41..f2954fd5192 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