This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: Python: fetch value when building gdb.Value object
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: Pedro Alves <pedro at codesourcery dot com>
- Cc: gdb-patches at sourceware dot org, Phil Muldoon <pmuldoon at redhat dot com>, Paul Koning <paulkoning at comcast dot net>
- Date: Sat, 1 Oct 2011 13:02:50 +0200
- Subject: Re: Python: fetch value when building gdb.Value object
- References: <36B29E9D-F2B3-446F-AF8A-97254A3AAEE2@comcast.net> <m3ipocii6a.fsf@redhat.com> <20111001092852.GB11227@host1.jankratochvil.net> <201110011122.46865.pedro@codesourcery.com>
On Sat, 01 Oct 2011 12:22:46 +0200, Pedro Alves wrote:
> On Saturday 01 October 2011 10:28:52, Jan Kratochvil wrote:
> > # Test memory error.
> > gdb_test "python print gdb.parse_and_eval('*(int*)0')" "gdb.MemoryError: Cannot access memory at address 0x0.*"
> > + gdb_test "python inval = gdb.parse_and_eval('*(int*)0')" "gdb.MemoryError: Cannot access memory at address 0x0.*"
>
> I see this is already the case, but just a reminder that this will fail
> (or rather the write will succeed) on targets without an MMU. We should
> skip it with something like:
So checked it in (I am aware the existing code elsewhere in GDB testsuite is
a bit different).
Thanks,
Jan
http://sourceware.org/ml/gdb-cvs/2011-10/msg00002.html
--- src/gdb/testsuite/ChangeLog 2011/09/30 15:07:32 1.2867
+++ src/gdb/testsuite/ChangeLog 2011/10/01 11:02:10 1.2868
@@ -1,3 +1,12 @@
+2011-10-01 Jan Kratochvil <jan.kratochvil@redhat.com>
+ Pedro Alves <pedro@codesourcery.com>
+
+ * 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 <mpolacek@redhat.com>
* gdb.python/python.exp (verify pagination beforehand)
--- src/gdb/testsuite/gdb.python/py-value.exp 2011/07/26 18:38:55 1.22
+++ src/gdb/testsuite/gdb.python/py-value.exp 2011/10/01 11:02:11 1.23
@@ -216,8 +216,25 @@
# 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\""