This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 4/4] py-unwind-maint.exp: Allow unwinders to be called during python import
- From: Kevin Buettner <kevin at buettner dot to>
- To: gdb-patches at sourceware dot org
- Date: Wed, 28 Sep 2016 01:59:38 -0700
- Subject: [PATCH 4/4] py-unwind-maint.exp: Allow unwinders to be called during python import
- Authentication-results: sourceware.org; auth=none
- References: <20160928014455.438266a2@pinnacle.lan>
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(-)
diff --git a/gdb/testsuite/gdb.python/py-unwind-maint.exp b/gdb/testsuite/gdb.python/py-unwind-maint.exp
index 1253057..91b1fdf 100644
--- a/gdb/testsuite/gdb.python/py-unwind-maint.exp
+++ b/gdb/testsuite/gdb.python/py-unwind-maint.exp
@@ -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" {