Skip to contentSkip to conversation

dom0cut script patch for x86-64.

PATCH Hiromichi Itou 3 participants 3 messages Jan 5, 2007 – Jan 10, 2007

lore
Share & tools
lore
#0 lore raw

Hi,

In my environment (x86-64), the following problem occurred by executing dom0cut script.

# dom0cut_x86.py -oDump2006122801 -dvmcore.2006122801 --target=0 -x/root/xen-3.0.4-testing.hg/xen/xen-syms -ax86_64 -f

Traceback (most recent call last):
File "/usr/bin/dom0cut_x86.py", line 174, in ?

    main()

File "/usr/bin/dom0cut_x86.py", line 165, in main
domextract(outdump, dump, options.xensyms, domid)
File "/usr/bin/dom0cut_x86.py", line 43, in domextract
dom_context = xenimg.get_domain_context(domp)
File "/usr/lib/python2.3/site-packages/xendump/XenImage.py", line
184, in get_domain_context
guest_reg.fromXen(regtxt)
File "/usr/lib/python2.3/site-packages/xendump/Register.py", line
41, in fromXen
return self.fromString(self.xenfmt, self.xenregs, regstring)
File "/usr/lib/python2.3/site-packages/xendump/Register.py", line
28, in fromString
regs = struct.unpack(fmt, regstring)
struct.error: unpack str size does not match format

I checked the size of fmt and regstring. (fmt is 'QQQQQQQQQQQQQQQLLQHHBBBBQQQQQQQ' in this case.) struct.calcsize(fmt) was 208. len(regstring) was 200.

The cause of this difference is in the behavior of the struct module in 64bit environment. struct.calcsize('L') is expected to become 4. But,struct.calcsize('L') was 8 in my environment. This difference can be corrected by adding the first character of the format string.

An attached patch fix this problem.

Hiromichi Ito

xendump/ElfCore.py +1 -1
diff -Naur dom0cut-0.1.0.orig/xendump/ElfCore.py dom0cut-0.1.0/xendump/ElfCore.py
@@ -27,7 +27,7 @@
     n_namesz = len(name) + 1
     n_descsz = len(desc)
 
-    outstr.write(struct.pack("LLL", n_namesz, n_descsz, n_type))
+    outstr.write(struct.pack("=LLL", n_namesz, n_descsz, n_type))
     outstr.write(name + '\0')
     outstr.seek(roundup(outstr.pos, 4))
     outstr.write(desc)
xendump/PageTable.py +1 -1
diff -Naur dom0cut-0.1.0.orig/xendump/PageTable.py dom0cut-0.1.0/xendump/PageTable.py
@@ -90,7 +90,7 @@
     def __read_pt(self, mfn, level):
         '''return pagetable'''
 
-        pt = struct.unpack( "L" * 1024,  self.dump.read_page(mfn) )
+        pt = struct.unpack( "=L" * 1024,  self.dump.read_page(mfn) )
 
         if level == 1:
             shift = 22
xendump/Register.py +1 -1
diff -Naur dom0cut-0.1.0.orig/xendump/Register.py dom0cut-0.1.0/xendump/Register.py
@@ -114,7 +114,7 @@
             'ds', 'es', 'fs', 'gs') 
 
         # from: $(XEN)/xen/include/public/arch-x86_64.h
