Allow signposts to take advantage of deferred string substitution
authorAdrian Prantl <aprantl@apple.com>
Fri, 11 Jun 2021 22:18:25 +0000 (15:18 -0700)
committerAdrian Prantl <aprantl@apple.com>
Mon, 14 Jun 2021 23:53:41 +0000 (16:53 -0700)
commit035217ff515b8ecdc871e39fa840f3cba1b9cec7
tree8068a0d11bc07c31a96f4891b1b65278ac31f86a
parent1c096bf09ffd3d51665b60942d6bde19e7dbbd5a
Allow signposts to take advantage of deferred string substitution

One nice feature of the os_signpost API is that format string
substitutions happen in the consumer, not the logging
application. LLVM's current Signpost class doesn't take advantage of
this though and instead always uses a static "Begin/End %s" format
string.

This patch uses variadic macros to allow the API to be used as
intended. Unfortunately, the primary use-case I had in mind (the
LLDB_SCOPED_TIMER() macro) does not get much better from this, because
__PRETTY_FUNCTION__ is *not* a macro, but a static string, so
signposts created by LLDB_SCOPED_TIMER() still use a static "%s"
format string. At least LLDB_SCOPED_TIMERF() works as intended.

This reapplies the previously reverted patch with additional include
order fixes for non-modular builds of LLDB.

Differential Revision: https://reviews.llvm.org/D103575
lldb/include/lldb/Utility/Timer.h
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
lldb/source/Utility/Timer.cpp
llvm/include/llvm/Support/Signposts.h
llvm/lib/Support/Signposts.cpp
llvm/lib/Support/Timer.cpp