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); } }
os_uint32 u_topicTypeSize( const u_topic _this) { v_topic kt; u_result r; os_uint32 size = 0; assert(_this); r = u_topicReadClaim(_this, &kt, C_MM_RESERVATION_ZERO); if (r == U_RESULT_OK) { assert(kt); size = (os_uint32)c_typeSize(v_topicDataType(kt)); u_topicRelease(_this, C_MM_RESERVATION_ZERO); } else { OS_REPORT(OS_WARNING, "u_topicTypeSize", r, "Could not claim topic."); } return size; }
void cmx_readerSnapshotNewAction( v_public p, c_voidp args) { v_dataReader reader; c_iter instances; v_dataReaderInstance instance; v_dataReaderSample sample; v_query query; c_bool release; sd_serializer ser; sd_serializedData data; struct cmx_readerSnapshotArg* arg; release = FALSE; arg = (struct cmx_readerSnapshotArg*)args; reader = NULL; instances = NULL; ser = NULL; switch(v_object(p)->kind){ case K_DATAREADER: reader = v_dataReader(p); arg->success = TRUE; arg->snapshot = cmx_readerSnapshot(os_malloc(C_SIZEOF(cmx_readerSnapshot))); v_observerLock(v_observer(reader)); if(reader->index->objects){ instances = ospl_c_select(reader->index->notEmptyList, 0); } break; case K_QUERY: case K_DATAREADERQUERY: query = v_query(p); reader = v_dataReader(v_querySource(query)); if(reader != NULL){ release = TRUE; arg->success = TRUE; arg->snapshot = cmx_readerSnapshot(os_malloc(C_SIZEOF(cmx_readerSnapshot))); v_observerLock(v_observer(reader)); switch(v_object(query)->kind){ case K_DATAREADERQUERY: if(v_dataReaderQuery(query)->instanceQ){ instances = ospl_c_select((c_collection)(v_dataReaderQuery(query)->instanceQ), 0); } break; default: OS_REPORT(OS_ERROR, CM_XML_CONTEXT, 0, "cmx_readerSnapshotNewAction unknown kind (%d).", v_object(query)->kind); break; } } break; default: break; } if(arg->success == TRUE){ arg->snapshot->samples = c_iterNew(NULL); } if(instances != NULL){ v_dataReaderSample sampleShallowCopy = NULL; instance = v_dataReaderInstance(c_iterTakeFirst(instances)); while(instance != NULL){ v_state ivState = instance->_parent._parent.state & (L_DISPOSED | L_NOWRITERS | L_NEW); sample = v_dataReaderInstanceOldest(instance); if (sample != NULL) { do { v_state state = ivState | ((sample->_parent.sampleState & (L_READ | L_LAZYREAD)) ? L_READ : 0); if (sampleShallowCopy == NULL) { sampleShallowCopy = c_new(c_getType(c_object(sample))); } memcpy(sampleShallowCopy, sample, c_typeSize(c_getType(sampleShallowCopy))); sampleShallowCopy->newer = NULL; sampleShallowCopy->_parent.sampleState &= ~(L_DISPOSED | L_NOWRITERS | L_NEW | L_READ | L_LAZYREAD); sampleShallowCopy->_parent.sampleState |= state; if(ser == NULL){ ser = sd_serializerXMLNewTyped(c_getType(c_object(sampleShallowCopy))); } data = sd_serializerSerialize(ser, c_object(sampleShallowCopy)); arg->snapshot->samples = c_iterInsert(arg->snapshot->samples, sd_serializerToString(ser, data)); sd_serializedDataFree(data); sample = sample->newer; } while (sample != NULL); } c_free(instance); instance = v_dataReaderInstance(c_iterTakeFirst(instances)); } c_iterFree(instances); if (sampleShallowCopy != NULL) { memset(sampleShallowCopy, 0, c_typeSize(c_getType(sampleShallowCopy))); c_free(sampleShallowCopy); } } if(reader != NULL){ v_observerUnlock(v_observer(reader)); if(release == TRUE){ c_free(reader); } } if(ser != NULL){ sd_serializerFree(ser); } }
void c_copyOut ( c_type type, c_object o, c_voidp *data) { c_long i,size; c_type t,subType; if (data == NULL) { OS_REPORT(OS_ERROR,"Database misc",0, "c_copyOut: no destination specified"); return; } if (o == NULL) { *data = NULL; return; } t = c_typeActualType(type); size = c_typeSize(t); if (size == 0) { OS_REPORT(OS_WARNING,"Database misc",0, "c_copyOut: zero sized type specified"); *data = NULL; return; } if (*data == NULL) { *data = (c_voidp)os_malloc(size); } if (c_baseObject(t)->kind == M_COLLECTION) { switch(c_collectionType(t)->kind) { case C_STRING: *data = os_strdup((c_char *)o); break; case C_LIST: case C_BAG: case C_SET: case C_MAP: case C_DICTIONARY: OS_REPORT(OS_WARNING,"Database misc",0, "c_copyOut: ODL collections unsupported"); assert(FALSE); break; case C_ARRAY: size = c_collectionType(t)->maxSize; if (size > 0) { subType = c_collectionType(t)->subType; for (i=0;i<size;i++) { c_copyIn(subType, ((c_voidp *)o)[i], &((c_voidp *)(*data))[i]); } } else { OS_REPORT(OS_WARNING,"Database misc",0, "c_copyOut: dynamic sized arrays unsupported"); } case C_SEQUENCE: OS_REPORT(OS_WARNING,"Database misc",0, "c_copyOut: sequences unsupported"); assert(FALSE); break; default: OS_REPORT_1(OS_ERROR,"Database misc",0, "c_copyOut: unknown collection kind (%d)", c_collectionType(t)->kind); assert(FALSE); break; } } else if (c_typeIsRef(t)) { memcpy(*data,*(void**)o,size); extractReferences(t,*(void**)o,*data); } else { memcpy(*data,o,size); extractReferences(t,o,*data); } }