rzel / python-on-a-chip

Automatically exported from code.google.com/p/python-on-a-chip
Other
0 stars 0 forks source link

fix pmHeapDump #182

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
oscar reported problems using src/tools/pmHeapDump.py
and tonio delivered this patch::

 static void
 heap_dump(void)
@@ -196,10 +196,8 @@
     static int n = 0;
     uint16_t s;
     uint32_t i;
-    void *b;
     char filename[32];
     FILE *fp;
-    uint8_t *pheap;

     snprintf(filename, 32, "pmheapdump%02d.bin", n++);
     fp = fopen(filename, "wb");
@@ -238,12 +236,10 @@
     fwrite(&pmHeap.size, sizeof(uint32_t), 1, fp);

     /* Write base address of heap */
-    b=&pmHeap.base;
-    fwrite((void*)(&b), sizeof(intptr_t), 1, fp);
+    fwrite((void*)&pmHeap.base, sizeof(intptr_t), 1, fp);

     /* Write contents of heap */
-    pheap = pmHeap.base;
-    fwrite(&pheap, 1, pmHeap.size, fp);
+    fwrite(pmHeap.base, 1, pmHeap.size, fp);

Original issue reported on code.google.com by dwhall...@gmail.com on 18 Jan 2011 at 2:57

GoogleCodeExporter commented 9 years ago
Further fix from tonio:

diff -r 76c20922f040 src/tools/pmHeapDump.py
--- a/src/tools/pmHeapDump.py    Sun Jan 09 08:53:58 2011 -0600
+++ b/src/tools/pmHeapDump.py    Tue Jan 18 09:55:50 2011 +0100
@@ -280,8 +280,8 @@
             self.addr = self.fp.tell()

             od = unpack_fp(heap.endianchr + "H", fp, False)[0]
-            self.mark = (' ','M')[(od & 0x4000) == 0x4000]
-            self.free = (' ','F')[(od & 0x8000) == 0x8000]
+            self.mark = (' ','M')[(od & 0x1) == 0x1]
+            self.free = (' ','F')[(od & 0x2) == 0x2]

Original comment by dwhall...@gmail.com on 18 Jan 2011 at 12:31

GoogleCodeExporter commented 9 years ago
This issue was updated by revision 4a737231a3.

Patches from tonio that fix the pmHeapDump.py tool:
- Writes the base properly in src/vm/heap.c
- Mask the Mark and Free bits properly in pmHeapDump.py

Original comment by dwhall...@gmail.com on 18 Jan 2011 at 12:52

GoogleCodeExporter commented 9 years ago
r4a737231a305

Tonio's two fixes work.  I tested by dumping an ipm session that went long 
enough to cause one GC.

Original comment by dwhall...@gmail.com on 18 Jan 2011 at 12:53

GoogleCodeExporter commented 9 years ago

Original comment by dwhall...@gmail.com on 18 Jan 2011 at 12:56