diff --git a/ndb/include/kernel/signaldata/SignalData.hpp b/ndb/include/kernel/signaldata/SignalData.hpp index 511e7d30c21..6e5748217b2 100644 --- a/ndb/include/kernel/signaldata/SignalData.hpp +++ b/ndb/include/kernel/signaldata/SignalData.hpp @@ -21,20 +21,10 @@ #include #include -#ifndef NDB_ASSERT -#ifdef VM_TRACE -#define NDB_ASSERT(test, message) { if(!(test)) { printf(message); exit(-1); }} -#else -#define NDB_ASSERT(test, message) -#endif -#endif - -// Useful ASSERT macros... -#define ASSERT_BOOL(flag, message) NDB_ASSERT( (flag<=1), (message) ) +#define ASSERT_BOOL(flag, message) assert(flag<=1) #define ASSERT_RANGE(value, min, max, message) \ - NDB_ASSERT((value) >= (min) && (value) <= (max), (message)) -#define ASSERT_MAX(value, max, message) \ - NDB_ASSERT((value) <= (max), (message)) + assert((value) >= (min) && (value) <= (max)) +#define ASSERT_MAX(value, max, message) assert((value) <= (max)) #define SECTION(x) STATIC_CONST(x) diff --git a/ndb/include/mgmcommon/MgmtErrorReporter.hpp b/ndb/include/mgmcommon/MgmtErrorReporter.hpp index 925d9e6407a..0d980aa7245 100644 --- a/ndb/include/mgmcommon/MgmtErrorReporter.hpp +++ b/ndb/include/mgmcommon/MgmtErrorReporter.hpp @@ -63,12 +63,6 @@ // Returns: - //**************************************************************************** -#ifndef NDB_ASSERT -#define NDB_ASSERT(trueToContinue, message) \ - if ( !(trueToContinue) ) { \ -ndbout << "ASSERT FAILED. FILE: " << __FILE__ << ", LINE: " << __LINE__ << ", MSG: " << message << endl;exit(-1);} -#endif - #define MGM_REQUIRE(x) \ if (!(x)) { ndbout << __FILE__ << " " << __LINE__ \ << ": Warning! Requirement failed" << endl; } diff --git a/ndb/include/util/Bitmask.hpp b/ndb/include/util/Bitmask.hpp index 7355742f845..a670889f3b3 100644 --- a/ndb/include/util/Bitmask.hpp +++ b/ndb/include/util/Bitmask.hpp @@ -19,11 +19,6 @@ #include -#ifndef NDB_ASSERT -#define NDB_ASSERT(x, s) \ - do { if (!(x)) { printf("%s\n", s); abort(); } } while (0) -#endif - /** * Bitmask implementation. Size is given explicitly * (as first argument). All methods are static. @@ -140,7 +135,7 @@ public: inline bool BitmaskImpl::get(unsigned size, const Uint32 data[], unsigned n) { - NDB_ASSERT(n < (size << 5), "bit get out of range"); + assert(n < (size << 5)); return (data[n >> 5] & (1 << (n & 31))) != 0; } @@ -153,7 +148,7 @@ BitmaskImpl::set(unsigned size, Uint32 data[], unsigned n, bool value) inline void BitmaskImpl::set(unsigned size, Uint32 data[], unsigned n) { - NDB_ASSERT(n < (size << 5), "bit set out of range"); + assert(n < (size << 5)); data[n >> 5] |= (1 << (n & 31)); } @@ -176,7 +171,7 @@ BitmaskImpl::assign(unsigned size, Uint32 dst[], const Uint32 src[]) inline void BitmaskImpl::clear(unsigned size, Uint32 data[], unsigned n) { - NDB_ASSERT(n < (size << 5), "bit clear out of range"); + assert(n < (size << 5)); data[n >> 5] &= ~(1 << (n & 31)); } diff --git a/ndb/src/common/debugger/SignalLoggerManager.cpp b/ndb/src/common/debugger/SignalLoggerManager.cpp index 3839a348222..d642ed09a68 100644 --- a/ndb/src/common/debugger/SignalLoggerManager.cpp +++ b/ndb/src/common/debugger/SignalLoggerManager.cpp @@ -487,31 +487,6 @@ SignalLoggerManager::printLinearSection(FILE * output, putc('\n', output); } -void -SignalLoggerManager::printSegmentedSection(FILE * output, - const SignalHeader & sh, - const SegmentedSectionPtr ptr[3], - unsigned i) -{ - fprintf(output, "SECTION %u type=segmented", i); - if (i >= 3) { - fprintf(output, " *** invalid ***\n"); - return; - } - const Uint32 len = ptr[i].sz; - SectionSegment * ssp = ptr[i].p; - Uint32 pos = 0; - fprintf(output, " size=%u\n", (unsigned)len); - while (pos < len) { - if (pos > 0 && pos % SectionSegment::DataLength == 0) { - ssp = g_sectionSegmentPool.getPtr(ssp->m_nextSegment); - } - printDataWord(output, pos, ssp->theData[pos % SectionSegment::DataLength]); - } - if (len > 0) - putc('\n', output); -} - void SignalLoggerManager::printDataWord(FILE * output, Uint32 & pos, const Uint32 data) { diff --git a/ndb/src/kernel/Main.cpp b/ndb/src/kernel/Main.cpp index 7bd4e75ca18..51960dbf694 100644 --- a/ndb/src/kernel/Main.cpp +++ b/ndb/src/kernel/Main.cpp @@ -143,7 +143,7 @@ NDB_MAIN(ndb_kernel){ // Set thread concurrency for Solaris' light weight processes int status; status = NdbThread_SetConcurrencyLevel(30); - NDB_ASSERT(status == 0, "Can't set appropriate concurrency level."); + assert(status == 0); #ifdef VM_TRACE // Create a signal logger @@ -168,7 +168,7 @@ NDB_MAIN(ndb_kernel){ globalEmulatorData.theThreadConfig->doStart(NodeState::SL_STARTING); break; default: - NDB_ASSERT(0, "Illegal state globalData.theRestartFlag"); + assert("Illegal state globalData.theRestartFlag" == 0); } globalTransporterRegistry.startSending(); diff --git a/ndb/src/kernel/blocks/dbtux/Dbtux.hpp b/ndb/src/kernel/blocks/dbtux/Dbtux.hpp index 25e85ba9f5f..62f47af94bd 100644 --- a/ndb/src/kernel/blocks/dbtux/Dbtux.hpp +++ b/ndb/src/kernel/blocks/dbtux/Dbtux.hpp @@ -924,7 +924,7 @@ Dbtux::TreeHead::getSize(AccSize acc) const case AccFull: return m_nodeSize; } - REQUIRE(false, "invalid Dbtux::AccSize"); + abort(); return 0; } diff --git a/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp b/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp index 7ba7d0d25c6..f6607cdbdbb 100644 --- a/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp +++ b/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp @@ -229,7 +229,7 @@ AsyncFile::run() endReq(); return; default: - THREAD_REQUIRE(false, "Using default switch in AsyncFile::run"); + abort(); break; }//switch theReportTo->writeChannel(request); diff --git a/ndb/src/kernel/blocks/ndbfs/MemoryChannel.hpp b/ndb/src/kernel/blocks/ndbfs/MemoryChannel.hpp index 435a6a6b208..03911d195ec 100644 --- a/ndb/src/kernel/blocks/ndbfs/MemoryChannel.hpp +++ b/ndb/src/kernel/blocks/ndbfs/MemoryChannel.hpp @@ -120,8 +120,7 @@ template void MemoryChannel::writeChannel( T *t) { NdbMutex_Lock(theMutexPtr); - REQUIRE(!full(theWriteIndex, theReadIndex), "Memory Channel Full"); - REQUIRE(theChannel != NULL, "Memory Channel Full"); + if(full(theWriteIndex, theReadIndex) || theChannel == NULL) abort(); theChannel[theWriteIndex]= t; ++theWriteIndex; NdbMutex_Unlock(theMutexPtr); diff --git a/ndb/src/kernel/blocks/ndbfs/Pool.hpp b/ndb/src/kernel/blocks/ndbfs/Pool.hpp index a26fa730727..0410673af6f 100644 --- a/ndb/src/kernel/blocks/ndbfs/Pool.hpp +++ b/ndb/src/kernel/blocks/ndbfs/Pool.hpp @@ -215,7 +215,6 @@ protected: T** tList = theList; int i; theList = new T*[aSize+theCurrentSize]; - REQUIRE(theList != 0, "Allocate in Pool.hpp failed"); // allocate full list for (i = 0; i < theTop; i++) { theList[i] = tList[i]; diff --git a/ndb/src/kernel/error/ErrorReporter.hpp b/ndb/src/kernel/error/ErrorReporter.hpp index b43b30f1873..201c998307e 100644 --- a/ndb/src/kernel/error/ErrorReporter.hpp +++ b/ndb/src/kernel/error/ErrorReporter.hpp @@ -23,35 +23,6 @@ #include "Error.hpp" #include - -#ifdef ASSERT -#undef ASSERT -#endif - -#define REQUIRE(trueToContinue, message) \ - if ( (trueToContinue) ) { } else { \ - ErrorReporter::handleAssert(message, __FILE__, __LINE__); } - -#define THREAD_REQUIRE(trueToContinue, message) \ - if ( (trueToContinue) ) { } else { \ - ErrorReporter::handleThreadAssert(message, __FILE__, __LINE__); } - -#ifdef NDEBUG -#define NDB_ASSERT(trueToContinue, message) -#else -#define NDB_ASSERT(trueToContinue, message) \ - if ( !(trueToContinue) ) { \ - ErrorReporter::handleAssert(message, __FILE__, __LINE__); } -#endif - - // Description: - // This macro is used to report programming errors. - // Parameters: - // trueToContinue IN An expression. If it evaluates to 0 - // execution is stopped. - // message IN A message from the programmer - // explaining what went wrong. - class ErrorReporter { public: diff --git a/ndb/src/kernel/vm/MetaData.cpp b/ndb/src/kernel/vm/MetaData.cpp index bcde6c63272..51afbf21503 100644 --- a/ndb/src/kernel/vm/MetaData.cpp +++ b/ndb/src/kernel/vm/MetaData.cpp @@ -47,7 +47,7 @@ MetaData::MetaData(SimulatedBlock* block) : MetaData::~MetaData() { for (int i = false; i <= true; i++) { - NDB_ASSERT(m_common.m_lock[i] >= m_lock[i], "invalid lock count"); + assert(m_common.m_lock[i] >= m_lock[i]); m_common.m_lock[i] -= m_lock[i]; m_lock[i] = 0; } diff --git a/ndb/src/kernel/vm/SimulatedBlock.cpp b/ndb/src/kernel/vm/SimulatedBlock.cpp index a6a8a6242cd..781c60e3817 100644 --- a/ndb/src/kernel/vm/SimulatedBlock.cpp +++ b/ndb/src/kernel/vm/SimulatedBlock.cpp @@ -136,12 +136,12 @@ SimulatedBlock::installSimulatedBlockFunctions(){ void SimulatedBlock::addRecSignalImpl(GlobalSignalNumber gsn, ExecFunction f, bool force){ - REQUIRE(gsn <= MAX_GSN, "Illegal signal added in block (GSN too high)"); - char probData[255]; - snprintf(probData, 255, - "Signal (%d) already added in block", - gsn); - REQUIRE(force || theExecArray[gsn] == 0, probData); + if(gsn > MAX_GSN || (!force && theExecArray[gsn] != 0)){ + char errorMsg[255]; + snprintf(errorMsg, 255, + "Illeagal signal (%d %d)", gsn, MAX_GSN); + ERROR_SET(fatal, ERR_ERROR_PRGERR, errorMsg, errorMsg); + } theExecArray[gsn] = f; } diff --git a/ndb/src/kernel/vm/SimulatedBlock.hpp b/ndb/src/kernel/vm/SimulatedBlock.hpp index 491d432625e..e3eac8c0e20 100644 --- a/ndb/src/kernel/vm/SimulatedBlock.hpp +++ b/ndb/src/kernel/vm/SimulatedBlock.hpp @@ -458,11 +458,11 @@ SimulatedBlock::executeFunction(GlobalSignalNumber gsn, Signal* signal){ char errorMsg[255]; if (!(gsn <= MAX_GSN)) { snprintf(errorMsg, 255, "Illegal signal received (GSN %d too high)", gsn); - REQUIRE(false, errorMsg); + ERROR_SET(fatal, ERR_ERROR_PRGERR, errorMsg, errorMsg); } if (!(theExecArray[gsn] != 0)) { snprintf(errorMsg, 255, "Illegal signal received (GSN %d not added)", gsn); - REQUIRE(false, errorMsg); + ERROR_SET(fatal, ERR_ERROR_PRGERR, errorMsg, errorMsg); } ndbrequire(false); } diff --git a/ndb/src/kernel/vm/TransporterCallback.cpp b/ndb/src/kernel/vm/TransporterCallback.cpp index eb7d138895c..158de64c87f 100644 --- a/ndb/src/kernel/vm/TransporterCallback.cpp +++ b/ndb/src/kernel/vm/TransporterCallback.cpp @@ -434,5 +434,28 @@ reportDisconnect(void * callbackObj, NodeId nodeId, Uint32 errNo){ globalScheduler.execute(&signal, JBA, CMVMI, GSN_DISCONNECT_REP); } - +void +SignalLoggerManager::printSegmentedSection(FILE * output, + const SignalHeader & sh, + const SegmentedSectionPtr ptr[3], + unsigned i) +{ + fprintf(output, "SECTION %u type=segmented", i); + if (i >= 3) { + fprintf(output, " *** invalid ***\n"); + return; + } + const Uint32 len = ptr[i].sz; + SectionSegment * ssp = ptr[i].p; + Uint32 pos = 0; + fprintf(output, " size=%u\n", (unsigned)len); + while (pos < len) { + if (pos > 0 && pos % SectionSegment::DataLength == 0) { + ssp = g_sectionSegmentPool.getPtr(ssp->m_nextSegment); + } + printDataWord(output, pos, ssp->theData[pos % SectionSegment::DataLength]); + } + if (len > 0) + putc('\n', output); +} diff --git a/ndb/src/mgmclient/CommandInterpreter.cpp b/ndb/src/mgmclient/CommandInterpreter.cpp index cf9d885847a..061ae3be8f0 100644 --- a/ndb/src/mgmclient/CommandInterpreter.cpp +++ b/ndb/src/mgmclient/CommandInterpreter.cpp @@ -1478,7 +1478,7 @@ CommandInterpreter::executeSet(int /*processId*/, << endl; } else { - NDB_ASSERT(false, ""); + assert(false); } } else { @@ -1497,7 +1497,7 @@ CommandInterpreter::executeSet(int /*processId*/, } else { // The primary is not tried to write if the write of backup file fails - NDB_ASSERT(false, ""); + abort(); } } free(newpar); diff --git a/ndb/src/mgmsrv/MgmtSrvr.cpp b/ndb/src/mgmsrv/MgmtSrvr.cpp index 713433cb8e9..5417d4a37e5 100644 --- a/ndb/src/mgmsrv/MgmtSrvr.cpp +++ b/ndb/src/mgmsrv/MgmtSrvr.cpp @@ -1698,7 +1698,7 @@ MgmtSrvr::setSignalLoggingMode(int processId, LogMode mode, logSpec = TestOrd::InputOutputSignals; break; default: - NDB_ASSERT(false, "Unexpected value, MgmtSrvr::setSignalLoggingMode"); + assert("Unexpected value, MgmtSrvr::setSignalLoggingMode" == 0); } NdbApiSignal* signal = getSignal(); diff --git a/ndb/src/ndbapi/TransporterFacade.cpp b/ndb/src/ndbapi/TransporterFacade.cpp index e725144a8f8..58e5d68c4b9 100644 --- a/ndb/src/ndbapi/TransporterFacade.cpp +++ b/ndb/src/ndbapi/TransporterFacade.cpp @@ -162,13 +162,6 @@ setSignalLog(){ } #endif -// These symbols are needed, but not used in the API -int g_sectionSegmentPool; -struct ErrorReporter { - void handleAssert(const char*, const char*, int); -}; -void ErrorReporter::handleAssert(const char* message, const char* file, int line) {} - /** * The execute function : Handle received signal */ @@ -314,6 +307,14 @@ execute(void * callbackObj, SignalHeader * const header, } } +// These symbols are needed, but not used in the API +void +SignalLoggerManager::printSegmentedSection(FILE *, const SignalHeader &, + const SegmentedSectionPtr ptr[3], + unsigned i){ + abort(); +} + void copy(Uint32 * & insertPtr, class SectionSegmentPool & thePool, const SegmentedSectionPtr & _ptr){