[4/4] py-unwind-maint.exp: Allow unwinders to be called during python import
Commit Message
py-unwind-maint.exp: Allow unwinders to be called during python import
In his commit of "Fix PR19927: Avoid unwinder recursion if sniffer
uses calls parse_and_eval", Pedro updated the py-unwind-maint.exp
test to account for different behavior in GDB caused by his changes
to frame.c.
This patch changes py-unwind-maint.exp so that either behavior is
acceptable.
Regardless of which path is taken, the number of PASSes and the
names of the tests are the same.
gdb/testsuite/ChangeLog:
* gdb.python/py-unwind-maint.exp: Adjust tests to allow for
unwinders to be called as a side effect of "source" and "disable
unwinder" commands. If these side effects don't occur, detect
that behavior and run slightly different tests which are also
considered to be correct behavior.
---
gdb/testsuite/gdb.python/py-unwind-maint.exp | 59 ++++++++++++++++++++++++----
1 file changed, 51 insertions(+), 8 deletions(-)
Comments
On 09/28/2016 09:59 AM, Kevin Buettner wrote:
> py-unwind-maint.exp: Allow unwinders to be called during python import
Looks like you have the subject here again.
>
> In his commit of "Fix PR19927: Avoid unwinder recursion if sniffer
> uses calls parse_and_eval", Pedro updated the py-unwind-maint.exp
> test to account for different behavior in GDB caused by his changes
> to frame.c.
>
> This patch changes py-unwind-maint.exp so that either behavior is
> acceptable.
>
> Regardless of which path is taken, the number of PASSes and the
> names of the tests are the same.
I'd like to understand better the need for this.
BTW, should probably use gdb_test_multiple instead
of send_gdb/gdb_expect.
Thanks,
Pedro Alves
@@ -34,13 +34,49 @@ if ![runto_main ] then {
return -1
}
-gdb_test "source ${pyfile}" "Python script imported" \
- "import python scripts"
-gdb_test_sequence "frame" "All unwinders enabled" {
- "py_unwind_maint_ps_unwinder called"
- "global_unwinder called"
- "#0 main"
+send_gdb "source ${pyfile}\n"
+gdb_expect {
+ -re "Python script imported\r\n$gdb_prompt $" {
+ set unwinder_called_on_import false
+ }
+ -re ".*$gdb_prompt $" {
+ set unwinder_called_on_import true
+ }
+ timeout {
+ fail "Can't source python script"
+ return -1
+ }
+}
+
+clean_restart ${testfile}
+
+if ![runto_main ] then {
+ fail "Can't run to main"
+ return -1
+}
+
+if { $unwinder_called_on_import } {
+ gdb_test_sequence "source ${pyfile}" "import python scripts" {
+ "Python script imported"
+ "py_unwind_maint_ps_unwinder called"
+ "global_unwinder called"
+ }
+ # The unwinders were called above. We keep the name of the
+ # test the same so that it matches the case below and so that
+ # we have no greater or fewer passes regardless which path
+ # is taken.
+ gdb_test_sequence "frame" "All unwinders enabled" {
+ "#0 main"
+ }
+} else {
+ gdb_test "source ${pyfile}" "Python script imported" \
+ "import python scripts"
+ gdb_test_sequence "frame" "All unwinders enabled" {
+ "py_unwind_maint_ps_unwinder called"
+ "global_unwinder called"
+ "#0 main"
+ }
}
gdb_test_sequence "info unwinder" "Show all unwinders" {
@@ -57,8 +93,15 @@ gdb_test_sequence "continue" "Unwinders called" {
"global_unwinder called"
}
-gdb_test_sequence "disable unwinder global .*" "Unwinder disabled" {
- "1 unwinder disabled"
+if { $unwinder_called_on_import } {
+ gdb_test_sequence "disable unwinder global .*" "Unwinder disabled" {
+ "1 unwinder disabled"
+ "py_unwind_maint_ps_unwinder called"
+ }
+} else {
+ gdb_test_sequence "disable unwinder global .*" "Unwinder disabled" {
+ "1 unwinder disabled"
+ }
}
gdb_test_sequence "info unwinder" "Show with global unwinder disabled" {