Exemplo n.º 1
0
Arquivo: debug.c Projeto: fmccabe/cafe
void stackTrace(processPo p, ioPo out, logical showStack) {
  heapPo h = processHeap(p);
  methodPo mtd = p->prog;
  framePo fp = p->fp;
  ptrPo sp = p->sp;
  insPo pc = p->pc;

  integer frameNo = 0;

  outMsg(out, "Stack trace for process %d ", p->processNo);
#ifdef TRACEEXEC
  if (debugDebugging) {
    stackSummary(out, p, sp);
    heapSummary(out, h);
  }
#endif
  outMsg(out, "\n");

  while (fp->fp < (framePo) p->stackLimit) {
    showStackEntry(out, frameNo, mtd, pc, fp, sp, showStack);

    mtd = fp->prog;
    pc = fp->rtn;
    sp = (ptrPo) (fp + 1);
    fp = fp->fp;
    frameNo++;
  }
  flushFile(out);
}
void testFlushFileSimple(RTTEST hTest)
{
    VBOXHGCMSVCFNTABLE  svcTable;
    VBOXHGCMSVCHELPERS  svcHelpers;
    SHFLROOT Root;
    const RTFILE hcFile = (RTFILE) 0x10000;
    SHFLHANDLE Handle;
    int rc;

    RTTestSub(hTest, "Flush file simple");
    Root = initWithWritableMapping(hTest, &svcTable, &svcHelpers,
                                   "/test/mapping", "testname");
    testRTFileOpenpFile = hcFile;
    rc = createFile(&svcTable, Root, "/test/file", SHFL_CF_ACCESS_READ,
                    &Handle, NULL);
    RTTEST_CHECK_RC_OK(hTest, rc);
    rc = flushFile(&svcTable, Root, Handle);
    RTTEST_CHECK_RC_OK(hTest, rc);
    RTTEST_CHECK_MSG(hTest, testRTFileFlushFile == hcFile,
                     (hTest, "File=%llu\n", LLUIFY(testRTFileFlushFile)));
    unmapAndRemoveMapping(hTest, &svcTable, Root, "testname");
    AssertReleaseRC(svcTable.pfnDisconnect(NULL, 0, svcTable.pvService));
    RTTestGuardedFree(hTest, svcTable.pvService);
    RTTEST_CHECK_MSG(hTest, testRTFileCloseFile == hcFile,
                     (hTest, "File=%llu\n", LLUIFY(testRTFileCloseFile)));
}
Exemplo n.º 3
0
void Master::recvChains(int proc, bool not_full_pkg)
{
    int chain_count = m_chain_pkg_size;

    //When not full pkg, recv chain count first.
    if(not_full_pkg)
    {
        MPI_Recv(&chain_count, 1, MPI_INTEGER, proc, COMM_ID_DATA, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
        if(chain_count > m_chain_pkg_size)
        {
            //wtf I dont want your chains
            return;
        }
    }

#ifdef __VERBOSE__
    printf("[master] receiving %d chains from %d\n", chain_count, proc);
#endif

    MPI_Recv(m_chain_buffer, chain_count * 20, MPI_CHAR, proc, COMM_ID_DATA, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
    m_chain_count += chain_count;

    //saving chains here
    fwrite(m_chain_buffer, chain_count, 20, m_table_file);
    flushFile();
}
Exemplo n.º 4
0
/**
  * Destructor of BufMgr class
  */
BufMgr::~BufMgr() {
	for(std::uint32_t i =0 ; i<numBufs; i++){
		if(bufDescTable[i].dirty == true){
			flushFile(bufDescTable[i].file);		
		}
	}
	delete[] bufDescTable;
	delete[] bufPool;
	delete hashTable;
}
Exemplo n.º 5
0
/**
* Destructor of BufMgr class
*/
BufMgr::~BufMgr() {
	for(FrameId i = 0; i < numBufs; i++){
		if(bufDescTable[i].dirty){
			flushFile(bufDescTable[i].file);
		}
	}

	delete [] bufPool;
	delete [] bufDescTable;
	delete hashTable;
}
Exemplo n.º 6
0
void VisualLog::flushLine(){
    if ( canLog() ){
        QString pref = prefix();
        if ( m_output & VisualLog::Console )
            vLoggerConsole(pref + m_buffer + "\n");
        if ( m_output & VisualLog::File )
            flushFile(pref + m_buffer + "\n");
        if ( m_output & VisualLog::View && m_model )
            m_model->onMessage(m_configuration, m_messageInfo, m_buffer);
        if ( m_output & VisualLog::Extensions )
            flushHandler(m_buffer);

        m_buffer = "";
    }
}
Exemplo n.º 7
0
Arquivo: debug.c Projeto: fmccabe/cafe
static DebugWaitFor cmder(debugOptPo opts, processPo p, methodPo mtd, termPo loc, insWord ins) {
  static bufferPo cmdBuffer = Null;

  if (cmdBuffer == Null)
    cmdBuffer = newStringBuffer();

  while (interactive) {
    dbgPrompt(p);
    clearBuffer(cmdBuffer);

    setEditLineCompletionCallback(cmdComplete, (void *) opts);
    retCode res = (debuggerListener == Null ? consoleInput(cmdBuffer) : inLine(debugInChnnl, cmdBuffer, "\n"));
    clearEditLineCompletionCallback();

    switch (res) {
      case Eof:
        return quitDbg;
      case Ok: {
        integer cmdLen = 0;
        char *cmdLine = getTextFromBuffer(cmdBuffer, &cmdLen);

        cmdLine = defltLine(cmdLine, cmdLen, &cmdLen);

        codePoint cmd;
        integer nxt = 0;
        cmd = nextCodePoint(cmdLine, &nxt, cmdLen);

        if (isNdChar((codePoint) cmd)) {
          cmd = 'n';
          nxt = 0;
        }

        for (int ix = 0; ix < opts->count; ix++) {
          if (opts->opts[ix].c == cmd)
            return opts->opts[ix].cmd(&cmdLine[nxt], p, loc, ins, opts->opts[ix].cl);
        }
        outMsg(debugOutChnnl, "invalid debugger command: %s\n", cmdLine);
      }
      default:
        for (int ix = 0; ix < opts->count; ix++)
          outMsg(debugOutChnnl, "%s\n", opts->opts[ix].usage);
        flushFile(debugOutChnnl);
        return moreDebug;
    }
  }
  return moreDebug;
}
Exemplo n.º 8
0
Arquivo: debug.c Projeto: fmccabe/cafe
static DebugWaitFor dbgShowCode(char *line, processPo p, termPo loc, insWord ins, void *cl) {
  integer count = maximum(1, cmdCount(line, 1));
  methodPo mtd = p->prog;
  insPo pc = p->pc;

  insPo last = entryPoint(mtd) + insCount(mtd);

  for (integer ix = 0; ix < count && pc < last; ix++) {
    pc = disass(debugOutChnnl, p, mtd, pc, Null, Null);
    outStr(debugOutChnnl, "\n");
  }

  flushFile(debugOutChnnl);
  resetDeflt("n");

  return moreDebug;
}
Exemplo n.º 9
0
Arquivo: debug.c Projeto: fmccabe/cafe
void dumpStackTrace(processPo p, ioPo out) {
  heapPo h = processHeap(p);
  methodPo mtd = p->prog;
  framePo fp = p->fp;
  insPo pc = p->pc;

  integer frameNo = 0;

  outMsg(out, "Stack dump for p: %d\n", processNo(p));

  while (fp->fp < (framePo) p->stackLimit) {
    showStackCall(out, frameNo, mtd, pc, fp, 1);

    mtd = fp->prog;
    pc = fp->rtn;
    fp = fp->fp;
    frameNo++;
  }
  flushFile(out);
}
Exemplo n.º 10
0
/** This function allocates a free frame using the clock algorithm;
if necessary, writing a dirty page back to disk.
Returns BUFFEREXCEEDED if all buffer frames are pinned,
UNIXERR if the call to the I/O layer returned an error when a dirty page was being written to disc; else OK.
This private method will get called by the readPage() and allocPage() methods.
If the buffer frame allocated has a valid page in it, then remove the appropriate entry from the hash table.
@param  frame-reference to the frame being allocated
@return Status-status information from function
**/
const Status BufMgr::allocBuf(int & frame) {

    int pinCount = 0;
    //unsigned int initialClockHand = clockHand;
    while(1){
        advanceClock();
        //if valid is false, clear and return frame number
        if (bufTable[clockHand].valid != false) {
            if (bufTable[clockHand].pinCnt > 0) {
                pinCount++;
            }
            //if pinCount reaches numBufs than every buffer frame is being referenced
            if (pinCount == numBufs) {
                return BUFFEREXCEEDED;
            }
            //The two loops in the logic diagram
            if (bufTable[clockHand].refbit == true) { //Check valid bit
                bufTable[clockHand].refbit = false;
                continue; //Loop if valid and refbit set
            } else if (bufTable[clockHand].refbit == false && bufTable[clockHand].pinCnt > 0){
                continue;
            // if valid, unreferenced, not pinned, and dirty; than flush page in frame to disc 
            } else if (bufTable[clockHand].refbit == false && bufTable[clockHand].pinCnt <= 0 && bufTable[clockHand].dirty == true) {
                assert(bufTable[clockHand].pinCnt == 0); //Sanity check
                /**Flush page to disk **/
                flushFile(bufTable[clockHand].file);
                bufTable[clockHand].dirty = false;
            }
            assert(bufTable[clockHand].dirty == false); //Should not be dirty
            assert(bufTable[clockHand].pinCnt == 0);    //Should be zero
            if (bufTable[clockHand].valid == true) {
                assert(bufTable[clockHand].pinCnt == 0);
                hashTable->remove(bufTable[clockHand].file, bufTable[clockHand].pageNo);
            }
        }//end valid == false
        //A frame has been selected for removal 
        bufTable[clockHand].Clear();
        frame = clockHand; //clear frame and return frame pointer
        return OK;
    }//end valid not equal to false
}// end function allocBuf
Exemplo n.º 11
0
int closeFile(fileHandleType fh) {


	if (fh > MAX_OPEN_FILES)
		return ERROR_BAD_HANDLE;

	if (fileCursors[fh].inUse == 0)
		return ERROR_BAD_HANDLE;

	flushFile(fh);

	fileCursors[fh].inUse = 0;
	fileCursors[fh].dirEntryNum = 0;
	fileCursors[fh].writePos = 0;
	fileCursors[fh].readPos = 0;
	fileCursors[fh].fileSize = 0;
	fileCursors[fh].othersPermissions = 0;

	return NO_ERROR;

}
Exemplo n.º 12
0
void VisualLog::asObject(const QString &type, const MLNode &mlvalue){
    QByteArray str;
    ml::toJson(mlvalue, str);
    QString pref = prefix();
    QString writeData =
        pref + "\\@" + type + "\n" +
        QString(pref.length(), ' ') + str + "\n";

    if ( m_output & VisualLog::Console && m_configuration->m_logObjects & VisualLog::Console ){
        flushConsole(writeData);
        m_output &= ~VisualLog::Console; // remove console flag from text based logging
    }
    if ( m_output & VisualLog::File && m_configuration->m_logObjects & VisualLog::File ){
        flushFile(writeData);
        m_output &= ~VisualLog::File; // remove file flag from text based logging
    }
    if ( m_output & VisualLog::Extensions && m_configuration->m_logObjects & VisualLog::Extensions){
        for ( auto it = m_configuration->m_transports.begin(); it != m_configuration->m_transports.end(); ++it ){
            (*it)->onObject(m_configuration, m_messageInfo, type, mlvalue);
        }
    }
}
Exemplo n.º 13
0
/*
 *
 * Allocate a free frame.  
 *
 * @param frame   	Frame reference, frame ID of allocated frame returned via this variable
 * @throws BufferExceededException If no such buffer is found which can be allocated
 */
void BufMgr::allocBuf(FrameId & frame) 
{
	std::uint32_t clock_count = 0;
	//clock algorithm
	while(1){
		advanceClock();
		if(bufDescTable[clockHand].valid == true){
			if(bufDescTable[clockHand].refbit == true){
				bufDescTable[clockHand].refbit = false;
				//skip all the steps below and loop again
				continue;
			}
			if(bufDescTable[clockHand].pinCnt > 0){
				clock_count++;
				//if every pages is being pinned in buffer pool, throw exception
				if(clock_count > numBufs){
					throw BufferExceededException();
				}
				continue;
			}
			if(bufDescTable[clockHand].dirty == true){
				flushFile(bufDescTable[clockHand].file);
				bufDescTable[clockHand].dirty = false;
			}
			else{
				hashTable->remove(bufDescTable[clockHand].file, bufDescTable[clockHand].pageNo);
			}
			break;
		}
		else{
			break;
		}
	}

	frame = bufDescTable[clockHand].frameNo;
}
Exemplo n.º 14
0
int cond::ValidateUtilities::execute(){

  initializeForDbConnection();
  std::string tag("");
  if( hasOptionValue("tag") ) tag = getOptionValue<std::string>("tag");
  std::string dir("");
  if( hasOptionValue("dir") ) dir = getOptionValue<std::string>("dir");

  bool debug = hasDebug();

  std::string refConnect = getOptionValue<std::string>("reference");
  std::string candidate = getOptionValue<std::string>("candidate" );

  std::tuple<std::string,std::string,std::string> connPars = persistency::parseConnectionString( refConnect );
  if( std::get<0>( connPars ) == "frontier" ) throwException("Cannot validate data from FronTier cache.","ValidateUtilities::execute");
     
  std::string refDbName = std::get<1>( connPars )+"_"+std::get<2>( connPars );
  
  if(debug){
    std::cout << "tag " << tag << std::endl;
  }  
  
  
  std::vector<std::string> tagToProcess;
  if( !tag.empty() ){
    tagToProcess.push_back( tag );
  } else {
    cond::DbSession refdb = openDbSession( "reference", cond::Auth::COND_READER_ROLE, true );
    refdb.transaction().start( true );
    cond::MetaData  metadata(refdb);
    metadata.listAllTags( tagToProcess );
    refdb.transaction().commit();
  }

  persistency::ConnectionPool connPool;
  std::cout <<"# Opening session on reference database..."<<std::endl;
  persistency::Session session0 = connPool.createSession( refConnect );
  std::cout <<"# Opening session on candidates database..."<<std::endl;
  persistency::Session session1 = connPool.createSession( candidate );
  session1.transaction().start();
  if( !session1.existsDatabase() ) throwException( "Candidate DB \""+candidate+" does not exist.",
						   "MigrateUtilities::execute" );

  std::cout <<"# "<<tagToProcess.size()<<" tag(s) to process."<<std::endl;
  std::cout <<std::endl;
  size_t nt = 0;
  size_t tid = 0;
  for( auto t : tagToProcess ){
    tid++;
    std::cout <<"--> Processing tag["<<tid<<"]: "<<t<<std::endl;
    std::string refFileName("");
    std::string candFileName("");
    try{      
      std::cout <<"    Writing reference db"<<std::endl;
      refFileName = writeTag( t, "ref", session0, dir );
      std::string destTag("");
      cond::MigrationStatus status;
      if( !session1.checkMigrationLog( refConnect, t, destTag, status ) ) {
	std::cout << "    ERROR: Tag "<< t <<" has not been migrated in database " << candidate <<std::endl;
	boost::filesystem::remove( boost::filesystem::path(refFileName) );
      } else {
	std::cout <<"    Writing candidate db"<<std::endl;
	candFileName = writeTag( destTag, "cand", session1, dir ); 
	bool cmp = compareFiles( refFileName, candFileName ); 
	if(!cmp){
	  std::cout <<"    ERROR: Comparison found differences."<<std::endl;
	  flushFile( refDbName, t, refFileName );
	  flushFile( refDbName, t, candFileName  );
	} else {
	  std::cout <<"    Comparison OK."<<std::endl;
	}
	nt++;
      }
    } catch ( const std::exception& e ){
      std::cout <<"    ERROR:"<<e.what()<<std::endl;
      std::cout <<"    Tag "<<t<<" will be skipped."<<std::endl;
    }
    cleanUp( refFileName );
    cleanUp( candFileName );
  }

  std::cout <<std::endl<<"# "<<nt<<" tag(s) checked for validation."<<std::endl;

  return 0;
}