Skip to contentSkip to conversation

dump-guest-memory.py: skip vmcoreinfo section if not available

PATCH In review Marc-André Lureau 2 participants 2 messages Jan 31, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dump-guest-memory.py: skip vmcoreinfo section if not available

On some architectures, qemu doesn't support vmcoreinfo device, and dump-guest-memory fails:

(gdb) dump-guest-memory /tmp/vmcore ppc64-le
guest RAM blocks:
target_start target_end host_addr message count
---------------- ---------------- ---------------- ------- -----
0000000000000000 0000000200000000 00003ffd86980000 added 1
0000200080000000 0000200080800000 00003ffd86170000 added 2
Python Exception <class 'gdb.error'> No symbol "vmcoreinfo_realize" in current context.:
Error occurred in Python command: No symbol "vmcoreinfo_realize" in current context.

Check that vmcoreinfo_realize symbol exists before evaluating an expression with it.

---
 scripts/dump-guest-memory.py | 2 ++
 1 file changed, 2 insertions(+)
scripts/dump-guest-memory.py +2 -0
index 03fbf69f8a..51acfcd0c0 100644
@@ -546,6 +546,8 @@ shape and this command should mostly work."""
         return None
 
     def add_vmcoreinfo(self):
+        if gdb.lookup_symbol("vmcoreinfo_realize")[0] is None:
+            return
         vmci = 'vmcoreinfo_realize::vmcoreinfo_state'
         if not gdb.parse_and_eval("%s" % vmci) \
            or not gdb.parse_and_eval("(%s)->has_vmcoreinfo" % vmci):
Signature · 1 line
2.16.0.rc1.1.gef27df75a1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 26 lines · Marc-André Lureau

On some architectures, qemu doesn't support vmcoreinfo device, and dump-guest-memory fails:

(gdb) dump-guest-memory /tmp/vmcore ppc64-le
guest RAM blocks:
target_start target_end host_addr message count
---------------- ---------------- ---------------- ------- -----
0000000000000000 0000000200000000 00003ffd86980000 added 1
0000200080000000 0000200080800000 00003ffd86170000 added 2
Python Exception <class 'gdb.error'> No symbol "vmcoreinfo_realize" in current context.:
Error occurred in Python command: No symbol "vmcoreinfo_realize" in current context.

Check that vmcoreinfo_realize symbol exists before evaluating an expression with it.

---
 scripts/dump-guest-memory.py | 2 ++
 1 file changed, 2 insertions(+)
scripts/dump-guest-memory.py +0 -0
index 03fbf69f8a..51acfcd0c0 100644

scripts/dump-guest-memory.py shape and this command should mostly work.""" · line 553

Quoted 8 lines
scripts/dump-guest-memory.py +2 -0
@@ -546,6 +546,8 @@ shape and this command should mostly work."""
         return None
 
     def add_vmcoreinfo(self):
+        if gdb.lookup_symbol("vmcoreinfo_realize")[0] is None:
+            return
         vmci = 'vmcoreinfo_realize::vmcoreinfo_state'
         if not gdb.parse_and_eval("%s" % vmci) \
            or not gdb.parse_and_eval("(%s)->has_vmcoreinfo" % vmci):