static c_bool walkProperty( c_metaObject object, c_metaWalkActionArg actionArg) { toolActionData actionData = (toolActionData)actionArg; c_object o; c_voidp addr; o = c_iterObject(actionData->stack, 0); if (c_baseObjectKind(object) == M_ATTRIBUTE) { addr = C_DISPLACE(o, (c_address)c_property(object)->offset); if (c_typeIsRef(c_property(object)->type)) { addr = *(c_voidp *)addr; if (c_baseObjectKind(c_property(object)->type) == M_COLLECTION) { if (addr) { if (c_iterContains(actionData->stack, addr)) { printf("Ignore cyclic reference 0x"PA_ADDRFMT"\n", (os_address)addr); } else { OBJECT_PUSH(actionData, addr); iprintf("%s ",_METANAME(object)); printType(c_property(object)->type, actionData); OBJECT_POP(actionData); } } else { iprintf(" %s <0x"PA_ADDRFMT">", _METANAME(object), (os_address)addr); } } else { iprintf(" %s <0x"PA_ADDRFMT">", _METANAME(object), (os_address)addr); if (addr) { /* Section for code to print additional type specific info. */ if (c_property(object)->type == v_topic_t) { printf(" /* topic name is: %s */", v_topicName(addr)); } if (c_property(object)->type == v_partition_t) { printf(" /* Partition: %s */", v_partitionName(addr)); } if (c_property(object)->type == c_type_t(c_getBase(object))) { printf(" /* Type: %s */", _METANAME(c_type(addr))); } } } printf("\n"); } else { OBJECT_PUSH(actionData, addr); iprintf("%s ",_METANAME(object)); printType(c_property(object)->type, actionData); printf("\n"); OBJECT_POP(actionData); } } return TRUE; }
static void toolAction ( d_storeMMFKernel kernel, c_voidp addr) { c_base base; c_type type; c_char *name; c_object o; c_address offset; c_long size; struct toolActionData actionData; actionData.fin = stdin; actionData.fout = stdout; actionData.depth = 0; actionData.stack = NULL; base = c_getBase(kernel); o = c_baseCheckPtr(base, addr); if (o) { type = c_getType(o); size = c_typeSize(type); if (o != addr) { offset = C_ADDRESS(addr) - C_ADDRESS(o); if (offset < (c_address)size) { printf("Warning: address is %lu bytes in %s " "object starting at 0x"PA_ADDRFMT"\n", offset, _METANAME(type), (os_address)o); OBJECT_PUSH(&actionData, o); tryPrintOffset(o,&actionData,offset); OBJECT_POP(&actionData); } else { printf("Warning: address is %lu bytes in " "memory starting at 0x"PA_ADDRFMT"\n", offset, (os_address)o); } } else { name = c_metaScopedName(c_metaObject(type)); printf("Object <0x"PA_ADDRFMT"> refCount=%d size=%d type is: <0x"PA_ADDRFMT"> %s\n", (os_address)o, c_refCount(o), size, (os_address)type, name); os_free(name); OBJECT_PUSH(&actionData, o); printType(type, &actionData); printf("\n"); OBJECT_POP(&actionData); } } else { printf("Address <0x"PA_ADDRFMT"> is not a Database Object\n", (os_address)addr); } }
static void printStructure( c_structure _this, toolActionData actionData) { c_object o; c_object object; c_long i, size; c_member member; o = c_iterObject(actionData->stack, 0); if (o) { if (c_iterLength(actionData->stack) == 1) { printf("%s ", _METANAME(_this)); } else { } printf("{\n"); size = c_structureMemberCount(_this); for (i=0; i<size; i++) { member = c_structureMember(_this, i); object = C_DISPLACE(o, (c_address)member->offset); if (c_typeIsRef(c_memberType(member))) { iprintf(" %s <0x"PA_ADDRFMT">\n", c_specifierName(member), *(os_address *)object); } else { OBJECT_PUSH(actionData, object); iprintf("%s ",c_specifierName(member)); printType(c_memberType(member), actionData); printf("\n"); OBJECT_POP(actionData); } } if (c_iterLength(actionData->stack) == 1) { iprintf("};"); } else { iprintf("} %s;", _METANAME(_this)); } if (c_type(_this) == v_handle_t) { v_object vo; v_handleClaim(*(v_handle *)o,&vo); v_handleRelease(*(v_handle *)o); printf(" /* Handle's object: <0x"PA_ADDRFMT"> */", (os_address)vo); } } }
static void printCollectionAction( c_metaObject mo, c_scopeWalkActionArg arg) { c_type type; c_object o = c_metaObject (mo); toolActionData actionData = (toolActionData)arg; c_char *name; if (o != NULL) { type = c_getType(o); name = c_metaScopedName(c_metaObject(type)); iprintf("Object <0x"PA_ADDRFMT"> refCount=%d type is: <0x"PA_ADDRFMT"> %s\n", (os_address)o, c_refCount(o), (os_address)type, name); os_free(name); OBJECT_PUSH(actionData, o); printType(type, actionData); printf("\n"); OBJECT_POP(actionData); } }
static c_bool printCollectionAction( c_object o, c_voidp arg) { c_type type; toolActionData actionData = (toolActionData)arg; c_char *name; if (o != NULL) { type = c_getType(o); name = c_metaScopedName(c_metaObject(type)); iprintf("Object <0x%x> type is: <0x%x> %s\n", (HEXVALUE)o, (HEXVALUE)type, name); os_free(name); OBJECT_PUSH(actionData, o); printType(type, actionData); printf("\n"); OBJECT_POP(actionData); } return TRUE; }
static void printCollection( c_collectionType type, toolActionData actionData) { c_long size, i, offset, esize; c_object o; c_voidp p; c_object arrayElement; c_type subtype; c_bool isRef; o = c_iterObject(actionData->stack, 0); switch (type->kind) { case C_ARRAY: case C_SEQUENCE: /* Walk over all entries */ switch (type->kind) { case C_ARRAY: if (type->maxSize == 0) { size = c_arraySize((c_array)o); } else { size = type->maxSize; } break; case C_SEQUENCE: size = c_arraySize((c_array)o); break; default: size = 0; assert(FALSE); break; } if (c_typeIsRef(type->subType)) { esize = sizeof(c_voidp); isRef = TRUE; } else { esize = type->subType->size; isRef = FALSE; } p = o; offset = 0; for (i=0; i<size; i++) { iprintf("Element (%d) Offset (%d)\n",i,offset); arrayElement = isRef ? *((c_object *)p) : (c_object) p; if (arrayElement != NULL) { OBJECT_PUSH(actionData, arrayElement); if (isRef) { subtype = c_getType(arrayElement); printType(subtype, actionData); } else { iprintf(" "); printType(type->subType, actionData); } printf("\n"); OBJECT_POP(actionData); } else { iprintf(" <0x0>\n"); } p = C_DISPLACE(p, esize); offset += esize; } break; case C_STRING: printf(" \"%s\"",(c_char *)o); break; case C_SET: case C_LIST: case C_BAG: case C_DICTIONARY: case C_QUERY: { if (o != NULL) { /* Walk over the elements */ c_walk(o, (c_action)printCollectionAction, actionData); if (c_count(o) == 0) { iprintf("<EMPTY>"); } } else { iprintf("<NULL>"); } } break; case C_SCOPE: c_scopeWalk(o, printCollectionAction, actionData); break; default: printf("Specified type <0x"PA_ADDRFMT"> is not a valid collection type\n", (os_address)type); break; } }