Re: Python: fetch value when building gdb.Value object

Pedro Alves
2011-10-01T10:23:06Z

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:

set can_read_zero 0
gdb_test_multiple "x 0" "memory at address 0" {
-re "0x0:.*Cannot access memory at address 0x0.*$gdb_prompt $" { }
-re "0x0:.*Error accessing memory address 0x0.*$gdb_prompt $" { }
-re ".*$gdb_prompt $" {
set can_read_zero 1
}
}

if { !$can_read_zero } {
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.*"
}

--
Pedro Alves