[Lldb-commits] [lldb] e7f1067 - [lldb/Reproducers] Skip API logging in the DUMMY macro

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Wed May 27 10:35:50 PDT 2020


Author: Jonas Devlieghere
Date: 2020-05-27T10:35:43-07:00
New Revision: e7f1067ad6f116ff1e4bfc0f7fe1977f172b0ea0

URL: https://github.com/llvm/llvm-project/commit/e7f1067ad6f116ff1e4bfc0f7fe1977f172b0ea0
DIFF: https://github.com/llvm/llvm-project/commit/e7f1067ad6f116ff1e4bfc0f7fe1977f172b0ea0.diff

LOG: [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.

Added: 
    

Modified: 
    lldb/include/lldb/Utility/ReproducerInstrumentation.h
    lldb/source/Utility/ReproducerInstrumentation.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Utility/ReproducerInstrumentation.h b/lldb/include/lldb/Utility/ReproducerInstrumentation.h
index 346eac52501a..f06b8c038818 100644
--- a/lldb/include/lldb/Utility/ReproducerInstrumentation.h
+++ b/lldb/include/lldb/Utility/ReproducerInstrumentation.h
@@ -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.

diff  --git a/lldb/source/Utility/ReproducerInstrumentation.cpp b/lldb/source/Utility/ReproducerInstrumentation.cpp
index 46bf6b76e1d2..09aea69d8313 100644
--- a/lldb/source/Utility/ReproducerInstrumentation.cpp
+++ b/lldb/source/Utility/ReproducerInstrumentation.cpp
@@ -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),


        


More information about the lldb-commits mailing list