diff options
author | Jonas Devlieghere <jonas@devlieghere.com> | 2019-03-07 22:47:13 +0000 |
---|---|---|
committer | Jonas Devlieghere <jonas@devlieghere.com> | 2019-03-07 22:47:13 +0000 |
commit | 581af8b09da31fc304f0c297526427c6bca3de14 (patch) | |
tree | 184339f41afce1f3f515bd1e2f7f450b7ede191d /lldb/source/API/SBData.cpp | |
parent | d672e533d5cbd37c7a5f623565ece47167dec411 (diff) | |
download | bcm5719-llvm-581af8b09da31fc304f0c297526427c6bca3de14.tar.gz bcm5719-llvm-581af8b09da31fc304f0c297526427c6bca3de14.zip |
[SBAPI] Log from record macro
The current record macros already log the function being called. This
patch extends the macros to also log their input arguments and removes
explicit logging from the SB API.
This might degrade the amount of information in some cases (because of
smarter casts or efforts to log return values). However I think this is
outweighed by the increased coverage and consistency. Furthermore, using
the reproducer infrastructure, diagnosing bugs in the API layer should
become much easier compared to relying on log messages.
Differential revision: https://reviews.llvm.org/D59101
llvm-svn: 355649
Diffstat (limited to 'lldb/source/API/SBData.cpp')
-rw-r--r-- | lldb/source/API/SBData.cpp | 178 |
1 files changed, 0 insertions, 178 deletions
diff --git a/lldb/source/API/SBData.cpp b/lldb/source/API/SBData.cpp index 6dbbd65e44a..77581f58529 100644 --- a/lldb/source/API/SBData.cpp +++ b/lldb/source/API/SBData.cpp @@ -14,7 +14,6 @@ #include "lldb/Core/DumpDataExtractor.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" -#include "lldb/Utility/Log.h" #include "lldb/Utility/Stream.h" #include <cinttypes> @@ -67,14 +66,9 @@ bool SBData::IsValid() { uint8_t SBData::GetAddressByteSize() { LLDB_RECORD_METHOD_NO_ARGS(uint8_t, SBData, GetAddressByteSize); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); uint8_t value = 0; if (m_opaque_sp.get()) value = m_opaque_sp->GetAddressByteSize(); - if (log) - log->Printf("SBData::GetAddressByteSize () => " - "(%i)", - value); return value; } @@ -82,11 +76,8 @@ void SBData::SetAddressByteSize(uint8_t addr_byte_size) { LLDB_RECORD_METHOD(void, SBData, SetAddressByteSize, (uint8_t), addr_byte_size); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); if (m_opaque_sp.get()) m_opaque_sp->SetAddressByteSize(addr_byte_size); - if (log) - log->Printf("SBData::SetAddressByteSize (%i)", addr_byte_size); } void SBData::Clear() { @@ -99,46 +90,32 @@ void SBData::Clear() { size_t SBData::GetByteSize() { LLDB_RECORD_METHOD_NO_ARGS(size_t, SBData, GetByteSize); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); size_t value = 0; if (m_opaque_sp.get()) value = m_opaque_sp->GetByteSize(); - if (log) - log->Printf("SBData::GetByteSize () => " - "( %" PRIu64 " )", - (uint64_t)value); return value; } lldb::ByteOrder SBData::GetByteOrder() { LLDB_RECORD_METHOD_NO_ARGS(lldb::ByteOrder, SBData, GetByteOrder); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); lldb::ByteOrder value = eByteOrderInvalid; if (m_opaque_sp.get()) value = m_opaque_sp->GetByteOrder(); - if (log) - log->Printf("SBData::GetByteOrder () => " - "(%i)", - value); return value; } void SBData::SetByteOrder(lldb::ByteOrder endian) { LLDB_RECORD_METHOD(void, SBData, SetByteOrder, (lldb::ByteOrder), endian); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); if (m_opaque_sp.get()) m_opaque_sp->SetByteOrder(endian); - if (log) - log->Printf("SBData::GetByteOrder (%i)", endian); } float SBData::GetFloat(lldb::SBError &error, lldb::offset_t offset) { LLDB_RECORD_METHOD(float, SBData, GetFloat, (lldb::SBError &, lldb::offset_t), error, offset); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); float value = 0; if (!m_opaque_sp.get()) { error.SetErrorString("no value to read from"); @@ -148,9 +125,6 @@ float SBData::GetFloat(lldb::SBError &error, lldb::offset_t offset) { if (offset == old_offset) error.SetErrorString("unable to read data"); } - if (log) - log->Printf("SBData::GetFloat (error=%p,offset=%" PRIu64 ") => (%f)", - static_cast<void *>(error.get()), offset, value); return value; } @@ -158,7 +132,6 @@ double SBData::GetDouble(lldb::SBError &error, lldb::offset_t offset) { LLDB_RECORD_METHOD(double, SBData, GetDouble, (lldb::SBError &, lldb::offset_t), error, offset); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); double value = 0; if (!m_opaque_sp.get()) { error.SetErrorString("no value to read from"); @@ -168,10 +141,6 @@ double SBData::GetDouble(lldb::SBError &error, lldb::offset_t offset) { if (offset == old_offset) error.SetErrorString("unable to read data"); } - if (log) - log->Printf("SBData::GetDouble (error=%p,offset=%" PRIu64 ") => " - "(%f)", - static_cast<void *>(error.get()), offset, value); return value; } @@ -179,7 +148,6 @@ long double SBData::GetLongDouble(lldb::SBError &error, lldb::offset_t offset) { LLDB_RECORD_METHOD(long double, SBData, GetLongDouble, (lldb::SBError &, lldb::offset_t), error, offset); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); long double value = 0; if (!m_opaque_sp.get()) { error.SetErrorString("no value to read from"); @@ -189,10 +157,6 @@ long double SBData::GetLongDouble(lldb::SBError &error, lldb::offset_t offset) { if (offset == old_offset) error.SetErrorString("unable to read data"); } - if (log) - log->Printf("SBData::GetLongDouble (error=%p,offset=%" PRIu64 ") => " - "(%Lf)", - static_cast<void *>(error.get()), offset, value); return value; } @@ -200,7 +164,6 @@ lldb::addr_t SBData::GetAddress(lldb::SBError &error, lldb::offset_t offset) { LLDB_RECORD_METHOD(lldb::addr_t, SBData, GetAddress, (lldb::SBError &, lldb::offset_t), error, offset); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); lldb::addr_t value = 0; if (!m_opaque_sp.get()) { error.SetErrorString("no value to read from"); @@ -210,11 +173,6 @@ lldb::addr_t SBData::GetAddress(lldb::SBError &error, lldb::offset_t offset) { if (offset == old_offset) error.SetErrorString("unable to read data"); } - if (log) - log->Printf("SBData::GetAddress (error=%p,offset=%" PRIu64 ") => " - "(%p)", - static_cast<void *>(error.get()), offset, - reinterpret_cast<void *>(value)); return value; } @@ -222,7 +180,6 @@ uint8_t SBData::GetUnsignedInt8(lldb::SBError &error, lldb::offset_t offset) { LLDB_RECORD_METHOD(uint8_t, SBData, GetUnsignedInt8, (lldb::SBError &, lldb::offset_t), error, offset); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); uint8_t value = 0; if (!m_opaque_sp.get()) { error.SetErrorString("no value to read from"); @@ -232,10 +189,6 @@ uint8_t SBData::GetUnsignedInt8(lldb::SBError &error, lldb::offset_t offset) { if (offset == old_offset) error.SetErrorString("unable to read data"); } - if (log) - log->Printf("SBData::GetUnsignedInt8 (error=%p,offset=%" PRIu64 ") => " - "(%c)", - static_cast<void *>(error.get()), offset, value); return value; } @@ -243,7 +196,6 @@ uint16_t SBData::GetUnsignedInt16(lldb::SBError &error, lldb::offset_t offset) { LLDB_RECORD_METHOD(uint16_t, SBData, GetUnsignedInt16, (lldb::SBError &, lldb::offset_t), error, offset); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); uint16_t value = 0; if (!m_opaque_sp.get()) { error.SetErrorString("no value to read from"); @@ -253,10 +205,6 @@ uint16_t SBData::GetUnsignedInt16(lldb::SBError &error, lldb::offset_t offset) { if (offset == old_offset) error.SetErrorString("unable to read data"); } - if (log) - log->Printf("SBData::GetUnsignedInt16 (error=%p,offset=%" PRIu64 ") => " - "(%hd)", - static_cast<void *>(error.get()), offset, value); return value; } @@ -264,7 +212,6 @@ uint32_t SBData::GetUnsignedInt32(lldb::SBError &error, lldb::offset_t offset) { LLDB_RECORD_METHOD(uint32_t, SBData, GetUnsignedInt32, (lldb::SBError &, lldb::offset_t), error, offset); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); uint32_t value = 0; if (!m_opaque_sp.get()) { error.SetErrorString("no value to read from"); @@ -274,10 +221,6 @@ uint32_t SBData::GetUnsignedInt32(lldb::SBError &error, lldb::offset_t offset) { if (offset == old_offset) error.SetErrorString("unable to read data"); } - if (log) - log->Printf("SBData::GetUnsignedInt32 (error=%p,offset=%" PRIu64 ") => " - "(%d)", - static_cast<void *>(error.get()), offset, value); return value; } @@ -285,7 +228,6 @@ uint64_t SBData::GetUnsignedInt64(lldb::SBError &error, lldb::offset_t offset) { LLDB_RECORD_METHOD(uint64_t, SBData, GetUnsignedInt64, (lldb::SBError &, lldb::offset_t), error, offset); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); uint64_t value = 0; if (!m_opaque_sp.get()) { error.SetErrorString("no value to read from"); @@ -295,10 +237,6 @@ uint64_t SBData::GetUnsignedInt64(lldb::SBError &error, lldb::offset_t offset) { if (offset == old_offset) error.SetErrorString("unable to read data"); } - if (log) - log->Printf("SBData::GetUnsignedInt64 (error=%p,offset=%" PRIu64 ") => " - "(%" PRId64 ")", - static_cast<void *>(error.get()), offset, value); return value; } @@ -306,7 +244,6 @@ int8_t SBData::GetSignedInt8(lldb::SBError &error, lldb::offset_t offset) { LLDB_RECORD_METHOD(int8_t, SBData, GetSignedInt8, (lldb::SBError &, lldb::offset_t), error, offset); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); int8_t value = 0; if (!m_opaque_sp.get()) { error.SetErrorString("no value to read from"); @@ -316,10 +253,6 @@ int8_t SBData::GetSignedInt8(lldb::SBError &error, lldb::offset_t offset) { if (offset == old_offset) error.SetErrorString("unable to read data"); } - if (log) - log->Printf("SBData::GetSignedInt8 (error=%p,offset=%" PRIu64 ") => " - "(%c)", - static_cast<void *>(error.get()), offset, value); return value; } @@ -327,7 +260,6 @@ int16_t SBData::GetSignedInt16(lldb::SBError &error, lldb::offset_t offset) { LLDB_RECORD_METHOD(int16_t, SBData, GetSignedInt16, (lldb::SBError &, lldb::offset_t), error, offset); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); int16_t value = 0; if (!m_opaque_sp.get()) { error.SetErrorString("no value to read from"); @@ -337,10 +269,6 @@ int16_t SBData::GetSignedInt16(lldb::SBError &error, lldb::offset_t offset) { if (offset == old_offset) error.SetErrorString("unable to read data"); } - if (log) - log->Printf("SBData::GetSignedInt16 (error=%p,offset=%" PRIu64 ") => " - "(%hd)", - static_cast<void *>(error.get()), offset, value); return value; } @@ -348,7 +276,6 @@ int32_t SBData::GetSignedInt32(lldb::SBError &error, lldb::offset_t offset) { LLDB_RECORD_METHOD(int32_t, SBData, GetSignedInt32, (lldb::SBError &, lldb::offset_t), error, offset); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); int32_t value = 0; if (!m_opaque_sp.get()) { error.SetErrorString("no value to read from"); @@ -358,10 +285,6 @@ int32_t SBData::GetSignedInt32(lldb::SBError &error, lldb::offset_t offset) { if (offset == old_offset) error.SetErrorString("unable to read data"); } - if (log) - log->Printf("SBData::GetSignedInt32 (error=%p,offset=%" PRIu64 ") => " - "(%d)", - static_cast<void *>(error.get()), offset, value); return value; } @@ -369,7 +292,6 @@ int64_t SBData::GetSignedInt64(lldb::SBError &error, lldb::offset_t offset) { LLDB_RECORD_METHOD(int64_t, SBData, GetSignedInt64, (lldb::SBError &, lldb::offset_t), error, offset); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); int64_t value = 0; if (!m_opaque_sp.get()) { error.SetErrorString("no value to read from"); @@ -379,10 +301,6 @@ int64_t SBData::GetSignedInt64(lldb::SBError &error, lldb::offset_t offset) { if (offset == old_offset) error.SetErrorString("unable to read data"); } - if (log) - log->Printf("SBData::GetSignedInt64 (error=%p,offset=%" PRIu64 ") => " - "(%" PRId64 ")", - static_cast<void *>(error.get()), offset, value); return value; } @@ -390,7 +308,6 @@ const char *SBData::GetString(lldb::SBError &error, lldb::offset_t offset) { LLDB_RECORD_METHOD(const char *, SBData, GetString, (lldb::SBError &, lldb::offset_t), error, offset); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); const char *value = 0; if (!m_opaque_sp.get()) { error.SetErrorString("no value to read from"); @@ -400,10 +317,6 @@ const char *SBData::GetString(lldb::SBError &error, lldb::offset_t offset) { if (offset == old_offset || (value == NULL)) error.SetErrorString("unable to read data"); } - if (log) - log->Printf("SBData::GetString (error=%p,offset=%" PRIu64 ") => (%p)", - static_cast<void *>(error.get()), offset, - static_cast<const void *>(value)); return value; } @@ -425,7 +338,6 @@ bool SBData::GetDescription(lldb::SBStream &description, size_t SBData::ReadRawData(lldb::SBError &error, lldb::offset_t offset, void *buf, size_t size) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); void *ok = NULL; if (!m_opaque_sp.get()) { error.SetErrorString("no value to read from"); @@ -435,19 +347,11 @@ size_t SBData::ReadRawData(lldb::SBError &error, lldb::offset_t offset, if ((offset == old_offset) || (ok == NULL)) error.SetErrorString("unable to read data"); } - if (log) - log->Printf("SBData::ReadRawData (error=%p,offset=%" PRIu64 - ",buf=%p,size=%" PRIu64 ") => " - "(%p)", - static_cast<void *>(error.get()), offset, - static_cast<void *>(buf), static_cast<uint64_t>(size), - static_cast<void *>(ok)); return ok ? size : 0; } void SBData::SetData(lldb::SBError &error, const void *buf, size_t size, lldb::ByteOrder endian, uint8_t addr_size) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); if (!m_opaque_sp.get()) m_opaque_sp = std::make_shared<DataExtractor>(buf, size, endian, addr_size); else @@ -456,25 +360,14 @@ void SBData::SetData(lldb::SBError &error, const void *buf, size_t size, m_opaque_sp->SetAddressByteSize(addr_size); } - if (log) - log->Printf("SBData::SetData (error=%p,buf=%p,size=%" PRIu64 - ",endian=%d,addr_size=%c) => " - "(%p)", - static_cast<void *>(error.get()), - static_cast<const void *>(buf), static_cast<uint64_t>(size), - endian, addr_size, static_cast<void *>(m_opaque_sp.get())); } bool SBData::Append(const SBData &rhs) { LLDB_RECORD_METHOD(bool, SBData, Append, (const lldb::SBData &), rhs); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); bool value = false; if (m_opaque_sp.get() && rhs.m_opaque_sp.get()) value = m_opaque_sp.get()->Append(*rhs.m_opaque_sp); - if (log) - log->Printf("SBData::Append (rhs=%p) => (%s)", - static_cast<void *>(rhs.get()), value ? "true" : "false"); return value; } @@ -612,12 +505,8 @@ lldb::SBData SBData::CreateDataFromDoubleArray(lldb::ByteOrder endian, bool SBData::SetDataFromCString(const char *data) { LLDB_RECORD_METHOD(bool, SBData, SetDataFromCString, (const char *), data); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); if (!data) { - if (log) - log->Printf("SBData::SetDataFromCString (data=%p) => false", - static_cast<const void *>(data)); return false; } @@ -631,9 +520,6 @@ bool SBData::SetDataFromCString(const char *data) { else m_opaque_sp->SetData(buffer_sp); - if (log) - log->Printf("SBData::SetDataFromCString (data=%p) => true", - static_cast<const void *>(data)); return true; } @@ -642,15 +528,8 @@ bool SBData::SetDataFromUInt64Array(uint64_t *array, size_t array_len) { LLDB_RECORD_METHOD(bool, SBData, SetDataFromUInt64Array, (uint64_t *, size_t), array, array_len); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); if (!array || array_len == 0) { - if (log) - log->Printf( - "SBData::SetDataFromUInt64Array (array=%p, array_len = %" PRIu64 - ") => " - "false", - static_cast<void *>(array), static_cast<uint64_t>(array_len)); return false; } @@ -664,11 +543,6 @@ bool SBData::SetDataFromUInt64Array(uint64_t *array, size_t array_len) { else m_opaque_sp->SetData(buffer_sp); - if (log) - log->Printf("SBData::SetDataFromUInt64Array (array=%p, array_len = %" PRIu64 - ") => " - "true", - static_cast<void *>(array), static_cast<uint64_t>(array_len)); return true; } @@ -677,15 +551,8 @@ bool SBData::SetDataFromUInt32Array(uint32_t *array, size_t array_len) { LLDB_RECORD_METHOD(bool, SBData, SetDataFromUInt32Array, (uint32_t *, size_t), array, array_len); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); if (!array || array_len == 0) { - if (log) - log->Printf( - "SBData::SetDataFromUInt32Array (array=%p, array_len = %" PRIu64 - ") => " - "false", - static_cast<void *>(array), static_cast<uint64_t>(array_len)); return false; } @@ -699,12 +566,6 @@ bool SBData::SetDataFromUInt32Array(uint32_t *array, size_t array_len) { else m_opaque_sp->SetData(buffer_sp); - if (log) - log->Printf("SBData::SetDataFromUInt32Array (array=%p, array_len = %" PRIu64 - ") => " - "true", - static_cast<void *>(array), static_cast<uint64_t>(array_len)); - return true; } @@ -712,15 +573,8 @@ bool SBData::SetDataFromSInt64Array(int64_t *array, size_t array_len) { LLDB_RECORD_METHOD(bool, SBData, SetDataFromSInt64Array, (int64_t *, size_t), array, array_len); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); if (!array || array_len == 0) { - if (log) - log->Printf( - "SBData::SetDataFromSInt64Array (array=%p, array_len = %" PRIu64 - ") => " - "false", - static_cast<void *>(array), static_cast<uint64_t>(array_len)); return false; } @@ -734,12 +588,6 @@ bool SBData::SetDataFromSInt64Array(int64_t *array, size_t array_len) { else m_opaque_sp->SetData(buffer_sp); - if (log) - log->Printf("SBData::SetDataFromSInt64Array (array=%p, array_len = %" PRIu64 - ") => " - "true", - static_cast<void *>(array), static_cast<uint64_t>(array_len)); - return true; } @@ -747,15 +595,8 @@ bool SBData::SetDataFromSInt32Array(int32_t *array, size_t array_len) { LLDB_RECORD_METHOD(bool, SBData, SetDataFromSInt32Array, (int32_t *, size_t), array, array_len); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); if (!array || array_len == 0) { - if (log) - log->Printf( - "SBData::SetDataFromSInt32Array (array=%p, array_len = %" PRIu64 - ") => " - "false", - static_cast<void *>(array), static_cast<uint64_t>(array_len)); return false; } @@ -769,12 +610,6 @@ bool SBData::SetDataFromSInt32Array(int32_t *array, size_t array_len) { else m_opaque_sp->SetData(buffer_sp); - if (log) - log->Printf("SBData::SetDataFromSInt32Array (array=%p, array_len = %" PRIu64 - ") => " - "true", - static_cast<void *>(array), static_cast<uint64_t>(array_len)); - return true; } @@ -782,15 +617,8 @@ bool SBData::SetDataFromDoubleArray(double *array, size_t array_len) { LLDB_RECORD_METHOD(bool, SBData, SetDataFromDoubleArray, (double *, size_t), array, array_len); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); if (!array || array_len == 0) { - if (log) - log->Printf( - "SBData::SetDataFromDoubleArray (array=%p, array_len = %" PRIu64 - ") => " - "false", - static_cast<void *>(array), static_cast<uint64_t>(array_len)); return false; } @@ -804,11 +632,5 @@ bool SBData::SetDataFromDoubleArray(double *array, size_t array_len) { else m_opaque_sp->SetData(buffer_sp); - if (log) - log->Printf("SBData::SetDataFromDoubleArray (array=%p, array_len = %" PRIu64 - ") => " - "true", - static_cast<void *>(array), static_cast<uint64_t>(array_len)); - return true; } |