Spelling mistakes in TraceConnect are not handled
When connecting to a trace source, a spelling error in the name does not end in a simulation error or warning, but the simulation runs without hooking anything.
Example:
Ptr<SomeObject> a = ....;
a->TraceConnectWithoutContext ("Txx", MakeCallback(&SomeTraceSink)); // The real trace source name is 'Tx'
The code for TraceConnectWithoutContext is:
bool
ObjectBase::TraceConnectWithoutContext(std::string name, const CallbackBase& cb)
{
NS_LOG_FUNCTION(this << name << &cb);
TypeId tid = GetInstanceTypeId();
Ptr<const TraceSourceAccessor> accessor = tid.LookupTraceSourceByName(name);
if (!accessor)
{
return false;
}
bool ok = accessor->ConnectWithoutContext(this, cb);
return ok;
}
If we enter in the if, we return false, but if that's a real mistake, then it would be more safe to abort the simulation with a meaningful error message.
Edited by Tom Henderson