scripts/dump-guest-memory.py: Improve python 3 compatibility
This commit does not make the script python 3 compatible, it is a preparation that fixes the easy and common incompatibilities. Print is a function in python 3 and therefore needs braces around its arguments. Range does not cast a gdb.Value object to int in python 3, we have to do it ourselves. Reviewed-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com> Message-Id: <1453464520-3882-4-git-send-email-frankja@linux.vnet.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
4789020384
commit
7cb1089d5f
@ -98,7 +98,7 @@ def memory_region_get_ram_ptr(mr):
|
|||||||
|
|
||||||
def get_guest_phys_blocks():
|
def get_guest_phys_blocks():
|
||||||
guest_phys_blocks = []
|
guest_phys_blocks = []
|
||||||
print "guest RAM blocks:"
|
print("guest RAM blocks:")
|
||||||
print("target_start target_end host_addr message "
|
print("target_start target_end host_addr message "
|
||||||
"count")
|
"count")
|
||||||
print("---------------- ---------------- ---------------- ------- "
|
print("---------------- ---------------- ---------------- ------- "
|
||||||
@ -106,7 +106,11 @@ def get_guest_phys_blocks():
|
|||||||
|
|
||||||
current_map_p = gdb.parse_and_eval("address_space_memory.current_map")
|
current_map_p = gdb.parse_and_eval("address_space_memory.current_map")
|
||||||
current_map = current_map_p.dereference()
|
current_map = current_map_p.dereference()
|
||||||
for cur in range(current_map["nr"]):
|
|
||||||
|
# Conversion to int is needed for python 3
|
||||||
|
# compatibility. Otherwise range doesn't cast the value itself and
|
||||||
|
# breaks.
|
||||||
|
for cur in range(int(current_map["nr"])):
|
||||||
flat_range = (current_map["ranges"] + cur).dereference()
|
flat_range = (current_map["ranges"] + cur).dereference()
|
||||||
mr = flat_range["mr"].dereference()
|
mr = flat_range["mr"].dereference()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user