Beispiel #1
0
//=============================================================================
// CONSTRUCTOR: SPELLwsFrame::SPELLwsFrame
//=============================================================================
SPELLwsFrame::SPELLwsFrame( const SPELLwsStartupInfo& info, unsigned int depth, PyFrameObject* frame )
{
	// If mode is recover and depth > 0, 'frame' contains the f_back frame.
	// If depth is zero and mode is recover, we just need to fix the dynamics.
	// If mode is other, 'frame' contains the frame associated to this structure.
	if (info.performRecovery)
	{
		DEBUG("[FRM] Recovering " + ISTR(depth) + " level frame");
		m_static = new SPELLwsStaticData(info,depth,frame);
		// Recover this frame
		m_frame = m_static->restore();
		// In recovery mode, the given frame is the previous one in the stack
		m_frame->f_back = frame;
		// Use the recovered frame to restore dynamic data
		m_dynamic = new SPELLwsDynamicData(info,depth,m_frame);
		m_dynamic->restore();
		DEBUG("[FRM] Recovering " + ISTR(depth) + " level frame done: " + PYCREPR(m_frame));
	}
	else
	{
		m_frame = frame;
		m_static = new SPELLwsStaticData(info,depth,m_frame);
		m_dynamic = new SPELLwsDynamicData(info,depth,m_frame);
	}
	DEBUG("[FRM] Created manager for frame " + PYCREPR(m_frame));
	m_lastInstruction = m_frame->f_lasti;
	m_lastLine = m_frame->f_lineno;
}
//=============================================================================
// METHOD: SPELLlistenerContext::onNewContext
//=============================================================================
void SPELLlistenerContext::onNewContext( const SPELLipcMessage& msg )
{
    ContextInfo* ctxInfo;

    std::string ctxName = msg.get(MessageField::FIELD_CTX_NAME);

    ctxInfo = &m_openContexts[ctxName];
    ctxInfo->m_key = msg.getKey();
    ctxInfo->m_port = STRI(msg.get(MessageField::FIELD_CTX_PORT));
    ctxInfo->m_status = MessageValue::DATA_CTX_RUNNING;

    DEBUG("New context:");
    DEBUG("- Name=" + ctxInfo->m_name);
    DEBUG("- Key=" + ISTR(ctxInfo->m_key));
    DEBUG("- Port=" + ISTR(ctxInfo->m_port));
    DEBUG("- Status=" + ctxInfo->m_status);

    m_waitForContextStart.set();

    // Notify to other clients
    SPELLipcMessage notify( msg );
    notify.setId( ListenerMessages::MSG_CONTEXT_OP );
    notify.setType( MSG_TYPE_ONEWAY );
    notify.set( MessageField::FIELD_CTX_STATUS, MessageValue::DATA_CTX_RUNNING );
    notify.setSender("LST");
    notify.setReceiver("GUI");
    m_gui->displace(&notify);

    // Send notification to peer if any, and if alignment is enabled
    if (m_peer) m_peer->displace(msg);
}
Beispiel #3
0
//=============================================================================
// METHOD    : SPELLcallstack::event_line
//=============================================================================
void SPELLcallstack::event_line( const std::string& file, const int& line, const std::string& name )
{
    DEBUG("[CSTACK] Event line: " + file + ":" + ISTR(line) + ", mode=" + ISTR(m_soMode) + ", so=" + BSTR(isSteppingOver()));

    // If the mark executed flag is set, before changing the current line to the new onee we need to
    // mark the old one as executed. The flag will not be set in case of skip or gotos.
    if (m_markExecuted)
    {
    	// Mark the previous line as executed.
		DEBUG("[CSTACK] Previous line executed");
    	SPELLexecutor::instance().getFrame().getTraceModel(file).markExecuted();
    }
    else
    {
    	// The flag is always kept to value true, unless there is a skip or goto. In that
    	// case, the flag is disabled, so that the line is not notified as executed in this
    	// method, and then the flag is reset to true here so that the next line visited
    	// will be (by default) marked as executed once left.
    	m_markExecuted = true;
    	DEBUG("[CSTACK] Previous line NOT executed");
    }

    // Visit the line
	SPELLexecutor::instance().getFrame().getTraceModel(file).setCurrentLine(line);
    // Add a new line for this event
    m_currentNode->eventLine(line);
    // Update the stack string
    m_stack = std::string(file + ":" + ISTR(line));
    // Update the code name string
    m_codeName = name;

	DEBUG("[CSTACK] Event line notify: " + getStack() + ", mode=" + ISTR(m_soMode) + ", so=" + BSTR(isSteppingOver()));
    SPELLexecutor::instance().getCIF().notifyLine();
}
Beispiel #4
0
//============================================================================
// FUNCTION:    SPELLutils::dumpFrameInfo()
//============================================================================
void SPELLutils::dumpFrameInfo( const std::string& id, PyFrameObject* frame, int iStateId, int TStateId, int FrameId )
{
	LOG_INFO("Dump information for frame " + ISTR(iStateId) + "." + ISTR(TStateId) + "." + ISTR(FrameId));

	std::string dataDir = getSPELL_DATA() + PATH_SEPARATOR + "Runtime" + PATH_SEPARATOR;
	std::string filename = dataDir + id + "_frame_state_" + ISTR(iStateId) + "." + ISTR(TStateId) + "." + ISTR(FrameId) + ".dump";
	std::ofstream dumpFile;
	dumpFile.open( filename.c_str() , std::ios::out );

	dumpFile << "FRAME STATE " << TStateId << " DATA" << std::endl;
	dumpFile << "--------------------------------------" << std::endl;
	dumpFile << "Address              : " << PSTR(frame) << std::endl;
	dumpFile << "Next address         : " << PSTR(frame->f_back) << std::endl;
	dumpFile << "Thread state address : " << PSTR(frame->f_tstate) << std::endl;
	dumpFile << "Last instruction     : " << frame->f_lasti << std::endl;
	dumpFile << "Last line            : " << frame->f_lineno << std::endl;
	dumpFile << "Try blocks count     : " << frame->f_iblock << std::endl;
	dumpFile << "Try blocks           : " << PSTR(frame->f_blockstack) << std::endl;
	dumpFile << "Value stack          : " << PSTR(frame->f_valuestack) << std::endl;
	dumpFile << "Stack top            : " << PSTR(frame->f_stacktop) << std::endl;
	dumpFile << "Stack count          : " << (frame->f_stacktop - frame->f_valuestack) << std::endl;
	dumpFile << "Fast locals          : " << (frame->f_code->co_nlocals-1) << std::endl;
	dumpFile << "Exception type       : " << PYREPR(frame->f_exc_type) << std::endl;
	dumpFile << "Exception value      : " << PYREPR(frame->f_exc_value) << std::endl;
	dumpFile << "Exception traceback  : " << PYREPR(frame->f_exc_traceback) << std::endl;
	dumpFile << "Trace function       : " << PYREPR(frame->f_trace) << std::endl;
	dumpFile << "Builtins             : " << PYSIZE(frame->f_builtins) << std::endl;
	dumpFile << "Globals              : " << PYSIZE(frame->f_globals) << std::endl;
	dumpFile << "Locals               : " << PYSIZE(frame->f_locals) << std::endl;
	dumpFile << "Code                 : " << PYCREPR(frame->f_code) << std::endl;

	// Close the frame state dump, no more to add
	dumpFile.flush();
	dumpFile.close();
}
Beispiel #5
0
//=============================================================================
// METHOD:    SPELLasRun::writePrompt
//=============================================================================
void SPELLasRun::writePrompt( const std::string& stack, const SPELLpromptDefinition& def )
{
    std::string message = def.message;
    SPELLutils::replace( message, "\n", "%C%");
    SPELLutils::replace( message, "\t", "%T%");
    toAsRun( STR("PROMPT") + "\t\t" + stack + "\t" + message + "\t" + ISTR(def.scope), true);

    toAsRun( STR("PROMPT_TYPE") + "\t" + ISTR(def.typecode), false);

    switch(def.typecode)
    {
    case LanguageConstants::PROMPT_OK:
        toAsRun( STR("PROMPT_OPTIONS") + "\tOk", false );
        toAsRun( STR("PROMPT_EXPECTED") + "\tO", false);
        break;
    case LanguageConstants::PROMPT_CANCEL:
        toAsRun( STR("PROMPT_OPTIONS") + "\tCancel", false );
        toAsRun( STR("PROMPT_EXPECTED") + "\tC", false);
        break;
    case LanguageConstants::PROMPT_OK_CANCEL:
        toAsRun( STR("PROMPT_OPTIONS") + "\tOk,,Cancel", false );
        toAsRun( STR("PROMPT_EXPECTED") + "\tO,,C", false);
        break;
    case LanguageConstants::PROMPT_YES:
        toAsRun( STR("PROMPT_OPTIONS") + "\tYes", false );
        toAsRun( STR("PROMPT_EXPECTED") + "\tY", false);
        break;
    case LanguageConstants::PROMPT_NO:
        toAsRun( STR("PROMPT_OPTIONS") + "\tNo", false );
        toAsRun( STR("PROMPT_EXPECTED") + "\tN", false);
        break;
    case LanguageConstants::PROMPT_YES_NO:
        toAsRun( STR("PROMPT_OPTIONS") + "\tYes,,No", false );
        toAsRun( STR("PROMPT_EXPECTED") + "\tY,,N", false);
        break;
    default:
        if ((def.typecode & LanguageConstants::PROMPT_LIST)>0)
        {
        	std::vector<std::string>::const_iterator it;

        	std::string options = "";
        	for( it = def.options.begin(); it != def.options.end(); it++)
        	{
        		if (!options.empty()) options += ",,";
        		options += *it;
        	}
            toAsRun( STR("PROMPT_OPTIONS") + "\t" + options, false);

        	std::string expected = "";
        	for( it = def.expected.begin(); it != def.expected.end(); it++)
        	{
        		if (!expected.empty()) expected += ",,";
        		expected += *it;
        	}
            toAsRun( STR("PROMPT_EXPECTED") + "\t" + expected, false);
        }
    	break;
    }
}
Beispiel #6
0
//=============================================================================
// CONSTRUCTOR: SPELLclientNotifier::SPELLclientNotifier()
//=============================================================================
SPELLclientNotifier::SPELLclientNotifier( SPELLclient* client, SPELLexecutor* exec )
: SPELLexecutorListener(),
  SPELLthread("notifier-" + ISTR(client->getClientKey()) + "-" + exec->getModel().getInstanceId()),
  m_client(client),
  m_exec(exec),
  m_requests(300)
{
	m_id = "notifier-" + ISTR(client->getClientKey()) + "-" + exec->getModel().getInstanceId();
	LOG_INFO("[NOTIF] Created notifier");
	m_exec->registerNotifier( m_id, this );
	m_currentRequest = VOID_MESSAGE;
}
Beispiel #7
0
//=============================================================================
// METHOD: SPELLutils::timestampUsec
//=============================================================================
std::string SPELLutils::timestampUsec()
{
	const std::string complete("000000");
	SPELLtimeDesc time = getSystemTime();
    std::string sec  = ISTR(time.seconds);
    std::string usec = ISTR(time.useconds);
    if (usec.length()<6)
    {
    	usec += complete.substr(0,6-usec.length());
    }
    return (sec + usec);
}
Beispiel #8
0
//=============================================================================
// METHOD: SPELLserverCif::getTimestampUsec
//=============================================================================
std::string SPELLserverCif::getTimestampUsec()
{
    const std::string complete("000000");
    struct timespec abstime;
    clock_gettime(CLOCK_REALTIME, &abstime);
    std::string sec  = ISTR(abstime.tv_sec);
    std::string usec = ISTR(abstime.tv_nsec/1000);
    if (usec.length()<6)
    {
        usec += complete.substr(0,6-usec.length());
    }
    return (sec + usec);
}
//=============================================================================
// CONSTRUCTOR: SPELLlistenerContext::SPELLlistenerContext
//=============================================================================
SPELLlistenerContext::SPELLlistenerContext(const std::string& configFile)
{
    SPELLcontextConfig* ctxConfig;
    SPELLdriverConfig* drvConfig;
    ContextInfo ctxInfo;
    std::vector<std::string> ctxList;

    m_gui = NULL;
    m_peer = NULL;

    m_configFile = configFile;
    m_port = STRI(SPELLconfiguration::instance().getListenerParameter("ContextListenerPort"));
    m_contextStartupCmd = SPELLconfiguration::instance().getListenerParameter("ContextScript");

    ctxList = SPELLconfiguration::instance().getAvailableContexts();

    for(std::vector<std::string>::iterator it = ctxList.begin() ;
        it != ctxList.end() ;
        it++)
    {
		DEBUG("Loading context information for " + *it);

		ctxInfo.m_key = 0;
		ctxInfo.m_name = *it;
		ctxInfo.m_port = 0;
		ctxInfo.m_status = MessageValue::DATA_CTX_AVAILABLE;

		try
		{
			ctxConfig = &SPELLconfiguration::instance().getContext(ctxInfo.m_name);
			drvConfig = &SPELLconfiguration::instance().getDriver(ctxConfig->getDriverName());
			ctxInfo.m_ctxConfig = ctxConfig;
			ctxInfo.m_drvConfig = drvConfig;
		}
		catch(SPELLcoreException& ex)
		{
			LOG_ERROR("Failed to read context configuration");
			ctxInfo.m_ctxConfig = NULL;
			ctxInfo.m_drvConfig = NULL;
		}

		m_openContexts[ctxInfo.m_name] = ctxInfo;

		DEBUG("Added context:");
		DEBUG("- Name=" + ctxInfo.m_name);
		DEBUG("- Key=" + ISTR(ctxInfo.m_key));
		DEBUG("- Port=" + ISTR(ctxInfo.m_port));
		DEBUG("- Status=" + ctxInfo.m_status);
    }
}
Beispiel #10
0
//=============================================================================
// METHOD:    SPELLasRun::writeAnswer
//=============================================================================
void SPELLasRun::writeAnswer( const std::string& stack, const std::string& msg, unsigned int scope )
{
    std::string message = msg;
    SPELLutils::replace( message, "\n", "%C%");
    SPELLutils::replace( message, "\t", "%T%");
    toAsRun( STR("ANSWER") + "\t\t" + stack + "\t" + message + "\t" + ISTR(scope), true);
}
Beispiel #11
0
//=============================================================================
// METHOD:    SPELLasRun::writeError
//=============================================================================
void SPELLasRun::writeError( const std::string& stack, const std::string& msg, unsigned int scope )
{
    std::string message = msg;
    SPELLutils::replace( message, "\n", "%C%");
    SPELLutils::replace( message, "\t", "%T%");
    toAsRun( STR("DISPLAY") + "\tERROR\t" + stack + "\t" + message + "\t" + ISTR(scope), true);
}
Beispiel #12
0
//=============================================================================
// METHOD:    SPELLasRun::toAsRun()
//=============================================================================
void SPELLasRun::toAsRun( const std::string& info, bool increaseSequence )
{
    std::string line = SPELLutils::timestamp() + "\t" + ISTR(m_sequence) + "\t" + info;
    m_file << line << std::endl;
    m_file.flush();
    if (increaseSequence) m_sequence++;
}
Beispiel #13
0
//=============================================================================
// METHOD: SPELLserverCif::error
//=============================================================================
void SPELLserverCif::error( const std::string& msg, unsigned int scope )
{
    if ( getVerbosity() > getVerbosityFilter() ) return;

    DEBUG("[CIF] Error message: " + msg);

    // We shall not bufferize in manual mode
    if (isManual())
    {
        completeMessage( &m_wrMessage );
        std::string timeStr = getTimestampUsec();
        m_wrMessage.set(MessageField::FIELD_TEXT,msg);
        m_wrMessage.set(MessageField::FIELD_LEVEL,MessageValue::DATA_SEVERITY_ERROR);
        m_wrMessage.set(MessageField::FIELD_MSGTYPE,LanguageConstants::DISPLAY);
        m_wrMessage.set(MessageField::FIELD_TIME, timeStr);
        m_wrMessage.set(MessageField::FIELD_SCOPE, ISTR(scope));
        sendGUIMessage(&m_wrMessage);
    }
    else
    {
        m_buffer->error( msg, scope );
    }

    m_asRun->writeError( getStack(), msg, scope );
}
Beispiel #14
0
static void
combiner_intr(void *arg)
{
	struct combiner_softc *sc;
	void (*ih) (void *);
	void *ih_user;
	int enabled;
	int intrs;
	int shift;
	int cirq;
	int grp;
	int i,n;

	sc = arg;

	intrs = READ4(sc, CIPSR);
	for (grp = 0; grp < 32; grp++) {
		if (intrs & (1 << grp)) {
			n = (grp / 4);
			shift = (grp % 4) * 8;

			cirq = READ4(sc, ISTR(n));
			for (i = 0; i < 8; i++) {
				if (cirq & (1 << (i + shift))) {
					ih = intr_map[grp][i].ih;
					ih_user = intr_map[grp][i].ih_user;
					enabled = intr_map[grp][i].enabled;
					if (enabled && (ih != NULL)) {
						ih(ih_user);
					}
				}
			}
		}
	}
}
//=============================================================================
// METHOD: SPELLipcMessageMailbox::retrieve
//=============================================================================
SPELLipcMessage SPELLipcMessageMailbox::retrieve( std::string id, unsigned long timeoutMsec )
{
    DEBUG(NAME + "Retrieve response with id " + id)
    SPELLipcMessageQueue* queue = getQueue(id);

    SPELLipcMessage msg = VOID_MESSAGE;
    try
    {
    	if (timeoutMsec == 0)
    	{
    		msg = queue->pull();
    	}
    	else
    	{
    		msg = queue->pull(timeoutMsec);
    	}
        remove(id);
    }
    catch( SPELLqueueTimeout& timeout )
    {
        //remove(id);
        // Re-throw the exception
        throw SPELLipcError(NAME + "Response timed out (limit " + ISTR(timeoutMsec) + " msec.)", (SPELLerrorCode) IPC_ERROR_TIMEOUT_ECODE);
    }
    DEBUG(NAME + "Retrieve message with id " + id + " done: " + msg.getSequenceStr());
    return msg;
}
Beispiel #16
0
//=============================================================================
// METHOD    : SPELLbreakpoint::removeBreakpoint()
//=============================================================================
void SPELLbreakpoint::removeBreakpoint( const std::string& file, unsigned int line )
{
	/*
     * REMOVE FROM PERMANENT BREAKPOINTS
     */
	BreakpointMap::iterator it = m_breakpoints.find(file);
	if ( it != m_breakpoints.end())
	{
		// Find the line number and remove it
		BreakpointList::iterator lit;
		for( lit = it->second.begin(); lit != it->second.end(); lit++)
		{
			if (*lit == line)
			{
				DEBUG("[BP] Remove breakpoint at " + file + ":" + ISTR(line) );
				it->second.erase(lit);
				return;
			}
		}
	}
	/*
     * TEMPORARY BREAKPOINTS ARE NOT REMOVED, AS THEY WILL BE REMOVED ONCE
     * THEY ARE REACHED
     */
}
Beispiel #17
0
//=============================================================================
// METHOD    : SPELLbreakpoint::addBreakpoint()
//=============================================================================
void SPELLbreakpoint::addBreakpoint( const std::string& file,
                                     unsigned int line,
                                     const SPELLbreakpointType type )
{
	// Even if the file entry does not exist yet, it will create it and add the line
	if (type == TEMPORARY)
 	{
		DEBUG("[BP] Set temporary breakpoint at " + file + ":" + ISTR(line) );
		m_tempBreakpoints[file].push_back(line);
    }
    else if (type == PERMANENT)
	{
		DEBUG("[BP] Set permanent breakpoint at " + file + ":" + ISTR(line) );
		m_breakpoints[file].push_back(line);
	}
}
Beispiel #18
0
//============================================================================
// FUNCTION:    SPELLutils::dumpThreadStateInfo()
//============================================================================
void SPELLutils::dumpThreadStateInfo( const std::string& id, PyThreadState* ts, int iStateId, int TStateId  )
{
	LOG_INFO("Dump information for thread state " + ISTR(iStateId) + "." + ISTR(TStateId));
	std::string dataDir = getSPELL_DATA() + PATH_SEPARATOR + "Runtime" + PATH_SEPARATOR;
	std::string filename = dataDir + id + "_thread_state_" + ISTR(iStateId) + "." + ISTR(TStateId) + ".dump";
	std::ofstream dumpFile;
	dumpFile.open( filename.c_str() , std::ios::out );

	dumpFile << "THREAD STATE " << TStateId << " DATA" << std::endl;
	dumpFile << "--------------------------------------" << std::endl;
	dumpFile << "Address           : " << PSTR(ts) << std::endl;
	dumpFile << "Next address      : " << PSTR(ts->next) << std::endl;
	dumpFile << "IState address    : " << PSTR(ts->interp) << std::endl;
	dumpFile << "Recursion depth   : " << ts->recursion_depth << std::endl;
	dumpFile << "Tracing flag      : " << ts->tracing << std::endl;
	dumpFile << "Use tracing flg   : " << ts->use_tracing << std::endl;
	dumpFile << "Profile function  : " << ts->c_profilefunc << std::endl;
	dumpFile << "Trace function    : " << ts->c_tracefunc << std::endl;
	dumpFile << "Profile object    : " << PYREPR(ts->c_profileobj) << std::endl;
	dumpFile << "Trace object      : " << PYREPR(ts->c_traceobj) << std::endl;
	dumpFile << "Current exc. type : " << PYREPR(ts->curexc_type) << std::endl;
	dumpFile << "Current exc. value: " << PYREPR(ts->curexc_value) << std::endl;
	dumpFile << "Current exc. tback: " << PYREPR(ts->curexc_traceback) << std::endl;
	dumpFile << "Exception type    : " << PYREPR(ts->exc_type) << std::endl;
	dumpFile << "Exception value   : " << PYREPR(ts->exc_value) << std::endl;
	dumpFile << "Exception tback   : " << PYREPR(ts->exc_traceback) << std::endl;
	dumpFile << "Main dict         : " << PYSIZE(ts->dict) << " items." << std::endl;
	dumpFile << "Tick counter      : " << ts->tick_counter << std::endl;
	dumpFile << "GIL state counter : " << ts->gilstate_counter << std::endl;
	dumpFile << "Async. exception  : " << PYREPR(ts->async_exc) << std::endl;
	dumpFile << "Thread id         : " << ts->thread_id << std::endl;

	// Count frames
	int numFR = 0;
	PyFrameObject* currFR = ts->frame;
	while( currFR != NULL )
	{
		dumpFrameInfo( id, currFR, iStateId, TStateId, numFR );
		numFR++;
		currFR = currFR->f_back;
	}
	dumpFile << "Number of frames  : " << numFR << std::endl;

	// Close the thread state dump, no more to add
	dumpFile.flush();
	dumpFile.close();
}
//=============================================================================
// METHOD    : SPELLwsWarmStartImpl::saveState()
//=============================================================================
void SPELLwsWarmStartImpl::saveState()
{
	DEBUG("[WS] Saving state ============================================");

	std::cerr << "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" << std::endl;
	std::cerr << "SAVE STATE START" << std::endl;
	std::cerr << "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" << std::endl;

	// Synchronize so that nothing can be done while saving
	SPELLmonitor m(m_lock);

	SPELLsafePythonOperations ops("SPELLwsWarmstartImpl::saveState()");

	//TODO check, possibly there are several states that need to be saved
	PyThreadState* state = m_topFrame->getFrameObject()->f_tstate;
	DEBUG("Current thread state: " + PSTR(state));

	assert(state != NULL);
	// Reset the storage. Remove this if we want the full history, but
	// the load algorith would need to be modified.
	m_storage->reset();
	DEBUG("    - Recursion depth : " + ISTR(state->recursion_depth));
	m_storage->storeLong( state->recursion_depth );
	DEBUG("    - Tick counter    : " + ISTR(state->tick_counter));
	m_storage->storeLong( state->tick_counter );
	DEBUG("    - GIL counter     : " + ISTR(state->gilstate_counter));
	m_storage->storeLong( state->gilstate_counter );
	DEBUG("    - Number of frames: " + ISTR(m_frames.size()));
	m_storage->storeLong( m_frames.size() );

	DEBUG("[WS] Saving frames");
	unsigned int frameCount = m_frames.size();
	for( unsigned int index = 0; index < frameCount; index++)
	{
		std::string id = m_frames[index]->getCodeId();
		DEBUG("   - Saving frame '" + id + "'");
		m_storage->storeObject(SSTRPY(id));
		m_frames[index]->saveState();
	}

	std::cerr << "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" << std::endl;
	std::cerr << "SAVE STATE END" << std::endl;
	std::cerr << "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" << std::endl;

	DEBUG("[WS] Saving state done =======================================");
}
Beispiel #20
0
//=============================================================================
// METHOD: SPELLserverCif::completeMessage
//=============================================================================
void SPELLserverCif::completeMessage( SPELLipcMessage* msg )
{
    msg->set(MessageField::FIELD_TIME, timestamp() );
    msg->set(MessageField::FIELD_MSG_SEQUENCE, ISTR(m_sequence));
    m_sequence++;

    msg->set(MessageField::FIELD_CSP, getStack() + "/" + ISTR(getNumExecutions()) );

    if (isManual())
    {
        msg->set(MessageField::FIELD_EXECUTION_MODE, MessageValue::DATA_EXEC_MODE_MANUAL);
    }
    else
    {
        msg->set(MessageField::FIELD_EXECUTION_MODE, MessageValue::DATA_EXEC_MODE_PROCEDURE);
    }
}
Beispiel #21
0
//=============================================================================
// METHOD    : SPELLcallstack::event_call
//=============================================================================
void SPELLcallstack::event_call( const std::string& file, const int& line, const std::string& name )
{
	// Call to a function, increase the stack
	DEBUG("[CSTACK] Event call: " + file + ":" + ISTR(line) + ", mode=" + ISTR(m_soMode) + ", so=" + BSTR(isSteppingOver()));

	// Consider first the first call in the execution: create the roots
	if (m_rootNode == NULL)
	{
		DEBUG("[CSTACK] First call" );
		m_rootNode = new SPELLcodeTreeNode(0,file,line,NULL);
		m_currentNode = m_rootNode;
		m_viewNode = m_rootNode;

	    // Visit the line
		SPELLexecutor::instance().getFrame().getTraceModel(file).setCurrentLine(line);
	}
	else // If we are in this case, there is a subprocedure being called
	{
		assert(m_currentNode != NULL);

		DEBUG("[CSTACK] Function call" );
		// ...and ensure the next line will be marked by default
		m_markExecuted = true;
		// Will add the child code corresponding to the call

		DEBUG("[CSTACK] Doing call on node " + m_currentNode->getCodeIdentifier() + ", depth " + ISTR(m_currentNode->getDepth()) );
		m_currentNode->eventCall(file,line);
		// Now update which the current node is
		m_currentNode = m_currentNode->getCurrentLine()->getChildCode();
		// If we are stepping over, do not change the view node position
		// otherwise move the view node together with the leaf
		if ( m_soMode >= SO_ONCE_INTO )
		{
			DEBUG("[CSTACK] Increasing level: " + ISTR(m_soMode) );
			m_viewNode = m_currentNode;
		}
	}
    // Update the stack string
    m_stack = std::string(file + ":" + ISTR(line));
    // Update the code name string
    m_codeName = name;

	DEBUG("[CSTACK] Event call notify: " + getStack() + ", mode=" + ISTR(m_soMode) + ", so=" + BSTR(isSteppingOver()));
	SPELLexecutor::instance().getCIF().notifyCall();
}
Beispiel #22
0
//=============================================================================
// METHOD: SPELLclientIPC::
//=============================================================================
void SPELLclientIPC::unregisterInterest( int clientKey, SPELLclientListener* listener )
{
	LOG_INFO("Unregister interest on client " + ISTR(clientKey));
	SPELLclientInterestList* list = getClientInterestList(clientKey);
	if (list != NULL)
	{
		list->removeClientListener();
	}
}
//=============================================================================
// METHOD: SPELLclientManager::clientLogin
//=============================================================================
void SPELLclientManager::clientLogin( int clientKey, const std::string& host )
{
	SPELLmonitor m(m_clientLock);
	ClientMap::iterator it = m_clientMap.find(clientKey);
	if (it == m_clientMap.end())
	{
		SPELLclient* client = new SPELLclient( clientKey, host, *m_ipc );

		m_clientMap.insert( std::make_pair( clientKey, client ));
		DEBUG("[CMGR] Client logged in: " + ISTR(clientKey));

		notifyClientOperation( clientKey, host, CLIENT_OP_LOGIN );
	}
	else
	{
		LOG_ERROR("Client " + ISTR(clientKey) + " already exists!");
	}
}
//=============================================================================
// METHOD: SPELLclientManager::clientLogout
//=============================================================================
void SPELLclientManager::clientLogout( int clientKey )
{
	SPELLmonitor m(m_clientLock);
	ClientMap::iterator it = m_clientMap.find(clientKey);
	if (it != m_clientMap.end())
	{
		SPELLclient* client = it->second;
		std::string host = client->getClientHost();
		LOG_INFO("Client logged out: " + ISTR(clientKey) + ":" + host);
		delete client;
		m_clientMap.erase(it);
		notifyClientOperation( clientKey, host, CLIENT_OP_LOGOUT );
	}
	else
	{
		LOG_ERROR("Client " + ISTR(clientKey) + " does not exist!");
	}
}
Beispiel #25
0
//=============================================================================
// METHOD    : SPELLwsWarmStartImpl::fixState()
//=============================================================================
PyFrameObject* SPELLwsWarmStartImpl::fixState()
{
	DEBUG("[WS] Fixing state ==============================================");

	// Synchronize so that nothing can be done while saving
	SPELLmonitor m(m_lock);

	// Get the head interpreter state
	PyInterpreterState* istate = PyInterpreterState_Head();

	// Get the current thread state
	PyThreadState* oldState = PyThreadState_GET();
	DEBUG("[WS] Old state: " + PSTR(oldState));
	DEBUG("[WS] Interpreter head: " + PSTR(istate->tstate_head));
	DEBUG("[WS] Interpreter next: " + PSTR(istate->next));
	DEBUG("[WS] State recursion depth: " + ISTR(oldState->recursion_depth));
	DEBUG("[WS] State next: " + PSTR(oldState->next));

	// Create a fresh thread state
	PyThreadState* newState = PyThreadState_New(istate);
	istate->tstate_head = newState;

	newState->recursion_depth = oldState->recursion_depth;
	newState->tracing = oldState->tracing;
	newState->use_tracing = oldState->use_tracing;
	newState->tick_counter = oldState->tick_counter;
	newState->gilstate_counter = oldState->gilstate_counter;
	newState->dict = PyDict_Copy(oldState->dict);

	FrameList::iterator it;
	unsigned int frameCount = m_frames.size();
	DEBUG("[WS] Total frames to fix " + ISTR(frameCount));
	m_topFrame = NULL;
	for( unsigned int index = 0; index < frameCount; index++)
	{
		bool isHead = (index == (frameCount-1));
		DEBUG("[WS] Fix state on frame index " + ISTR(index) + " frame=" + PYCREPR(m_frames[index]));
		m_topFrame = m_frames[index];
		m_topFrame->fixState(newState, isHead);
	}
	DEBUG("[WS] State fixed ===============================================");
	PyErr_Clear();
	return m_topFrame->getFrameObject();
}
Beispiel #26
0
//=============================================================================
// METHOD: SPELLclientIPC::processConnectionClosed
//=============================================================================
void SPELLclientIPC::processConnectionClosed( int peerKey )
{
	// Avoid duplicated processing
	InterestMap::iterator it = m_interestMap.find(peerKey);
	if (it != m_interestMap.end())
	{
		LOG_INFO( "Client " + ISTR(peerKey) + " removed" );
		destroyClientInterestList(peerKey);
	}
}
Beispiel #27
0
//=============================================================================
// METHOD: SPELLclientIPC::
//=============================================================================
void SPELLclientIPC::registerInterest( int clientKey, SPELLclientListener* listener )
{
	LOG_INFO("Register interest on client " + ISTR(clientKey));
	SPELLclientInterestList* list = getClientInterestList(clientKey);
	if (list == NULL)
	{
		list = createClientInterestList(clientKey);
	}
	list->setClientListener( listener );
}
Beispiel #28
0
//=============================================================================
// METHOD: SPELLipcTrash::cancelAndCleanRequests
//=============================================================================
void SPELLipcTrash::cancelAndCleanRequests( int peerKey )
{
    SPELLmonitor m(m_dataLock);
    DEBUG( NAME + "Cancel all requests from peer " + ISTR(peerKey) );
    SPELLipcTrashList::iterator it;
    for( it = m_messages.begin(); it != m_messages.end(); it++)
    {
    	if (peerKey == (*it)->getKey())
    	{
    		DEBUG("    - cancel request " + (*it)->getProcessingId());
			(*it)->cancel();
    	}
    	else
    	{
    		DEBUG("    - do not cancel " + (*it)->getProcessingId());
    	}
    }
    DEBUG( NAME + "All requests from peer " + ISTR(peerKey) + " cancelled" );
}
Beispiel #29
0
//=============================================================================
// METHOD    : SPELLbreakpoint::checkBreakpoint()
//=============================================================================
bool SPELLbreakpoint::checkBreakpoint( const std::string& file, unsigned int line )
{
	/*
     * PERMANENT BREAKPOINTS LOOKUP
     */
	BreakpointMap::iterator it = m_breakpoints.find(file);
	if ( it != m_breakpoints.end())
	{
		// Find the line number and remove it
		BreakpointList::const_iterator lit;
		for( lit = it->second.begin(); lit != it->second.end(); lit++)
		{
			if (*lit == line)
			{
				DEBUG("[BP] Found permanent breakpoint at " + file + ":" + ISTR(line));
				return true;
			}
		}
	}

    /*
     * TEMPORARY BREAKPOINTS LOOKUP
     */
	it = m_tempBreakpoints.find(file);
	if ( it != m_tempBreakpoints.end())
	{
		// Find the line number and remove it
		BreakpointList::const_iterator lit;
		for( lit = it->second.begin(); lit != it->second.end(); lit++)
		{
			if (*lit == line)
			{
				DEBUG("[BP] Found temporary breakpoint at " + file + ":" + ISTR(line));
				// Delete the temporary breakpoint
				m_tempBreakpoints.erase(it);
				return true;
			}
		}
	}

	return false;
}
//=============================================================================
// METHOD: SPELLlistenerContext::fillContextInfo
//=============================================================================
void SPELLlistenerContext::fillContextInfo(const std::string ctxName, SPELLipcMessage& msg )
{
    std::string driverName;
    SPELLcontextConfig* ctxConfig;
    SPELLdriverConfig* drvConfig;
    ContextInfo* ctxInfo;

	ctxInfo = &m_openContexts[ctxName];
	ctxConfig = ctxInfo->m_ctxConfig;
	drvConfig = ctxInfo->m_drvConfig;

	msg.set(MessageField::FIELD_CTX_NAME, ctxName);
	msg.set( MessageField::FIELD_CTX_PORT, ISTR(ctxInfo->m_port) );

	if (ctxConfig != NULL)
	{
		msg.set(MessageField::FIELD_CTX_DRV, ctxConfig->getDriverName());
		msg.set(MessageField::FIELD_CTX_SC, ctxConfig->getSC());
		msg.set(MessageField::FIELD_CTX_FAM, ctxConfig->getFamily());
		msg.set(MessageField::FIELD_CTX_GCS, ctxConfig->getGCS());
		msg.set(MessageField::FIELD_CTX_DESC, ctxConfig->getDescription());
		msg.set(MessageField::FIELD_CTX_STATUS, ctxInfo->m_status);
	}
	else
	{
		msg.set(MessageField::FIELD_CTX_DRV, "Unknown");
		msg.set(MessageField::FIELD_CTX_SC, "Unknown");
		msg.set(MessageField::FIELD_CTX_FAM, "Unknown");
		msg.set(MessageField::FIELD_CTX_GCS, "Unknown");
		msg.set(MessageField::FIELD_CTX_DESC, "Unknown");
		msg.set(MessageField::FIELD_CTX_STATUS, "ERROR");
	}

	if (drvConfig != NULL)
	{
		msg.set(MessageField::FIELD_CTX_MAXPROC, ISTR(drvConfig->getMaxProcs()));
	}
	else
	{
		msg.set(MessageField::FIELD_CTX_MAXPROC, "0" );
	}
}