|
|
5d360b |
From 58efb548d48964d4ff7bdcebdb97ec10e708e5ed Mon Sep 17 00:00:00 2001
|
|
|
5d360b |
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
|
|
|
5d360b |
Date: Wed, 13 Dec 2017 13:39:06 +0100
|
|
|
5d360b |
Subject: [PATCH 35/41] scripts/dump-guest-memory.py: Improve python 3
|
|
|
5d360b |
compatibility
|
|
|
5d360b |
MIME-Version: 1.0
|
|
|
5d360b |
Content-Type: text/plain; charset=UTF-8
|
|
|
5d360b |
Content-Transfer-Encoding: 8bit
|
|
|
5d360b |
|
|
|
5d360b |
RH-Author: Marc-André Lureau <marcandre.lureau@redhat.com>
|
|
|
5d360b |
Message-id: <20171213133912.26176-36-marcandre.lureau@redhat.com>
|
|
|
5d360b |
Patchwork-id: 78385
|
|
|
5d360b |
O-Subject: [RHEL-7.5 qemu-kvm PATCH v3 35/41] scripts/dump-guest-memory.py: Improve python 3 compatibility
|
|
|
5d360b |
Bugzilla: 1411490
|
|
|
5d360b |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
5d360b |
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
5d360b |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
5d360b |
|
|
|
5d360b |
From: Janosch Frank <frankja@linux.vnet.ibm.com>
|
|
|
5d360b |
|
|
|
5d360b |
This commit does not make the script python 3 compatible, it is a
|
|
|
5d360b |
preparation that fixes the easy and common incompatibilities.
|
|
|
5d360b |
|
|
|
5d360b |
Print is a function in python 3 and therefore needs braces around its
|
|
|
5d360b |
arguments.
|
|
|
5d360b |
|
|
|
5d360b |
Range does not cast a gdb.Value object to int in python 3, we have to
|
|
|
5d360b |
do it ourselves.
|
|
|
5d360b |
|
|
|
5d360b |
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
5d360b |
Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
|
|
|
5d360b |
Message-Id: <1453464520-3882-4-git-send-email-frankja@linux.vnet.ibm.com>
|
|
|
5d360b |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
5d360b |
|
|
|
5d360b |
(cherry picked from commit 7cb1089d5fbd7b2d9497f111ce948edef41df32d)
|
|
|
5d360b |
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
|
|
5d360b |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
5d360b |
---
|
|
|
5d360b |
scripts/dump-guest-memory.py | 26 +++++++++++++++-----------
|
|
|
5d360b |
1 file changed, 15 insertions(+), 11 deletions(-)
|
|
|
5d360b |
|
|
|
5d360b |
diff --git a/scripts/dump-guest-memory.py b/scripts/dump-guest-memory.py
|
|
|
5d360b |
index 7d93d86..d44de99 100644
|
|
|
5d360b |
--- a/scripts/dump-guest-memory.py
|
|
|
5d360b |
+++ b/scripts/dump-guest-memory.py
|
|
|
5d360b |
@@ -98,15 +98,19 @@ def memory_region_get_ram_ptr(mr):
|
|
|
5d360b |
|
|
|
5d360b |
def get_guest_phys_blocks():
|
|
|
5d360b |
guest_phys_blocks = []
|
|
|
5d360b |
- print "guest RAM blocks:"
|
|
|
5d360b |
- print ("target_start target_end host_addr message "
|
|
|
5d360b |
- "count")
|
|
|
5d360b |
- print ("---------------- ---------------- ---------------- ------- "
|
|
|
5d360b |
- "-----")
|
|
|
5d360b |
+ print("guest RAM blocks:")
|
|
|
5d360b |
+ print("target_start target_end host_addr message "
|
|
|
5d360b |
+ "count")
|
|
|
5d360b |
+ print("---------------- ---------------- ---------------- ------- "
|
|
|
5d360b |
+ "-----")
|
|
|
5d360b |
|
|
|
5d360b |
current_map_p = gdb.parse_and_eval("address_space_memory.current_map")
|
|
|
5d360b |
current_map = current_map_p.dereference()
|
|
|
5d360b |
- for cur in range(current_map["nr"]):
|
|
|
5d360b |
+
|
|
|
5d360b |
+ # Conversion to int is needed for python 3
|
|
|
5d360b |
+ # compatibility. Otherwise range doesn't cast the value itself and
|
|
|
5d360b |
+ # breaks.
|
|
|
5d360b |
+ for cur in range(int(current_map["nr"])):
|
|
|
5d360b |
flat_range = (current_map["ranges"] + cur).dereference()
|
|
|
5d360b |
mr = flat_range["mr"].dereference()
|
|
|
5d360b |
|
|
|
5d360b |
@@ -149,9 +153,9 @@ def get_guest_phys_blocks():
|
|
|
5d360b |
predecessor["target_end"] = target_end
|
|
|
5d360b |
message = "joined"
|
|
|
5d360b |
|
|
|
5d360b |
- print ("%016x %016x %016x %-7s %5u" %
|
|
|
5d360b |
- (target_start, target_end, host_addr.cast(UINTPTR_T),
|
|
|
5d360b |
- message, len(guest_phys_blocks)))
|
|
|
5d360b |
+ print("%016x %016x %016x %-7s %5u" %
|
|
|
5d360b |
+ (target_start, target_end, host_addr.cast(UINTPTR_T),
|
|
|
5d360b |
+ message, len(guest_phys_blocks)))
|
|
|
5d360b |
|
|
|
5d360b |
return guest_phys_blocks
|
|
|
5d360b |
|
|
|
5d360b |
@@ -311,8 +315,8 @@ shape and this command should mostly work."""
|
|
|
5d360b |
for block in self.guest_phys_blocks:
|
|
|
5d360b |
cur = block["host_addr"]
|
|
|
5d360b |
left = block["target_end"] - block["target_start"]
|
|
|
5d360b |
- print ("dumping range at %016x for length %016x" %
|
|
|
5d360b |
- (cur.cast(UINTPTR_T), left))
|
|
|
5d360b |
+ print("dumping range at %016x for length %016x" %
|
|
|
5d360b |
+ (cur.cast(UINTPTR_T), left))
|
|
|
5d360b |
while (left > 0):
|
|
|
5d360b |
chunk_size = min(TARGET_PAGE_SIZE, left)
|
|
|
5d360b |
chunk = qemu_core.read_memory(cur, chunk_size)
|
|
|
5d360b |
--
|
|
|
5d360b |
1.8.3.1
|
|
|
5d360b |
|