From c18366eacff6dedf5d3be4a3435c466def19780d Mon Sep 17 00:00:00 2001 From: Arne Welzel Date: Tue, 21 Mar 2023 21:32:27 +0100 Subject: [PATCH] Desc: Add obj_desc_short() Same as obj_desc() but use the short version and do not include the location information by default. New method instead of bool parameters for readability. --- src/Desc.cc | 11 +++++++++++ src/Desc.h | 5 ++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Desc.cc b/src/Desc.cc index dc022528bf..17ac87d6a8 100644 --- a/src/Desc.cc +++ b/src/Desc.cc @@ -432,4 +432,15 @@ std::string obj_desc(const Obj* o) return std::string(d.Description()); } +std::string obj_desc_short(const Obj* o) + { + static ODesc d; + + d.SetShort(true); + d.Clear(); + o->Describe(&d); + + return std::string(d.Description()); + } + } // namespace zeek diff --git a/src/Desc.h b/src/Desc.h index 9cc86fef20..d33b9bf03f 100644 --- a/src/Desc.h +++ b/src/Desc.h @@ -230,6 +230,9 @@ protected: // 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); +std::string obj_desc(const Obj* o); + +// Same as obj_desc(), but ensure it is short and don't include location info. +std::string obj_desc_short(const Obj* o); } // namespace zeek