[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 46/49] scripts/dump-guest-memory.py: Improve python 3
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 46/49] scripts/dump-guest-memory.py: Improve python 3 compatibility |
Date: |
Tue, 26 Jan 2016 14:47:18 +0100 |
From: Janosch Frank <address@hidden>
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 <address@hidden>
Signed-off-by: Janosch Frank <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
scripts/dump-guest-memory.py | 26 +++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)
diff --git a/scripts/dump-guest-memory.py b/scripts/dump-guest-memory.py
index d0b927a..bb4ca8e 100644
--- a/scripts/dump-guest-memory.py
+++ b/scripts/dump-guest-memory.py
@@ -98,15 +98,19 @@ def memory_region_get_ram_ptr(mr):
def get_guest_phys_blocks():
guest_phys_blocks = []
- print "guest RAM blocks:"
- print ("target_start target_end host_addr message "
- "count")
- print ("---------------- ---------------- ---------------- ------- "
- "-----")
+ print("guest RAM blocks:")
+ print("target_start target_end host_addr message "
+ "count")
+ print("---------------- ---------------- ---------------- ------- "
+ "-----")
current_map_p = gdb.parse_and_eval("address_space_memory.current_map")
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()
mr = flat_range["mr"].dereference()
@@ -149,9 +153,9 @@ def get_guest_phys_blocks():
predecessor["target_end"] = target_end
message = "joined"
- print ("%016x %016x %016x %-7s %5u" %
- (target_start, target_end, host_addr.cast(UINTPTR_T),
- message, len(guest_phys_blocks)))
+ print("%016x %016x %016x %-7s %5u" %
+ (target_start, target_end, host_addr.cast(UINTPTR_T),
+ message, len(guest_phys_blocks)))
return guest_phys_blocks
@@ -311,8 +315,8 @@ shape and this command should mostly work."""
for block in self.guest_phys_blocks:
cur = block["host_addr"]
left = block["target_end"] - block["target_start"]
- print ("dumping range at %016x for length %016x" %
- (cur.cast(UINTPTR_T), left))
+ print("dumping range at %016x for length %016x" %
+ (cur.cast(UINTPTR_T), left))
while (left > 0):
chunk_size = min(TARGET_PAGE_SIZE, left)
chunk = qemu_core.read_memory(cur, chunk_size)
--
1.8.3.1
- [Qemu-devel] [PULL 37/49] scripts/kvm/kvm_stat: Fix rlimit for unprivileged users, (continued)
- [Qemu-devel] [PULL 37/49] scripts/kvm/kvm_stat: Fix rlimit for unprivileged users, Paolo Bonzini, 2016/01/26
- [Qemu-devel] [PULL 38/49] scripts/kvm/kvm_stat: Fixup filtering, Paolo Bonzini, 2016/01/26
- [Qemu-devel] [PULL 32/49] scripts/kvm/kvm_stat: Remove unneeded X86_EXIT_REASONS, Paolo Bonzini, 2016/01/26
- [Qemu-devel] [PULL 35/49] scripts/kvm/kvm_stat: Cleanup and pre-init perf_event_attr, Paolo Bonzini, 2016/01/26
- [Qemu-devel] [PULL 40/49] scripts/kvm/kvm_stat: Add optparse description, Paolo Bonzini, 2016/01/26
- [Qemu-devel] [PULL 41/49] cpus: use broadcast on qemu_pause_cond, Paolo Bonzini, 2016/01/26
- [Qemu-devel] [PULL 39/49] scripts/kvm/kvm_stat: Add interactive filtering, Paolo Bonzini, 2016/01/26
- [Qemu-devel] [PULL 43/49] nbd: add missed aio_context_acquire in nbd_export_new, Paolo Bonzini, 2016/01/26
- [Qemu-devel] [PULL 42/49] memory: exit when hugepage allocation fails if mem-prealloc, Paolo Bonzini, 2016/01/26
- [Qemu-devel] [PULL 45/49] scripts/dump-guest-memory.py: Make methods functions, Paolo Bonzini, 2016/01/26
- [Qemu-devel] [PULL 46/49] scripts/dump-guest-memory.py: Improve python 3 compatibility,
Paolo Bonzini <=
- [Qemu-devel] [PULL 47/49] scripts/dump-guest-memory.py: Cleanup functions, Paolo Bonzini, 2016/01/26
- [Qemu-devel] [PULL 44/49] scripts/dump-guest-memory.py: Move constants to the top, Paolo Bonzini, 2016/01/26
- [Qemu-devel] [PULL 48/49] scripts/dump-guest-memory.py: Introduce multi-arch support, Paolo Bonzini, 2016/01/26
- [Qemu-devel] [PULL 49/49] scripts/dump-guest-memory.py: Fix module docstring, Paolo Bonzini, 2016/01/26
- Re: [Qemu-devel] [PULL 00/49] chardev, NBD, cpus, scripts/ changes for 2015-01-26, Peter Maydell, 2016/01/26