mirror of
https://github.com/intel/llvm.git
synced 2026-01-31 15:44:23 +08:00
[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
This commit is contained in:
@@ -13,7 +13,6 @@
|
||||
#include "lldb/Host/FileSystem.h"
|
||||
#include "lldb/Host/PosixApi.h"
|
||||
#include "lldb/Utility/FileSpec.h"
|
||||
#include "lldb/Utility/Log.h"
|
||||
#include "lldb/Utility/Stream.h"
|
||||
|
||||
#include "llvm/ADT/SmallString.h"
|
||||
@@ -72,16 +71,7 @@ bool SBFileSpec::IsValid() const {
|
||||
bool SBFileSpec::Exists() const {
|
||||
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBFileSpec, Exists);
|
||||
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
||||
|
||||
bool result = FileSystem::Instance().Exists(*m_opaque_up);
|
||||
|
||||
if (log)
|
||||
log->Printf("SBFileSpec(%p)::Exists () => %s",
|
||||
static_cast<void *>(m_opaque_up.get()),
|
||||
(result ? "true" : "false"));
|
||||
|
||||
return result;
|
||||
return FileSystem::Instance().Exists(*m_opaque_up);
|
||||
}
|
||||
|
||||
bool SBFileSpec::ResolveExecutableLocation() {
|
||||
@@ -105,19 +95,7 @@ int SBFileSpec::ResolvePath(const char *src_path, char *dst_path,
|
||||
const char *SBFileSpec::GetFilename() const {
|
||||
LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBFileSpec, GetFilename);
|
||||
|
||||
const char *s = m_opaque_up->GetFilename().AsCString();
|
||||
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
||||
if (log) {
|
||||
if (s)
|
||||
log->Printf("SBFileSpec(%p)::GetFilename () => \"%s\"",
|
||||
static_cast<void *>(m_opaque_up.get()), s);
|
||||
else
|
||||
log->Printf("SBFileSpec(%p)::GetFilename () => NULL",
|
||||
static_cast<void *>(m_opaque_up.get()));
|
||||
}
|
||||
|
||||
return s;
|
||||
return m_opaque_up->GetFilename().AsCString();
|
||||
}
|
||||
|
||||
const char *SBFileSpec::GetDirectory() const {
|
||||
@@ -125,16 +103,6 @@ const char *SBFileSpec::GetDirectory() const {
|
||||
|
||||
FileSpec directory{*m_opaque_up};
|
||||
directory.GetFilename().Clear();
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
||||
if (log) {
|
||||
if (directory)
|
||||
log->Printf("SBFileSpec(%p)::GetDirectory () => \"%s\"",
|
||||
static_cast<void *>(m_opaque_up.get()),
|
||||
directory.GetCString());
|
||||
else
|
||||
log->Printf("SBFileSpec(%p)::GetDirectory () => NULL",
|
||||
static_cast<void *>(m_opaque_up.get()));
|
||||
}
|
||||
return directory.GetCString();
|
||||
}
|
||||
|
||||
@@ -160,16 +128,8 @@ uint32_t SBFileSpec::GetPath(char *dst_path, size_t dst_len) const {
|
||||
LLDB_RECORD_METHOD_CONST(uint32_t, SBFileSpec, GetPath, (char *, size_t),
|
||||
dst_path, dst_len);
|
||||
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
||||
|
||||
uint32_t result = m_opaque_up->GetPath(dst_path, dst_len);
|
||||
|
||||
if (log)
|
||||
log->Printf("SBFileSpec(%p)::GetPath (dst_path=\"%.*s\", dst_len=%" PRIu64
|
||||
") => %u",
|
||||
static_cast<void *>(m_opaque_up.get()), result, dst_path,
|
||||
static_cast<uint64_t>(dst_len), result);
|
||||
|
||||
if (result == 0 && dst_path && dst_len > 0)
|
||||
*dst_path = '\0';
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user