All of lore.kernel.org
 help / color / mirror / Atom feed
From: Janosch Frank <frankja@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: frankja@linux.vnet.ibm.com, lersek@redhat.com, pbonzini@redhat.com
Subject: [Qemu-devel] [RFC 3/5] scripts/dump-guest-memory.py: Improve python 3 compatibility
Date: Thu, 14 Jan 2016 09:48:25 +0100	[thread overview]
Message-ID: <1452761307-57200-4-git-send-email-frankja@linux.vnet.ibm.com> (raw)
In-Reply-To: <1452761307-57200-1-git-send-email-frankja@linux.vnet.ibm.com>

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.

Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
---
 scripts/dump-guest-memory.py | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/scripts/dump-guest-memory.py b/scripts/dump-guest-memory.py
index 76a6ecb..fe93135 100644
--- a/scripts/dump-guest-memory.py
+++ b/scripts/dump-guest-memory.py
@@ -98,15 +98,15 @@ 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"]):
+    for cur in range(int(current_map["nr"])):
         flat_range   = (current_map["ranges"] + cur).dereference()
         mr           = flat_range["mr"].dereference()
 
@@ -149,9 +149,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 +311,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)
-- 
2.3.0

  parent reply	other threads:[~2016-01-14  8:51 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-14  8:48 [Qemu-devel] [RFC 0/5] scripts/dump-guest-memory.py: Add multi-arch support Janosch Frank
2016-01-14  8:48 ` [Qemu-devel] [RFC 1/5] scripts/dump-guest-memory.py: Move constants to the top Janosch Frank
2016-01-14  8:48 ` [Qemu-devel] [RFC 2/5] scripts/dump-guest-memory.py: Make methods functions Janosch Frank
2016-01-14  8:48 ` Janosch Frank [this message]
2016-01-14 16:03   ` [Qemu-devel] [RFC 3/5] scripts/dump-guest-memory.py: Improve python 3 compatibility Laszlo Ersek
2016-01-15 10:05     ` Janosch Frank
2016-01-20 11:18   ` Paolo Bonzini
2016-01-20 13:02     ` Janosch Frank
2016-01-14  8:48 ` [Qemu-devel] [RFC 4/5] scripts/dump-guest-memory.py: Cleanup functions Janosch Frank
2016-01-14 16:11   ` Laszlo Ersek
2016-01-14  8:48 ` [Qemu-devel] [RFC 5/5] scripts/dump-guest-memory.py: Introduce multi-arch support Janosch Frank
2016-01-14 16:24 ` [Qemu-devel] [RFC 0/5] scripts/dump-guest-memory.py: Add " Laszlo Ersek
2016-01-18 16:31   ` Andrew Jones
2016-01-18 17:57     ` Laszlo Ersek
2016-01-20 10:03       ` Janosch Frank
2016-01-20 11:34         ` Paolo Bonzini
2016-01-20 13:50           ` Markus Armbruster
2016-01-20 16:13             ` Laszlo Ersek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1452761307-57200-4-git-send-email-frankja@linux.vnet.ibm.com \
    --to=frankja@linux.vnet.ibm.com \
    --cc=lersek@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.