Skip to content

Commit

Permalink
[lldb/Reproducers] Skip API logging in the DUMMY macro
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
JDevlieghere committed May 27, 2020
1 parent 07cd19e commit e7f1067
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lldb/include/lldb/Utility/ReproducerInstrumentation.h
Expand Up @@ -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 {
Expand Down Expand Up @@ -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.
Expand Down
9 changes: 9 additions & 0 deletions lldb/source/Utility/ReproducerInstrumentation.cpp
Expand Up @@ -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),
Expand Down

0 comments on commit e7f1067

Please sign in to comment.