changeset 910:03ae5db3dbe9

add memory dump
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Wed, 27 Jan 2021 23:40:36 +0900
parents 90c0ea7811ea
children 6a619da280ff
files src/parallel_execution/ModelChecking/MCWorker.cbc src/parallel_execution/ModelChecking/memory.c src/parallel_execution/ModelChecking/memory.h
diffstat 3 files changed, 30 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/parallel_execution/ModelChecking/MCWorker.cbc	Wed Jan 27 23:18:27 2021 +0900
+++ b/src/parallel_execution/ModelChecking/MCWorker.cbc	Wed Jan 27 23:40:36 2021 +0900
@@ -84,9 +84,11 @@
     StateNode st;
     st.memory = mcti->mem;
     st.hash = get_memory_hash(mcti->mem,0);
+    dump_memory(mcti->mem);printf("\n");
     if (lookup_StateDB(&st, &mcti->state_db, &out)) {
     // found in the state database
-    //printf("found %d\n",count);
+      // printf("found %d\n",count);
+      printf("found\n");
       while(!(list = (struct Context*)takeNextIterator(mcworker->task_iter))) {
           // no more branch, go back to the previous one
           TaskIterator* prev_iter = mcworker->task_iter->prev;
@@ -104,14 +106,14 @@
       //    here we assume task list is fixed, we don't have to
       //    recover task list itself
       restore_memory(mcworker->task_iter->state->memory);
-      //printf("restore list %x next %x\n",(int)list,(int)(list->next));
+      // printf("restore list %x next %x\n",(int)list,(int)(list->next));
     } else {
       // one step further
       mcworker->depth++;
       struct SingleLinkedQueue* mcSingleQueue = (struct SingleLinkedQueue*)mcworker->mcQueue->queue;
       mcworker->task_iter = createQueueIterator(mcSingleQueue->top->next,out,mcworker->task_iter);
     }
-    //printf("depth %d count %d\n", depth, count++);
+    // printf("depth %d count %d\n", depth, count++);
     mcworker->count++;
     //goto list->phils->next(list->phils,list);
     goto meta(context, next);
--- a/src/parallel_execution/ModelChecking/memory.c	Wed Jan 27 23:18:27 2021 +0900
+++ b/src/parallel_execution/ModelChecking/memory.c	Wed Jan 27 23:40:36 2021 +0900
@@ -339,6 +339,28 @@
 }
 
 /*
+    dump memory 
+ */
+
+void
+dump_memory(MemoryPtr m)
+{
+    while (m) {
+      // memcpy(m->adr,m->body,m->length);
+      printf("\n%p : ",m->adr);
+      unsigned char *p = (unsigned char *)m->adr;
+      for(int i=0; i<m->length ;i++) {
+          printf("%02x : ",p[i]);
+          if ((i+1)%4==0) putchar(' ');
+      }
+      if (m->left)  dump_memory(m->left);
+      m = m->right;
+    }
+     printf("\nend\n");
+}
+
+
+/*
  */
 
 void
--- a/src/parallel_execution/ModelChecking/memory.h	Wed Jan 27 23:18:27 2021 +0900
+++ b/src/parallel_execution/ModelChecking/memory.h	Wed Jan 27 23:40:36 2021 +0900
@@ -52,6 +52,9 @@
 extern void
 memory_usage();
 
+extern void
+dump_memory(MemoryPtr m);
+
 
 #endif
 /* end */