From 7bc83564357eb805c90b7d941103732ddfa221bb Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Mon, 11 Mar 2019 20:31:21 +0000 Subject: [PATCH] [Reproducers] Implement log_append for function pointers. Changing the type in the DUMMY macro to void* doesn't actually fix the build error, because the argument type is deducted from the template (as opposed to when serializing through the instrumentation framework, where this would matter). Instead I've added a proper instance of log_append that takes function pointers and logs their address. llvm-svn: 355863 --- lldb/include/lldb/Utility/ReproducerInstrumentation.h | 5 +++++ lldb/source/API/SBCommunication.cpp | 2 +- lldb/source/API/SBDebugger.cpp | 19 +++++++++++-------- lldb/source/API/SBExpressionOptions.cpp | 2 +- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/lldb/include/lldb/Utility/ReproducerInstrumentation.h b/lldb/include/lldb/Utility/ReproducerInstrumentation.h index adba3aa..eeb9ab0 100644 --- a/lldb/include/lldb/Utility/ReproducerInstrumentation.h +++ b/lldb/include/lldb/Utility/ReproducerInstrumentation.h @@ -37,6 +37,11 @@ inline void log_append(llvm::raw_string_ostream &ss, const T *t) { ss << t; } +template +inline void log_append(llvm::raw_string_ostream &ss, T (*t)(E...)) { + ss << &t; +} + template <> inline void log_append(llvm::raw_string_ostream &ss, const char *t) { ss << t; diff --git a/lldb/source/API/SBCommunication.cpp b/lldb/source/API/SBCommunication.cpp index 99f9a4f..6c2efa5 100644 --- a/lldb/source/API/SBCommunication.cpp +++ b/lldb/source/API/SBCommunication.cpp @@ -157,7 +157,7 @@ bool SBCommunication::ReadThreadIsRunning() { bool SBCommunication::SetReadThreadBytesReceivedCallback( ReadThreadBytesReceived callback, void *callback_baton) { - LLDB_RECORD_DUMMY(bool, SBCommunication, void *, + LLDB_RECORD_DUMMY(bool, SBCommunication, SetReadThreadBytesReceivedCallback, (lldb::SBCommunication::ReadThreadBytesReceived, void *), callback, callback_baton); diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp index 82661f4..693b0fe 100644 --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -141,11 +141,13 @@ SBError SBInputReader::Initialize( unsigned long), void *a, lldb::InputReaderGranularity b, char const *c, char const *d, bool e) { - LLDB_RECORD_DUMMY(lldb::SBError, SBInputReader, Initialize, - (lldb::SBDebugger &, void *, void *, - lldb::InputReaderGranularity, const char *, const char *, - bool), - sb_debugger, callback, a, b, c, d, e); + LLDB_RECORD_DUMMY( + lldb::SBError, SBInputReader, Initialize, + (lldb::SBDebugger &, + unsigned long (*)(void *, lldb::SBInputReader *, lldb::InputReaderAction, + const char *, unsigned long), + void *, lldb::InputReaderGranularity, const char *, const char *, bool), + sb_debugger, callback, a, b, c, d, e); return SBError(); } @@ -237,7 +239,8 @@ SBDebugger SBDebugger::Create(bool source_init_files, { LLDB_RECORD_DUMMY(lldb::SBDebugger, SBDebugger, Create, - (bool, void *, void *), source_init_files, callback, baton); + (bool, lldb::LogOutputCallback, void *), source_init_files, + callback, baton); SBDebugger debugger; @@ -1533,8 +1536,8 @@ bool SBDebugger::EnableLog(const char *channel, const char **categories) { void SBDebugger::SetLoggingCallback(lldb::LogOutputCallback log_callback, void *baton) { - LLDB_RECORD_DUMMY(void, SBDebugger, SetLoggingCallback, (void *, void *), - log_callback, baton); + LLDB_RECORD_DUMMY(void, SBDebugger, SetLoggingCallback, + (lldb::LogOutputCallback, void *), log_callback, baton); if (m_opaque_sp) { return m_opaque_sp->SetLoggingCallback(log_callback, baton); diff --git a/lldb/source/API/SBExpressionOptions.cpp b/lldb/source/API/SBExpressionOptions.cpp index e8ca600..ab9c149 100644 --- a/lldb/source/API/SBExpressionOptions.cpp +++ b/lldb/source/API/SBExpressionOptions.cpp @@ -180,7 +180,7 @@ void SBExpressionOptions::SetLanguage(lldb::LanguageType language) { void SBExpressionOptions::SetCancelCallback( lldb::ExpressionCancelCallback callback, void *baton) { LLDB_RECORD_DUMMY(void, SBExpressionOptions, SetCancelCallback, - (void *, void *), callback, baton); + (lldb::ExpressionCancelCallback, void *), callback, baton); m_opaque_up->SetCancelCallback(callback, baton); } -- 2.7.4