예제 #1
0
int CVIFUNC mouth_Error (const char message[], dnaByte abortQ,
						 dnaByte forceErrorQ)
{
	int status,err;
	long count;
	char mouthMessage[80]={0};
#if VERBOSE > 0
	if (forceErrorQ) {
		FmtOut ("%s\n", message);
		Beep();
		Breakpoint();
		ScanIn ("%s", mouthMessage);		// Wait for enter to be pressed
		if (abortQ) abort();
		return -1;
	}		
	status = ThreadIbsta ();
	if (status & ERR) {						// ERR is defined in gpib.h
		err=ThreadIberr();
		count = ThreadIbcntl();
		FmtOut ("%s\n", message);
		FmtOut ("status %d  error %d count %d\n", status,err,count);
		FmtOut ("Library error so Abort always requested.\n");
		FmtOut ("Reminder: Did you turn on the SRS? to GPIB ID #19?\n");
		Beep();
		Breakpoint();
		ScanIn ("%s", mouthMessage);		// Wait for enter to be pressed
		if (abortQ) abort();
		return -1;
	}		
#else
	if (forceErrorQ) {
		Beep();
		MessagePopup ("Mouth Error", message);
		Breakpoint();
		if (abortQ) abort();
		return -1;
	}
	status = ThreadIbsta ();
	if (status & ERR) {
		err=ThreadIberr();
		count = ThreadIbcntl();
		Fmt (mouthMessage, "%s<%s\n", message);
		Fmt (mouthMessage, "%s[a]<status %d  error %d count %d\n", status,err,count);
		if (abortQ)
			Fmt (mouthMessage, "%s[a]<Software Error and Abort has been requested.\n");
		Fmt (mouthMessage, "%s[a]<Reminder: Did you turn on the SRS? to GPIB ID #19?\n");
		Beep();
		MessagePopup ("Mouth Error", mouthMessage);
		Breakpoint();
//		if (abortQ) abort();
		return -1;
	}		

#endif

	return 0;    
}
예제 #2
0
int main(int argc, char **argv)
{
    if (argc != 1 && argc != 4)
    {
        std::cerr << "Must specify three arguments or none\n";
        return 1;
    }

    // When arguments are specified, just generate the
    // debugger scripts.
    //
    if (argc == 4)
    {
        if (std::strcmp(argv[1], "basic") == 0)
        {
            GenerateBasicScripts(argv[2], argv[3]);
        }
        else if (std::strcmp(argv[1], "detach") == 0)
        {
            GenerateDetachScripts(argv[2], argv[3]);
        }
        else if (std::strcmp(argv[1], "step-custom-break") == 0)
        {
            GenerateStepCustomBreakScripts(argv[2], argv[3]);
        }
        else
        {
            std::cerr << "Unknown script name '" << argv[1] << "'\n";
            return 1;
        }
        return 0;
    }

    // When run with no arguments, execute the test code.
    //
    Breakpoint();
    Breakpoint();
    Breakpoint();
    DoRegMemTest();
    DoStepCustomBreakTest();
    std::cout << "Test completed" << std::endl;
    return 0;
}
예제 #3
0
//!	Return an iterator refering to the insertion position for a
//!	Breakpoint at the specified time (that is, the position of the first
//!	Breakpoint at a time later than the specified time).
//	
Partial::iterator 
Partial::findAfter( double time ) 
{
#if defined(USE_VECTOR) 
	//	see note above
	Partial_value_type dummy( time, Breakpoint() );
	return std::upper_bound( _breakpoints.begin(), _breakpoints.end(), dummy, order_by_time );
#else
	return _breakpoints.lower_bound( time );
#endif
}
예제 #4
0
Data DebugSession::debugPause(const Data& data) {
	std::lock_guard<std::recursive_mutex> lock(_mutex);

	_skipTo = Breakpoint();
	stepping(true);

	Data replyData;
	replyData.compound["status"] = Data("success", Data::VERBATIM);

	return replyData;
}
예제 #5
0
void Debugger::toggleBreakpointAt(int4 memPos)
{
	vector<Breakpoint>::iterator bp = findBreakpointAt(memPos);
	if (bp != breakpoints.end())
	{
		breakpoints.erase(bp);
	}
	else
	{
		breakpoints.push_back(Breakpoint(memPos));
	}
}
예제 #6
0
void InspectorDebuggerAgent::setStickyBreakpoint(const String& url, unsigned lineNumber, const String& condition, bool enabled)
{
    HashMap<String, ScriptBreakpoints>::iterator it = m_stickyBreakpoints.find(url);
    if (it == m_stickyBreakpoints.end())
        it = m_stickyBreakpoints.set(url, ScriptBreakpoints()).first;
    it->second.set(lineNumber, Breakpoint(condition, enabled));

    URLToSourceIDsMap::iterator urlToSourceIDsIterator = m_urlToSourceIDs.find(url);
    if (urlToSourceIDsIterator == m_urlToSourceIDs.end())
        return;
    const Vector<String>& sourceIDs = urlToSourceIDsIterator->second;
    for (size_t i = 0; i < sourceIDs.size(); ++i)
        restoreBreakpoint(sourceIDs[i], lineNumber, condition, enabled);
}
예제 #7
0
void DebugSession::checkBreakpoints(const std::list<Breakpoint> qualifiedBreakpoints) {
	std::list<Breakpoint>::const_iterator qualifiedBreakpointIter = qualifiedBreakpoints.begin();

	if (!_breakpointsEnabled)
		return;

	while(qualifiedBreakpointIter != qualifiedBreakpoints.end()) {
		const Breakpoint& qualifiedBreakpoint = *qualifiedBreakpointIter++;

		// check if one of the user-supplied breakpoints match
		bool userBreakpointMatched = false;
		Data replyData;

		if (_skipTo) {
			if (_skipTo.matches(_interpreter, qualifiedBreakpoint)) {
				replyData.compound["breakpoint"] = _skipTo.toData();
				replyData.compound["qualified"] = qualifiedBreakpoint.toData();
				breakExecution(replyData);
				_skipTo = Breakpoint();
			}
			continue;
		}

		std::set<Breakpoint>::const_iterator breakpointIter = _breakPoints.begin();
		while(breakpointIter != _breakPoints.end()) {
			const Breakpoint& breakpoint = *breakpointIter++;
			if (!breakpoint.enabled)
				continue;
			if (breakpoint.matches(_interpreter, qualifiedBreakpoint)) {
				// do we have a condition?

				replyData.compound["breakpoint"] = breakpoint.toData();
				replyData.compound["qualified"] = qualifiedBreakpoint.toData();

				userBreakpointMatched = true;
				breakExecution(replyData);
			}
		}
		if (_isStepping && !userBreakpointMatched) {
			replyData.compound["qualified"] = qualifiedBreakpoint.toData();
			breakExecution(replyData);

		}
	}
}
예제 #8
0
Data DebugSession::skipToBreakPoint(const Data& data) {
	std::lock_guard<std::recursive_mutex> lock(_mutex);

	_skipTo = Breakpoint(data);
	Data replyData;

	if (_interpreter) {
		// register ourself as a monitor
		if (!_isRunning) {
			_isRunning = true;
			_interpreterThread = new std::thread(DebugSession::run, this);
		}

		replyData.compound["status"] = Data("success", Data::VERBATIM);
	} else {
		replyData.compound["status"] = Data("failure", Data::VERBATIM);
	}

	_resumeCond.notify_one();
	return replyData;
}
예제 #9
0
Data DebugSession::debugStop(const Data& data) {
	Data replyData;

	if (_interpreter) {
		// detach from old intepreter
		_debugger->detachSession(_interpreter.getImpl().get());
	}

	if (_isRunning && _interpreterThread != NULL) {
		_isRunning = false;
		_interpreterThread->join();
		delete(_interpreterThread);
	}
	// unblock
	_resumeCond.notify_all();

	_skipTo = Breakpoint();
	replyData.compound["status"] = Data("success", Data::VERBATIM);

	// calls destructor
	_interpreter = Interpreter();

	return replyData;
}
예제 #10
0
static void *Child(void *)
{
    Breakpoint();
    return 0;
}
예제 #11
0
// ---------------------------------------------------------------------------
//	parametersAt
// ---------------------------------------------------------------------------
//!	Return the interpolated parameters of this Partial at
//!	the specified time, same as building a Breakpoint from
//!	the results of frequencyAt, ampitudeAt, bandwidthAt, and
//!	phaseAt, but performs only one Breakpoint envelope search.
//!	Throw an InvalidPartial exception if this Partial has no
//!	Breakpoints. If non-zero fadeTime is specified, then the
//!	amplitude at the ends of the Partial is coomputed using a 
//!	linear fade. The default fadeTime is ShortestSafeFadeTime.
//
Breakpoint
Partial::parametersAt( double time, double fadeTime ) const 
{
	if ( numBreakpoints() == 0 )
	{
		Throw( InvalidPartial, "Tried to interpolate a Partial with no Breakpoints." );
	}
	
	//	findAfter returns the position of the earliest
	//	Breakpoint later than time, or the end
	//	position if no such Breakpoint exists:
	Partial::const_iterator it = findAfter( time );
		
	if ( it == begin() ) 
	{
		//	time is before the onset of the Partial:
		//	frequency is starting frequency, 
		//	amplitude is 0 (or fading), bandwidth is starting 
		//	bandwidth, and phase is rolled back.
		double alpha =  (time < it.time()) ? 0. : 1.;
		if ( fadeTime > 0 )
		{
			//	fade in ampltude if time is before the onset of the Partial:
			alpha = std::max(0., 1. - ((it.time() - time) / fadeTime) );
		}
		double amp = alpha * it.breakpoint().amplitude();

		double dp = 2. * Pi * (it.time() - time) * it.breakpoint().frequency();
		double ph = std::fmod( it.breakpoint().phase() - dp, 2. * Pi);
		
		return Breakpoint( it.breakpoint().frequency(), amp, 
						   it.breakpoint().bandwidth(), ph );
	}
	else if (it == end() ) 
	{
		//	time is past the end of the Partial:
		//	frequency is ending frequency, 
		//	amplitude is 0 (or fading), bandwidth is ending 
		//	bandwidth, and phase is rolled forward.
		--it; 
		
		double alpha =  (time > it.time()) ? 0. : 1.;
		if ( fadeTime > 0 )
		{
			//	fade out ampltude if time is past the end of the Partial:
			alpha = std::max(0., 1. - ((time - it.time()) / fadeTime) );
		}
		double amp = alpha * it.breakpoint().amplitude();

		double dp = 2. * Pi * (time - it.time()) * it.breakpoint().frequency();
		double ph = std::fmod( it.breakpoint().phase() + dp, 2. * Pi );

		return Breakpoint( it.breakpoint().frequency(), amp, 
						   it.breakpoint().bandwidth(), ph );
	}
	else 
	{
	//	interpolate between it and its predeccessor
	//	(we checked already that it is not begin):
		const Breakpoint & hi = it.breakpoint();
		double hitime = it.time();
		const Breakpoint & lo = (--it).breakpoint();
		double lotime = it.time();
		double alpha = (time - lotime) / (hitime - lotime);

		double finterp = ( alpha * hi.frequency() ) + 
						 ( ( 1. - alpha ) * lo.frequency() );

		//	need to keep fmod in here because other stuff 
		//	(Spc export and sdif export, for example) rely 
		//	on it:
		double ph = 0;
		if ( alpha < 0.5 )
		{
			double favg = 0.5 * ( lo.frequency() + finterp );
			double dp = 2. * Pi * (time - lotime) * favg;
			ph = std::fmod( lo.phase() + dp, 2. * Pi );
		}
		else
		{
			double favg = 0.5 * ( hi.frequency() + finterp );
			double dp = 2. * Pi * (hitime - time) * favg;
			ph = std::fmod( hi.phase() - dp, 2. * Pi );
		}

		return Breakpoint( (alpha * hi.frequency()) + ((1. - alpha) * lo.frequency()),
						   (alpha * hi.amplitude()) + ((1. - alpha) * lo.amplitude()),
						   (alpha * hi.bandwidth()) + ((1. - alpha) * lo.bandwidth()),
						   ph );
				
	}
}
예제 #12
0
// ---------------------------------------------------------------------------
//	insert
// ---------------------------------------------------------------------------
//!	Breakpoint insertion: insert a copy of the specified Breakpoint in the
//!	parameter envelope at time (seconds), and return an iterator
//!	refering to the position of the inserted Breakpoint.
//
Partial::iterator 
Partial::insert( double time, const Breakpoint & bp )
{
#if defined(USE_VECTOR) 
	//	see note above
	//	find the position at which to insert the new Breakpoint:
	Partial_value_type dummy( time, Breakpoint() );
	Partial::container_type::iterator insertHere = 
		std::lower_bound( _breakpoints.begin(), _breakpoints.end(), dummy, order_by_time );
		
	//	if the time at insertHere is equal to the insertion time,
	//	simply replace the Breakpoint, otherwise insert:
	if ( insertHere->first == time )
	{
		insertHere->second = bp;
	}
	else
	{
		insertHere = _breakpoints.insert( insertHere, Partial_value_type(time, bp) );
	}
	return insertHere;
#else
    /*
    //  this allows Breakpoints to be inserted arbitrarily
    //  cloase together, which is no good, can cause trouble later:
    
	std::pair< container_type::iterator, bool > result = 
		_breakpoints.insert( container_type::value_type(time, bp) );
	if ( ! result.second )
    {
		result.first->second = bp;
    }
	return result.first;
    */
    
    //  do not insert a Breakpoint closer than 1ns away
    //  from the nearest existing Breakpoint:
    static const double MinTimeDif = 1.0E-9; // 1 ns
    
    //  find the insertion point for this time
    container_type::iterator pos = _breakpoints.lower_bound( time );
    
    //  the time of pos is either equal to or greater
    //  than the insertion time, if this is too close, 
    //  remove the Breakpoint at pos:
    if ( _breakpoints.end() != pos && MinTimeDif > pos->first - time )
    {
        _breakpoints.erase( pos++ );
    }
    //  otherwise, if the preceding position is too clase, 
    //  remove the Breakpoint at that position
    else if ( _breakpoints.begin() != pos && MinTimeDif > time - (--pos)->first )
    {
        _breakpoints.erase( pos++ );
    }

    //  now pos is at most one position away from the insertion point
    //  so insertion can be performed in constant time, and the new
    //  Breakpoint is at least 1ns away from any other Breakpoint:
    pos = _breakpoints.insert( pos, container_type::value_type(time, bp) );

    Assert( pos->first == time );

	return pos;

#endif
}
예제 #13
0
inline Breakpoint* BreakpointTable::add_breakpoint(int32_t location)
{
	assert(!contains(location));
	_breakpoints.insert(std::make_pair(location, Breakpoint()));
	return &(_breakpoints.find(location)->second);
}
예제 #14
0
파일: Dilator.cpp 프로젝트: EQ4/Paraphrasis
// ---------------------------------------------------------------------------
//	dilate
// ---------------------------------------------------------------------------
//!	Replace the Partial envelope with a new envelope having the
//!	same Breakpoints at times computed to align temporal features
//!	in the sorted sequence of initial time points with their 
//!	counterparts the sorted sequence of target time points.
//!
//!	Depending on the specification of initial and target time 
//!	points, the dilated Partial may have Breakpoints at times
//!	less than 0, even if the original Partial did not.
//!
//!	It is possible to have duplicate time points in either sequence.
//!	Duplicate initial time points result in very localized stretching.
//!	Duplicate target time points result in very localized compression.
//!
//!	If all initial time points are greater than 0, then an implicit
//!	time point at 0 is assumed in both initial and target sequences, 
//!	so the onset of a sound can be stretched without explcitly specifying a 
//!	zero point in each vector. (This seems most intuitive, and only looks
//!	like an inconsistency if clients are using negative time points in 
//!	their Dilator, or Partials having Breakpoints before time 0, both 
//!	of which are probably unusual circumstances.)
//!
//!	\param p is the Partial to dilate.
//	
void
Dilator::dilate( Partial & p ) const
{
	debugger << "dilating Partial having " << p.numBreakpoints() 
			 << " Breakpoints" << endl;

	//	sanity check:
	Assert( _initial.size() == _target.size() );
	
	//	don't dilate if there's no time points, or no Breakpoints:
	if ( 0 == _initial.size() ||
	     0 == p.numBreakpoints() )
	{
		return;
    }
    
	//	create the new Partial:
	Partial newp;
	newp.setLabel( p.label() );
	
	//	timepoint index:
	int idx = 0;
	for ( Partial::const_iterator iter = p.begin(); iter != p.end(); ++iter )
	{
		//	find the first initial time point later 
		//	than the currentTime:
		double currentTime = iter.time();
        idx = std::distance( _initial.begin(), 
                             std::lower_bound( _initial.begin(), _initial.end(), currentTime ) );
        Assert( idx == _initial.size() || currentTime <= _initial[idx] );
        
		//	compute a new time for the Breakpoint at pIter:
		double newtime = 0;
		if ( idx == 0 ) 
		{
			//	all time points in _initial are later than 
			//	the currentTime; stretch if no zero time 
			//	point has been specified, otherwise, shift:
			if ( _initial[idx] != 0. )
				newtime = currentTime * _target[idx] / _initial[idx];
			else
				newtime = _target[idx] + (currentTime - _initial[idx]);
		}
		else if ( idx == _initial.size() ) 
		{
			//	all time points in _initial are earlier than 
			//	the currentTime; shift:
			//
			//	note: size is already known to be > 0, so
			//	idx-1 is safe
			newtime = _target[idx-1] + (currentTime - _initial[idx-1]);
		}
		else 
		{
			//	currentTime is between the time points at idx and
			//	idx-1 in _initial; shift and stretch: 
			//
			//	note: size is already known to be > 0, so
			//	idx-1 is safe
			Assert( _initial[idx-1] < _initial[idx] );	//	currentTime can't wind up 
														//	between two equal times
			
			double stretch = (_target[idx]	- _target[idx-1]) / (_initial[idx] - _initial[idx-1]);			
			newtime = _target[idx-1] + ((currentTime - _initial[idx-1]) * stretch);
		}
		
		//	add a Breakpoint at the computed time:
		newp.insert( newtime, iter.breakpoint() );
	}
	
	//	new Breakpoints need to be added to the Partial at times corresponding
	//	to all target time points that are after the first Breakpoint and
	//	before the last, otherwise, Partials may be briefly out of tune with
	//	each other, since our Breakpoints are non-uniformly distributed in time:
	for ( idx = 0; idx < _initial.size(); ++ idx )
	{
		if ( _initial[idx] <= p.startTime() )
        {
			continue;
        }
		else if ( _initial[idx] >= p.endTime() )
        {
			break;
        }
		else
		{
			newp.insert( _target[idx], 
						 Breakpoint( p.frequencyAt(_initial[idx]), p.amplitudeAt(_initial[idx]),
									 p.bandwidthAt(_initial[idx]), p.phaseAt(_initial[idx]) ) );
		}
	}
	
	//	store the new Partial:
	p = newp;
}