[lldb/Reproducers] Skip API logging in the DUMMY macro

The purpose of the LLDB_RECORD_DUMMY macro is twofold: it is used in
functions that take arguments that we don't know how to serialize (e.g.
void*) and it's used by function where we want to avoid doing excessive
work because they can be called from a signal handler (e.g.
setTerminalWidth).

To support the latter case, I've disabled API logging form the Recorder
ctor used by the DUMMY macro. This ensures we don't allocate memory when
called from a signal handler.
This commit is contained in:
Jonas Devlieghere 2020-05-27 10:27:44 -07:00
parent 07cd19efa2
commit e7f1067ad6
2 changed files with 13 additions and 4 deletions

View File

@ -207,11 +207,10 @@ template <typename... Ts> inline std::string stringify_args(const Ts &... ts) {
/// anything. It's used to track API boundaries when we cannot record for
/// technical reasons.
#define LLDB_RECORD_DUMMY(Result, Class, Method, Signature, ...) \
lldb_private::repro::Recorder _recorder(LLVM_PRETTY_FUNCTION, \
stringify_args(__VA_ARGS__));
lldb_private::repro::Recorder _recorder;
#define LLDB_RECORD_DUMMY_NO_ARGS(Result, Class, Method) \
lldb_private::repro::Recorder _recorder(LLVM_PRETTY_FUNCTION);
lldb_private::repro::Recorder _recorder;
namespace lldb_private {
namespace repro {
@ -727,7 +726,8 @@ struct EmptyArg {};
/// this class is also used for logging.
class Recorder {
public:
Recorder(llvm::StringRef pretty_func = {}, std::string &&pretty_args = {});
Recorder();
Recorder(llvm::StringRef pretty_func, std::string &&pretty_args = {});
~Recorder();
/// Records a single function call.

View File

@ -179,6 +179,15 @@ unsigned ObjectToIndex::GetIndexForObjectImpl(const void *object) {
return m_mapping[object];
}
Recorder::Recorder()
: m_serializer(nullptr), m_pretty_func(), m_pretty_args(),
m_local_boundary(false), m_result_recorded(true) {
if (!g_global_boundary) {
g_global_boundary = true;
m_local_boundary = true;
}
}
Recorder::Recorder(llvm::StringRef pretty_func, std::string &&pretty_args)
: m_serializer(nullptr), m_pretty_func(pretty_func),
m_pretty_args(pretty_args), m_local_boundary(false),