static PsmAddress findFileName(PsmPartition trace, TraceHeader *trh, char *sourceFileName) { PsmAddress elt; PsmAddress filenameAddress; char *filename; int buflen; for (elt = sm_list_first(trace, trh->files); elt; elt = sm_list_next(trace, elt)) { filenameAddress = sm_list_data(trace, elt); filename = (char *) psp(trace, filenameAddress); if (strcmp(filename, sourceFileName) == 0) { return filenameAddress; } } /* This is a source file we haven't heard of before. */ buflen = strlen(sourceFileName) + 1; filenameAddress = psm_zalloc(trace, buflen); if (filenameAddress == 0) { discardEvent(trace); return 0; } /* Add this source file to the list for the trace. */ istrcpy((char *) psp(trace, filenameAddress), sourceFileName, buflen); if (sm_list_insert_last(trace, trh->files, filenameAddress) == 0) { discardEvent(trace); return 0; } return filenameAddress; }
static void logEvent(PsmPartition trace, int opType, unsigned long addr, int objectSize, char *msg, char *fileName, int lineNbr, PsmAddress *eltp) { PsmAddress traceHeaderAddress; TraceHeader *trh; PsmAddress itemAddr; TraceItem *item; int buflen; PsmAddress elt; if (eltp) { *eltp = 0; } traceHeaderAddress = psm_get_root(trace); trh = (TraceHeader *) psp(trace, traceHeaderAddress); if (trh == NULL) return; itemAddr = psm_zalloc(trace, sizeof(TraceItem)); if (itemAddr == 0) { discardEvent(trace); return; } item = (TraceItem *) psp(trace, itemAddr); memset((char *) item, 0, sizeof(TraceItem)); if (msg) { buflen = strlen(msg) + 1; item->msg = psm_zalloc(trace, buflen); if (item->msg == 0) { discardEvent(trace); return; } istrcpy((char *) psp(trace, item->msg), msg, buflen); } item->taskId = sm_TaskIdSelf(); item->fileName = findFileName(trace, trh, fileName); if (item->fileName == 0) { return; /* Events are being discarded. */ } item->lineNbr = lineNbr; trh->opCount++; item->opNbr = trh->opCount; item->opType = opType; item->objectAddress = addr; item->objectSize = objectSize; elt = sm_list_insert_last(trace, trh->log, itemAddr); if (elt == 0) { discardEvent(trace); return; } if (eltp) { *eltp = elt; } }
int addEmbargo(IonNode *node, uvast neighborNodeNbr) { PsmPartition ionwm = getIonwm(); PsmAddress nextElt; PsmAddress elt; Embargo *embargo; PsmAddress addr; /* Find insertion point in embargoes list. */ CHKERR(node); nextElt = 0; for (elt = sm_list_first(ionwm, node->embargoes); elt; elt = sm_list_next(ionwm, elt)) { embargo = (Embargo *) psp(ionwm, sm_list_data(ionwm, elt)); CHKERR(embargo); if (embargo->nodeNbr < neighborNodeNbr) { continue; } if (embargo->nodeNbr > neighborNodeNbr) { nextElt = elt; break; /* Have found insertion point. */ } return 0; /* Embargo has already been added. */ } addr = psm_zalloc(ionwm, sizeof(Embargo)); if (addr == 0) { putErrmsg("Can't add embargo.", NULL); return -1; } if (nextElt) { elt = sm_list_insert_before(ionwm, nextElt, addr); } else { elt = sm_list_insert_last(ionwm, node->embargoes, addr); } if (elt == 0) { psm_free(ionwm, addr); putErrmsg("Can't add embargo.", NULL); return -1; } embargo = (Embargo *) psp(ionwm, addr); CHKERR(embargo); embargo->nodeNbr = neighborNodeNbr; embargo->probeIsDue = 0; postProbeEvent(node, embargo); /* Initial probe event. */ return 0; }