void ErrorReporter::handleAssert(const char* message, const char* file, int line, int ec) { char refMessage[100]; Uint32 jamBlockNumber; #ifdef NO_EMULATED_JAM BaseString::snprintf(refMessage, 100, "file: %s lineNo: %d", file, line); jam = NULL; jamIndex = 0; jamBlockNumber = 0; #else const EmulatedJamBuffer *jamBuffer = (EmulatedJamBuffer *)NdbThread_GetTlsKey(NDB_THREAD_TLS_JAM); jamBlockNumber = jamBuffer->theEmulatedJamBlockNumber; const char *blockName = getBlockName(jamBlockNumber); BaseString::snprintf(refMessage, 100, "%s line: %d (block: %s)", file, line, blockName); #endif NdbShutdownType nst = s_errorHandlerShutdownType; WriteMessage(ec, message, refMessage, nst); NdbShutdown(ec, nst); exit(1); // Deadcode }
std::string UniformBlock::makeShaderLayout() { std::ostringstream stream; if (mUseBuffer) { stream << "layout (std140) uniform " << getBlockName() << " {" << std::endl; } DataDescriptor::forEachEntry([&stream, this](const DataEntry& entry) mutable { int nelems = entry.Count; if (entry.IsSet) { stream << "uniform " << entry.Type << " " << entry.Name; if (nelems > 1) { stream << "[" << nelems << "]"; } stream << ";" << std::endl; } }); if (mUseBuffer) { stream << "};" << std::endl; } return stream.str(); }
static void lstProperty(EjsMod *mp, EjsModule *module, EjsObj *block, int slotNum, EjsName qname, int attributes, EjsName typeName) { Ejs *ejs; EjsType *propType; EjsString *space, *blockName; ejs = mp->ejs; space = mapSpace(ejs, qname.space); mprFprintf(mp->file, "VARIABLE: "); blockName = getBlockName(mp, block, slotNum); mprFprintf(mp->file, "[%@-%02d] %@ %svar %@", blockName, slotNum, space, getAttributeString(mp, attributes), qname.name); if (typeName.name && typeName.name->value[0]) { mprFprintf(mp->file, " : %@", typeName.name); } mprFprintf(mp->file, "\n"); if (block == 0) { /* Nested block. */ if (typeName.name) { propType = (EjsType*) ejsGetPropertyByName(ejs, ejs->global, typeName); } else { propType = 0; } mprAssert(mp->currentBlock && ejsIsBlock(ejs, mp->currentBlock)); slotNum = ejsDefineProperty(ejs, (EjsObj*) mp->currentBlock, -1, qname, propType, attributes, 0); } }
static void lstBlock(EjsMod *mp, EjsModule *module, EjsObj *owner, int slotNum, EjsString *name, int numProp) { EjsString *blockName; blockName = getBlockName(mp, owner, slotNum); mprFprintf(mp->file, "BLOCK: [%@-%02d] %@ (Slots %d)\n", blockName, slotNum, name, numProp); }
bool printLCP_COMPLETE_REP(FILE * output, const Uint32 * theData, Uint32 len, Uint16 receiverBlockNo){ const LcpCompleteRep * const sig = (LcpCompleteRep *) theData; fprintf(output, " LcpId: %d NodeId: %d Block: %s\n", sig->lcpId, sig->nodeId, getBlockName(sig->blockNo)); return true; }
static Uint32 switchRef(Uint32 block, Uint32 node) { const Uint32 ref = numberToRef(block, node); #ifdef DBINFO_SCAN_TRACE ndbout_c("Dbinfo: switching to %s in node %d, ref: 0x%.8x", getBlockName(block, "<unknown>"), node, ref); #endif return ref; }
void ErrorReporter::handleAssert(const char* message, const char* file, int line, int ec) { char refMessage[100]; #ifdef NO_EMULATED_JAM BaseString::snprintf(refMessage, 100, "file: %s lineNo: %d", file, line); #else const Uint32 blockNumber = theEmulatedJamBlockNumber; const char *blockName = getBlockName(blockNumber); BaseString::snprintf(refMessage, 100, "%s line: %d (block: %s)", file, line, blockName); #endif WriteMessage(ec, message, refMessage, theEmulatedJamIndex, theEmulatedJam); childReportError(ec); NdbShutdown(s_errorHandlerShutdownType); exit(1); // Deadcode }
bool printNF_COMPLETE_REP(FILE * output, const Uint32 * theData, Uint32 len, Uint16 recBlockNo) { NFCompleteRep * sig = (NFCompleteRep*)theData; const char * who = getBlockName(sig->blockNo, 0); if(who == 0) { fprintf(output, " Node: %d has completed failure of node %d\n", sig->nodeId, sig->failedNodeId); } else { fprintf(output, " Node: %d block: %s has completed failure of node %d\n", sig->nodeId, who, sig->failedNodeId); } fprintf(output, "Sent from line: %d\n", sig->from); return true; }
GmodelVar GmodelVar::deepCopy() { GmodelVar gVar = GmodelVar(m_mode, m_type, m_name, m_name->getFileName(), getEndLine(), getBlockName(), getBlockPath()); if(m_isPrim) gVar.setAsPrim(); return gVar; }
void dumpJam(FILE *jamStream, Uint32 thrdTheEmulatedJamIndex, Uint8 thrdTheEmulatedJam[]) { #ifndef NO_EMULATED_JAM // print header const int maxaddr = 8; fprintf(jamStream, "JAM CONTENTS up->down left->right ?=not block entry\n"); fprintf(jamStream, "%-7s ", "BLOCK"); for (int i = 0; i < maxaddr; i++) fprintf(jamStream, "%-6s ", "ADDR"); fprintf(jamStream, "\n"); // treat as array of Uint32 const Uint32 *base = (Uint32 *)thrdTheEmulatedJam; const int first = thrdTheEmulatedJamIndex / sizeof(Uint32); // oldest int cnt, idx; // look for first block entry for (cnt = 0, idx = first; cnt < EMULATED_JAM_SIZE; cnt++, idx++) { if (idx >= EMULATED_JAM_SIZE) idx = 0; const Uint32 aJamEntry = base[idx]; if (aJamEntry > (1 << 20)) break; } // 1. if first entry is a block entry, it is printed in the main loop // 2. else if any block entry exists, the jam starts in an unknown block // 3. else if no block entry exists, the block is theEmulatedJamBlockNumber // a "?" indicates first addr is not a block entry if (cnt == 0) ; else if (cnt < EMULATED_JAM_SIZE) fprintf(jamStream, "%-7s?", ""); else { const Uint32 aBlockNumber = theEmulatedJamBlockNumber; const char *aBlockName = getBlockName(aBlockNumber); if (aBlockName != 0) fprintf(jamStream, "%-7s?", aBlockName); else fprintf(jamStream, "0x%-5X?", aBlockNumber); } // loop over all entries int cntaddr = 0; for (cnt = 0, idx = first; cnt < EMULATED_JAM_SIZE; cnt++, idx++) { globalData.incrementWatchDogCounter(4); // watchdog not to kill us ? if (idx >= EMULATED_JAM_SIZE) idx = 0; const Uint32 aJamEntry = base[idx]; if (aJamEntry > (1 << 20)) { const Uint32 aBlockNumber = aJamEntry >> 20; const char *aBlockName = getBlockName(aBlockNumber); if (cnt > 0) fprintf(jamStream, "\n"); if (aBlockName != 0) fprintf(jamStream, "%-7s ", aBlockName); else fprintf(jamStream, "0x%-5X ", aBlockNumber); cntaddr = 0; } if (cntaddr == maxaddr) { fprintf(jamStream, "\n%-7s ", ""); cntaddr = 0; } fprintf(jamStream, "%06u ", aJamEntry & 0xFFFFF); cntaddr++; } fprintf(jamStream, "\n"); fflush(jamStream); #endif // ifndef NO_EMULATED_JAM }
bool printPACKED_SIGNAL(FILE * output, const Uint32 * theData, Uint32 len, Uint16 receiverBlockNo){ fprintf(output, "Signal data: "); Uint32 i = 0; while (i < len) fprintf(output, "H\'%.8x ", theData[i++]); fprintf(output,"\n"); fprintf(output, "--------- Begin Packed Signals --------\n"); // Print each signal separately for (i = 0; i < len;) { switch (PackedSignal::getSignalType(theData[i])) { case ZCOMMIT: { Uint32 signalLength = 5; fprintf(output, "--------------- Signal ----------------\n"); fprintf(output, "r.bn: %u \"%s\", length: %u \"COMMIT\"\n", receiverBlockNo, getBlockName(receiverBlockNo,""), signalLength); fprintf(output, "Signal data: "); for(Uint32 j = 0; j < signalLength; j++) fprintf(output, "H\'%.8x ", theData[i++]); fprintf(output,"\n"); break; } case ZCOMPLETE: { Uint32 signalLength = 3; fprintf(output, "--------------- Signal ----------------\n"); fprintf(output, "r.bn: %u \"%s\", length: %u \"COMPLETE\"\n", receiverBlockNo, getBlockName(receiverBlockNo,""), signalLength); fprintf(output, "Signal data: "); for(Uint32 j = 0; j < signalLength; j++) fprintf(output, "H\'%.8x ", theData[i++]); fprintf(output,"\n"); break; } case ZCOMMITTED: { Uint32 signalLength = 3; fprintf(output, "--------------- Signal ----------------\n"); fprintf(output, "r.bn: %u \"%s\", length: %u \"COMMITTED\"\n", receiverBlockNo, getBlockName(receiverBlockNo,""), signalLength); fprintf(output, "Signal data: "); for(Uint32 j = 0; j < signalLength; j++) fprintf(output, "H\'%.8x ", theData[i++]); fprintf(output,"\n"); break; } case ZCOMPLETED: { Uint32 signalLength = 3; fprintf(output, "--------------- Signal ----------------\n"); fprintf(output, "r.bn: %u \"%s\", length: %u \"COMPLETED\"\n", receiverBlockNo, getBlockName(receiverBlockNo,""), signalLength); fprintf(output, "Signal data: "); for(Uint32 j = 0; j < signalLength; j++) fprintf(output, "H\'%.8x ", theData[i++]); fprintf(output,"\n"); break; } case ZLQHKEYCONF: { Uint32 signalLength = LqhKeyConf::SignalLength; fprintf(output, "--------------- Signal ----------------\n"); fprintf(output, "r.bn: %u \"%s\", length: %u \"LQHKEYCONF\"\n", receiverBlockNo, getBlockName(receiverBlockNo,""), signalLength); printLQHKEYCONF(output, theData + i, signalLength, receiverBlockNo); i += signalLength; break; } case ZREMOVE_MARKER: { bool removed_by_api = !(theData[i] & 1); Uint32 signalLength = 2; fprintf(output, "--------------- Signal ----------------\n"); if (removed_by_api) { fprintf(output, "r.bn: %u \"%s\", length: %u \"REMOVE_MARKER\"\n", receiverBlockNo, getBlockName(receiverBlockNo,""), signalLength); } else { fprintf(output, "r.bn: %u \"%s\", length: %u \"REMOVE_MARKER_FAIL_API\"\n", receiverBlockNo, getBlockName(receiverBlockNo,""), signalLength); } fprintf(output, "Signal data: "); i++; // Skip first word! for(Uint32 j = 0; j < signalLength; j++) fprintf(output, "H\'%.8x ", theData[i++]); fprintf(output,"\n"); break; } case ZFIRE_TRIG_REQ: { Uint32 signalLength = FireTrigReq::SignalLength; fprintf(output, "--------------- Signal ----------------\n"); fprintf(output, "r.bn: %u \"%s\", length: %u \"FIRE_TRIG_REQ\"\n", receiverBlockNo, getBlockName(receiverBlockNo,""), signalLength); i += signalLength; break; } case ZFIRE_TRIG_CONF: { Uint32 signalLength = FireTrigConf::SignalLength; fprintf(output, "--------------- Signal ----------------\n"); fprintf(output, "r.bn: %u \"%s\", length: %u \"FIRE_TRIG_CONF\"\n", receiverBlockNo, getBlockName(receiverBlockNo,""), signalLength); i += signalLength; break; } default: fprintf(output, "Unknown signal type\n"); i = len; // terminate printing break; } }//for fprintf(output, "--------- End Packed Signals ----------\n"); return true; }
void execute(void * callbackObj, SignalHeader * const header, Uint8 prio, Uint32 * const theData, LinearSectionPtr ptr[3]){ const Uint32 secCount = header->m_noOfSections; const Uint32 length = header->theLength; #ifdef TRACE_DISTRIBUTED ndbout_c("recv: %s(%d) from (%s, %d)", getSignalName(header->theVerId_signalNumber), header->theVerId_signalNumber, getBlockName(refToBlock(header->theSendersBlockRef)), refToNode(header->theSendersBlockRef)); #endif bool ok = true; Ptr<SectionSegment> secPtr[3]; switch(secCount){ case 3: ok &= import(secPtr[2], ptr[2].p, ptr[2].sz); case 2: ok &= import(secPtr[1], ptr[1].p, ptr[1].sz); case 1: ok &= import(secPtr[0], ptr[0].p, ptr[0].sz); } /** * Check that we haven't received a too long signal */ ok &= (length + secCount <= 25); Uint32 secPtrI[3]; if(ok){ /** * Normal path */ secPtrI[0] = secPtr[0].i; secPtrI[1] = secPtr[1].i; secPtrI[2] = secPtr[2].i; globalScheduler.execute(header, prio, theData, secPtrI); return; } /** * Out of memory */ for(Uint32 i = 0; i<secCount; i++){ if(secPtr[i].p != 0){ g_sectionSegmentPool.releaseList(relSz(ptr[i].sz), secPtr[i].i, secPtr[i].p->m_lastSegment); } } Uint32 gsn = header->theVerId_signalNumber; Uint32 len = header->theLength; Uint32 newLen= (len > 22 ? 22 : len); SignalDroppedRep * rep = (SignalDroppedRep*)theData; memmove(rep->originalData, theData, (4 * newLen)); rep->originalGsn = gsn; rep->originalLength = len; rep->originalSectionCount = secCount; header->theVerId_signalNumber = GSN_SIGNAL_DROPPED_REP; header->theLength = newLen + 3; header->m_noOfSections = 0; globalScheduler.execute(header, prio, theData, secPtrI); }
void Filename::set(Filename::NameSpec& spec, BlockReference blockReference, const Uint32 filenumber[4], bool dir) { char buf[PATH_MAX]; const Uint32 type = FsOpenReq::getSuffix(filenumber); const Uint32 version = FsOpenReq::getVersion(filenumber); size_t sz; if (version == 2) { sz = BaseString::snprintf(theName, sizeof(theName), "%s", spec.backup_path.c_str()); m_base_name = theName + spec.backup_path.length(); } else { sz = BaseString::snprintf(theName, sizeof(theName), "%s", spec.fs_path.c_str()); m_base_name = theName + spec.fs_path.length(); } switch(version){ case 1 :{ const Uint32 diskNo = FsOpenReq::v1_getDisk(filenumber); const Uint32 table = FsOpenReq::v1_getTable(filenumber); const Uint32 frag = FsOpenReq::v1_getFragment(filenumber); const Uint32 S_val = FsOpenReq::v1_getS(filenumber); const Uint32 P_val = FsOpenReq::v1_getP(filenumber); if (diskNo < 0xff){ BaseString::snprintf(buf, sizeof(buf), "D%d%s", diskNo, DIR_SEPARATOR); strcat(theName, buf); } { const char* blockName = getBlockName( refToBlock(blockReference) ); if (blockName == NULL){ ERROR_SET(ecError, NDBD_EXIT_AFS_PARAMETER,"","No Block Name"); return; } BaseString::snprintf(buf, sizeof(buf), "%s%s", blockName, DIR_SEPARATOR); strcat(theName, buf); } if (table < 0xffffffff){ BaseString::snprintf(buf, sizeof(buf), "T%d%s", table, DIR_SEPARATOR); strcat(theName, buf); } if (frag < 0xffffffff){ BaseString::snprintf(buf, sizeof(buf), "F%d%s", frag, DIR_SEPARATOR); strcat(theName, buf); } if (S_val < 0xffffffff){ BaseString::snprintf(buf, sizeof(buf), "S%d", S_val); strcat(theName, buf); } if (P_val < 0xff){ BaseString::snprintf(buf, sizeof(buf), "P%d", P_val); strcat(theName, buf); } } break; case 2:{ const Uint32 seq = FsOpenReq::v2_getSequence(filenumber); const Uint32 nodeId = FsOpenReq::v2_getNodeId(filenumber); const Uint32 count = FsOpenReq::v2_getCount(filenumber); BaseString::snprintf(buf, sizeof(buf), "BACKUP%sBACKUP-%d%s", DIR_SEPARATOR, seq, DIR_SEPARATOR); strcat(theName, buf); if(count == 0xffffffff) { BaseString::snprintf(buf, sizeof(buf), "BACKUP-%d.%d", seq, nodeId); strcat(theName, buf); } else { BaseString::snprintf(buf, sizeof(buf), "BACKUP-%d-%d.%d", seq, count, nodeId); strcat(theName, buf); } break; } break; case 3:{ const Uint32 diskNo = FsOpenReq::v1_getDisk(filenumber); if(diskNo == 0xFF){ ERROR_SET(ecError, NDBD_EXIT_AFS_PARAMETER,"","Invalid disk specification"); } BaseString::snprintf(buf, sizeof(buf), "D%d%s", diskNo, DIR_SEPARATOR); strcat(theName, buf); } break; case 5: { Uint32 tableId = FsOpenReq::v5_getTableId(filenumber); Uint32 lcpNo = FsOpenReq::v5_getLcpNo(filenumber); Uint32 fragId = FsOpenReq::v5_getFragmentId(filenumber); BaseString::snprintf(buf, sizeof(buf), "LCP/%d/T%dF%d", lcpNo, tableId, fragId); strcat(theName, buf); break; } default: ERROR_SET(ecError, NDBD_EXIT_AFS_PARAMETER,"","Wrong version"); } if (type >= noOfExtensions){ ERROR_SET(ecError, NDBD_EXIT_AFS_PARAMETER,"","File Type doesn't exist"); return; } strcat(theName, fileExtension[type]); if(dir == true){ for(int l = strlen(theName) - 1; l >= 0; l--){ if(theName[l] == DIR_SEPARATOR[0]){ theName[l] = 0; break; } } } }
static void lstFunction(EjsMod *mp, EjsModule *module, EjsObj *block, int slotNum, EjsName qname, EjsFunction *fun, int attributes) { Ejs *ejs; EjsTrait *trait; EjsName lname; EjsType *resultType; EjsPot *activation; EjsString *space, *blockName; int i, numLocals, numProp; ejs = mp->ejs; activation = fun->activation; numProp = activation ? activation->numProp : 0; space = mapSpace(ejs, qname.space); mprFprintf(mp->file, "\nFUNCTION: "); /* Do the function declaration */ if (attributes) { if (slotNum < 0) { /* Special just for global initializers */ mprFprintf(mp->file, "[initializer] %@ %sfunction %@(", space, getAttributeString(mp, attributes), qname.name); } else { blockName = getBlockName(mp, block, slotNum); mprFprintf(mp->file, "[%@-%02d] %@ %sfunction %@(", blockName, slotNum, space, getAttributeString(mp, attributes), qname.name); } } else { blockName = getBlockName(mp, block, slotNum); mprFprintf(mp->file, "[%@-%02d] %@ function %@(", blockName, slotNum, space, qname.name); } for (i = 0; i < (int) fun->numArgs; ) { lname = ejsGetPropertyName(ejs, activation, i); trait = ejsGetPropertyTraits(ejs, activation, i); if (trait->type) { mprFprintf(mp->file, "%@: %@", lname.name, trait->type->qname.name); } else { mprFprintf(mp->file, "%@", lname.name); } if (++i < (int) fun->numArgs) { mprFprintf(mp->file, ", "); } } resultType = fun->resultType; mprFprintf(mp->file, ") : %@\n", resultType ? resultType->qname.name : EST(Void)->qname.name); /* Repeat the args */ for (i = 0; i < (int) fun->numArgs; i++) { lname = ejsGetPropertyName(ejs, activation, i); trait = ejsGetPropertyTraits(ejs, activation, i); mprFprintf(mp->file, " ARG: [arg-%02d] %@ %@", i, lname.space, lname.name); if (trait->type) { mprFprintf(mp->file, " : %@", trait->type->qname.name); } mprFprintf(mp->file, "\n"); } numLocals = numProp - fun->numArgs; for (i = 0; i < numLocals; i++) { lname = ejsGetPropertyName(ejs, activation, i + fun->numArgs); trait = ejsGetPropertyTraits(ejs, activation, i + fun->numArgs); mprFprintf(mp->file, " LOCAL: [local-%02d] var %@", i + fun->numArgs, lname.name); if (trait->type) { mprFprintf(mp->file, " : %@", trait->type->qname.name); } mprFprintf(mp->file, "\n"); } if (fun->body.code) { mprFprintf(mp->file, "\n"); interp(mp, module, fun); } mprFprintf(mp->file, "\n"); }