JDevlieghere updated this revision to Diff 257460.
JDevlieghere added a comment.

Add a comment


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78141/new/

https://reviews.llvm.org/D78141

Files:
  lldb/include/lldb/Utility/ReproducerInstrumentation.h

Index: lldb/include/lldb/Utility/ReproducerInstrumentation.h
===================================================================
--- lldb/include/lldb/Utility/ReproducerInstrumentation.h
+++ lldb/include/lldb/Utility/ReproducerInstrumentation.h
@@ -134,72 +134,37 @@
     _recorder.RecordResult(this, false);                                       \
   }
 
-#define LLDB_RECORD_METHOD(Result, Class, Method, Signature, ...)              \
+#define LLDB_RECORD_(Method, T1, T2, ...)                                      \
   lldb_private::repro::Recorder _recorder(LLVM_PRETTY_FUNCTION,                \
-                                          stringify_args(*this, __VA_ARGS__)); \
+                                          stringify_args(__VA_ARGS__));        \
   if (lldb_private::repro::InstrumentationData _data =                         \
           LLDB_GET_INSTRUMENTATION_DATA()) {                                   \
     _recorder.Record(_data.GetSerializer(), _data.GetRegistry(),               \
-                     &lldb_private::repro::invoke<Result(                      \
-                         Class::*) Signature>::method<(&Class::Method)>::doit, \
-                     this, __VA_ARGS__);                                       \
+                     &lldb_private::repro::invoke<T1>::Method<T2>::doit,       \
+                     __VA_ARGS__);                                             \
   }
 
+#define LLDB_RECORD_METHOD(Result, Class, Method, Signature, ...)              \
+  LLDB_RECORD_(method, Result(Class::*) Signature, (&Class::Method), this,     \
+               __VA_ARGS__)
+
 #define LLDB_RECORD_METHOD_CONST(Result, Class, Method, Signature, ...)        \
-  lldb_private::repro::Recorder _recorder(LLVM_PRETTY_FUNCTION,                \
-                                          stringify_args(*this, __VA_ARGS__)); \
-  if (lldb_private::repro::InstrumentationData _data =                         \
-          LLDB_GET_INSTRUMENTATION_DATA()) {                                   \
-    _recorder.Record(                                                          \
-        _data.GetSerializer(), _data.GetRegistry(),                            \
-        &lldb_private::repro::invoke<Result(                                   \
-            Class::*) Signature const>::method_const<(&Class::Method)>::doit,  \
-        this, __VA_ARGS__);                                                    \
-  }
+  LLDB_RECORD_(method_const, Result(Class::*) Signature const,                 \
+               (&Class::Method), this, __VA_ARGS__)
 
 #define LLDB_RECORD_METHOD_NO_ARGS(Result, Class, Method)                      \
-  lldb_private::repro::Recorder _recorder(LLVM_PRETTY_FUNCTION,                \
-                                          stringify_args(*this));              \
-  if (lldb_private::repro::InstrumentationData _data =                         \
-          LLDB_GET_INSTRUMENTATION_DATA()) {                                   \
-    _recorder.Record(_data.GetSerializer(), _data.GetRegistry(),               \
-                     &lldb_private::repro::invoke<Result (                     \
-                         Class::*)()>::method<(&Class::Method)>::doit,         \
-                     this);                                                    \
-  }
+  LLDB_RECORD_(method, Result (Class::*)(), (&Class::Method), this)
 
 #define LLDB_RECORD_METHOD_CONST_NO_ARGS(Result, Class, Method)                \
-  lldb_private::repro::Recorder _recorder(LLVM_PRETTY_FUNCTION,                \
-                                          stringify_args(*this));              \
-  if (lldb_private::repro::InstrumentationData _data =                         \
-          LLDB_GET_INSTRUMENTATION_DATA()) {                                   \
-    _recorder.Record(                                                          \
-        _data.GetSerializer(), _data.GetRegistry(),                            \
-        &lldb_private::repro::invoke<Result (                                  \
-            Class::*)() const>::method_const<(&Class::Method)>::doit,          \
-        this);                                                                 \
-  }
+  LLDB_RECORD_(method_const, Result (Class::*)() const, (&Class::Method), this)
 
 #define LLDB_RECORD_STATIC_METHOD(Result, Class, Method, Signature, ...)       \
-  lldb_private::repro::Recorder _recorder(LLVM_PRETTY_FUNCTION,                \
-                                          stringify_args(__VA_ARGS__));        \
-  if (lldb_private::repro::InstrumentationData _data =                         \
-          LLDB_GET_INSTRUMENTATION_DATA()) {                                   \
-    _recorder.Record(                                                          \
-        _data.GetSerializer(), _data.GetRegistry(),                            \
-        lldb_private::repro::invoke<Result(*) Signature>::method_static<(      \
-            &Class::Method)>::doit,                                            \
-        __VA_ARGS__);                                                          \
-  }
+  LLDB_RECORD_(method_static, Result(*) Signature, (&Class::Method),           \
+               __VA_ARGS__)
 
 #define LLDB_RECORD_STATIC_METHOD_NO_ARGS(Result, Class, Method)               \
-  lldb_private::repro::Recorder _recorder(LLVM_PRETTY_FUNCTION);               \
-  if (lldb_private::repro::InstrumentationData _data =                         \
-          LLDB_GET_INSTRUMENTATION_DATA()) {                                   \
-    _recorder.Record(_data.GetSerializer(), _data.GetRegistry(),               \
-                     lldb_private::repro::invoke<Result (*)()>::method_static< \
-                         (&Class::Method)>::doit);                             \
-  }
+  LLDB_RECORD_(method_static, Result (*)(), (&Class::Method),                  \
+               lldb_private::repro::EmptyArg())
 
 #define LLDB_RECORD_RESULT(Result) _recorder.RecordResult(Result, true);
 
@@ -712,6 +677,8 @@
   Registry *m_registry;
 };
 
+struct EmptyArg {};
+
 /// RAII object that records function invocations and their return value.
 ///
 /// API calls are only captured when the API boundary is crossed. Once we're in
@@ -777,6 +744,22 @@
     m_result_recorded = true;
   }
 
+  /// Specializations for the no-argument methods. These are passed an empty
+  /// dummy argument so the same variadic macro can be used. These methods
+  /// strip the arguments before forwarding them.
+  /// {
+  template <typename Result>
+  void Record(Serializer &serializer, Registry &registry, Result (*f)(),
+              const EmptyArg &arg) {
+    Record(serializer, registry, f);
+  }
+
+  void Record(Serializer &serializer, Registry &registry, void (*f)(),
+              const EmptyArg &arg) {
+    Record(serializer, registry, f);
+  }
+  /// }
+
   /// Record the result of a function call.
   template <typename Result>
   Result RecordResult(Result &&r, bool update_boundary) {
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to