-        self.xenfmt = 'QQQQQQQQQQQQQQQLLQHHBBBBQQQQQQQ'
+        self.xenfmt = '=QQQQQQQQQQQQQQQLLQHHBBBBQQQQQQQ'
         self.xenregs = (
             'r15', 'r14', 'r13', 'r12',
             'rbp', 'rbx', 'r11', 'r10',
xendump/XenCore.py +1 -1
diff -Naur dom0cut-0.1.0.orig/xendump/XenCore.py dom0cut-0.1.0/xendump/XenCore.py
@@ -8,7 +8,7 @@
 import struct
 
 CORE_MAGIC = 0xF00FEBEDL
-HEADER_FORMAT = "LLLLLL"
+HEADER_FORMAT = "=LLLLLL"
 
         
 class XenCore(CoreDump.CoreDump):
xendump/XenImage.py +3 -3
diff -Naur dom0cut-0.1.0.orig/xendump/XenImage.py dom0cut-0.1.0/xendump/XenImage.py
@@ -49,7 +49,7 @@
     def get_xen_online_cpus(self):
         '''return list of on-line cpu id'''
         online_cpus = []
-        cpu_online_map_t = 'L'          # XXX x86_32 specific
+        cpu_online_map_t = '=L'          # XXX x86_32 specific
 
         cpu_online_map = self.dump.read_struct(self.pt.v2m(self.st['cpu_online_map']), cpu_online_map_t)[0]
         for i in range(self.arch.max_cpu):
@@ -111,7 +111,7 @@
     def get_domain_id(self, domainp):
         """get domain ID from domain pointer"""
         domain_domain_id_offset = self.dwarf.calc_struct_member_offset('domain', 'domain_id')
-        domain_id = self.dump.read_struct(self.pt.v2m(domainp + domain_domain_id_offset), 'L')[0]
+        domain_id = self.dump.read_struct(self.pt.v2m(domainp + domain_domain_id_offset), '=L')[0]
 
         return domain_id
 
@@ -162,7 +162,7 @@
         ctxts = []
         for vcpu in vcpus:
             processor = self.dump.read_struct(self.pt.v2m(vcpu + processor_offset), self.arch.ptr_format)[0]
-            state = self.dump.read_struct(self.pt.v2m(vcpu + state_offset), 'L')[0]
+            state = self.dump.read_struct(self.pt.v2m(vcpu + state_offset), '=L')[0]
             context = XenContext.XenContext(self.arch.name, self.dwarf, context=self.pt.load_data(vcpu + ctxt_offset, ctxt_size))
             if state == RUNSTATE_running:              
                 reg = self.get_xen_crash_note_regs(processor)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw

Hello,

I'm sorry for delayed reply. I just backed from off.

Thank you for your fix. I applied this patch and add '=' to other format strings which contain 'L' exclude one case(which need to treat 'int' variable both in 32 and 64 bit environment)

You can get updated tarball from:

http://people.valinux.co.jp/~moriwaka/dumpread/dom0cut-0.1.2.tar.gz

Thanks,

Signature · 5 lines
Kazuo Moriwaka <[email protected]>

From: Hiromichi Itou <[email protected]>
Subject: dom0cut script patch for x86-64.
Date: Fri, 5 Jan 2007 18:53:15 +0900
Quoted 41 lines

Hi,

In my environment (x86-64), the following problem occurred by executing dom0cut script.

# dom0cut_x86.py -oDump2006122801 -dvmcore.2006122801 --target=0 -x/ 
root/xen-3.0.4-testing.hg/xen/xen-syms -ax86_64 -f

Traceback (most recent call last):

   File "/usr/bin/dom0cut_x86.py", line 174, in ?
     main()
   File "/usr/bin/dom0cut_x86.py", line 165, in main
     domextract(outdump, dump, options.xensyms, domid)
   File "/usr/bin/dom0cut_x86.py", line 43, in domextract
     dom_context = xenimg.get_domain_context(domp)
   File "/usr/lib/python2.3/site-packages/xendump/XenImage.py", line  

184, in get_domain_context
guest_reg.fromXen(regtxt)
File "/usr/lib/python2.3/site-packages/xendump/Register.py", line
41, in fromXen
return self.fromString(self.xenfmt, self.xenregs, regstring)
File "/usr/lib/python2.3/site-packages/xendump/Register.py", line
28, in fromString
regs = struct.unpack(fmt, regstring)
struct.error: unpack str size does not match format

I checked the size of fmt and regstring. (fmt is 'QQQQQQQQQQQQQQQLLQHHBBBBQQQQQQQ' in this case.) struct.calcsize(fmt) was 208. len(regstring) was 200.

The cause of this difference is in the behavior of the struct module in 64bit environment.
struct.calcsize('L') is expected to become 4. But,struct.calcsize ('L') was 8 in my environment.
This difference can be corrected by adding the first character of the format string.

An attached patch fix this problem.

Hiromichi Ito

#2 lore raw
In reply to Hiromichi Itou

Hello,

I'm sorry for delayed reply. I just backed from off.

Thank you for your fix. I applied this patch and add '=' to other format strings which contain 'L' exclude one case(which need to treat 'int' variable both in 32 and 64 bit environment)

You can get updated tarball from:

http://people.valinux.co.jp/~moriwaka/dumpread/dom0cut-0.1.2.tar.gz

Thanks,

Signature · 1 line
Kazuo Moriwaka
Quoted 51 lines · Hiromichi Itou

Hi,

In my environment (x86-64), the following problem occurred by executing dom0cut script.

# dom0cut_x86.py -oDump2006122801 -dvmcore.2006122801 --target=0 -x/
root/xen-3.0.4-testing.hg/xen/xen-syms -ax86_64 -f

Traceback (most recent call last):

   File "/usr/bin/dom0cut_x86.py", line 174, in ?
     main()
   File "/usr/bin/dom0cut_x86.py", line 165, in main
     domextract(outdump, dump, options.xensyms, domid)
   File "/usr/bin/dom0cut_x86.py", line 43, in domextract
     dom_context = xenimg.get_domain_context(domp)
   File "/usr/lib/python2.3/site-packages/xendump/XenImage.py", line

184, in get_domain_context
guest_reg.fromXen(regtxt)
File "/usr/lib/python2.3/site-packages/xendump/Register.py", line
41, in fromXen
return self.fromString(self.xenfmt, self.xenregs, regstring)
File "/usr/lib/python2.3/site-packages/xendump/Register.py", line
28, in fromString
regs = struct.unpack(fmt, regstring)
struct.error: unpack str size does not match format

I checked the size of fmt and regstring. (fmt is 'QQQQQQQQQQQQQQQLLQHHBBBBQQQQQQQ' in this case.) struct.calcsize(fmt) was 208. len(regstring) was 200.

The cause of this difference is in the behavior of the struct module in 64bit environment.
struct.calcsize('L') is expected to become 4. But,struct.calcsize ('L') was 8 in my environment.
This difference can be corrected by adding the first character of the format string.

An attached patch fix this problem.

Hiromichi Ito

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel