@@ -84,21 +84,20 @@ template <typename... Ts> inline std::string stringify_args(const Ts &... ts) {
84
84
#Result, #Class, #Method, #Signature)
85
85
86
86
#define LLDB_REGISTER_METHOD_CONST (Result, Class, Method, Signature ) \
87
- R.Register(&invoke<Result(Class::*) Signature const >::method_const<( \
88
- &Class::Method)>::doit, \
87
+ R.Register(&invoke<Result(Class::*) \
88
+ Signature const >::method<( &Class::Method)>::doit, \
89
89
#Result, #Class, #Method, #Signature)
90
90
91
91
#define LLDB_REGISTER_STATIC_METHOD (Result, Class, Method, Signature ) \
92
- R.Register( \
93
- &invoke<Result(*) Signature>::method_static<(&Class::Method)>::doit, \
94
- #Result, #Class, #Method, #Signature)
92
+ R.Register(&invoke<Result(*) Signature>::method<(&Class::Method)>::doit, \
93
+ #Result, #Class, #Method, #Signature)
95
94
96
95
#define LLDB_REGISTER_CHAR_PTR_REDIRECT_STATIC (Result, Class, Method ) \
97
- R.Register(&invoke<Result (*)( char *, size_t )>::method_static<( \
98
- &Class::Method)>::doit, \
99
- &char_ptr_redirect<Result (*)(char *, size_t )>::method_static<( \
100
- &Class::Method)>::doit, \
101
- #Result, #Class, #Method, " (char*, size_t" );
96
+ R.Register( \
97
+ &invoke<Result (*)( char *, size_t )>::method<( &Class::Method)>::doit, \
98
+ &char_ptr_redirect<Result (*)(char *, \
99
+ size_t )>::method<(&Class::Method)>::doit, \
100
+ #Result, #Class, #Method, " (char*, size_t" );
102
101
103
102
#define LLDB_REGISTER_CHAR_PTR_REDIRECT (Result, Class, Method ) \
104
103
R.Register(&invoke<Result (Class::*)(char *, size_t )>::method<( \
@@ -109,97 +108,55 @@ template <typename... Ts> inline std::string stringify_args(const Ts &... ts) {
109
108
110
109
#define LLDB_REGISTER_CHAR_PTR_REDIRECT_CONST (Result, Class, Method ) \
111
110
R.Register(&invoke<Result (Class::*)(char *, size_t ) \
112
- const >::method_const <(&Class::Method)>::doit, \
113
- &char_ptr_redirect<Result (Class::*)( \
114
- char *, size_t ) const >::method_const <(&Class::Method)>::doit, \
111
+ const >::method <(&Class::Method)>::doit, \
112
+ &char_ptr_redirect<Result (Class::*)(char *, size_t ) \
113
+ const >::method <(&Class::Method)>::doit, \
115
114
#Result, #Class, #Method, " (char*, size_t" );
116
115
117
- #define LLDB_RECORD_CONSTRUCTOR (Class, Signature, ...) \
116
+ #define LLDB_CONSTRUCT_ (T, ...) \
118
117
lldb_private::repro::Recorder _recorder (LLVM_PRETTY_FUNCTION, \
119
118
stringify_args (__VA_ARGS__)); \
120
119
if (lldb_private::repro::InstrumentationData _data = \
121
120
LLDB_GET_INSTRUMENTATION_DATA ()) { \
122
121
_recorder.Record (_data.GetSerializer (), _data.GetRegistry (), \
123
- &lldb_private::repro::construct<Class Signature>::doit, \
124
- __VA_ARGS__); \
122
+ &lldb_private::repro::construct<T>::doit, __VA_ARGS__); \
125
123
_recorder.RecordResult (this , false ); \
126
124
}
127
125
126
+ #define LLDB_RECORD_CONSTRUCTOR (Class, Signature, ...) \
127
+ LLDB_CONSTRUCT_ (Class Signature, __VA_ARGS__)
128
+
128
129
#define LLDB_RECORD_CONSTRUCTOR_NO_ARGS (Class ) \
129
- lldb_private::repro::Recorder _recorder (LLVM_PRETTY_FUNCTION); \
130
- if (lldb_private::repro::InstrumentationData _data = \
131
- LLDB_GET_INSTRUMENTATION_DATA ()) { \
132
- _recorder.Record (_data.GetSerializer (), _data.GetRegistry (), \
133
- &lldb_private::repro::construct<Class ()>::doit); \
134
- _recorder.RecordResult (this , false ); \
135
- }
130
+ LLDB_CONSTRUCT_ (Class(), lldb_private::repro::EmptyArg())
136
131
137
- #define LLDB_RECORD_METHOD (Result, Class, Method, Signature, ...) \
132
+ #define LLDB_RECORD_ (T1, T2, ...) \
138
133
lldb_private::repro::Recorder _recorder (LLVM_PRETTY_FUNCTION, \
139
- stringify_args (* this , __VA_ARGS__)); \
134
+ stringify_args (__VA_ARGS__)); \
140
135
if (lldb_private::repro::InstrumentationData _data = \
141
136
LLDB_GET_INSTRUMENTATION_DATA ()) { \
142
137
_recorder.Record (_data.GetSerializer (), _data.GetRegistry (), \
143
- &lldb_private::repro::invoke<Result ( \
144
- Class::*) Signature>::method<(&Class::Method)>::doit, \
145
- this , __VA_ARGS__); \
138
+ &lldb_private::repro::invoke<T1>::method<T2>::doit, \
139
+ __VA_ARGS__); \
146
140
}
147
141
142
+ #define LLDB_RECORD_METHOD (Result, Class, Method, Signature, ...) \
143
+ LLDB_RECORD_ (Result(Class::*) Signature, (&Class::Method), this, __VA_ARGS__)
144
+
148
145
#define LLDB_RECORD_METHOD_CONST (Result, Class, Method, Signature, ...) \
149
- lldb_private::repro::Recorder _recorder (LLVM_PRETTY_FUNCTION, \
150
- stringify_args (*this , __VA_ARGS__)); \
151
- if (lldb_private::repro::InstrumentationData _data = \
152
- LLDB_GET_INSTRUMENTATION_DATA ()) { \
153
- _recorder.Record ( \
154
- _data.GetSerializer (), _data.GetRegistry (), \
155
- &lldb_private::repro::invoke<Result ( \
156
- Class::*) Signature const >::method_const<(&Class::Method)>::doit, \
157
- this , __VA_ARGS__); \
158
- }
146
+ LLDB_RECORD_ (Result(Class::*) Signature const , (&Class::Method), this, \
147
+ __VA_ARGS__)
159
148
160
149
#define LLDB_RECORD_METHOD_NO_ARGS (Result, Class, Method ) \
161
- lldb_private::repro::Recorder _recorder (LLVM_PRETTY_FUNCTION, \
162
- stringify_args (*this )); \
163
- if (lldb_private::repro::InstrumentationData _data = \
164
- LLDB_GET_INSTRUMENTATION_DATA ()) { \
165
- _recorder.Record (_data.GetSerializer (), _data.GetRegistry (), \
166
- &lldb_private::repro::invoke<Result ( \
167
- Class::*)()>::method<(&Class::Method)>::doit, \
168
- this ); \
169
- }
150
+ LLDB_RECORD_ (Result (Class::*)(), (&Class::Method), this)
170
151
171
152
#define LLDB_RECORD_METHOD_CONST_NO_ARGS (Result, Class, Method ) \
172
- lldb_private::repro::Recorder _recorder (LLVM_PRETTY_FUNCTION, \
173
- stringify_args (*this )); \
174
- if (lldb_private::repro::InstrumentationData _data = \
175
- LLDB_GET_INSTRUMENTATION_DATA ()) { \
176
- _recorder.Record ( \
177
- _data.GetSerializer (), _data.GetRegistry (), \
178
- &lldb_private::repro::invoke<Result ( \
179
- Class::*)() const >::method_const<(&Class::Method)>::doit, \
180
- this ); \
181
- }
153
+ LLDB_RECORD_ (Result (Class::*)() const , (&Class::Method), this)
182
154
183
155
#define LLDB_RECORD_STATIC_METHOD (Result, Class, Method, Signature, ...) \
184
- lldb_private::repro::Recorder _recorder (LLVM_PRETTY_FUNCTION, \
185
- stringify_args (__VA_ARGS__)); \
186
- if (lldb_private::repro::InstrumentationData _data = \
187
- LLDB_GET_INSTRUMENTATION_DATA ()) { \
188
- _recorder.Record ( \
189
- _data.GetSerializer (), _data.GetRegistry (), \
190
- lldb_private::repro::invoke<Result (*) Signature>::method_static<( \
191
- &Class::Method)>::doit, \
192
- __VA_ARGS__); \
193
- }
156
+ LLDB_RECORD_ (Result(*) Signature, (&Class::Method), __VA_ARGS__)
194
157
195
158
#define LLDB_RECORD_STATIC_METHOD_NO_ARGS (Result, Class, Method ) \
196
- lldb_private::repro::Recorder _recorder (LLVM_PRETTY_FUNCTION); \
197
- if (lldb_private::repro::InstrumentationData _data = \
198
- LLDB_GET_INSTRUMENTATION_DATA ()) { \
199
- _recorder.Record (_data.GetSerializer (), _data.GetRegistry (), \
200
- lldb_private::repro::invoke<Result (*)()>::method_static< \
201
- (&Class::Method)>::doit); \
202
- }
159
+ LLDB_RECORD_ (Result (*)(), (&Class::Method), lldb_private::repro::EmptyArg())
203
160
204
161
#define LLDB_RECORD_RESULT (Result ) _recorder.RecordResult(Result, true );
205
162
@@ -561,20 +518,20 @@ struct invoke<Result (Class::*)(Args...)> {
561
518
562
519
template <typename Result, typename Class, typename ... Args>
563
520
struct invoke <Result (Class::*)(Args...) const > {
564
- template <Result (Class::*m)(Args...) const > struct method_const {
521
+ template <Result (Class::*m)(Args...) const > struct method {
565
522
static Result doit (Class *c, Args... args) { return (c->*m)(args...); }
566
523
};
567
524
};
568
525
569
526
template <typename Result, typename ... Args>
570
527
struct invoke <Result (*)(Args...)> {
571
- template <Result (*m)(Args...)> struct method_static {
528
+ template <Result (*m)(Args...)> struct method {
572
529
static Result doit (Args... args) { return (*m)(args...); }
573
530
};
574
531
};
575
532
576
533
template <typename ... Args> struct invoke <void (*)(Args...)> {
577
- template <void (*m)(Args...)> struct method_static {
534
+ template <void (*m)(Args...)> struct method {
578
535
static void doit (Args... args) { return (*m)(args...); }
579
536
};
580
537
};
@@ -712,6 +669,8 @@ class InstrumentationData {
712
669
Registry *m_registry;
713
670
};
714
671
672
+ struct EmptyArg {};
673
+
715
674
// / RAII object that records function invocations and their return value.
716
675
// /
717
676
// / API calls are only captured when the API boundary is crossed. Once we're in
@@ -777,6 +736,15 @@ class Recorder {
777
736
m_result_recorded = true ;
778
737
}
779
738
739
+ // / Specializations for the no-argument methods. These are passed an empty
740
+ // / dummy argument so the same variadic macro can be used. These methods
741
+ // / strip the arguments before forwarding them.
742
+ template <typename Result>
743
+ void Record (Serializer &serializer, Registry ®istry, Result (*f)(),
744
+ const EmptyArg &arg) {
745
+ Record (serializer, registry, f);
746
+ }
747
+
780
748
// / Record the result of a function call.
781
749
template <typename Result>
782
750
Result RecordResult (Result &&r, bool update_boundary) {
@@ -830,7 +798,7 @@ class Recorder {
830
798
template <typename Signature> struct char_ptr_redirect ;
831
799
template <typename Result, typename Class>
832
800
struct char_ptr_redirect <Result (Class::*)(char *, size_t ) const > {
833
- template <Result (Class::*m)(char *, size_t ) const > struct method_const {
801
+ template <Result (Class::*m)(char *, size_t ) const > struct method {
834
802
static Result doit (Class *c, char *s, size_t l) {
835
803
char *buffer = reinterpret_cast <char *>(calloc (l, sizeof (char )));
836
804
return (c->*m)(buffer, l);
@@ -849,7 +817,7 @@ struct char_ptr_redirect<Result (Class::*)(char *, size_t)> {
849
817
850
818
template <typename Result>
851
819
struct char_ptr_redirect <Result (*)(char *, size_t )> {
852
- template <Result (*m)(char *, size_t )> struct method_static {
820
+ template <Result (*m)(char *, size_t )> struct method {
853
821
static Result doit (char *s, size_t l) {
854
822
char *buffer = reinterpret_cast <char *>(calloc (l, sizeof (char )));
855
823
return (*m)(buffer, l);
0 commit comments