Пример #1
0
void heap_print_marks(struct object_heap* oh, byte_t* memory, word_t memorySize) {
  struct Object* obj = (struct Object*) memory;
  word_t count = 80;
  word_t pin_count = 0, used_count = 0, free_count = 0;
  fprintf(stderr, "\nmemory:\n");
  while (object_in_memory(oh, obj, memory, memorySize)) {
    if (object_is_pinned(oh, obj)) {
      fprintf(stderr, "X");
      pin_count++;
    } else if (object_is_free(obj)) {
      fprintf(stderr, " ");
      free_count++;
    } else {
      fprintf(stderr, "*");
      used_count++;
    }
    count--;
    if (count == 0) {
      count = 80;
      fprintf(stderr, "\n");
    }
    obj = object_after(oh, obj);
  }
  fprintf(stderr, "\n");
  fprintf(stderr, "free: %" PRIdPTR ", used: %" PRIdPTR ", pinned: %" PRIdPTR "\n", free_count, used_count, pin_count);
}
Пример #2
0
void
describe_ptr (char *ptr)
{
    MonoVTable *vtable;
    mword desc;
    int type;
    char *start;

    if (sgen_ptr_in_nursery (ptr)) {
        printf ("Pointer inside nursery.\n");
    } else {
        if (sgen_ptr_is_in_los (ptr, &start)) {
            if (ptr == start)
                printf ("Pointer is the start of object %p in LOS space.\n", start);
            else
                printf ("Pointer is at offset 0x%x of object %p in LOS space.\n", (int)(ptr - start), start);
            ptr = start;
        } else if (major_collector.ptr_is_in_non_pinned_space (ptr)) {
            printf ("Pointer inside oldspace.\n");
        } else if (major_collector.obj_is_from_pinned_alloc (ptr)) {
            printf ("Pointer is inside a pinned chunk.\n");
        } else {
            printf ("Pointer unknown.\n");
            return;
        }
    }

    if (object_is_pinned (ptr))
        printf ("Object is pinned.\n");

    if (object_is_forwarded (ptr))
        printf ("Object is forwared.\n");

    // FIXME: Handle pointers to the inside of objects
    vtable = (MonoVTable*)LOAD_VTABLE (ptr);

    printf ("VTable: %p\n", vtable);
    if (vtable == NULL) {
        printf ("VTable is invalid (empty).\n");
        return;
    }
    if (sgen_ptr_in_nursery (vtable)) {
        printf ("VTable is invalid (points inside nursery).\n");
        return;
    }
    printf ("Class: %s\n", vtable->klass->name);

    desc = ((GCVTable*)vtable)->desc;
    printf ("Descriptor: %lx\n", (long)desc);

    type = desc & 0x7;
    printf ("Descriptor type: %d (%s)\n", type, descriptor_types [type]);
}
Пример #3
0
void heap_print_objects(struct object_heap* oh, byte_t* memory, word_t memorySize) {
  struct Object* obj = (struct Object*) memory;
  word_t pin_count = 0, used_count = 0, free_count = 0;
  fprintf(stderr, "\nmemory:\n");
  while (object_in_memory(oh, obj, memory, memorySize)) {
    if (object_is_pinned(oh, obj)) {
      fprintf(stderr, "[pinned ");
      pin_count++;
    } else if (object_is_free(obj)) {
      fprintf(stderr, "[free ");
      free_count++;
    } else {
      fprintf(stderr, "[used ");
      used_count++;
    }
    fprintf(stderr, "%" PRIdPTR "]\n", object_total_size(obj));
    obj = object_after(oh, obj);
  }
  fprintf(stderr, "\n");
  fprintf(stderr, "free: %" PRIdPTR ", used: %" PRIdPTR ", pinned: %" PRIdPTR "\n", free_count, used_count, pin_count);
}