From 46f886f1f598b001afc5cb85be195714464459d1 Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Sat, 1 Oct 2011 11:02:11 +0000 Subject: [PATCH] gdb/testsuite/ * gdb.python/py-value.exp (test_value_in_inferior): New variable can_read_0, test for it. (python print gdb.parse_and_eval('*(int*)0')): Rename to ... (parse_and_eval with memory error): ... here, make it untested if can_read_0. --- gdb/testsuite/ChangeLog | 9 +++++++++ gdb/testsuite/gdb.python/py-value.exp | 19 ++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index b5b40ef0a05..a2380a0eb74 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2011-10-01 Jan Kratochvil + Pedro Alves + + * gdb.python/py-value.exp (test_value_in_inferior): New variable + can_read_0, test for it. + (python print gdb.parse_and_eval('*(int*)0')): Rename to ... + (parse_and_eval with memory error): ... here, make it untested if + can_read_0. + 2011-09-30 Marek Polacek * gdb.python/python.exp (verify pagination beforehand) diff --git a/gdb/testsuite/gdb.python/py-value.exp b/gdb/testsuite/gdb.python/py-value.exp index bb9bed54407..35fe0be4375 100644 --- a/gdb/testsuite/gdb.python/py-value.exp +++ b/gdb/testsuite/gdb.python/py-value.exp @@ -216,8 +216,25 @@ proc test_value_in_inferior {} { # Test address attribute gdb_test "python print 'result =', arg0.address" "= 0x\[\[:xdigit:\]\]+" "Test address attribute" + # Test displaying a variable that is temporarily at a bad address. + # But if we can examine what's at memory address 0, then we'll also be + # able to display it without error. Don't run the test in that case. + set can_read_0 0 + gdb_test_multiple "x 0" "memory at address 0" { + -re "0x0:\[ \t\]*Cannot access memory at address 0x0\r\n$gdb_prompt $" { } + -re "0x0:\[ \t\]*Error accessing memory address 0x0\r\n$gdb_prompt $" { } + -re "\r\n$gdb_prompt $" { + set can_read_0 1 + } + } + # Test memory error. - gdb_test "python print gdb.parse_and_eval('*(int*)0')" "gdb.MemoryError: Cannot access memory at address 0x0.*" + set test "parse_and_eval with memory error" + if {$can_read_0} { + untested $test + } else { + gdb_test "python print gdb.parse_and_eval('*(int*)0')" "gdb.MemoryError: Cannot access memory at address 0x0.*" $test + } # Test string fetches, both partial and whole. gdb_test "print st" "\"divide et impera\"" -- 2.30.2