convenience function for accessing object descriptions

This commit is contained in:
Vern Paxson 2021-01-10 13:22:23 -08:00
parent c30f787949
commit 63502e655f
2 changed files with 20 additions and 0 deletions

View file

@ -427,4 +427,17 @@ bool ODesc::FindType(const Type* type)
return false;
}
std::string obj_desc(const Obj* o)
{
static ODesc d;
d.Clear();
o->Describe(&d);
d.SP();
o->GetLocationInfo()->Describe(&d);
return std::string(d.Description());
}
} // namespace zeek

View file

@ -210,6 +210,13 @@ protected:
std::set<const Type*> encountered_types;
};
// Returns a string representation of an object's description. Used for
// debugging and error messages. takes a bare pointer rather than an
// IntrusivePtr because the latter is harder to deal with when making
// calls from a debugger like lldb, which is the main use of this function.
class Obj;
extern std::string obj_desc(const Obj* o);
} // namespace zeek
using BroFile [[deprecated("Remove in v4.1. Use zeek::File.")]] = zeek::File;