diff options
Diffstat (limited to 'source/API')
73 files changed, 11329 insertions, 5462 deletions
diff --git a/source/API/SBAddress.cpp b/source/API/SBAddress.cpp index 09ec6c3f10db9..358cb400a76cc 100644 --- a/source/API/SBAddress.cpp +++ b/source/API/SBAddress.cpp @@ -1,13 +1,14 @@ //===-- SBAddress.cpp -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBAddress.h" +#include "SBReproducerPrivate.h" +#include "Utils.h" #include "lldb/API/SBProcess.h" #include "lldb/API/SBSection.h" #include "lldb/API/SBStream.h" @@ -15,44 +16,51 @@ #include "lldb/Core/Module.h" #include "lldb/Symbol/LineEntry.h" #include "lldb/Target/Target.h" -#include "lldb/Utility/Log.h" #include "lldb/Utility/StreamString.h" using namespace lldb; using namespace lldb_private; -SBAddress::SBAddress() : m_opaque_ap(new Address()) {} +SBAddress::SBAddress() : m_opaque_up(new Address()) { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBAddress); +} SBAddress::SBAddress(const Address *lldb_object_ptr) - : m_opaque_ap(new Address()) { + : m_opaque_up(new Address()) { if (lldb_object_ptr) - ref() = *lldb_object_ptr; + m_opaque_up = llvm::make_unique<Address>(*lldb_object_ptr); } -SBAddress::SBAddress(const SBAddress &rhs) : m_opaque_ap(new Address()) { - if (rhs.IsValid()) - ref() = rhs.ref(); +SBAddress::SBAddress(const SBAddress &rhs) : m_opaque_up(new Address()) { + LLDB_RECORD_CONSTRUCTOR(SBAddress, (const lldb::SBAddress &), rhs); + + m_opaque_up = clone(rhs.m_opaque_up); } SBAddress::SBAddress(lldb::SBSection section, lldb::addr_t offset) - : m_opaque_ap(new Address(section.GetSP(), offset)) {} + : m_opaque_up(new Address(section.GetSP(), offset)) { + LLDB_RECORD_CONSTRUCTOR(SBAddress, (lldb::SBSection, lldb::addr_t), section, + offset); +} // Create an address by resolving a load address using the supplied target SBAddress::SBAddress(lldb::addr_t load_addr, lldb::SBTarget &target) - : m_opaque_ap(new Address()) { + : m_opaque_up(new Address()) { + LLDB_RECORD_CONSTRUCTOR(SBAddress, (lldb::addr_t, lldb::SBTarget &), + load_addr, target); + SetLoadAddress(load_addr, target); } SBAddress::~SBAddress() {} const SBAddress &SBAddress::operator=(const SBAddress &rhs) { - if (this != &rhs) { - if (rhs.IsValid()) - ref() = rhs.ref(); - else - m_opaque_ap.reset(new Address()); - } - return *this; + LLDB_RECORD_METHOD(const lldb::SBAddress &, + SBAddress, operator=,(const lldb::SBAddress &), rhs); + + if (this != &rhs) + m_opaque_up = clone(rhs.m_opaque_up); + return LLDB_RECORD_RESULT(*this); } bool lldb::operator==(const SBAddress &lhs, const SBAddress &rhs) { @@ -61,13 +69,33 @@ bool lldb::operator==(const SBAddress &lhs, const SBAddress &rhs) { return false; } +bool SBAddress::operator!=(const SBAddress &rhs) const { + LLDB_RECORD_METHOD_CONST(bool, SBAddress, operator!=,(const SBAddress &), + &rhs); + + return !(*this == rhs); +} + bool SBAddress::IsValid() const { - return m_opaque_ap != NULL && m_opaque_ap->IsValid(); + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBAddress, IsValid); + return this->operator bool(); } +SBAddress::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBAddress, operator bool); -void SBAddress::Clear() { m_opaque_ap.reset(new Address()); } + return m_opaque_up != nullptr && m_opaque_up->IsValid(); +} + +void SBAddress::Clear() { + LLDB_RECORD_METHOD_NO_ARGS(void, SBAddress, Clear); + + m_opaque_up.reset(new Address()); +} void SBAddress::SetAddress(lldb::SBSection section, lldb::addr_t offset) { + LLDB_RECORD_METHOD(void, SBAddress, SetAddress, + (lldb::SBSection, lldb::addr_t), section, offset); + Address &addr = ref(); addr.SetSection(section.GetSP()); addr.SetOffset(offset); @@ -77,61 +105,59 @@ void SBAddress::SetAddress(const Address *lldb_object_ptr) { if (lldb_object_ptr) ref() = *lldb_object_ptr; else - m_opaque_ap.reset(new Address()); + m_opaque_up.reset(new Address()); } lldb::addr_t SBAddress::GetFileAddress() const { - if (m_opaque_ap->IsValid()) - return m_opaque_ap->GetFileAddress(); + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::addr_t, SBAddress, GetFileAddress); + + if (m_opaque_up->IsValid()) + return m_opaque_up->GetFileAddress(); else return LLDB_INVALID_ADDRESS; } lldb::addr_t SBAddress::GetLoadAddress(const SBTarget &target) const { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_CONST(lldb::addr_t, SBAddress, GetLoadAddress, + (const lldb::SBTarget &), target); lldb::addr_t addr = LLDB_INVALID_ADDRESS; TargetSP target_sp(target.GetSP()); if (target_sp) { - if (m_opaque_ap->IsValid()) { + if (m_opaque_up->IsValid()) { std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); - addr = m_opaque_ap->GetLoadAddress(target_sp.get()); + addr = m_opaque_up->GetLoadAddress(target_sp.get()); } } - if (log) { - if (addr == LLDB_INVALID_ADDRESS) - log->Printf( - "SBAddress::GetLoadAddress (SBTarget(%p)) => LLDB_INVALID_ADDRESS", - static_cast<void *>(target_sp.get())); - else - log->Printf("SBAddress::GetLoadAddress (SBTarget(%p)) => 0x%" PRIx64, - static_cast<void *>(target_sp.get()), addr); - } - return addr; } void SBAddress::SetLoadAddress(lldb::addr_t load_addr, lldb::SBTarget &target) { + LLDB_RECORD_METHOD(void, SBAddress, SetLoadAddress, + (lldb::addr_t, lldb::SBTarget &), load_addr, target); + // Create the address object if we don't already have one ref(); if (target.IsValid()) *this = target.ResolveLoadAddress(load_addr); else - m_opaque_ap->Clear(); + m_opaque_up->Clear(); // Check if we weren't were able to resolve a section offset address. If we // weren't it is ok, the load address might be a location on the stack or // heap, so we should just have an address with no section and a valid offset - if (!m_opaque_ap->IsValid()) - m_opaque_ap->SetOffset(load_addr); + if (!m_opaque_up->IsValid()) + m_opaque_up->SetOffset(load_addr); } bool SBAddress::OffsetAddress(addr_t offset) { - if (m_opaque_ap->IsValid()) { - addr_t addr_offset = m_opaque_ap->GetOffset(); + LLDB_RECORD_METHOD(bool, SBAddress, OffsetAddress, (lldb::addr_t), offset); + + if (m_opaque_up->IsValid()) { + addr_t addr_offset = m_opaque_up->GetOffset(); if (addr_offset != LLDB_INVALID_ADDRESS) { - m_opaque_ap->SetOffset(addr_offset + offset); + m_opaque_up->SetOffset(addr_offset + offset); return true; } } @@ -139,46 +165,53 @@ bool SBAddress::OffsetAddress(addr_t offset) { } lldb::SBSection SBAddress::GetSection() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBSection, SBAddress, GetSection); + lldb::SBSection sb_section; - if (m_opaque_ap->IsValid()) - sb_section.SetSP(m_opaque_ap->GetSection()); - return sb_section; + if (m_opaque_up->IsValid()) + sb_section.SetSP(m_opaque_up->GetSection()); + return LLDB_RECORD_RESULT(sb_section); } lldb::addr_t SBAddress::GetOffset() { - if (m_opaque_ap->IsValid()) - return m_opaque_ap->GetOffset(); + LLDB_RECORD_METHOD_NO_ARGS(lldb::addr_t, SBAddress, GetOffset); + + if (m_opaque_up->IsValid()) + return m_opaque_up->GetOffset(); return 0; } -Address *SBAddress::operator->() { return m_opaque_ap.get(); } +Address *SBAddress::operator->() { return m_opaque_up.get(); } -const Address *SBAddress::operator->() const { return m_opaque_ap.get(); } +const Address *SBAddress::operator->() const { return m_opaque_up.get(); } Address &SBAddress::ref() { - if (m_opaque_ap == NULL) - m_opaque_ap.reset(new Address()); - return *m_opaque_ap; + if (m_opaque_up == nullptr) + m_opaque_up.reset(new Address()); + return *m_opaque_up; } const Address &SBAddress::ref() const { // This object should already have checked with "IsValid()" prior to calling // this function. In case you didn't we will assert and die to let you know. - assert(m_opaque_ap.get()); - return *m_opaque_ap; + assert(m_opaque_up.get()); + return *m_opaque_up; } -Address *SBAddress::get() { return m_opaque_ap.get(); } +Address *SBAddress::get() { return m_opaque_up.get(); } bool SBAddress::GetDescription(SBStream &description) { + LLDB_RECORD_METHOD(bool, SBAddress, GetDescription, (lldb::SBStream &), + description); + // Call "ref()" on the stream to make sure it creates a backing stream in // case there isn't one already... Stream &strm = description.ref(); - if (m_opaque_ap->IsValid()) { - m_opaque_ap->Dump(&strm, NULL, Address::DumpStyleResolvedDescription, + if (m_opaque_up->IsValid()) { + m_opaque_up->Dump(&strm, nullptr, Address::DumpStyleResolvedDescription, Address::DumpStyleModuleWithFileAddress, 4); StreamString sstrm; - // m_opaque_ap->Dump (&sstrm, NULL, + // m_opaque_up->Dump (&sstrm, NULL, // Address::DumpStyleResolvedDescription, Address::DumpStyleInvalid, // 4); // if (sstrm.GetData()) @@ -190,54 +223,109 @@ bool SBAddress::GetDescription(SBStream &description) { } SBModule SBAddress::GetModule() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBModule, SBAddress, GetModule); + SBModule sb_module; - if (m_opaque_ap->IsValid()) - sb_module.SetSP(m_opaque_ap->GetModule()); - return sb_module; + if (m_opaque_up->IsValid()) + sb_module.SetSP(m_opaque_up->GetModule()); + return LLDB_RECORD_RESULT(sb_module); } SBSymbolContext SBAddress::GetSymbolContext(uint32_t resolve_scope) { + LLDB_RECORD_METHOD(lldb::SBSymbolContext, SBAddress, GetSymbolContext, + (uint32_t), resolve_scope); + SBSymbolContext sb_sc; SymbolContextItem scope = static_cast<SymbolContextItem>(resolve_scope); - if (m_opaque_ap->IsValid()) - m_opaque_ap->CalculateSymbolContext(&sb_sc.ref(), scope); - return sb_sc; + if (m_opaque_up->IsValid()) + m_opaque_up->CalculateSymbolContext(&sb_sc.ref(), scope); + return LLDB_RECORD_RESULT(sb_sc); } SBCompileUnit SBAddress::GetCompileUnit() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBCompileUnit, SBAddress, GetCompileUnit); + SBCompileUnit sb_comp_unit; - if (m_opaque_ap->IsValid()) - sb_comp_unit.reset(m_opaque_ap->CalculateSymbolContextCompileUnit()); - return sb_comp_unit; + if (m_opaque_up->IsValid()) + sb_comp_unit.reset(m_opaque_up->CalculateSymbolContextCompileUnit()); + return LLDB_RECORD_RESULT(sb_comp_unit); } SBFunction SBAddress::GetFunction() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFunction, SBAddress, GetFunction); + SBFunction sb_function; - if (m_opaque_ap->IsValid()) - sb_function.reset(m_opaque_ap->CalculateSymbolContextFunction()); - return sb_function; + if (m_opaque_up->IsValid()) + sb_function.reset(m_opaque_up->CalculateSymbolContextFunction()); + return LLDB_RECORD_RESULT(sb_function); } SBBlock SBAddress::GetBlock() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBBlock, SBAddress, GetBlock); + SBBlock sb_block; - if (m_opaque_ap->IsValid()) - sb_block.SetPtr(m_opaque_ap->CalculateSymbolContextBlock()); - return sb_block; + if (m_opaque_up->IsValid()) + sb_block.SetPtr(m_opaque_up->CalculateSymbolContextBlock()); + return LLDB_RECORD_RESULT(sb_block); } SBSymbol SBAddress::GetSymbol() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBSymbol, SBAddress, GetSymbol); + SBSymbol sb_symbol; - if (m_opaque_ap->IsValid()) - sb_symbol.reset(m_opaque_ap->CalculateSymbolContextSymbol()); - return sb_symbol; + if (m_opaque_up->IsValid()) + sb_symbol.reset(m_opaque_up->CalculateSymbolContextSymbol()); + return LLDB_RECORD_RESULT(sb_symbol); } SBLineEntry SBAddress::GetLineEntry() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBLineEntry, SBAddress, GetLineEntry); + SBLineEntry sb_line_entry; - if (m_opaque_ap->IsValid()) { + if (m_opaque_up->IsValid()) { LineEntry line_entry; - if (m_opaque_ap->CalculateSymbolContextLineEntry(line_entry)) + if (m_opaque_up->CalculateSymbolContextLineEntry(line_entry)) sb_line_entry.SetLineEntry(line_entry); } - return sb_line_entry; + return LLDB_RECORD_RESULT(sb_line_entry); +} + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBAddress>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBAddress, ()); + LLDB_REGISTER_CONSTRUCTOR(SBAddress, (const lldb::SBAddress &)); + LLDB_REGISTER_CONSTRUCTOR(SBAddress, (lldb::SBSection, lldb::addr_t)); + LLDB_REGISTER_CONSTRUCTOR(SBAddress, (lldb::addr_t, lldb::SBTarget &)); + LLDB_REGISTER_METHOD(const lldb::SBAddress &, + SBAddress, operator=,(const lldb::SBAddress &)); + LLDB_REGISTER_METHOD_CONST(bool, + SBAddress, operator!=,(const lldb::SBAddress &)); + LLDB_REGISTER_METHOD_CONST(bool, SBAddress, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBAddress, operator bool, ()); + LLDB_REGISTER_METHOD(void, SBAddress, Clear, ()); + LLDB_REGISTER_METHOD(void, SBAddress, SetAddress, + (lldb::SBSection, lldb::addr_t)); + LLDB_REGISTER_METHOD_CONST(lldb::addr_t, SBAddress, GetFileAddress, ()); + LLDB_REGISTER_METHOD_CONST(lldb::addr_t, SBAddress, GetLoadAddress, + (const lldb::SBTarget &)); + LLDB_REGISTER_METHOD(void, SBAddress, SetLoadAddress, + (lldb::addr_t, lldb::SBTarget &)); + LLDB_REGISTER_METHOD(bool, SBAddress, OffsetAddress, (lldb::addr_t)); + LLDB_REGISTER_METHOD(lldb::SBSection, SBAddress, GetSection, ()); + LLDB_REGISTER_METHOD(lldb::addr_t, SBAddress, GetOffset, ()); + LLDB_REGISTER_METHOD(bool, SBAddress, GetDescription, (lldb::SBStream &)); + LLDB_REGISTER_METHOD(lldb::SBModule, SBAddress, GetModule, ()); + LLDB_REGISTER_METHOD(lldb::SBSymbolContext, SBAddress, GetSymbolContext, + (uint32_t)); + LLDB_REGISTER_METHOD(lldb::SBCompileUnit, SBAddress, GetCompileUnit, ()); + LLDB_REGISTER_METHOD(lldb::SBFunction, SBAddress, GetFunction, ()); + LLDB_REGISTER_METHOD(lldb::SBBlock, SBAddress, GetBlock, ()); + LLDB_REGISTER_METHOD(lldb::SBSymbol, SBAddress, GetSymbol, ()); + LLDB_REGISTER_METHOD(lldb::SBLineEntry, SBAddress, GetLineEntry, ()); +} + +} } diff --git a/source/API/SBAttachInfo.cpp b/source/API/SBAttachInfo.cpp index a74487a70fe3a..838385c104ae6 100644 --- a/source/API/SBAttachInfo.cpp +++ b/source/API/SBAttachInfo.cpp @@ -1,14 +1,14 @@ //===-- SBAttachInfo.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBAttachInfo.h" - +#include "SBReproducerPrivate.h" +#include "Utils.h" #include "lldb/API/SBFileSpec.h" #include "lldb/API/SBListener.h" #include "lldb/Target/Process.h" @@ -16,15 +16,21 @@ using namespace lldb; using namespace lldb_private; -SBAttachInfo::SBAttachInfo() : m_opaque_sp(new ProcessAttachInfo()) {} +SBAttachInfo::SBAttachInfo() : m_opaque_sp(new ProcessAttachInfo()) { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBAttachInfo); +} SBAttachInfo::SBAttachInfo(lldb::pid_t pid) : m_opaque_sp(new ProcessAttachInfo()) { + LLDB_RECORD_CONSTRUCTOR(SBAttachInfo, (lldb::pid_t), pid); + m_opaque_sp->SetProcessID(pid); } SBAttachInfo::SBAttachInfo(const char *path, bool wait_for) : m_opaque_sp(new ProcessAttachInfo()) { + LLDB_RECORD_CONSTRUCTOR(SBAttachInfo, (const char *, bool), path, wait_for); + if (path && path[0]) m_opaque_sp->GetExecutableFile().SetFile(path, FileSpec::Style::native); m_opaque_sp->SetWaitForLaunch(wait_for); @@ -32,6 +38,9 @@ SBAttachInfo::SBAttachInfo(const char *path, bool wait_for) SBAttachInfo::SBAttachInfo(const char *path, bool wait_for, bool async) : m_opaque_sp(new ProcessAttachInfo()) { + LLDB_RECORD_CONSTRUCTOR(SBAttachInfo, (const char *, bool, bool), path, + wait_for, async); + if (path && path[0]) m_opaque_sp->GetExecutableFile().SetFile(path, FileSpec::Style::native); m_opaque_sp->SetWaitForLaunch(wait_for); @@ -40,7 +49,9 @@ SBAttachInfo::SBAttachInfo(const char *path, bool wait_for, bool async) SBAttachInfo::SBAttachInfo(const SBAttachInfo &rhs) : m_opaque_sp(new ProcessAttachInfo()) { - *m_opaque_sp = *rhs.m_opaque_sp; + LLDB_RECORD_CONSTRUCTOR(SBAttachInfo, (const lldb::SBAttachInfo &), rhs); + + m_opaque_sp = clone(rhs.m_opaque_sp); } SBAttachInfo::~SBAttachInfo() {} @@ -48,34 +59,54 @@ SBAttachInfo::~SBAttachInfo() {} lldb_private::ProcessAttachInfo &SBAttachInfo::ref() { return *m_opaque_sp; } SBAttachInfo &SBAttachInfo::operator=(const SBAttachInfo &rhs) { + LLDB_RECORD_METHOD(lldb::SBAttachInfo &, + SBAttachInfo, operator=,(const lldb::SBAttachInfo &), rhs); + if (this != &rhs) - *m_opaque_sp = *rhs.m_opaque_sp; - return *this; + m_opaque_sp = clone(rhs.m_opaque_sp); + return LLDB_RECORD_RESULT(*this); } -lldb::pid_t SBAttachInfo::GetProcessID() { return m_opaque_sp->GetProcessID(); } +lldb::pid_t SBAttachInfo::GetProcessID() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::pid_t, SBAttachInfo, GetProcessID); + + return m_opaque_sp->GetProcessID(); +} void SBAttachInfo::SetProcessID(lldb::pid_t pid) { + LLDB_RECORD_METHOD(void, SBAttachInfo, SetProcessID, (lldb::pid_t), pid); + m_opaque_sp->SetProcessID(pid); } uint32_t SBAttachInfo::GetResumeCount() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBAttachInfo, GetResumeCount); + return m_opaque_sp->GetResumeCount(); } void SBAttachInfo::SetResumeCount(uint32_t c) { + LLDB_RECORD_METHOD(void, SBAttachInfo, SetResumeCount, (uint32_t), c); + m_opaque_sp->SetResumeCount(c); } const char *SBAttachInfo::GetProcessPluginName() { + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBAttachInfo, GetProcessPluginName); + return m_opaque_sp->GetProcessPluginName(); } void SBAttachInfo::SetProcessPluginName(const char *plugin_name) { + LLDB_RECORD_METHOD(void, SBAttachInfo, SetProcessPluginName, (const char *), + plugin_name); + return m_opaque_sp->SetProcessPluginName(plugin_name); } void SBAttachInfo::SetExecutable(const char *path) { + LLDB_RECORD_METHOD(void, SBAttachInfo, SetExecutable, (const char *), path); + if (path && path[0]) m_opaque_sp->GetExecutableFile().SetFile(path, FileSpec::Style::native); else @@ -83,6 +114,9 @@ void SBAttachInfo::SetExecutable(const char *path) { } void SBAttachInfo::SetExecutable(SBFileSpec exe_file) { + LLDB_RECORD_METHOD(void, SBAttachInfo, SetExecutable, (lldb::SBFileSpec), + exe_file); + if (exe_file.IsValid()) m_opaque_sp->GetExecutableFile() = exe_file.ref(); else @@ -90,78 +124,185 @@ void SBAttachInfo::SetExecutable(SBFileSpec exe_file) { } bool SBAttachInfo::GetWaitForLaunch() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBAttachInfo, GetWaitForLaunch); + return m_opaque_sp->GetWaitForLaunch(); } void SBAttachInfo::SetWaitForLaunch(bool b) { + LLDB_RECORD_METHOD(void, SBAttachInfo, SetWaitForLaunch, (bool), b); + m_opaque_sp->SetWaitForLaunch(b); } void SBAttachInfo::SetWaitForLaunch(bool b, bool async) { + LLDB_RECORD_METHOD(void, SBAttachInfo, SetWaitForLaunch, (bool, bool), b, + async); + m_opaque_sp->SetWaitForLaunch(b); m_opaque_sp->SetAsync(async); } bool SBAttachInfo::GetIgnoreExisting() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBAttachInfo, GetIgnoreExisting); + return m_opaque_sp->GetIgnoreExisting(); } void SBAttachInfo::SetIgnoreExisting(bool b) { + LLDB_RECORD_METHOD(void, SBAttachInfo, SetIgnoreExisting, (bool), b); + m_opaque_sp->SetIgnoreExisting(b); } -uint32_t SBAttachInfo::GetUserID() { return m_opaque_sp->GetUserID(); } +uint32_t SBAttachInfo::GetUserID() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBAttachInfo, GetUserID); + + return m_opaque_sp->GetUserID(); +} + +uint32_t SBAttachInfo::GetGroupID() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBAttachInfo, GetGroupID); -uint32_t SBAttachInfo::GetGroupID() { return m_opaque_sp->GetGroupID(); } + return m_opaque_sp->GetGroupID(); +} + +bool SBAttachInfo::UserIDIsValid() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBAttachInfo, UserIDIsValid); -bool SBAttachInfo::UserIDIsValid() { return m_opaque_sp->UserIDIsValid(); } + return m_opaque_sp->UserIDIsValid(); +} -bool SBAttachInfo::GroupIDIsValid() { return m_opaque_sp->GroupIDIsValid(); } +bool SBAttachInfo::GroupIDIsValid() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBAttachInfo, GroupIDIsValid); -void SBAttachInfo::SetUserID(uint32_t uid) { m_opaque_sp->SetUserID(uid); } + return m_opaque_sp->GroupIDIsValid(); +} + +void SBAttachInfo::SetUserID(uint32_t uid) { + LLDB_RECORD_METHOD(void, SBAttachInfo, SetUserID, (uint32_t), uid); + + m_opaque_sp->SetUserID(uid); +} -void SBAttachInfo::SetGroupID(uint32_t gid) { m_opaque_sp->SetGroupID(gid); } +void SBAttachInfo::SetGroupID(uint32_t gid) { + LLDB_RECORD_METHOD(void, SBAttachInfo, SetGroupID, (uint32_t), gid); + + m_opaque_sp->SetGroupID(gid); +} uint32_t SBAttachInfo::GetEffectiveUserID() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBAttachInfo, GetEffectiveUserID); + return m_opaque_sp->GetEffectiveUserID(); } uint32_t SBAttachInfo::GetEffectiveGroupID() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBAttachInfo, GetEffectiveGroupID); + return m_opaque_sp->GetEffectiveGroupID(); } bool SBAttachInfo::EffectiveUserIDIsValid() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBAttachInfo, EffectiveUserIDIsValid); + return m_opaque_sp->EffectiveUserIDIsValid(); } bool SBAttachInfo::EffectiveGroupIDIsValid() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBAttachInfo, EffectiveGroupIDIsValid); + return m_opaque_sp->EffectiveGroupIDIsValid(); } void SBAttachInfo::SetEffectiveUserID(uint32_t uid) { + LLDB_RECORD_METHOD(void, SBAttachInfo, SetEffectiveUserID, (uint32_t), uid); + m_opaque_sp->SetEffectiveUserID(uid); } void SBAttachInfo::SetEffectiveGroupID(uint32_t gid) { + LLDB_RECORD_METHOD(void, SBAttachInfo, SetEffectiveGroupID, (uint32_t), gid); + m_opaque_sp->SetEffectiveGroupID(gid); } lldb::pid_t SBAttachInfo::GetParentProcessID() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::pid_t, SBAttachInfo, GetParentProcessID); + return m_opaque_sp->GetParentProcessID(); } void SBAttachInfo::SetParentProcessID(lldb::pid_t pid) { + LLDB_RECORD_METHOD(void, SBAttachInfo, SetParentProcessID, (lldb::pid_t), + pid); + m_opaque_sp->SetParentProcessID(pid); } bool SBAttachInfo::ParentProcessIDIsValid() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBAttachInfo, ParentProcessIDIsValid); + return m_opaque_sp->ParentProcessIDIsValid(); } SBListener SBAttachInfo::GetListener() { - return SBListener(m_opaque_sp->GetListener()); + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBListener, SBAttachInfo, GetListener); + + return LLDB_RECORD_RESULT(SBListener(m_opaque_sp->GetListener())); } void SBAttachInfo::SetListener(SBListener &listener) { + LLDB_RECORD_METHOD(void, SBAttachInfo, SetListener, (lldb::SBListener &), + listener); + m_opaque_sp->SetListener(listener.GetSP()); } + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBAttachInfo>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBAttachInfo, ()); + LLDB_REGISTER_CONSTRUCTOR(SBAttachInfo, (lldb::pid_t)); + LLDB_REGISTER_CONSTRUCTOR(SBAttachInfo, (const char *, bool)); + LLDB_REGISTER_CONSTRUCTOR(SBAttachInfo, (const char *, bool, bool)); + LLDB_REGISTER_CONSTRUCTOR(SBAttachInfo, (const lldb::SBAttachInfo &)); + LLDB_REGISTER_METHOD(lldb::SBAttachInfo &, + SBAttachInfo, operator=,(const lldb::SBAttachInfo &)); + LLDB_REGISTER_METHOD(lldb::pid_t, SBAttachInfo, GetProcessID, ()); + LLDB_REGISTER_METHOD(void, SBAttachInfo, SetProcessID, (lldb::pid_t)); + LLDB_REGISTER_METHOD(uint32_t, SBAttachInfo, GetResumeCount, ()); + LLDB_REGISTER_METHOD(void, SBAttachInfo, SetResumeCount, (uint32_t)); + LLDB_REGISTER_METHOD(const char *, SBAttachInfo, GetProcessPluginName, ()); + LLDB_REGISTER_METHOD(void, SBAttachInfo, SetProcessPluginName, + (const char *)); + LLDB_REGISTER_METHOD(void, SBAttachInfo, SetExecutable, (const char *)); + LLDB_REGISTER_METHOD(void, SBAttachInfo, SetExecutable, (lldb::SBFileSpec)); + LLDB_REGISTER_METHOD(bool, SBAttachInfo, GetWaitForLaunch, ()); + LLDB_REGISTER_METHOD(void, SBAttachInfo, SetWaitForLaunch, (bool)); + LLDB_REGISTER_METHOD(void, SBAttachInfo, SetWaitForLaunch, (bool, bool)); + LLDB_REGISTER_METHOD(bool, SBAttachInfo, GetIgnoreExisting, ()); + LLDB_REGISTER_METHOD(void, SBAttachInfo, SetIgnoreExisting, (bool)); + LLDB_REGISTER_METHOD(uint32_t, SBAttachInfo, GetUserID, ()); + LLDB_REGISTER_METHOD(uint32_t, SBAttachInfo, GetGroupID, ()); + LLDB_REGISTER_METHOD(bool, SBAttachInfo, UserIDIsValid, ()); + LLDB_REGISTER_METHOD(bool, SBAttachInfo, GroupIDIsValid, ()); + LLDB_REGISTER_METHOD(void, SBAttachInfo, SetUserID, (uint32_t)); + LLDB_REGISTER_METHOD(void, SBAttachInfo, SetGroupID, (uint32_t)); + LLDB_REGISTER_METHOD(uint32_t, SBAttachInfo, GetEffectiveUserID, ()); + LLDB_REGISTER_METHOD(uint32_t, SBAttachInfo, GetEffectiveGroupID, ()); + LLDB_REGISTER_METHOD(bool, SBAttachInfo, EffectiveUserIDIsValid, ()); + LLDB_REGISTER_METHOD(bool, SBAttachInfo, EffectiveGroupIDIsValid, ()); + LLDB_REGISTER_METHOD(void, SBAttachInfo, SetEffectiveUserID, (uint32_t)); + LLDB_REGISTER_METHOD(void, SBAttachInfo, SetEffectiveGroupID, (uint32_t)); + LLDB_REGISTER_METHOD(lldb::pid_t, SBAttachInfo, GetParentProcessID, ()); + LLDB_REGISTER_METHOD(void, SBAttachInfo, SetParentProcessID, (lldb::pid_t)); + LLDB_REGISTER_METHOD(bool, SBAttachInfo, ParentProcessIDIsValid, ()); + LLDB_REGISTER_METHOD(lldb::SBListener, SBAttachInfo, GetListener, ()); + LLDB_REGISTER_METHOD(void, SBAttachInfo, SetListener, (lldb::SBListener &)); +} + +} +} diff --git a/source/API/SBBlock.cpp b/source/API/SBBlock.cpp index cd453872201ad..f333d1d7b5f32 100644 --- a/source/API/SBBlock.cpp +++ b/source/API/SBBlock.cpp @@ -1,13 +1,13 @@ //===-- SBBlock.cpp ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBBlock.h" +#include "SBReproducerPrivate.h" #include "lldb/API/SBAddress.h" #include "lldb/API/SBFileSpec.h" #include "lldb/API/SBFrame.h" @@ -21,34 +21,52 @@ #include "lldb/Symbol/VariableList.h" #include "lldb/Target/StackFrame.h" #include "lldb/Target/Target.h" -#include "lldb/Utility/Log.h" using namespace lldb; using namespace lldb_private; -SBBlock::SBBlock() : m_opaque_ptr(NULL) {} +SBBlock::SBBlock() : m_opaque_ptr(nullptr) { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBBlock); +} SBBlock::SBBlock(lldb_private::Block *lldb_object_ptr) : m_opaque_ptr(lldb_object_ptr) {} -SBBlock::SBBlock(const SBBlock &rhs) : m_opaque_ptr(rhs.m_opaque_ptr) {} +SBBlock::SBBlock(const SBBlock &rhs) : m_opaque_ptr(rhs.m_opaque_ptr) { + LLDB_RECORD_CONSTRUCTOR(SBBlock, (const lldb::SBBlock &), rhs); +} const SBBlock &SBBlock::operator=(const SBBlock &rhs) { + LLDB_RECORD_METHOD(const lldb::SBBlock &, + SBBlock, operator=,(const lldb::SBBlock &), rhs); + m_opaque_ptr = rhs.m_opaque_ptr; - return *this; + return LLDB_RECORD_RESULT(*this); } -SBBlock::~SBBlock() { m_opaque_ptr = NULL; } +SBBlock::~SBBlock() { m_opaque_ptr = nullptr; } -bool SBBlock::IsValid() const { return m_opaque_ptr != NULL; } +bool SBBlock::IsValid() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBlock, IsValid); + return this->operator bool(); +} +SBBlock::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBlock, operator bool); + + return m_opaque_ptr != nullptr; +} bool SBBlock::IsInlined() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBlock, IsInlined); + if (m_opaque_ptr) - return m_opaque_ptr->GetInlinedFunctionInfo() != NULL; + return m_opaque_ptr->GetInlinedFunctionInfo() != nullptr; return false; } const char *SBBlock::GetInlinedName() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBBlock, GetInlinedName); + if (m_opaque_ptr) { const InlineFunctionInfo *inlined_info = m_opaque_ptr->GetInlinedFunctionInfo(); @@ -59,13 +77,16 @@ const char *SBBlock::GetInlinedName() const { language = function->GetLanguage(); else language = lldb::eLanguageTypeUnknown; - return inlined_info->GetName(language).AsCString(NULL); + return inlined_info->GetName(language).AsCString(nullptr); } } - return NULL; + return nullptr; } SBFileSpec SBBlock::GetInlinedCallSiteFile() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBFileSpec, SBBlock, + GetInlinedCallSiteFile); + SBFileSpec sb_file; if (m_opaque_ptr) { const InlineFunctionInfo *inlined_info = @@ -73,10 +94,12 @@ SBFileSpec SBBlock::GetInlinedCallSiteFile() const { if (inlined_info) sb_file.SetFileSpec(inlined_info->GetCallSite().GetFile()); } - return sb_file; + return LLDB_RECORD_RESULT(sb_file); } uint32_t SBBlock::GetInlinedCallSiteLine() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBBlock, GetInlinedCallSiteLine); + if (m_opaque_ptr) { const InlineFunctionInfo *inlined_info = m_opaque_ptr->GetInlinedFunctionInfo(); @@ -87,6 +110,8 @@ uint32_t SBBlock::GetInlinedCallSiteLine() const { } uint32_t SBBlock::GetInlinedCallSiteColumn() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBBlock, GetInlinedCallSiteColumn); + if (m_opaque_ptr) { const InlineFunctionInfo *inlined_info = m_opaque_ptr->GetInlinedFunctionInfo(); @@ -106,31 +131,39 @@ void SBBlock::AppendVariables(bool can_create, bool get_parent_variables, } SBBlock SBBlock::GetParent() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBBlock, SBBlock, GetParent); + SBBlock sb_block; if (m_opaque_ptr) sb_block.m_opaque_ptr = m_opaque_ptr->GetParent(); - return sb_block; + return LLDB_RECORD_RESULT(sb_block); } lldb::SBBlock SBBlock::GetContainingInlinedBlock() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBBlock, SBBlock, GetContainingInlinedBlock); + SBBlock sb_block; if (m_opaque_ptr) sb_block.m_opaque_ptr = m_opaque_ptr->GetContainingInlinedBlock(); - return sb_block; + return LLDB_RECORD_RESULT(sb_block); } SBBlock SBBlock::GetSibling() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBBlock, SBBlock, GetSibling); + SBBlock sb_block; if (m_opaque_ptr) sb_block.m_opaque_ptr = m_opaque_ptr->GetSibling(); - return sb_block; + return LLDB_RECORD_RESULT(sb_block); } SBBlock SBBlock::GetFirstChild() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBBlock, SBBlock, GetFirstChild); + SBBlock sb_block; if (m_opaque_ptr) sb_block.m_opaque_ptr = m_opaque_ptr->GetFirstChild(); - return sb_block; + return LLDB_RECORD_RESULT(sb_block); } lldb_private::Block *SBBlock::GetPtr() { return m_opaque_ptr; } @@ -138,6 +171,9 @@ lldb_private::Block *SBBlock::GetPtr() { return m_opaque_ptr; } void SBBlock::SetPtr(lldb_private::Block *block) { m_opaque_ptr = block; } bool SBBlock::GetDescription(SBStream &description) { + LLDB_RECORD_METHOD(bool, SBBlock, GetDescription, (lldb::SBStream &), + description); + Stream &strm = description.ref(); if (m_opaque_ptr) { @@ -160,12 +196,17 @@ bool SBBlock::GetDescription(SBStream &description) { } uint32_t SBBlock::GetNumRanges() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBBlock, GetNumRanges); + if (m_opaque_ptr) return m_opaque_ptr->GetNumRanges(); return 0; } lldb::SBAddress SBBlock::GetRangeStartAddress(uint32_t idx) { + LLDB_RECORD_METHOD(lldb::SBAddress, SBBlock, GetRangeStartAddress, (uint32_t), + idx); + lldb::SBAddress sb_addr; if (m_opaque_ptr) { AddressRange range; @@ -173,10 +214,13 @@ lldb::SBAddress SBBlock::GetRangeStartAddress(uint32_t idx) { sb_addr.ref() = range.GetBaseAddress(); } } - return sb_addr; + return LLDB_RECORD_RESULT(sb_addr); } lldb::SBAddress SBBlock::GetRangeEndAddress(uint32_t idx) { + LLDB_RECORD_METHOD(lldb::SBAddress, SBBlock, GetRangeEndAddress, (uint32_t), + idx); + lldb::SBAddress sb_addr; if (m_opaque_ptr) { AddressRange range; @@ -185,10 +229,13 @@ lldb::SBAddress SBBlock::GetRangeEndAddress(uint32_t idx) { sb_addr.ref().Slide(range.GetByteSize()); } } - return sb_addr; + return LLDB_RECORD_RESULT(sb_addr); } uint32_t SBBlock::GetRangeIndexForBlockAddress(lldb::SBAddress block_addr) { + LLDB_RECORD_METHOD(uint32_t, SBBlock, GetRangeIndexForBlockAddress, + (lldb::SBAddress), block_addr); + if (m_opaque_ptr && block_addr.IsValid()) { return m_opaque_ptr->GetRangeIndexContainingAddress(block_addr.ref()); } @@ -199,6 +246,11 @@ uint32_t SBBlock::GetRangeIndexForBlockAddress(lldb::SBAddress block_addr) { lldb::SBValueList SBBlock::GetVariables(lldb::SBFrame &frame, bool arguments, bool locals, bool statics, lldb::DynamicValueType use_dynamic) { + LLDB_RECORD_METHOD( + lldb::SBValueList, SBBlock, GetVariables, + (lldb::SBFrame &, bool, bool, bool, lldb::DynamicValueType), frame, + arguments, locals, statics, use_dynamic); + Block *block = GetPtr(); SBValueList value_list; if (block) { @@ -245,11 +297,15 @@ lldb::SBValueList SBBlock::GetVariables(lldb::SBFrame &frame, bool arguments, } } } - return value_list; + return LLDB_RECORD_RESULT(value_list); } lldb::SBValueList SBBlock::GetVariables(lldb::SBTarget &target, bool arguments, bool locals, bool statics) { + LLDB_RECORD_METHOD(lldb::SBValueList, SBBlock, GetVariables, + (lldb::SBTarget &, bool, bool, bool), target, arguments, + locals, statics); + Block *block = GetPtr(); SBValueList value_list; @@ -293,5 +349,44 @@ lldb::SBValueList SBBlock::GetVariables(lldb::SBTarget &target, bool arguments, } } } - return value_list; + return LLDB_RECORD_RESULT(value_list); +} + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBBlock>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBBlock, ()); + LLDB_REGISTER_CONSTRUCTOR(SBBlock, (const lldb::SBBlock &)); + LLDB_REGISTER_METHOD(const lldb::SBBlock &, + SBBlock, operator=,(const lldb::SBBlock &)); + LLDB_REGISTER_METHOD_CONST(bool, SBBlock, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBBlock, operator bool, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBBlock, IsInlined, ()); + LLDB_REGISTER_METHOD_CONST(const char *, SBBlock, GetInlinedName, ()); + LLDB_REGISTER_METHOD_CONST(lldb::SBFileSpec, SBBlock, + GetInlinedCallSiteFile, ()); + LLDB_REGISTER_METHOD_CONST(uint32_t, SBBlock, GetInlinedCallSiteLine, ()); + LLDB_REGISTER_METHOD_CONST(uint32_t, SBBlock, GetInlinedCallSiteColumn, ()); + LLDB_REGISTER_METHOD(lldb::SBBlock, SBBlock, GetParent, ()); + LLDB_REGISTER_METHOD(lldb::SBBlock, SBBlock, GetContainingInlinedBlock, ()); + LLDB_REGISTER_METHOD(lldb::SBBlock, SBBlock, GetSibling, ()); + LLDB_REGISTER_METHOD(lldb::SBBlock, SBBlock, GetFirstChild, ()); + LLDB_REGISTER_METHOD(bool, SBBlock, GetDescription, (lldb::SBStream &)); + LLDB_REGISTER_METHOD(uint32_t, SBBlock, GetNumRanges, ()); + LLDB_REGISTER_METHOD(lldb::SBAddress, SBBlock, GetRangeStartAddress, + (uint32_t)); + LLDB_REGISTER_METHOD(lldb::SBAddress, SBBlock, GetRangeEndAddress, + (uint32_t)); + LLDB_REGISTER_METHOD(uint32_t, SBBlock, GetRangeIndexForBlockAddress, + (lldb::SBAddress)); + LLDB_REGISTER_METHOD( + lldb::SBValueList, SBBlock, GetVariables, + (lldb::SBFrame &, bool, bool, bool, lldb::DynamicValueType)); + LLDB_REGISTER_METHOD(lldb::SBValueList, SBBlock, GetVariables, + (lldb::SBTarget &, bool, bool, bool)); +} + +} } diff --git a/source/API/SBBreakpoint.cpp b/source/API/SBBreakpoint.cpp index b6720071e17c7..45eaea6b61819 100644 --- a/source/API/SBBreakpoint.cpp +++ b/source/API/SBBreakpoint.cpp @@ -1,13 +1,13 @@ //===-- SBBreakpoint.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBBreakpoint.h" +#include "SBReproducerPrivate.h" #include "lldb/API/SBBreakpointLocation.h" #include "lldb/API/SBDebugger.h" #include "lldb/API/SBEvent.h" @@ -32,7 +32,6 @@ #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadSpec.h" -#include "lldb/Utility/Log.h" #include "lldb/Utility/Stream.h" #include "SBBreakpointOptionCommon.h" @@ -44,42 +43,60 @@ using namespace lldb; using namespace lldb_private; -SBBreakpoint::SBBreakpoint() {} +SBBreakpoint::SBBreakpoint() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBBreakpoint); } SBBreakpoint::SBBreakpoint(const SBBreakpoint &rhs) - : m_opaque_wp(rhs.m_opaque_wp) {} + : m_opaque_wp(rhs.m_opaque_wp) { + LLDB_RECORD_CONSTRUCTOR(SBBreakpoint, (const lldb::SBBreakpoint &), rhs); +} SBBreakpoint::SBBreakpoint(const lldb::BreakpointSP &bp_sp) - : m_opaque_wp(bp_sp) {} + : m_opaque_wp(bp_sp) { + LLDB_RECORD_CONSTRUCTOR(SBBreakpoint, (const lldb::BreakpointSP &), bp_sp); +} SBBreakpoint::~SBBreakpoint() = default; const SBBreakpoint &SBBreakpoint::operator=(const SBBreakpoint &rhs) { + LLDB_RECORD_METHOD(const lldb::SBBreakpoint &, + SBBreakpoint, operator=,(const lldb::SBBreakpoint &), rhs); + m_opaque_wp = rhs.m_opaque_wp; - return *this; + return LLDB_RECORD_RESULT(*this); } bool SBBreakpoint::operator==(const lldb::SBBreakpoint &rhs) { + LLDB_RECORD_METHOD( + bool, SBBreakpoint, operator==,(const lldb::SBBreakpoint &), rhs); + return m_opaque_wp.lock() == rhs.m_opaque_wp.lock(); } bool SBBreakpoint::operator!=(const lldb::SBBreakpoint &rhs) { + LLDB_RECORD_METHOD( + bool, SBBreakpoint, operator!=,(const lldb::SBBreakpoint &), rhs); + return m_opaque_wp.lock() != rhs.m_opaque_wp.lock(); } break_id_t SBBreakpoint::GetID() const { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::break_id_t, SBBreakpoint, GetID); break_id_t break_id = LLDB_INVALID_BREAK_ID; BreakpointSP bkpt_sp = GetSP(); if (bkpt_sp) break_id = bkpt_sp->GetID(); - LLDB_LOG(log, "breakpoint = {0}, id = {1}", bkpt_sp.get(), break_id); return break_id; } bool SBBreakpoint::IsValid() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpoint, IsValid); + return this->operator bool(); +} +SBBreakpoint::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpoint, operator bool); + BreakpointSP bkpt_sp = GetSP(); if (!bkpt_sp) return false; @@ -90,6 +107,8 @@ bool SBBreakpoint::IsValid() const { } void SBBreakpoint::ClearAllBreakpointSites() { + LLDB_RECORD_METHOD_NO_ARGS(void, SBBreakpoint, ClearAllBreakpointSites); + BreakpointSP bkpt_sp = GetSP(); if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( @@ -99,6 +118,9 @@ void SBBreakpoint::ClearAllBreakpointSites() { } SBBreakpointLocation SBBreakpoint::FindLocationByAddress(addr_t vm_addr) { + LLDB_RECORD_METHOD(lldb::SBBreakpointLocation, SBBreakpoint, + FindLocationByAddress, (lldb::addr_t), vm_addr); + SBBreakpointLocation sb_bp_location; BreakpointSP bkpt_sp = GetSP(); @@ -114,10 +136,13 @@ SBBreakpointLocation SBBreakpoint::FindLocationByAddress(addr_t vm_addr) { sb_bp_location.SetLocation(bkpt_sp->FindLocationByAddress(address)); } } - return sb_bp_location; + return LLDB_RECORD_RESULT(sb_bp_location); } break_id_t SBBreakpoint::FindLocationIDByAddress(addr_t vm_addr) { + LLDB_RECORD_METHOD(lldb::break_id_t, SBBreakpoint, FindLocationIDByAddress, + (lldb::addr_t), vm_addr); + break_id_t break_id = LLDB_INVALID_BREAK_ID; BreakpointSP bkpt_sp = GetSP(); @@ -136,6 +161,9 @@ break_id_t SBBreakpoint::FindLocationIDByAddress(addr_t vm_addr) { } SBBreakpointLocation SBBreakpoint::FindLocationByID(break_id_t bp_loc_id) { + LLDB_RECORD_METHOD(lldb::SBBreakpointLocation, SBBreakpoint, FindLocationByID, + (lldb::break_id_t), bp_loc_id); + SBBreakpointLocation sb_bp_location; BreakpointSP bkpt_sp = GetSP(); @@ -145,10 +173,13 @@ SBBreakpointLocation SBBreakpoint::FindLocationByID(break_id_t bp_loc_id) { sb_bp_location.SetLocation(bkpt_sp->FindLocationByID(bp_loc_id)); } - return sb_bp_location; + return LLDB_RECORD_RESULT(sb_bp_location); } SBBreakpointLocation SBBreakpoint::GetLocationAtIndex(uint32_t index) { + LLDB_RECORD_METHOD(lldb::SBBreakpointLocation, SBBreakpoint, + GetLocationAtIndex, (uint32_t), index); + SBBreakpointLocation sb_bp_location; BreakpointSP bkpt_sp = GetSP(); @@ -158,14 +189,13 @@ SBBreakpointLocation SBBreakpoint::GetLocationAtIndex(uint32_t index) { sb_bp_location.SetLocation(bkpt_sp->GetLocationAtIndex(index)); } - return sb_bp_location; + return LLDB_RECORD_RESULT(sb_bp_location); } void SBBreakpoint::SetEnabled(bool enable) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - BreakpointSP bkpt_sp = GetSP(); + LLDB_RECORD_METHOD(void, SBBreakpoint, SetEnabled, (bool), enable); - LLDB_LOG(log, "breakpoint = {0}, enable = {1}", bkpt_sp.get(), enable); + BreakpointSP bkpt_sp = GetSP(); if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( @@ -175,6 +205,8 @@ void SBBreakpoint::SetEnabled(bool enable) { } bool SBBreakpoint::IsEnabled() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBBreakpoint, IsEnabled); + BreakpointSP bkpt_sp = GetSP(); if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( @@ -185,10 +217,9 @@ bool SBBreakpoint::IsEnabled() { } void SBBreakpoint::SetOneShot(bool one_shot) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - BreakpointSP bkpt_sp = GetSP(); + LLDB_RECORD_METHOD(void, SBBreakpoint, SetOneShot, (bool), one_shot); - LLDB_LOG(log, "breakpoint = {0}, one_shot = {1}", bkpt_sp.get(), one_shot); + BreakpointSP bkpt_sp = GetSP(); if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( @@ -198,6 +229,8 @@ void SBBreakpoint::SetOneShot(bool one_shot) { } bool SBBreakpoint::IsOneShot() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpoint, IsOneShot); + BreakpointSP bkpt_sp = GetSP(); if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( @@ -208,6 +241,8 @@ bool SBBreakpoint::IsOneShot() const { } bool SBBreakpoint::IsInternal() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBBreakpoint, IsInternal); + BreakpointSP bkpt_sp = GetSP(); if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( @@ -218,10 +253,9 @@ bool SBBreakpoint::IsInternal() { } void SBBreakpoint::SetIgnoreCount(uint32_t count) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - BreakpointSP bkpt_sp = GetSP(); + LLDB_RECORD_METHOD(void, SBBreakpoint, SetIgnoreCount, (uint32_t), count); - LLDB_LOG(log, "breakpoint = {0}, count = {1}", bkpt_sp.get(), count); + BreakpointSP bkpt_sp = GetSP(); if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( @@ -231,6 +265,9 @@ void SBBreakpoint::SetIgnoreCount(uint32_t count) { } void SBBreakpoint::SetCondition(const char *condition) { + LLDB_RECORD_METHOD(void, SBBreakpoint, SetCondition, (const char *), + condition); + BreakpointSP bkpt_sp = GetSP(); if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( @@ -240,6 +277,8 @@ void SBBreakpoint::SetCondition(const char *condition) { } const char *SBBreakpoint::GetCondition() { + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBBreakpoint, GetCondition); + BreakpointSP bkpt_sp = GetSP(); if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( @@ -250,6 +289,9 @@ const char *SBBreakpoint::GetCondition() { } void SBBreakpoint::SetAutoContinue(bool auto_continue) { + LLDB_RECORD_METHOD(void, SBBreakpoint, SetAutoContinue, (bool), + auto_continue); + BreakpointSP bkpt_sp = GetSP(); if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( @@ -259,6 +301,8 @@ void SBBreakpoint::SetAutoContinue(bool auto_continue) { } bool SBBreakpoint::GetAutoContinue() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBBreakpoint, GetAutoContinue); + BreakpointSP bkpt_sp = GetSP(); if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( @@ -269,6 +313,8 @@ bool SBBreakpoint::GetAutoContinue() { } uint32_t SBBreakpoint::GetHitCount() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBBreakpoint, GetHitCount); + uint32_t count = 0; BreakpointSP bkpt_sp = GetSP(); if (bkpt_sp) { @@ -277,13 +323,12 @@ uint32_t SBBreakpoint::GetHitCount() const { count = bkpt_sp->GetHitCount(); } - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - LLDB_LOG(log, "breakpoint = {0}, count = {1}", bkpt_sp.get(), count); - return count; } uint32_t SBBreakpoint::GetIgnoreCount() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBBreakpoint, GetIgnoreCount); + uint32_t count = 0; BreakpointSP bkpt_sp = GetSP(); if (bkpt_sp) { @@ -292,24 +337,23 @@ uint32_t SBBreakpoint::GetIgnoreCount() const { count = bkpt_sp->GetIgnoreCount(); } - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - LLDB_LOG(log, "breakpoint = {0}, count = {1}", bkpt_sp.get(), count); - return count; } void SBBreakpoint::SetThreadID(tid_t tid) { + LLDB_RECORD_METHOD(void, SBBreakpoint, SetThreadID, (lldb::tid_t), tid); + BreakpointSP bkpt_sp = GetSP(); if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( bkpt_sp->GetTarget().GetAPIMutex()); bkpt_sp->SetThreadID(tid); } - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - LLDB_LOG(log, "breakpoint = {0}, tid = {1:x}", bkpt_sp.get(), tid); } tid_t SBBreakpoint::GetThreadID() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::tid_t, SBBreakpoint, GetThreadID); + tid_t tid = LLDB_INVALID_THREAD_ID; BreakpointSP bkpt_sp = GetSP(); if (bkpt_sp) { @@ -318,15 +362,13 @@ tid_t SBBreakpoint::GetThreadID() { tid = bkpt_sp->GetThreadID(); } - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - LLDB_LOG(log, "breakpoint = {0}, tid = {1:x}", bkpt_sp.get(), tid); return tid; } void SBBreakpoint::SetThreadIndex(uint32_t index) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(void, SBBreakpoint, SetThreadIndex, (uint32_t), index); + BreakpointSP bkpt_sp = GetSP(); - LLDB_LOG(log, "breakpoint = {0}, index = {1}", bkpt_sp.get(), index); if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( bkpt_sp->GetTarget().GetAPIMutex()); @@ -335,6 +377,8 @@ void SBBreakpoint::SetThreadIndex(uint32_t index) { } uint32_t SBBreakpoint::GetThreadIndex() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBBreakpoint, GetThreadIndex); + uint32_t thread_idx = UINT32_MAX; BreakpointSP bkpt_sp = GetSP(); if (bkpt_sp) { @@ -345,16 +389,15 @@ uint32_t SBBreakpoint::GetThreadIndex() const { if (thread_spec != nullptr) thread_idx = thread_spec->GetIndex(); } - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - LLDB_LOG(log, "breakpoint = {0}, index = {1}", bkpt_sp.get(), thread_idx); return thread_idx; } void SBBreakpoint::SetThreadName(const char *thread_name) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(void, SBBreakpoint, SetThreadName, (const char *), + thread_name); + BreakpointSP bkpt_sp = GetSP(); - LLDB_LOG(log, "breakpoint = {0}, name = {1}", bkpt_sp.get(), thread_name); if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( @@ -364,6 +407,8 @@ void SBBreakpoint::SetThreadName(const char *thread_name) { } const char *SBBreakpoint::GetThreadName() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBBreakpoint, GetThreadName); + const char *name = nullptr; BreakpointSP bkpt_sp = GetSP(); if (bkpt_sp) { @@ -374,17 +419,15 @@ const char *SBBreakpoint::GetThreadName() const { if (thread_spec != nullptr) name = thread_spec->GetName(); } - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - LLDB_LOG(log, "breakpoint = {0}, name = {1}", bkpt_sp.get(), name); return name; } void SBBreakpoint::SetQueueName(const char *queue_name) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(void, SBBreakpoint, SetQueueName, (const char *), + queue_name); + BreakpointSP bkpt_sp = GetSP(); - LLDB_LOG(log, "breakpoint = {0}, queue_name = {1}", bkpt_sp.get(), - queue_name); if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( bkpt_sp->GetTarget().GetAPIMutex()); @@ -393,6 +436,8 @@ void SBBreakpoint::SetQueueName(const char *queue_name) { } const char *SBBreakpoint::GetQueueName() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBBreakpoint, GetQueueName); + const char *name = nullptr; BreakpointSP bkpt_sp = GetSP(); if (bkpt_sp) { @@ -403,13 +448,14 @@ const char *SBBreakpoint::GetQueueName() const { if (thread_spec) name = thread_spec->GetQueueName(); } - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - LLDB_LOG(log, "breakpoint = {0}, name = {1}", bkpt_sp.get(), name); return name; } size_t SBBreakpoint::GetNumResolvedLocations() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(size_t, SBBreakpoint, + GetNumResolvedLocations); + size_t num_resolved = 0; BreakpointSP bkpt_sp = GetSP(); if (bkpt_sp) { @@ -417,13 +463,12 @@ size_t SBBreakpoint::GetNumResolvedLocations() const { bkpt_sp->GetTarget().GetAPIMutex()); num_resolved = bkpt_sp->GetNumResolvedLocations(); } - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - LLDB_LOG(log, "breakpoint = {0}, num_resolved = {1}", bkpt_sp.get(), - num_resolved); return num_resolved; } size_t SBBreakpoint::GetNumLocations() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(size_t, SBBreakpoint, GetNumLocations); + BreakpointSP bkpt_sp = GetSP(); size_t num_locs = 0; if (bkpt_sp) { @@ -431,12 +476,13 @@ size_t SBBreakpoint::GetNumLocations() const { bkpt_sp->GetTarget().GetAPIMutex()); num_locs = bkpt_sp->GetNumLocations(); } - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - LLDB_LOG(log, "breakpoint = {0}, num_locs = {1}", bkpt_sp.get(), num_locs); return num_locs; } void SBBreakpoint::SetCommandLineCommands(SBStringList &commands) { + LLDB_RECORD_METHOD(void, SBBreakpoint, SetCommandLineCommands, + (lldb::SBStringList &), commands); + BreakpointSP bkpt_sp = GetSP(); if (!bkpt_sp) return; @@ -452,6 +498,9 @@ void SBBreakpoint::SetCommandLineCommands(SBStringList &commands) { } bool SBBreakpoint::GetCommandLineCommands(SBStringList &commands) { + LLDB_RECORD_METHOD(bool, SBBreakpoint, GetCommandLineCommands, + (lldb::SBStringList &), commands); + BreakpointSP bkpt_sp = GetSP(); if (!bkpt_sp) return false; @@ -464,10 +513,15 @@ bool SBBreakpoint::GetCommandLineCommands(SBStringList &commands) { } bool SBBreakpoint::GetDescription(SBStream &s) { + LLDB_RECORD_METHOD(bool, SBBreakpoint, GetDescription, (lldb::SBStream &), s); + return GetDescription(s, true); } bool SBBreakpoint::GetDescription(SBStream &s, bool include_locations) { + LLDB_RECORD_METHOD(bool, SBBreakpoint, GetDescription, + (lldb::SBStream &, bool), s, include_locations); + BreakpointSP bkpt_sp = GetSP(); if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( @@ -485,47 +539,45 @@ bool SBBreakpoint::GetDescription(SBStream &s, bool include_locations) { return false; } -SBError -SBBreakpoint::AddLocation(SBAddress &address) { - BreakpointSP bkpt_sp = GetSP(); - SBError error; - - if (!address.IsValid()) { - error.SetErrorString("Can't add an invalid address."); - return error; - } - - if (!bkpt_sp) { - error.SetErrorString("No breakpoint to add a location to."); - return error; - } - - if (!llvm::isa<BreakpointResolverScripted>(bkpt_sp->GetResolver().get())) { - error.SetErrorString("Only a scripted resolver can add locations."); - return error; - } - - if (bkpt_sp->GetSearchFilter()->AddressPasses(address.ref())) - bkpt_sp->AddLocation(address.ref()); - else - { - StreamString s; - address.get()->Dump(&s, &bkpt_sp->GetTarget(), - Address::DumpStyleModuleWithFileAddress); - error.SetErrorStringWithFormat("Address: %s didn't pass the filter.", - s.GetData()); - } - return error; +SBError SBBreakpoint::AddLocation(SBAddress &address) { + LLDB_RECORD_METHOD(lldb::SBError, SBBreakpoint, AddLocation, + (lldb::SBAddress &), address); + + BreakpointSP bkpt_sp = GetSP(); + SBError error; + + if (!address.IsValid()) { + error.SetErrorString("Can't add an invalid address."); + return LLDB_RECORD_RESULT(error); + } + + if (!bkpt_sp) { + error.SetErrorString("No breakpoint to add a location to."); + return LLDB_RECORD_RESULT(error); + } + + if (!llvm::isa<BreakpointResolverScripted>(bkpt_sp->GetResolver().get())) { + error.SetErrorString("Only a scripted resolver can add locations."); + return LLDB_RECORD_RESULT(error); + } + + if (bkpt_sp->GetSearchFilter()->AddressPasses(address.ref())) + bkpt_sp->AddLocation(address.ref()); + else { + StreamString s; + address.get()->Dump(&s, &bkpt_sp->GetTarget(), + Address::DumpStyleModuleWithFileAddress); + error.SetErrorStringWithFormat("Address: %s didn't pass the filter.", + s.GetData()); + } + return LLDB_RECORD_RESULT(error); } +void SBBreakpoint ::SetCallback(SBBreakpointHitCallback callback, void *baton) { + LLDB_RECORD_DUMMY(void, SBBreakpoint, SetCallback, + (lldb::SBBreakpointHitCallback, void *), callback, baton); -void SBBreakpoint - ::SetCallback(SBBreakpointHitCallback callback, - void *baton) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); BreakpointSP bkpt_sp = GetSP(); - LLDB_LOG(log, "breakpoint = {0}, callback = {1}, baton = {2}", bkpt_sp.get(), - callback, baton); if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( @@ -539,10 +591,10 @@ void SBBreakpoint void SBBreakpoint::SetScriptCallbackFunction( const char *callback_function_name) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(void, SBBreakpoint, SetScriptCallbackFunction, + (const char *), callback_function_name); + BreakpointSP bkpt_sp = GetSP(); - LLDB_LOG(log, "breakpoint = {0}, callback = {1}", bkpt_sp.get(), - callback_function_name); if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( @@ -550,7 +602,6 @@ void SBBreakpoint::SetScriptCallbackFunction( BreakpointOptions *bp_options = bkpt_sp->GetOptions(); bkpt_sp->GetTarget() .GetDebugger() - .GetCommandInterpreter() .GetScriptInterpreter() ->SetBreakpointCommandCallbackFunction(bp_options, callback_function_name); @@ -558,10 +609,10 @@ void SBBreakpoint::SetScriptCallbackFunction( } SBError SBBreakpoint::SetScriptCallbackBody(const char *callback_body_text) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(lldb::SBError, SBBreakpoint, SetScriptCallbackBody, + (const char *), callback_body_text); + BreakpointSP bkpt_sp = GetSP(); - LLDB_LOG(log, "breakpoint = {0}, callback body:\n{1}", bkpt_sp.get(), - callback_body_text); SBError sb_error; if (bkpt_sp) { @@ -571,20 +622,19 @@ SBError SBBreakpoint::SetScriptCallbackBody(const char *callback_body_text) { Status error = bkpt_sp->GetTarget() .GetDebugger() - .GetCommandInterpreter() .GetScriptInterpreter() ->SetBreakpointCommandCallback(bp_options, callback_body_text); sb_error.SetError(error); } else sb_error.SetErrorString("invalid breakpoint"); - return sb_error; + return LLDB_RECORD_RESULT(sb_error); } bool SBBreakpoint::AddName(const char *new_name) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(bool, SBBreakpoint, AddName, (const char *), new_name); + BreakpointSP bkpt_sp = GetSP(); - LLDB_LOG(log, "breakpoint = {0}, name = {1}", bkpt_sp.get(), new_name); if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( @@ -593,34 +643,30 @@ bool SBBreakpoint::AddName(const char *new_name) { // probably more annoying to have to provide it. bkpt_sp->GetTarget().AddNameToBreakpoint(bkpt_sp, new_name, error); if (error.Fail()) - { - if (log) - log->Printf("Failed to add name: '%s' to breakpoint: %s", - new_name, error.AsCString()); return false; - } } return true; } void SBBreakpoint::RemoveName(const char *name_to_remove) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(void, SBBreakpoint, RemoveName, (const char *), + name_to_remove); + BreakpointSP bkpt_sp = GetSP(); - LLDB_LOG(log, "breakpoint = {0}, name = {1}", bkpt_sp.get(), name_to_remove); if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( bkpt_sp->GetTarget().GetAPIMutex()); - bkpt_sp->GetTarget().RemoveNameFromBreakpoint(bkpt_sp, - ConstString(name_to_remove)); + bkpt_sp->GetTarget().RemoveNameFromBreakpoint(bkpt_sp, + ConstString(name_to_remove)); } } bool SBBreakpoint::MatchesName(const char *name) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(bool, SBBreakpoint, MatchesName, (const char *), name); + BreakpointSP bkpt_sp = GetSP(); - LLDB_LOG(log, "breakpoint = {0}, name = {1}", bkpt_sp.get(), name); if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( @@ -632,9 +678,10 @@ bool SBBreakpoint::MatchesName(const char *name) { } void SBBreakpoint::GetNames(SBStringList &names) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(void, SBBreakpoint, GetNames, (lldb::SBStringList &), + names); + BreakpointSP bkpt_sp = GetSP(); - LLDB_LOG(log, "breakpoint = {0}", bkpt_sp.get()); if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( @@ -648,12 +695,19 @@ void SBBreakpoint::GetNames(SBStringList &names) { } bool SBBreakpoint::EventIsBreakpointEvent(const lldb::SBEvent &event) { + LLDB_RECORD_STATIC_METHOD(bool, SBBreakpoint, EventIsBreakpointEvent, + (const lldb::SBEvent &), event); + return Breakpoint::BreakpointEventData::GetEventDataFromEvent(event.get()) != nullptr; } BreakpointEventType SBBreakpoint::GetBreakpointEventTypeFromEvent(const SBEvent &event) { + LLDB_RECORD_STATIC_METHOD(lldb::BreakpointEventType, SBBreakpoint, + GetBreakpointEventTypeFromEvent, + (const lldb::SBEvent &), event); + if (event.IsValid()) return Breakpoint::BreakpointEventData::GetBreakpointEventTypeFromEvent( event.GetSP()); @@ -661,25 +715,38 @@ SBBreakpoint::GetBreakpointEventTypeFromEvent(const SBEvent &event) { } SBBreakpoint SBBreakpoint::GetBreakpointFromEvent(const lldb::SBEvent &event) { + LLDB_RECORD_STATIC_METHOD(lldb::SBBreakpoint, SBBreakpoint, + GetBreakpointFromEvent, (const lldb::SBEvent &), + event); + if (event.IsValid()) - return SBBreakpoint( - Breakpoint::BreakpointEventData::GetBreakpointFromEvent(event.GetSP())); - return SBBreakpoint(); + return LLDB_RECORD_RESULT( + SBBreakpoint(Breakpoint::BreakpointEventData::GetBreakpointFromEvent( + event.GetSP()))); + return LLDB_RECORD_RESULT(SBBreakpoint()); } SBBreakpointLocation SBBreakpoint::GetBreakpointLocationAtIndexFromEvent(const lldb::SBEvent &event, uint32_t loc_idx) { + LLDB_RECORD_STATIC_METHOD(lldb::SBBreakpointLocation, SBBreakpoint, + GetBreakpointLocationAtIndexFromEvent, + (const lldb::SBEvent &, uint32_t), event, loc_idx); + SBBreakpointLocation sb_breakpoint_loc; if (event.IsValid()) sb_breakpoint_loc.SetLocation( Breakpoint::BreakpointEventData::GetBreakpointLocationAtIndexFromEvent( event.GetSP(), loc_idx)); - return sb_breakpoint_loc; + return LLDB_RECORD_RESULT(sb_breakpoint_loc); } uint32_t SBBreakpoint::GetNumBreakpointLocationsFromEvent(const lldb::SBEvent &event) { + LLDB_RECORD_STATIC_METHOD(uint32_t, SBBreakpoint, + GetNumBreakpointLocationsFromEvent, + (const lldb::SBEvent &), event); + uint32_t num_locations = 0; if (event.IsValid()) num_locations = @@ -689,6 +756,8 @@ SBBreakpoint::GetNumBreakpointLocationsFromEvent(const lldb::SBEvent &event) { } bool SBBreakpoint::IsHardware() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpoint, IsHardware); + BreakpointSP bkpt_sp = GetSP(); if (bkpt_sp) return bkpt_sp->IsHardware(); @@ -782,11 +851,15 @@ private: }; SBBreakpointList::SBBreakpointList(SBTarget &target) - : m_opaque_sp(new SBBreakpointListImpl(target.GetSP())) {} + : m_opaque_sp(new SBBreakpointListImpl(target.GetSP())) { + LLDB_RECORD_CONSTRUCTOR(SBBreakpointList, (lldb::SBTarget &), target); +} SBBreakpointList::~SBBreakpointList() {} size_t SBBreakpointList::GetSize() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(size_t, SBBreakpointList, GetSize); + if (!m_opaque_sp) return 0; else @@ -794,21 +867,30 @@ size_t SBBreakpointList::GetSize() const { } SBBreakpoint SBBreakpointList::GetBreakpointAtIndex(size_t idx) { + LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBBreakpointList, GetBreakpointAtIndex, + (size_t), idx); + if (!m_opaque_sp) - return SBBreakpoint(); + return LLDB_RECORD_RESULT(SBBreakpoint()); BreakpointSP bkpt_sp = m_opaque_sp->GetBreakpointAtIndex(idx); - return SBBreakpoint(bkpt_sp); + return LLDB_RECORD_RESULT(SBBreakpoint(bkpt_sp)); } SBBreakpoint SBBreakpointList::FindBreakpointByID(lldb::break_id_t id) { + LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBBreakpointList, FindBreakpointByID, + (lldb::break_id_t), id); + if (!m_opaque_sp) - return SBBreakpoint(); + return LLDB_RECORD_RESULT(SBBreakpoint()); BreakpointSP bkpt_sp = m_opaque_sp->FindBreakpointByID(id); - return SBBreakpoint(bkpt_sp); + return LLDB_RECORD_RESULT(SBBreakpoint(bkpt_sp)); } void SBBreakpointList::Append(const SBBreakpoint &sb_bkpt) { + LLDB_RECORD_METHOD(void, SBBreakpointList, Append, + (const lldb::SBBreakpoint &), sb_bkpt); + if (!sb_bkpt.IsValid()) return; if (!m_opaque_sp) @@ -817,12 +899,18 @@ void SBBreakpointList::Append(const SBBreakpoint &sb_bkpt) { } void SBBreakpointList::AppendByID(lldb::break_id_t id) { + LLDB_RECORD_METHOD(void, SBBreakpointList, AppendByID, (lldb::break_id_t), + id); + if (!m_opaque_sp) return; m_opaque_sp->AppendByID(id); } bool SBBreakpointList::AppendIfUnique(const SBBreakpoint &sb_bkpt) { + LLDB_RECORD_METHOD(bool, SBBreakpointList, AppendIfUnique, + (const lldb::SBBreakpoint &), sb_bkpt); + if (!sb_bkpt.IsValid()) return false; if (!m_opaque_sp) @@ -831,6 +919,8 @@ bool SBBreakpointList::AppendIfUnique(const SBBreakpoint &sb_bkpt) { } void SBBreakpointList::Clear() { + LLDB_RECORD_METHOD_NO_ARGS(void, SBBreakpointList, Clear); + if (m_opaque_sp) m_opaque_sp->Clear(); } @@ -840,3 +930,107 @@ void SBBreakpointList::CopyToBreakpointIDList( if (m_opaque_sp) m_opaque_sp->CopyToBreakpointIDList(bp_id_list); } + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBBreakpoint>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBBreakpoint, ()); + LLDB_REGISTER_CONSTRUCTOR(SBBreakpoint, (const lldb::SBBreakpoint &)); + LLDB_REGISTER_CONSTRUCTOR(SBBreakpoint, (const lldb::BreakpointSP &)); + LLDB_REGISTER_METHOD(const lldb::SBBreakpoint &, + SBBreakpoint, operator=,(const lldb::SBBreakpoint &)); + LLDB_REGISTER_METHOD(bool, + SBBreakpoint, operator==,(const lldb::SBBreakpoint &)); + LLDB_REGISTER_METHOD(bool, + SBBreakpoint, operator!=,(const lldb::SBBreakpoint &)); + LLDB_REGISTER_METHOD_CONST(lldb::break_id_t, SBBreakpoint, GetID, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBBreakpoint, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBBreakpoint, operator bool, ()); + LLDB_REGISTER_METHOD(void, SBBreakpoint, ClearAllBreakpointSites, ()); + LLDB_REGISTER_METHOD(lldb::SBBreakpointLocation, SBBreakpoint, + FindLocationByAddress, (lldb::addr_t)); + LLDB_REGISTER_METHOD(lldb::break_id_t, SBBreakpoint, + FindLocationIDByAddress, (lldb::addr_t)); + LLDB_REGISTER_METHOD(lldb::SBBreakpointLocation, SBBreakpoint, + FindLocationByID, (lldb::break_id_t)); + LLDB_REGISTER_METHOD(lldb::SBBreakpointLocation, SBBreakpoint, + GetLocationAtIndex, (uint32_t)); + LLDB_REGISTER_METHOD(void, SBBreakpoint, SetEnabled, (bool)); + LLDB_REGISTER_METHOD(bool, SBBreakpoint, IsEnabled, ()); + LLDB_REGISTER_METHOD(void, SBBreakpoint, SetOneShot, (bool)); + LLDB_REGISTER_METHOD_CONST(bool, SBBreakpoint, IsOneShot, ()); + LLDB_REGISTER_METHOD(bool, SBBreakpoint, IsInternal, ()); + LLDB_REGISTER_METHOD(void, SBBreakpoint, SetIgnoreCount, (uint32_t)); + LLDB_REGISTER_METHOD(void, SBBreakpoint, SetCondition, (const char *)); + LLDB_REGISTER_METHOD(const char *, SBBreakpoint, GetCondition, ()); + LLDB_REGISTER_METHOD(void, SBBreakpoint, SetAutoContinue, (bool)); + LLDB_REGISTER_METHOD(bool, SBBreakpoint, GetAutoContinue, ()); + LLDB_REGISTER_METHOD_CONST(uint32_t, SBBreakpoint, GetHitCount, ()); + LLDB_REGISTER_METHOD_CONST(uint32_t, SBBreakpoint, GetIgnoreCount, ()); + LLDB_REGISTER_METHOD(void, SBBreakpoint, SetThreadID, (lldb::tid_t)); + LLDB_REGISTER_METHOD(lldb::tid_t, SBBreakpoint, GetThreadID, ()); + LLDB_REGISTER_METHOD(void, SBBreakpoint, SetThreadIndex, (uint32_t)); + LLDB_REGISTER_METHOD_CONST(uint32_t, SBBreakpoint, GetThreadIndex, ()); + LLDB_REGISTER_METHOD(void, SBBreakpoint, SetThreadName, (const char *)); + LLDB_REGISTER_METHOD_CONST(const char *, SBBreakpoint, GetThreadName, ()); + LLDB_REGISTER_METHOD(void, SBBreakpoint, SetQueueName, (const char *)); + LLDB_REGISTER_METHOD_CONST(const char *, SBBreakpoint, GetQueueName, ()); + LLDB_REGISTER_METHOD_CONST(size_t, SBBreakpoint, GetNumResolvedLocations, + ()); + LLDB_REGISTER_METHOD_CONST(size_t, SBBreakpoint, GetNumLocations, ()); + LLDB_REGISTER_METHOD(void, SBBreakpoint, SetCommandLineCommands, + (lldb::SBStringList &)); + LLDB_REGISTER_METHOD(bool, SBBreakpoint, GetCommandLineCommands, + (lldb::SBStringList &)); + LLDB_REGISTER_METHOD(bool, SBBreakpoint, GetDescription, + (lldb::SBStream &)); + LLDB_REGISTER_METHOD(bool, SBBreakpoint, GetDescription, + (lldb::SBStream &, bool)); + LLDB_REGISTER_METHOD(lldb::SBError, SBBreakpoint, AddLocation, + (lldb::SBAddress &)); + LLDB_REGISTER_METHOD(void, SBBreakpoint, SetScriptCallbackFunction, + (const char *)); + LLDB_REGISTER_METHOD(lldb::SBError, SBBreakpoint, SetScriptCallbackBody, + (const char *)); + LLDB_REGISTER_METHOD(bool, SBBreakpoint, AddName, (const char *)); + LLDB_REGISTER_METHOD(void, SBBreakpoint, RemoveName, (const char *)); + LLDB_REGISTER_METHOD(bool, SBBreakpoint, MatchesName, (const char *)); + LLDB_REGISTER_METHOD(void, SBBreakpoint, GetNames, (lldb::SBStringList &)); + LLDB_REGISTER_STATIC_METHOD(bool, SBBreakpoint, EventIsBreakpointEvent, + (const lldb::SBEvent &)); + LLDB_REGISTER_STATIC_METHOD(lldb::BreakpointEventType, SBBreakpoint, + GetBreakpointEventTypeFromEvent, + (const lldb::SBEvent &)); + LLDB_REGISTER_STATIC_METHOD(lldb::SBBreakpoint, SBBreakpoint, + GetBreakpointFromEvent, + (const lldb::SBEvent &)); + LLDB_REGISTER_STATIC_METHOD(lldb::SBBreakpointLocation, SBBreakpoint, + GetBreakpointLocationAtIndexFromEvent, + (const lldb::SBEvent &, uint32_t)); + LLDB_REGISTER_STATIC_METHOD(uint32_t, SBBreakpoint, + GetNumBreakpointLocationsFromEvent, + (const lldb::SBEvent &)); + LLDB_REGISTER_METHOD_CONST(bool, SBBreakpoint, IsHardware, ()); +} + +template <> +void RegisterMethods<SBBreakpointList>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBBreakpointList, (lldb::SBTarget &)); + LLDB_REGISTER_METHOD_CONST(size_t, SBBreakpointList, GetSize, ()); + LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBBreakpointList, + GetBreakpointAtIndex, (size_t)); + LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBBreakpointList, + FindBreakpointByID, (lldb::break_id_t)); + LLDB_REGISTER_METHOD(void, SBBreakpointList, Append, + (const lldb::SBBreakpoint &)); + LLDB_REGISTER_METHOD(void, SBBreakpointList, AppendByID, + (lldb::break_id_t)); + LLDB_REGISTER_METHOD(bool, SBBreakpointList, AppendIfUnique, + (const lldb::SBBreakpoint &)); + LLDB_REGISTER_METHOD(void, SBBreakpointList, Clear, ()); +} + +} +} diff --git a/source/API/SBBreakpointLocation.cpp b/source/API/SBBreakpointLocation.cpp index 99ac0277e7000..640545f55ef97 100644 --- a/source/API/SBBreakpointLocation.cpp +++ b/source/API/SBBreakpointLocation.cpp @@ -1,13 +1,13 @@ //===-- SBBreakpointLocation.cpp --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBBreakpointLocation.h" +#include "SBReproducerPrivate.h" #include "lldb/API/SBAddress.h" #include "lldb/API/SBDebugger.h" #include "lldb/API/SBDefines.h" @@ -22,7 +22,6 @@ #include "lldb/Interpreter/ScriptInterpreter.h" #include "lldb/Target/Target.h" #include "lldb/Target/ThreadSpec.h" -#include "lldb/Utility/Log.h" #include "lldb/Utility/Stream.h" #include "lldb/lldb-defines.h" #include "lldb/lldb-types.h" @@ -30,27 +29,32 @@ using namespace lldb; using namespace lldb_private; -SBBreakpointLocation::SBBreakpointLocation() {} +SBBreakpointLocation::SBBreakpointLocation() { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBBreakpointLocation); +} SBBreakpointLocation::SBBreakpointLocation( const lldb::BreakpointLocationSP &break_loc_sp) : m_opaque_wp(break_loc_sp) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - - if (log) { - SBStream sstr; - GetDescription(sstr, lldb::eDescriptionLevelBrief); - LLDB_LOG(log, "location = {0} ({1})", break_loc_sp.get(), sstr.GetData()); - } + LLDB_RECORD_CONSTRUCTOR(SBBreakpointLocation, + (const lldb::BreakpointLocationSP &), break_loc_sp); } SBBreakpointLocation::SBBreakpointLocation(const SBBreakpointLocation &rhs) - : m_opaque_wp(rhs.m_opaque_wp) {} + : m_opaque_wp(rhs.m_opaque_wp) { + LLDB_RECORD_CONSTRUCTOR(SBBreakpointLocation, + (const lldb::SBBreakpointLocation &), rhs); +} const SBBreakpointLocation &SBBreakpointLocation:: operator=(const SBBreakpointLocation &rhs) { + LLDB_RECORD_METHOD( + const lldb::SBBreakpointLocation &, + SBBreakpointLocation, operator=,(const lldb::SBBreakpointLocation &), + rhs); + m_opaque_wp = rhs.m_opaque_wp; - return *this; + return LLDB_RECORD_RESULT(*this); } SBBreakpointLocation::~SBBreakpointLocation() {} @@ -59,17 +63,31 @@ BreakpointLocationSP SBBreakpointLocation::GetSP() const { return m_opaque_wp.lock(); } -bool SBBreakpointLocation::IsValid() const { return bool(GetSP()); } +bool SBBreakpointLocation::IsValid() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpointLocation, IsValid); + return this->operator bool(); +} +SBBreakpointLocation::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpointLocation, operator bool); + + return bool(GetSP()); +} SBAddress SBBreakpointLocation::GetAddress() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBAddress, SBBreakpointLocation, GetAddress); + BreakpointLocationSP loc_sp = GetSP(); - if (loc_sp) - return SBAddress(&loc_sp->GetAddress()); - else - return SBAddress(); + if (loc_sp) { + return LLDB_RECORD_RESULT(SBAddress(&loc_sp->GetAddress())); + } + + return LLDB_RECORD_RESULT(SBAddress()); } addr_t SBBreakpointLocation::GetLoadAddress() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::addr_t, SBBreakpointLocation, + GetLoadAddress); + addr_t ret_addr = LLDB_INVALID_ADDRESS; BreakpointLocationSP loc_sp = GetSP(); @@ -83,6 +101,8 @@ addr_t SBBreakpointLocation::GetLoadAddress() { } void SBBreakpointLocation::SetEnabled(bool enabled) { + LLDB_RECORD_METHOD(void, SBBreakpointLocation, SetEnabled, (bool), enabled); + BreakpointLocationSP loc_sp = GetSP(); if (loc_sp) { std::lock_guard<std::recursive_mutex> guard( @@ -92,6 +112,8 @@ void SBBreakpointLocation::SetEnabled(bool enabled) { } bool SBBreakpointLocation::IsEnabled() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBBreakpointLocation, IsEnabled); + BreakpointLocationSP loc_sp = GetSP(); if (loc_sp) { std::lock_guard<std::recursive_mutex> guard( @@ -102,6 +124,8 @@ bool SBBreakpointLocation::IsEnabled() { } uint32_t SBBreakpointLocation::GetHitCount() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBBreakpointLocation, GetHitCount); + BreakpointLocationSP loc_sp = GetSP(); if (loc_sp) { std::lock_guard<std::recursive_mutex> guard( @@ -112,6 +136,8 @@ uint32_t SBBreakpointLocation::GetHitCount() { } uint32_t SBBreakpointLocation::GetIgnoreCount() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBBreakpointLocation, GetIgnoreCount); + BreakpointLocationSP loc_sp = GetSP(); if (loc_sp) { std::lock_guard<std::recursive_mutex> guard( @@ -122,6 +148,8 @@ uint32_t SBBreakpointLocation::GetIgnoreCount() { } void SBBreakpointLocation::SetIgnoreCount(uint32_t n) { + LLDB_RECORD_METHOD(void, SBBreakpointLocation, SetIgnoreCount, (uint32_t), n); + BreakpointLocationSP loc_sp = GetSP(); if (loc_sp) { std::lock_guard<std::recursive_mutex> guard( @@ -131,6 +159,9 @@ void SBBreakpointLocation::SetIgnoreCount(uint32_t n) { } void SBBreakpointLocation::SetCondition(const char *condition) { + LLDB_RECORD_METHOD(void, SBBreakpointLocation, SetCondition, (const char *), + condition); + BreakpointLocationSP loc_sp = GetSP(); if (loc_sp) { std::lock_guard<std::recursive_mutex> guard( @@ -140,16 +171,21 @@ void SBBreakpointLocation::SetCondition(const char *condition) { } const char *SBBreakpointLocation::GetCondition() { + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBBreakpointLocation, GetCondition); + BreakpointLocationSP loc_sp = GetSP(); if (loc_sp) { std::lock_guard<std::recursive_mutex> guard( loc_sp->GetTarget().GetAPIMutex()); return loc_sp->GetConditionText(); } - return NULL; + return nullptr; } void SBBreakpointLocation::SetAutoContinue(bool auto_continue) { + LLDB_RECORD_METHOD(void, SBBreakpointLocation, SetAutoContinue, (bool), + auto_continue); + BreakpointLocationSP loc_sp = GetSP(); if (loc_sp) { std::lock_guard<std::recursive_mutex> guard( @@ -159,6 +195,8 @@ void SBBreakpointLocation::SetAutoContinue(bool auto_continue) { } bool SBBreakpointLocation::GetAutoContinue() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBBreakpointLocation, GetAutoContinue); + BreakpointLocationSP loc_sp = GetSP(); if (loc_sp) { std::lock_guard<std::recursive_mutex> guard( @@ -170,10 +208,10 @@ bool SBBreakpointLocation::GetAutoContinue() { void SBBreakpointLocation::SetScriptCallbackFunction( const char *callback_function_name) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(void, SBBreakpointLocation, SetScriptCallbackFunction, + (const char *), callback_function_name); + BreakpointLocationSP loc_sp = GetSP(); - LLDB_LOG(log, "location = {0}, callback = {1}", loc_sp.get(), - callback_function_name); if (loc_sp) { std::lock_guard<std::recursive_mutex> guard( @@ -182,7 +220,6 @@ void SBBreakpointLocation::SetScriptCallbackFunction( loc_sp->GetBreakpoint() .GetTarget() .GetDebugger() - .GetCommandInterpreter() .GetScriptInterpreter() ->SetBreakpointCommandCallbackFunction(bp_options, callback_function_name); @@ -191,10 +228,10 @@ void SBBreakpointLocation::SetScriptCallbackFunction( SBError SBBreakpointLocation::SetScriptCallbackBody(const char *callback_body_text) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(lldb::SBError, SBBreakpointLocation, SetScriptCallbackBody, + (const char *), callback_body_text); + BreakpointLocationSP loc_sp = GetSP(); - LLDB_LOG(log, "location = {0}: callback body:\n{1}", loc_sp.get(), - callback_body_text); SBError sb_error; if (loc_sp) { @@ -205,17 +242,19 @@ SBBreakpointLocation::SetScriptCallbackBody(const char *callback_body_text) { loc_sp->GetBreakpoint() .GetTarget() .GetDebugger() - .GetCommandInterpreter() .GetScriptInterpreter() ->SetBreakpointCommandCallback(bp_options, callback_body_text); sb_error.SetError(error); } else sb_error.SetErrorString("invalid breakpoint"); - return sb_error; + return LLDB_RECORD_RESULT(sb_error); } void SBBreakpointLocation::SetCommandLineCommands(SBStringList &commands) { + LLDB_RECORD_METHOD(void, SBBreakpointLocation, SetCommandLineCommands, + (lldb::SBStringList &), commands); + BreakpointLocationSP loc_sp = GetSP(); if (!loc_sp) return; @@ -231,6 +270,9 @@ void SBBreakpointLocation::SetCommandLineCommands(SBStringList &commands) { } bool SBBreakpointLocation::GetCommandLineCommands(SBStringList &commands) { + LLDB_RECORD_METHOD(bool, SBBreakpointLocation, GetCommandLineCommands, + (lldb::SBStringList &), commands); + BreakpointLocationSP loc_sp = GetSP(); if (!loc_sp) return false; @@ -243,6 +285,9 @@ bool SBBreakpointLocation::GetCommandLineCommands(SBStringList &commands) { } void SBBreakpointLocation::SetThreadID(tid_t thread_id) { + LLDB_RECORD_METHOD(void, SBBreakpointLocation, SetThreadID, (lldb::tid_t), + thread_id); + BreakpointLocationSP loc_sp = GetSP(); if (loc_sp) { std::lock_guard<std::recursive_mutex> guard( @@ -252,6 +297,8 @@ void SBBreakpointLocation::SetThreadID(tid_t thread_id) { } tid_t SBBreakpointLocation::GetThreadID() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::tid_t, SBBreakpointLocation, GetThreadID); + tid_t tid = LLDB_INVALID_THREAD_ID; BreakpointLocationSP loc_sp = GetSP(); if (loc_sp) { @@ -263,6 +310,9 @@ tid_t SBBreakpointLocation::GetThreadID() { } void SBBreakpointLocation::SetThreadIndex(uint32_t index) { + LLDB_RECORD_METHOD(void, SBBreakpointLocation, SetThreadIndex, (uint32_t), + index); + BreakpointLocationSP loc_sp = GetSP(); if (loc_sp) { std::lock_guard<std::recursive_mutex> guard( @@ -272,6 +322,9 @@ void SBBreakpointLocation::SetThreadIndex(uint32_t index) { } uint32_t SBBreakpointLocation::GetThreadIndex() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBBreakpointLocation, + GetThreadIndex); + uint32_t thread_idx = UINT32_MAX; BreakpointLocationSP loc_sp = GetSP(); if (loc_sp) { @@ -283,6 +336,9 @@ uint32_t SBBreakpointLocation::GetThreadIndex() const { } void SBBreakpointLocation::SetThreadName(const char *thread_name) { + LLDB_RECORD_METHOD(void, SBBreakpointLocation, SetThreadName, (const char *), + thread_name); + BreakpointLocationSP loc_sp = GetSP(); if (loc_sp) { std::lock_guard<std::recursive_mutex> guard( @@ -292,16 +348,22 @@ void SBBreakpointLocation::SetThreadName(const char *thread_name) { } const char *SBBreakpointLocation::GetThreadName() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBBreakpointLocation, + GetThreadName); + BreakpointLocationSP loc_sp = GetSP(); if (loc_sp) { std::lock_guard<std::recursive_mutex> guard( loc_sp->GetTarget().GetAPIMutex()); return loc_sp->GetThreadName(); } - return NULL; + return nullptr; } void SBBreakpointLocation::SetQueueName(const char *queue_name) { + LLDB_RECORD_METHOD(void, SBBreakpointLocation, SetQueueName, (const char *), + queue_name); + BreakpointLocationSP loc_sp = GetSP(); if (loc_sp) { std::lock_guard<std::recursive_mutex> guard( @@ -311,16 +373,21 @@ void SBBreakpointLocation::SetQueueName(const char *queue_name) { } const char *SBBreakpointLocation::GetQueueName() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBBreakpointLocation, + GetQueueName); + BreakpointLocationSP loc_sp = GetSP(); if (loc_sp) { std::lock_guard<std::recursive_mutex> guard( loc_sp->GetTarget().GetAPIMutex()); loc_sp->GetQueueName(); } - return NULL; + return nullptr; } bool SBBreakpointLocation::IsResolved() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBBreakpointLocation, IsResolved); + BreakpointLocationSP loc_sp = GetSP(); if (loc_sp) { std::lock_guard<std::recursive_mutex> guard( @@ -338,6 +405,10 @@ void SBBreakpointLocation::SetLocation( bool SBBreakpointLocation::GetDescription(SBStream &description, DescriptionLevel level) { + LLDB_RECORD_METHOD(bool, SBBreakpointLocation, GetDescription, + (lldb::SBStream &, lldb::DescriptionLevel), description, + level); + Stream &strm = description.ref(); BreakpointLocationSP loc_sp = GetSP(); @@ -353,6 +424,8 @@ bool SBBreakpointLocation::GetDescription(SBStream &description, } break_id_t SBBreakpointLocation::GetID() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::break_id_t, SBBreakpointLocation, GetID); + BreakpointLocationSP loc_sp = GetSP(); if (loc_sp) { std::lock_guard<std::recursive_mutex> guard( @@ -363,7 +436,9 @@ break_id_t SBBreakpointLocation::GetID() { } SBBreakpoint SBBreakpointLocation::GetBreakpoint() { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBBreakpoint, SBBreakpointLocation, + GetBreakpoint); + BreakpointLocationSP loc_sp = GetSP(); SBBreakpoint sb_bp; @@ -373,11 +448,68 @@ SBBreakpoint SBBreakpointLocation::GetBreakpoint() { sb_bp = loc_sp->GetBreakpoint().shared_from_this(); } - if (log) { - SBStream sstr; - sb_bp.GetDescription(sstr); - LLDB_LOG(log, "location = {0}, breakpoint = {1} ({2})", loc_sp.get(), - sb_bp.GetSP().get(), sstr.GetData()); - } - return sb_bp; + return LLDB_RECORD_RESULT(sb_bp); +} + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBBreakpointLocation>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBBreakpointLocation, ()); + LLDB_REGISTER_CONSTRUCTOR(SBBreakpointLocation, + (const lldb::BreakpointLocationSP &)); + LLDB_REGISTER_CONSTRUCTOR(SBBreakpointLocation, + (const lldb::SBBreakpointLocation &)); + LLDB_REGISTER_METHOD( + const lldb::SBBreakpointLocation &, + SBBreakpointLocation, operator=,(const lldb::SBBreakpointLocation &)); + LLDB_REGISTER_METHOD_CONST(bool, SBBreakpointLocation, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBBreakpointLocation, operator bool, ()); + LLDB_REGISTER_METHOD(lldb::SBAddress, SBBreakpointLocation, GetAddress, ()); + LLDB_REGISTER_METHOD(lldb::addr_t, SBBreakpointLocation, GetLoadAddress, + ()); + LLDB_REGISTER_METHOD(void, SBBreakpointLocation, SetEnabled, (bool)); + LLDB_REGISTER_METHOD(bool, SBBreakpointLocation, IsEnabled, ()); + LLDB_REGISTER_METHOD(uint32_t, SBBreakpointLocation, GetHitCount, ()); + LLDB_REGISTER_METHOD(uint32_t, SBBreakpointLocation, GetIgnoreCount, ()); + LLDB_REGISTER_METHOD(void, SBBreakpointLocation, SetIgnoreCount, + (uint32_t)); + LLDB_REGISTER_METHOD(void, SBBreakpointLocation, SetCondition, + (const char *)); + LLDB_REGISTER_METHOD(const char *, SBBreakpointLocation, GetCondition, ()); + LLDB_REGISTER_METHOD(void, SBBreakpointLocation, SetAutoContinue, (bool)); + LLDB_REGISTER_METHOD(bool, SBBreakpointLocation, GetAutoContinue, ()); + LLDB_REGISTER_METHOD(void, SBBreakpointLocation, SetScriptCallbackFunction, + (const char *)); + LLDB_REGISTER_METHOD(lldb::SBError, SBBreakpointLocation, + SetScriptCallbackBody, (const char *)); + LLDB_REGISTER_METHOD(void, SBBreakpointLocation, SetCommandLineCommands, + (lldb::SBStringList &)); + LLDB_REGISTER_METHOD(bool, SBBreakpointLocation, GetCommandLineCommands, + (lldb::SBStringList &)); + LLDB_REGISTER_METHOD(void, SBBreakpointLocation, SetThreadID, + (lldb::tid_t)); + LLDB_REGISTER_METHOD(lldb::tid_t, SBBreakpointLocation, GetThreadID, ()); + LLDB_REGISTER_METHOD(void, SBBreakpointLocation, SetThreadIndex, + (uint32_t)); + LLDB_REGISTER_METHOD_CONST(uint32_t, SBBreakpointLocation, GetThreadIndex, + ()); + LLDB_REGISTER_METHOD(void, SBBreakpointLocation, SetThreadName, + (const char *)); + LLDB_REGISTER_METHOD_CONST(const char *, SBBreakpointLocation, + GetThreadName, ()); + LLDB_REGISTER_METHOD(void, SBBreakpointLocation, SetQueueName, + (const char *)); + LLDB_REGISTER_METHOD_CONST(const char *, SBBreakpointLocation, GetQueueName, + ()); + LLDB_REGISTER_METHOD(bool, SBBreakpointLocation, IsResolved, ()); + LLDB_REGISTER_METHOD(bool, SBBreakpointLocation, GetDescription, + (lldb::SBStream &, lldb::DescriptionLevel)); + LLDB_REGISTER_METHOD(lldb::break_id_t, SBBreakpointLocation, GetID, ()); + LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBBreakpointLocation, + GetBreakpoint, ()); +} + +} } diff --git a/source/API/SBBreakpointName.cpp b/source/API/SBBreakpointName.cpp index 47bddd752346c..1c794fca8ca5a 100644 --- a/source/API/SBBreakpointName.cpp +++ b/source/API/SBBreakpointName.cpp @@ -1,13 +1,13 @@ //===-- SBBreakpointName.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBBreakpointName.h" +#include "SBReproducerPrivate.h" #include "lldb/API/SBDebugger.h" #include "lldb/API/SBError.h" #include "lldb/API/SBStream.h" @@ -21,7 +21,6 @@ #include "lldb/Interpreter/ScriptInterpreter.h" #include "lldb/Target/Target.h" #include "lldb/Target/ThreadSpec.h" -#include "lldb/Utility/Log.h" #include "lldb/Utility/Stream.h" #include "SBBreakpointOptionCommon.h" @@ -37,10 +36,10 @@ public: if (!name || name[0] == '\0') return; m_name.assign(name); - + if (!target_sp) return; - + m_target_wp = target_sp; } @@ -50,15 +49,15 @@ public: // For now we take a simple approach and only keep the name, and relook up // the location when we need it. - + TargetSP GetTarget() const { return m_target_wp.lock(); } - + const char *GetName() const { return m_name.c_str(); } - + bool IsValid() const { return !m_name.empty() && m_target_wp.lock(); } @@ -106,10 +105,14 @@ lldb_private::BreakpointName *SBBreakpointNameImpl::GetBreakpointName() const { } // namespace lldb -SBBreakpointName::SBBreakpointName() {} +SBBreakpointName::SBBreakpointName() { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBBreakpointName); +} + +SBBreakpointName::SBBreakpointName(SBTarget &sb_target, const char *name) { + LLDB_RECORD_CONSTRUCTOR(SBBreakpointName, (lldb::SBTarget &, const char *), + sb_target, name); -SBBreakpointName::SBBreakpointName(SBTarget &sb_target, const char *name) -{ m_impl_up.reset(new SBBreakpointNameImpl(sb_target, name)); // Call FindBreakpointName here to make sure the name is valid, reset if not: BreakpointName *bp_name = GetBreakpointName(); @@ -117,8 +120,10 @@ SBBreakpointName::SBBreakpointName(SBTarget &sb_target, const char *name) m_impl_up.reset(); } -SBBreakpointName::SBBreakpointName(SBBreakpoint &sb_bkpt, const char *name) -{ +SBBreakpointName::SBBreakpointName(SBBreakpoint &sb_bkpt, const char *name) { + LLDB_RECORD_CONSTRUCTOR(SBBreakpointName, + (lldb::SBBreakpoint &, const char *), sb_bkpt, name); + if (!sb_bkpt.IsValid()) { m_impl_up.reset(); return; @@ -127,21 +132,23 @@ SBBreakpointName::SBBreakpointName(SBBreakpoint &sb_bkpt, const char *name) Target &target = bkpt_sp->GetTarget(); m_impl_up.reset(new SBBreakpointNameImpl(target.shared_from_this(), name)); - + // Call FindBreakpointName here to make sure the name is valid, reset if not: BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) { m_impl_up.reset(); return; } - + // Now copy over the breakpoint's options: target.ConfigureBreakpointName(*bp_name, *bkpt_sp->GetOptions(), BreakpointName::Permissions()); } -SBBreakpointName::SBBreakpointName(const SBBreakpointName &rhs) -{ +SBBreakpointName::SBBreakpointName(const SBBreakpointName &rhs) { + LLDB_RECORD_CONSTRUCTOR(SBBreakpointName, (const lldb::SBBreakpointName &), + rhs); + if (!rhs.m_impl_up) return; else @@ -151,46 +158,63 @@ SBBreakpointName::SBBreakpointName(const SBBreakpointName &rhs) SBBreakpointName::~SBBreakpointName() = default; -const SBBreakpointName &SBBreakpointName::operator=(const SBBreakpointName &rhs) -{ +const SBBreakpointName &SBBreakpointName:: +operator=(const SBBreakpointName &rhs) { + LLDB_RECORD_METHOD( + const lldb::SBBreakpointName &, + SBBreakpointName, operator=,(const lldb::SBBreakpointName &), rhs); + if (!rhs.m_impl_up) { m_impl_up.reset(); - return *this; + return LLDB_RECORD_RESULT(*this); } - + m_impl_up.reset(new SBBreakpointNameImpl(rhs.m_impl_up->GetTarget(), rhs.m_impl_up->GetName())); - return *this; + return LLDB_RECORD_RESULT(*this); } bool SBBreakpointName::operator==(const lldb::SBBreakpointName &rhs) { + LLDB_RECORD_METHOD( + bool, SBBreakpointName, operator==,(const lldb::SBBreakpointName &), rhs); + return *m_impl_up == *rhs.m_impl_up; } bool SBBreakpointName::operator!=(const lldb::SBBreakpointName &rhs) { + LLDB_RECORD_METHOD( + bool, SBBreakpointName, operator!=,(const lldb::SBBreakpointName &), rhs); + return *m_impl_up != *rhs.m_impl_up; } bool SBBreakpointName::IsValid() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpointName, IsValid); + return this->operator bool(); +} +SBBreakpointName::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpointName, operator bool); + if (!m_impl_up) return false; return m_impl_up->IsValid(); } const char *SBBreakpointName::GetName() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBBreakpointName, GetName); + if (!m_impl_up) return "<Invalid Breakpoint Name Object>"; return m_impl_up->GetName(); } void SBBreakpointName::SetEnabled(bool enable) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - + LLDB_RECORD_METHOD(void, SBBreakpointName, SetEnabled, (bool), enable); + BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) return; - - LLDB_LOG(log, "Name: {0} enabled: {1}\n", bp_name->GetName(), enable); + std::lock_guard<std::recursive_mutex> guard( m_impl_up->GetTarget()->GetAPIMutex()); @@ -209,13 +233,12 @@ void SBBreakpointName::UpdateName(BreakpointName &bp_name) { } bool SBBreakpointName::IsEnabled() { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - + LLDB_RECORD_METHOD_NO_ARGS(bool, SBBreakpointName, IsEnabled); + BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) return false; - - LLDB_LOG(log, "Name: {0}\n", bp_name->GetName()); + std::lock_guard<std::recursive_mutex> guard( m_impl_up->GetTarget()->GetAPIMutex()); @@ -223,13 +246,12 @@ bool SBBreakpointName::IsEnabled() { } void SBBreakpointName::SetOneShot(bool one_shot) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - + LLDB_RECORD_METHOD(void, SBBreakpointName, SetOneShot, (bool), one_shot); + BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) return; - - LLDB_LOG(log, "Name: {0} one_shot: {1}\n", bp_name->GetName(), one_shot); + std::lock_guard<std::recursive_mutex> guard( m_impl_up->GetTarget()->GetAPIMutex()); @@ -238,13 +260,12 @@ void SBBreakpointName::SetOneShot(bool one_shot) { } bool SBBreakpointName::IsOneShot() const { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpointName, IsOneShot); + const BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) return false; - - LLDB_LOG(log, "Name: {0}\n", bp_name->GetName()); + std::lock_guard<std::recursive_mutex> guard( m_impl_up->GetTarget()->GetAPIMutex()); @@ -252,13 +273,12 @@ bool SBBreakpointName::IsOneShot() const { } void SBBreakpointName::SetIgnoreCount(uint32_t count) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - + LLDB_RECORD_METHOD(void, SBBreakpointName, SetIgnoreCount, (uint32_t), count); + BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) return; - - LLDB_LOG(log, "Name: {0} one_shot: {1}\n", bp_name->GetName(), count); + std::lock_guard<std::recursive_mutex> guard( m_impl_up->GetTarget()->GetAPIMutex()); @@ -267,13 +287,12 @@ void SBBreakpointName::SetIgnoreCount(uint32_t count) { } uint32_t SBBreakpointName::GetIgnoreCount() const { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - + LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBBreakpointName, GetIgnoreCount); + BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) return false; - - LLDB_LOG(log, "Name: {0}\n", bp_name->GetName()); + std::lock_guard<std::recursive_mutex> guard( m_impl_up->GetTarget()->GetAPIMutex()); @@ -281,15 +300,13 @@ uint32_t SBBreakpointName::GetIgnoreCount() const { } void SBBreakpointName::SetCondition(const char *condition) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - + LLDB_RECORD_METHOD(void, SBBreakpointName, SetCondition, (const char *), + condition); + BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) return; - - LLDB_LOG(log, "Name: {0} one_shot: {1}\n", bp_name->GetName(), - condition ? condition : "<NULL>"); - + std::lock_guard<std::recursive_mutex> guard( m_impl_up->GetTarget()->GetAPIMutex()); @@ -298,13 +315,12 @@ void SBBreakpointName::SetCondition(const char *condition) { } const char *SBBreakpointName::GetCondition() { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBBreakpointName, GetCondition); + BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) return nullptr; - - LLDB_LOG(log, "Name: {0}\n", bp_name->GetName()); + std::lock_guard<std::recursive_mutex> guard( m_impl_up->GetTarget()->GetAPIMutex()); @@ -312,14 +328,13 @@ const char *SBBreakpointName::GetCondition() { } void SBBreakpointName::SetAutoContinue(bool auto_continue) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - + LLDB_RECORD_METHOD(void, SBBreakpointName, SetAutoContinue, (bool), + auto_continue); + BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) return; - - LLDB_LOG(log, "Name: {0} auto-continue: {1}\n", bp_name->GetName(), auto_continue); - + std::lock_guard<std::recursive_mutex> guard( m_impl_up->GetTarget()->GetAPIMutex()); @@ -328,13 +343,12 @@ void SBBreakpointName::SetAutoContinue(bool auto_continue) { } bool SBBreakpointName::GetAutoContinue() { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - + LLDB_RECORD_METHOD_NO_ARGS(bool, SBBreakpointName, GetAutoContinue); + BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) return false; - - LLDB_LOG(log, "Name: {0}\n", bp_name->GetName()); + std::lock_guard<std::recursive_mutex> guard( m_impl_up->GetTarget()->GetAPIMutex()); @@ -342,14 +356,12 @@ bool SBBreakpointName::GetAutoContinue() { } void SBBreakpointName::SetThreadID(tid_t tid) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - + LLDB_RECORD_METHOD(void, SBBreakpointName, SetThreadID, (lldb::tid_t), tid); + BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) return; - - LLDB_LOG(log, "Name: {0} tid: {1:x}\n", bp_name->GetName(), tid); - + std::lock_guard<std::recursive_mutex> guard( m_impl_up->GetTarget()->GetAPIMutex()); @@ -358,13 +370,12 @@ void SBBreakpointName::SetThreadID(tid_t tid) { } tid_t SBBreakpointName::GetThreadID() { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - + LLDB_RECORD_METHOD_NO_ARGS(lldb::tid_t, SBBreakpointName, GetThreadID); + BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) return LLDB_INVALID_THREAD_ID; - - LLDB_LOG(log, "Name: {0}\n", bp_name->GetName()); + std::lock_guard<std::recursive_mutex> guard( m_impl_up->GetTarget()->GetAPIMutex()); @@ -372,14 +383,12 @@ tid_t SBBreakpointName::GetThreadID() { } void SBBreakpointName::SetThreadIndex(uint32_t index) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - + LLDB_RECORD_METHOD(void, SBBreakpointName, SetThreadIndex, (uint32_t), index); + BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) return; - - LLDB_LOG(log, "Name: {0} thread index: {1}\n", bp_name->GetName(), index); - + std::lock_guard<std::recursive_mutex> guard( m_impl_up->GetTarget()->GetAPIMutex()); @@ -388,13 +397,12 @@ void SBBreakpointName::SetThreadIndex(uint32_t index) { } uint32_t SBBreakpointName::GetThreadIndex() const { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - + LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBBreakpointName, GetThreadIndex); + BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) return LLDB_INVALID_THREAD_ID; - - LLDB_LOG(log, "Name: {0}\n", bp_name->GetName()); + std::lock_guard<std::recursive_mutex> guard( m_impl_up->GetTarget()->GetAPIMutex()); @@ -402,14 +410,13 @@ uint32_t SBBreakpointName::GetThreadIndex() const { } void SBBreakpointName::SetThreadName(const char *thread_name) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - + LLDB_RECORD_METHOD(void, SBBreakpointName, SetThreadName, (const char *), + thread_name); + BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) return; - - LLDB_LOG(log, "Name: {0} thread name: {1}\n", bp_name->GetName(), thread_name); - + std::lock_guard<std::recursive_mutex> guard( m_impl_up->GetTarget()->GetAPIMutex()); @@ -418,13 +425,13 @@ void SBBreakpointName::SetThreadName(const char *thread_name) { } const char *SBBreakpointName::GetThreadName() const { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - + LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBBreakpointName, + GetThreadName); + BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) return nullptr; - - LLDB_LOG(log, "Name: {0}\n", bp_name->GetName()); + std::lock_guard<std::recursive_mutex> guard( m_impl_up->GetTarget()->GetAPIMutex()); @@ -432,14 +439,13 @@ const char *SBBreakpointName::GetThreadName() const { } void SBBreakpointName::SetQueueName(const char *queue_name) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - + LLDB_RECORD_METHOD(void, SBBreakpointName, SetQueueName, (const char *), + queue_name); + BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) return; - - LLDB_LOG(log, "Name: {0} queue name: {1}\n", bp_name->GetName(), queue_name); - + std::lock_guard<std::recursive_mutex> guard( m_impl_up->GetTarget()->GetAPIMutex()); @@ -448,13 +454,13 @@ void SBBreakpointName::SetQueueName(const char *queue_name) { } const char *SBBreakpointName::GetQueueName() const { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - + LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBBreakpointName, + GetQueueName); + BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) return nullptr; - - LLDB_LOG(log, "Name: {0}\n", bp_name->GetName()); + std::lock_guard<std::recursive_mutex> guard( m_impl_up->GetTarget()->GetAPIMutex()); @@ -462,14 +468,15 @@ const char *SBBreakpointName::GetQueueName() const { } void SBBreakpointName::SetCommandLineCommands(SBStringList &commands) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(void, SBBreakpointName, SetCommandLineCommands, + (lldb::SBStringList &), commands); + BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) return; if (commands.GetSize() == 0) return; - LLDB_LOG(log, "Name: {0} commands\n", bp_name->GetName()); std::lock_guard<std::recursive_mutex> guard( m_impl_up->GetTarget()->GetAPIMutex()); @@ -481,13 +488,13 @@ void SBBreakpointName::SetCommandLineCommands(SBStringList &commands) { } bool SBBreakpointName::GetCommandLineCommands(SBStringList &commands) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - + LLDB_RECORD_METHOD(bool, SBBreakpointName, GetCommandLineCommands, + (lldb::SBStringList &), commands); + BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) return false; - - LLDB_LOG(log, "Name: {0}\n", bp_name->GetName()); + StringList command_list; bool has_commands = bp_name->GetOptions().GetCommandLineCallbacks(command_list); @@ -497,23 +504,24 @@ bool SBBreakpointName::GetCommandLineCommands(SBStringList &commands) { } const char *SBBreakpointName::GetHelpString() const { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - + LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBBreakpointName, + GetHelpString); + BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) return ""; - - LLDB_LOG(log, "Help: {0}\n", bp_name->GetHelp()); + return bp_name->GetHelp(); } void SBBreakpointName::SetHelpString(const char *help_string) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(void, SBBreakpointName, SetHelpString, (const char *), + help_string); + BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) return; - LLDB_LOG(log, "Name: {0} help: {1}\n", bp_name->GetName(), help_string); std::lock_guard<std::recursive_mutex> guard( m_impl_up->GetTarget()->GetAPIMutex()); @@ -521,16 +529,16 @@ void SBBreakpointName::SetHelpString(const char *help_string) { } bool SBBreakpointName::GetDescription(SBStream &s) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - + LLDB_RECORD_METHOD(bool, SBBreakpointName, GetDescription, (lldb::SBStream &), + s); + BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) { s.Printf("No value"); return false; } - - LLDB_LOG(log, "Name: {0}\n", bp_name->GetName()); + std::lock_guard<std::recursive_mutex> guard( m_impl_up->GetTarget()->GetAPIMutex()); bp_name->GetDescription(s.get(), eDescriptionLevelFull); @@ -539,11 +547,12 @@ bool SBBreakpointName::GetDescription(SBStream &s) { void SBBreakpointName::SetCallback(SBBreakpointHitCallback callback, void *baton) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_DUMMY(void, SBBreakpointName, SetCallback, + (lldb::SBBreakpointHitCallback, void *), callback, baton); + BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) return; - LLDB_LOG(log, "callback = {1}, baton = {2}", callback, baton); std::lock_guard<std::recursive_mutex> guard( m_impl_up->GetTarget()->GetAPIMutex()); @@ -557,39 +566,35 @@ void SBBreakpointName::SetCallback(SBBreakpointHitCallback callback, void SBBreakpointName::SetScriptCallbackFunction( const char *callback_function_name) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - + LLDB_RECORD_METHOD(void, SBBreakpointName, SetScriptCallbackFunction, + (const char *), callback_function_name); + BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) return; - - LLDB_LOG(log, "Name: {0} callback: {1}\n", bp_name->GetName(), - callback_function_name); - + std::lock_guard<std::recursive_mutex> guard( m_impl_up->GetTarget()->GetAPIMutex()); BreakpointOptions &bp_options = bp_name->GetOptions(); m_impl_up->GetTarget() ->GetDebugger() - .GetCommandInterpreter() .GetScriptInterpreter() ->SetBreakpointCommandCallbackFunction(&bp_options, callback_function_name); UpdateName(*bp_name); } -SBError SBBreakpointName::SetScriptCallbackBody(const char *callback_body_text) -{ - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); +SBError +SBBreakpointName::SetScriptCallbackBody(const char *callback_body_text) { + LLDB_RECORD_METHOD(lldb::SBError, SBBreakpointName, SetScriptCallbackBody, + (const char *), callback_body_text); + SBError sb_error; BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) - return sb_error; - - LLDB_LOG(log, "Name: {0} callback: {1}\n", bp_name->GetName(), - callback_body_text); - + return LLDB_RECORD_RESULT(sb_error); + std::lock_guard<std::recursive_mutex> guard( m_impl_up->GetTarget()->GetAPIMutex()); @@ -597,76 +602,68 @@ SBError SBBreakpointName::SetScriptCallbackBody(const char *callback_body_text) Status error = m_impl_up->GetTarget() ->GetDebugger() - .GetCommandInterpreter() .GetScriptInterpreter() ->SetBreakpointCommandCallback(&bp_options, callback_body_text); sb_error.SetError(error); if (!sb_error.Fail()) UpdateName(*bp_name); - return sb_error; + return LLDB_RECORD_RESULT(sb_error); } -bool SBBreakpointName::GetAllowList() const -{ +bool SBBreakpointName::GetAllowList() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpointName, GetAllowList); + BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) return false; return bp_name->GetPermissions().GetAllowList(); } -void SBBreakpointName::SetAllowList(bool value) -{ - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); +void SBBreakpointName::SetAllowList(bool value) { + LLDB_RECORD_METHOD(void, SBBreakpointName, SetAllowList, (bool), value); + BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) return; - if (log) - log->Printf("Setting allow list to %u for %s.", value, - bp_name->GetName().AsCString()); bp_name->GetPermissions().SetAllowList(value); } - -bool SBBreakpointName::GetAllowDelete() -{ + +bool SBBreakpointName::GetAllowDelete() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBBreakpointName, GetAllowDelete); + BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) return false; return bp_name->GetPermissions().GetAllowDelete(); } -void SBBreakpointName::SetAllowDelete(bool value) -{ - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); +void SBBreakpointName::SetAllowDelete(bool value) { + LLDB_RECORD_METHOD(void, SBBreakpointName, SetAllowDelete, (bool), value); + BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) return; - if (log) - log->Printf("Setting allow delete to %u for %s.", value, - bp_name->GetName().AsCString()); bp_name->GetPermissions().SetAllowDelete(value); } - -bool SBBreakpointName::GetAllowDisable() -{ + +bool SBBreakpointName::GetAllowDisable() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBBreakpointName, GetAllowDisable); + BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) return false; return bp_name->GetPermissions().GetAllowDisable(); } -void SBBreakpointName::SetAllowDisable(bool value) -{ - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); +void SBBreakpointName::SetAllowDisable(bool value) { + LLDB_RECORD_METHOD(void, SBBreakpointName, SetAllowDisable, (bool), value); BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) return; - if (log) - log->Printf("Setting allow disable to %u for %s.", value, - bp_name->GetName().AsCString()); bp_name->GetPermissions().SetAllowDisable(value); } @@ -677,3 +674,69 @@ lldb_private::BreakpointName *SBBreakpointName::GetBreakpointName() const return m_impl_up->GetBreakpointName(); } + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBBreakpointName>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBBreakpointName, ()); + LLDB_REGISTER_CONSTRUCTOR(SBBreakpointName, + (lldb::SBTarget &, const char *)); + LLDB_REGISTER_CONSTRUCTOR(SBBreakpointName, + (lldb::SBBreakpoint &, const char *)); + LLDB_REGISTER_CONSTRUCTOR(SBBreakpointName, + (const lldb::SBBreakpointName &)); + LLDB_REGISTER_METHOD( + const lldb::SBBreakpointName &, + SBBreakpointName, operator=,(const lldb::SBBreakpointName &)); + LLDB_REGISTER_METHOD( + bool, SBBreakpointName, operator==,(const lldb::SBBreakpointName &)); + LLDB_REGISTER_METHOD( + bool, SBBreakpointName, operator!=,(const lldb::SBBreakpointName &)); + LLDB_REGISTER_METHOD_CONST(bool, SBBreakpointName, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBBreakpointName, operator bool, ()); + LLDB_REGISTER_METHOD_CONST(const char *, SBBreakpointName, GetName, ()); + LLDB_REGISTER_METHOD(void, SBBreakpointName, SetEnabled, (bool)); + LLDB_REGISTER_METHOD(bool, SBBreakpointName, IsEnabled, ()); + LLDB_REGISTER_METHOD(void, SBBreakpointName, SetOneShot, (bool)); + LLDB_REGISTER_METHOD_CONST(bool, SBBreakpointName, IsOneShot, ()); + LLDB_REGISTER_METHOD(void, SBBreakpointName, SetIgnoreCount, (uint32_t)); + LLDB_REGISTER_METHOD_CONST(uint32_t, SBBreakpointName, GetIgnoreCount, ()); + LLDB_REGISTER_METHOD(void, SBBreakpointName, SetCondition, (const char *)); + LLDB_REGISTER_METHOD(const char *, SBBreakpointName, GetCondition, ()); + LLDB_REGISTER_METHOD(void, SBBreakpointName, SetAutoContinue, (bool)); + LLDB_REGISTER_METHOD(bool, SBBreakpointName, GetAutoContinue, ()); + LLDB_REGISTER_METHOD(void, SBBreakpointName, SetThreadID, (lldb::tid_t)); + LLDB_REGISTER_METHOD(lldb::tid_t, SBBreakpointName, GetThreadID, ()); + LLDB_REGISTER_METHOD(void, SBBreakpointName, SetThreadIndex, (uint32_t)); + LLDB_REGISTER_METHOD_CONST(uint32_t, SBBreakpointName, GetThreadIndex, ()); + LLDB_REGISTER_METHOD(void, SBBreakpointName, SetThreadName, (const char *)); + LLDB_REGISTER_METHOD_CONST(const char *, SBBreakpointName, GetThreadName, + ()); + LLDB_REGISTER_METHOD(void, SBBreakpointName, SetQueueName, (const char *)); + LLDB_REGISTER_METHOD_CONST(const char *, SBBreakpointName, GetQueueName, + ()); + LLDB_REGISTER_METHOD(void, SBBreakpointName, SetCommandLineCommands, + (lldb::SBStringList &)); + LLDB_REGISTER_METHOD(bool, SBBreakpointName, GetCommandLineCommands, + (lldb::SBStringList &)); + LLDB_REGISTER_METHOD_CONST(const char *, SBBreakpointName, GetHelpString, + ()); + LLDB_REGISTER_METHOD(void, SBBreakpointName, SetHelpString, (const char *)); + LLDB_REGISTER_METHOD(bool, SBBreakpointName, GetDescription, + (lldb::SBStream &)); + LLDB_REGISTER_METHOD(void, SBBreakpointName, SetScriptCallbackFunction, + (const char *)); + LLDB_REGISTER_METHOD(lldb::SBError, SBBreakpointName, SetScriptCallbackBody, + (const char *)); + LLDB_REGISTER_METHOD_CONST(bool, SBBreakpointName, GetAllowList, ()); + LLDB_REGISTER_METHOD(void, SBBreakpointName, SetAllowList, (bool)); + LLDB_REGISTER_METHOD(bool, SBBreakpointName, GetAllowDelete, ()); + LLDB_REGISTER_METHOD(void, SBBreakpointName, SetAllowDelete, (bool)); + LLDB_REGISTER_METHOD(bool, SBBreakpointName, GetAllowDisable, ()); + LLDB_REGISTER_METHOD(void, SBBreakpointName, SetAllowDisable, (bool)); +} + +} +} diff --git a/source/API/SBBreakpointOptionCommon.cpp b/source/API/SBBreakpointOptionCommon.cpp index c0618adb238a3..058b3e0398cd5 100644 --- a/source/API/SBBreakpointOptionCommon.cpp +++ b/source/API/SBBreakpointOptionCommon.cpp @@ -1,9 +1,8 @@ -//===-- SBBreakpointName.cpp ----------------------------------------*- C++ -*-===// +//===-- SBBreakpointOptionCommon.cpp --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/source/API/SBBreakpointOptionCommon.h b/source/API/SBBreakpointOptionCommon.h index fe276ac636fef..52049e4e7588c 100644 --- a/source/API/SBBreakpointOptionCommon.h +++ b/source/API/SBBreakpointOptionCommon.h @@ -1,9 +1,8 @@ //===-- SBBreakpointOptionCommon.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -25,7 +24,7 @@ public: SBBreakpointCallbackBaton(SBBreakpointHitCallback callback, void *baton); - ~SBBreakpointCallbackBaton(); + ~SBBreakpointCallbackBaton() override; static bool PrivateBreakpointHitCallback(void *baton, lldb_private::StoppointCallbackContext *ctx, diff --git a/source/API/SBBroadcaster.cpp b/source/API/SBBroadcaster.cpp index 7868c38a818ab..e1efdf7baf61f 100644 --- a/source/API/SBBroadcaster.cpp +++ b/source/API/SBBroadcaster.cpp @@ -1,14 +1,13 @@ //===-- SBBroadcaster.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// +#include "SBReproducerPrivate.h" #include "lldb/Utility/Broadcaster.h" -#include "lldb/Utility/Log.h" #include "lldb/API/SBBroadcaster.h" #include "lldb/API/SBEvent.h" @@ -17,44 +16,44 @@ using namespace lldb; using namespace lldb_private; -SBBroadcaster::SBBroadcaster() : m_opaque_sp(), m_opaque_ptr(NULL) {} +SBBroadcaster::SBBroadcaster() : m_opaque_sp(), m_opaque_ptr(nullptr) { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBBroadcaster); +} SBBroadcaster::SBBroadcaster(const char *name) - : m_opaque_sp(new Broadcaster(NULL, name)), m_opaque_ptr(NULL) { + : m_opaque_sp(new Broadcaster(nullptr, name)), m_opaque_ptr(nullptr) { + LLDB_RECORD_CONSTRUCTOR(SBBroadcaster, (const char *), name); + m_opaque_ptr = m_opaque_sp.get(); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - LLDB_LOGV(log, "(name=\"{0}\") => SBBroadcaster({1})", name, m_opaque_ptr); } SBBroadcaster::SBBroadcaster(lldb_private::Broadcaster *broadcaster, bool owns) - : m_opaque_sp(owns ? broadcaster : NULL), m_opaque_ptr(broadcaster) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - LLDB_LOGV(log, "(broadcaster={0}, owns={1}) => SBBroadcaster({2})", - broadcaster, owns, m_opaque_ptr); -} + : m_opaque_sp(owns ? broadcaster : nullptr), m_opaque_ptr(broadcaster) {} SBBroadcaster::SBBroadcaster(const SBBroadcaster &rhs) - : m_opaque_sp(rhs.m_opaque_sp), m_opaque_ptr(rhs.m_opaque_ptr) {} + : m_opaque_sp(rhs.m_opaque_sp), m_opaque_ptr(rhs.m_opaque_ptr) { + LLDB_RECORD_CONSTRUCTOR(SBBroadcaster, (const lldb::SBBroadcaster &), rhs); +} const SBBroadcaster &SBBroadcaster::operator=(const SBBroadcaster &rhs) { + LLDB_RECORD_METHOD(const lldb::SBBroadcaster &, + SBBroadcaster, operator=,(const lldb::SBBroadcaster &), + rhs); + if (this != &rhs) { m_opaque_sp = rhs.m_opaque_sp; m_opaque_ptr = rhs.m_opaque_ptr; } - return *this; + return LLDB_RECORD_RESULT(*this); } -SBBroadcaster::~SBBroadcaster() { reset(NULL, false); } +SBBroadcaster::~SBBroadcaster() { reset(nullptr, false); } void SBBroadcaster::BroadcastEventByType(uint32_t event_type, bool unique) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - - if (log) - log->Printf("SBBroadcaster(%p)::BroadcastEventByType (event_type=0x%8.8x, " - "unique=%i)", - static_cast<void *>(m_opaque_ptr), event_type, unique); + LLDB_RECORD_METHOD(void, SBBroadcaster, BroadcastEventByType, + (uint32_t, bool), event_type, unique); - if (m_opaque_ptr == NULL) + if (m_opaque_ptr == nullptr) return; if (unique) @@ -64,15 +63,10 @@ void SBBroadcaster::BroadcastEventByType(uint32_t event_type, bool unique) { } void SBBroadcaster::BroadcastEvent(const SBEvent &event, bool unique) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(void, SBBroadcaster, BroadcastEvent, + (const lldb::SBEvent &, bool), event, unique); - if (log) - log->Printf( - "SBBroadcaster(%p)::BroadcastEventByType (SBEvent(%p), unique=%i)", - static_cast<void *>(m_opaque_ptr), static_cast<void *>(event.get()), - unique); - - if (m_opaque_ptr == NULL) + if (m_opaque_ptr == nullptr) return; EventSP event_sp = event.GetSP(); @@ -84,12 +78,10 @@ void SBBroadcaster::BroadcastEvent(const SBEvent &event, bool unique) { void SBBroadcaster::AddInitialEventsToListener(const SBListener &listener, uint32_t requested_events) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBBroadcaster(%p)::AddInitialEventsToListener " - "(SBListener(%p), event_mask=0x%8.8x)", - static_cast<void *>(m_opaque_ptr), - static_cast<void *>(listener.get()), requested_events); + LLDB_RECORD_METHOD(void, SBBroadcaster, AddInitialEventsToListener, + (const lldb::SBListener &, uint32_t), listener, + requested_events); + if (m_opaque_ptr) m_opaque_ptr->AddInitialEventsToListener(listener.m_opaque_sp, requested_events); @@ -97,18 +89,27 @@ void SBBroadcaster::AddInitialEventsToListener(const SBListener &listener, uint32_t SBBroadcaster::AddListener(const SBListener &listener, uint32_t event_mask) { + LLDB_RECORD_METHOD(uint32_t, SBBroadcaster, AddListener, + (const lldb::SBListener &, uint32_t), listener, + event_mask); + if (m_opaque_ptr) return m_opaque_ptr->AddListener(listener.m_opaque_sp, event_mask); return 0; } const char *SBBroadcaster::GetName() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBBroadcaster, GetName); + if (m_opaque_ptr) return m_opaque_ptr->GetBroadcasterName().GetCString(); - return NULL; + return nullptr; } bool SBBroadcaster::EventTypeHasListeners(uint32_t event_type) { + LLDB_RECORD_METHOD(bool, SBBroadcaster, EventTypeHasListeners, (uint32_t), + event_type); + if (m_opaque_ptr) return m_opaque_ptr->EventTypeHasListeners(event_type); return false; @@ -116,6 +117,10 @@ bool SBBroadcaster::EventTypeHasListeners(uint32_t event_type) { bool SBBroadcaster::RemoveListener(const SBListener &listener, uint32_t event_mask) { + LLDB_RECORD_METHOD(bool, SBBroadcaster, RemoveListener, + (const lldb::SBListener &, uint32_t), listener, + event_mask); + if (m_opaque_ptr) return m_opaque_ptr->RemoveListener(listener.m_opaque_sp, event_mask); return false; @@ -131,21 +136,78 @@ void SBBroadcaster::reset(Broadcaster *broadcaster, bool owns) { m_opaque_ptr = broadcaster; } -bool SBBroadcaster::IsValid() const { return m_opaque_ptr != NULL; } +bool SBBroadcaster::IsValid() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBroadcaster, IsValid); + return this->operator bool(); +} +SBBroadcaster::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBroadcaster, operator bool); + + return m_opaque_ptr != nullptr; +} void SBBroadcaster::Clear() { + LLDB_RECORD_METHOD_NO_ARGS(void, SBBroadcaster, Clear); + m_opaque_sp.reset(); - m_opaque_ptr = NULL; + m_opaque_ptr = nullptr; } bool SBBroadcaster::operator==(const SBBroadcaster &rhs) const { + LLDB_RECORD_METHOD_CONST( + bool, SBBroadcaster, operator==,(const lldb::SBBroadcaster &), rhs); + return m_opaque_ptr == rhs.m_opaque_ptr; } bool SBBroadcaster::operator!=(const SBBroadcaster &rhs) const { + LLDB_RECORD_METHOD_CONST( + bool, SBBroadcaster, operator!=,(const lldb::SBBroadcaster &), rhs); + return m_opaque_ptr != rhs.m_opaque_ptr; } bool SBBroadcaster::operator<(const SBBroadcaster &rhs) const { + LLDB_RECORD_METHOD_CONST( + bool, SBBroadcaster, operator<,(const lldb::SBBroadcaster &), rhs); + return m_opaque_ptr < rhs.m_opaque_ptr; } + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBBroadcaster>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBBroadcaster, ()); + LLDB_REGISTER_CONSTRUCTOR(SBBroadcaster, (const char *)); + LLDB_REGISTER_CONSTRUCTOR(SBBroadcaster, (const lldb::SBBroadcaster &)); + LLDB_REGISTER_METHOD( + const lldb::SBBroadcaster &, + SBBroadcaster, operator=,(const lldb::SBBroadcaster &)); + LLDB_REGISTER_METHOD(void, SBBroadcaster, BroadcastEventByType, + (uint32_t, bool)); + LLDB_REGISTER_METHOD(void, SBBroadcaster, BroadcastEvent, + (const lldb::SBEvent &, bool)); + LLDB_REGISTER_METHOD(void, SBBroadcaster, AddInitialEventsToListener, + (const lldb::SBListener &, uint32_t)); + LLDB_REGISTER_METHOD(uint32_t, SBBroadcaster, AddListener, + (const lldb::SBListener &, uint32_t)); + LLDB_REGISTER_METHOD_CONST(const char *, SBBroadcaster, GetName, ()); + LLDB_REGISTER_METHOD(bool, SBBroadcaster, EventTypeHasListeners, + (uint32_t)); + LLDB_REGISTER_METHOD(bool, SBBroadcaster, RemoveListener, + (const lldb::SBListener &, uint32_t)); + LLDB_REGISTER_METHOD_CONST(bool, SBBroadcaster, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBBroadcaster, operator bool, ()); + LLDB_REGISTER_METHOD(void, SBBroadcaster, Clear, ()); + LLDB_REGISTER_METHOD_CONST( + bool, SBBroadcaster, operator==,(const lldb::SBBroadcaster &)); + LLDB_REGISTER_METHOD_CONST( + bool, SBBroadcaster, operator!=,(const lldb::SBBroadcaster &)); + LLDB_REGISTER_METHOD_CONST( + bool, SBBroadcaster, operator<,(const lldb::SBBroadcaster &)); +} + +} +} diff --git a/source/API/SBCommandInterpreter.cpp b/source/API/SBCommandInterpreter.cpp index 2a06e608c0b94..c07dffce0baaf 100644 --- a/source/API/SBCommandInterpreter.cpp +++ b/source/API/SBCommandInterpreter.cpp @@ -1,14 +1,14 @@ //===-- SBCommandInterpreter.cpp --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/lldb-types.h" +#include "SBReproducerPrivate.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandObjectMultiword.h" #include "lldb/Interpreter/CommandReturnObject.h" @@ -26,68 +26,114 @@ #include "lldb/API/SBStringList.h" #include "lldb/API/SBTarget.h" +#include <memory> + using namespace lldb; using namespace lldb_private; SBCommandInterpreterRunOptions::SBCommandInterpreterRunOptions() { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBCommandInterpreterRunOptions); + m_opaque_up.reset(new CommandInterpreterRunOptions()); } SBCommandInterpreterRunOptions::~SBCommandInterpreterRunOptions() = default; bool SBCommandInterpreterRunOptions::GetStopOnContinue() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions, + GetStopOnContinue); + return m_opaque_up->GetStopOnContinue(); } void SBCommandInterpreterRunOptions::SetStopOnContinue(bool stop_on_continue) { + LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetStopOnContinue, + (bool), stop_on_continue); + m_opaque_up->SetStopOnContinue(stop_on_continue); } bool SBCommandInterpreterRunOptions::GetStopOnError() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions, + GetStopOnError); + return m_opaque_up->GetStopOnError(); } void SBCommandInterpreterRunOptions::SetStopOnError(bool stop_on_error) { + LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetStopOnError, + (bool), stop_on_error); + m_opaque_up->SetStopOnError(stop_on_error); } bool SBCommandInterpreterRunOptions::GetStopOnCrash() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions, + GetStopOnCrash); + return m_opaque_up->GetStopOnCrash(); } void SBCommandInterpreterRunOptions::SetStopOnCrash(bool stop_on_crash) { + LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetStopOnCrash, + (bool), stop_on_crash); + m_opaque_up->SetStopOnCrash(stop_on_crash); } bool SBCommandInterpreterRunOptions::GetEchoCommands() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions, + GetEchoCommands); + return m_opaque_up->GetEchoCommands(); } void SBCommandInterpreterRunOptions::SetEchoCommands(bool echo_commands) { + LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetEchoCommands, + (bool), echo_commands); + m_opaque_up->SetEchoCommands(echo_commands); } bool SBCommandInterpreterRunOptions::GetEchoCommentCommands() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions, + GetEchoCommentCommands); + return m_opaque_up->GetEchoCommentCommands(); } void SBCommandInterpreterRunOptions::SetEchoCommentCommands(bool echo) { + LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, + SetEchoCommentCommands, (bool), echo); + m_opaque_up->SetEchoCommentCommands(echo); } bool SBCommandInterpreterRunOptions::GetPrintResults() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions, + GetPrintResults); + return m_opaque_up->GetPrintResults(); } void SBCommandInterpreterRunOptions::SetPrintResults(bool print_results) { + LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetPrintResults, + (bool), print_results); + m_opaque_up->SetPrintResults(print_results); } bool SBCommandInterpreterRunOptions::GetAddToHistory() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions, + GetAddToHistory); + return m_opaque_up->GetAddToHistory(); } void SBCommandInterpreterRunOptions::SetAddToHistory(bool add_to_history) { + LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetAddToHistory, + (bool), add_to_history); + m_opaque_up->SetAddToHistory(add_to_history); } @@ -129,47 +175,72 @@ protected: SBCommandInterpreter::SBCommandInterpreter(CommandInterpreter *interpreter) : m_opaque_ptr(interpreter) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_CONSTRUCTOR(SBCommandInterpreter, + (lldb_private::CommandInterpreter *), interpreter); - if (log) - log->Printf("SBCommandInterpreter::SBCommandInterpreter (interpreter=%p)" - " => SBCommandInterpreter(%p)", - static_cast<void *>(interpreter), - static_cast<void *>(m_opaque_ptr)); } SBCommandInterpreter::SBCommandInterpreter(const SBCommandInterpreter &rhs) - : m_opaque_ptr(rhs.m_opaque_ptr) {} + : m_opaque_ptr(rhs.m_opaque_ptr) { + LLDB_RECORD_CONSTRUCTOR(SBCommandInterpreter, + (const lldb::SBCommandInterpreter &), rhs); +} SBCommandInterpreter::~SBCommandInterpreter() = default; const SBCommandInterpreter &SBCommandInterpreter:: operator=(const SBCommandInterpreter &rhs) { + LLDB_RECORD_METHOD( + const lldb::SBCommandInterpreter &, + SBCommandInterpreter, operator=,(const lldb::SBCommandInterpreter &), + rhs); + m_opaque_ptr = rhs.m_opaque_ptr; - return *this; + return LLDB_RECORD_RESULT(*this); } -bool SBCommandInterpreter::IsValid() const { return m_opaque_ptr != nullptr; } +bool SBCommandInterpreter::IsValid() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreter, IsValid); + return this->operator bool(); +} +SBCommandInterpreter::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreter, operator bool); + + return m_opaque_ptr != nullptr; +} bool SBCommandInterpreter::CommandExists(const char *cmd) { + LLDB_RECORD_METHOD(bool, SBCommandInterpreter, CommandExists, (const char *), + cmd); + return (((cmd != nullptr) && IsValid()) ? m_opaque_ptr->CommandExists(cmd) : false); } bool SBCommandInterpreter::AliasExists(const char *cmd) { + LLDB_RECORD_METHOD(bool, SBCommandInterpreter, AliasExists, (const char *), + cmd); + return (((cmd != nullptr) && IsValid()) ? m_opaque_ptr->AliasExists(cmd) : false); } bool SBCommandInterpreter::IsActive() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommandInterpreter, IsActive); + return (IsValid() ? m_opaque_ptr->IsActive() : false); } bool SBCommandInterpreter::WasInterrupted() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreter, WasInterrupted); + return (IsValid() ? m_opaque_ptr->WasInterrupted() : false); } const char *SBCommandInterpreter::GetIOHandlerControlSequence(char ch) { + LLDB_RECORD_METHOD(const char *, SBCommandInterpreter, + GetIOHandlerControlSequence, (char), ch); + return (IsValid() ? m_opaque_ptr->GetDebugger() .GetTopIOHandlerControlSequence(ch) @@ -181,6 +252,10 @@ lldb::ReturnStatus SBCommandInterpreter::HandleCommand(const char *command_line, SBCommandReturnObject &result, bool add_to_history) { + LLDB_RECORD_METHOD(lldb::ReturnStatus, SBCommandInterpreter, HandleCommand, + (const char *, lldb::SBCommandReturnObject &, bool), + command_line, result, add_to_history); + SBExecutionContext sb_exe_ctx; return HandleCommand(command_line, sb_exe_ctx, result, add_to_history); } @@ -188,13 +263,11 @@ SBCommandInterpreter::HandleCommand(const char *command_line, lldb::ReturnStatus SBCommandInterpreter::HandleCommand( const char *command_line, SBExecutionContext &override_context, SBCommandReturnObject &result, bool add_to_history) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(lldb::ReturnStatus, SBCommandInterpreter, HandleCommand, + (const char *, lldb::SBExecutionContext &, + lldb::SBCommandReturnObject &, bool), + command_line, override_context, result, add_to_history); - if (log) - log->Printf("SBCommandInterpreter(%p)::HandleCommand (command=\"%s\", " - "SBCommandReturnObject(%p), add_to_history=%i)", - static_cast<void *>(m_opaque_ptr), command_line, - static_cast<void *>(result.get()), add_to_history); ExecutionContext ctx, *ctx_ptr; if (override_context.get()) { @@ -215,17 +288,6 @@ lldb::ReturnStatus SBCommandInterpreter::HandleCommand( result->SetStatus(eReturnStatusFailed); } - // We need to get the value again, in case the command disabled the log! - log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API); - if (log) { - SBStream sstr; - result.GetDescription(sstr); - log->Printf("SBCommandInterpreter(%p)::HandleCommand (command=\"%s\", " - "SBCommandReturnObject(%p): %s, add_to_history=%i) => %i", - static_cast<void *>(m_opaque_ptr), command_line, - static_cast<void *>(result.get()), sstr.GetData(), - add_to_history, result.GetStatus()); - } return result.GetStatus(); } @@ -234,16 +296,11 @@ void SBCommandInterpreter::HandleCommandsFromFile( lldb::SBFileSpec &file, lldb::SBExecutionContext &override_context, lldb::SBCommandInterpreterRunOptions &options, lldb::SBCommandReturnObject result) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - - if (log) { - SBStream s; - file.GetDescription(s); - log->Printf("SBCommandInterpreter(%p)::HandleCommandsFromFile " - "(file=\"%s\", SBCommandReturnObject(%p))", - static_cast<void *>(m_opaque_ptr), s.GetData(), - static_cast<void *>(result.get())); - } + LLDB_RECORD_METHOD(void, SBCommandInterpreter, HandleCommandsFromFile, + (lldb::SBFileSpec &, lldb::SBExecutionContext &, + lldb::SBCommandInterpreterRunOptions &, + lldb::SBCommandReturnObject), + file, override_context, options, result); if (!IsValid()) { result->AppendError("SBCommandInterpreter is not valid."); @@ -273,6 +330,12 @@ void SBCommandInterpreter::HandleCommandsFromFile( int SBCommandInterpreter::HandleCompletion( const char *current_line, const char *cursor, const char *last_char, int match_start_point, int max_return_elements, SBStringList &matches) { + LLDB_RECORD_METHOD(int, SBCommandInterpreter, HandleCompletion, + (const char *, const char *, const char *, int, int, + lldb::SBStringList &), + current_line, cursor, last_char, match_start_point, + max_return_elements, matches); + SBStringList dummy_descriptions; return HandleCompletionWithDescriptions( current_line, cursor, last_char, match_start_point, max_return_elements, @@ -283,7 +346,13 @@ int SBCommandInterpreter::HandleCompletionWithDescriptions( const char *current_line, const char *cursor, const char *last_char, int match_start_point, int max_return_elements, SBStringList &matches, SBStringList &descriptions) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(int, SBCommandInterpreter, + HandleCompletionWithDescriptions, + (const char *, const char *, const char *, int, int, + lldb::SBStringList &, lldb::SBStringList &), + current_line, cursor, last_char, match_start_point, + max_return_elements, matches, descriptions); + int num_completions = 0; // Sanity check the arguments that are passed in: cursor & last_char have to @@ -299,15 +368,6 @@ int SBCommandInterpreter::HandleCompletionWithDescriptions( last_char - current_line > static_cast<ptrdiff_t>(current_line_size)) return 0; - if (log) - log->Printf("SBCommandInterpreter(%p)::HandleCompletion " - "(current_line=\"%s\", cursor at: %" PRId64 - ", last char at: %" PRId64 - ", match_start_point: %d, max_return_elements: %d)", - static_cast<void *>(m_opaque_ptr), current_line, - static_cast<uint64_t>(cursor - current_line), - static_cast<uint64_t>(last_char - current_line), - match_start_point, max_return_elements); if (IsValid()) { lldb_private::StringList lldb_matches, lldb_descriptions; @@ -320,10 +380,6 @@ int SBCommandInterpreter::HandleCompletionWithDescriptions( SBStringList temp_descriptions_list(&lldb_descriptions); descriptions.AppendList(temp_descriptions_list); } - if (log) - log->Printf( - "SBCommandInterpreter(%p)::HandleCompletion - Found %d completions.", - static_cast<void *>(m_opaque_ptr), num_completions); return num_completions; } @@ -332,6 +388,13 @@ int SBCommandInterpreter::HandleCompletionWithDescriptions( const char *current_line, uint32_t cursor_pos, int match_start_point, int max_return_elements, SBStringList &matches, SBStringList &descriptions) { + LLDB_RECORD_METHOD(int, SBCommandInterpreter, + HandleCompletionWithDescriptions, + (const char *, uint32_t, int, int, lldb::SBStringList &, + lldb::SBStringList &), + current_line, cursor_pos, match_start_point, + max_return_elements, matches, descriptions); + const char *cursor = current_line + cursor_pos; const char *last_char = current_line + strlen(current_line); return HandleCompletionWithDescriptions( @@ -344,6 +407,11 @@ int SBCommandInterpreter::HandleCompletion(const char *current_line, int match_start_point, int max_return_elements, lldb::SBStringList &matches) { + LLDB_RECORD_METHOD(int, SBCommandInterpreter, HandleCompletion, + (const char *, uint32_t, int, int, lldb::SBStringList &), + current_line, cursor_pos, match_start_point, + max_return_elements, matches); + const char *cursor = current_line + cursor_pos; const char *last_char = current_line + strlen(current_line); return HandleCompletion(current_line, cursor, last_char, match_start_point, @@ -351,18 +419,26 @@ int SBCommandInterpreter::HandleCompletion(const char *current_line, } bool SBCommandInterpreter::HasCommands() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommandInterpreter, HasCommands); + return (IsValid() ? m_opaque_ptr->HasCommands() : false); } bool SBCommandInterpreter::HasAliases() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommandInterpreter, HasAliases); + return (IsValid() ? m_opaque_ptr->HasAliases() : false); } bool SBCommandInterpreter::HasAliasOptions() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommandInterpreter, HasAliasOptions); + return (IsValid() ? m_opaque_ptr->HasAliasOptions() : false); } SBProcess SBCommandInterpreter::GetProcess() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBProcess, SBCommandInterpreter, GetProcess); + SBProcess sb_process; ProcessSP process_sp; if (IsValid()) { @@ -373,45 +449,45 @@ SBProcess SBCommandInterpreter::GetProcess() { sb_process.SetSP(process_sp); } } - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBCommandInterpreter(%p)::GetProcess () => SBProcess(%p)", - static_cast<void *>(m_opaque_ptr), - static_cast<void *>(process_sp.get())); - - return sb_process; + return LLDB_RECORD_RESULT(sb_process); } SBDebugger SBCommandInterpreter::GetDebugger() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBDebugger, SBCommandInterpreter, + GetDebugger); + SBDebugger sb_debugger; if (IsValid()) sb_debugger.reset(m_opaque_ptr->GetDebugger().shared_from_this()); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - - if (log) - log->Printf("SBCommandInterpreter(%p)::GetDebugger () => SBDebugger(%p)", - static_cast<void *>(m_opaque_ptr), - static_cast<void *>(sb_debugger.get())); - return sb_debugger; + return LLDB_RECORD_RESULT(sb_debugger); } bool SBCommandInterpreter::GetPromptOnQuit() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommandInterpreter, GetPromptOnQuit); + return (IsValid() ? m_opaque_ptr->GetPromptOnQuit() : false); } void SBCommandInterpreter::SetPromptOnQuit(bool b) { + LLDB_RECORD_METHOD(void, SBCommandInterpreter, SetPromptOnQuit, (bool), b); + if (IsValid()) m_opaque_ptr->SetPromptOnQuit(b); } void SBCommandInterpreter::AllowExitCodeOnQuit(bool allow) { + LLDB_RECORD_METHOD(void, SBCommandInterpreter, AllowExitCodeOnQuit, (bool), + allow); + if (m_opaque_ptr) m_opaque_ptr->AllowExitCodeOnQuit(allow); } bool SBCommandInterpreter::HasCustomQuitExitCode() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommandInterpreter, HasCustomQuitExitCode); + bool exited = false; if (m_opaque_ptr) m_opaque_ptr->GetQuitExitCode(exited); @@ -419,12 +495,18 @@ bool SBCommandInterpreter::HasCustomQuitExitCode() { } int SBCommandInterpreter::GetQuitStatus() { + LLDB_RECORD_METHOD_NO_ARGS(int, SBCommandInterpreter, GetQuitStatus); + bool exited = false; return (m_opaque_ptr ? m_opaque_ptr->GetQuitExitCode(exited) : 0); } void SBCommandInterpreter::ResolveCommand(const char *command_line, SBCommandReturnObject &result) { + LLDB_RECORD_METHOD(void, SBCommandInterpreter, ResolveCommand, + (const char *, lldb::SBCommandReturnObject &), + command_line, result); + result.Clear(); if (command_line && IsValid()) { m_opaque_ptr->ResolveCommand(command_line, result.ref()); @@ -449,78 +531,83 @@ void SBCommandInterpreter::reset( void SBCommandInterpreter::SourceInitFileInHomeDirectory( SBCommandReturnObject &result) { + LLDB_RECORD_METHOD(void, SBCommandInterpreter, SourceInitFileInHomeDirectory, + (lldb::SBCommandReturnObject &), result); + result.Clear(); if (IsValid()) { TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget()); std::unique_lock<std::recursive_mutex> lock; if (target_sp) lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex()); - m_opaque_ptr->SourceInitFile(false, result.ref()); + m_opaque_ptr->SourceInitFileHome(result.ref()); } else { result->AppendError("SBCommandInterpreter is not valid"); result->SetStatus(eReturnStatusFailed); } - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - - if (log) - log->Printf("SBCommandInterpreter(%p)::SourceInitFileInHomeDirectory " - "(&SBCommandReturnObject(%p))", - static_cast<void *>(m_opaque_ptr), - static_cast<void *>(result.get())); } void SBCommandInterpreter::SourceInitFileInCurrentWorkingDirectory( SBCommandReturnObject &result) { + LLDB_RECORD_METHOD(void, SBCommandInterpreter, + SourceInitFileInCurrentWorkingDirectory, + (lldb::SBCommandReturnObject &), result); + result.Clear(); if (IsValid()) { TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget()); std::unique_lock<std::recursive_mutex> lock; if (target_sp) lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex()); - m_opaque_ptr->SourceInitFile(true, result.ref()); + m_opaque_ptr->SourceInitFileCwd(result.ref()); } else { result->AppendError("SBCommandInterpreter is not valid"); result->SetStatus(eReturnStatusFailed); } - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - - if (log) - log->Printf( - "SBCommandInterpreter(%p)::SourceInitFileInCurrentWorkingDirectory " - "(&SBCommandReturnObject(%p))", - static_cast<void *>(m_opaque_ptr), static_cast<void *>(result.get())); } SBBroadcaster SBCommandInterpreter::GetBroadcaster() { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBBroadcaster, SBCommandInterpreter, + GetBroadcaster); + SBBroadcaster broadcaster(m_opaque_ptr, false); - if (log) - log->Printf( - "SBCommandInterpreter(%p)::GetBroadcaster() => SBBroadcaster(%p)", - static_cast<void *>(m_opaque_ptr), - static_cast<void *>(broadcaster.get())); - return broadcaster; + return LLDB_RECORD_RESULT(broadcaster); } const char *SBCommandInterpreter::GetBroadcasterClass() { + LLDB_RECORD_STATIC_METHOD_NO_ARGS(const char *, SBCommandInterpreter, + GetBroadcasterClass); + return CommandInterpreter::GetStaticBroadcasterClass().AsCString(); } const char *SBCommandInterpreter::GetArgumentTypeAsCString( const lldb::CommandArgumentType arg_type) { + LLDB_RECORD_STATIC_METHOD(const char *, SBCommandInterpreter, + GetArgumentTypeAsCString, + (const lldb::CommandArgumentType), arg_type); + return CommandObject::GetArgumentTypeAsCString(arg_type); } const char *SBCommandInterpreter::GetArgumentDescriptionAsCString( const lldb::CommandArgumentType arg_type) { + LLDB_RECORD_STATIC_METHOD(const char *, SBCommandInterpreter, + GetArgumentDescriptionAsCString, + (const lldb::CommandArgumentType), arg_type); + return CommandObject::GetArgumentDescriptionAsCString(arg_type); } bool SBCommandInterpreter::EventIsCommandInterpreterEvent( const lldb::SBEvent &event) { + LLDB_RECORD_STATIC_METHOD(bool, SBCommandInterpreter, + EventIsCommandInterpreterEvent, + (const lldb::SBEvent &), event); + return event.GetBroadcasterClass() == SBCommandInterpreter::GetBroadcasterClass(); } @@ -528,6 +615,10 @@ bool SBCommandInterpreter::EventIsCommandInterpreterEvent( bool SBCommandInterpreter::SetCommandOverrideCallback( const char *command_name, lldb::CommandOverrideCallback callback, void *baton) { + LLDB_RECORD_DUMMY(bool, SBCommandInterpreter, SetCommandOverrideCallback, + (const char *, lldb::CommandOverrideCallback, void *), + command_name, callback, baton); + if (command_name && command_name[0] && IsValid()) { llvm::StringRef command_name_str = command_name; CommandObject *cmd_obj = @@ -543,122 +634,310 @@ bool SBCommandInterpreter::SetCommandOverrideCallback( lldb::SBCommand SBCommandInterpreter::AddMultiwordCommand(const char *name, const char *help) { + LLDB_RECORD_METHOD(lldb::SBCommand, SBCommandInterpreter, AddMultiwordCommand, + (const char *, const char *), name, help); + CommandObjectMultiword *new_command = new CommandObjectMultiword(*m_opaque_ptr, name, help); new_command->SetRemovable(true); lldb::CommandObjectSP new_command_sp(new_command); if (new_command_sp && m_opaque_ptr->AddUserCommand(name, new_command_sp, true)) - return lldb::SBCommand(new_command_sp); - return lldb::SBCommand(); + return LLDB_RECORD_RESULT(lldb::SBCommand(new_command_sp)); + return LLDB_RECORD_RESULT(lldb::SBCommand()); } lldb::SBCommand SBCommandInterpreter::AddCommand( const char *name, lldb::SBCommandPluginInterface *impl, const char *help) { + LLDB_RECORD_METHOD( + lldb::SBCommand, SBCommandInterpreter, AddCommand, + (const char *, lldb::SBCommandPluginInterface *, const char *), name, + impl, help); + lldb::CommandObjectSP new_command_sp; - new_command_sp.reset(new CommandPluginInterfaceImplementation( - *m_opaque_ptr, name, impl, help)); + new_command_sp = std::make_shared<CommandPluginInterfaceImplementation>( + *m_opaque_ptr, name, impl, help); if (new_command_sp && m_opaque_ptr->AddUserCommand(name, new_command_sp, true)) - return lldb::SBCommand(new_command_sp); - return lldb::SBCommand(); + return LLDB_RECORD_RESULT(lldb::SBCommand(new_command_sp)); + return LLDB_RECORD_RESULT(lldb::SBCommand()); } lldb::SBCommand SBCommandInterpreter::AddCommand(const char *name, lldb::SBCommandPluginInterface *impl, const char *help, const char *syntax) { + LLDB_RECORD_METHOD(lldb::SBCommand, SBCommandInterpreter, AddCommand, + (const char *, lldb::SBCommandPluginInterface *, + const char *, const char *), + name, impl, help, syntax); + lldb::CommandObjectSP new_command_sp; - new_command_sp.reset(new CommandPluginInterfaceImplementation( - *m_opaque_ptr, name, impl, help, syntax)); + new_command_sp = std::make_shared<CommandPluginInterfaceImplementation>( + *m_opaque_ptr, name, impl, help, syntax); if (new_command_sp && m_opaque_ptr->AddUserCommand(name, new_command_sp, true)) - return lldb::SBCommand(new_command_sp); - return lldb::SBCommand(); + return LLDB_RECORD_RESULT(lldb::SBCommand(new_command_sp)); + return LLDB_RECORD_RESULT(lldb::SBCommand()); } -SBCommand::SBCommand() = default; +SBCommand::SBCommand() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBCommand); } SBCommand::SBCommand(lldb::CommandObjectSP cmd_sp) : m_opaque_sp(cmd_sp) {} -bool SBCommand::IsValid() { return m_opaque_sp.get() != nullptr; } +bool SBCommand::IsValid() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommand, IsValid); + return this->operator bool(); +} +SBCommand::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommand, operator bool); + + return m_opaque_sp.get() != nullptr; +} const char *SBCommand::GetName() { + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBCommand, GetName); + return (IsValid() ? ConstString(m_opaque_sp->GetCommandName()).AsCString() : nullptr); } const char *SBCommand::GetHelp() { + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBCommand, GetHelp); + return (IsValid() ? ConstString(m_opaque_sp->GetHelp()).AsCString() : nullptr); } const char *SBCommand::GetHelpLong() { + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBCommand, GetHelpLong); + return (IsValid() ? ConstString(m_opaque_sp->GetHelpLong()).AsCString() : nullptr); } void SBCommand::SetHelp(const char *help) { + LLDB_RECORD_METHOD(void, SBCommand, SetHelp, (const char *), help); + if (IsValid()) m_opaque_sp->SetHelp(help); } void SBCommand::SetHelpLong(const char *help) { + LLDB_RECORD_METHOD(void, SBCommand, SetHelpLong, (const char *), help); + if (IsValid()) m_opaque_sp->SetHelpLong(help); } lldb::SBCommand SBCommand::AddMultiwordCommand(const char *name, const char *help) { + LLDB_RECORD_METHOD(lldb::SBCommand, SBCommand, AddMultiwordCommand, + (const char *, const char *), name, help); + if (!IsValid()) - return lldb::SBCommand(); + return LLDB_RECORD_RESULT(lldb::SBCommand()); if (!m_opaque_sp->IsMultiwordObject()) - return lldb::SBCommand(); + return LLDB_RECORD_RESULT(lldb::SBCommand()); CommandObjectMultiword *new_command = new CommandObjectMultiword( m_opaque_sp->GetCommandInterpreter(), name, help); new_command->SetRemovable(true); lldb::CommandObjectSP new_command_sp(new_command); if (new_command_sp && m_opaque_sp->LoadSubCommand(name, new_command_sp)) - return lldb::SBCommand(new_command_sp); - return lldb::SBCommand(); + return LLDB_RECORD_RESULT(lldb::SBCommand(new_command_sp)); + return LLDB_RECORD_RESULT(lldb::SBCommand()); } lldb::SBCommand SBCommand::AddCommand(const char *name, lldb::SBCommandPluginInterface *impl, const char *help) { + LLDB_RECORD_METHOD( + lldb::SBCommand, SBCommand, AddCommand, + (const char *, lldb::SBCommandPluginInterface *, const char *), name, + impl, help); + if (!IsValid()) - return lldb::SBCommand(); + return LLDB_RECORD_RESULT(lldb::SBCommand()); if (!m_opaque_sp->IsMultiwordObject()) - return lldb::SBCommand(); + return LLDB_RECORD_RESULT(lldb::SBCommand()); lldb::CommandObjectSP new_command_sp; - new_command_sp.reset(new CommandPluginInterfaceImplementation( - m_opaque_sp->GetCommandInterpreter(), name, impl, help)); + new_command_sp = std::make_shared<CommandPluginInterfaceImplementation>( + m_opaque_sp->GetCommandInterpreter(), name, impl, help); if (new_command_sp && m_opaque_sp->LoadSubCommand(name, new_command_sp)) - return lldb::SBCommand(new_command_sp); - return lldb::SBCommand(); + return LLDB_RECORD_RESULT(lldb::SBCommand(new_command_sp)); + return LLDB_RECORD_RESULT(lldb::SBCommand()); } lldb::SBCommand SBCommand::AddCommand(const char *name, lldb::SBCommandPluginInterface *impl, const char *help, const char *syntax) { + LLDB_RECORD_METHOD(lldb::SBCommand, SBCommand, AddCommand, + (const char *, lldb::SBCommandPluginInterface *, + const char *, const char *), + name, impl, help, syntax); + if (!IsValid()) - return lldb::SBCommand(); + return LLDB_RECORD_RESULT(lldb::SBCommand()); if (!m_opaque_sp->IsMultiwordObject()) - return lldb::SBCommand(); + return LLDB_RECORD_RESULT(lldb::SBCommand()); lldb::CommandObjectSP new_command_sp; - new_command_sp.reset(new CommandPluginInterfaceImplementation( - m_opaque_sp->GetCommandInterpreter(), name, impl, help, syntax)); + new_command_sp = std::make_shared<CommandPluginInterfaceImplementation>( + m_opaque_sp->GetCommandInterpreter(), name, impl, help, syntax); if (new_command_sp && m_opaque_sp->LoadSubCommand(name, new_command_sp)) - return lldb::SBCommand(new_command_sp); - return lldb::SBCommand(); + return LLDB_RECORD_RESULT(lldb::SBCommand(new_command_sp)); + return LLDB_RECORD_RESULT(lldb::SBCommand()); } uint32_t SBCommand::GetFlags() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBCommand, GetFlags); + return (IsValid() ? m_opaque_sp->GetFlags().Get() : 0); } void SBCommand::SetFlags(uint32_t flags) { + LLDB_RECORD_METHOD(void, SBCommand, SetFlags, (uint32_t), flags); + if (IsValid()) m_opaque_sp->GetFlags().Set(flags); } + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBCommandInterpreterRunOptions>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBCommandInterpreterRunOptions, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions, + GetStopOnContinue, ()); + LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, + SetStopOnContinue, (bool)); + LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions, + GetStopOnError, ()); + LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetStopOnError, + (bool)); + LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions, + GetStopOnCrash, ()); + LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetStopOnCrash, + (bool)); + LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions, + GetEchoCommands, ()); + LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetEchoCommands, + (bool)); + LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions, + GetEchoCommentCommands, ()); + LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, + SetEchoCommentCommands, (bool)); + LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions, + GetPrintResults, ()); + LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetPrintResults, + (bool)); + LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions, + GetAddToHistory, ()); + LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetAddToHistory, + (bool)); + LLDB_REGISTER_CONSTRUCTOR(SBCommandInterpreter, + (lldb_private::CommandInterpreter *)); + LLDB_REGISTER_CONSTRUCTOR(SBCommandInterpreter, + (const lldb::SBCommandInterpreter &)); + LLDB_REGISTER_METHOD( + const lldb::SBCommandInterpreter &, + SBCommandInterpreter, operator=,(const lldb::SBCommandInterpreter &)); + LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreter, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreter, operator bool, ()); + LLDB_REGISTER_METHOD(bool, SBCommandInterpreter, CommandExists, + (const char *)); + LLDB_REGISTER_METHOD(bool, SBCommandInterpreter, AliasExists, + (const char *)); + LLDB_REGISTER_METHOD(bool, SBCommandInterpreter, IsActive, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreter, WasInterrupted, ()); + LLDB_REGISTER_METHOD(const char *, SBCommandInterpreter, + GetIOHandlerControlSequence, (char)); + LLDB_REGISTER_METHOD(lldb::ReturnStatus, SBCommandInterpreter, + HandleCommand, + (const char *, lldb::SBCommandReturnObject &, bool)); + LLDB_REGISTER_METHOD(lldb::ReturnStatus, SBCommandInterpreter, + HandleCommand, + (const char *, lldb::SBExecutionContext &, + lldb::SBCommandReturnObject &, bool)); + LLDB_REGISTER_METHOD(void, SBCommandInterpreter, HandleCommandsFromFile, + (lldb::SBFileSpec &, lldb::SBExecutionContext &, + lldb::SBCommandInterpreterRunOptions &, + lldb::SBCommandReturnObject)); + LLDB_REGISTER_METHOD(int, SBCommandInterpreter, HandleCompletion, + (const char *, const char *, const char *, int, int, + lldb::SBStringList &)); + LLDB_REGISTER_METHOD(int, SBCommandInterpreter, + HandleCompletionWithDescriptions, + (const char *, const char *, const char *, int, int, + lldb::SBStringList &, lldb::SBStringList &)); + LLDB_REGISTER_METHOD(int, SBCommandInterpreter, + HandleCompletionWithDescriptions, + (const char *, uint32_t, int, int, + lldb::SBStringList &, lldb::SBStringList &)); + LLDB_REGISTER_METHOD( + int, SBCommandInterpreter, HandleCompletion, + (const char *, uint32_t, int, int, lldb::SBStringList &)); + LLDB_REGISTER_METHOD(bool, SBCommandInterpreter, HasCommands, ()); + LLDB_REGISTER_METHOD(bool, SBCommandInterpreter, HasAliases, ()); + LLDB_REGISTER_METHOD(bool, SBCommandInterpreter, HasAliasOptions, ()); + LLDB_REGISTER_METHOD(lldb::SBProcess, SBCommandInterpreter, GetProcess, ()); + LLDB_REGISTER_METHOD(lldb::SBDebugger, SBCommandInterpreter, GetDebugger, + ()); + LLDB_REGISTER_METHOD(bool, SBCommandInterpreter, GetPromptOnQuit, ()); + LLDB_REGISTER_METHOD(void, SBCommandInterpreter, SetPromptOnQuit, (bool)); + LLDB_REGISTER_METHOD(void, SBCommandInterpreter, AllowExitCodeOnQuit, + (bool)); + LLDB_REGISTER_METHOD(bool, SBCommandInterpreter, HasCustomQuitExitCode, ()); + LLDB_REGISTER_METHOD(int, SBCommandInterpreter, GetQuitStatus, ()); + LLDB_REGISTER_METHOD(void, SBCommandInterpreter, ResolveCommand, + (const char *, lldb::SBCommandReturnObject &)); + LLDB_REGISTER_METHOD(void, SBCommandInterpreter, + SourceInitFileInHomeDirectory, + (lldb::SBCommandReturnObject &)); + LLDB_REGISTER_METHOD(void, SBCommandInterpreter, + SourceInitFileInCurrentWorkingDirectory, + (lldb::SBCommandReturnObject &)); + LLDB_REGISTER_METHOD(lldb::SBBroadcaster, SBCommandInterpreter, + GetBroadcaster, ()); + LLDB_REGISTER_STATIC_METHOD(const char *, SBCommandInterpreter, + GetBroadcasterClass, ()); + LLDB_REGISTER_STATIC_METHOD(const char *, SBCommandInterpreter, + GetArgumentTypeAsCString, + (const lldb::CommandArgumentType)); + LLDB_REGISTER_STATIC_METHOD(const char *, SBCommandInterpreter, + GetArgumentDescriptionAsCString, + (const lldb::CommandArgumentType)); + LLDB_REGISTER_STATIC_METHOD(bool, SBCommandInterpreter, + EventIsCommandInterpreterEvent, + (const lldb::SBEvent &)); + LLDB_REGISTER_METHOD(lldb::SBCommand, SBCommandInterpreter, + AddMultiwordCommand, (const char *, const char *)); + LLDB_REGISTER_METHOD( + lldb::SBCommand, SBCommandInterpreter, AddCommand, + (const char *, lldb::SBCommandPluginInterface *, const char *)); + LLDB_REGISTER_METHOD(lldb::SBCommand, SBCommandInterpreter, AddCommand, + (const char *, lldb::SBCommandPluginInterface *, + const char *, const char *)); + LLDB_REGISTER_CONSTRUCTOR(SBCommand, ()); + LLDB_REGISTER_METHOD(bool, SBCommand, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBCommand, operator bool, ()); + LLDB_REGISTER_METHOD(const char *, SBCommand, GetName, ()); + LLDB_REGISTER_METHOD(const char *, SBCommand, GetHelp, ()); + LLDB_REGISTER_METHOD(const char *, SBCommand, GetHelpLong, ()); + LLDB_REGISTER_METHOD(void, SBCommand, SetHelp, (const char *)); + LLDB_REGISTER_METHOD(void, SBCommand, SetHelpLong, (const char *)); + LLDB_REGISTER_METHOD(lldb::SBCommand, SBCommand, AddMultiwordCommand, + (const char *, const char *)); + LLDB_REGISTER_METHOD( + lldb::SBCommand, SBCommand, AddCommand, + (const char *, lldb::SBCommandPluginInterface *, const char *)); + LLDB_REGISTER_METHOD(lldb::SBCommand, SBCommand, AddCommand, + (const char *, lldb::SBCommandPluginInterface *, + const char *, const char *)); + LLDB_REGISTER_METHOD(uint32_t, SBCommand, GetFlags, ()); + LLDB_REGISTER_METHOD(void, SBCommand, SetFlags, (uint32_t)); +} + +} +} diff --git a/source/API/SBCommandReturnObject.cpp b/source/API/SBCommandReturnObject.cpp index 7bc02985a3ec1..94e89916f7f6d 100644 --- a/source/API/SBCommandReturnObject.cpp +++ b/source/API/SBCommandReturnObject.cpp @@ -1,105 +1,113 @@ //===-- SBCommandReturnObject.cpp -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBCommandReturnObject.h" +#include "SBReproducerPrivate.h" +#include "Utils.h" #include "lldb/API/SBError.h" #include "lldb/API/SBStream.h" - #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Utility/ConstString.h" -#include "lldb/Utility/Log.h" #include "lldb/Utility/Status.h" using namespace lldb; using namespace lldb_private; SBCommandReturnObject::SBCommandReturnObject() - : m_opaque_ap(new CommandReturnObject()) {} + : m_opaque_up(new CommandReturnObject()) { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBCommandReturnObject); +} SBCommandReturnObject::SBCommandReturnObject(const SBCommandReturnObject &rhs) - : m_opaque_ap() { - if (rhs.m_opaque_ap) - m_opaque_ap.reset(new CommandReturnObject(*rhs.m_opaque_ap)); + : m_opaque_up() { + LLDB_RECORD_CONSTRUCTOR(SBCommandReturnObject, + (const lldb::SBCommandReturnObject &), rhs); + + m_opaque_up = clone(rhs.m_opaque_up); } SBCommandReturnObject::SBCommandReturnObject(CommandReturnObject *ptr) - : m_opaque_ap(ptr) {} + : m_opaque_up(ptr) { + LLDB_RECORD_CONSTRUCTOR(SBCommandReturnObject, + (lldb_private::CommandReturnObject *), ptr); +} SBCommandReturnObject::~SBCommandReturnObject() = default; CommandReturnObject *SBCommandReturnObject::Release() { - return m_opaque_ap.release(); + LLDB_RECORD_METHOD_NO_ARGS(lldb_private::CommandReturnObject *, + SBCommandReturnObject, Release); + + return LLDB_RECORD_RESULT(m_opaque_up.release()); } const SBCommandReturnObject &SBCommandReturnObject:: operator=(const SBCommandReturnObject &rhs) { - if (this != &rhs) { - if (rhs.m_opaque_ap) - m_opaque_ap.reset(new CommandReturnObject(*rhs.m_opaque_ap)); - else - m_opaque_ap.reset(); - } - return *this; + LLDB_RECORD_METHOD( + const lldb::SBCommandReturnObject &, + SBCommandReturnObject, operator=,(const lldb::SBCommandReturnObject &), + rhs); + + if (this != &rhs) + m_opaque_up = clone(rhs.m_opaque_up); + return LLDB_RECORD_RESULT(*this); +} + +bool SBCommandReturnObject::IsValid() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandReturnObject, IsValid); + return this->operator bool(); } +SBCommandReturnObject::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandReturnObject, operator bool); -bool SBCommandReturnObject::IsValid() const { return m_opaque_ap != nullptr; } + return m_opaque_up != nullptr; +} const char *SBCommandReturnObject::GetOutput() { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBCommandReturnObject, GetOutput); - if (m_opaque_ap) { - llvm::StringRef output = m_opaque_ap->GetOutputData(); + if (m_opaque_up) { + llvm::StringRef output = m_opaque_up->GetOutputData(); ConstString result(output.empty() ? llvm::StringRef("") : output); - if (log) - log->Printf("SBCommandReturnObject(%p)::GetOutput () => \"%s\"", - static_cast<void *>(m_opaque_ap.get()), result.AsCString()); - return result.AsCString(); } - if (log) - log->Printf("SBCommandReturnObject(%p)::GetOutput () => nullptr", - static_cast<void *>(m_opaque_ap.get())); - return nullptr; } const char *SBCommandReturnObject::GetError() { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBCommandReturnObject, GetError); - if (m_opaque_ap) { - llvm::StringRef output = m_opaque_ap->GetErrorData(); + if (m_opaque_up) { + llvm::StringRef output = m_opaque_up->GetErrorData(); ConstString result(output.empty() ? llvm::StringRef("") : output); - if (log) - log->Printf("SBCommandReturnObject(%p)::GetError () => \"%s\"", - static_cast<void *>(m_opaque_ap.get()), result.AsCString()); - return result.AsCString(); } - if (log) - log->Printf("SBCommandReturnObject(%p)::GetError () => nullptr", - static_cast<void *>(m_opaque_ap.get())); - return nullptr; } size_t SBCommandReturnObject::GetOutputSize() { - return (m_opaque_ap ? m_opaque_ap->GetOutputData().size() : 0); + LLDB_RECORD_METHOD_NO_ARGS(size_t, SBCommandReturnObject, GetOutputSize); + + return (m_opaque_up ? m_opaque_up->GetOutputData().size() : 0); } size_t SBCommandReturnObject::GetErrorSize() { - return (m_opaque_ap ? m_opaque_ap->GetErrorData().size() : 0); + LLDB_RECORD_METHOD_NO_ARGS(size_t, SBCommandReturnObject, GetErrorSize); + + return (m_opaque_up ? m_opaque_up->GetErrorData().size() : 0); } size_t SBCommandReturnObject::PutOutput(FILE *fh) { + LLDB_RECORD_METHOD(size_t, SBCommandReturnObject, PutOutput, (FILE *), fh); + if (fh) { size_t num_bytes = GetOutputSize(); if (num_bytes) @@ -109,6 +117,8 @@ size_t SBCommandReturnObject::PutOutput(FILE *fh) { } size_t SBCommandReturnObject::PutError(FILE *fh) { + LLDB_RECORD_METHOD(size_t, SBCommandReturnObject, PutError, (FILE *), fh); + if (fh) { size_t num_bytes = GetErrorSize(); if (num_bytes) @@ -118,71 +128,92 @@ size_t SBCommandReturnObject::PutError(FILE *fh) { } void SBCommandReturnObject::Clear() { - if (m_opaque_ap) - m_opaque_ap->Clear(); + LLDB_RECORD_METHOD_NO_ARGS(void, SBCommandReturnObject, Clear); + + if (m_opaque_up) + m_opaque_up->Clear(); } lldb::ReturnStatus SBCommandReturnObject::GetStatus() { - return (m_opaque_ap ? m_opaque_ap->GetStatus() : lldb::eReturnStatusInvalid); + LLDB_RECORD_METHOD_NO_ARGS(lldb::ReturnStatus, SBCommandReturnObject, + GetStatus); + + return (m_opaque_up ? m_opaque_up->GetStatus() : lldb::eReturnStatusInvalid); } void SBCommandReturnObject::SetStatus(lldb::ReturnStatus status) { - if (m_opaque_ap) - m_opaque_ap->SetStatus(status); + LLDB_RECORD_METHOD(void, SBCommandReturnObject, SetStatus, + (lldb::ReturnStatus), status); + + if (m_opaque_up) + m_opaque_up->SetStatus(status); } bool SBCommandReturnObject::Succeeded() { - return (m_opaque_ap ? m_opaque_ap->Succeeded() : false); + LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommandReturnObject, Succeeded); + + return (m_opaque_up ? m_opaque_up->Succeeded() : false); } bool SBCommandReturnObject::HasResult() { - return (m_opaque_ap ? m_opaque_ap->HasResult() : false); + LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommandReturnObject, HasResult); + + return (m_opaque_up ? m_opaque_up->HasResult() : false); } void SBCommandReturnObject::AppendMessage(const char *message) { - if (m_opaque_ap) - m_opaque_ap->AppendMessage(message); + LLDB_RECORD_METHOD(void, SBCommandReturnObject, AppendMessage, (const char *), + message); + + if (m_opaque_up) + m_opaque_up->AppendMessage(message); } void SBCommandReturnObject::AppendWarning(const char *message) { - if (m_opaque_ap) - m_opaque_ap->AppendWarning(message); + LLDB_RECORD_METHOD(void, SBCommandReturnObject, AppendWarning, (const char *), + message); + + if (m_opaque_up) + m_opaque_up->AppendWarning(message); } CommandReturnObject *SBCommandReturnObject::operator->() const { - return m_opaque_ap.get(); + return m_opaque_up.get(); } CommandReturnObject *SBCommandReturnObject::get() const { - return m_opaque_ap.get(); + return m_opaque_up.get(); } CommandReturnObject &SBCommandReturnObject::operator*() const { - assert(m_opaque_ap.get()); - return *(m_opaque_ap.get()); + assert(m_opaque_up.get()); + return *(m_opaque_up.get()); } CommandReturnObject &SBCommandReturnObject::ref() const { - assert(m_opaque_ap.get()); - return *(m_opaque_ap.get()); + assert(m_opaque_up.get()); + return *(m_opaque_up.get()); } void SBCommandReturnObject::SetLLDBObjectPtr(CommandReturnObject *ptr) { - if (m_opaque_ap) - m_opaque_ap.reset(ptr); + if (m_opaque_up) + m_opaque_up.reset(ptr); } bool SBCommandReturnObject::GetDescription(SBStream &description) { + LLDB_RECORD_METHOD(bool, SBCommandReturnObject, GetDescription, + (lldb::SBStream &), description); + Stream &strm = description.ref(); - if (m_opaque_ap) { + if (m_opaque_up) { description.Printf("Error: "); - lldb::ReturnStatus status = m_opaque_ap->GetStatus(); + lldb::ReturnStatus status = m_opaque_up->GetStatus(); if (status == lldb::eReturnStatusStarted) strm.PutCString("Started"); else if (status == lldb::eReturnStatusInvalid) strm.PutCString("Invalid"); - else if (m_opaque_ap->Succeeded()) + else if (m_opaque_up->Succeeded()) strm.PutCString("Success"); else strm.PutCString("Fail"); @@ -199,60 +230,81 @@ bool SBCommandReturnObject::GetDescription(SBStream &description) { } void SBCommandReturnObject::SetImmediateOutputFile(FILE *fh) { + LLDB_RECORD_METHOD(void, SBCommandReturnObject, SetImmediateOutputFile, + (FILE *), fh); + SetImmediateOutputFile(fh, false); } void SBCommandReturnObject::SetImmediateErrorFile(FILE *fh) { + LLDB_RECORD_METHOD(void, SBCommandReturnObject, SetImmediateErrorFile, + (FILE *), fh); + SetImmediateErrorFile(fh, false); } void SBCommandReturnObject::SetImmediateOutputFile(FILE *fh, bool transfer_ownership) { - if (m_opaque_ap) - m_opaque_ap->SetImmediateOutputFile(fh, transfer_ownership); + LLDB_RECORD_METHOD(void, SBCommandReturnObject, SetImmediateOutputFile, + (FILE *, bool), fh, transfer_ownership); + + if (m_opaque_up) + m_opaque_up->SetImmediateOutputFile(fh, transfer_ownership); } void SBCommandReturnObject::SetImmediateErrorFile(FILE *fh, bool transfer_ownership) { - if (m_opaque_ap) - m_opaque_ap->SetImmediateErrorFile(fh, transfer_ownership); + LLDB_RECORD_METHOD(void, SBCommandReturnObject, SetImmediateErrorFile, + (FILE *, bool), fh, transfer_ownership); + + if (m_opaque_up) + m_opaque_up->SetImmediateErrorFile(fh, transfer_ownership); } void SBCommandReturnObject::PutCString(const char *string, int len) { - if (m_opaque_ap) { + LLDB_RECORD_METHOD(void, SBCommandReturnObject, PutCString, + (const char *, int), string, len); + + if (m_opaque_up) { if (len == 0 || string == nullptr || *string == 0) { return; } else if (len > 0) { std::string buffer(string, len); - m_opaque_ap->AppendMessage(buffer.c_str()); + m_opaque_up->AppendMessage(buffer.c_str()); } else - m_opaque_ap->AppendMessage(string); + m_opaque_up->AppendMessage(string); } } const char *SBCommandReturnObject::GetOutput(bool only_if_no_immediate) { - if (!m_opaque_ap) + LLDB_RECORD_METHOD(const char *, SBCommandReturnObject, GetOutput, (bool), + only_if_no_immediate); + + if (!m_opaque_up) return nullptr; if (!only_if_no_immediate || - m_opaque_ap->GetImmediateOutputStream().get() == nullptr) + m_opaque_up->GetImmediateOutputStream().get() == nullptr) return GetOutput(); return nullptr; } const char *SBCommandReturnObject::GetError(bool only_if_no_immediate) { - if (!m_opaque_ap) + LLDB_RECORD_METHOD(const char *, SBCommandReturnObject, GetError, (bool), + only_if_no_immediate); + + if (!m_opaque_up) return nullptr; if (!only_if_no_immediate || - m_opaque_ap->GetImmediateErrorStream().get() == nullptr) + m_opaque_up->GetImmediateErrorStream().get() == nullptr) return GetError(); return nullptr; } size_t SBCommandReturnObject::Printf(const char *format, ...) { - if (m_opaque_ap) { + if (m_opaque_up) { va_list args; va_start(args, format); - size_t result = m_opaque_ap->GetOutputStream().PrintfVarArg(format, args); + size_t result = m_opaque_up->GetOutputStream().PrintfVarArg(format, args); va_end(args); return result; } @@ -261,15 +313,79 @@ size_t SBCommandReturnObject::Printf(const char *format, ...) { void SBCommandReturnObject::SetError(lldb::SBError &error, const char *fallback_error_cstr) { - if (m_opaque_ap) { + LLDB_RECORD_METHOD(void, SBCommandReturnObject, SetError, + (lldb::SBError &, const char *), error, + fallback_error_cstr); + + if (m_opaque_up) { if (error.IsValid()) - m_opaque_ap->SetError(error.ref(), fallback_error_cstr); + m_opaque_up->SetError(error.ref(), fallback_error_cstr); else if (fallback_error_cstr) - m_opaque_ap->SetError(Status(), fallback_error_cstr); + m_opaque_up->SetError(Status(), fallback_error_cstr); } } void SBCommandReturnObject::SetError(const char *error_cstr) { - if (m_opaque_ap && error_cstr) - m_opaque_ap->SetError(error_cstr); + LLDB_RECORD_METHOD(void, SBCommandReturnObject, SetError, (const char *), + error_cstr); + + if (m_opaque_up && error_cstr) + m_opaque_up->SetError(error_cstr); +} + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBCommandReturnObject>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBCommandReturnObject, ()); + LLDB_REGISTER_CONSTRUCTOR(SBCommandReturnObject, + (const lldb::SBCommandReturnObject &)); + LLDB_REGISTER_CONSTRUCTOR(SBCommandReturnObject, + (lldb_private::CommandReturnObject *)); + LLDB_REGISTER_METHOD(lldb_private::CommandReturnObject *, + SBCommandReturnObject, Release, ()); + LLDB_REGISTER_METHOD( + const lldb::SBCommandReturnObject &, + SBCommandReturnObject, operator=,(const lldb::SBCommandReturnObject &)); + LLDB_REGISTER_METHOD_CONST(bool, SBCommandReturnObject, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBCommandReturnObject, operator bool, ()); + LLDB_REGISTER_METHOD(const char *, SBCommandReturnObject, GetOutput, ()); + LLDB_REGISTER_METHOD(const char *, SBCommandReturnObject, GetError, ()); + LLDB_REGISTER_METHOD(size_t, SBCommandReturnObject, GetOutputSize, ()); + LLDB_REGISTER_METHOD(size_t, SBCommandReturnObject, GetErrorSize, ()); + LLDB_REGISTER_METHOD(size_t, SBCommandReturnObject, PutOutput, (FILE *)); + LLDB_REGISTER_METHOD(size_t, SBCommandReturnObject, PutError, (FILE *)); + LLDB_REGISTER_METHOD(void, SBCommandReturnObject, Clear, ()); + LLDB_REGISTER_METHOD(lldb::ReturnStatus, SBCommandReturnObject, GetStatus, + ()); + LLDB_REGISTER_METHOD(void, SBCommandReturnObject, SetStatus, + (lldb::ReturnStatus)); + LLDB_REGISTER_METHOD(bool, SBCommandReturnObject, Succeeded, ()); + LLDB_REGISTER_METHOD(bool, SBCommandReturnObject, HasResult, ()); + LLDB_REGISTER_METHOD(void, SBCommandReturnObject, AppendMessage, + (const char *)); + LLDB_REGISTER_METHOD(void, SBCommandReturnObject, AppendWarning, + (const char *)); + LLDB_REGISTER_METHOD(bool, SBCommandReturnObject, GetDescription, + (lldb::SBStream &)); + LLDB_REGISTER_METHOD(void, SBCommandReturnObject, SetImmediateOutputFile, + (FILE *)); + LLDB_REGISTER_METHOD(void, SBCommandReturnObject, SetImmediateErrorFile, + (FILE *)); + LLDB_REGISTER_METHOD(void, SBCommandReturnObject, SetImmediateOutputFile, + (FILE *, bool)); + LLDB_REGISTER_METHOD(void, SBCommandReturnObject, SetImmediateErrorFile, + (FILE *, bool)); + LLDB_REGISTER_METHOD(void, SBCommandReturnObject, PutCString, + (const char *, int)); + LLDB_REGISTER_METHOD(const char *, SBCommandReturnObject, GetOutput, + (bool)); + LLDB_REGISTER_METHOD(const char *, SBCommandReturnObject, GetError, (bool)); + LLDB_REGISTER_METHOD(void, SBCommandReturnObject, SetError, + (lldb::SBError &, const char *)); + LLDB_REGISTER_METHOD(void, SBCommandReturnObject, SetError, (const char *)); +} + +} } diff --git a/source/API/SBCommunication.cpp b/source/API/SBCommunication.cpp index 63b672efe3c02..90df70bde72f1 100644 --- a/source/API/SBCommunication.cpp +++ b/source/API/SBCommunication.cpp @@ -1,65 +1,77 @@ //===-- SBCommunication.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBCommunication.h" +#include "SBReproducerPrivate.h" #include "lldb/API/SBBroadcaster.h" #include "lldb/Core/Communication.h" #include "lldb/Host/ConnectionFileDescriptor.h" #include "lldb/Host/Host.h" -#include "lldb/Utility/Log.h" using namespace lldb; using namespace lldb_private; -SBCommunication::SBCommunication() : m_opaque(NULL), m_opaque_owned(false) {} +SBCommunication::SBCommunication() : m_opaque(nullptr), m_opaque_owned(false) { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBCommunication); +} SBCommunication::SBCommunication(const char *broadcaster_name) : m_opaque(new Communication(broadcaster_name)), m_opaque_owned(true) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - - if (log) - log->Printf("SBCommunication::SBCommunication (broadcaster_name=\"%s\") => " - "SBCommunication(%p)", - broadcaster_name, static_cast<void *>(m_opaque)); + LLDB_RECORD_CONSTRUCTOR(SBCommunication, (const char *), broadcaster_name); } SBCommunication::~SBCommunication() { if (m_opaque && m_opaque_owned) delete m_opaque; - m_opaque = NULL; + m_opaque = nullptr; m_opaque_owned = false; } -bool SBCommunication::IsValid() const { return m_opaque != NULL; } +bool SBCommunication::IsValid() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommunication, IsValid); + return this->operator bool(); +} +SBCommunication::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommunication, operator bool); + + return m_opaque != nullptr; +} bool SBCommunication::GetCloseOnEOF() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommunication, GetCloseOnEOF); + if (m_opaque) return m_opaque->GetCloseOnEOF(); return false; } void SBCommunication::SetCloseOnEOF(bool b) { + LLDB_RECORD_METHOD(void, SBCommunication, SetCloseOnEOF, (bool), b); + if (m_opaque) m_opaque->SetCloseOnEOF(b); } ConnectionStatus SBCommunication::Connect(const char *url) { + LLDB_RECORD_METHOD(lldb::ConnectionStatus, SBCommunication, Connect, + (const char *), url); + if (m_opaque) { if (!m_opaque->HasConnection()) m_opaque->SetConnection(Host::CreateDefaultConnection(url).release()); - return m_opaque->Connect(url, NULL); + return m_opaque->Connect(url, nullptr); } return eConnectionStatusNoConnection; } ConnectionStatus SBCommunication::AdoptFileDesriptor(int fd, bool owns_fd) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(lldb::ConnectionStatus, SBCommunication, + AdoptFileDesriptor, (int, bool), fd, owns_fd); ConnectionStatus status = eConnectionStatusNoConnection; if (m_opaque) { @@ -73,183 +85,131 @@ ConnectionStatus SBCommunication::AdoptFileDesriptor(int fd, bool owns_fd) { else status = eConnectionStatusLostConnection; } - - if (log) - log->Printf( - "SBCommunication(%p)::AdoptFileDescriptor (fd=%d, ownd_fd=%i) => %s", - static_cast<void *>(m_opaque), fd, owns_fd, - Communication::ConnectionStatusAsCString(status)); - return status; } ConnectionStatus SBCommunication::Disconnect() { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_NO_ARGS(lldb::ConnectionStatus, SBCommunication, + Disconnect); ConnectionStatus status = eConnectionStatusNoConnection; if (m_opaque) status = m_opaque->Disconnect(); - - if (log) - log->Printf("SBCommunication(%p)::Disconnect () => %s", - static_cast<void *>(m_opaque), - Communication::ConnectionStatusAsCString(status)); - return status; } bool SBCommunication::IsConnected() const { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - bool result = false; - if (m_opaque) - result = m_opaque->IsConnected(); + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommunication, IsConnected); - if (log) - log->Printf("SBCommunication(%p)::IsConnected () => %i", - static_cast<void *>(m_opaque), result); - - return false; + return m_opaque ? m_opaque->IsConnected() : false; } size_t SBCommunication::Read(void *dst, size_t dst_len, uint32_t timeout_usec, ConnectionStatus &status) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBCommunication(%p)::Read (dst=%p, dst_len=%" PRIu64 - ", timeout_usec=%u, &status)...", - static_cast<void *>(m_opaque), static_cast<void *>(dst), - static_cast<uint64_t>(dst_len), timeout_usec); + LLDB_RECORD_DUMMY(size_t, SBCommunication, Read, + (void *, size_t, uint32_t, lldb::ConnectionStatus &), dst, + dst_len, timeout_usec, status); + size_t bytes_read = 0; Timeout<std::micro> timeout = timeout_usec == UINT32_MAX ? Timeout<std::micro>(llvm::None) : std::chrono::microseconds(timeout_usec); if (m_opaque) - bytes_read = m_opaque->Read(dst, dst_len, timeout, status, NULL); + bytes_read = m_opaque->Read(dst, dst_len, timeout, status, nullptr); else status = eConnectionStatusNoConnection; - if (log) - log->Printf("SBCommunication(%p)::Read (dst=%p, dst_len=%" PRIu64 - ", timeout_usec=%u, &status=%s) => %" PRIu64, - static_cast<void *>(m_opaque), static_cast<void *>(dst), - static_cast<uint64_t>(dst_len), timeout_usec, - Communication::ConnectionStatusAsCString(status), - static_cast<uint64_t>(bytes_read)); return bytes_read; } size_t SBCommunication::Write(const void *src, size_t src_len, ConnectionStatus &status) { + LLDB_RECORD_DUMMY(size_t, SBCommunication, Write, + (const void *, size_t, lldb::ConnectionStatus &), src, + src_len, status); + size_t bytes_written = 0; if (m_opaque) - bytes_written = m_opaque->Write(src, src_len, status, NULL); + bytes_written = m_opaque->Write(src, src_len, status, nullptr); else status = eConnectionStatusNoConnection; - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBCommunication(%p)::Write (src=%p, src_len=%" PRIu64 - ", &status=%s) => %" PRIu64, - static_cast<void *>(m_opaque), static_cast<const void *>(src), - static_cast<uint64_t>(src_len), - Communication::ConnectionStatusAsCString(status), - static_cast<uint64_t>(bytes_written)); - - return 0; + return bytes_written; } bool SBCommunication::ReadThreadStart() { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - - bool success = false; - if (m_opaque) - success = m_opaque->StartReadThread(); - - if (log) - log->Printf("SBCommunication(%p)::ReadThreadStart () => %i", - static_cast<void *>(m_opaque), success); + LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommunication, ReadThreadStart); - return success; + return m_opaque ? m_opaque->StartReadThread() : false; } bool SBCommunication::ReadThreadStop() { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBCommunication(%p)::ReadThreadStop ()...", - static_cast<void *>(m_opaque)); + LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommunication, ReadThreadStop); - bool success = false; - if (m_opaque) - success = m_opaque->StopReadThread(); - - if (log) - log->Printf("SBCommunication(%p)::ReadThreadStop () => %i", - static_cast<void *>(m_opaque), success); - - return success; + return m_opaque ? m_opaque->StopReadThread() : false; } bool SBCommunication::ReadThreadIsRunning() { - bool result = false; - if (m_opaque) - result = m_opaque->ReadThreadIsRunning(); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBCommunication(%p)::ReadThreadIsRunning () => %i", - static_cast<void *>(m_opaque), result); - return result; + LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommunication, ReadThreadIsRunning); + + return m_opaque ? m_opaque->ReadThreadIsRunning() : false; } bool SBCommunication::SetReadThreadBytesReceivedCallback( ReadThreadBytesReceived callback, void *callback_baton) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_DUMMY(bool, SBCommunication, SetReadThreadBytesReceivedCallback, + (lldb::SBCommunication::ReadThreadBytesReceived, void *), + callback, callback_baton); bool result = false; if (m_opaque) { m_opaque->SetReadThreadBytesReceivedCallback(callback, callback_baton); result = true; } - - if (log) - log->Printf("SBCommunication(%p)::SetReadThreadBytesReceivedCallback " - "(callback=%p, baton=%p) => %i", - static_cast<void *>(m_opaque), - reinterpret_cast<void *>(reinterpret_cast<intptr_t>(callback)), - static_cast<void *>(callback_baton), result); - return result; } SBBroadcaster SBCommunication::GetBroadcaster() { - SBBroadcaster broadcaster(m_opaque, false); - - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBBroadcaster, SBCommunication, + GetBroadcaster); - if (log) - log->Printf("SBCommunication(%p)::GetBroadcaster () => SBBroadcaster (%p)", - static_cast<void *>(m_opaque), - static_cast<void *>(broadcaster.get())); - - return broadcaster; + SBBroadcaster broadcaster(m_opaque, false); + return LLDB_RECORD_RESULT(broadcaster); } const char *SBCommunication::GetBroadcasterClass() { + LLDB_RECORD_STATIC_METHOD_NO_ARGS(const char *, SBCommunication, + GetBroadcasterClass); + return Communication::GetStaticBroadcasterClass().AsCString(); } -// -// void -// SBCommunication::CreateIfNeeded () -//{ -// if (m_opaque == NULL) -// { -// static uint32_t g_broadcaster_num; -// char broadcaster_name[256]; -// ::snprintf (name, broadcaster_name, "%p SBCommunication", this); -// m_opaque = new Communication (broadcaster_name); -// m_opaque_owned = true; -// } -// assert (m_opaque); -//} -// -// +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBCommunication>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBCommunication, ()); + LLDB_REGISTER_CONSTRUCTOR(SBCommunication, (const char *)); + LLDB_REGISTER_METHOD_CONST(bool, SBCommunication, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBCommunication, operator bool, ()); + LLDB_REGISTER_METHOD(bool, SBCommunication, GetCloseOnEOF, ()); + LLDB_REGISTER_METHOD(void, SBCommunication, SetCloseOnEOF, (bool)); + LLDB_REGISTER_METHOD(lldb::ConnectionStatus, SBCommunication, Connect, + (const char *)); + LLDB_REGISTER_METHOD(lldb::ConnectionStatus, SBCommunication, + AdoptFileDesriptor, (int, bool)); + LLDB_REGISTER_METHOD(lldb::ConnectionStatus, SBCommunication, Disconnect, + ()); + LLDB_REGISTER_METHOD_CONST(bool, SBCommunication, IsConnected, ()); + LLDB_REGISTER_METHOD(bool, SBCommunication, ReadThreadStart, ()); + LLDB_REGISTER_METHOD(bool, SBCommunication, ReadThreadStop, ()); + LLDB_REGISTER_METHOD(bool, SBCommunication, ReadThreadIsRunning, ()); + LLDB_REGISTER_METHOD(lldb::SBBroadcaster, SBCommunication, GetBroadcaster, + ()); + LLDB_REGISTER_STATIC_METHOD(const char *, SBCommunication, + GetBroadcasterClass, ()); +} + +} +} diff --git a/source/API/SBCompileUnit.cpp b/source/API/SBCompileUnit.cpp index 4e2fc6af460a4..c9ca70645d958 100644 --- a/source/API/SBCompileUnit.cpp +++ b/source/API/SBCompileUnit.cpp @@ -1,13 +1,13 @@ //===-- SBCompileUnit.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBCompileUnit.h" +#include "SBReproducerPrivate.h" #include "lldb/API/SBLineEntry.h" #include "lldb/API/SBStream.h" #include "lldb/Core/Module.h" @@ -16,44 +16,58 @@ #include "lldb/Symbol/LineTable.h" #include "lldb/Symbol/SymbolVendor.h" #include "lldb/Symbol/Type.h" -#include "lldb/Utility/Log.h" using namespace lldb; using namespace lldb_private; -SBCompileUnit::SBCompileUnit() : m_opaque_ptr(NULL) {} +SBCompileUnit::SBCompileUnit() : m_opaque_ptr(nullptr) { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBCompileUnit); +} SBCompileUnit::SBCompileUnit(lldb_private::CompileUnit *lldb_object_ptr) : m_opaque_ptr(lldb_object_ptr) {} SBCompileUnit::SBCompileUnit(const SBCompileUnit &rhs) - : m_opaque_ptr(rhs.m_opaque_ptr) {} + : m_opaque_ptr(rhs.m_opaque_ptr) { + LLDB_RECORD_CONSTRUCTOR(SBCompileUnit, (const lldb::SBCompileUnit &), rhs); +} const SBCompileUnit &SBCompileUnit::operator=(const SBCompileUnit &rhs) { + LLDB_RECORD_METHOD(const lldb::SBCompileUnit &, + SBCompileUnit, operator=,(const lldb::SBCompileUnit &), + rhs); + m_opaque_ptr = rhs.m_opaque_ptr; - return *this; + return LLDB_RECORD_RESULT(*this); } -SBCompileUnit::~SBCompileUnit() { m_opaque_ptr = NULL; } +SBCompileUnit::~SBCompileUnit() { m_opaque_ptr = nullptr; } SBFileSpec SBCompileUnit::GetFileSpec() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBFileSpec, SBCompileUnit, + GetFileSpec); + SBFileSpec file_spec; if (m_opaque_ptr) file_spec.SetFileSpec(*m_opaque_ptr); - return file_spec; + return LLDB_RECORD_RESULT(file_spec); } uint32_t SBCompileUnit::GetNumLineEntries() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBCompileUnit, GetNumLineEntries); + if (m_opaque_ptr) { LineTable *line_table = m_opaque_ptr->GetLineTable(); - if (line_table) + if (line_table) { return line_table->GetSize(); + } } return 0; } SBLineEntry SBCompileUnit::GetLineEntryAtIndex(uint32_t idx) const { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_CONST(lldb::SBLineEntry, SBCompileUnit, + GetLineEntryAtIndex, (uint32_t), idx); SBLineEntry sb_line_entry; if (m_opaque_ptr) { @@ -65,20 +79,15 @@ SBLineEntry SBCompileUnit::GetLineEntryAtIndex(uint32_t idx) const { } } - if (log) { - SBStream sstr; - sb_line_entry.GetDescription(sstr); - log->Printf("SBCompileUnit(%p)::GetLineEntryAtIndex (idx=%u) => " - "SBLineEntry(%p): '%s'", - static_cast<void *>(m_opaque_ptr), idx, - static_cast<void *>(sb_line_entry.get()), sstr.GetData()); - } - - return sb_line_entry; + return LLDB_RECORD_RESULT(sb_line_entry); } uint32_t SBCompileUnit::FindLineEntryIndex(uint32_t start_idx, uint32_t line, SBFileSpec *inline_file_spec) const { + LLDB_RECORD_METHOD_CONST(uint32_t, SBCompileUnit, FindLineEntryIndex, + (uint32_t, uint32_t, lldb::SBFileSpec *), start_idx, + line, inline_file_spec); + const bool exact = true; return FindLineEntryIndex(start_idx, line, inline_file_spec, exact); } @@ -86,7 +95,9 @@ uint32_t SBCompileUnit::FindLineEntryIndex(uint32_t start_idx, uint32_t line, uint32_t SBCompileUnit::FindLineEntryIndex(uint32_t start_idx, uint32_t line, SBFileSpec *inline_file_spec, bool exact) const { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_CONST(uint32_t, SBCompileUnit, FindLineEntryIndex, + (uint32_t, uint32_t, lldb::SBFileSpec *, bool), + start_idx, line, inline_file_spec, exact); uint32_t index = UINT32_MAX; if (m_opaque_ptr) { @@ -97,107 +108,103 @@ uint32_t SBCompileUnit::FindLineEntryIndex(uint32_t start_idx, uint32_t line, file_spec = *m_opaque_ptr; index = m_opaque_ptr->FindLineEntry( - start_idx, line, inline_file_spec ? inline_file_spec->get() : NULL, - exact, NULL); - } - - if (log) { - SBStream sstr; - if (index == UINT32_MAX) { - log->Printf("SBCompileUnit(%p)::FindLineEntryIndex (start_idx=%u, " - "line=%u, SBFileSpec(%p)) => NOT FOUND", - static_cast<void *>(m_opaque_ptr), start_idx, line, - inline_file_spec - ? static_cast<const void *>(inline_file_spec->get()) - : NULL); - } else { - log->Printf("SBCompileUnit(%p)::FindLineEntryIndex (start_idx=%u, " - "line=%u, SBFileSpec(%p)) => %u", - static_cast<void *>(m_opaque_ptr), start_idx, line, - inline_file_spec - ? static_cast<const void *>(inline_file_spec->get()) - : NULL, - index); - } + start_idx, line, inline_file_spec ? inline_file_spec->get() : nullptr, + exact, nullptr); } return index; } uint32_t SBCompileUnit::GetNumSupportFiles() const { - if (m_opaque_ptr) { - FileSpecList &support_files = m_opaque_ptr->GetSupportFiles(); - return support_files.GetSize(); - } + LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBCompileUnit, GetNumSupportFiles); + + if (m_opaque_ptr) + return m_opaque_ptr->GetSupportFiles().GetSize(); + return 0; } lldb::SBTypeList SBCompileUnit::GetTypes(uint32_t type_mask) { + LLDB_RECORD_METHOD(lldb::SBTypeList, SBCompileUnit, GetTypes, (uint32_t), + type_mask); + SBTypeList sb_type_list; if (!m_opaque_ptr) - return sb_type_list; + return LLDB_RECORD_RESULT(sb_type_list); ModuleSP module_sp(m_opaque_ptr->GetModule()); if (!module_sp) - return sb_type_list; + return LLDB_RECORD_RESULT(sb_type_list); SymbolVendor *vendor = module_sp->GetSymbolVendor(); if (!vendor) - return sb_type_list; + return LLDB_RECORD_RESULT(sb_type_list); TypeClass type_class = static_cast<TypeClass>(type_mask); TypeList type_list; vendor->GetTypes(m_opaque_ptr, type_class, type_list); - sb_type_list.m_opaque_ap->Append(type_list); - return sb_type_list; + sb_type_list.m_opaque_up->Append(type_list); + return LLDB_RECORD_RESULT(sb_type_list); } SBFileSpec SBCompileUnit::GetSupportFileAtIndex(uint32_t idx) const { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_CONST(lldb::SBFileSpec, SBCompileUnit, + GetSupportFileAtIndex, (uint32_t), idx); SBFileSpec sb_file_spec; if (m_opaque_ptr) { - FileSpecList &support_files = m_opaque_ptr->GetSupportFiles(); - FileSpec file_spec = support_files.GetFileSpecAtIndex(idx); - sb_file_spec.SetFileSpec(file_spec); + FileSpec spec = m_opaque_ptr->GetSupportFiles().GetFileSpecAtIndex(idx); + sb_file_spec.SetFileSpec(spec); } - if (log) { - SBStream sstr; - sb_file_spec.GetDescription(sstr); - log->Printf("SBCompileUnit(%p)::GetGetFileSpecAtIndex (idx=%u) => " - "SBFileSpec(%p): '%s'", - static_cast<void *>(m_opaque_ptr), idx, - static_cast<const void *>(sb_file_spec.get()), sstr.GetData()); - } - return sb_file_spec; + return LLDB_RECORD_RESULT(sb_file_spec); } uint32_t SBCompileUnit::FindSupportFileIndex(uint32_t start_idx, const SBFileSpec &sb_file, bool full) { + LLDB_RECORD_METHOD(uint32_t, SBCompileUnit, FindSupportFileIndex, + (uint32_t, const lldb::SBFileSpec &, bool), start_idx, + sb_file, full); + if (m_opaque_ptr) { - FileSpecList &support_files = m_opaque_ptr->GetSupportFiles(); + const FileSpecList &support_files = m_opaque_ptr->GetSupportFiles(); return support_files.FindFileIndex(start_idx, sb_file.ref(), full); } return 0; } lldb::LanguageType SBCompileUnit::GetLanguage() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::LanguageType, SBCompileUnit, GetLanguage); + if (m_opaque_ptr) return m_opaque_ptr->GetLanguage(); return lldb::eLanguageTypeUnknown; } -bool SBCompileUnit::IsValid() const { return m_opaque_ptr != NULL; } +bool SBCompileUnit::IsValid() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCompileUnit, IsValid); + return this->operator bool(); +} +SBCompileUnit::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCompileUnit, operator bool); + + return m_opaque_ptr != nullptr; +} bool SBCompileUnit::operator==(const SBCompileUnit &rhs) const { + LLDB_RECORD_METHOD_CONST( + bool, SBCompileUnit, operator==,(const lldb::SBCompileUnit &), rhs); + return m_opaque_ptr == rhs.m_opaque_ptr; } bool SBCompileUnit::operator!=(const SBCompileUnit &rhs) const { + LLDB_RECORD_METHOD_CONST( + bool, SBCompileUnit, operator!=,(const lldb::SBCompileUnit &), rhs); + return m_opaque_ptr != rhs.m_opaque_ptr; } @@ -216,6 +223,9 @@ void SBCompileUnit::reset(lldb_private::CompileUnit *lldb_object_ptr) { } bool SBCompileUnit::GetDescription(SBStream &description) { + LLDB_RECORD_METHOD(bool, SBCompileUnit, GetDescription, (lldb::SBStream &), + description); + Stream &strm = description.ref(); if (m_opaque_ptr) { @@ -225,3 +235,42 @@ bool SBCompileUnit::GetDescription(SBStream &description) { return true; } + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBCompileUnit>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBCompileUnit, ()); + LLDB_REGISTER_CONSTRUCTOR(SBCompileUnit, (const lldb::SBCompileUnit &)); + LLDB_REGISTER_METHOD( + const lldb::SBCompileUnit &, + SBCompileUnit, operator=,(const lldb::SBCompileUnit &)); + LLDB_REGISTER_METHOD_CONST(lldb::SBFileSpec, SBCompileUnit, GetFileSpec, + ()); + LLDB_REGISTER_METHOD_CONST(uint32_t, SBCompileUnit, GetNumLineEntries, ()); + LLDB_REGISTER_METHOD_CONST(lldb::SBLineEntry, SBCompileUnit, + GetLineEntryAtIndex, (uint32_t)); + LLDB_REGISTER_METHOD_CONST(uint32_t, SBCompileUnit, FindLineEntryIndex, + (uint32_t, uint32_t, lldb::SBFileSpec *)); + LLDB_REGISTER_METHOD_CONST(uint32_t, SBCompileUnit, FindLineEntryIndex, + (uint32_t, uint32_t, lldb::SBFileSpec *, bool)); + LLDB_REGISTER_METHOD_CONST(uint32_t, SBCompileUnit, GetNumSupportFiles, ()); + LLDB_REGISTER_METHOD(lldb::SBTypeList, SBCompileUnit, GetTypes, (uint32_t)); + LLDB_REGISTER_METHOD_CONST(lldb::SBFileSpec, SBCompileUnit, + GetSupportFileAtIndex, (uint32_t)); + LLDB_REGISTER_METHOD(uint32_t, SBCompileUnit, FindSupportFileIndex, + (uint32_t, const lldb::SBFileSpec &, bool)); + LLDB_REGISTER_METHOD(lldb::LanguageType, SBCompileUnit, GetLanguage, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBCompileUnit, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBCompileUnit, operator bool, ()); + LLDB_REGISTER_METHOD_CONST( + bool, SBCompileUnit, operator==,(const lldb::SBCompileUnit &)); + LLDB_REGISTER_METHOD_CONST( + bool, SBCompileUnit, operator!=,(const lldb::SBCompileUnit &)); + LLDB_REGISTER_METHOD(bool, SBCompileUnit, GetDescription, + (lldb::SBStream &)); +} + +} +} diff --git a/source/API/SBData.cpp b/source/API/SBData.cpp index a30a778a19d2b..528cd8d43ecce 100644 --- a/source/API/SBData.cpp +++ b/source/API/SBData.cpp @@ -1,37 +1,44 @@ //===-- SBData.cpp ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// -#include <inttypes.h> - #include "lldb/API/SBData.h" +#include "SBReproducerPrivate.h" #include "lldb/API/SBError.h" #include "lldb/API/SBStream.h" #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> +#include <memory> + using namespace lldb; using namespace lldb_private; -SBData::SBData() : m_opaque_sp(new DataExtractor()) {} +SBData::SBData() : m_opaque_sp(new DataExtractor()) { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBData); +} SBData::SBData(const lldb::DataExtractorSP &data_sp) : m_opaque_sp(data_sp) {} -SBData::SBData(const SBData &rhs) : m_opaque_sp(rhs.m_opaque_sp) {} +SBData::SBData(const SBData &rhs) : m_opaque_sp(rhs.m_opaque_sp) { + LLDB_RECORD_CONSTRUCTOR(SBData, (const lldb::SBData &), rhs); +} const SBData &SBData::operator=(const SBData &rhs) { + LLDB_RECORD_METHOD(const lldb::SBData &, + SBData, operator=,(const lldb::SBData &), rhs); + if (this != &rhs) m_opaque_sp = rhs.m_opaque_sp; - return *this; + return LLDB_RECORD_RESULT(*this); } SBData::~SBData() {} @@ -50,67 +57,69 @@ lldb::DataExtractorSP &SBData::operator*() { return m_opaque_sp; } const lldb::DataExtractorSP &SBData::operator*() const { return m_opaque_sp; } -bool SBData::IsValid() { return m_opaque_sp.get() != NULL; } +bool SBData::IsValid() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBData, IsValid); + return this->operator bool(); +} +SBData::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBData, operator bool); + + return m_opaque_sp.get() != nullptr; +} uint8_t SBData::GetAddressByteSize() { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_NO_ARGS(uint8_t, SBData, GetAddressByteSize); + uint8_t value = 0; if (m_opaque_sp.get()) value = m_opaque_sp->GetAddressByteSize(); - if (log) - log->Printf("SBData::GetAddressByteSize () => " - "(%i)", - value); return value; } void SBData::SetAddressByteSize(uint8_t addr_byte_size) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(void, SBData, SetAddressByteSize, (uint8_t), + addr_byte_size); + 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() { + LLDB_RECORD_METHOD_NO_ARGS(void, SBData, Clear); + if (m_opaque_sp.get()) m_opaque_sp->Clear(); } size_t SBData::GetByteSize() { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_NO_ARGS(size_t, SBData, GetByteSize); + 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() { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_NO_ARGS(lldb::ByteOrder, SBData, GetByteOrder); + 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) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(void, SBData, SetByteOrder, (lldb::ByteOrder), endian); + 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) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(float, SBData, GetFloat, (lldb::SBError &, lldb::offset_t), + error, offset); + float value = 0; if (!m_opaque_sp.get()) { error.SetErrorString("no value to read from"); @@ -120,14 +129,13 @@ 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; } double SBData::GetDouble(lldb::SBError &error, lldb::offset_t offset) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(double, SBData, GetDouble, + (lldb::SBError &, lldb::offset_t), error, offset); + double value = 0; if (!m_opaque_sp.get()) { error.SetErrorString("no value to read from"); @@ -137,15 +145,13 @@ 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; } long double SBData::GetLongDouble(lldb::SBError &error, lldb::offset_t offset) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(long double, SBData, GetLongDouble, + (lldb::SBError &, lldb::offset_t), error, offset); + long double value = 0; if (!m_opaque_sp.get()) { error.SetErrorString("no value to read from"); @@ -155,15 +161,13 @@ 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; } lldb::addr_t SBData::GetAddress(lldb::SBError &error, lldb::offset_t offset) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(lldb::addr_t, SBData, GetAddress, + (lldb::SBError &, lldb::offset_t), error, offset); + lldb::addr_t value = 0; if (!m_opaque_sp.get()) { error.SetErrorString("no value to read from"); @@ -173,16 +177,13 @@ 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; } uint8_t SBData::GetUnsignedInt8(lldb::SBError &error, lldb::offset_t offset) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(uint8_t, SBData, GetUnsignedInt8, + (lldb::SBError &, lldb::offset_t), error, offset); + uint8_t value = 0; if (!m_opaque_sp.get()) { error.SetErrorString("no value to read from"); @@ -192,15 +193,13 @@ 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; } uint16_t SBData::GetUnsignedInt16(lldb::SBError &error, lldb::offset_t offset) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(uint16_t, SBData, GetUnsignedInt16, + (lldb::SBError &, lldb::offset_t), error, offset); + uint16_t value = 0; if (!m_opaque_sp.get()) { error.SetErrorString("no value to read from"); @@ -210,15 +209,13 @@ 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; } uint32_t SBData::GetUnsignedInt32(lldb::SBError &error, lldb::offset_t offset) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(uint32_t, SBData, GetUnsignedInt32, + (lldb::SBError &, lldb::offset_t), error, offset); + uint32_t value = 0; if (!m_opaque_sp.get()) { error.SetErrorString("no value to read from"); @@ -228,15 +225,13 @@ 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; } uint64_t SBData::GetUnsignedInt64(lldb::SBError &error, lldb::offset_t offset) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(uint64_t, SBData, GetUnsignedInt64, + (lldb::SBError &, lldb::offset_t), error, offset); + uint64_t value = 0; if (!m_opaque_sp.get()) { error.SetErrorString("no value to read from"); @@ -246,15 +241,13 @@ 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; } int8_t SBData::GetSignedInt8(lldb::SBError &error, lldb::offset_t offset) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(int8_t, SBData, GetSignedInt8, + (lldb::SBError &, lldb::offset_t), error, offset); + int8_t value = 0; if (!m_opaque_sp.get()) { error.SetErrorString("no value to read from"); @@ -264,15 +257,13 @@ 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; } int16_t SBData::GetSignedInt16(lldb::SBError &error, lldb::offset_t offset) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(int16_t, SBData, GetSignedInt16, + (lldb::SBError &, lldb::offset_t), error, offset); + int16_t value = 0; if (!m_opaque_sp.get()) { error.SetErrorString("no value to read from"); @@ -282,15 +273,13 @@ 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; } int32_t SBData::GetSignedInt32(lldb::SBError &error, lldb::offset_t offset) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(int32_t, SBData, GetSignedInt32, + (lldb::SBError &, lldb::offset_t), error, offset); + int32_t value = 0; if (!m_opaque_sp.get()) { error.SetErrorString("no value to read from"); @@ -300,15 +289,13 @@ 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; } int64_t SBData::GetSignedInt64(lldb::SBError &error, lldb::offset_t offset) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(int64_t, SBData, GetSignedInt64, + (lldb::SBError &, lldb::offset_t), error, offset); + int64_t value = 0; if (!m_opaque_sp.get()) { error.SetErrorString("no value to read from"); @@ -318,33 +305,30 @@ 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; } const char *SBData::GetString(lldb::SBError &error, lldb::offset_t offset) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - const char *value = 0; + LLDB_RECORD_METHOD(const char *, SBData, GetString, + (lldb::SBError &, lldb::offset_t), error, offset); + + const char *value = nullptr; if (!m_opaque_sp.get()) { error.SetErrorString("no value to read from"); } else { uint32_t old_offset = offset; value = m_opaque_sp->GetCStr(&offset); - if (offset == old_offset || (value == NULL)) + if (offset == old_offset || (value == nullptr)) 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; } bool SBData::GetDescription(lldb::SBStream &description, lldb::addr_t base_addr) { + LLDB_RECORD_METHOD(bool, SBData, GetDescription, + (lldb::SBStream &, lldb::addr_t), description, base_addr); + Stream &strm = description.ref(); if (m_opaque_sp) { @@ -358,62 +342,56 @@ 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; + LLDB_RECORD_DUMMY(size_t, SBData, ReadRawData, + (lldb::SBError &, lldb::offset_t, void *, size_t), error, + offset, buf, size); + + void *ok = nullptr; if (!m_opaque_sp.get()) { error.SetErrorString("no value to read from"); } else { uint32_t old_offset = offset; ok = m_opaque_sp->GetU8(&offset, buf, size); - if ((offset == old_offset) || (ok == NULL)) + if ((offset == old_offset) || (ok == nullptr)) 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)); + LLDB_RECORD_DUMMY( + void, SBData, SetData, + (lldb::SBError &, const void *, size_t, lldb::ByteOrder, uint8_t), error, + buf, size, endian, addr_size); + if (!m_opaque_sp.get()) - m_opaque_sp.reset(new DataExtractor(buf, size, endian, addr_size)); + m_opaque_sp = std::make_shared<DataExtractor>(buf, size, endian, addr_size); else { m_opaque_sp->SetData(buf, size, endian); 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) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(bool, SBData, Append, (const lldb::SBData &), rhs); + 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; } lldb::SBData SBData::CreateDataFromCString(lldb::ByteOrder endian, uint32_t addr_byte_size, const char *data) { + LLDB_RECORD_STATIC_METHOD(lldb::SBData, SBData, CreateDataFromCString, + (lldb::ByteOrder, uint32_t, const char *), endian, + addr_byte_size, data); + if (!data || !data[0]) - return SBData(); + return LLDB_RECORD_RESULT(SBData()); uint32_t data_len = strlen(data); @@ -423,15 +401,19 @@ lldb::SBData SBData::CreateDataFromCString(lldb::ByteOrder endian, SBData ret(data_sp); - return ret; + return LLDB_RECORD_RESULT(ret); } lldb::SBData SBData::CreateDataFromUInt64Array(lldb::ByteOrder endian, uint32_t addr_byte_size, uint64_t *array, size_t array_len) { + LLDB_RECORD_STATIC_METHOD(lldb::SBData, SBData, CreateDataFromUInt64Array, + (lldb::ByteOrder, uint32_t, uint64_t *, size_t), + endian, addr_byte_size, array, array_len); + if (!array || array_len == 0) - return SBData(); + return LLDB_RECORD_RESULT(SBData()); size_t data_len = array_len * sizeof(uint64_t); @@ -441,15 +423,19 @@ lldb::SBData SBData::CreateDataFromUInt64Array(lldb::ByteOrder endian, SBData ret(data_sp); - return ret; + return LLDB_RECORD_RESULT(ret); } lldb::SBData SBData::CreateDataFromUInt32Array(lldb::ByteOrder endian, uint32_t addr_byte_size, uint32_t *array, size_t array_len) { + LLDB_RECORD_STATIC_METHOD(lldb::SBData, SBData, CreateDataFromUInt32Array, + (lldb::ByteOrder, uint32_t, uint32_t *, size_t), + endian, addr_byte_size, array, array_len); + if (!array || array_len == 0) - return SBData(); + return LLDB_RECORD_RESULT(SBData()); size_t data_len = array_len * sizeof(uint32_t); @@ -459,15 +445,19 @@ lldb::SBData SBData::CreateDataFromUInt32Array(lldb::ByteOrder endian, SBData ret(data_sp); - return ret; + return LLDB_RECORD_RESULT(ret); } lldb::SBData SBData::CreateDataFromSInt64Array(lldb::ByteOrder endian, uint32_t addr_byte_size, int64_t *array, size_t array_len) { + LLDB_RECORD_STATIC_METHOD(lldb::SBData, SBData, CreateDataFromSInt64Array, + (lldb::ByteOrder, uint32_t, int64_t *, size_t), + endian, addr_byte_size, array, array_len); + if (!array || array_len == 0) - return SBData(); + return LLDB_RECORD_RESULT(SBData()); size_t data_len = array_len * sizeof(int64_t); @@ -477,15 +467,19 @@ lldb::SBData SBData::CreateDataFromSInt64Array(lldb::ByteOrder endian, SBData ret(data_sp); - return ret; + return LLDB_RECORD_RESULT(ret); } lldb::SBData SBData::CreateDataFromSInt32Array(lldb::ByteOrder endian, uint32_t addr_byte_size, int32_t *array, size_t array_len) { + LLDB_RECORD_STATIC_METHOD(lldb::SBData, SBData, CreateDataFromSInt32Array, + (lldb::ByteOrder, uint32_t, int32_t *, size_t), + endian, addr_byte_size, array, array_len); + if (!array || array_len == 0) - return SBData(); + return LLDB_RECORD_RESULT(SBData()); size_t data_len = array_len * sizeof(int32_t); @@ -495,15 +489,19 @@ lldb::SBData SBData::CreateDataFromSInt32Array(lldb::ByteOrder endian, SBData ret(data_sp); - return ret; + return LLDB_RECORD_RESULT(ret); } lldb::SBData SBData::CreateDataFromDoubleArray(lldb::ByteOrder endian, uint32_t addr_byte_size, double *array, size_t array_len) { + LLDB_RECORD_STATIC_METHOD(lldb::SBData, SBData, CreateDataFromDoubleArray, + (lldb::ByteOrder, uint32_t, double *, size_t), + endian, addr_byte_size, array, array_len); + if (!array || array_len == 0) - return SBData(); + return LLDB_RECORD_RESULT(SBData()); size_t data_len = array_len * sizeof(double); @@ -513,16 +511,14 @@ lldb::SBData SBData::CreateDataFromDoubleArray(lldb::ByteOrder endian, SBData ret(data_sp); - return ret; + return LLDB_RECORD_RESULT(ret); } bool SBData::SetDataFromCString(const char *data) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(bool, SBData, SetDataFromCString, (const char *), data); + if (!data) { - if (log) - log->Printf("SBData::SetDataFromCString (data=%p) => false", - static_cast<const void *>(data)); return false; } @@ -531,28 +527,21 @@ bool SBData::SetDataFromCString(const char *data) { lldb::DataBufferSP buffer_sp(new DataBufferHeap(data, data_len)); if (!m_opaque_sp.get()) - m_opaque_sp.reset( - new DataExtractor(buffer_sp, GetByteOrder(), GetAddressByteSize())); + m_opaque_sp = std::make_shared<DataExtractor>(buffer_sp, GetByteOrder(), + GetAddressByteSize()); else m_opaque_sp->SetData(buffer_sp); - if (log) - log->Printf("SBData::SetDataFromCString (data=%p) => true", - static_cast<const void *>(data)); return true; } bool SBData::SetDataFromUInt64Array(uint64_t *array, size_t array_len) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(bool, SBData, SetDataFromUInt64Array, (uint64_t *, size_t), + array, array_len); + 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; } @@ -561,30 +550,21 @@ bool SBData::SetDataFromUInt64Array(uint64_t *array, size_t array_len) { lldb::DataBufferSP buffer_sp(new DataBufferHeap(array, data_len)); if (!m_opaque_sp.get()) - m_opaque_sp.reset( - new DataExtractor(buffer_sp, GetByteOrder(), GetAddressByteSize())); + m_opaque_sp = std::make_shared<DataExtractor>(buffer_sp, GetByteOrder(), + GetAddressByteSize()); 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; } bool SBData::SetDataFromUInt32Array(uint32_t *array, size_t array_len) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(bool, SBData, SetDataFromUInt32Array, (uint32_t *, size_t), + array, array_len); + 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; } @@ -593,30 +573,20 @@ bool SBData::SetDataFromUInt32Array(uint32_t *array, size_t array_len) { lldb::DataBufferSP buffer_sp(new DataBufferHeap(array, data_len)); if (!m_opaque_sp.get()) - m_opaque_sp.reset( - new DataExtractor(buffer_sp, GetByteOrder(), GetAddressByteSize())); + m_opaque_sp = std::make_shared<DataExtractor>(buffer_sp, GetByteOrder(), + GetAddressByteSize()); 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; } bool SBData::SetDataFromSInt64Array(int64_t *array, size_t array_len) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(bool, SBData, SetDataFromSInt64Array, (int64_t *, size_t), + array, array_len); + 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; } @@ -625,30 +595,20 @@ bool SBData::SetDataFromSInt64Array(int64_t *array, size_t array_len) { lldb::DataBufferSP buffer_sp(new DataBufferHeap(array, data_len)); if (!m_opaque_sp.get()) - m_opaque_sp.reset( - new DataExtractor(buffer_sp, GetByteOrder(), GetAddressByteSize())); + m_opaque_sp = std::make_shared<DataExtractor>(buffer_sp, GetByteOrder(), + GetAddressByteSize()); 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; } bool SBData::SetDataFromSInt32Array(int32_t *array, size_t array_len) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(bool, SBData, SetDataFromSInt32Array, (int32_t *, size_t), + array, array_len); + 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; } @@ -657,30 +617,20 @@ bool SBData::SetDataFromSInt32Array(int32_t *array, size_t array_len) { lldb::DataBufferSP buffer_sp(new DataBufferHeap(array, data_len)); if (!m_opaque_sp.get()) - m_opaque_sp.reset( - new DataExtractor(buffer_sp, GetByteOrder(), GetAddressByteSize())); + m_opaque_sp = std::make_shared<DataExtractor>(buffer_sp, GetByteOrder(), + GetAddressByteSize()); 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; } bool SBData::SetDataFromDoubleArray(double *array, size_t array_len) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(bool, SBData, SetDataFromDoubleArray, (double *, size_t), + array, array_len); + 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; } @@ -689,16 +639,86 @@ bool SBData::SetDataFromDoubleArray(double *array, size_t array_len) { lldb::DataBufferSP buffer_sp(new DataBufferHeap(array, data_len)); if (!m_opaque_sp.get()) - m_opaque_sp.reset( - new DataExtractor(buffer_sp, GetByteOrder(), GetAddressByteSize())); + m_opaque_sp = std::make_shared<DataExtractor>(buffer_sp, GetByteOrder(), + GetAddressByteSize()); 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; } + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBData>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBData, ()); + LLDB_REGISTER_CONSTRUCTOR(SBData, (const lldb::SBData &)); + LLDB_REGISTER_METHOD(const lldb::SBData &, + SBData, operator=,(const lldb::SBData &)); + LLDB_REGISTER_METHOD(bool, SBData, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBData, operator bool, ()); + LLDB_REGISTER_METHOD(uint8_t, SBData, GetAddressByteSize, ()); + LLDB_REGISTER_METHOD(void, SBData, SetAddressByteSize, (uint8_t)); + LLDB_REGISTER_METHOD(void, SBData, Clear, ()); + LLDB_REGISTER_METHOD(size_t, SBData, GetByteSize, ()); + LLDB_REGISTER_METHOD(lldb::ByteOrder, SBData, GetByteOrder, ()); + LLDB_REGISTER_METHOD(void, SBData, SetByteOrder, (lldb::ByteOrder)); + LLDB_REGISTER_METHOD(float, SBData, GetFloat, + (lldb::SBError &, lldb::offset_t)); + LLDB_REGISTER_METHOD(double, SBData, GetDouble, + (lldb::SBError &, lldb::offset_t)); + LLDB_REGISTER_METHOD(long double, SBData, GetLongDouble, + (lldb::SBError &, lldb::offset_t)); + LLDB_REGISTER_METHOD(lldb::addr_t, SBData, GetAddress, + (lldb::SBError &, lldb::offset_t)); + LLDB_REGISTER_METHOD(uint8_t, SBData, GetUnsignedInt8, + (lldb::SBError &, lldb::offset_t)); + LLDB_REGISTER_METHOD(uint16_t, SBData, GetUnsignedInt16, + (lldb::SBError &, lldb::offset_t)); + LLDB_REGISTER_METHOD(uint32_t, SBData, GetUnsignedInt32, + (lldb::SBError &, lldb::offset_t)); + LLDB_REGISTER_METHOD(uint64_t, SBData, GetUnsignedInt64, + (lldb::SBError &, lldb::offset_t)); + LLDB_REGISTER_METHOD(int8_t, SBData, GetSignedInt8, + (lldb::SBError &, lldb::offset_t)); + LLDB_REGISTER_METHOD(int16_t, SBData, GetSignedInt16, + (lldb::SBError &, lldb::offset_t)); + LLDB_REGISTER_METHOD(int32_t, SBData, GetSignedInt32, + (lldb::SBError &, lldb::offset_t)); + LLDB_REGISTER_METHOD(int64_t, SBData, GetSignedInt64, + (lldb::SBError &, lldb::offset_t)); + LLDB_REGISTER_METHOD(const char *, SBData, GetString, + (lldb::SBError &, lldb::offset_t)); + LLDB_REGISTER_METHOD(bool, SBData, GetDescription, + (lldb::SBStream &, lldb::addr_t)); + LLDB_REGISTER_METHOD(bool, SBData, Append, (const lldb::SBData &)); + LLDB_REGISTER_STATIC_METHOD(lldb::SBData, SBData, CreateDataFromCString, + (lldb::ByteOrder, uint32_t, const char *)); + LLDB_REGISTER_STATIC_METHOD( + lldb::SBData, SBData, CreateDataFromUInt64Array, + (lldb::ByteOrder, uint32_t, uint64_t *, size_t)); + LLDB_REGISTER_STATIC_METHOD( + lldb::SBData, SBData, CreateDataFromUInt32Array, + (lldb::ByteOrder, uint32_t, uint32_t *, size_t)); + LLDB_REGISTER_STATIC_METHOD(lldb::SBData, SBData, CreateDataFromSInt64Array, + (lldb::ByteOrder, uint32_t, int64_t *, size_t)); + LLDB_REGISTER_STATIC_METHOD(lldb::SBData, SBData, CreateDataFromSInt32Array, + (lldb::ByteOrder, uint32_t, int32_t *, size_t)); + LLDB_REGISTER_STATIC_METHOD(lldb::SBData, SBData, CreateDataFromDoubleArray, + (lldb::ByteOrder, uint32_t, double *, size_t)); + LLDB_REGISTER_METHOD(bool, SBData, SetDataFromCString, (const char *)); + LLDB_REGISTER_METHOD(bool, SBData, SetDataFromUInt64Array, + (uint64_t *, size_t)); + LLDB_REGISTER_METHOD(bool, SBData, SetDataFromUInt32Array, + (uint32_t *, size_t)); + LLDB_REGISTER_METHOD(bool, SBData, SetDataFromSInt64Array, + (int64_t *, size_t)); + LLDB_REGISTER_METHOD(bool, SBData, SetDataFromSInt32Array, + (int32_t *, size_t)); + LLDB_REGISTER_METHOD(bool, SBData, SetDataFromDoubleArray, + (double *, size_t)); +} + +} +} diff --git a/source/API/SBDebugger.cpp b/source/API/SBDebugger.cpp index af343233c90ec..634c4a9295953 100644 --- a/source/API/SBDebugger.cpp +++ b/source/API/SBDebugger.cpp @@ -1,13 +1,12 @@ //===-- SBDebugger.cpp ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// - +#include "SBReproducerPrivate.h" #include "SystemInitializerFull.h" #include "lldb/API/SBDebugger.h" @@ -58,6 +57,51 @@ using namespace lldb; using namespace lldb_private; +/// Helper class for replaying commands through the reproducer. +class CommandLoader { +public: + CommandLoader(std::vector<std::string> files) : m_files(files) {} + + static std::unique_ptr<CommandLoader> Create() { + repro::Loader *loader = repro::Reproducer::Instance().GetLoader(); + if (!loader) + return {}; + + FileSpec file = loader->GetFile<repro::CommandProvider::Info>(); + if (!file) + return {}; + + auto error_or_file = llvm::MemoryBuffer::getFile(file.GetPath()); + if (auto err = error_or_file.getError()) + return {}; + + std::vector<std::string> files; + llvm::yaml::Input yin((*error_or_file)->getBuffer()); + yin >> files; + + if (auto err = yin.error()) + return {}; + + for (auto &file : files) { + FileSpec absolute_path = + loader->GetRoot().CopyByAppendingPathComponent(file); + file = absolute_path.GetPath(); + } + + return llvm::make_unique<CommandLoader>(std::move(files)); + } + + FILE *GetNextFile() { + if (m_index >= m_files.size()) + return nullptr; + return FileSystem::Instance().Fopen(m_files[m_index++].c_str(), "r"); + } + +private: + std::vector<std::string> m_files; + unsigned m_index = 0; +}; + static llvm::sys::DynamicLibrary LoadPlugin(const lldb::DebuggerSP &debugger_sp, const FileSpec &spec, Status &error) { @@ -98,60 +142,83 @@ static llvm::ManagedStatic<SystemLifetimeManager> g_debugger_lifetime; SBError SBInputReader::Initialize( lldb::SBDebugger &sb_debugger, - unsigned long (*)(void *, lldb::SBInputReader *, lldb::InputReaderAction, - char const *, unsigned long), - void *, lldb::InputReaderGranularity, char const *, char const *, bool) { + unsigned long (*callback)(void *, lldb::SBInputReader *, + lldb::InputReaderAction, char const *, + unsigned long), + void *a, lldb::InputReaderGranularity b, char const *c, char const *d, + bool 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(); } -void SBInputReader::SetIsDone(bool) {} +void SBInputReader::SetIsDone(bool b) { + LLDB_RECORD_METHOD(void, SBInputReader, SetIsDone, (bool), b); +} -bool SBInputReader::IsActive() const { return false; } +bool SBInputReader::IsActive() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBInputReader, IsActive); -SBDebugger::SBDebugger() = default; + return false; +} + +SBDebugger::SBDebugger() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBDebugger); } SBDebugger::SBDebugger(const lldb::DebuggerSP &debugger_sp) - : m_opaque_sp(debugger_sp) {} + : m_opaque_sp(debugger_sp) { + LLDB_RECORD_CONSTRUCTOR(SBDebugger, (const lldb::DebuggerSP &), debugger_sp); +} -SBDebugger::SBDebugger(const SBDebugger &rhs) : m_opaque_sp(rhs.m_opaque_sp) {} +SBDebugger::SBDebugger(const SBDebugger &rhs) : m_opaque_sp(rhs.m_opaque_sp) { + LLDB_RECORD_CONSTRUCTOR(SBDebugger, (const lldb::SBDebugger &), rhs); +} SBDebugger::~SBDebugger() = default; SBDebugger &SBDebugger::operator=(const SBDebugger &rhs) { + LLDB_RECORD_METHOD(lldb::SBDebugger &, + SBDebugger, operator=,(const lldb::SBDebugger &), rhs); + if (this != &rhs) { m_opaque_sp = rhs.m_opaque_sp; } - return *this; + return LLDB_RECORD_RESULT(*this); } void SBDebugger::Initialize() { - SBInitializerOptions options; - SBDebugger::Initialize(options); + LLDB_RECORD_STATIC_METHOD_NO_ARGS(void, SBDebugger, Initialize); + SBError ignored = SBDebugger::InitializeWithErrorHandling(); } -lldb::SBError SBDebugger::Initialize(SBInitializerOptions &options) { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); +lldb::SBError SBDebugger::InitializeWithErrorHandling() { + LLDB_RECORD_STATIC_METHOD_NO_ARGS(lldb::SBError, SBDebugger, + InitializeWithErrorHandling); + - if (log) - log->Printf("SBDebugger::Initialize ()"); SBError error; if (auto e = g_debugger_lifetime->Initialize( - llvm::make_unique<SystemInitializerFull>(), *options.m_opaque_up, - LoadPlugin)) { + llvm::make_unique<SystemInitializerFull>(), LoadPlugin)) { error.SetError(Status(std::move(e))); } - return error; + return LLDB_RECORD_RESULT(error); } -void SBDebugger::Terminate() { g_debugger_lifetime->Terminate(); } +void SBDebugger::Terminate() { + LLDB_RECORD_STATIC_METHOD_NO_ARGS(void, SBDebugger, Terminate); + + g_debugger_lifetime->Terminate(); +} void SBDebugger::Clear() { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_NO_ARGS(void, SBDebugger, Clear); - if (log) - log->Printf("SBDebugger(%p)::Clear ()", - static_cast<void *>(m_opaque_sp.get())); if (m_opaque_sp) m_opaque_sp->ClearIOHandlers(); @@ -160,18 +227,26 @@ void SBDebugger::Clear() { } SBDebugger SBDebugger::Create() { - return SBDebugger::Create(false, nullptr, nullptr); + LLDB_RECORD_STATIC_METHOD_NO_ARGS(lldb::SBDebugger, SBDebugger, Create); + + return LLDB_RECORD_RESULT(SBDebugger::Create(false, nullptr, nullptr)); } SBDebugger SBDebugger::Create(bool source_init_files) { - return SBDebugger::Create(source_init_files, nullptr, nullptr); + LLDB_RECORD_STATIC_METHOD(lldb::SBDebugger, SBDebugger, Create, (bool), + source_init_files); + + return LLDB_RECORD_RESULT( + SBDebugger::Create(source_init_files, nullptr, nullptr)); } SBDebugger SBDebugger::Create(bool source_init_files, lldb::LogOutputCallback callback, void *baton) { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_DUMMY(lldb::SBDebugger, SBDebugger, Create, + (bool, lldb::LogOutputCallback, void *), source_init_files, + callback, baton); SBDebugger debugger; @@ -185,13 +260,6 @@ SBDebugger SBDebugger::Create(bool source_init_files, debugger.reset(Debugger::CreateInstance(callback, baton)); - if (log) { - SBStream sstr; - debugger.GetDescription(sstr); - log->Printf("SBDebugger::Create () => SBDebugger(%p): %s", - static_cast<void *>(debugger.m_opaque_sp.get()), - sstr.GetData()); - } SBCommandInterpreter interp = debugger.GetCommandInterpreter(); if (source_init_files) { @@ -207,15 +275,9 @@ SBDebugger SBDebugger::Create(bool source_init_files, } void SBDebugger::Destroy(SBDebugger &debugger) { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_STATIC_METHOD(void, SBDebugger, Destroy, (lldb::SBDebugger &), + debugger); - if (log) { - SBStream sstr; - debugger.GetDescription(sstr); - log->Printf("SBDebugger::Destroy () => SBDebugger(%p): %s", - static_cast<void *>(debugger.m_opaque_sp.get()), - sstr.GetData()); - } Debugger::Destroy(debugger.m_opaque_sp); @@ -224,38 +286,51 @@ void SBDebugger::Destroy(SBDebugger &debugger) { } void SBDebugger::MemoryPressureDetected() { + LLDB_RECORD_STATIC_METHOD_NO_ARGS(void, SBDebugger, MemoryPressureDetected); + // Since this function can be call asynchronously, we allow it to be non- // mandatory. We have seen deadlocks with this function when called so we // need to safeguard against this until we can determine what is causing the // deadlocks. - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); const bool mandatory = false; - if (log) { - log->Printf("SBDebugger::MemoryPressureDetected (), mandatory = %d", - mandatory); - } ModuleList::RemoveOrphanSharedModules(mandatory); } -bool SBDebugger::IsValid() const { return m_opaque_sp.get() != nullptr; } +bool SBDebugger::IsValid() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBDebugger, IsValid); + return this->operator bool(); +} +SBDebugger::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBDebugger, operator bool); + + return m_opaque_sp.get() != nullptr; +} void SBDebugger::SetAsync(bool b) { + LLDB_RECORD_METHOD(void, SBDebugger, SetAsync, (bool), b); + if (m_opaque_sp) m_opaque_sp->SetAsyncExecution(b); } bool SBDebugger::GetAsync() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBDebugger, GetAsync); + return (m_opaque_sp ? m_opaque_sp->GetAsyncExecution() : false); } void SBDebugger::SkipLLDBInitFiles(bool b) { + LLDB_RECORD_METHOD(void, SBDebugger, SkipLLDBInitFiles, (bool), b); + if (m_opaque_sp) m_opaque_sp->GetCommandInterpreter().SkipLLDBInitFiles(b); } void SBDebugger::SkipAppInitFiles(bool b) { + LLDB_RECORD_METHOD(void, SBDebugger, SkipAppInitFiles, (bool), b); + if (m_opaque_sp) m_opaque_sp->GetCommandInterpreter().SkipAppInitFiles(b); } @@ -264,97 +339,102 @@ void SBDebugger::SkipAppInitFiles(bool b) { // of problems; don't want users trying to switch modes in the middle of a // debugging session. void SBDebugger::SetInputFileHandle(FILE *fh, bool transfer_ownership) { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(void, SBDebugger, SetInputFileHandle, (FILE *, bool), fh, + transfer_ownership); - if (log) - log->Printf( - "SBDebugger(%p)::SetInputFileHandle (fh=%p, transfer_ownership=%i)", - static_cast<void *>(m_opaque_sp.get()), static_cast<void *>(fh), - transfer_ownership); + if (!m_opaque_sp) + return; - if (m_opaque_sp) - m_opaque_sp->SetInputFileHandle(fh, transfer_ownership); + repro::DataRecorder *recorder = nullptr; + if (repro::Generator *g = repro::Reproducer::Instance().GetGenerator()) + recorder = g->GetOrCreate<repro::CommandProvider>().GetNewDataRecorder(); + + static std::unique_ptr<CommandLoader> loader = CommandLoader::Create(); + if (loader) + fh = loader->GetNextFile(); + + m_opaque_sp->SetInputFileHandle(fh, transfer_ownership, recorder); } void SBDebugger::SetOutputFileHandle(FILE *fh, bool transfer_ownership) { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - - if (log) - log->Printf( - "SBDebugger(%p)::SetOutputFileHandle (fh=%p, transfer_ownership=%i)", - static_cast<void *>(m_opaque_sp.get()), static_cast<void *>(fh), - transfer_ownership); + LLDB_RECORD_METHOD(void, SBDebugger, SetOutputFileHandle, (FILE *, bool), fh, + transfer_ownership); if (m_opaque_sp) m_opaque_sp->SetOutputFileHandle(fh, transfer_ownership); } void SBDebugger::SetErrorFileHandle(FILE *fh, bool transfer_ownership) { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(void, SBDebugger, SetErrorFileHandle, (FILE *, bool), fh, + transfer_ownership); - if (log) - log->Printf( - "SBDebugger(%p)::SetErrorFileHandle (fh=%p, transfer_ownership=%i)", - static_cast<void *>(m_opaque_sp.get()), static_cast<void *>(fh), - transfer_ownership); if (m_opaque_sp) m_opaque_sp->SetErrorFileHandle(fh, transfer_ownership); } FILE *SBDebugger::GetInputFileHandle() { + LLDB_RECORD_METHOD_NO_ARGS(FILE *, SBDebugger, GetInputFileHandle); + if (m_opaque_sp) { StreamFileSP stream_file_sp(m_opaque_sp->GetInputFile()); if (stream_file_sp) - return stream_file_sp->GetFile().GetStream(); + return LLDB_RECORD_RESULT(stream_file_sp->GetFile().GetStream()); } return nullptr; } FILE *SBDebugger::GetOutputFileHandle() { + LLDB_RECORD_METHOD_NO_ARGS(FILE *, SBDebugger, GetOutputFileHandle); + if (m_opaque_sp) { StreamFileSP stream_file_sp(m_opaque_sp->GetOutputFile()); if (stream_file_sp) - return stream_file_sp->GetFile().GetStream(); + return LLDB_RECORD_RESULT(stream_file_sp->GetFile().GetStream()); } return nullptr; } FILE *SBDebugger::GetErrorFileHandle() { + LLDB_RECORD_METHOD_NO_ARGS(FILE *, SBDebugger, GetErrorFileHandle); + if (m_opaque_sp) { StreamFileSP stream_file_sp(m_opaque_sp->GetErrorFile()); if (stream_file_sp) - return stream_file_sp->GetFile().GetStream(); + return LLDB_RECORD_RESULT(stream_file_sp->GetFile().GetStream()); } return nullptr; } void SBDebugger::SaveInputTerminalState() { + LLDB_RECORD_METHOD_NO_ARGS(void, SBDebugger, SaveInputTerminalState); + if (m_opaque_sp) m_opaque_sp->SaveInputTerminalState(); } void SBDebugger::RestoreInputTerminalState() { + LLDB_RECORD_METHOD_NO_ARGS(void, SBDebugger, RestoreInputTerminalState); + if (m_opaque_sp) m_opaque_sp->RestoreInputTerminalState(); } SBCommandInterpreter SBDebugger::GetCommandInterpreter() { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBCommandInterpreter, SBDebugger, + GetCommandInterpreter); + SBCommandInterpreter sb_interpreter; if (m_opaque_sp) sb_interpreter.reset(&m_opaque_sp->GetCommandInterpreter()); - if (log) - log->Printf( - "SBDebugger(%p)::GetCommandInterpreter () => SBCommandInterpreter(%p)", - static_cast<void *>(m_opaque_sp.get()), - static_cast<void *>(sb_interpreter.get())); - return sb_interpreter; + return LLDB_RECORD_RESULT(sb_interpreter); } void SBDebugger::HandleCommand(const char *command) { + LLDB_RECORD_METHOD(void, SBDebugger, HandleCommand, (const char *), command); + if (m_opaque_sp) { TargetSP target_sp(m_opaque_sp->GetSelectedTarget()); std::unique_lock<std::recursive_mutex> lock; @@ -389,23 +469,25 @@ void SBDebugger::HandleCommand(const char *command) { } SBListener SBDebugger::GetListener() { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBListener, SBDebugger, GetListener); + SBListener sb_listener; if (m_opaque_sp) sb_listener.reset(m_opaque_sp->GetListener()); - if (log) - log->Printf("SBDebugger(%p)::GetListener () => SBListener(%p)", - static_cast<void *>(m_opaque_sp.get()), - static_cast<void *>(sb_listener.get())); - return sb_listener; + return LLDB_RECORD_RESULT(sb_listener); } void SBDebugger::HandleProcessEvent(const SBProcess &process, const SBEvent &event, FILE *out, FILE *err) { + LLDB_RECORD_METHOD( + void, SBDebugger, HandleProcessEvent, + (const lldb::SBProcess &, const lldb::SBEvent &, FILE *, FILE *), process, + event, out, err); + if (!process.IsValid()) return; @@ -448,11 +530,17 @@ void SBDebugger::HandleProcessEvent(const SBProcess &process, } SBSourceManager SBDebugger::GetSourceManager() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBSourceManager, SBDebugger, + GetSourceManager); + SBSourceManager sb_source_manager(*this); - return sb_source_manager; + return LLDB_RECORD_RESULT(sb_source_manager); } bool SBDebugger::GetDefaultArchitecture(char *arch_name, size_t arch_name_len) { + LLDB_RECORD_STATIC_METHOD(bool, SBDebugger, GetDefaultArchitecture, + (char *, size_t), "", arch_name_len); + if (arch_name && arch_name_len) { ArchSpec default_arch = Target::GetDefaultArchitecture(); @@ -472,6 +560,9 @@ bool SBDebugger::GetDefaultArchitecture(char *arch_name, size_t arch_name_len) { } bool SBDebugger::SetDefaultArchitecture(const char *arch_name) { + LLDB_RECORD_STATIC_METHOD(bool, SBDebugger, SetDefaultArchitecture, + (const char *), arch_name); + if (arch_name) { ArchSpec arch(arch_name); if (arch.IsValid()) { @@ -484,16 +575,24 @@ bool SBDebugger::SetDefaultArchitecture(const char *arch_name) { ScriptLanguage SBDebugger::GetScriptingLanguage(const char *script_language_name) { + LLDB_RECORD_METHOD(lldb::ScriptLanguage, SBDebugger, GetScriptingLanguage, + (const char *), script_language_name); + if (!script_language_name) return eScriptLanguageDefault; return OptionArgParser::ToScriptLanguage( llvm::StringRef(script_language_name), eScriptLanguageDefault, nullptr); } const char *SBDebugger::GetVersionString() { + LLDB_RECORD_STATIC_METHOD_NO_ARGS(const char *, SBDebugger, GetVersionString); + return lldb_private::GetVersion(); } const char *SBDebugger::StateAsCString(StateType state) { + LLDB_RECORD_STATIC_METHOD(const char *, SBDebugger, StateAsCString, + (lldb::StateType), state); + return lldb_private::StateAsCString(state); } @@ -518,6 +617,9 @@ static void AddLLVMTargets(StructuredData::Dictionary &dict) { } SBStructuredData SBDebugger::GetBuildConfiguration() { + LLDB_RECORD_STATIC_METHOD_NO_ARGS(lldb::SBStructuredData, SBDebugger, + GetBuildConfiguration); + auto config_up = llvm::make_unique<StructuredData::Dictionary>(); AddBoolConfigEntry( *config_up, "xml", XMLDocument::XMLEnabled(), @@ -526,27 +628,25 @@ SBStructuredData SBDebugger::GetBuildConfiguration() { SBStructuredData data; data.m_impl_up->SetObjectSP(std::move(config_up)); - return data; + return LLDB_RECORD_RESULT(data); } bool SBDebugger::StateIsRunningState(StateType state) { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_STATIC_METHOD(bool, SBDebugger, StateIsRunningState, + (lldb::StateType), state); + const bool result = lldb_private::StateIsRunningState(state); - if (log) - log->Printf("SBDebugger::StateIsRunningState (state=%s) => %i", - StateAsCString(state), result); return result; } bool SBDebugger::StateIsStoppedState(StateType state) { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_STATIC_METHOD(bool, SBDebugger, StateIsStoppedState, + (lldb::StateType), state); + const bool result = lldb_private::StateIsStoppedState(state, false); - if (log) - log->Printf("SBDebugger::StateIsStoppedState (state=%s) => %i", - StateAsCString(state), result); return result; } @@ -556,6 +656,11 @@ lldb::SBTarget SBDebugger::CreateTarget(const char *filename, const char *platform_name, bool add_dependent_modules, lldb::SBError &sb_error) { + LLDB_RECORD_METHOD( + lldb::SBTarget, SBDebugger, CreateTarget, + (const char *, const char *, const char *, bool, lldb::SBError &), + filename, target_triple, platform_name, add_dependent_modules, sb_error); + SBTarget sb_target; TargetSP target_sp; if (m_opaque_sp) { @@ -583,12 +688,16 @@ lldb::SBTarget SBDebugger::CreateTarget(const char *filename, platform_name, add_dependent_modules, sb_error.GetCString(), static_cast<void *>(target_sp.get())); - return sb_target; + return LLDB_RECORD_RESULT(sb_target); } SBTarget SBDebugger::CreateTargetWithFileAndTargetTriple(const char *filename, const char *target_triple) { + LLDB_RECORD_METHOD(lldb::SBTarget, SBDebugger, + CreateTargetWithFileAndTargetTriple, + (const char *, const char *), filename, target_triple); + SBTarget sb_target; TargetSP target_sp; if (m_opaque_sp) { @@ -607,11 +716,14 @@ SBDebugger::CreateTargetWithFileAndTargetTriple(const char *filename, static_cast<void *>(m_opaque_sp.get()), filename, target_triple, static_cast<void *>(target_sp.get())); - return sb_target; + return LLDB_RECORD_RESULT(sb_target); } SBTarget SBDebugger::CreateTargetWithFileAndArch(const char *filename, const char *arch_cstr) { + LLDB_RECORD_METHOD(lldb::SBTarget, SBDebugger, CreateTargetWithFileAndArch, + (const char *, const char *), filename, arch_cstr); + Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); SBTarget sb_target; @@ -637,10 +749,13 @@ SBTarget SBDebugger::CreateTargetWithFileAndArch(const char *filename, static_cast<void *>(m_opaque_sp.get()), filename, arch_cstr, static_cast<void *>(target_sp.get())); - return sb_target; + return LLDB_RECORD_RESULT(sb_target); } SBTarget SBDebugger::CreateTarget(const char *filename) { + LLDB_RECORD_METHOD(lldb::SBTarget, SBDebugger, CreateTarget, (const char *), + filename); + SBTarget sb_target; TargetSP target_sp; if (m_opaque_sp) { @@ -662,10 +777,12 @@ SBTarget SBDebugger::CreateTarget(const char *filename) { "SBDebugger(%p)::CreateTarget (filename=\"%s\") => SBTarget(%p)", static_cast<void *>(m_opaque_sp.get()), filename, static_cast<void *>(target_sp.get())); - return sb_target; + return LLDB_RECORD_RESULT(sb_target); } SBTarget SBDebugger::GetDummyTarget() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTarget, SBDebugger, GetDummyTarget); + SBTarget sb_target; if (m_opaque_sp) { sb_target.SetSP(m_opaque_sp->GetDummyTarget()->shared_from_this()); @@ -676,10 +793,13 @@ SBTarget SBDebugger::GetDummyTarget() { "SBDebugger(%p)::GetDummyTarget() => SBTarget(%p)", static_cast<void *>(m_opaque_sp.get()), static_cast<void *>(sb_target.GetSP().get())); - return sb_target; + return LLDB_RECORD_RESULT(sb_target); } bool SBDebugger::DeleteTarget(lldb::SBTarget &target) { + LLDB_RECORD_METHOD(bool, SBDebugger, DeleteTarget, (lldb::SBTarget &), + target); + bool result = false; if (m_opaque_sp) { TargetSP target_sp(target.GetSP()); @@ -703,15 +823,20 @@ bool SBDebugger::DeleteTarget(lldb::SBTarget &target) { } SBTarget SBDebugger::GetTargetAtIndex(uint32_t idx) { + LLDB_RECORD_METHOD(lldb::SBTarget, SBDebugger, GetTargetAtIndex, (uint32_t), + idx); + SBTarget sb_target; if (m_opaque_sp) { // No need to lock, the target list is thread safe sb_target.SetSP(m_opaque_sp->GetTargetList().GetTargetAtIndex(idx)); } - return sb_target; + return LLDB_RECORD_RESULT(sb_target); } uint32_t SBDebugger::GetIndexOfTarget(lldb::SBTarget target) { + LLDB_RECORD_METHOD(uint32_t, SBDebugger, GetIndexOfTarget, (lldb::SBTarget), + target); lldb::TargetSP target_sp = target.GetSP(); if (!target_sp) @@ -724,16 +849,22 @@ uint32_t SBDebugger::GetIndexOfTarget(lldb::SBTarget target) { } SBTarget SBDebugger::FindTargetWithProcessID(lldb::pid_t pid) { + LLDB_RECORD_METHOD(lldb::SBTarget, SBDebugger, FindTargetWithProcessID, + (lldb::pid_t), pid); + SBTarget sb_target; if (m_opaque_sp) { // No need to lock, the target list is thread safe sb_target.SetSP(m_opaque_sp->GetTargetList().FindTargetWithProcessID(pid)); } - return sb_target; + return LLDB_RECORD_RESULT(sb_target); } SBTarget SBDebugger::FindTargetWithFileAndArch(const char *filename, const char *arch_name) { + LLDB_RECORD_METHOD(lldb::SBTarget, SBDebugger, FindTargetWithFileAndArch, + (const char *, const char *), filename, arch_name); + SBTarget sb_target; if (m_opaque_sp && filename && filename[0]) { // No need to lock, the target list is thread safe @@ -744,7 +875,7 @@ SBTarget SBDebugger::FindTargetWithFileAndArch(const char *filename, FileSpec(filename), arch_name ? &arch : nullptr)); sb_target.SetSP(target_sp); } - return sb_target; + return LLDB_RECORD_RESULT(sb_target); } SBTarget SBDebugger::FindTargetWithLLDBProcess(const ProcessSP &process_sp) { @@ -758,6 +889,8 @@ SBTarget SBDebugger::FindTargetWithLLDBProcess(const ProcessSP &process_sp) { } uint32_t SBDebugger::GetNumTargets() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBDebugger, GetNumTargets); + if (m_opaque_sp) { // No need to lock, the target list is thread safe return m_opaque_sp->GetTargetList().GetNumTargets(); @@ -766,6 +899,8 @@ uint32_t SBDebugger::GetNumTargets() { } SBTarget SBDebugger::GetSelectedTarget() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTarget, SBDebugger, GetSelectedTarget); + Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); SBTarget sb_target; @@ -784,10 +919,13 @@ SBTarget SBDebugger::GetSelectedTarget() { static_cast<void *>(target_sp.get()), sstr.GetData()); } - return sb_target; + return LLDB_RECORD_RESULT(sb_target); } void SBDebugger::SetSelectedTarget(SBTarget &sb_target) { + LLDB_RECORD_METHOD(void, SBDebugger, SetSelectedTarget, (lldb::SBTarget &), + sb_target); + Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); TargetSP target_sp(sb_target.GetSP()); @@ -804,6 +942,8 @@ void SBDebugger::SetSelectedTarget(SBTarget &sb_target) { } SBPlatform SBDebugger::GetSelectedPlatform() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBPlatform, SBDebugger, GetSelectedPlatform); + Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); SBPlatform sb_platform; @@ -816,10 +956,13 @@ SBPlatform SBDebugger::GetSelectedPlatform() { static_cast<void *>(m_opaque_sp.get()), static_cast<void *>(sb_platform.GetSP().get()), sb_platform.GetName()); - return sb_platform; + return LLDB_RECORD_RESULT(sb_platform); } void SBDebugger::SetSelectedPlatform(SBPlatform &sb_platform) { + LLDB_RECORD_METHOD(void, SBDebugger, SetSelectedPlatform, + (lldb::SBPlatform &), sb_platform); + Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); DebuggerSP debugger_sp(m_opaque_sp); @@ -835,6 +978,8 @@ void SBDebugger::SetSelectedPlatform(SBPlatform &sb_platform) { } uint32_t SBDebugger::GetNumPlatforms() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBDebugger, GetNumPlatforms); + if (m_opaque_sp) { // No need to lock, the platform list is thread safe return m_opaque_sp->GetPlatformList().GetSize(); @@ -843,15 +988,20 @@ uint32_t SBDebugger::GetNumPlatforms() { } SBPlatform SBDebugger::GetPlatformAtIndex(uint32_t idx) { + LLDB_RECORD_METHOD(lldb::SBPlatform, SBDebugger, GetPlatformAtIndex, + (uint32_t), idx); + SBPlatform sb_platform; if (m_opaque_sp) { // No need to lock, the platform list is thread safe sb_platform.SetSP(m_opaque_sp->GetPlatformList().GetAtIndex(idx)); } - return sb_platform; + return LLDB_RECORD_RESULT(sb_platform); } uint32_t SBDebugger::GetNumAvailablePlatforms() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBDebugger, GetNumAvailablePlatforms); + uint32_t idx = 0; while (true) { if (!PluginManager::GetPlatformPluginNameAtIndex(idx)) { @@ -864,6 +1014,9 @@ uint32_t SBDebugger::GetNumAvailablePlatforms() { } SBStructuredData SBDebugger::GetAvailablePlatformInfoAtIndex(uint32_t idx) { + LLDB_RECORD_METHOD(lldb::SBStructuredData, SBDebugger, + GetAvailablePlatformInfoAtIndex, (uint32_t), idx); + SBStructuredData data; auto platform_dict = llvm::make_unique<StructuredData::Dictionary>(); llvm::StringRef name_str("name"), desc_str("description"); @@ -878,28 +1031,34 @@ SBStructuredData SBDebugger::GetAvailablePlatformInfoAtIndex(uint32_t idx) { const char *plugin_name = PluginManager::GetPlatformPluginNameAtIndex(idx - 1); if (!plugin_name) { - return data; + return LLDB_RECORD_RESULT(data); } platform_dict->AddStringItem(name_str, llvm::StringRef(plugin_name)); const char *plugin_desc = PluginManager::GetPlatformPluginDescriptionAtIndex(idx - 1); if (!plugin_desc) { - return data; + return LLDB_RECORD_RESULT(data); } platform_dict->AddStringItem(desc_str, llvm::StringRef(plugin_desc)); } data.m_impl_up->SetObjectSP( StructuredData::ObjectSP(platform_dict.release())); - return data; + return LLDB_RECORD_RESULT(data); } void SBDebugger::DispatchInput(void *baton, const void *data, size_t data_len) { + LLDB_RECORD_DUMMY(void, SBDebugger, DispatchInput, + (void *, const void *, size_t), baton, data, data_len); + DispatchInput(data, data_len); } void SBDebugger::DispatchInput(const void *data, size_t data_len) { + LLDB_RECORD_DUMMY(void, SBDebugger, DispatchInput, (const void *, size_t), + data, data_len); + // Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); // // if (log) @@ -915,19 +1074,29 @@ void SBDebugger::DispatchInput(const void *data, size_t data_len) { } void SBDebugger::DispatchInputInterrupt() { + LLDB_RECORD_METHOD_NO_ARGS(void, SBDebugger, DispatchInputInterrupt); + if (m_opaque_sp) m_opaque_sp->DispatchInputInterrupt(); } void SBDebugger::DispatchInputEndOfFile() { + LLDB_RECORD_METHOD_NO_ARGS(void, SBDebugger, DispatchInputEndOfFile); + if (m_opaque_sp) m_opaque_sp->DispatchInputEndOfFile(); } -void SBDebugger::PushInputReader(SBInputReader &reader) {} +void SBDebugger::PushInputReader(SBInputReader &reader) { + LLDB_RECORD_METHOD(void, SBDebugger, PushInputReader, (lldb::SBInputReader &), + reader); +} void SBDebugger::RunCommandInterpreter(bool auto_handle_events, bool spawn_thread) { + LLDB_RECORD_METHOD(void, SBDebugger, RunCommandInterpreter, (bool, bool), + auto_handle_events, spawn_thread); + if (m_opaque_sp) { CommandInterpreterRunOptions options; @@ -943,6 +1112,12 @@ void SBDebugger::RunCommandInterpreter(bool auto_handle_events, bool &stopped_for_crash) { + LLDB_RECORD_METHOD(void, SBDebugger, RunCommandInterpreter, + (bool, bool, lldb::SBCommandInterpreterRunOptions &, int &, + bool &, bool &), + auto_handle_events, spawn_thread, options, num_errors, + quit_requested, stopped_for_crash); + if (m_opaque_sp) { CommandInterpreter &interp = m_opaque_sp->GetCommandInterpreter(); interp.RunCommandInterpreter(auto_handle_events, spawn_thread, @@ -955,12 +1130,16 @@ void SBDebugger::RunCommandInterpreter(bool auto_handle_events, SBError SBDebugger::RunREPL(lldb::LanguageType language, const char *repl_options) { + LLDB_RECORD_METHOD(lldb::SBError, SBDebugger, RunREPL, + (lldb::LanguageType, const char *), language, + repl_options); + SBError error; if (m_opaque_sp) error.ref() = m_opaque_sp->RunREPL(language, repl_options); else error.SetErrorString("invalid debugger"); - return error; + return LLDB_RECORD_RESULT(error); } void SBDebugger::reset(const DebuggerSP &debugger_sp) { @@ -977,20 +1156,29 @@ Debugger &SBDebugger::ref() const { const lldb::DebuggerSP &SBDebugger::get_sp() const { return m_opaque_sp; } SBDebugger SBDebugger::FindDebuggerWithID(int id) { + LLDB_RECORD_STATIC_METHOD(lldb::SBDebugger, SBDebugger, FindDebuggerWithID, + (int), id); + // No need to lock, the debugger list is thread safe SBDebugger sb_debugger; DebuggerSP debugger_sp = Debugger::FindDebuggerWithID(id); if (debugger_sp) sb_debugger.reset(debugger_sp); - return sb_debugger; + return LLDB_RECORD_RESULT(sb_debugger); } const char *SBDebugger::GetInstanceName() { + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBDebugger, GetInstanceName); + return (m_opaque_sp ? m_opaque_sp->GetInstanceName().AsCString() : nullptr); } SBError SBDebugger::SetInternalVariable(const char *var_name, const char *value, const char *debugger_instance_name) { + LLDB_RECORD_STATIC_METHOD(lldb::SBError, SBDebugger, SetInternalVariable, + (const char *, const char *, const char *), + var_name, value, debugger_instance_name); + SBError sb_error; DebuggerSP debugger_sp(Debugger::FindDebuggerWithInstanceName( ConstString(debugger_instance_name))); @@ -1006,12 +1194,16 @@ SBError SBDebugger::SetInternalVariable(const char *var_name, const char *value, } if (error.Fail()) sb_error.SetError(error); - return sb_error; + return LLDB_RECORD_RESULT(sb_error); } SBStringList SBDebugger::GetInternalVariableValue(const char *var_name, const char *debugger_instance_name) { + LLDB_RECORD_STATIC_METHOD( + lldb::SBStringList, SBDebugger, GetInternalVariableValue, + (const char *, const char *), var_name, debugger_instance_name); + SBStringList ret_value; DebuggerSP debugger_sp(Debugger::FindDebuggerWithInstanceName( ConstString(debugger_instance_name))); @@ -1028,23 +1220,30 @@ SBDebugger::GetInternalVariableValue(const char *var_name, if (!value_str.empty()) { StringList string_list; string_list.SplitIntoLines(value_str); - return SBStringList(&string_list); + return LLDB_RECORD_RESULT(SBStringList(&string_list)); } } } - return SBStringList(); + return LLDB_RECORD_RESULT(SBStringList()); } uint32_t SBDebugger::GetTerminalWidth() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBDebugger, GetTerminalWidth); + return (m_opaque_sp ? m_opaque_sp->GetTerminalWidth() : 0); } void SBDebugger::SetTerminalWidth(uint32_t term_width) { + LLDB_RECORD_METHOD(void, SBDebugger, SetTerminalWidth, (uint32_t), + term_width); + if (m_opaque_sp) m_opaque_sp->SetTerminalWidth(term_width); } const char *SBDebugger::GetPrompt() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBDebugger, GetPrompt); + Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); if (log) @@ -1057,43 +1256,64 @@ const char *SBDebugger::GetPrompt() const { } void SBDebugger::SetPrompt(const char *prompt) { + LLDB_RECORD_METHOD(void, SBDebugger, SetPrompt, (const char *), prompt); + if (m_opaque_sp) m_opaque_sp->SetPrompt(llvm::StringRef::withNullAsEmpty(prompt)); } const char *SBDebugger::GetReproducerPath() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBDebugger, GetReproducerPath); + return (m_opaque_sp ? ConstString(m_opaque_sp->GetReproducerPath()).GetCString() : nullptr); } ScriptLanguage SBDebugger::GetScriptLanguage() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::ScriptLanguage, SBDebugger, + GetScriptLanguage); + return (m_opaque_sp ? m_opaque_sp->GetScriptLanguage() : eScriptLanguageNone); } void SBDebugger::SetScriptLanguage(ScriptLanguage script_lang) { + LLDB_RECORD_METHOD(void, SBDebugger, SetScriptLanguage, + (lldb::ScriptLanguage), script_lang); + if (m_opaque_sp) { m_opaque_sp->SetScriptLanguage(script_lang); } } bool SBDebugger::SetUseExternalEditor(bool value) { + LLDB_RECORD_METHOD(bool, SBDebugger, SetUseExternalEditor, (bool), value); + return (m_opaque_sp ? m_opaque_sp->SetUseExternalEditor(value) : false); } bool SBDebugger::GetUseExternalEditor() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBDebugger, GetUseExternalEditor); + return (m_opaque_sp ? m_opaque_sp->GetUseExternalEditor() : false); } bool SBDebugger::SetUseColor(bool value) { + LLDB_RECORD_METHOD(bool, SBDebugger, SetUseColor, (bool), value); + return (m_opaque_sp ? m_opaque_sp->SetUseColor(value) : false); } bool SBDebugger::GetUseColor() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBDebugger, GetUseColor); + return (m_opaque_sp ? m_opaque_sp->GetUseColor() : false); } bool SBDebugger::GetDescription(SBStream &description) { + LLDB_RECORD_METHOD(bool, SBDebugger, GetDescription, (lldb::SBStream &), + description); + Stream &strm = description.ref(); if (m_opaque_sp) { @@ -1107,10 +1327,15 @@ bool SBDebugger::GetDescription(SBStream &description) { } user_id_t SBDebugger::GetID() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::user_id_t, SBDebugger, GetID); + return (m_opaque_sp ? m_opaque_sp->GetID() : LLDB_INVALID_UID); } SBError SBDebugger::SetCurrentPlatform(const char *platform_name_cstr) { + LLDB_RECORD_METHOD(lldb::SBError, SBDebugger, SetCurrentPlatform, + (const char *), platform_name_cstr); + SBError sb_error; if (m_opaque_sp) { if (platform_name_cstr && platform_name_cstr[0]) { @@ -1135,10 +1360,13 @@ SBError SBDebugger::SetCurrentPlatform(const char *platform_name_cstr) { } else { sb_error.ref().SetErrorString("invalid debugger"); } - return sb_error; + return LLDB_RECORD_RESULT(sb_error); } bool SBDebugger::SetCurrentPlatformSDKRoot(const char *sysroot) { + LLDB_RECORD_METHOD(bool, SBDebugger, SetCurrentPlatformSDKRoot, + (const char *), sysroot); + Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); if (m_opaque_sp) { PlatformSP platform_sp( @@ -1155,49 +1383,68 @@ bool SBDebugger::SetCurrentPlatformSDKRoot(const char *sysroot) { } bool SBDebugger::GetCloseInputOnEOF() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBDebugger, GetCloseInputOnEOF); + return (m_opaque_sp ? m_opaque_sp->GetCloseInputOnEOF() : false); } void SBDebugger::SetCloseInputOnEOF(bool b) { + LLDB_RECORD_METHOD(void, SBDebugger, SetCloseInputOnEOF, (bool), b); + if (m_opaque_sp) m_opaque_sp->SetCloseInputOnEOF(b); } SBTypeCategory SBDebugger::GetCategory(const char *category_name) { + LLDB_RECORD_METHOD(lldb::SBTypeCategory, SBDebugger, GetCategory, + (const char *), category_name); + if (!category_name || *category_name == 0) - return SBTypeCategory(); + return LLDB_RECORD_RESULT(SBTypeCategory()); TypeCategoryImplSP category_sp; if (DataVisualization::Categories::GetCategory(ConstString(category_name), - category_sp, false)) - return SBTypeCategory(category_sp); - else - return SBTypeCategory(); + category_sp, false)) { + return LLDB_RECORD_RESULT(SBTypeCategory(category_sp)); + } else { + return LLDB_RECORD_RESULT(SBTypeCategory()); + } } SBTypeCategory SBDebugger::GetCategory(lldb::LanguageType lang_type) { + LLDB_RECORD_METHOD(lldb::SBTypeCategory, SBDebugger, GetCategory, + (lldb::LanguageType), lang_type); + TypeCategoryImplSP category_sp; - if (DataVisualization::Categories::GetCategory(lang_type, category_sp)) - return SBTypeCategory(category_sp); - else - return SBTypeCategory(); + if (DataVisualization::Categories::GetCategory(lang_type, category_sp)) { + return LLDB_RECORD_RESULT(SBTypeCategory(category_sp)); + } else { + return LLDB_RECORD_RESULT(SBTypeCategory()); + } } SBTypeCategory SBDebugger::CreateCategory(const char *category_name) { + LLDB_RECORD_METHOD(lldb::SBTypeCategory, SBDebugger, CreateCategory, + (const char *), category_name); + if (!category_name || *category_name == 0) - return SBTypeCategory(); + return LLDB_RECORD_RESULT(SBTypeCategory()); TypeCategoryImplSP category_sp; if (DataVisualization::Categories::GetCategory(ConstString(category_name), - category_sp, true)) - return SBTypeCategory(category_sp); - else - return SBTypeCategory(); + category_sp, true)) { + return LLDB_RECORD_RESULT(SBTypeCategory(category_sp)); + } else { + return LLDB_RECORD_RESULT(SBTypeCategory()); + } } bool SBDebugger::DeleteCategory(const char *category_name) { + LLDB_RECORD_METHOD(bool, SBDebugger, DeleteCategory, (const char *), + category_name); + if (!category_name || *category_name == 0) return false; @@ -1205,47 +1452,65 @@ bool SBDebugger::DeleteCategory(const char *category_name) { } uint32_t SBDebugger::GetNumCategories() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBDebugger, GetNumCategories); + return DataVisualization::Categories::GetCount(); } SBTypeCategory SBDebugger::GetCategoryAtIndex(uint32_t index) { - return SBTypeCategory( - DataVisualization::Categories::GetCategoryAtIndex(index)); + LLDB_RECORD_METHOD(lldb::SBTypeCategory, SBDebugger, GetCategoryAtIndex, + (uint32_t), index); + + return LLDB_RECORD_RESULT( + SBTypeCategory(DataVisualization::Categories::GetCategoryAtIndex(index))); } SBTypeCategory SBDebugger::GetDefaultCategory() { - return GetCategory("default"); + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTypeCategory, SBDebugger, + GetDefaultCategory); + + return LLDB_RECORD_RESULT(GetCategory("default")); } SBTypeFormat SBDebugger::GetFormatForType(SBTypeNameSpecifier type_name) { + LLDB_RECORD_METHOD(lldb::SBTypeFormat, SBDebugger, GetFormatForType, + (lldb::SBTypeNameSpecifier), type_name); + SBTypeCategory default_category_sb = GetDefaultCategory(); if (default_category_sb.GetEnabled()) - return default_category_sb.GetFormatForType(type_name); - return SBTypeFormat(); + return LLDB_RECORD_RESULT(default_category_sb.GetFormatForType(type_name)); + return LLDB_RECORD_RESULT(SBTypeFormat()); } -#ifndef LLDB_DISABLE_PYTHON SBTypeSummary SBDebugger::GetSummaryForType(SBTypeNameSpecifier type_name) { + LLDB_RECORD_METHOD(lldb::SBTypeSummary, SBDebugger, GetSummaryForType, + (lldb::SBTypeNameSpecifier), type_name); + if (!type_name.IsValid()) - return SBTypeSummary(); - return SBTypeSummary(DataVisualization::GetSummaryForType(type_name.GetSP())); + return LLDB_RECORD_RESULT(SBTypeSummary()); + return LLDB_RECORD_RESULT( + SBTypeSummary(DataVisualization::GetSummaryForType(type_name.GetSP()))); } -#endif // LLDB_DISABLE_PYTHON SBTypeFilter SBDebugger::GetFilterForType(SBTypeNameSpecifier type_name) { + LLDB_RECORD_METHOD(lldb::SBTypeFilter, SBDebugger, GetFilterForType, + (lldb::SBTypeNameSpecifier), type_name); + if (!type_name.IsValid()) - return SBTypeFilter(); - return SBTypeFilter(DataVisualization::GetFilterForType(type_name.GetSP())); + return LLDB_RECORD_RESULT(SBTypeFilter()); + return LLDB_RECORD_RESULT( + SBTypeFilter(DataVisualization::GetFilterForType(type_name.GetSP()))); } -#ifndef LLDB_DISABLE_PYTHON SBTypeSynthetic SBDebugger::GetSyntheticForType(SBTypeNameSpecifier type_name) { + LLDB_RECORD_METHOD(lldb::SBTypeSynthetic, SBDebugger, GetSyntheticForType, + (lldb::SBTypeNameSpecifier), type_name); + if (!type_name.IsValid()) - return SBTypeSynthetic(); - return SBTypeSynthetic( - DataVisualization::GetSyntheticForType(type_name.GetSP())); + return LLDB_RECORD_RESULT(SBTypeSynthetic()); + return LLDB_RECORD_RESULT(SBTypeSynthetic( + DataVisualization::GetSyntheticForType(type_name.GetSP()))); } -#endif // LLDB_DISABLE_PYTHON static llvm::ArrayRef<const char *> GetCategoryArray(const char **categories) { if (categories == nullptr) @@ -1257,6 +1522,9 @@ static llvm::ArrayRef<const char *> GetCategoryArray(const char **categories) { } bool SBDebugger::EnableLog(const char *channel, const char **categories) { + LLDB_RECORD_METHOD(bool, SBDebugger, EnableLog, (const char *, const char **), + channel, categories); + if (m_opaque_sp) { uint32_t log_options = LLDB_LOG_OPTION_PREPEND_TIMESTAMP | LLDB_LOG_OPTION_PREPEND_THREAD_NAME; @@ -1270,7 +1538,193 @@ bool SBDebugger::EnableLog(const char *channel, const char **categories) { void SBDebugger::SetLoggingCallback(lldb::LogOutputCallback log_callback, void *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); } } + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBInputReader>(Registry &R) { + LLDB_REGISTER_METHOD(void, SBInputReader, SetIsDone, (bool)); + LLDB_REGISTER_METHOD_CONST(bool, SBInputReader, IsActive, ()); +} + +static void SetFileHandleRedirect(SBDebugger *, FILE *, bool) { + // Do nothing. +} + +static bool GetDefaultArchitectureRedirect(char *arch_name, + size_t arch_name_len) { + // The function is writing to its argument. Without the redirect it would + // write into the replay buffer. + char buffer[1024]; + return SBDebugger::GetDefaultArchitecture(buffer, arch_name_len); +} + +template <> +void RegisterMethods<SBDebugger>(Registry &R) { + // Custom implementation. + R.Register(&invoke<void (SBDebugger::*)( + FILE *, bool)>::method<&SBDebugger::SetErrorFileHandle>::doit, + &SetFileHandleRedirect); + R.Register(&invoke<void (SBDebugger::*)( + FILE *, bool)>::method<&SBDebugger::SetOutputFileHandle>::doit, + &SetFileHandleRedirect); + R.Register<bool(char *, size_t)>(static_cast<bool (*)(char *, size_t)>( + &SBDebugger::GetDefaultArchitecture), + &GetDefaultArchitectureRedirect); + + LLDB_REGISTER_CONSTRUCTOR(SBDebugger, ()); + LLDB_REGISTER_CONSTRUCTOR(SBDebugger, (const lldb::DebuggerSP &)); + LLDB_REGISTER_CONSTRUCTOR(SBDebugger, (const lldb::SBDebugger &)); + LLDB_REGISTER_METHOD(lldb::SBDebugger &, + SBDebugger, operator=,(const lldb::SBDebugger &)); + LLDB_REGISTER_STATIC_METHOD(void, SBDebugger, Initialize, ()); + LLDB_REGISTER_STATIC_METHOD(lldb::SBError, SBDebugger, + InitializeWithErrorHandling, ()); + LLDB_REGISTER_STATIC_METHOD(void, SBDebugger, Terminate, ()); + LLDB_REGISTER_METHOD(void, SBDebugger, Clear, ()); + LLDB_REGISTER_STATIC_METHOD(lldb::SBDebugger, SBDebugger, Create, ()); + LLDB_REGISTER_STATIC_METHOD(lldb::SBDebugger, SBDebugger, Create, (bool)); + LLDB_REGISTER_STATIC_METHOD(void, SBDebugger, Destroy, + (lldb::SBDebugger &)); + LLDB_REGISTER_STATIC_METHOD(void, SBDebugger, MemoryPressureDetected, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBDebugger, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBDebugger, operator bool, ()); + LLDB_REGISTER_METHOD(void, SBDebugger, SetAsync, (bool)); + LLDB_REGISTER_METHOD(bool, SBDebugger, GetAsync, ()); + LLDB_REGISTER_METHOD(void, SBDebugger, SkipLLDBInitFiles, (bool)); + LLDB_REGISTER_METHOD(void, SBDebugger, SkipAppInitFiles, (bool)); + LLDB_REGISTER_METHOD(void, SBDebugger, SetInputFileHandle, (FILE *, bool)); + LLDB_REGISTER_METHOD(FILE *, SBDebugger, GetInputFileHandle, ()); + LLDB_REGISTER_METHOD(FILE *, SBDebugger, GetOutputFileHandle, ()); + LLDB_REGISTER_METHOD(FILE *, SBDebugger, GetErrorFileHandle, ()); + LLDB_REGISTER_METHOD(void, SBDebugger, SaveInputTerminalState, ()); + LLDB_REGISTER_METHOD(void, SBDebugger, RestoreInputTerminalState, ()); + LLDB_REGISTER_METHOD(lldb::SBCommandInterpreter, SBDebugger, + GetCommandInterpreter, ()); + LLDB_REGISTER_METHOD(void, SBDebugger, HandleCommand, (const char *)); + LLDB_REGISTER_METHOD(lldb::SBListener, SBDebugger, GetListener, ()); + LLDB_REGISTER_METHOD( + void, SBDebugger, HandleProcessEvent, + (const lldb::SBProcess &, const lldb::SBEvent &, FILE *, FILE *)); + LLDB_REGISTER_METHOD(lldb::SBSourceManager, SBDebugger, GetSourceManager, + ()); + LLDB_REGISTER_STATIC_METHOD(bool, SBDebugger, SetDefaultArchitecture, + (const char *)); + LLDB_REGISTER_METHOD(lldb::ScriptLanguage, SBDebugger, GetScriptingLanguage, + (const char *)); + LLDB_REGISTER_STATIC_METHOD(const char *, SBDebugger, GetVersionString, ()); + LLDB_REGISTER_STATIC_METHOD(const char *, SBDebugger, StateAsCString, + (lldb::StateType)); + LLDB_REGISTER_STATIC_METHOD(lldb::SBStructuredData, SBDebugger, + GetBuildConfiguration, ()); + LLDB_REGISTER_STATIC_METHOD(bool, SBDebugger, StateIsRunningState, + (lldb::StateType)); + LLDB_REGISTER_STATIC_METHOD(bool, SBDebugger, StateIsStoppedState, + (lldb::StateType)); + LLDB_REGISTER_METHOD( + lldb::SBTarget, SBDebugger, CreateTarget, + (const char *, const char *, const char *, bool, lldb::SBError &)); + LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, + CreateTargetWithFileAndTargetTriple, + (const char *, const char *)); + LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, + CreateTargetWithFileAndArch, + (const char *, const char *)); + LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, CreateTarget, + (const char *)); + LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, GetDummyTarget, ()); + LLDB_REGISTER_METHOD(bool, SBDebugger, DeleteTarget, (lldb::SBTarget &)); + LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, GetTargetAtIndex, + (uint32_t)); + LLDB_REGISTER_METHOD(uint32_t, SBDebugger, GetIndexOfTarget, + (lldb::SBTarget)); + LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, FindTargetWithProcessID, + (lldb::pid_t)); + LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, FindTargetWithFileAndArch, + (const char *, const char *)); + LLDB_REGISTER_METHOD(uint32_t, SBDebugger, GetNumTargets, ()); + LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, GetSelectedTarget, ()); + LLDB_REGISTER_METHOD(void, SBDebugger, SetSelectedTarget, + (lldb::SBTarget &)); + LLDB_REGISTER_METHOD(lldb::SBPlatform, SBDebugger, GetSelectedPlatform, ()); + LLDB_REGISTER_METHOD(void, SBDebugger, SetSelectedPlatform, + (lldb::SBPlatform &)); + LLDB_REGISTER_METHOD(uint32_t, SBDebugger, GetNumPlatforms, ()); + LLDB_REGISTER_METHOD(lldb::SBPlatform, SBDebugger, GetPlatformAtIndex, + (uint32_t)); + LLDB_REGISTER_METHOD(uint32_t, SBDebugger, GetNumAvailablePlatforms, ()); + LLDB_REGISTER_METHOD(lldb::SBStructuredData, SBDebugger, + GetAvailablePlatformInfoAtIndex, (uint32_t)); + LLDB_REGISTER_METHOD(void, SBDebugger, DispatchInputInterrupt, ()); + LLDB_REGISTER_METHOD(void, SBDebugger, DispatchInputEndOfFile, ()); + LLDB_REGISTER_METHOD(void, SBDebugger, PushInputReader, + (lldb::SBInputReader &)); + LLDB_REGISTER_METHOD(void, SBDebugger, RunCommandInterpreter, (bool, bool)); + LLDB_REGISTER_METHOD(void, SBDebugger, RunCommandInterpreter, + (bool, bool, lldb::SBCommandInterpreterRunOptions &, + int &, bool &, bool &)); + LLDB_REGISTER_METHOD(lldb::SBError, SBDebugger, RunREPL, + (lldb::LanguageType, const char *)); + LLDB_REGISTER_STATIC_METHOD(lldb::SBDebugger, SBDebugger, + FindDebuggerWithID, (int)); + LLDB_REGISTER_METHOD(const char *, SBDebugger, GetInstanceName, ()); + LLDB_REGISTER_STATIC_METHOD(lldb::SBError, SBDebugger, SetInternalVariable, + (const char *, const char *, const char *)); + LLDB_REGISTER_STATIC_METHOD(lldb::SBStringList, SBDebugger, + GetInternalVariableValue, + (const char *, const char *)); + LLDB_REGISTER_METHOD_CONST(uint32_t, SBDebugger, GetTerminalWidth, ()); + LLDB_REGISTER_METHOD(void, SBDebugger, SetTerminalWidth, (uint32_t)); + LLDB_REGISTER_METHOD_CONST(const char *, SBDebugger, GetPrompt, ()); + LLDB_REGISTER_METHOD(void, SBDebugger, SetPrompt, (const char *)); + LLDB_REGISTER_METHOD_CONST(const char *, SBDebugger, GetReproducerPath, ()); + LLDB_REGISTER_METHOD_CONST(lldb::ScriptLanguage, SBDebugger, + GetScriptLanguage, ()); + LLDB_REGISTER_METHOD(void, SBDebugger, SetScriptLanguage, + (lldb::ScriptLanguage)); + LLDB_REGISTER_METHOD(bool, SBDebugger, SetUseExternalEditor, (bool)); + LLDB_REGISTER_METHOD(bool, SBDebugger, GetUseExternalEditor, ()); + LLDB_REGISTER_METHOD(bool, SBDebugger, SetUseColor, (bool)); + LLDB_REGISTER_METHOD_CONST(bool, SBDebugger, GetUseColor, ()); + LLDB_REGISTER_METHOD(bool, SBDebugger, GetDescription, (lldb::SBStream &)); + LLDB_REGISTER_METHOD(lldb::user_id_t, SBDebugger, GetID, ()); + LLDB_REGISTER_METHOD(lldb::SBError, SBDebugger, SetCurrentPlatform, + (const char *)); + LLDB_REGISTER_METHOD(bool, SBDebugger, SetCurrentPlatformSDKRoot, + (const char *)); + LLDB_REGISTER_METHOD_CONST(bool, SBDebugger, GetCloseInputOnEOF, ()); + LLDB_REGISTER_METHOD(void, SBDebugger, SetCloseInputOnEOF, (bool)); + LLDB_REGISTER_METHOD(lldb::SBTypeCategory, SBDebugger, GetCategory, + (const char *)); + LLDB_REGISTER_METHOD(lldb::SBTypeCategory, SBDebugger, GetCategory, + (lldb::LanguageType)); + LLDB_REGISTER_METHOD(lldb::SBTypeCategory, SBDebugger, CreateCategory, + (const char *)); + LLDB_REGISTER_METHOD(bool, SBDebugger, DeleteCategory, (const char *)); + LLDB_REGISTER_METHOD(uint32_t, SBDebugger, GetNumCategories, ()); + LLDB_REGISTER_METHOD(lldb::SBTypeCategory, SBDebugger, GetCategoryAtIndex, + (uint32_t)); + LLDB_REGISTER_METHOD(lldb::SBTypeCategory, SBDebugger, GetDefaultCategory, + ()); + LLDB_REGISTER_METHOD(lldb::SBTypeFormat, SBDebugger, GetFormatForType, + (lldb::SBTypeNameSpecifier)); + LLDB_REGISTER_METHOD(lldb::SBTypeSummary, SBDebugger, GetSummaryForType, + (lldb::SBTypeNameSpecifier)); + LLDB_REGISTER_METHOD(lldb::SBTypeSynthetic, SBDebugger, GetSyntheticForType, + (lldb::SBTypeNameSpecifier)); + LLDB_REGISTER_METHOD(lldb::SBTypeFilter, SBDebugger, GetFilterForType, + (lldb::SBTypeNameSpecifier)); + LLDB_REGISTER_METHOD(bool, SBDebugger, EnableLog, + (const char *, const char **)); +} + +} +} diff --git a/source/API/SBDeclaration.cpp b/source/API/SBDeclaration.cpp index 90e4db367d2a7..a7790b2939810 100644 --- a/source/API/SBDeclaration.cpp +++ b/source/API/SBDeclaration.cpp @@ -1,17 +1,17 @@ //===-- SBDeclaration.cpp ----------------------------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBDeclaration.h" +#include "SBReproducerPrivate.h" +#include "Utils.h" #include "lldb/API/SBStream.h" #include "lldb/Host/PosixApi.h" #include "lldb/Symbol/Declaration.h" -#include "lldb/Utility/Log.h" #include "lldb/Utility/Stream.h" #include <limits.h> @@ -19,27 +19,30 @@ using namespace lldb; using namespace lldb_private; -SBDeclaration::SBDeclaration() : m_opaque_ap() {} +SBDeclaration::SBDeclaration() : m_opaque_up() { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBDeclaration); +} + +SBDeclaration::SBDeclaration(const SBDeclaration &rhs) : m_opaque_up() { + LLDB_RECORD_CONSTRUCTOR(SBDeclaration, (const lldb::SBDeclaration &), rhs); -SBDeclaration::SBDeclaration(const SBDeclaration &rhs) : m_opaque_ap() { - if (rhs.IsValid()) - ref() = rhs.ref(); + m_opaque_up = clone(rhs.m_opaque_up); } SBDeclaration::SBDeclaration(const lldb_private::Declaration *lldb_object_ptr) - : m_opaque_ap() { + : m_opaque_up() { if (lldb_object_ptr) - ref() = *lldb_object_ptr; + m_opaque_up = llvm::make_unique<Declaration>(*lldb_object_ptr); } const SBDeclaration &SBDeclaration::operator=(const SBDeclaration &rhs) { - if (this != &rhs) { - if (rhs.IsValid()) - ref() = rhs.ref(); - else - m_opaque_ap.reset(); - } - return *this; + LLDB_RECORD_METHOD(const lldb::SBDeclaration &, + SBDeclaration, operator=,(const lldb::SBDeclaration &), + rhs); + + if (this != &rhs) + m_opaque_up = clone(rhs.m_opaque_up); + return LLDB_RECORD_RESULT(*this); } void SBDeclaration::SetDeclaration( @@ -50,60 +53,75 @@ void SBDeclaration::SetDeclaration( SBDeclaration::~SBDeclaration() {} bool SBDeclaration::IsValid() const { - return m_opaque_ap.get() && m_opaque_ap->IsValid(); + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBDeclaration, IsValid); + return this->operator bool(); +} +SBDeclaration::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBDeclaration, operator bool); + + return m_opaque_up.get() && m_opaque_up->IsValid(); } SBFileSpec SBDeclaration::GetFileSpec() const { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBFileSpec, SBDeclaration, + GetFileSpec); + SBFileSpec sb_file_spec; - if (m_opaque_ap.get() && m_opaque_ap->GetFile()) - sb_file_spec.SetFileSpec(m_opaque_ap->GetFile()); + if (m_opaque_up.get() && m_opaque_up->GetFile()) + sb_file_spec.SetFileSpec(m_opaque_up->GetFile()); - if (log) { - SBStream sstr; - sb_file_spec.GetDescription(sstr); - log->Printf("SBLineEntry(%p)::GetFileSpec () => SBFileSpec(%p): %s", - static_cast<void *>(m_opaque_ap.get()), - static_cast<const void *>(sb_file_spec.get()), sstr.GetData()); - } - return sb_file_spec; + return LLDB_RECORD_RESULT(sb_file_spec); } uint32_t SBDeclaration::GetLine() const { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBDeclaration, GetLine); + uint32_t line = 0; - if (m_opaque_ap) - line = m_opaque_ap->GetLine(); + if (m_opaque_up) + line = m_opaque_up->GetLine(); - if (log) - log->Printf("SBLineEntry(%p)::GetLine () => %u", - static_cast<void *>(m_opaque_ap.get()), line); return line; } uint32_t SBDeclaration::GetColumn() const { - if (m_opaque_ap) - return m_opaque_ap->GetColumn(); + LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBDeclaration, GetColumn); + + if (m_opaque_up) + return m_opaque_up->GetColumn(); return 0; } void SBDeclaration::SetFileSpec(lldb::SBFileSpec filespec) { + LLDB_RECORD_METHOD(void, SBDeclaration, SetFileSpec, (lldb::SBFileSpec), + filespec); + if (filespec.IsValid()) ref().SetFile(filespec.ref()); else ref().SetFile(FileSpec()); } -void SBDeclaration::SetLine(uint32_t line) { ref().SetLine(line); } +void SBDeclaration::SetLine(uint32_t line) { + LLDB_RECORD_METHOD(void, SBDeclaration, SetLine, (uint32_t), line); -void SBDeclaration::SetColumn(uint32_t column) { ref().SetColumn(column); } + ref().SetLine(line); +} + +void SBDeclaration::SetColumn(uint32_t column) { + LLDB_RECORD_METHOD(void, SBDeclaration, SetColumn, (uint32_t), column); + + ref().SetColumn(column); +} bool SBDeclaration::operator==(const SBDeclaration &rhs) const { - lldb_private::Declaration *lhs_ptr = m_opaque_ap.get(); - lldb_private::Declaration *rhs_ptr = rhs.m_opaque_ap.get(); + LLDB_RECORD_METHOD_CONST( + bool, SBDeclaration, operator==,(const lldb::SBDeclaration &), rhs); + + lldb_private::Declaration *lhs_ptr = m_opaque_up.get(); + lldb_private::Declaration *rhs_ptr = rhs.m_opaque_up.get(); if (lhs_ptr && rhs_ptr) return lldb_private::Declaration::Compare(*lhs_ptr, *rhs_ptr) == 0; @@ -112,8 +130,11 @@ bool SBDeclaration::operator==(const SBDeclaration &rhs) const { } bool SBDeclaration::operator!=(const SBDeclaration &rhs) const { - lldb_private::Declaration *lhs_ptr = m_opaque_ap.get(); - lldb_private::Declaration *rhs_ptr = rhs.m_opaque_ap.get(); + LLDB_RECORD_METHOD_CONST( + bool, SBDeclaration, operator!=,(const lldb::SBDeclaration &), rhs); + + lldb_private::Declaration *lhs_ptr = m_opaque_up.get(); + lldb_private::Declaration *rhs_ptr = rhs.m_opaque_up.get(); if (lhs_ptr && rhs_ptr) return lldb_private::Declaration::Compare(*lhs_ptr, *rhs_ptr) != 0; @@ -122,25 +143,28 @@ bool SBDeclaration::operator!=(const SBDeclaration &rhs) const { } const lldb_private::Declaration *SBDeclaration::operator->() const { - return m_opaque_ap.get(); + return m_opaque_up.get(); } lldb_private::Declaration &SBDeclaration::ref() { - if (m_opaque_ap == NULL) - m_opaque_ap.reset(new lldb_private::Declaration()); - return *m_opaque_ap; + if (m_opaque_up == nullptr) + m_opaque_up.reset(new lldb_private::Declaration()); + return *m_opaque_up; } const lldb_private::Declaration &SBDeclaration::ref() const { - return *m_opaque_ap; + return *m_opaque_up; } bool SBDeclaration::GetDescription(SBStream &description) { + LLDB_RECORD_METHOD(bool, SBDeclaration, GetDescription, (lldb::SBStream &), + description); + Stream &strm = description.ref(); - if (m_opaque_ap) { + if (m_opaque_up) { char file_path[PATH_MAX * 2]; - m_opaque_ap->GetFile().GetPath(file_path, sizeof(file_path)); + m_opaque_up->GetFile().GetPath(file_path, sizeof(file_path)); strm.Printf("%s:%u", file_path, GetLine()); if (GetColumn() > 0) strm.Printf(":%u", GetColumn()); @@ -150,4 +174,34 @@ bool SBDeclaration::GetDescription(SBStream &description) { return true; } -lldb_private::Declaration *SBDeclaration::get() { return m_opaque_ap.get(); } +lldb_private::Declaration *SBDeclaration::get() { return m_opaque_up.get(); } + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBDeclaration>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBDeclaration, ()); + LLDB_REGISTER_CONSTRUCTOR(SBDeclaration, (const lldb::SBDeclaration &)); + LLDB_REGISTER_METHOD( + const lldb::SBDeclaration &, + SBDeclaration, operator=,(const lldb::SBDeclaration &)); + LLDB_REGISTER_METHOD_CONST(bool, SBDeclaration, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBDeclaration, operator bool, ()); + LLDB_REGISTER_METHOD_CONST(lldb::SBFileSpec, SBDeclaration, GetFileSpec, + ()); + LLDB_REGISTER_METHOD_CONST(uint32_t, SBDeclaration, GetLine, ()); + LLDB_REGISTER_METHOD_CONST(uint32_t, SBDeclaration, GetColumn, ()); + LLDB_REGISTER_METHOD(void, SBDeclaration, SetFileSpec, (lldb::SBFileSpec)); + LLDB_REGISTER_METHOD(void, SBDeclaration, SetLine, (uint32_t)); + LLDB_REGISTER_METHOD(void, SBDeclaration, SetColumn, (uint32_t)); + LLDB_REGISTER_METHOD_CONST( + bool, SBDeclaration, operator==,(const lldb::SBDeclaration &)); + LLDB_REGISTER_METHOD_CONST( + bool, SBDeclaration, operator!=,(const lldb::SBDeclaration &)); + LLDB_REGISTER_METHOD(bool, SBDeclaration, GetDescription, + (lldb::SBStream &)); +} + +} +} diff --git a/source/API/SBError.cpp b/source/API/SBError.cpp index 04433bb1aab01..7256e8e55de94 100644 --- a/source/API/SBError.cpp +++ b/source/API/SBError.cpp @@ -1,15 +1,15 @@ //===-- SBError.cpp ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBError.h" +#include "SBReproducerPrivate.h" +#include "Utils.h" #include "lldb/API/SBStream.h" -#include "lldb/Utility/Log.h" #include "lldb/Utility/Status.h" #include <stdarg.h> @@ -17,157 +17,196 @@ using namespace lldb; using namespace lldb_private; -SBError::SBError() : m_opaque_ap() {} +SBError::SBError() : m_opaque_up() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBError); } + +SBError::SBError(const SBError &rhs) : m_opaque_up() { + LLDB_RECORD_CONSTRUCTOR(SBError, (const lldb::SBError &), rhs); -SBError::SBError(const SBError &rhs) : m_opaque_ap() { - if (rhs.IsValid()) - m_opaque_ap.reset(new Status(*rhs)); + m_opaque_up = clone(rhs.m_opaque_up); } SBError::~SBError() {} const SBError &SBError::operator=(const SBError &rhs) { - if (rhs.IsValid()) { - if (m_opaque_ap) - *m_opaque_ap = *rhs; - else - m_opaque_ap.reset(new Status(*rhs)); - } else - m_opaque_ap.reset(); + LLDB_RECORD_METHOD(const lldb::SBError &, + SBError, operator=,(const lldb::SBError &), rhs); - return *this; + if (this != &rhs) + m_opaque_up = clone(rhs.m_opaque_up); + return LLDB_RECORD_RESULT(*this); } const char *SBError::GetCString() const { - if (m_opaque_ap) - return m_opaque_ap->AsCString(); - return NULL; + LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBError, GetCString); + + if (m_opaque_up) + return m_opaque_up->AsCString(); + return nullptr; } void SBError::Clear() { - if (m_opaque_ap) - m_opaque_ap->Clear(); + LLDB_RECORD_METHOD_NO_ARGS(void, SBError, Clear); + + if (m_opaque_up) + m_opaque_up->Clear(); } bool SBError::Fail() const { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBError, Fail); bool ret_value = false; - if (m_opaque_ap) - ret_value = m_opaque_ap->Fail(); + if (m_opaque_up) + ret_value = m_opaque_up->Fail(); - if (log) - log->Printf("SBError(%p)::Fail () => %i", - static_cast<void *>(m_opaque_ap.get()), ret_value); return ret_value; } bool SBError::Success() const { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - bool ret_value = true; - if (m_opaque_ap) - ret_value = m_opaque_ap->Success(); + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBError, Success); - if (log) - log->Printf("SBError(%p)::Success () => %i", - static_cast<void *>(m_opaque_ap.get()), ret_value); + bool ret_value = true; + if (m_opaque_up) + ret_value = m_opaque_up->Success(); return ret_value; } uint32_t SBError::GetError() const { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBError, GetError); + uint32_t err = 0; - if (m_opaque_ap) - err = m_opaque_ap->GetError(); + if (m_opaque_up) + err = m_opaque_up->GetError(); - if (log) - log->Printf("SBError(%p)::GetError () => 0x%8.8x", - static_cast<void *>(m_opaque_ap.get()), err); return err; } ErrorType SBError::GetType() const { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - ErrorType err_type = eErrorTypeInvalid; - if (m_opaque_ap) - err_type = m_opaque_ap->GetType(); + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::ErrorType, SBError, GetType); - if (log) - log->Printf("SBError(%p)::GetType () => %i", - static_cast<void *>(m_opaque_ap.get()), err_type); + ErrorType err_type = eErrorTypeInvalid; + if (m_opaque_up) + err_type = m_opaque_up->GetType(); return err_type; } void SBError::SetError(uint32_t err, ErrorType type) { + LLDB_RECORD_METHOD(void, SBError, SetError, (uint32_t, lldb::ErrorType), err, + type); + CreateIfNeeded(); - m_opaque_ap->SetError(err, type); + m_opaque_up->SetError(err, type); } void SBError::SetError(const Status &lldb_error) { CreateIfNeeded(); - *m_opaque_ap = lldb_error; + *m_opaque_up = lldb_error; } void SBError::SetErrorToErrno() { + LLDB_RECORD_METHOD_NO_ARGS(void, SBError, SetErrorToErrno); + CreateIfNeeded(); - m_opaque_ap->SetErrorToErrno(); + m_opaque_up->SetErrorToErrno(); } void SBError::SetErrorToGenericError() { + LLDB_RECORD_METHOD_NO_ARGS(void, SBError, SetErrorToGenericError); + CreateIfNeeded(); - m_opaque_ap->SetErrorToErrno(); + m_opaque_up->SetErrorToErrno(); } void SBError::SetErrorString(const char *err_str) { + LLDB_RECORD_METHOD(void, SBError, SetErrorString, (const char *), err_str); + CreateIfNeeded(); - m_opaque_ap->SetErrorString(err_str); + m_opaque_up->SetErrorString(err_str); } int SBError::SetErrorStringWithFormat(const char *format, ...) { CreateIfNeeded(); va_list args; va_start(args, format); - int num_chars = m_opaque_ap->SetErrorStringWithVarArg(format, args); + int num_chars = m_opaque_up->SetErrorStringWithVarArg(format, args); va_end(args); return num_chars; } -bool SBError::IsValid() const { return m_opaque_ap != NULL; } +bool SBError::IsValid() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBError, IsValid); + return this->operator bool(); +} +SBError::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBError, operator bool); + + return m_opaque_up != nullptr; +} void SBError::CreateIfNeeded() { - if (m_opaque_ap == NULL) - m_opaque_ap.reset(new Status()); + if (m_opaque_up == nullptr) + m_opaque_up.reset(new Status()); } -lldb_private::Status *SBError::operator->() { return m_opaque_ap.get(); } +lldb_private::Status *SBError::operator->() { return m_opaque_up.get(); } -lldb_private::Status *SBError::get() { return m_opaque_ap.get(); } +lldb_private::Status *SBError::get() { return m_opaque_up.get(); } lldb_private::Status &SBError::ref() { CreateIfNeeded(); - return *m_opaque_ap; + return *m_opaque_up; } const lldb_private::Status &SBError::operator*() const { // Be sure to call "IsValid()" before calling this function or it will crash - return *m_opaque_ap; + return *m_opaque_up; } bool SBError::GetDescription(SBStream &description) { - if (m_opaque_ap) { - if (m_opaque_ap->Success()) + LLDB_RECORD_METHOD(bool, SBError, GetDescription, (lldb::SBStream &), + description); + + if (m_opaque_up) { + if (m_opaque_up->Success()) description.Printf("success"); else { const char *err_string = GetCString(); - description.Printf("error: %s", (err_string != NULL ? err_string : "")); + description.Printf("error: %s", + (err_string != nullptr ? err_string : "")); } } else description.Printf("error: <NULL>"); return true; } + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBError>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBError, ()); + LLDB_REGISTER_CONSTRUCTOR(SBError, (const lldb::SBError &)); + LLDB_REGISTER_METHOD(const lldb::SBError &, + SBError, operator=,(const lldb::SBError &)); + LLDB_REGISTER_METHOD_CONST(const char *, SBError, GetCString, ()); + LLDB_REGISTER_METHOD(void, SBError, Clear, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBError, Fail, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBError, Success, ()); + LLDB_REGISTER_METHOD_CONST(uint32_t, SBError, GetError, ()); + LLDB_REGISTER_METHOD_CONST(lldb::ErrorType, SBError, GetType, ()); + LLDB_REGISTER_METHOD(void, SBError, SetError, (uint32_t, lldb::ErrorType)); + LLDB_REGISTER_METHOD(void, SBError, SetErrorToErrno, ()); + LLDB_REGISTER_METHOD(void, SBError, SetErrorToGenericError, ()); + LLDB_REGISTER_METHOD(void, SBError, SetErrorString, (const char *)); + LLDB_REGISTER_METHOD_CONST(bool, SBError, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBError, operator bool, ()); + LLDB_REGISTER_METHOD(bool, SBError, GetDescription, (lldb::SBStream &)); +} + +} +} diff --git a/source/API/SBEvent.cpp b/source/API/SBEvent.cpp index 0556f50f65442..75ca2830df9fb 100644 --- a/source/API/SBEvent.cpp +++ b/source/API/SBEvent.cpp @@ -1,13 +1,13 @@ //===-- SBEvent.cpp ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBEvent.h" +#include "SBReproducerPrivate.h" #include "lldb/API/SBBroadcaster.h" #include "lldb/API/SBStream.h" @@ -22,71 +22,83 @@ using namespace lldb; using namespace lldb_private; -SBEvent::SBEvent() : m_event_sp(), m_opaque_ptr(NULL) {} +SBEvent::SBEvent() : m_event_sp(), m_opaque_ptr(nullptr) { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBEvent); +} SBEvent::SBEvent(uint32_t event_type, const char *cstr, uint32_t cstr_len) : m_event_sp(new Event(event_type, new EventDataBytes(cstr, cstr_len))), - m_opaque_ptr(m_event_sp.get()) {} + m_opaque_ptr(m_event_sp.get()) { + LLDB_RECORD_CONSTRUCTOR(SBEvent, (uint32_t, const char *, uint32_t), + event_type, cstr, cstr_len); +} SBEvent::SBEvent(EventSP &event_sp) - : m_event_sp(event_sp), m_opaque_ptr(event_sp.get()) {} + : m_event_sp(event_sp), m_opaque_ptr(event_sp.get()) { + LLDB_RECORD_CONSTRUCTOR(SBEvent, (lldb::EventSP &), event_sp); +} -SBEvent::SBEvent(Event *event_ptr) : m_event_sp(), m_opaque_ptr(event_ptr) {} +SBEvent::SBEvent(Event *event_ptr) : m_event_sp(), m_opaque_ptr(event_ptr) { + LLDB_RECORD_CONSTRUCTOR(SBEvent, (lldb_private::Event *), event_ptr); +} SBEvent::SBEvent(const SBEvent &rhs) - : m_event_sp(rhs.m_event_sp), m_opaque_ptr(rhs.m_opaque_ptr) {} + : m_event_sp(rhs.m_event_sp), m_opaque_ptr(rhs.m_opaque_ptr) { + LLDB_RECORD_CONSTRUCTOR(SBEvent, (const lldb::SBEvent &), rhs); +} const SBEvent &SBEvent::operator=(const SBEvent &rhs) { + LLDB_RECORD_METHOD(const lldb::SBEvent &, + SBEvent, operator=,(const lldb::SBEvent &), rhs); + if (this != &rhs) { m_event_sp = rhs.m_event_sp; m_opaque_ptr = rhs.m_opaque_ptr; } - return *this; + return LLDB_RECORD_RESULT(*this); } SBEvent::~SBEvent() {} const char *SBEvent::GetDataFlavor() { + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBEvent, GetDataFlavor); + Event *lldb_event = get(); if (lldb_event) { EventData *event_data = lldb_event->GetData(); if (event_data) return lldb_event->GetData()->GetFlavor().AsCString(); } - return NULL; + return nullptr; } uint32_t SBEvent::GetType() const { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBEvent, GetType); + const Event *lldb_event = get(); uint32_t event_type = 0; if (lldb_event) event_type = lldb_event->GetType(); - if (log) { - StreamString sstr; - if (lldb_event && lldb_event->GetBroadcaster() && - lldb_event->GetBroadcaster()->GetEventNames(sstr, event_type, true)) - log->Printf("SBEvent(%p)::GetType () => 0x%8.8x (%s)", - static_cast<void *>(get()), event_type, sstr.GetData()); - else - log->Printf("SBEvent(%p)::GetType () => 0x%8.8x", - static_cast<void *>(get()), event_type); - } return event_type; } SBBroadcaster SBEvent::GetBroadcaster() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBBroadcaster, SBEvent, + GetBroadcaster); + SBBroadcaster broadcaster; const Event *lldb_event = get(); if (lldb_event) broadcaster.reset(lldb_event->GetBroadcaster(), false); - return broadcaster; + return LLDB_RECORD_RESULT(broadcaster); } const char *SBEvent::GetBroadcasterClass() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBEvent, GetBroadcasterClass); + const Event *lldb_event = get(); if (lldb_event) return lldb_event->GetBroadcaster()->GetBroadcasterClass().AsCString(); @@ -95,28 +107,30 @@ const char *SBEvent::GetBroadcasterClass() const { } bool SBEvent::BroadcasterMatchesPtr(const SBBroadcaster *broadcaster) { + LLDB_RECORD_METHOD(bool, SBEvent, BroadcasterMatchesPtr, + (const lldb::SBBroadcaster *), broadcaster); + if (broadcaster) return BroadcasterMatchesRef(*broadcaster); return false; } bool SBEvent::BroadcasterMatchesRef(const SBBroadcaster &broadcaster) { + LLDB_RECORD_METHOD(bool, SBEvent, BroadcasterMatchesRef, + (const lldb::SBBroadcaster &), broadcaster); Event *lldb_event = get(); bool success = false; if (lldb_event) success = lldb_event->BroadcasterIs(broadcaster.get()); - // For logging, this gets a little chatty so only enable this when verbose - // logging is on - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - LLDB_LOGV(log, "({0}) (SBBroadcaster({1}): {2}) => {3}", get(), - broadcaster.get(), broadcaster.GetName(), success); return success; } void SBEvent::Clear() { + LLDB_RECORD_METHOD_NO_ARGS(void, SBEvent, Clear); + Event *lldb_event = get(); if (lldb_event) lldb_event->Clear(); @@ -146,25 +160,29 @@ void SBEvent::reset(Event *event_ptr) { } bool SBEvent::IsValid() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBEvent, IsValid); + return this->operator bool(); +} +SBEvent::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBEvent, operator bool); + // Do NOT use m_opaque_ptr directly!!! Must use the SBEvent::get() accessor. // See comments in SBEvent::get().... - return SBEvent::get() != NULL; + return SBEvent::get() != nullptr; } const char *SBEvent::GetCStringFromEvent(const SBEvent &event) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - - if (log) - log->Printf("SBEvent(%p)::GetCStringFromEvent () => \"%s\"", - static_cast<void *>(event.get()), - reinterpret_cast<const char *>( - EventDataBytes::GetBytesFromEvent(event.get()))); + LLDB_RECORD_STATIC_METHOD(const char *, SBEvent, GetCStringFromEvent, + (const lldb::SBEvent &), event); return reinterpret_cast<const char *>( EventDataBytes::GetBytesFromEvent(event.get())); } bool SBEvent::GetDescription(SBStream &description) { + LLDB_RECORD_METHOD(bool, SBEvent, GetDescription, (lldb::SBStream &), + description); + Stream &strm = description.ref(); if (get()) { @@ -176,6 +194,9 @@ bool SBEvent::GetDescription(SBStream &description) { } bool SBEvent::GetDescription(SBStream &description) const { + LLDB_RECORD_METHOD_CONST(bool, SBEvent, GetDescription, (lldb::SBStream &), + description); + Stream &strm = description.ref(); if (get()) { @@ -185,3 +206,37 @@ bool SBEvent::GetDescription(SBStream &description) const { return true; } + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBEvent>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBEvent, ()); + LLDB_REGISTER_CONSTRUCTOR(SBEvent, (uint32_t, const char *, uint32_t)); + LLDB_REGISTER_CONSTRUCTOR(SBEvent, (lldb::EventSP &)); + LLDB_REGISTER_CONSTRUCTOR(SBEvent, (lldb_private::Event *)); + LLDB_REGISTER_CONSTRUCTOR(SBEvent, (const lldb::SBEvent &)); + LLDB_REGISTER_METHOD(const lldb::SBEvent &, + SBEvent, operator=,(const lldb::SBEvent &)); + LLDB_REGISTER_METHOD(const char *, SBEvent, GetDataFlavor, ()); + LLDB_REGISTER_METHOD_CONST(uint32_t, SBEvent, GetType, ()); + LLDB_REGISTER_METHOD_CONST(lldb::SBBroadcaster, SBEvent, GetBroadcaster, + ()); + LLDB_REGISTER_METHOD_CONST(const char *, SBEvent, GetBroadcasterClass, ()); + LLDB_REGISTER_METHOD(bool, SBEvent, BroadcasterMatchesPtr, + (const lldb::SBBroadcaster *)); + LLDB_REGISTER_METHOD(bool, SBEvent, BroadcasterMatchesRef, + (const lldb::SBBroadcaster &)); + LLDB_REGISTER_METHOD(void, SBEvent, Clear, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBEvent, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBEvent, operator bool, ()); + LLDB_REGISTER_STATIC_METHOD(const char *, SBEvent, GetCStringFromEvent, + (const lldb::SBEvent &)); + LLDB_REGISTER_METHOD(bool, SBEvent, GetDescription, (lldb::SBStream &)); + LLDB_REGISTER_METHOD_CONST(bool, SBEvent, GetDescription, + (lldb::SBStream &)); +} + +} +} diff --git a/source/API/SBExecutionContext.cpp b/source/API/SBExecutionContext.cpp index 74a543c77d2d3..1224c2abe989b 100644 --- a/source/API/SBExecutionContext.cpp +++ b/source/API/SBExecutionContext.cpp @@ -1,14 +1,14 @@ //===-- SBExecutionContext.cpp ------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBExecutionContext.h" +#include "SBReproducerPrivate.h" #include "lldb/API/SBFrame.h" #include "lldb/API/SBProcess.h" @@ -20,32 +20,49 @@ using namespace lldb; using namespace lldb_private; -SBExecutionContext::SBExecutionContext() : m_exe_ctx_sp() {} +SBExecutionContext::SBExecutionContext() : m_exe_ctx_sp() { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBExecutionContext); +} SBExecutionContext::SBExecutionContext(const lldb::SBExecutionContext &rhs) - : m_exe_ctx_sp(rhs.m_exe_ctx_sp) {} + : m_exe_ctx_sp(rhs.m_exe_ctx_sp) { + LLDB_RECORD_CONSTRUCTOR(SBExecutionContext, + (const lldb::SBExecutionContext &), rhs); +} SBExecutionContext::SBExecutionContext( lldb::ExecutionContextRefSP exe_ctx_ref_sp) - : m_exe_ctx_sp(exe_ctx_ref_sp) {} + : m_exe_ctx_sp(exe_ctx_ref_sp) { + LLDB_RECORD_CONSTRUCTOR(SBExecutionContext, (lldb::ExecutionContextRefSP), + exe_ctx_ref_sp); +} SBExecutionContext::SBExecutionContext(const lldb::SBTarget &target) : m_exe_ctx_sp(new ExecutionContextRef()) { + LLDB_RECORD_CONSTRUCTOR(SBExecutionContext, (const lldb::SBTarget &), target); + m_exe_ctx_sp->SetTargetSP(target.GetSP()); } SBExecutionContext::SBExecutionContext(const lldb::SBProcess &process) : m_exe_ctx_sp(new ExecutionContextRef()) { + LLDB_RECORD_CONSTRUCTOR(SBExecutionContext, (const lldb::SBProcess &), + process); + m_exe_ctx_sp->SetProcessSP(process.GetSP()); } SBExecutionContext::SBExecutionContext(lldb::SBThread thread) : m_exe_ctx_sp(new ExecutionContextRef()) { + LLDB_RECORD_CONSTRUCTOR(SBExecutionContext, (lldb::SBThread), thread); + m_exe_ctx_sp->SetThreadPtr(thread.get()); } SBExecutionContext::SBExecutionContext(const lldb::SBFrame &frame) : m_exe_ctx_sp(new ExecutionContextRef()) { + LLDB_RECORD_CONSTRUCTOR(SBExecutionContext, (const lldb::SBFrame &), frame); + m_exe_ctx_sp->SetFrameSP(frame.GetFrameSP()); } @@ -53,8 +70,12 @@ SBExecutionContext::~SBExecutionContext() {} const SBExecutionContext &SBExecutionContext:: operator=(const lldb::SBExecutionContext &rhs) { + LLDB_RECORD_METHOD( + const lldb::SBExecutionContext &, + SBExecutionContext, operator=,(const lldb::SBExecutionContext &), rhs); + m_exe_ctx_sp = rhs.m_exe_ctx_sp; - return *this; + return LLDB_RECORD_RESULT(*this); } ExecutionContextRef *SBExecutionContext::get() const { @@ -62,41 +83,81 @@ ExecutionContextRef *SBExecutionContext::get() const { } SBTarget SBExecutionContext::GetTarget() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBTarget, SBExecutionContext, + GetTarget); + SBTarget sb_target; if (m_exe_ctx_sp) { TargetSP target_sp(m_exe_ctx_sp->GetTargetSP()); if (target_sp) sb_target.SetSP(target_sp); } - return sb_target; + return LLDB_RECORD_RESULT(sb_target); } SBProcess SBExecutionContext::GetProcess() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBProcess, SBExecutionContext, + GetProcess); + SBProcess sb_process; if (m_exe_ctx_sp) { ProcessSP process_sp(m_exe_ctx_sp->GetProcessSP()); if (process_sp) sb_process.SetSP(process_sp); } - return sb_process; + return LLDB_RECORD_RESULT(sb_process); } SBThread SBExecutionContext::GetThread() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBThread, SBExecutionContext, + GetThread); + SBThread sb_thread; if (m_exe_ctx_sp) { ThreadSP thread_sp(m_exe_ctx_sp->GetThreadSP()); if (thread_sp) sb_thread.SetThread(thread_sp); } - return sb_thread; + return LLDB_RECORD_RESULT(sb_thread); } SBFrame SBExecutionContext::GetFrame() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBFrame, SBExecutionContext, GetFrame); + SBFrame sb_frame; if (m_exe_ctx_sp) { StackFrameSP frame_sp(m_exe_ctx_sp->GetFrameSP()); if (frame_sp) sb_frame.SetFrameSP(frame_sp); } - return sb_frame; + return LLDB_RECORD_RESULT(sb_frame); +} + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBExecutionContext>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBExecutionContext, ()); + LLDB_REGISTER_CONSTRUCTOR(SBExecutionContext, + (const lldb::SBExecutionContext &)); + LLDB_REGISTER_CONSTRUCTOR(SBExecutionContext, + (lldb::ExecutionContextRefSP)); + LLDB_REGISTER_CONSTRUCTOR(SBExecutionContext, (const lldb::SBTarget &)); + LLDB_REGISTER_CONSTRUCTOR(SBExecutionContext, (const lldb::SBProcess &)); + LLDB_REGISTER_CONSTRUCTOR(SBExecutionContext, (lldb::SBThread)); + LLDB_REGISTER_CONSTRUCTOR(SBExecutionContext, (const lldb::SBFrame &)); + LLDB_REGISTER_METHOD( + const lldb::SBExecutionContext &, + SBExecutionContext, operator=,(const lldb::SBExecutionContext &)); + LLDB_REGISTER_METHOD_CONST(lldb::SBTarget, SBExecutionContext, GetTarget, + ()); + LLDB_REGISTER_METHOD_CONST(lldb::SBProcess, SBExecutionContext, GetProcess, + ()); + LLDB_REGISTER_METHOD_CONST(lldb::SBThread, SBExecutionContext, GetThread, + ()); + LLDB_REGISTER_METHOD_CONST(lldb::SBFrame, SBExecutionContext, GetFrame, ()); +} + +} } diff --git a/source/API/SBExpressionOptions.cpp b/source/API/SBExpressionOptions.cpp index 76cec876a2161..8c34194abf1e2 100644 --- a/source/API/SBExpressionOptions.cpp +++ b/source/API/SBExpressionOptions.cpp @@ -1,177 +1,336 @@ //===-- SBExpressionOptions.cpp ---------------------------------------------*- //C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBExpressionOptions.h" +#include "SBReproducerPrivate.h" +#include "Utils.h" #include "lldb/API/SBStream.h" - #include "lldb/Target/Target.h" using namespace lldb; using namespace lldb_private; SBExpressionOptions::SBExpressionOptions() - : m_opaque_ap(new EvaluateExpressionOptions()) {} + : m_opaque_up(new EvaluateExpressionOptions()) { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBExpressionOptions); +} -SBExpressionOptions::SBExpressionOptions(const SBExpressionOptions &rhs) { - m_opaque_ap.reset(new EvaluateExpressionOptions()); - *(m_opaque_ap.get()) = rhs.ref(); +SBExpressionOptions::SBExpressionOptions(const SBExpressionOptions &rhs) + : m_opaque_up() { + LLDB_RECORD_CONSTRUCTOR(SBExpressionOptions, + (const lldb::SBExpressionOptions &), rhs); + + m_opaque_up = clone(rhs.m_opaque_up); } const SBExpressionOptions &SBExpressionOptions:: operator=(const SBExpressionOptions &rhs) { - if (this != &rhs) { - this->ref() = rhs.ref(); - } - return *this; + LLDB_RECORD_METHOD( + const lldb::SBExpressionOptions &, + SBExpressionOptions, operator=,(const lldb::SBExpressionOptions &), rhs); + + if (this != &rhs) + m_opaque_up = clone(rhs.m_opaque_up); + return LLDB_RECORD_RESULT(*this); } SBExpressionOptions::~SBExpressionOptions() {} bool SBExpressionOptions::GetCoerceResultToId() const { - return m_opaque_ap->DoesCoerceToId(); + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions, + GetCoerceResultToId); + + return m_opaque_up->DoesCoerceToId(); } void SBExpressionOptions::SetCoerceResultToId(bool coerce) { - m_opaque_ap->SetCoerceToId(coerce); + LLDB_RECORD_METHOD(void, SBExpressionOptions, SetCoerceResultToId, (bool), + coerce); + + m_opaque_up->SetCoerceToId(coerce); } bool SBExpressionOptions::GetUnwindOnError() const { - return m_opaque_ap->DoesUnwindOnError(); + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions, GetUnwindOnError); + + return m_opaque_up->DoesUnwindOnError(); } void SBExpressionOptions::SetUnwindOnError(bool unwind) { - m_opaque_ap->SetUnwindOnError(unwind); + LLDB_RECORD_METHOD(void, SBExpressionOptions, SetUnwindOnError, (bool), + unwind); + + m_opaque_up->SetUnwindOnError(unwind); } bool SBExpressionOptions::GetIgnoreBreakpoints() const { - return m_opaque_ap->DoesIgnoreBreakpoints(); + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions, + GetIgnoreBreakpoints); + + return m_opaque_up->DoesIgnoreBreakpoints(); } void SBExpressionOptions::SetIgnoreBreakpoints(bool ignore) { - m_opaque_ap->SetIgnoreBreakpoints(ignore); + LLDB_RECORD_METHOD(void, SBExpressionOptions, SetIgnoreBreakpoints, (bool), + ignore); + + m_opaque_up->SetIgnoreBreakpoints(ignore); } lldb::DynamicValueType SBExpressionOptions::GetFetchDynamicValue() const { - return m_opaque_ap->GetUseDynamic(); + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::DynamicValueType, SBExpressionOptions, + GetFetchDynamicValue); + + return m_opaque_up->GetUseDynamic(); } void SBExpressionOptions::SetFetchDynamicValue(lldb::DynamicValueType dynamic) { - m_opaque_ap->SetUseDynamic(dynamic); + LLDB_RECORD_METHOD(void, SBExpressionOptions, SetFetchDynamicValue, + (lldb::DynamicValueType), dynamic); + + m_opaque_up->SetUseDynamic(dynamic); } uint32_t SBExpressionOptions::GetTimeoutInMicroSeconds() const { - return m_opaque_ap->GetTimeout() ? m_opaque_ap->GetTimeout()->count() : 0; + LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBExpressionOptions, + GetTimeoutInMicroSeconds); + + return m_opaque_up->GetTimeout() ? m_opaque_up->GetTimeout()->count() : 0; } void SBExpressionOptions::SetTimeoutInMicroSeconds(uint32_t timeout) { - m_opaque_ap->SetTimeout(timeout == 0 ? Timeout<std::micro>(llvm::None) + LLDB_RECORD_METHOD(void, SBExpressionOptions, SetTimeoutInMicroSeconds, + (uint32_t), timeout); + + m_opaque_up->SetTimeout(timeout == 0 ? Timeout<std::micro>(llvm::None) : std::chrono::microseconds(timeout)); } uint32_t SBExpressionOptions::GetOneThreadTimeoutInMicroSeconds() const { - return m_opaque_ap->GetOneThreadTimeout() ? m_opaque_ap->GetOneThreadTimeout()->count() : 0; + LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBExpressionOptions, + GetOneThreadTimeoutInMicroSeconds); + + return m_opaque_up->GetOneThreadTimeout() + ? m_opaque_up->GetOneThreadTimeout()->count() + : 0; } void SBExpressionOptions::SetOneThreadTimeoutInMicroSeconds(uint32_t timeout) { - m_opaque_ap->SetOneThreadTimeout(timeout == 0 + LLDB_RECORD_METHOD(void, SBExpressionOptions, + SetOneThreadTimeoutInMicroSeconds, (uint32_t), timeout); + + m_opaque_up->SetOneThreadTimeout(timeout == 0 ? Timeout<std::micro>(llvm::None) : std::chrono::microseconds(timeout)); } bool SBExpressionOptions::GetTryAllThreads() const { - return m_opaque_ap->GetTryAllThreads(); + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions, GetTryAllThreads); + + return m_opaque_up->GetTryAllThreads(); } void SBExpressionOptions::SetTryAllThreads(bool run_others) { - m_opaque_ap->SetTryAllThreads(run_others); + LLDB_RECORD_METHOD(void, SBExpressionOptions, SetTryAllThreads, (bool), + run_others); + + m_opaque_up->SetTryAllThreads(run_others); } bool SBExpressionOptions::GetStopOthers() const { - return m_opaque_ap->GetStopOthers(); + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions, GetStopOthers); + + return m_opaque_up->GetStopOthers(); } void SBExpressionOptions::SetStopOthers(bool run_others) { - m_opaque_ap->SetStopOthers(run_others); + LLDB_RECORD_METHOD(void, SBExpressionOptions, SetStopOthers, (bool), + run_others); + + m_opaque_up->SetStopOthers(run_others); } bool SBExpressionOptions::GetTrapExceptions() const { - return m_opaque_ap->GetTrapExceptions(); + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions, + GetTrapExceptions); + + return m_opaque_up->GetTrapExceptions(); } void SBExpressionOptions::SetTrapExceptions(bool trap_exceptions) { - m_opaque_ap->SetTrapExceptions(trap_exceptions); + LLDB_RECORD_METHOD(void, SBExpressionOptions, SetTrapExceptions, (bool), + trap_exceptions); + + m_opaque_up->SetTrapExceptions(trap_exceptions); } void SBExpressionOptions::SetLanguage(lldb::LanguageType language) { - m_opaque_ap->SetLanguage(language); + LLDB_RECORD_METHOD(void, SBExpressionOptions, SetLanguage, + (lldb::LanguageType), language); + + m_opaque_up->SetLanguage(language); } void SBExpressionOptions::SetCancelCallback( lldb::ExpressionCancelCallback callback, void *baton) { - m_opaque_ap->SetCancelCallback(callback, baton); + LLDB_RECORD_DUMMY(void, SBExpressionOptions, SetCancelCallback, + (lldb::ExpressionCancelCallback, void *), callback, baton); + + m_opaque_up->SetCancelCallback(callback, baton); } bool SBExpressionOptions::GetGenerateDebugInfo() { - return m_opaque_ap->GetGenerateDebugInfo(); + LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions, GetGenerateDebugInfo); + + return m_opaque_up->GetGenerateDebugInfo(); } void SBExpressionOptions::SetGenerateDebugInfo(bool b) { - return m_opaque_ap->SetGenerateDebugInfo(b); + LLDB_RECORD_METHOD(void, SBExpressionOptions, SetGenerateDebugInfo, (bool), + b); + + return m_opaque_up->SetGenerateDebugInfo(b); } bool SBExpressionOptions::GetSuppressPersistentResult() { - return m_opaque_ap->GetResultIsInternal(); + LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions, + GetSuppressPersistentResult); + + return m_opaque_up->GetResultIsInternal(); } void SBExpressionOptions::SetSuppressPersistentResult(bool b) { - return m_opaque_ap->SetResultIsInternal(b); + LLDB_RECORD_METHOD(void, SBExpressionOptions, SetSuppressPersistentResult, + (bool), b); + + return m_opaque_up->SetResultIsInternal(b); } const char *SBExpressionOptions::GetPrefix() const { - return m_opaque_ap->GetPrefix(); + LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBExpressionOptions, + GetPrefix); + + return m_opaque_up->GetPrefix(); } void SBExpressionOptions::SetPrefix(const char *prefix) { - return m_opaque_ap->SetPrefix(prefix); + LLDB_RECORD_METHOD(void, SBExpressionOptions, SetPrefix, (const char *), + prefix); + + return m_opaque_up->SetPrefix(prefix); } bool SBExpressionOptions::GetAutoApplyFixIts() { - return m_opaque_ap->GetAutoApplyFixIts(); + LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions, GetAutoApplyFixIts); + + return m_opaque_up->GetAutoApplyFixIts(); } void SBExpressionOptions::SetAutoApplyFixIts(bool b) { - return m_opaque_ap->SetAutoApplyFixIts(b); + LLDB_RECORD_METHOD(void, SBExpressionOptions, SetAutoApplyFixIts, (bool), b); + + return m_opaque_up->SetAutoApplyFixIts(b); } bool SBExpressionOptions::GetTopLevel() { - return m_opaque_ap->GetExecutionPolicy() == eExecutionPolicyTopLevel; + LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions, GetTopLevel); + + return m_opaque_up->GetExecutionPolicy() == eExecutionPolicyTopLevel; } void SBExpressionOptions::SetTopLevel(bool b) { - m_opaque_ap->SetExecutionPolicy(b ? eExecutionPolicyTopLevel - : m_opaque_ap->default_execution_policy); + LLDB_RECORD_METHOD(void, SBExpressionOptions, SetTopLevel, (bool), b); + + m_opaque_up->SetExecutionPolicy(b ? eExecutionPolicyTopLevel + : m_opaque_up->default_execution_policy); } bool SBExpressionOptions::GetAllowJIT() { - return m_opaque_ap->GetExecutionPolicy() != eExecutionPolicyNever; + LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions, GetAllowJIT); + + return m_opaque_up->GetExecutionPolicy() != eExecutionPolicyNever; } void SBExpressionOptions::SetAllowJIT(bool allow) { - m_opaque_ap->SetExecutionPolicy(allow ? m_opaque_ap->default_execution_policy - : eExecutionPolicyNever); + LLDB_RECORD_METHOD(void, SBExpressionOptions, SetAllowJIT, (bool), allow); + + m_opaque_up->SetExecutionPolicy(allow ? m_opaque_up->default_execution_policy + : eExecutionPolicyNever); } EvaluateExpressionOptions *SBExpressionOptions::get() const { - return m_opaque_ap.get(); + return m_opaque_up.get(); } EvaluateExpressionOptions &SBExpressionOptions::ref() const { - return *(m_opaque_ap.get()); + return *(m_opaque_up.get()); +} + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBExpressionOptions>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBExpressionOptions, ()); + LLDB_REGISTER_CONSTRUCTOR(SBExpressionOptions, + (const lldb::SBExpressionOptions &)); + LLDB_REGISTER_METHOD( + const lldb::SBExpressionOptions &, + SBExpressionOptions, operator=,(const lldb::SBExpressionOptions &)); + LLDB_REGISTER_METHOD_CONST(bool, SBExpressionOptions, GetCoerceResultToId, + ()); + LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetCoerceResultToId, + (bool)); + LLDB_REGISTER_METHOD_CONST(bool, SBExpressionOptions, GetUnwindOnError, ()); + LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetUnwindOnError, (bool)); + LLDB_REGISTER_METHOD_CONST(bool, SBExpressionOptions, GetIgnoreBreakpoints, + ()); + LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetIgnoreBreakpoints, + (bool)); + LLDB_REGISTER_METHOD_CONST(lldb::DynamicValueType, SBExpressionOptions, + GetFetchDynamicValue, ()); + LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetFetchDynamicValue, + (lldb::DynamicValueType)); + LLDB_REGISTER_METHOD_CONST(uint32_t, SBExpressionOptions, + GetTimeoutInMicroSeconds, ()); + LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetTimeoutInMicroSeconds, + (uint32_t)); + LLDB_REGISTER_METHOD_CONST(uint32_t, SBExpressionOptions, + GetOneThreadTimeoutInMicroSeconds, ()); + LLDB_REGISTER_METHOD(void, SBExpressionOptions, + SetOneThreadTimeoutInMicroSeconds, (uint32_t)); + LLDB_REGISTER_METHOD_CONST(bool, SBExpressionOptions, GetTryAllThreads, ()); + LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetTryAllThreads, (bool)); + LLDB_REGISTER_METHOD_CONST(bool, SBExpressionOptions, GetStopOthers, ()); + LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetStopOthers, (bool)); + LLDB_REGISTER_METHOD_CONST(bool, SBExpressionOptions, GetTrapExceptions, + ()); + LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetTrapExceptions, (bool)); + LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetLanguage, + (lldb::LanguageType)); + LLDB_REGISTER_METHOD(bool, SBExpressionOptions, GetGenerateDebugInfo, ()); + LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetGenerateDebugInfo, + (bool)); + LLDB_REGISTER_METHOD(bool, SBExpressionOptions, GetSuppressPersistentResult, + ()); + LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetSuppressPersistentResult, + (bool)); + LLDB_REGISTER_METHOD_CONST(const char *, SBExpressionOptions, GetPrefix, + ()); + LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetPrefix, (const char *)); + LLDB_REGISTER_METHOD(bool, SBExpressionOptions, GetAutoApplyFixIts, ()); + LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetAutoApplyFixIts, (bool)); + LLDB_REGISTER_METHOD(bool, SBExpressionOptions, GetTopLevel, ()); + LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetTopLevel, (bool)); + LLDB_REGISTER_METHOD(bool, SBExpressionOptions, GetAllowJIT, ()); + LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetAllowJIT, (bool)); +} + +} } diff --git a/source/API/SBFileSpec.cpp b/source/API/SBFileSpec.cpp index f136409d0b68e..2f910b9ba294e 100644 --- a/source/API/SBFileSpec.cpp +++ b/source/API/SBFileSpec.cpp @@ -1,76 +1,109 @@ //===-- SBFileSpec.cpp ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// -#include <inttypes.h> -#include <limits.h> - #include "lldb/API/SBFileSpec.h" +#include "SBReproducerPrivate.h" +#include "Utils.h" #include "lldb/API/SBStream.h" #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" +#include <inttypes.h> +#include <limits.h> + using namespace lldb; using namespace lldb_private; -SBFileSpec::SBFileSpec() : m_opaque_ap(new lldb_private::FileSpec()) {} +SBFileSpec::SBFileSpec() : m_opaque_up(new lldb_private::FileSpec()) { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBFileSpec); +} -SBFileSpec::SBFileSpec(const SBFileSpec &rhs) - : m_opaque_ap(new lldb_private::FileSpec(*rhs.m_opaque_ap)) {} +SBFileSpec::SBFileSpec(const SBFileSpec &rhs) : m_opaque_up() { + LLDB_RECORD_CONSTRUCTOR(SBFileSpec, (const lldb::SBFileSpec &), rhs); + + m_opaque_up = clone(rhs.m_opaque_up); +} SBFileSpec::SBFileSpec(const lldb_private::FileSpec &fspec) - : m_opaque_ap(new lldb_private::FileSpec(fspec)) {} + : m_opaque_up(new lldb_private::FileSpec(fspec)) {} // Deprecated!!! -SBFileSpec::SBFileSpec(const char *path) : m_opaque_ap(new FileSpec(path)) { - FileSystem::Instance().Resolve(*m_opaque_ap); +SBFileSpec::SBFileSpec(const char *path) : m_opaque_up(new FileSpec(path)) { + LLDB_RECORD_CONSTRUCTOR(SBFileSpec, (const char *), path); + + FileSystem::Instance().Resolve(*m_opaque_up); } SBFileSpec::SBFileSpec(const char *path, bool resolve) - : m_opaque_ap(new FileSpec(path)) { + : m_opaque_up(new FileSpec(path)) { + LLDB_RECORD_CONSTRUCTOR(SBFileSpec, (const char *, bool), path, resolve); + if (resolve) - FileSystem::Instance().Resolve(*m_opaque_ap); + FileSystem::Instance().Resolve(*m_opaque_up); } SBFileSpec::~SBFileSpec() {} const SBFileSpec &SBFileSpec::operator=(const SBFileSpec &rhs) { + LLDB_RECORD_METHOD(const lldb::SBFileSpec &, + SBFileSpec, operator=,(const lldb::SBFileSpec &), rhs); + if (this != &rhs) - *m_opaque_ap = *rhs.m_opaque_ap; - return *this; + m_opaque_up = clone(rhs.m_opaque_up); + return LLDB_RECORD_RESULT(*this); } -bool SBFileSpec::IsValid() const { return m_opaque_ap->operator bool(); } +bool SBFileSpec::operator==(const SBFileSpec &rhs) const { + LLDB_RECORD_METHOD_CONST(bool, SBFileSpec, operator==,(const SBFileSpec &rhs), + rhs); -bool SBFileSpec::Exists() const { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + return ref() == rhs.ref(); +} - bool result = FileSystem::Instance().Exists(*m_opaque_ap); +bool SBFileSpec::operator!=(const SBFileSpec &rhs) const { + LLDB_RECORD_METHOD_CONST(bool, SBFileSpec, operator!=,(const SBFileSpec &rhs), + rhs); - if (log) - log->Printf("SBFileSpec(%p)::Exists () => %s", - static_cast<void *>(m_opaque_ap.get()), - (result ? "true" : "false")); + return !(*this == rhs); +} - return result; +bool SBFileSpec::IsValid() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBFileSpec, IsValid); + return this->operator bool(); +} +SBFileSpec::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBFileSpec, operator bool); + + return m_opaque_up->operator bool(); +} + +bool SBFileSpec::Exists() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBFileSpec, Exists); + + return FileSystem::Instance().Exists(*m_opaque_up); } bool SBFileSpec::ResolveExecutableLocation() { - return FileSystem::Instance().ResolveExecutableLocation(*m_opaque_ap); + LLDB_RECORD_METHOD_NO_ARGS(bool, SBFileSpec, ResolveExecutableLocation); + + return FileSystem::Instance().ResolveExecutableLocation(*m_opaque_up); } int SBFileSpec::ResolvePath(const char *src_path, char *dst_path, size_t dst_len) { + LLDB_RECORD_STATIC_METHOD(int, SBFileSpec, ResolvePath, + (const char *, char *, size_t), src_path, dst_path, + dst_len); + llvm::SmallString<64> result(src_path); FileSystem::Instance().Resolve(result); ::snprintf(dst_path, dst_len, "%s", result.c_str()); @@ -78,61 +111,42 @@ int SBFileSpec::ResolvePath(const char *src_path, char *dst_path, } const char *SBFileSpec::GetFilename() const { - const char *s = m_opaque_ap->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_ap.get()), s); - else - log->Printf("SBFileSpec(%p)::GetFilename () => NULL", - static_cast<void *>(m_opaque_ap.get())); - } + LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBFileSpec, GetFilename); - return s; + return m_opaque_up->GetFilename().AsCString(); } const char *SBFileSpec::GetDirectory() const { - FileSpec directory{*m_opaque_ap}; + LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBFileSpec, GetDirectory); + + 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_ap.get()), - directory.GetCString()); - else - log->Printf("SBFileSpec(%p)::GetDirectory () => NULL", - static_cast<void *>(m_opaque_ap.get())); - } return directory.GetCString(); } void SBFileSpec::SetFilename(const char *filename) { + LLDB_RECORD_METHOD(void, SBFileSpec, SetFilename, (const char *), filename); + if (filename && filename[0]) - m_opaque_ap->GetFilename().SetCString(filename); + m_opaque_up->GetFilename().SetCString(filename); else - m_opaque_ap->GetFilename().Clear(); + m_opaque_up->GetFilename().Clear(); } void SBFileSpec::SetDirectory(const char *directory) { + LLDB_RECORD_METHOD(void, SBFileSpec, SetDirectory, (const char *), directory); + if (directory && directory[0]) - m_opaque_ap->GetDirectory().SetCString(directory); + m_opaque_up->GetDirectory().SetCString(directory); else - m_opaque_ap->GetDirectory().Clear(); + m_opaque_up->GetDirectory().Clear(); } uint32_t SBFileSpec::GetPath(char *dst_path, size_t dst_len) const { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - - uint32_t result = m_opaque_ap->GetPath(dst_path, dst_len); + LLDB_RECORD_METHOD_CONST(uint32_t, SBFileSpec, GetPath, (char *, size_t), + dst_path, dst_len); - if (log) - log->Printf("SBFileSpec(%p)::GetPath (dst_path=\"%.*s\", dst_len=%" PRIu64 - ") => %u", - static_cast<void *>(m_opaque_ap.get()), result, dst_path, - static_cast<uint64_t>(dst_len), result); + uint32_t result = m_opaque_up->GetPath(dst_path, dst_len); if (result == 0 && dst_path && dst_len > 0) *dst_path = '\0'; @@ -140,31 +154,70 @@ uint32_t SBFileSpec::GetPath(char *dst_path, size_t dst_len) const { } const lldb_private::FileSpec *SBFileSpec::operator->() const { - return m_opaque_ap.get(); + return m_opaque_up.get(); } const lldb_private::FileSpec *SBFileSpec::get() const { - return m_opaque_ap.get(); + return m_opaque_up.get(); } const lldb_private::FileSpec &SBFileSpec::operator*() const { - return *m_opaque_ap; + return *m_opaque_up; } -const lldb_private::FileSpec &SBFileSpec::ref() const { return *m_opaque_ap; } +const lldb_private::FileSpec &SBFileSpec::ref() const { return *m_opaque_up; } void SBFileSpec::SetFileSpec(const lldb_private::FileSpec &fs) { - *m_opaque_ap = fs; + *m_opaque_up = fs; } bool SBFileSpec::GetDescription(SBStream &description) const { + LLDB_RECORD_METHOD_CONST(bool, SBFileSpec, GetDescription, (lldb::SBStream &), + description); + Stream &strm = description.ref(); char path[PATH_MAX]; - if (m_opaque_ap->GetPath(path, sizeof(path))) + if (m_opaque_up->GetPath(path, sizeof(path))) strm.PutCString(path); return true; } void SBFileSpec::AppendPathComponent(const char *fn) { - m_opaque_ap->AppendPathComponent(fn); + LLDB_RECORD_METHOD(void, SBFileSpec, AppendPathComponent, (const char *), fn); + + m_opaque_up->AppendPathComponent(fn); +} + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBFileSpec>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBFileSpec, ()); + LLDB_REGISTER_CONSTRUCTOR(SBFileSpec, (const lldb::SBFileSpec &)); + LLDB_REGISTER_CONSTRUCTOR(SBFileSpec, (const char *)); + LLDB_REGISTER_CONSTRUCTOR(SBFileSpec, (const char *, bool)); + LLDB_REGISTER_METHOD(const lldb::SBFileSpec &, + SBFileSpec, operator=,(const lldb::SBFileSpec &)); + LLDB_REGISTER_METHOD_CONST(bool, + SBFileSpec, operator==,(const lldb::SBFileSpec &)); + LLDB_REGISTER_METHOD_CONST(bool, + SBFileSpec, operator!=,(const lldb::SBFileSpec &)); + LLDB_REGISTER_METHOD_CONST(bool, SBFileSpec, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBFileSpec, operator bool, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBFileSpec, Exists, ()); + LLDB_REGISTER_METHOD(bool, SBFileSpec, ResolveExecutableLocation, ()); + LLDB_REGISTER_STATIC_METHOD(int, SBFileSpec, ResolvePath, + (const char *, char *, size_t)); + LLDB_REGISTER_METHOD_CONST(const char *, SBFileSpec, GetFilename, ()); + LLDB_REGISTER_METHOD_CONST(const char *, SBFileSpec, GetDirectory, ()); + LLDB_REGISTER_METHOD(void, SBFileSpec, SetFilename, (const char *)); + LLDB_REGISTER_METHOD(void, SBFileSpec, SetDirectory, (const char *)); + LLDB_REGISTER_METHOD_CONST(uint32_t, SBFileSpec, GetPath, (char *, size_t)); + LLDB_REGISTER_METHOD_CONST(bool, SBFileSpec, GetDescription, + (lldb::SBStream &)); + LLDB_REGISTER_METHOD(void, SBFileSpec, AppendPathComponent, (const char *)); +} + +} } diff --git a/source/API/SBFileSpecList.cpp b/source/API/SBFileSpecList.cpp index 439859c3fd856..3143964b38cbe 100644 --- a/source/API/SBFileSpecList.cpp +++ b/source/API/SBFileSpecList.cpp @@ -1,99 +1,121 @@ //===-- SBFileSpecList.cpp --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// -#include <limits.h> - -#include "lldb/API/SBFileSpec.h" #include "lldb/API/SBFileSpecList.h" +#include "SBReproducerPrivate.h" +#include "Utils.h" +#include "lldb/API/SBFileSpec.h" #include "lldb/API/SBStream.h" #include "lldb/Core/FileSpecList.h" #include "lldb/Host/PosixApi.h" #include "lldb/Utility/FileSpec.h" -#include "lldb/Utility/Log.h" #include "lldb/Utility/Stream.h" +#include <limits.h> + using namespace lldb; using namespace lldb_private; -SBFileSpecList::SBFileSpecList() : m_opaque_ap(new FileSpecList()) {} +SBFileSpecList::SBFileSpecList() : m_opaque_up(new FileSpecList()) { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBFileSpecList); +} -SBFileSpecList::SBFileSpecList(const SBFileSpecList &rhs) : m_opaque_ap() { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); +SBFileSpecList::SBFileSpecList(const SBFileSpecList &rhs) : m_opaque_up() { + LLDB_RECORD_CONSTRUCTOR(SBFileSpecList, (const lldb::SBFileSpecList &), rhs); - if (rhs.m_opaque_ap) - m_opaque_ap.reset(new FileSpecList(*(rhs.get()))); - if (log) { - log->Printf("SBFileSpecList::SBFileSpecList (const SBFileSpecList " - "rhs.ap=%p) => SBFileSpecList(%p)", - static_cast<void *>(rhs.m_opaque_ap.get()), - static_cast<void *>(m_opaque_ap.get())); - } + m_opaque_up = clone(rhs.m_opaque_up); } SBFileSpecList::~SBFileSpecList() {} const SBFileSpecList &SBFileSpecList::operator=(const SBFileSpecList &rhs) { - if (this != &rhs) { - m_opaque_ap.reset(new lldb_private::FileSpecList(*(rhs.get()))); - } - return *this; + LLDB_RECORD_METHOD(const lldb::SBFileSpecList &, + SBFileSpecList, operator=,(const lldb::SBFileSpecList &), + rhs); + + if (this != &rhs) + m_opaque_up = clone(rhs.m_opaque_up); + return LLDB_RECORD_RESULT(*this); } -uint32_t SBFileSpecList::GetSize() const { return m_opaque_ap->GetSize(); } +uint32_t SBFileSpecList::GetSize() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBFileSpecList, GetSize); + + return m_opaque_up->GetSize(); +} void SBFileSpecList::Append(const SBFileSpec &sb_file) { - m_opaque_ap->Append(sb_file.ref()); + LLDB_RECORD_METHOD(void, SBFileSpecList, Append, (const lldb::SBFileSpec &), + sb_file); + + m_opaque_up->Append(sb_file.ref()); } bool SBFileSpecList::AppendIfUnique(const SBFileSpec &sb_file) { - return m_opaque_ap->AppendIfUnique(sb_file.ref()); + LLDB_RECORD_METHOD(bool, SBFileSpecList, AppendIfUnique, + (const lldb::SBFileSpec &), sb_file); + + return m_opaque_up->AppendIfUnique(sb_file.ref()); } -void SBFileSpecList::Clear() { m_opaque_ap->Clear(); } +void SBFileSpecList::Clear() { + LLDB_RECORD_METHOD_NO_ARGS(void, SBFileSpecList, Clear); + + m_opaque_up->Clear(); +} uint32_t SBFileSpecList::FindFileIndex(uint32_t idx, const SBFileSpec &sb_file, bool full) { - return m_opaque_ap->FindFileIndex(idx, sb_file.ref(), full); + LLDB_RECORD_METHOD(uint32_t, SBFileSpecList, FindFileIndex, + (uint32_t, const lldb::SBFileSpec &, bool), idx, sb_file, + full); + + return m_opaque_up->FindFileIndex(idx, sb_file.ref(), full); } const SBFileSpec SBFileSpecList::GetFileSpecAtIndex(uint32_t idx) const { + LLDB_RECORD_METHOD_CONST(const lldb::SBFileSpec, SBFileSpecList, + GetFileSpecAtIndex, (uint32_t), idx); + SBFileSpec new_spec; - new_spec.SetFileSpec(m_opaque_ap->GetFileSpecAtIndex(idx)); - return new_spec; + new_spec.SetFileSpec(m_opaque_up->GetFileSpecAtIndex(idx)); + return LLDB_RECORD_RESULT(new_spec); } const lldb_private::FileSpecList *SBFileSpecList::operator->() const { - return m_opaque_ap.get(); + return m_opaque_up.get(); } const lldb_private::FileSpecList *SBFileSpecList::get() const { - return m_opaque_ap.get(); + return m_opaque_up.get(); } const lldb_private::FileSpecList &SBFileSpecList::operator*() const { - return *m_opaque_ap; + return *m_opaque_up; } const lldb_private::FileSpecList &SBFileSpecList::ref() const { - return *m_opaque_ap; + return *m_opaque_up; } bool SBFileSpecList::GetDescription(SBStream &description) const { + LLDB_RECORD_METHOD_CONST(bool, SBFileSpecList, GetDescription, + (lldb::SBStream &), description); + Stream &strm = description.ref(); - if (m_opaque_ap) { - uint32_t num_files = m_opaque_ap->GetSize(); + if (m_opaque_up) { + uint32_t num_files = m_opaque_up->GetSize(); strm.Printf("%d files: ", num_files); for (uint32_t i = 0; i < num_files; i++) { char path[PATH_MAX]; - if (m_opaque_ap->GetFileSpecAtIndex(i).GetPath(path, sizeof(path))) + if (m_opaque_up->GetFileSpecAtIndex(i).GetPath(path, sizeof(path))) strm.Printf("\n %s", path); } } else @@ -101,3 +123,30 @@ bool SBFileSpecList::GetDescription(SBStream &description) const { return true; } + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBFileSpecList>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBFileSpecList, ()); + LLDB_REGISTER_CONSTRUCTOR(SBFileSpecList, (const lldb::SBFileSpecList &)); + LLDB_REGISTER_METHOD( + const lldb::SBFileSpecList &, + SBFileSpecList, operator=,(const lldb::SBFileSpecList &)); + LLDB_REGISTER_METHOD_CONST(uint32_t, SBFileSpecList, GetSize, ()); + LLDB_REGISTER_METHOD(void, SBFileSpecList, Append, + (const lldb::SBFileSpec &)); + LLDB_REGISTER_METHOD(bool, SBFileSpecList, AppendIfUnique, + (const lldb::SBFileSpec &)); + LLDB_REGISTER_METHOD(void, SBFileSpecList, Clear, ()); + LLDB_REGISTER_METHOD(uint32_t, SBFileSpecList, FindFileIndex, + (uint32_t, const lldb::SBFileSpec &, bool)); + LLDB_REGISTER_METHOD_CONST(const lldb::SBFileSpec, SBFileSpecList, + GetFileSpecAtIndex, (uint32_t)); + LLDB_REGISTER_METHOD_CONST(bool, SBFileSpecList, GetDescription, + (lldb::SBStream &)); +} + +} +} diff --git a/source/API/SBFrame.cpp b/source/API/SBFrame.cpp index 44dcfd806be59..9268f0f9bdbf9 100644 --- a/source/API/SBFrame.cpp +++ b/source/API/SBFrame.cpp @@ -1,9 +1,8 @@ //===-- SBFrame.cpp ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -15,11 +14,13 @@ #include "lldb/lldb-types.h" -#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h" +#include "SBReproducerPrivate.h" +#include "Utils.h" #include "lldb/Core/Address.h" #include "lldb/Core/StreamFile.h" #include "lldb/Core/ValueObjectRegister.h" #include "lldb/Core/ValueObjectVariable.h" +#include "lldb/Expression/ExpressionVariable.h" #include "lldb/Expression/UserExpression.h" #include "lldb/Host/Host.h" #include "lldb/Symbol/Block.h" @@ -37,7 +38,6 @@ #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/ConstString.h" -#include "lldb/Utility/Log.h" #include "lldb/Utility/Stream.h" #include "lldb/API/SBAddress.h" @@ -54,30 +54,31 @@ using namespace lldb; using namespace lldb_private; -SBFrame::SBFrame() : m_opaque_sp(new ExecutionContextRef()) {} +SBFrame::SBFrame() : m_opaque_sp(new ExecutionContextRef()) { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBFrame); +} SBFrame::SBFrame(const StackFrameSP &lldb_object_sp) : m_opaque_sp(new ExecutionContextRef(lldb_object_sp)) { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - - if (log) { - SBStream sstr; - GetDescription(sstr); - log->Printf("SBFrame::SBFrame (sp=%p) => SBFrame(%p): %s", - static_cast<void *>(lldb_object_sp.get()), - static_cast<void *>(lldb_object_sp.get()), sstr.GetData()); - } + LLDB_RECORD_CONSTRUCTOR(SBFrame, (const lldb::StackFrameSP &), + lldb_object_sp); } -SBFrame::SBFrame(const SBFrame &rhs) - : m_opaque_sp(new ExecutionContextRef(*rhs.m_opaque_sp)) {} +SBFrame::SBFrame(const SBFrame &rhs) : m_opaque_sp() { + LLDB_RECORD_CONSTRUCTOR(SBFrame, (const lldb::SBFrame &), rhs); + + m_opaque_sp = clone(rhs.m_opaque_sp); +} SBFrame::~SBFrame() = default; const SBFrame &SBFrame::operator=(const SBFrame &rhs) { + LLDB_RECORD_METHOD(const lldb::SBFrame &, + SBFrame, operator=,(const lldb::SBFrame &), rhs); + if (this != &rhs) - *m_opaque_sp = *rhs.m_opaque_sp; - return *this; + m_opaque_sp = clone(rhs.m_opaque_sp); + return LLDB_RECORD_RESULT(*this); } StackFrameSP SBFrame::GetFrameSP() const { @@ -89,6 +90,12 @@ void SBFrame::SetFrameSP(const StackFrameSP &lldb_object_sp) { } bool SBFrame::IsValid() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBFrame, IsValid); + return this->operator bool(); +} +SBFrame::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBFrame, operator bool); + std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -105,7 +112,9 @@ bool SBFrame::IsValid() const { } SBSymbolContext SBFrame::GetSymbolContext(uint32_t resolve_scope) const { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_CONST(lldb::SBSymbolContext, SBFrame, GetSymbolContext, + (uint32_t), resolve_scope); + SBSymbolContext sb_sym_ctx; std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -117,31 +126,17 @@ SBSymbolContext SBFrame::GetSymbolContext(uint32_t resolve_scope) const { Process::StopLocker stop_locker; if (stop_locker.TryLock(&process->GetRunLock())) { frame = exe_ctx.GetFramePtr(); - if (frame) { + if (frame) sb_sym_ctx.SetSymbolContext(&frame->GetSymbolContext(scope)); - } else { - if (log) - log->Printf("SBFrame::GetVariables () => error: could not " - "reconstruct frame object for this SBFrame."); - } - } else { - if (log) - log->Printf( - "SBFrame::GetSymbolContext () => error: process is running"); } } - if (log) - log->Printf("SBFrame(%p)::GetSymbolContext (resolve_scope=0x%8.8x) => " - "SBSymbolContext(%p)", - static_cast<void *>(frame), resolve_scope, - static_cast<void *>(sb_sym_ctx.get())); - - return sb_sym_ctx; + return LLDB_RECORD_RESULT(sb_sym_ctx); } SBModule SBFrame::GetModule() const { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBModule, SBFrame, GetModule); + SBModule sb_module; ModuleSP module_sp; std::unique_lock<std::recursive_mutex> lock; @@ -157,27 +152,17 @@ SBModule SBFrame::GetModule() const { if (frame) { module_sp = frame->GetSymbolContext(eSymbolContextModule).module_sp; sb_module.SetSP(module_sp); - } else { - if (log) - log->Printf("SBFrame::GetModule () => error: could not reconstruct " - "frame object for this SBFrame."); } - } else { - if (log) - log->Printf("SBFrame::GetModule () => error: process is running"); } } - if (log) - log->Printf("SBFrame(%p)::GetModule () => SBModule(%p)", - static_cast<void *>(frame), - static_cast<void *>(module_sp.get())); - - return sb_module; + return LLDB_RECORD_RESULT(sb_module); } SBCompileUnit SBFrame::GetCompileUnit() const { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBCompileUnit, SBFrame, + GetCompileUnit); + SBCompileUnit sb_comp_unit; std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -192,26 +177,16 @@ SBCompileUnit SBFrame::GetCompileUnit() const { if (frame) { sb_comp_unit.reset( frame->GetSymbolContext(eSymbolContextCompUnit).comp_unit); - } else { - if (log) - log->Printf("SBFrame::GetCompileUnit () => error: could not " - "reconstruct frame object for this SBFrame."); } - } else { - if (log) - log->Printf("SBFrame::GetCompileUnit () => error: process is running"); } } - if (log) - log->Printf("SBFrame(%p)::GetCompileUnit () => SBCompileUnit(%p)", - static_cast<void *>(frame), - static_cast<void *>(sb_comp_unit.get())); - return sb_comp_unit; + return LLDB_RECORD_RESULT(sb_comp_unit); } SBFunction SBFrame::GetFunction() const { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBFunction, SBFrame, GetFunction); + SBFunction sb_function; std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -226,26 +201,16 @@ SBFunction SBFrame::GetFunction() const { if (frame) { sb_function.reset( frame->GetSymbolContext(eSymbolContextFunction).function); - } else { - if (log) - log->Printf("SBFrame::GetFunction () => error: could not reconstruct " - "frame object for this SBFrame."); } - } else { - if (log) - log->Printf("SBFrame::GetFunction () => error: process is running"); } } - if (log) - log->Printf("SBFrame(%p)::GetFunction () => SBFunction(%p)", - static_cast<void *>(frame), - static_cast<void *>(sb_function.get())); - return sb_function; + return LLDB_RECORD_RESULT(sb_function); } SBSymbol SBFrame::GetSymbol() const { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBSymbol, SBFrame, GetSymbol); + SBSymbol sb_symbol; std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -259,25 +224,16 @@ SBSymbol SBFrame::GetSymbol() const { frame = exe_ctx.GetFramePtr(); if (frame) { sb_symbol.reset(frame->GetSymbolContext(eSymbolContextSymbol).symbol); - } else { - if (log) - log->Printf("SBFrame::GetSymbol () => error: could not reconstruct " - "frame object for this SBFrame."); } - } else { - if (log) - log->Printf("SBFrame::GetSymbol () => error: process is running"); } } - if (log) - log->Printf("SBFrame(%p)::GetSymbol () => SBSymbol(%p)", - static_cast<void *>(frame), - static_cast<void *>(sb_symbol.get())); - return sb_symbol; + + return LLDB_RECORD_RESULT(sb_symbol); } SBBlock SBFrame::GetBlock() const { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBBlock, SBFrame, GetBlock); + SBBlock sb_block; std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -289,60 +245,37 @@ SBBlock SBFrame::GetBlock() const { Process::StopLocker stop_locker; if (stop_locker.TryLock(&process->GetRunLock())) { frame = exe_ctx.GetFramePtr(); - if (frame) { + if (frame) sb_block.SetPtr(frame->GetSymbolContext(eSymbolContextBlock).block); - } else { - if (log) - log->Printf("SBFrame::GetBlock () => error: could not reconstruct " - "frame object for this SBFrame."); - } - } else { - if (log) - log->Printf("SBFrame(%p)::GetBlock () => error: process is running", - static_cast<void *>(frame)); } } - if (log) - log->Printf("SBFrame(%p)::GetBlock () => SBBlock(%p)", - static_cast<void *>(frame), - static_cast<void *>(sb_block.GetPtr())); - return sb_block; + return LLDB_RECORD_RESULT(sb_block); } SBBlock SBFrame::GetFrameBlock() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBBlock, SBFrame, GetFrameBlock); + SBBlock sb_block; std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); Process *process = exe_ctx.GetProcessPtr(); if (target && process) { Process::StopLocker stop_locker; if (stop_locker.TryLock(&process->GetRunLock())) { frame = exe_ctx.GetFramePtr(); - if (frame) { + if (frame) sb_block.SetPtr(frame->GetFrameBlock()); - } else { - if (log) - log->Printf("SBFrame::GetFrameBlock () => error: could not " - "reconstruct frame object for this SBFrame."); - } - } else { - if (log) - log->Printf("SBFrame::GetFrameBlock () => error: process is running"); } } - if (log) - log->Printf("SBFrame(%p)::GetFrameBlock () => SBBlock(%p)", - static_cast<void *>(frame), - static_cast<void *>(sb_block.GetPtr())); - return sb_block; + return LLDB_RECORD_RESULT(sb_block); } SBLineEntry SBFrame::GetLineEntry() const { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBLineEntry, SBFrame, GetLineEntry); + SBLineEntry sb_line_entry; std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -357,24 +290,15 @@ SBLineEntry SBFrame::GetLineEntry() const { if (frame) { sb_line_entry.SetLineEntry( frame->GetSymbolContext(eSymbolContextLineEntry).line_entry); - } else { - if (log) - log->Printf("SBFrame::GetLineEntry () => error: could not " - "reconstruct frame object for this SBFrame."); } - } else { - if (log) - log->Printf("SBFrame::GetLineEntry () => error: process is running"); } } - if (log) - log->Printf("SBFrame(%p)::GetLineEntry () => SBLineEntry(%p)", - static_cast<void *>(frame), - static_cast<void *>(sb_line_entry.get())); - return sb_line_entry; + return LLDB_RECORD_RESULT(sb_line_entry); } uint32_t SBFrame::GetFrameID() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBFrame, GetFrameID); + uint32_t frame_idx = UINT32_MAX; std::unique_lock<std::recursive_mutex> lock; @@ -384,14 +308,12 @@ uint32_t SBFrame::GetFrameID() const { if (frame) frame_idx = frame->GetFrameIndex(); - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBFrame(%p)::GetFrameID () => %u", static_cast<void *>(frame), - frame_idx); return frame_idx; } lldb::addr_t SBFrame::GetCFA() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::addr_t, SBFrame, GetCFA); + std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -402,7 +324,8 @@ lldb::addr_t SBFrame::GetCFA() const { } addr_t SBFrame::GetPC() const { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::addr_t, SBFrame, GetPC); + addr_t addr = LLDB_INVALID_ADDRESS; std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -417,26 +340,16 @@ addr_t SBFrame::GetPC() const { if (frame) { addr = frame->GetFrameCodeAddress().GetOpcodeLoadAddress( target, AddressClass::eCode); - } else { - if (log) - log->Printf("SBFrame::GetPC () => error: could not reconstruct frame " - "object for this SBFrame."); } - } else { - if (log) - log->Printf("SBFrame::GetPC () => error: process is running"); } } - if (log) - log->Printf("SBFrame(%p)::GetPC () => 0x%" PRIx64, - static_cast<void *>(frame), addr); - return addr; } bool SBFrame::SetPC(addr_t new_pc) { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(bool, SBFrame, SetPC, (lldb::addr_t), new_pc); + bool ret_val = false; std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -450,26 +363,16 @@ bool SBFrame::SetPC(addr_t new_pc) { frame = exe_ctx.GetFramePtr(); if (frame) { ret_val = frame->GetRegisterContext()->SetPC(new_pc); - } else { - if (log) - log->Printf("SBFrame::SetPC () => error: could not reconstruct frame " - "object for this SBFrame."); } - } else { - if (log) - log->Printf("SBFrame::SetPC () => error: process is running"); } } - if (log) - log->Printf("SBFrame(%p)::SetPC (new_pc=0x%" PRIx64 ") => %i", - static_cast<void *>(frame), new_pc, ret_val); - return ret_val; } addr_t SBFrame::GetSP() const { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::addr_t, SBFrame, GetSP); + addr_t addr = LLDB_INVALID_ADDRESS; std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -483,25 +386,16 @@ addr_t SBFrame::GetSP() const { frame = exe_ctx.GetFramePtr(); if (frame) { addr = frame->GetRegisterContext()->GetSP(); - } else { - if (log) - log->Printf("SBFrame::GetSP () => error: could not reconstruct frame " - "object for this SBFrame."); } - } else { - if (log) - log->Printf("SBFrame::GetSP () => error: process is running"); } } - if (log) - log->Printf("SBFrame(%p)::GetSP () => 0x%" PRIx64, - static_cast<void *>(frame), addr); return addr; } addr_t SBFrame::GetFP() const { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::addr_t, SBFrame, GetFP); + addr_t addr = LLDB_INVALID_ADDRESS; std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -513,27 +407,17 @@ addr_t SBFrame::GetFP() const { Process::StopLocker stop_locker; if (stop_locker.TryLock(&process->GetRunLock())) { frame = exe_ctx.GetFramePtr(); - if (frame) { + if (frame) addr = frame->GetRegisterContext()->GetFP(); - } else { - if (log) - log->Printf("SBFrame::GetFP () => error: could not reconstruct frame " - "object for this SBFrame."); - } - } else { - if (log) - log->Printf("SBFrame::GetFP () => error: process is running"); } } - if (log) - log->Printf("SBFrame(%p)::GetFP () => 0x%" PRIx64, - static_cast<void *>(frame), addr); return addr; } SBAddress SBFrame::GetPCAddress() const { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBAddress, SBFrame, GetPCAddress); + SBAddress sb_addr; std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -545,27 +429,23 @@ SBAddress SBFrame::GetPCAddress() const { Process::StopLocker stop_locker; if (stop_locker.TryLock(&process->GetRunLock())) { frame = exe_ctx.GetFramePtr(); - if (frame) { + if (frame) sb_addr.SetAddress(&frame->GetFrameCodeAddress()); - } else { - if (log) - log->Printf("SBFrame::GetPCAddress () => error: could not " - "reconstruct frame object for this SBFrame."); - } - } else { - if (log) - log->Printf("SBFrame::GetPCAddress () => error: process is running"); } } - if (log) - log->Printf("SBFrame(%p)::GetPCAddress () => SBAddress(%p)", - static_cast<void *>(frame), static_cast<void *>(sb_addr.get())); - return sb_addr; + return LLDB_RECORD_RESULT(sb_addr); } -void SBFrame::Clear() { m_opaque_sp->Clear(); } +void SBFrame::Clear() { + LLDB_RECORD_METHOD_NO_ARGS(void, SBFrame, Clear); + + m_opaque_sp->Clear(); +} lldb::SBValue SBFrame::GetValueForVariablePath(const char *var_path) { + LLDB_RECORD_METHOD(lldb::SBValue, SBFrame, GetValueForVariablePath, + (const char *), var_path); + SBValue sb_value; std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -577,18 +457,18 @@ lldb::SBValue SBFrame::GetValueForVariablePath(const char *var_path) { frame->CalculateTarget()->GetPreferDynamicValue(); sb_value = GetValueForVariablePath(var_path, use_dynamic); } - return sb_value; + return LLDB_RECORD_RESULT(sb_value); } lldb::SBValue SBFrame::GetValueForVariablePath(const char *var_path, DynamicValueType use_dynamic) { + LLDB_RECORD_METHOD(lldb::SBValue, SBFrame, GetValueForVariablePath, + (const char *, lldb::DynamicValueType), var_path, + use_dynamic); + SBValue sb_value; - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); if (var_path == nullptr || var_path[0] == '\0') { - if (log) - log->Printf( - "SBFrame::GetValueForVariablePath called with empty variable path."); - return sb_value; + return LLDB_RECORD_RESULT(sb_value); } std::unique_lock<std::recursive_mutex> lock; @@ -610,21 +490,16 @@ lldb::SBValue SBFrame::GetValueForVariablePath(const char *var_path, StackFrame::eExpressionPathOptionsAllowDirectIVarAccess, var_sp, error)); sb_value.SetSP(value_sp, use_dynamic); - } else { - if (log) - log->Printf("SBFrame::GetValueForVariablePath () => error: could not " - "reconstruct frame object for this SBFrame."); } - } else { - if (log) - log->Printf( - "SBFrame::GetValueForVariablePath () => error: process is running"); } } - return sb_value; + return LLDB_RECORD_RESULT(sb_value); } SBValue SBFrame::FindVariable(const char *name) { + LLDB_RECORD_METHOD(lldb::SBValue, SBFrame, FindVariable, (const char *), + name); + SBValue value; std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -636,19 +511,19 @@ SBValue SBFrame::FindVariable(const char *name) { frame->CalculateTarget()->GetPreferDynamicValue(); value = FindVariable(name, use_dynamic); } - return value; + return LLDB_RECORD_RESULT(value); } SBValue SBFrame::FindVariable(const char *name, lldb::DynamicValueType use_dynamic) { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(lldb::SBValue, SBFrame, FindVariable, + (const char *, lldb::DynamicValueType), name, use_dynamic); + VariableSP var_sp; SBValue sb_value; if (name == nullptr || name[0] == '\0') { - if (log) - log->Printf("SBFrame::FindVariable called with empty name"); - return sb_value; + return LLDB_RECORD_RESULT(sb_value); } ValueObjectSP value_sp; @@ -667,26 +542,17 @@ SBValue SBFrame::FindVariable(const char *name, if (value_sp) sb_value.SetSP(value_sp, use_dynamic); - } else { - if (log) - log->Printf("SBFrame::FindVariable () => error: could not " - "reconstruct frame object for this SBFrame."); } - } else { - if (log) - log->Printf("SBFrame::FindVariable () => error: process is running"); } } - if (log) - log->Printf("SBFrame(%p)::FindVariable (name=\"%s\") => SBValue(%p)", - static_cast<void *>(frame), name, - static_cast<void *>(value_sp.get())); - - return sb_value; + return LLDB_RECORD_RESULT(sb_value); } SBValue SBFrame::FindValue(const char *name, ValueType value_type) { + LLDB_RECORD_METHOD(lldb::SBValue, SBFrame, FindValue, + (const char *, lldb::ValueType), name, value_type); + SBValue value; std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -698,18 +564,19 @@ SBValue SBFrame::FindValue(const char *name, ValueType value_type) { frame->CalculateTarget()->GetPreferDynamicValue(); value = FindValue(name, value_type, use_dynamic); } - return value; + return LLDB_RECORD_RESULT(value); } SBValue SBFrame::FindValue(const char *name, ValueType value_type, lldb::DynamicValueType use_dynamic) { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(lldb::SBValue, SBFrame, FindValue, + (const char *, lldb::ValueType, lldb::DynamicValueType), + name, value_type, use_dynamic); + SBValue sb_value; if (name == nullptr || name[0] == '\0') { - if (log) - log->Printf("SBFrame::FindValue called with empty name."); - return sb_value; + return LLDB_RECORD_RESULT(sb_value); } ValueObjectSP value_sp; @@ -816,38 +683,38 @@ SBValue SBFrame::FindValue(const char *name, ValueType value_type, default: break; } - } else { - if (log) - log->Printf("SBFrame::FindValue () => error: could not reconstruct " - "frame object for this SBFrame."); } - } else { - if (log) - log->Printf("SBFrame::FindValue () => error: process is running"); } } - if (log) - log->Printf("SBFrame(%p)::FindVariableInScope (name=\"%s\", value_type=%i) " - "=> SBValue(%p)", - static_cast<void *>(frame), name, value_type, - static_cast<void *>(value_sp.get())); - - return sb_value; + return LLDB_RECORD_RESULT(sb_value); } bool SBFrame::IsEqual(const SBFrame &that) const { + LLDB_RECORD_METHOD_CONST(bool, SBFrame, IsEqual, (const lldb::SBFrame &), + that); + lldb::StackFrameSP this_sp = GetFrameSP(); lldb::StackFrameSP that_sp = that.GetFrameSP(); return (this_sp && that_sp && this_sp->GetStackID() == that_sp->GetStackID()); } -bool SBFrame::operator==(const SBFrame &rhs) const { return IsEqual(rhs); } +bool SBFrame::operator==(const SBFrame &rhs) const { + LLDB_RECORD_METHOD_CONST(bool, SBFrame, operator==,(const lldb::SBFrame &), + rhs); + + return IsEqual(rhs); +} + +bool SBFrame::operator!=(const SBFrame &rhs) const { + LLDB_RECORD_METHOD_CONST(bool, SBFrame, operator!=,(const lldb::SBFrame &), + rhs); -bool SBFrame::operator!=(const SBFrame &rhs) const { return !IsEqual(rhs); } + return !IsEqual(rhs); +} SBThread SBFrame::GetThread() const { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBThread, SBFrame, GetThread); std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -855,19 +722,12 @@ SBThread SBFrame::GetThread() const { ThreadSP thread_sp(exe_ctx.GetThreadSP()); SBThread sb_thread(thread_sp); - if (log) { - SBStream sstr; - sb_thread.GetDescription(sstr); - log->Printf("SBFrame(%p)::GetThread () => SBThread(%p): %s", - static_cast<void *>(exe_ctx.GetFramePtr()), - static_cast<void *>(thread_sp.get()), sstr.GetData()); - } - - return sb_thread; + return LLDB_RECORD_RESULT(sb_thread); } const char *SBFrame::Disassemble() const { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBFrame, Disassemble); + const char *disassembly = nullptr; std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -881,26 +741,19 @@ const char *SBFrame::Disassemble() const { frame = exe_ctx.GetFramePtr(); if (frame) { disassembly = frame->Disassemble(); - } else { - if (log) - log->Printf("SBFrame::Disassemble () => error: could not reconstruct " - "frame object for this SBFrame."); } - } else { - if (log) - log->Printf("SBFrame::Disassemble () => error: process is running"); } } - if (log) - log->Printf("SBFrame(%p)::Disassemble () => %s", static_cast<void *>(frame), - disassembly); - return disassembly; } SBValueList SBFrame::GetVariables(bool arguments, bool locals, bool statics, bool in_scope_only) { + LLDB_RECORD_METHOD(lldb::SBValueList, SBFrame, GetVariables, + (bool, bool, bool, bool), arguments, locals, statics, + in_scope_only); + SBValueList value_list; std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -923,12 +776,16 @@ SBValueList SBFrame::GetVariables(bool arguments, bool locals, bool statics, value_list = GetVariables(options); } - return value_list; + return LLDB_RECORD_RESULT(value_list); } lldb::SBValueList SBFrame::GetVariables(bool arguments, bool locals, bool statics, bool in_scope_only, lldb::DynamicValueType use_dynamic) { + LLDB_RECORD_METHOD(lldb::SBValueList, SBFrame, GetVariables, + (bool, bool, bool, bool, lldb::DynamicValueType), + arguments, locals, statics, in_scope_only, use_dynamic); + std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -942,11 +799,12 @@ lldb::SBValueList SBFrame::GetVariables(bool arguments, bool locals, options.SetInScopeOnly(in_scope_only); options.SetIncludeRuntimeSupportValues(include_runtime_support_values); options.SetUseDynamic(use_dynamic); - return GetVariables(options); + return LLDB_RECORD_RESULT(GetVariables(options)); } SBValueList SBFrame::GetVariables(const lldb::SBVariablesOptions &options) { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(lldb::SBValueList, SBFrame, GetVariables, + (const lldb::SBVariablesOptions &), options); SBValueList value_list; std::unique_lock<std::recursive_mutex> lock; @@ -965,12 +823,6 @@ SBValueList SBFrame::GetVariables(const lldb::SBVariablesOptions &options) { options.GetIncludeRuntimeSupportValues(); const lldb::DynamicValueType use_dynamic = options.GetUseDynamic(); - if (log) - log->Printf( - "SBFrame::GetVariables (arguments=%i, recognized_arguments=%i, " - "locals=%i, statics=%i, in_scope_only=%i runtime=%i dynamic=%i)", - arguments, recognized_arguments, locals, statics, in_scope_only, - include_runtime_support_values, use_dynamic); std::set<VariableSP> variable_set; Process *process = exe_ctx.GetProcessPtr(); @@ -1046,27 +898,15 @@ SBValueList SBFrame::GetVariables(const lldb::SBVariablesOptions &options) { } } } - } else { - if (log) - log->Printf("SBFrame::GetVariables () => error: could not " - "reconstruct frame object for this SBFrame."); } - } else { - if (log) - log->Printf("SBFrame::GetVariables () => error: process is running"); } } - if (log) - log->Printf("SBFrame(%p)::GetVariables (...) => SBValueList(%p)", - static_cast<void *>(frame), - static_cast<void *>(value_list.opaque_ptr())); - - return value_list; + return LLDB_RECORD_RESULT(value_list); } SBValueList SBFrame::GetRegisters() { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBValueList, SBFrame, GetRegisters); SBValueList value_list; std::unique_lock<std::recursive_mutex> lock; @@ -1088,27 +928,16 @@ SBValueList SBFrame::GetRegisters() { ValueObjectRegisterSet::Create(frame, reg_ctx, set_idx)); } } - } else { - if (log) - log->Printf("SBFrame::GetRegisters () => error: could not " - "reconstruct frame object for this SBFrame."); } - } else { - if (log) - log->Printf("SBFrame::GetRegisters () => error: process is running"); } } - if (log) - log->Printf("SBFrame(%p)::GetRegisters () => SBValueList(%p)", - static_cast<void *>(frame), - static_cast<void *>(value_list.opaque_ptr())); - - return value_list; + return LLDB_RECORD_RESULT(value_list); } SBValue SBFrame::FindRegister(const char *name) { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(lldb::SBValue, SBFrame, FindRegister, (const char *), + name); SBValue result; ValueObjectSP value_sp; @@ -1139,27 +968,17 @@ SBValue SBFrame::FindRegister(const char *name) { } } } - } else { - if (log) - log->Printf("SBFrame::FindRegister () => error: could not " - "reconstruct frame object for this SBFrame."); } - } else { - if (log) - log->Printf("SBFrame::FindRegister () => error: process is running"); } } - if (log) - log->Printf("SBFrame(%p)::FindRegister () => SBValue(%p)", - static_cast<void *>(frame), - static_cast<void *>(value_sp.get())); - - return result; + return LLDB_RECORD_RESULT(result); } bool SBFrame::GetDescription(SBStream &description) { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(bool, SBFrame, GetDescription, (lldb::SBStream &), + description); + Stream &strm = description.ref(); std::unique_lock<std::recursive_mutex> lock; @@ -1174,14 +993,7 @@ bool SBFrame::GetDescription(SBStream &description) { frame = exe_ctx.GetFramePtr(); if (frame) { frame->DumpUsingSettingsFormat(&strm); - } else { - if (log) - log->Printf("SBFrame::GetDescription () => error: could not " - "reconstruct frame object for this SBFrame."); } - } else { - if (log) - log->Printf("SBFrame::GetDescription () => error: process is running"); } } else @@ -1191,6 +1003,9 @@ bool SBFrame::GetDescription(SBStream &description) { } SBValue SBFrame::EvaluateExpression(const char *expr) { + LLDB_RECORD_METHOD(lldb::SBValue, SBFrame, EvaluateExpression, (const char *), + expr); + SBValue result; std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -1208,14 +1023,18 @@ SBValue SBFrame::EvaluateExpression(const char *expr) { options.SetLanguage(target->GetLanguage()); else options.SetLanguage(frame->GetLanguage()); - return EvaluateExpression(expr, options); + return LLDB_RECORD_RESULT(EvaluateExpression(expr, options)); } - return result; + return LLDB_RECORD_RESULT(result); } SBValue SBFrame::EvaluateExpression(const char *expr, lldb::DynamicValueType fetch_dynamic_value) { + LLDB_RECORD_METHOD(lldb::SBValue, SBFrame, EvaluateExpression, + (const char *, lldb::DynamicValueType), expr, + fetch_dynamic_value); + SBExpressionOptions options; options.SetFetchDynamicValue(fetch_dynamic_value); options.SetUnwindOnError(true); @@ -1229,12 +1048,16 @@ SBFrame::EvaluateExpression(const char *expr, options.SetLanguage(target->GetLanguage()); else if (frame) options.SetLanguage(frame->GetLanguage()); - return EvaluateExpression(expr, options); + return LLDB_RECORD_RESULT(EvaluateExpression(expr, options)); } SBValue SBFrame::EvaluateExpression(const char *expr, lldb::DynamicValueType fetch_dynamic_value, bool unwind_on_error) { + LLDB_RECORD_METHOD(lldb::SBValue, SBFrame, EvaluateExpression, + (const char *, lldb::DynamicValueType, bool), expr, + fetch_dynamic_value, unwind_on_error); + SBExpressionOptions options; std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -1248,25 +1071,21 @@ SBValue SBFrame::EvaluateExpression(const char *expr, options.SetLanguage(target->GetLanguage()); else if (frame) options.SetLanguage(frame->GetLanguage()); - return EvaluateExpression(expr, options); + return LLDB_RECORD_RESULT(EvaluateExpression(expr, options)); } lldb::SBValue SBFrame::EvaluateExpression(const char *expr, const SBExpressionOptions &options) { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(lldb::SBValue, SBFrame, EvaluateExpression, + (const char *, const lldb::SBExpressionOptions &), expr, + options); -#ifndef LLDB_DISABLE_PYTHON Log *expr_log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); -#endif - ExpressionResults exe_results = eExpressionSetupError; SBValue expr_result; if (expr == nullptr || expr[0] == '\0') { - if (log) - log->Printf( - "SBFrame::EvaluateExpression called with an empty expression"); - return expr_result; + return LLDB_RECORD_RESULT(expr_result); } ValueObjectSP expr_value_sp; @@ -1274,8 +1093,6 @@ lldb::SBValue SBFrame::EvaluateExpression(const char *expr, std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); - if (log) - log->Printf("SBFrame()::EvaluateExpression (expr=\"%s\")...", expr); StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); @@ -1297,43 +1114,29 @@ lldb::SBValue SBFrame::EvaluateExpression(const char *expr, frame_description.GetData()); } - exe_results = target->EvaluateExpression(expr, frame, expr_value_sp, - options.ref()); + target->EvaluateExpression(expr, frame, expr_value_sp, options.ref()); expr_result.SetSP(expr_value_sp, options.GetFetchDynamicValue()); - } else { - if (log) - log->Printf("SBFrame::EvaluateExpression () => error: could not " - "reconstruct frame object for this SBFrame."); } - } else { - if (log) - log->Printf( - "SBFrame::EvaluateExpression () => error: process is running"); } } -#ifndef LLDB_DISABLE_PYTHON if (expr_log) expr_log->Printf("** [SBFrame::EvaluateExpression] Expression result is " "%s, summary %s **", expr_result.GetValue(), expr_result.GetSummary()); - if (log) - log->Printf("SBFrame(%p)::EvaluateExpression (expr=\"%s\") => SBValue(%p) " - "(execution result=%d)", - static_cast<void *>(frame), expr, - static_cast<void *>(expr_value_sp.get()), exe_results); -#endif - - return expr_result; + return LLDB_RECORD_RESULT(expr_result); } bool SBFrame::IsInlined() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBFrame, IsInlined); + return static_cast<const SBFrame *>(this)->IsInlined(); } bool SBFrame::IsInlined() const { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBFrame, IsInlined); + std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -1349,24 +1152,21 @@ bool SBFrame::IsInlined() const { Block *block = frame->GetSymbolContext(eSymbolContextBlock).block; if (block) return block->GetContainingInlinedBlock() != nullptr; - } else { - if (log) - log->Printf("SBFrame::IsInlined () => error: could not reconstruct " - "frame object for this SBFrame."); } - } else { - if (log) - log->Printf("SBFrame::IsInlined () => error: process is running"); } } return false; } bool SBFrame::IsArtificial() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBFrame, IsArtificial); + return static_cast<const SBFrame *>(this)->IsArtificial(); } bool SBFrame::IsArtificial() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBFrame, IsArtificial); + std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -1378,13 +1178,17 @@ bool SBFrame::IsArtificial() const { } const char *SBFrame::GetFunctionName() { + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBFrame, GetFunctionName); + return static_cast<const SBFrame *>(this)->GetFunctionName(); } lldb::LanguageType SBFrame::GuessLanguage() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::LanguageType, SBFrame, GuessLanguage); + std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); - + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); @@ -1401,7 +1205,8 @@ lldb::LanguageType SBFrame::GuessLanguage() const { } const char *SBFrame::GetFunctionName() const { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBFrame, GetFunctionName); + const char *name = nullptr; std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -1436,21 +1241,15 @@ const char *SBFrame::GetFunctionName() const { if (sc.symbol) name = sc.symbol->GetName().GetCString(); } - } else { - if (log) - log->Printf("SBFrame::GetFunctionName () => error: could not " - "reconstruct frame object for this SBFrame."); } - } else { - if (log) - log->Printf("SBFrame::GetFunctionName() => error: process is running"); } } return name; } const char *SBFrame::GetDisplayFunctionName() { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBFrame, GetDisplayFunctionName); + const char *name = nullptr; std::unique_lock<std::recursive_mutex> lock; @@ -1486,16 +1285,87 @@ const char *SBFrame::GetDisplayFunctionName() { if (sc.symbol) name = sc.symbol->GetDisplayName().GetCString(); } - } else { - if (log) - log->Printf("SBFrame::GetDisplayFunctionName () => error: could not " - "reconstruct frame object for this SBFrame."); } - } else { - if (log) - log->Printf( - "SBFrame::GetDisplayFunctionName() => error: process is running"); } } return name; } + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBFrame>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBFrame, ()); + LLDB_REGISTER_CONSTRUCTOR(SBFrame, (const lldb::StackFrameSP &)); + LLDB_REGISTER_CONSTRUCTOR(SBFrame, (const lldb::SBFrame &)); + LLDB_REGISTER_METHOD(const lldb::SBFrame &, + SBFrame, operator=,(const lldb::SBFrame &)); + LLDB_REGISTER_METHOD_CONST(bool, SBFrame, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBFrame, operator bool, ()); + LLDB_REGISTER_METHOD_CONST(lldb::SBSymbolContext, SBFrame, GetSymbolContext, + (uint32_t)); + LLDB_REGISTER_METHOD_CONST(lldb::SBModule, SBFrame, GetModule, ()); + LLDB_REGISTER_METHOD_CONST(lldb::SBCompileUnit, SBFrame, GetCompileUnit, + ()); + LLDB_REGISTER_METHOD_CONST(lldb::SBFunction, SBFrame, GetFunction, ()); + LLDB_REGISTER_METHOD_CONST(lldb::SBSymbol, SBFrame, GetSymbol, ()); + LLDB_REGISTER_METHOD_CONST(lldb::SBBlock, SBFrame, GetBlock, ()); + LLDB_REGISTER_METHOD_CONST(lldb::SBBlock, SBFrame, GetFrameBlock, ()); + LLDB_REGISTER_METHOD_CONST(lldb::SBLineEntry, SBFrame, GetLineEntry, ()); + LLDB_REGISTER_METHOD_CONST(uint32_t, SBFrame, GetFrameID, ()); + LLDB_REGISTER_METHOD_CONST(lldb::addr_t, SBFrame, GetCFA, ()); + LLDB_REGISTER_METHOD_CONST(lldb::addr_t, SBFrame, GetPC, ()); + LLDB_REGISTER_METHOD(bool, SBFrame, SetPC, (lldb::addr_t)); + LLDB_REGISTER_METHOD_CONST(lldb::addr_t, SBFrame, GetSP, ()); + LLDB_REGISTER_METHOD_CONST(lldb::addr_t, SBFrame, GetFP, ()); + LLDB_REGISTER_METHOD_CONST(lldb::SBAddress, SBFrame, GetPCAddress, ()); + LLDB_REGISTER_METHOD(void, SBFrame, Clear, ()); + LLDB_REGISTER_METHOD(lldb::SBValue, SBFrame, GetValueForVariablePath, + (const char *)); + LLDB_REGISTER_METHOD(lldb::SBValue, SBFrame, GetValueForVariablePath, + (const char *, lldb::DynamicValueType)); + LLDB_REGISTER_METHOD(lldb::SBValue, SBFrame, FindVariable, (const char *)); + LLDB_REGISTER_METHOD(lldb::SBValue, SBFrame, FindVariable, + (const char *, lldb::DynamicValueType)); + LLDB_REGISTER_METHOD(lldb::SBValue, SBFrame, FindValue, + (const char *, lldb::ValueType)); + LLDB_REGISTER_METHOD( + lldb::SBValue, SBFrame, FindValue, + (const char *, lldb::ValueType, lldb::DynamicValueType)); + LLDB_REGISTER_METHOD_CONST(bool, SBFrame, IsEqual, (const lldb::SBFrame &)); + LLDB_REGISTER_METHOD_CONST(bool, + SBFrame, operator==,(const lldb::SBFrame &)); + LLDB_REGISTER_METHOD_CONST(bool, + SBFrame, operator!=,(const lldb::SBFrame &)); + LLDB_REGISTER_METHOD_CONST(lldb::SBThread, SBFrame, GetThread, ()); + LLDB_REGISTER_METHOD_CONST(const char *, SBFrame, Disassemble, ()); + LLDB_REGISTER_METHOD(lldb::SBValueList, SBFrame, GetVariables, + (bool, bool, bool, bool)); + LLDB_REGISTER_METHOD(lldb::SBValueList, SBFrame, GetVariables, + (bool, bool, bool, bool, lldb::DynamicValueType)); + LLDB_REGISTER_METHOD(lldb::SBValueList, SBFrame, GetVariables, + (const lldb::SBVariablesOptions &)); + LLDB_REGISTER_METHOD(lldb::SBValueList, SBFrame, GetRegisters, ()); + LLDB_REGISTER_METHOD(lldb::SBValue, SBFrame, FindRegister, (const char *)); + LLDB_REGISTER_METHOD(bool, SBFrame, GetDescription, (lldb::SBStream &)); + LLDB_REGISTER_METHOD(lldb::SBValue, SBFrame, EvaluateExpression, + (const char *)); + LLDB_REGISTER_METHOD(lldb::SBValue, SBFrame, EvaluateExpression, + (const char *, lldb::DynamicValueType)); + LLDB_REGISTER_METHOD(lldb::SBValue, SBFrame, EvaluateExpression, + (const char *, lldb::DynamicValueType, bool)); + LLDB_REGISTER_METHOD(lldb::SBValue, SBFrame, EvaluateExpression, + (const char *, const lldb::SBExpressionOptions &)); + LLDB_REGISTER_METHOD(bool, SBFrame, IsInlined, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBFrame, IsInlined, ()); + LLDB_REGISTER_METHOD(bool, SBFrame, IsArtificial, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBFrame, IsArtificial, ()); + LLDB_REGISTER_METHOD(const char *, SBFrame, GetFunctionName, ()); + LLDB_REGISTER_METHOD_CONST(lldb::LanguageType, SBFrame, GuessLanguage, ()); + LLDB_REGISTER_METHOD_CONST(const char *, SBFrame, GetFunctionName, ()); + LLDB_REGISTER_METHOD(const char *, SBFrame, GetDisplayFunctionName, ()); +} + +} +} diff --git a/source/API/SBFunction.cpp b/source/API/SBFunction.cpp index 6a24f64b43e4e..1770bede2f428 100644 --- a/source/API/SBFunction.cpp +++ b/source/API/SBFunction.cpp @@ -1,13 +1,13 @@ //===-- SBFunction.cpp ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBFunction.h" +#include "SBReproducerPrivate.h" #include "lldb/API/SBProcess.h" #include "lldb/API/SBStream.h" #include "lldb/Core/Disassembler.h" @@ -18,89 +18,90 @@ #include "lldb/Symbol/VariableList.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Target.h" -#include "lldb/Utility/Log.h" using namespace lldb; using namespace lldb_private; -SBFunction::SBFunction() : m_opaque_ptr(NULL) {} +SBFunction::SBFunction() : m_opaque_ptr(nullptr) { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBFunction); +} SBFunction::SBFunction(lldb_private::Function *lldb_object_ptr) : m_opaque_ptr(lldb_object_ptr) {} SBFunction::SBFunction(const lldb::SBFunction &rhs) - : m_opaque_ptr(rhs.m_opaque_ptr) {} + : m_opaque_ptr(rhs.m_opaque_ptr) { + LLDB_RECORD_CONSTRUCTOR(SBFunction, (const lldb::SBFunction &), rhs); +} const SBFunction &SBFunction::operator=(const SBFunction &rhs) { + LLDB_RECORD_METHOD(const lldb::SBFunction &, + SBFunction, operator=,(const lldb::SBFunction &), rhs); + m_opaque_ptr = rhs.m_opaque_ptr; - return *this; + return LLDB_RECORD_RESULT(*this); } -SBFunction::~SBFunction() { m_opaque_ptr = NULL; } +SBFunction::~SBFunction() { m_opaque_ptr = nullptr; } -bool SBFunction::IsValid() const { return m_opaque_ptr != NULL; } +bool SBFunction::IsValid() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBFunction, IsValid); + return this->operator bool(); +} +SBFunction::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBFunction, operator bool); + + return m_opaque_ptr != nullptr; +} const char *SBFunction::GetName() const { - const char *cstr = NULL; + LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBFunction, GetName); + + const char *cstr = nullptr; if (m_opaque_ptr) cstr = m_opaque_ptr->GetName().AsCString(); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) { - if (cstr) - log->Printf("SBFunction(%p)::GetName () => \"%s\"", - static_cast<void *>(m_opaque_ptr), cstr); - else - log->Printf("SBFunction(%p)::GetName () => NULL", - static_cast<void *>(m_opaque_ptr)); - } return cstr; } const char *SBFunction::GetDisplayName() const { - const char *cstr = NULL; + LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBFunction, GetDisplayName); + + const char *cstr = nullptr; if (m_opaque_ptr) cstr = m_opaque_ptr->GetMangled() .GetDisplayDemangledName(m_opaque_ptr->GetLanguage()) .AsCString(); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) { - if (cstr) - log->Printf("SBFunction(%p)::GetDisplayName () => \"%s\"", - static_cast<void *>(m_opaque_ptr), cstr); - else - log->Printf("SBFunction(%p)::GetDisplayName () => NULL", - static_cast<void *>(m_opaque_ptr)); - } return cstr; } const char *SBFunction::GetMangledName() const { - const char *cstr = NULL; + LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBFunction, GetMangledName); + + const char *cstr = nullptr; if (m_opaque_ptr) cstr = m_opaque_ptr->GetMangled().GetMangledName().AsCString(); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) { - if (cstr) - log->Printf("SBFunction(%p)::GetMangledName () => \"%s\"", - static_cast<void *>(m_opaque_ptr), cstr); - else - log->Printf("SBFunction(%p)::GetMangledName () => NULL", - static_cast<void *>(m_opaque_ptr)); - } return cstr; } bool SBFunction::operator==(const SBFunction &rhs) const { + LLDB_RECORD_METHOD_CONST( + bool, SBFunction, operator==,(const lldb::SBFunction &), rhs); + return m_opaque_ptr == rhs.m_opaque_ptr; } bool SBFunction::operator!=(const SBFunction &rhs) const { + LLDB_RECORD_METHOD_CONST( + bool, SBFunction, operator!=,(const lldb::SBFunction &), rhs); + return m_opaque_ptr != rhs.m_opaque_ptr; } bool SBFunction::GetDescription(SBStream &s) { + LLDB_RECORD_METHOD(bool, SBFunction, GetDescription, (lldb::SBStream &), s); + if (m_opaque_ptr) { s.Printf("SBFunction: id = 0x%8.8" PRIx64 ", name = %s", m_opaque_ptr->GetID(), m_opaque_ptr->GetName().AsCString()); @@ -114,11 +115,17 @@ bool SBFunction::GetDescription(SBStream &s) { } SBInstructionList SBFunction::GetInstructions(SBTarget target) { - return GetInstructions(target, NULL); + LLDB_RECORD_METHOD(lldb::SBInstructionList, SBFunction, GetInstructions, + (lldb::SBTarget), target); + + return LLDB_RECORD_RESULT(GetInstructions(target, nullptr)); } SBInstructionList SBFunction::GetInstructions(SBTarget target, const char *flavor) { + LLDB_RECORD_METHOD(lldb::SBInstructionList, SBFunction, GetInstructions, + (lldb::SBTarget, const char *), target, flavor); + SBInstructionList sb_instructions; if (m_opaque_ptr) { ExecutionContext exe_ctx; @@ -134,11 +141,11 @@ SBInstructionList SBFunction::GetInstructions(SBTarget target, if (module_sp) { const bool prefer_file_cache = false; sb_instructions.SetDisassembler(Disassembler::DisassembleRange( - module_sp->GetArchitecture(), NULL, flavor, exe_ctx, + module_sp->GetArchitecture(), nullptr, flavor, exe_ctx, m_opaque_ptr->GetAddressRange(), prefer_file_cache)); } } - return sb_instructions; + return LLDB_RECORD_RESULT(sb_instructions); } lldb_private::Function *SBFunction::get() { return m_opaque_ptr; } @@ -148,13 +155,17 @@ void SBFunction::reset(lldb_private::Function *lldb_object_ptr) { } SBAddress SBFunction::GetStartAddress() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBAddress, SBFunction, GetStartAddress); + SBAddress addr; if (m_opaque_ptr) addr.SetAddress(&m_opaque_ptr->GetAddressRange().GetBaseAddress()); - return addr; + return LLDB_RECORD_RESULT(addr); } SBAddress SBFunction::GetEndAddress() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBAddress, SBFunction, GetEndAddress); + SBAddress addr; if (m_opaque_ptr) { addr_t byte_size = m_opaque_ptr->GetAddressRange().GetByteSize(); @@ -163,10 +174,13 @@ SBAddress SBFunction::GetEndAddress() { addr->Slide(byte_size); } } - return addr; + return LLDB_RECORD_RESULT(addr); } const char *SBFunction::GetArgumentName(uint32_t arg_idx) { + LLDB_RECORD_METHOD(const char *, SBFunction, GetArgumentName, (uint32_t), + arg_idx); + if (m_opaque_ptr) { Block &block = m_opaque_ptr->GetBlock(true); VariableListSP variable_list_sp = block.GetBlockVariableList(true); @@ -183,29 +197,37 @@ const char *SBFunction::GetArgumentName(uint32_t arg_idx) { } uint32_t SBFunction::GetPrologueByteSize() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBFunction, GetPrologueByteSize); + if (m_opaque_ptr) return m_opaque_ptr->GetPrologueByteSize(); return 0; } SBType SBFunction::GetType() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBFunction, GetType); + SBType sb_type; if (m_opaque_ptr) { Type *function_type = m_opaque_ptr->GetType(); if (function_type) sb_type.ref().SetType(function_type->shared_from_this()); } - return sb_type; + return LLDB_RECORD_RESULT(sb_type); } SBBlock SBFunction::GetBlock() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBBlock, SBFunction, GetBlock); + SBBlock sb_block; if (m_opaque_ptr) sb_block.SetPtr(&m_opaque_ptr->GetBlock(true)); - return sb_block; + return LLDB_RECORD_RESULT(sb_block); } lldb::LanguageType SBFunction::GetLanguage() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::LanguageType, SBFunction, GetLanguage); + if (m_opaque_ptr) { if (m_opaque_ptr->GetCompileUnit()) return m_opaque_ptr->GetCompileUnit()->GetLanguage(); @@ -214,9 +236,47 @@ lldb::LanguageType SBFunction::GetLanguage() { } bool SBFunction::GetIsOptimized() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBFunction, GetIsOptimized); + if (m_opaque_ptr) { if (m_opaque_ptr->GetCompileUnit()) return m_opaque_ptr->GetCompileUnit()->GetIsOptimized(); } return false; } + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBFunction>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBFunction, ()); + LLDB_REGISTER_CONSTRUCTOR(SBFunction, (const lldb::SBFunction &)); + LLDB_REGISTER_METHOD(const lldb::SBFunction &, + SBFunction, operator=,(const lldb::SBFunction &)); + LLDB_REGISTER_METHOD_CONST(bool, SBFunction, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBFunction, operator bool, ()); + LLDB_REGISTER_METHOD_CONST(const char *, SBFunction, GetName, ()); + LLDB_REGISTER_METHOD_CONST(const char *, SBFunction, GetDisplayName, ()); + LLDB_REGISTER_METHOD_CONST(const char *, SBFunction, GetMangledName, ()); + LLDB_REGISTER_METHOD_CONST( + bool, SBFunction, operator==,(const lldb::SBFunction &)); + LLDB_REGISTER_METHOD_CONST( + bool, SBFunction, operator!=,(const lldb::SBFunction &)); + LLDB_REGISTER_METHOD(bool, SBFunction, GetDescription, (lldb::SBStream &)); + LLDB_REGISTER_METHOD(lldb::SBInstructionList, SBFunction, GetInstructions, + (lldb::SBTarget)); + LLDB_REGISTER_METHOD(lldb::SBInstructionList, SBFunction, GetInstructions, + (lldb::SBTarget, const char *)); + LLDB_REGISTER_METHOD(lldb::SBAddress, SBFunction, GetStartAddress, ()); + LLDB_REGISTER_METHOD(lldb::SBAddress, SBFunction, GetEndAddress, ()); + LLDB_REGISTER_METHOD(const char *, SBFunction, GetArgumentName, (uint32_t)); + LLDB_REGISTER_METHOD(uint32_t, SBFunction, GetPrologueByteSize, ()); + LLDB_REGISTER_METHOD(lldb::SBType, SBFunction, GetType, ()); + LLDB_REGISTER_METHOD(lldb::SBBlock, SBFunction, GetBlock, ()); + LLDB_REGISTER_METHOD(lldb::LanguageType, SBFunction, GetLanguage, ()); + LLDB_REGISTER_METHOD(bool, SBFunction, GetIsOptimized, ()); +} + +} +} diff --git a/source/API/SBHostOS.cpp b/source/API/SBHostOS.cpp index ac6ab40bda416..c3c92e68140d4 100644 --- a/source/API/SBHostOS.cpp +++ b/source/API/SBHostOS.cpp @@ -1,16 +1,12 @@ //===-- SBHostOS.cpp --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// -#ifndef LLDB_DISABLE_PYTHON -#include "Plugins/ScriptInterpreter/Python/lldb-python.h" -#endif - +#include "SBReproducerPrivate.h" #include "lldb/API/SBError.h" #include "lldb/API/SBHostOS.h" #include "lldb/Host/FileSystem.h" @@ -20,7 +16,6 @@ #include "lldb/Host/HostThread.h" #include "lldb/Host/ThreadLauncher.h" #include "lldb/Utility/FileSpec.h" -#include "lldb/Utility/Log.h" #include "Plugins/ExpressionParser/Clang/ClangHost.h" #ifndef LLDB_DISABLE_PYTHON @@ -34,16 +29,25 @@ using namespace lldb; using namespace lldb_private; SBFileSpec SBHostOS::GetProgramFileSpec() { + LLDB_RECORD_STATIC_METHOD_NO_ARGS(lldb::SBFileSpec, SBHostOS, + GetProgramFileSpec); + SBFileSpec sb_filespec; sb_filespec.SetFileSpec(HostInfo::GetProgramFileSpec()); - return sb_filespec; + return LLDB_RECORD_RESULT(sb_filespec); } SBFileSpec SBHostOS::GetLLDBPythonPath() { - return GetLLDBPath(ePathTypePythonDir); + LLDB_RECORD_STATIC_METHOD_NO_ARGS(lldb::SBFileSpec, SBHostOS, + GetLLDBPythonPath); + + return LLDB_RECORD_RESULT(GetLLDBPath(ePathTypePythonDir)); } SBFileSpec SBHostOS::GetLLDBPath(lldb::PathType path_type) { + LLDB_RECORD_STATIC_METHOD(lldb::SBFileSpec, SBHostOS, GetLLDBPath, + (lldb::PathType), path_type); + FileSpec fspec; switch (path_type) { case ePathTypeLLDBShlibDir: @@ -79,10 +83,13 @@ SBFileSpec SBHostOS::GetLLDBPath(lldb::PathType path_type) { SBFileSpec sb_fspec; sb_fspec.SetFileSpec(fspec); - return sb_fspec; + return LLDB_RECORD_RESULT(sb_fspec); } SBFileSpec SBHostOS::GetUserHomeDirectory() { + LLDB_RECORD_STATIC_METHOD_NO_ARGS(lldb::SBFileSpec, SBHostOS, + GetUserHomeDirectory); + SBFileSpec sb_fspec; llvm::SmallString<64> home_dir_path; @@ -91,32 +98,38 @@ SBFileSpec SBHostOS::GetUserHomeDirectory() { FileSystem::Instance().Resolve(homedir); sb_fspec.SetFileSpec(homedir); - return sb_fspec; + return LLDB_RECORD_RESULT(sb_fspec); } lldb::thread_t SBHostOS::ThreadCreate(const char *name, lldb::thread_func_t thread_function, void *thread_arg, SBError *error_ptr) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - - if (log) - log->Printf( - "SBHostOS::ThreadCreate (name=\"%s\", thread_function=%p, " - "thread_arg=%p, error_ptr=%p)", - name, - reinterpret_cast<void *>(reinterpret_cast<intptr_t>(thread_function)), - static_cast<void *>(thread_arg), static_cast<void *>(error_ptr)); - - // FIXME: You should log the return value? + LLDB_RECORD_DUMMY(lldb::thread_t, SBHostOS, ThreadCreate, + (lldb::thread_func_t, void *, SBError *), name, + thread_function, thread_arg, error_ptr); + llvm::Expected<HostThread> thread = + ThreadLauncher::LaunchThread(name, thread_function, thread_arg); + if (!thread) { + if (error_ptr) + error_ptr->SetError(Status(thread.takeError())); + else + llvm::consumeError(thread.takeError()); + return LLDB_INVALID_HOST_THREAD; + } - HostThread thread(ThreadLauncher::LaunchThread( - name, thread_function, thread_arg, error_ptr ? error_ptr->get() : NULL)); - return thread.Release(); + return thread->Release(); } -void SBHostOS::ThreadCreated(const char *name) {} +void SBHostOS::ThreadCreated(const char *name) { + LLDB_RECORD_STATIC_METHOD(void, SBHostOS, ThreadCreated, (const char *), + name); +} bool SBHostOS::ThreadCancel(lldb::thread_t thread, SBError *error_ptr) { + LLDB_RECORD_DUMMY(bool, SBHostOS, ThreadCancel, + (lldb::thread_t, lldb::SBError *), thread, + error_ptr); + Status error; HostThread host_thread(thread); error = host_thread.Cancel(); @@ -127,6 +140,10 @@ bool SBHostOS::ThreadCancel(lldb::thread_t thread, SBError *error_ptr) { } bool SBHostOS::ThreadDetach(lldb::thread_t thread, SBError *error_ptr) { + LLDB_RECORD_DUMMY(bool, SBHostOS, ThreadDetach, + (lldb::thread_t, lldb::SBError *), thread, + error_ptr); + Status error; #if defined(_WIN32) if (error_ptr) @@ -143,6 +160,11 @@ bool SBHostOS::ThreadDetach(lldb::thread_t thread, SBError *error_ptr) { bool SBHostOS::ThreadJoin(lldb::thread_t thread, lldb::thread_result_t *result, SBError *error_ptr) { + LLDB_RECORD_DUMMY( + bool, SBHostOS, ThreadJoin, + (lldb::thread_t, lldb::thread_result_t *, lldb::SBError *), thread, + result, error_ptr); + Status error; HostThread host_thread(thread); error = host_thread.Join(result); @@ -151,3 +173,22 @@ bool SBHostOS::ThreadJoin(lldb::thread_t thread, lldb::thread_result_t *result, host_thread.Release(); return error.Success(); } + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBHostOS>(Registry &R) { + LLDB_REGISTER_STATIC_METHOD(lldb::SBFileSpec, SBHostOS, GetProgramFileSpec, + ()); + LLDB_REGISTER_STATIC_METHOD(lldb::SBFileSpec, SBHostOS, GetLLDBPythonPath, + ()); + LLDB_REGISTER_STATIC_METHOD(lldb::SBFileSpec, SBHostOS, GetLLDBPath, + (lldb::PathType)); + LLDB_REGISTER_STATIC_METHOD(lldb::SBFileSpec, SBHostOS, + GetUserHomeDirectory, ()); + LLDB_REGISTER_STATIC_METHOD(void, SBHostOS, ThreadCreated, (const char *)); +} + +} +} diff --git a/source/API/SBInitializerOptions.cpp b/source/API/SBInitializerOptions.cpp deleted file mode 100644 index 8d8ec28190ec1..0000000000000 --- a/source/API/SBInitializerOptions.cpp +++ /dev/null @@ -1,49 +0,0 @@ -//===-- SBInitializerOptions.cpp --------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "lldb/API/SBInitializerOptions.h" -#include "lldb/Initialization/SystemInitializer.h" - -using namespace lldb; -using namespace lldb_private; - -SBInitializerOptions::SBInitializerOptions(const SBInitializerOptions &rhs) { - m_opaque_up.reset(new InitializerOptions()); - *(m_opaque_up.get()) = rhs.ref(); -} - -const SBInitializerOptions &SBInitializerOptions:: -operator=(const SBInitializerOptions &rhs) { - if (this != &rhs) { - this->ref() = rhs.ref(); - } - return *this; -} - -SBInitializerOptions::~SBInitializerOptions() {} - -SBInitializerOptions::SBInitializerOptions() { - m_opaque_up.reset(new InitializerOptions()); -} - -void SBInitializerOptions::SetCaptureReproducer(bool b) { - m_opaque_up->reproducer_capture = b; -} - -void SBInitializerOptions::SetReplayReproducer(bool b) { - m_opaque_up->reproducer_replay = b; -} - -void SBInitializerOptions::SetReproducerPath(const char *path) { - m_opaque_up->reproducer_path = path; -} - -InitializerOptions &SBInitializerOptions::ref() const { - return *(m_opaque_up.get()); -} diff --git a/source/API/SBInstruction.cpp b/source/API/SBInstruction.cpp index 462f082880920..fcf66fd258240 100644 --- a/source/API/SBInstruction.cpp +++ b/source/API/SBInstruction.cpp @@ -1,16 +1,17 @@ //===-- SBInstruction.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBInstruction.h" +#include "SBReproducerPrivate.h" #include "lldb/API/SBAddress.h" #include "lldb/API/SBFrame.h" + #include "lldb/API/SBInstruction.h" #include "lldb/API/SBStream.h" #include "lldb/API/SBTarget.h" @@ -26,7 +27,8 @@ #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" -//---------------------------------------------------------------------- +#include <memory> + // We recently fixed a leak in one of the Instruction subclasses where the // instruction will only hold a weak reference to the disassembler to avoid a // cycle that was keeping both objects alive (leak) and we need the @@ -45,7 +47,6 @@ // objects that are given out have a strong reference to the disassembler and // the instruction so that the object can live and successfully respond to all // queries. -//---------------------------------------------------------------------- class InstructionImpl { public: InstructionImpl(const lldb::DisassemblerSP &disasm_sp, @@ -64,34 +65,55 @@ protected: using namespace lldb; using namespace lldb_private; -SBInstruction::SBInstruction() : m_opaque_sp() {} +SBInstruction::SBInstruction() : m_opaque_sp() { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBInstruction); +} SBInstruction::SBInstruction(const lldb::DisassemblerSP &disasm_sp, const lldb::InstructionSP &inst_sp) : m_opaque_sp(new InstructionImpl(disasm_sp, inst_sp)) {} SBInstruction::SBInstruction(const SBInstruction &rhs) - : m_opaque_sp(rhs.m_opaque_sp) {} + : m_opaque_sp(rhs.m_opaque_sp) { + LLDB_RECORD_CONSTRUCTOR(SBInstruction, (const lldb::SBInstruction &), rhs); +} const SBInstruction &SBInstruction::operator=(const SBInstruction &rhs) { + LLDB_RECORD_METHOD(const lldb::SBInstruction &, + SBInstruction, operator=,(const lldb::SBInstruction &), + rhs); + if (this != &rhs) m_opaque_sp = rhs.m_opaque_sp; - return *this; + return LLDB_RECORD_RESULT(*this); } SBInstruction::~SBInstruction() {} -bool SBInstruction::IsValid() { return m_opaque_sp && m_opaque_sp->IsValid(); } +bool SBInstruction::IsValid() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBInstruction, IsValid); + return this->operator bool(); +} +SBInstruction::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBInstruction, operator bool); + + return m_opaque_sp && m_opaque_sp->IsValid(); +} SBAddress SBInstruction::GetAddress() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBAddress, SBInstruction, GetAddress); + SBAddress sb_addr; lldb::InstructionSP inst_sp(GetOpaque()); if (inst_sp && inst_sp->GetAddress().IsValid()) sb_addr.SetAddress(&inst_sp->GetAddress()); - return sb_addr; + return LLDB_RECORD_RESULT(sb_addr); } const char *SBInstruction::GetMnemonic(SBTarget target) { + LLDB_RECORD_METHOD(const char *, SBInstruction, GetMnemonic, (lldb::SBTarget), + target); + lldb::InstructionSP inst_sp(GetOpaque()); if (inst_sp) { ExecutionContext exe_ctx; @@ -105,10 +127,13 @@ const char *SBInstruction::GetMnemonic(SBTarget target) { } return inst_sp->GetMnemonic(&exe_ctx); } - return NULL; + return nullptr; } const char *SBInstruction::GetOperands(SBTarget target) { + LLDB_RECORD_METHOD(const char *, SBInstruction, GetOperands, (lldb::SBTarget), + target); + lldb::InstructionSP inst_sp(GetOpaque()); if (inst_sp) { ExecutionContext exe_ctx; @@ -122,10 +147,13 @@ const char *SBInstruction::GetOperands(SBTarget target) { } return inst_sp->GetOperands(&exe_ctx); } - return NULL; + return nullptr; } const char *SBInstruction::GetComment(SBTarget target) { + LLDB_RECORD_METHOD(const char *, SBInstruction, GetComment, (lldb::SBTarget), + target); + lldb::InstructionSP inst_sp(GetOpaque()); if (inst_sp) { ExecutionContext exe_ctx; @@ -139,10 +167,12 @@ const char *SBInstruction::GetComment(SBTarget target) { } return inst_sp->GetComment(&exe_ctx); } - return NULL; + return nullptr; } size_t SBInstruction::GetByteSize() { + LLDB_RECORD_METHOD_NO_ARGS(size_t, SBInstruction, GetByteSize); + lldb::InstructionSP inst_sp(GetOpaque()); if (inst_sp) return inst_sp->GetOpcode().GetByteSize(); @@ -150,6 +180,9 @@ size_t SBInstruction::GetByteSize() { } SBData SBInstruction::GetData(SBTarget target) { + LLDB_RECORD_METHOD(lldb::SBData, SBInstruction, GetData, (lldb::SBTarget), + target); + lldb::SBData sb_data; lldb::InstructionSP inst_sp(GetOpaque()); if (inst_sp) { @@ -158,10 +191,12 @@ SBData SBInstruction::GetData(SBTarget target) { sb_data.SetOpaque(data_extractor_sp); } } - return sb_data; + return LLDB_RECORD_RESULT(sb_data); } bool SBInstruction::DoesBranch() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBInstruction, DoesBranch); + lldb::InstructionSP inst_sp(GetOpaque()); if (inst_sp) return inst_sp->DoesBranch(); @@ -169,13 +204,17 @@ bool SBInstruction::DoesBranch() { } bool SBInstruction::HasDelaySlot() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBInstruction, HasDelaySlot); + lldb::InstructionSP inst_sp(GetOpaque()); if (inst_sp) return inst_sp->HasDelaySlot(); return false; } -bool SBInstruction::CanSetBreakpoint () { +bool SBInstruction::CanSetBreakpoint() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBInstruction, CanSetBreakpoint); + lldb::InstructionSP inst_sp(GetOpaque()); if (inst_sp) return inst_sp->CanSetBreakpoint(); @@ -191,10 +230,13 @@ lldb::InstructionSP SBInstruction::GetOpaque() { void SBInstruction::SetOpaque(const lldb::DisassemblerSP &disasm_sp, const lldb::InstructionSP &inst_sp) { - m_opaque_sp.reset(new InstructionImpl(disasm_sp, inst_sp)); + m_opaque_sp = std::make_shared<InstructionImpl>(disasm_sp, inst_sp); } bool SBInstruction::GetDescription(lldb::SBStream &s) { + LLDB_RECORD_METHOD(bool, SBInstruction, GetDescription, (lldb::SBStream &), + s); + lldb::InstructionSP inst_sp(GetOpaque()); if (inst_sp) { SymbolContext sc; @@ -207,14 +249,16 @@ bool SBInstruction::GetDescription(lldb::SBStream &s) { // didn't have a stream already created, one will get created... FormatEntity::Entry format; FormatEntity::Parse("${addr}: ", format); - inst_sp->Dump(&s.ref(), 0, true, false, NULL, &sc, NULL, &format, 0); + inst_sp->Dump(&s.ref(), 0, true, false, nullptr, &sc, nullptr, &format, 0); return true; } return false; } void SBInstruction::Print(FILE *out) { - if (out == NULL) + LLDB_RECORD_METHOD(void, SBInstruction, Print, (FILE *), out); + + if (out == nullptr) return; lldb::InstructionSP inst_sp(GetOpaque()); @@ -228,12 +272,16 @@ void SBInstruction::Print(FILE *out) { StreamFile out_stream(out, false); FormatEntity::Entry format; FormatEntity::Parse("${addr}: ", format); - inst_sp->Dump(&out_stream, 0, true, false, NULL, &sc, NULL, &format, 0); + inst_sp->Dump(&out_stream, 0, true, false, nullptr, &sc, nullptr, &format, + 0); } } bool SBInstruction::EmulateWithFrame(lldb::SBFrame &frame, uint32_t evaluate_options) { + LLDB_RECORD_METHOD(bool, SBInstruction, EmulateWithFrame, + (lldb::SBFrame &, uint32_t), frame, evaluate_options); + lldb::InstructionSP inst_sp(GetOpaque()); if (inst_sp) { lldb::StackFrameSP frame_sp(frame.GetFrameSP()); @@ -256,6 +304,9 @@ bool SBInstruction::EmulateWithFrame(lldb::SBFrame &frame, } bool SBInstruction::DumpEmulation(const char *triple) { + LLDB_RECORD_METHOD(bool, SBInstruction, DumpEmulation, (const char *), + triple); + lldb::InstructionSP inst_sp(GetOpaque()); if (inst_sp && triple) { return inst_sp->DumpEmulation(HostInfo::GetAugmentedArchSpec(triple)); @@ -265,6 +316,10 @@ bool SBInstruction::DumpEmulation(const char *triple) { bool SBInstruction::TestEmulation(lldb::SBStream &output_stream, const char *test_file) { + LLDB_RECORD_METHOD(bool, SBInstruction, TestEmulation, + (lldb::SBStream &, const char *), output_stream, + test_file); + if (!m_opaque_sp) SetOpaque(lldb::DisassemblerSP(), lldb::InstructionSP(new PseudoInstruction())); @@ -274,3 +329,41 @@ bool SBInstruction::TestEmulation(lldb::SBStream &output_stream, return inst_sp->TestEmulation(output_stream.get(), test_file); return false; } + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBInstruction>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBInstruction, ()); + LLDB_REGISTER_CONSTRUCTOR(SBInstruction, (const lldb::SBInstruction &)); + LLDB_REGISTER_METHOD( + const lldb::SBInstruction &, + SBInstruction, operator=,(const lldb::SBInstruction &)); + LLDB_REGISTER_METHOD(bool, SBInstruction, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBInstruction, operator bool, ()); + LLDB_REGISTER_METHOD(lldb::SBAddress, SBInstruction, GetAddress, ()); + LLDB_REGISTER_METHOD(const char *, SBInstruction, GetMnemonic, + (lldb::SBTarget)); + LLDB_REGISTER_METHOD(const char *, SBInstruction, GetOperands, + (lldb::SBTarget)); + LLDB_REGISTER_METHOD(const char *, SBInstruction, GetComment, + (lldb::SBTarget)); + LLDB_REGISTER_METHOD(size_t, SBInstruction, GetByteSize, ()); + LLDB_REGISTER_METHOD(lldb::SBData, SBInstruction, GetData, + (lldb::SBTarget)); + LLDB_REGISTER_METHOD(bool, SBInstruction, DoesBranch, ()); + LLDB_REGISTER_METHOD(bool, SBInstruction, HasDelaySlot, ()); + LLDB_REGISTER_METHOD(bool, SBInstruction, CanSetBreakpoint, ()); + LLDB_REGISTER_METHOD(bool, SBInstruction, GetDescription, + (lldb::SBStream &)); + LLDB_REGISTER_METHOD(void, SBInstruction, Print, (FILE *)); + LLDB_REGISTER_METHOD(bool, SBInstruction, EmulateWithFrame, + (lldb::SBFrame &, uint32_t)); + LLDB_REGISTER_METHOD(bool, SBInstruction, DumpEmulation, (const char *)); + LLDB_REGISTER_METHOD(bool, SBInstruction, TestEmulation, + (lldb::SBStream &, const char *)); +} + +} +} diff --git a/source/API/SBInstructionList.cpp b/source/API/SBInstructionList.cpp index 29e0c96075fd0..cce923bf04a4b 100644 --- a/source/API/SBInstructionList.cpp +++ b/source/API/SBInstructionList.cpp @@ -1,15 +1,15 @@ //===-- SBInstructionList.cpp -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBInstructionList.h" -#include "lldb/API/SBInstruction.h" +#include "SBReproducerPrivate.h" #include "lldb/API/SBAddress.h" +#include "lldb/API/SBInstruction.h" #include "lldb/API/SBStream.h" #include "lldb/Core/Disassembler.h" #include "lldb/Core/Module.h" @@ -19,40 +19,66 @@ using namespace lldb; using namespace lldb_private; -SBInstructionList::SBInstructionList() : m_opaque_sp() {} +SBInstructionList::SBInstructionList() : m_opaque_sp() { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBInstructionList); +} SBInstructionList::SBInstructionList(const SBInstructionList &rhs) - : m_opaque_sp(rhs.m_opaque_sp) {} + : m_opaque_sp(rhs.m_opaque_sp) { + LLDB_RECORD_CONSTRUCTOR(SBInstructionList, (const lldb::SBInstructionList &), + rhs); +} const SBInstructionList &SBInstructionList:: operator=(const SBInstructionList &rhs) { + LLDB_RECORD_METHOD( + const lldb::SBInstructionList &, + SBInstructionList, operator=,(const lldb::SBInstructionList &), rhs); + if (this != &rhs) m_opaque_sp = rhs.m_opaque_sp; - return *this; + return LLDB_RECORD_RESULT(*this); } SBInstructionList::~SBInstructionList() {} -bool SBInstructionList::IsValid() const { return m_opaque_sp.get() != NULL; } +bool SBInstructionList::IsValid() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBInstructionList, IsValid); + return this->operator bool(); +} +SBInstructionList::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBInstructionList, operator bool); + + return m_opaque_sp.get() != nullptr; +} size_t SBInstructionList::GetSize() { + LLDB_RECORD_METHOD_NO_ARGS(size_t, SBInstructionList, GetSize); + if (m_opaque_sp) return m_opaque_sp->GetInstructionList().GetSize(); return 0; } SBInstruction SBInstructionList::GetInstructionAtIndex(uint32_t idx) { + LLDB_RECORD_METHOD(lldb::SBInstruction, SBInstructionList, + GetInstructionAtIndex, (uint32_t), idx); + SBInstruction inst; if (m_opaque_sp && idx < m_opaque_sp->GetInstructionList().GetSize()) inst.SetOpaque( m_opaque_sp, m_opaque_sp->GetInstructionList().GetInstructionAtIndex(idx)); - return inst; + return LLDB_RECORD_RESULT(inst); } size_t SBInstructionList::GetInstructionsCount(const SBAddress &start, - const SBAddress &end, - bool canSetBreakpoint) { + const SBAddress &end, + bool canSetBreakpoint) { + LLDB_RECORD_METHOD(size_t, SBInstructionList, GetInstructionsCount, + (const lldb::SBAddress &, const lldb::SBAddress &, bool), + start, end, canSetBreakpoint); + size_t num_instructions = GetSize(); size_t i = 0; SBAddress addr; @@ -75,20 +101,32 @@ size_t SBInstructionList::GetInstructionsCount(const SBAddress &start, return upper_index - lower_index - instructions_to_skip; } -void SBInstructionList::Clear() { m_opaque_sp.reset(); } +void SBInstructionList::Clear() { + LLDB_RECORD_METHOD_NO_ARGS(void, SBInstructionList, Clear); -void SBInstructionList::AppendInstruction(SBInstruction insn) {} + m_opaque_sp.reset(); +} + +void SBInstructionList::AppendInstruction(SBInstruction insn) { + LLDB_RECORD_METHOD(void, SBInstructionList, AppendInstruction, + (lldb::SBInstruction), insn); +} void SBInstructionList::SetDisassembler(const lldb::DisassemblerSP &opaque_sp) { m_opaque_sp = opaque_sp; } void SBInstructionList::Print(FILE *out) { - if (out == NULL) + LLDB_RECORD_METHOD(void, SBInstructionList, Print, (FILE *), out); + + if (out == nullptr) return; } bool SBInstructionList::GetDescription(lldb::SBStream &description) { + LLDB_RECORD_METHOD(bool, SBInstructionList, GetDescription, + (lldb::SBStream &), description); + if (m_opaque_sp) { size_t num_instructions = GetSize(); if (num_instructions) { @@ -104,7 +142,7 @@ bool SBInstructionList::GetDescription(lldb::SBStream &description) { for (size_t i = 0; i < num_instructions; ++i) { Instruction *inst = m_opaque_sp->GetInstructionList().GetInstructionAtIndex(i).get(); - if (inst == NULL) + if (inst == nullptr) break; const Address &addr = inst->GetAddress(); @@ -115,7 +153,7 @@ bool SBInstructionList::GetDescription(lldb::SBStream &description) { addr, eSymbolContextEverything, sc); } - inst->Dump(&sref, max_opcode_byte_size, true, false, NULL, &sc, + inst->Dump(&sref, max_opcode_byte_size, true, false, nullptr, &sc, &prev_sc, &format, 0); sref.EOL(); } @@ -126,6 +164,9 @@ bool SBInstructionList::GetDescription(lldb::SBStream &description) { } bool SBInstructionList::DumpEmulationForAllInstructions(const char *triple) { + LLDB_RECORD_METHOD(bool, SBInstructionList, DumpEmulationForAllInstructions, + (const char *), triple); + if (m_opaque_sp) { size_t len = GetSize(); for (size_t i = 0; i < len; ++i) { @@ -135,3 +176,35 @@ bool SBInstructionList::DumpEmulationForAllInstructions(const char *triple) { } return true; } + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBInstructionList>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBInstructionList, ()); + LLDB_REGISTER_CONSTRUCTOR(SBInstructionList, + (const lldb::SBInstructionList &)); + LLDB_REGISTER_METHOD( + const lldb::SBInstructionList &, + SBInstructionList, operator=,(const lldb::SBInstructionList &)); + LLDB_REGISTER_METHOD_CONST(bool, SBInstructionList, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBInstructionList, operator bool, ()); + LLDB_REGISTER_METHOD(size_t, SBInstructionList, GetSize, ()); + LLDB_REGISTER_METHOD(lldb::SBInstruction, SBInstructionList, + GetInstructionAtIndex, (uint32_t)); + LLDB_REGISTER_METHOD( + size_t, SBInstructionList, GetInstructionsCount, + (const lldb::SBAddress &, const lldb::SBAddress &, bool)); + LLDB_REGISTER_METHOD(void, SBInstructionList, Clear, ()); + LLDB_REGISTER_METHOD(void, SBInstructionList, AppendInstruction, + (lldb::SBInstruction)); + LLDB_REGISTER_METHOD(void, SBInstructionList, Print, (FILE *)); + LLDB_REGISTER_METHOD(bool, SBInstructionList, GetDescription, + (lldb::SBStream &)); + LLDB_REGISTER_METHOD(bool, SBInstructionList, + DumpEmulationForAllInstructions, (const char *)); +} + +} +} diff --git a/source/API/SBLanguageRuntime.cpp b/source/API/SBLanguageRuntime.cpp index d3b7514346aab..04bd08fb739e0 100644 --- a/source/API/SBLanguageRuntime.cpp +++ b/source/API/SBLanguageRuntime.cpp @@ -1,13 +1,13 @@ //===-- SBLanguageRuntime.cpp -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBLanguageRuntime.h" +#include "SBReproducerPrivate.h" #include "lldb/Target/Language.h" using namespace lldb; @@ -15,11 +15,32 @@ using namespace lldb_private; lldb::LanguageType SBLanguageRuntime::GetLanguageTypeFromString(const char *string) { + LLDB_RECORD_STATIC_METHOD(lldb::LanguageType, SBLanguageRuntime, + GetLanguageTypeFromString, (const char *), string); + return Language::GetLanguageTypeFromString( llvm::StringRef::withNullAsEmpty(string)); } const char * SBLanguageRuntime::GetNameForLanguageType(lldb::LanguageType language) { + LLDB_RECORD_STATIC_METHOD(const char *, SBLanguageRuntime, + GetNameForLanguageType, (lldb::LanguageType), + language); + return Language::GetNameForLanguageType(language); } + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBLanguageRuntime>(Registry &R) { + LLDB_REGISTER_STATIC_METHOD(lldb::LanguageType, SBLanguageRuntime, + GetLanguageTypeFromString, (const char *)); + LLDB_REGISTER_STATIC_METHOD(const char *, SBLanguageRuntime, + GetNameForLanguageType, (lldb::LanguageType)); +} + +} +} diff --git a/source/API/SBLaunchInfo.cpp b/source/API/SBLaunchInfo.cpp index b1bbfa55d5c18..5c5e69704c7cf 100644 --- a/source/API/SBLaunchInfo.cpp +++ b/source/API/SBLaunchInfo.cpp @@ -1,17 +1,17 @@ //===-- SBLaunchInfo.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBLaunchInfo.h" +#include "SBReproducerPrivate.h" #include "lldb/API/SBFileSpec.h" #include "lldb/API/SBListener.h" -#include "lldb/Target/ProcessLaunchInfo.h" +#include "lldb/Host/ProcessLaunchInfo.h" using namespace lldb; using namespace lldb_private; @@ -36,6 +36,8 @@ private: SBLaunchInfo::SBLaunchInfo(const char **argv) : m_opaque_sp(new SBLaunchInfoImpl()) { + LLDB_RECORD_CONSTRUCTOR(SBLaunchInfo, (const char **), argv); + m_opaque_sp->GetFlags().Reset(eLaunchFlagDebug | eLaunchFlagDisableASLR); if (argv && argv[0]) m_opaque_sp->GetArguments().SetArguments(argv); @@ -51,46 +53,92 @@ void SBLaunchInfo::set_ref(const ProcessLaunchInfo &info) { *m_opaque_sp = info; } -lldb::pid_t SBLaunchInfo::GetProcessID() { return m_opaque_sp->GetProcessID(); } +lldb::pid_t SBLaunchInfo::GetProcessID() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::pid_t, SBLaunchInfo, GetProcessID); + + return m_opaque_sp->GetProcessID(); +} + +uint32_t SBLaunchInfo::GetUserID() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBLaunchInfo, GetUserID); + + return m_opaque_sp->GetUserID(); +} + +uint32_t SBLaunchInfo::GetGroupID() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBLaunchInfo, GetGroupID); -uint32_t SBLaunchInfo::GetUserID() { return m_opaque_sp->GetUserID(); } + return m_opaque_sp->GetGroupID(); +} -uint32_t SBLaunchInfo::GetGroupID() { return m_opaque_sp->GetGroupID(); } +bool SBLaunchInfo::UserIDIsValid() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBLaunchInfo, UserIDIsValid); -bool SBLaunchInfo::UserIDIsValid() { return m_opaque_sp->UserIDIsValid(); } + return m_opaque_sp->UserIDIsValid(); +} -bool SBLaunchInfo::GroupIDIsValid() { return m_opaque_sp->GroupIDIsValid(); } +bool SBLaunchInfo::GroupIDIsValid() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBLaunchInfo, GroupIDIsValid); -void SBLaunchInfo::SetUserID(uint32_t uid) { m_opaque_sp->SetUserID(uid); } + return m_opaque_sp->GroupIDIsValid(); +} + +void SBLaunchInfo::SetUserID(uint32_t uid) { + LLDB_RECORD_METHOD(void, SBLaunchInfo, SetUserID, (uint32_t), uid); + + m_opaque_sp->SetUserID(uid); +} -void SBLaunchInfo::SetGroupID(uint32_t gid) { m_opaque_sp->SetGroupID(gid); } +void SBLaunchInfo::SetGroupID(uint32_t gid) { + LLDB_RECORD_METHOD(void, SBLaunchInfo, SetGroupID, (uint32_t), gid); + + m_opaque_sp->SetGroupID(gid); +} SBFileSpec SBLaunchInfo::GetExecutableFile() { - return SBFileSpec(m_opaque_sp->GetExecutableFile()); + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFileSpec, SBLaunchInfo, GetExecutableFile); + + return LLDB_RECORD_RESULT(SBFileSpec(m_opaque_sp->GetExecutableFile())); } void SBLaunchInfo::SetExecutableFile(SBFileSpec exe_file, bool add_as_first_arg) { + LLDB_RECORD_METHOD(void, SBLaunchInfo, SetExecutableFile, + (lldb::SBFileSpec, bool), exe_file, add_as_first_arg); + m_opaque_sp->SetExecutableFile(exe_file.ref(), add_as_first_arg); } SBListener SBLaunchInfo::GetListener() { - return SBListener(m_opaque_sp->GetListener()); + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBListener, SBLaunchInfo, GetListener); + + return LLDB_RECORD_RESULT(SBListener(m_opaque_sp->GetListener())); } void SBLaunchInfo::SetListener(SBListener &listener) { + LLDB_RECORD_METHOD(void, SBLaunchInfo, SetListener, (lldb::SBListener &), + listener); + m_opaque_sp->SetListener(listener.GetSP()); } uint32_t SBLaunchInfo::GetNumArguments() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBLaunchInfo, GetNumArguments); + return m_opaque_sp->GetArguments().GetArgumentCount(); } const char *SBLaunchInfo::GetArgumentAtIndex(uint32_t idx) { + LLDB_RECORD_METHOD(const char *, SBLaunchInfo, GetArgumentAtIndex, (uint32_t), + idx); + return m_opaque_sp->GetArguments().GetArgumentAtIndex(idx); } void SBLaunchInfo::SetArguments(const char **argv, bool append) { + LLDB_RECORD_METHOD(void, SBLaunchInfo, SetArguments, (const char **, bool), + argv, append); + if (append) { if (argv) m_opaque_sp->GetArguments().AppendArguments(argv); @@ -103,16 +151,24 @@ void SBLaunchInfo::SetArguments(const char **argv, bool append) { } uint32_t SBLaunchInfo::GetNumEnvironmentEntries() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBLaunchInfo, GetNumEnvironmentEntries); + return m_opaque_sp->GetEnvironment().size(); } const char *SBLaunchInfo::GetEnvironmentEntryAtIndex(uint32_t idx) { + LLDB_RECORD_METHOD(const char *, SBLaunchInfo, GetEnvironmentEntryAtIndex, + (uint32_t), idx); + if (idx > GetNumEnvironmentEntries()) return nullptr; return m_opaque_sp->GetEnvp()[idx]; } void SBLaunchInfo::SetEnvironmentEntries(const char **envp, bool append) { + LLDB_RECORD_METHOD(void, SBLaunchInfo, SetEnvironmentEntries, + (const char **, bool), envp, append); + Environment env(envp); if (append) m_opaque_sp->GetEnvironment().insert(env.begin(), env.end()); @@ -121,33 +177,54 @@ void SBLaunchInfo::SetEnvironmentEntries(const char **envp, bool append) { m_opaque_sp->RegenerateEnvp(); } -void SBLaunchInfo::Clear() { m_opaque_sp->Clear(); } +void SBLaunchInfo::Clear() { + LLDB_RECORD_METHOD_NO_ARGS(void, SBLaunchInfo, Clear); + + m_opaque_sp->Clear(); +} const char *SBLaunchInfo::GetWorkingDirectory() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBLaunchInfo, + GetWorkingDirectory); + return m_opaque_sp->GetWorkingDirectory().GetCString(); } void SBLaunchInfo::SetWorkingDirectory(const char *working_dir) { + LLDB_RECORD_METHOD(void, SBLaunchInfo, SetWorkingDirectory, (const char *), + working_dir); + m_opaque_sp->SetWorkingDirectory(FileSpec(working_dir)); } uint32_t SBLaunchInfo::GetLaunchFlags() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBLaunchInfo, GetLaunchFlags); + return m_opaque_sp->GetFlags().Get(); } void SBLaunchInfo::SetLaunchFlags(uint32_t flags) { + LLDB_RECORD_METHOD(void, SBLaunchInfo, SetLaunchFlags, (uint32_t), flags); + m_opaque_sp->GetFlags().Reset(flags); } const char *SBLaunchInfo::GetProcessPluginName() { + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBLaunchInfo, GetProcessPluginName); + return m_opaque_sp->GetProcessPluginName(); } void SBLaunchInfo::SetProcessPluginName(const char *plugin_name) { + LLDB_RECORD_METHOD(void, SBLaunchInfo, SetProcessPluginName, (const char *), + plugin_name); + return m_opaque_sp->SetProcessPluginName(plugin_name); } const char *SBLaunchInfo::GetShell() { + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBLaunchInfo, GetShell); + // Constify this string so that it is saved in the string pool. Otherwise it // would be freed when this function goes out of scope. ConstString shell(m_opaque_sp->GetShell().GetPath().c_str()); @@ -155,54 +232,148 @@ const char *SBLaunchInfo::GetShell() { } void SBLaunchInfo::SetShell(const char *path) { + LLDB_RECORD_METHOD(void, SBLaunchInfo, SetShell, (const char *), path); + m_opaque_sp->SetShell(FileSpec(path)); } bool SBLaunchInfo::GetShellExpandArguments() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBLaunchInfo, GetShellExpandArguments); + return m_opaque_sp->GetShellExpandArguments(); } void SBLaunchInfo::SetShellExpandArguments(bool expand) { + LLDB_RECORD_METHOD(void, SBLaunchInfo, SetShellExpandArguments, (bool), + expand); + m_opaque_sp->SetShellExpandArguments(expand); } uint32_t SBLaunchInfo::GetResumeCount() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBLaunchInfo, GetResumeCount); + return m_opaque_sp->GetResumeCount(); } void SBLaunchInfo::SetResumeCount(uint32_t c) { + LLDB_RECORD_METHOD(void, SBLaunchInfo, SetResumeCount, (uint32_t), c); + m_opaque_sp->SetResumeCount(c); } bool SBLaunchInfo::AddCloseFileAction(int fd) { + LLDB_RECORD_METHOD(bool, SBLaunchInfo, AddCloseFileAction, (int), fd); + return m_opaque_sp->AppendCloseFileAction(fd); } bool SBLaunchInfo::AddDuplicateFileAction(int fd, int dup_fd) { + LLDB_RECORD_METHOD(bool, SBLaunchInfo, AddDuplicateFileAction, (int, int), fd, + dup_fd); + return m_opaque_sp->AppendDuplicateFileAction(fd, dup_fd); } bool SBLaunchInfo::AddOpenFileAction(int fd, const char *path, bool read, bool write) { + LLDB_RECORD_METHOD(bool, SBLaunchInfo, AddOpenFileAction, + (int, const char *, bool, bool), fd, path, read, write); + return m_opaque_sp->AppendOpenFileAction(fd, FileSpec(path), read, write); } bool SBLaunchInfo::AddSuppressFileAction(int fd, bool read, bool write) { + LLDB_RECORD_METHOD(bool, SBLaunchInfo, AddSuppressFileAction, + (int, bool, bool), fd, read, write); + return m_opaque_sp->AppendSuppressFileAction(fd, read, write); } void SBLaunchInfo::SetLaunchEventData(const char *data) { + LLDB_RECORD_METHOD(void, SBLaunchInfo, SetLaunchEventData, (const char *), + data); + m_opaque_sp->SetLaunchEventData(data); } const char *SBLaunchInfo::GetLaunchEventData() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBLaunchInfo, + GetLaunchEventData); + return m_opaque_sp->GetLaunchEventData(); } void SBLaunchInfo::SetDetachOnError(bool enable) { + LLDB_RECORD_METHOD(void, SBLaunchInfo, SetDetachOnError, (bool), enable); + m_opaque_sp->SetDetachOnError(enable); } bool SBLaunchInfo::GetDetachOnError() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBLaunchInfo, GetDetachOnError); + return m_opaque_sp->GetDetachOnError(); } + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBLaunchInfo>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBLaunchInfo, (const char **)); + LLDB_REGISTER_METHOD(lldb::pid_t, SBLaunchInfo, GetProcessID, ()); + LLDB_REGISTER_METHOD(uint32_t, SBLaunchInfo, GetUserID, ()); + LLDB_REGISTER_METHOD(uint32_t, SBLaunchInfo, GetGroupID, ()); + LLDB_REGISTER_METHOD(bool, SBLaunchInfo, UserIDIsValid, ()); + LLDB_REGISTER_METHOD(bool, SBLaunchInfo, GroupIDIsValid, ()); + LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetUserID, (uint32_t)); + LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetGroupID, (uint32_t)); + LLDB_REGISTER_METHOD(lldb::SBFileSpec, SBLaunchInfo, GetExecutableFile, ()); + LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetExecutableFile, + (lldb::SBFileSpec, bool)); + LLDB_REGISTER_METHOD(lldb::SBListener, SBLaunchInfo, GetListener, ()); + LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetListener, (lldb::SBListener &)); + LLDB_REGISTER_METHOD(uint32_t, SBLaunchInfo, GetNumArguments, ()); + LLDB_REGISTER_METHOD(const char *, SBLaunchInfo, GetArgumentAtIndex, + (uint32_t)); + LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetArguments, + (const char **, bool)); + LLDB_REGISTER_METHOD(uint32_t, SBLaunchInfo, GetNumEnvironmentEntries, ()); + LLDB_REGISTER_METHOD(const char *, SBLaunchInfo, GetEnvironmentEntryAtIndex, + (uint32_t)); + LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetEnvironmentEntries, + (const char **, bool)); + LLDB_REGISTER_METHOD(void, SBLaunchInfo, Clear, ()); + LLDB_REGISTER_METHOD_CONST(const char *, SBLaunchInfo, GetWorkingDirectory, + ()); + LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetWorkingDirectory, + (const char *)); + LLDB_REGISTER_METHOD(uint32_t, SBLaunchInfo, GetLaunchFlags, ()); + LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetLaunchFlags, (uint32_t)); + LLDB_REGISTER_METHOD(const char *, SBLaunchInfo, GetProcessPluginName, ()); + LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetProcessPluginName, + (const char *)); + LLDB_REGISTER_METHOD(const char *, SBLaunchInfo, GetShell, ()); + LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetShell, (const char *)); + LLDB_REGISTER_METHOD(bool, SBLaunchInfo, GetShellExpandArguments, ()); + LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetShellExpandArguments, (bool)); + LLDB_REGISTER_METHOD(uint32_t, SBLaunchInfo, GetResumeCount, ()); + LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetResumeCount, (uint32_t)); + LLDB_REGISTER_METHOD(bool, SBLaunchInfo, AddCloseFileAction, (int)); + LLDB_REGISTER_METHOD(bool, SBLaunchInfo, AddDuplicateFileAction, + (int, int)); + LLDB_REGISTER_METHOD(bool, SBLaunchInfo, AddOpenFileAction, + (int, const char *, bool, bool)); + LLDB_REGISTER_METHOD(bool, SBLaunchInfo, AddSuppressFileAction, + (int, bool, bool)); + LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetLaunchEventData, + (const char *)); + LLDB_REGISTER_METHOD_CONST(const char *, SBLaunchInfo, GetLaunchEventData, + ()); + LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetDetachOnError, (bool)); + LLDB_REGISTER_METHOD_CONST(bool, SBLaunchInfo, GetDetachOnError, ()); +} + +} +} diff --git a/source/API/SBLineEntry.cpp b/source/API/SBLineEntry.cpp index 6f59fe3407e8a..010a6057cd310 100644 --- a/source/API/SBLineEntry.cpp +++ b/source/API/SBLineEntry.cpp @@ -1,148 +1,142 @@ //===-- SBLineEntry.cpp -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// -#include <limits.h> - #include "lldb/API/SBLineEntry.h" +#include "SBReproducerPrivate.h" +#include "Utils.h" #include "lldb/API/SBStream.h" #include "lldb/Host/PosixApi.h" #include "lldb/Symbol/LineEntry.h" -#include "lldb/Utility/Log.h" #include "lldb/Utility/StreamString.h" +#include <limits.h> + using namespace lldb; using namespace lldb_private; -SBLineEntry::SBLineEntry() : m_opaque_ap() {} +SBLineEntry::SBLineEntry() : m_opaque_up() { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBLineEntry); +} + +SBLineEntry::SBLineEntry(const SBLineEntry &rhs) : m_opaque_up() { + LLDB_RECORD_CONSTRUCTOR(SBLineEntry, (const lldb::SBLineEntry &), rhs); -SBLineEntry::SBLineEntry(const SBLineEntry &rhs) : m_opaque_ap() { - if (rhs.IsValid()) - ref() = rhs.ref(); + m_opaque_up = clone(rhs.m_opaque_up); } SBLineEntry::SBLineEntry(const lldb_private::LineEntry *lldb_object_ptr) - : m_opaque_ap() { + : m_opaque_up() { if (lldb_object_ptr) - ref() = *lldb_object_ptr; + m_opaque_up = llvm::make_unique<LineEntry>(*lldb_object_ptr); } const SBLineEntry &SBLineEntry::operator=(const SBLineEntry &rhs) { - if (this != &rhs) { - if (rhs.IsValid()) - ref() = rhs.ref(); - else - m_opaque_ap.reset(); - } - return *this; + LLDB_RECORD_METHOD(const lldb::SBLineEntry &, + SBLineEntry, operator=,(const lldb::SBLineEntry &), rhs); + + if (this != &rhs) + m_opaque_up = clone(rhs.m_opaque_up); + return LLDB_RECORD_RESULT(*this); } void SBLineEntry::SetLineEntry(const lldb_private::LineEntry &lldb_object_ref) { - ref() = lldb_object_ref; + m_opaque_up = llvm::make_unique<LineEntry>(lldb_object_ref); } SBLineEntry::~SBLineEntry() {} SBAddress SBLineEntry::GetStartAddress() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBAddress, SBLineEntry, + GetStartAddress); + SBAddress sb_address; - if (m_opaque_ap) - sb_address.SetAddress(&m_opaque_ap->range.GetBaseAddress()); - - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) { - StreamString sstr; - const Address *addr = sb_address.get(); - if (addr) - addr->Dump(&sstr, NULL, Address::DumpStyleModuleWithFileAddress, - Address::DumpStyleInvalid, 4); - log->Printf("SBLineEntry(%p)::GetStartAddress () => SBAddress (%p): %s", - static_cast<void *>(m_opaque_ap.get()), - static_cast<void *>(sb_address.get()), sstr.GetData()); - } + if (m_opaque_up) + sb_address.SetAddress(&m_opaque_up->range.GetBaseAddress()); - return sb_address; + return LLDB_RECORD_RESULT(sb_address); } SBAddress SBLineEntry::GetEndAddress() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBAddress, SBLineEntry, GetEndAddress); + SBAddress sb_address; - if (m_opaque_ap) { - sb_address.SetAddress(&m_opaque_ap->range.GetBaseAddress()); - sb_address.OffsetAddress(m_opaque_ap->range.GetByteSize()); + if (m_opaque_up) { + sb_address.SetAddress(&m_opaque_up->range.GetBaseAddress()); + sb_address.OffsetAddress(m_opaque_up->range.GetByteSize()); } - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) { - StreamString sstr; - const Address *addr = sb_address.get(); - if (addr) - addr->Dump(&sstr, NULL, Address::DumpStyleModuleWithFileAddress, - Address::DumpStyleInvalid, 4); - log->Printf("SBLineEntry(%p)::GetEndAddress () => SBAddress (%p): %s", - static_cast<void *>(m_opaque_ap.get()), - static_cast<void *>(sb_address.get()), sstr.GetData()); - } - return sb_address; + return LLDB_RECORD_RESULT(sb_address); } bool SBLineEntry::IsValid() const { - return m_opaque_ap.get() && m_opaque_ap->IsValid(); + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBLineEntry, IsValid); + return this->operator bool(); +} +SBLineEntry::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBLineEntry, operator bool); + + return m_opaque_up.get() && m_opaque_up->IsValid(); } SBFileSpec SBLineEntry::GetFileSpec() const { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBFileSpec, SBLineEntry, GetFileSpec); SBFileSpec sb_file_spec; - if (m_opaque_ap.get() && m_opaque_ap->file) - sb_file_spec.SetFileSpec(m_opaque_ap->file); - - if (log) { - SBStream sstr; - sb_file_spec.GetDescription(sstr); - log->Printf("SBLineEntry(%p)::GetFileSpec () => SBFileSpec(%p): %s", - static_cast<void *>(m_opaque_ap.get()), - static_cast<const void *>(sb_file_spec.get()), sstr.GetData()); - } + if (m_opaque_up.get() && m_opaque_up->file) + sb_file_spec.SetFileSpec(m_opaque_up->file); - return sb_file_spec; + return LLDB_RECORD_RESULT(sb_file_spec); } uint32_t SBLineEntry::GetLine() const { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBLineEntry, GetLine); uint32_t line = 0; - if (m_opaque_ap) - line = m_opaque_ap->line; - - if (log) - log->Printf("SBLineEntry(%p)::GetLine () => %u", - static_cast<void *>(m_opaque_ap.get()), line); + if (m_opaque_up) + line = m_opaque_up->line; return line; } uint32_t SBLineEntry::GetColumn() const { - if (m_opaque_ap) - return m_opaque_ap->column; + LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBLineEntry, GetColumn); + + if (m_opaque_up) + return m_opaque_up->column; return 0; } void SBLineEntry::SetFileSpec(lldb::SBFileSpec filespec) { + LLDB_RECORD_METHOD(void, SBLineEntry, SetFileSpec, (lldb::SBFileSpec), + filespec); + if (filespec.IsValid()) ref().file = filespec.ref(); else ref().file.Clear(); } -void SBLineEntry::SetLine(uint32_t line) { ref().line = line; } +void SBLineEntry::SetLine(uint32_t line) { + LLDB_RECORD_METHOD(void, SBLineEntry, SetLine, (uint32_t), line); + + ref().line = line; +} + +void SBLineEntry::SetColumn(uint32_t column) { + LLDB_RECORD_METHOD(void, SBLineEntry, SetColumn, (uint32_t), column); -void SBLineEntry::SetColumn(uint32_t column) { ref().line = column; } + ref().line = column; +} bool SBLineEntry::operator==(const SBLineEntry &rhs) const { - lldb_private::LineEntry *lhs_ptr = m_opaque_ap.get(); - lldb_private::LineEntry *rhs_ptr = rhs.m_opaque_ap.get(); + LLDB_RECORD_METHOD_CONST( + bool, SBLineEntry, operator==,(const lldb::SBLineEntry &), rhs); + + lldb_private::LineEntry *lhs_ptr = m_opaque_up.get(); + lldb_private::LineEntry *rhs_ptr = rhs.m_opaque_up.get(); if (lhs_ptr && rhs_ptr) return lldb_private::LineEntry::Compare(*lhs_ptr, *rhs_ptr) == 0; @@ -151,8 +145,11 @@ bool SBLineEntry::operator==(const SBLineEntry &rhs) const { } bool SBLineEntry::operator!=(const SBLineEntry &rhs) const { - lldb_private::LineEntry *lhs_ptr = m_opaque_ap.get(); - lldb_private::LineEntry *rhs_ptr = rhs.m_opaque_ap.get(); + LLDB_RECORD_METHOD_CONST( + bool, SBLineEntry, operator!=,(const lldb::SBLineEntry &), rhs); + + lldb_private::LineEntry *lhs_ptr = m_opaque_up.get(); + lldb_private::LineEntry *rhs_ptr = rhs.m_opaque_up.get(); if (lhs_ptr && rhs_ptr) return lldb_private::LineEntry::Compare(*lhs_ptr, *rhs_ptr) != 0; @@ -161,23 +158,26 @@ bool SBLineEntry::operator!=(const SBLineEntry &rhs) const { } const lldb_private::LineEntry *SBLineEntry::operator->() const { - return m_opaque_ap.get(); + return m_opaque_up.get(); } lldb_private::LineEntry &SBLineEntry::ref() { - if (m_opaque_ap == NULL) - m_opaque_ap.reset(new lldb_private::LineEntry()); - return *m_opaque_ap; + if (m_opaque_up == nullptr) + m_opaque_up.reset(new lldb_private::LineEntry()); + return *m_opaque_up; } -const lldb_private::LineEntry &SBLineEntry::ref() const { return *m_opaque_ap; } +const lldb_private::LineEntry &SBLineEntry::ref() const { return *m_opaque_up; } bool SBLineEntry::GetDescription(SBStream &description) { + LLDB_RECORD_METHOD(bool, SBLineEntry, GetDescription, (lldb::SBStream &), + description); + Stream &strm = description.ref(); - if (m_opaque_ap) { + if (m_opaque_up) { char file_path[PATH_MAX * 2]; - m_opaque_ap->file.GetPath(file_path, sizeof(file_path)); + m_opaque_up->file.GetPath(file_path, sizeof(file_path)); strm.Printf("%s:%u", file_path, GetLine()); if (GetColumn() > 0) strm.Printf(":%u", GetColumn()); @@ -187,4 +187,34 @@ bool SBLineEntry::GetDescription(SBStream &description) { return true; } -lldb_private::LineEntry *SBLineEntry::get() { return m_opaque_ap.get(); } +lldb_private::LineEntry *SBLineEntry::get() { return m_opaque_up.get(); } + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBLineEntry>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBLineEntry, ()); + LLDB_REGISTER_CONSTRUCTOR(SBLineEntry, (const lldb::SBLineEntry &)); + LLDB_REGISTER_METHOD(const lldb::SBLineEntry &, + SBLineEntry, operator=,(const lldb::SBLineEntry &)); + LLDB_REGISTER_METHOD_CONST(lldb::SBAddress, SBLineEntry, GetStartAddress, + ()); + LLDB_REGISTER_METHOD_CONST(lldb::SBAddress, SBLineEntry, GetEndAddress, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBLineEntry, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBLineEntry, operator bool, ()); + LLDB_REGISTER_METHOD_CONST(lldb::SBFileSpec, SBLineEntry, GetFileSpec, ()); + LLDB_REGISTER_METHOD_CONST(uint32_t, SBLineEntry, GetLine, ()); + LLDB_REGISTER_METHOD_CONST(uint32_t, SBLineEntry, GetColumn, ()); + LLDB_REGISTER_METHOD(void, SBLineEntry, SetFileSpec, (lldb::SBFileSpec)); + LLDB_REGISTER_METHOD(void, SBLineEntry, SetLine, (uint32_t)); + LLDB_REGISTER_METHOD(void, SBLineEntry, SetColumn, (uint32_t)); + LLDB_REGISTER_METHOD_CONST( + bool, SBLineEntry, operator==,(const lldb::SBLineEntry &)); + LLDB_REGISTER_METHOD_CONST( + bool, SBLineEntry, operator!=,(const lldb::SBLineEntry &)); + LLDB_REGISTER_METHOD(bool, SBLineEntry, GetDescription, (lldb::SBStream &)); +} + +} +} diff --git a/source/API/SBListener.cpp b/source/API/SBListener.cpp index e671d9f2ce8cc..4fe90f6f68620 100644 --- a/source/API/SBListener.cpp +++ b/source/API/SBListener.cpp @@ -1,13 +1,13 @@ //===-- SBListener.cpp ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBListener.h" +#include "SBReproducerPrivate.h" #include "lldb/API/SBBroadcaster.h" #include "lldb/API/SBDebugger.h" #include "lldb/API/SBEvent.h" @@ -15,32 +15,34 @@ #include "lldb/Core/Debugger.h" #include "lldb/Utility/Broadcaster.h" #include "lldb/Utility/Listener.h" -#include "lldb/Utility/Log.h" #include "lldb/Utility/StreamString.h" using namespace lldb; using namespace lldb_private; -SBListener::SBListener() : m_opaque_sp(), m_unused_ptr(NULL) {} +SBListener::SBListener() : m_opaque_sp(), m_unused_ptr(nullptr) { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBListener); +} SBListener::SBListener(const char *name) : m_opaque_sp(Listener::MakeListener(name)), m_unused_ptr(nullptr) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - - if (log) - log->Printf("SBListener::SBListener (name=\"%s\") => SBListener(%p)", name, - static_cast<void *>(m_opaque_sp.get())); + LLDB_RECORD_CONSTRUCTOR(SBListener, (const char *), name); } SBListener::SBListener(const SBListener &rhs) - : m_opaque_sp(rhs.m_opaque_sp), m_unused_ptr(nullptr) {} + : m_opaque_sp(rhs.m_opaque_sp), m_unused_ptr(nullptr) { + LLDB_RECORD_CONSTRUCTOR(SBListener, (const lldb::SBListener &), rhs); +} const lldb::SBListener &SBListener::operator=(const lldb::SBListener &rhs) { + LLDB_RECORD_METHOD(const lldb::SBListener &, + SBListener, operator=,(const lldb::SBListener &), rhs); + if (this != &rhs) { m_opaque_sp = rhs.m_opaque_sp; m_unused_ptr = nullptr; } - return *this; + return LLDB_RECORD_RESULT(*this); } SBListener::SBListener(const lldb::ListenerSP &listener_sp) @@ -48,15 +50,28 @@ SBListener::SBListener(const lldb::ListenerSP &listener_sp) SBListener::~SBListener() {} -bool SBListener::IsValid() const { return m_opaque_sp != nullptr; } +bool SBListener::IsValid() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBListener, IsValid); + return this->operator bool(); +} +SBListener::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBListener, operator bool); + + return m_opaque_sp != nullptr; +} void SBListener::AddEvent(const SBEvent &event) { + LLDB_RECORD_METHOD(void, SBListener, AddEvent, (const lldb::SBEvent &), + event); + EventSP &event_sp = event.GetSP(); if (event_sp) m_opaque_sp->AddEvent(event_sp); } void SBListener::Clear() { + LLDB_RECORD_METHOD_NO_ARGS(void, SBListener, Clear); + if (m_opaque_sp) m_opaque_sp->Clear(); } @@ -64,6 +79,10 @@ void SBListener::Clear() { uint32_t SBListener::StartListeningForEventClass(SBDebugger &debugger, const char *broadcaster_class, uint32_t event_mask) { + LLDB_RECORD_METHOD(uint32_t, SBListener, StartListeningForEventClass, + (lldb::SBDebugger &, const char *, uint32_t), debugger, + broadcaster_class, event_mask); + if (m_opaque_sp) { Debugger *lldb_debugger = debugger.get(); if (!lldb_debugger) @@ -78,6 +97,10 @@ uint32_t SBListener::StartListeningForEventClass(SBDebugger &debugger, bool SBListener::StopListeningForEventClass(SBDebugger &debugger, const char *broadcaster_class, uint32_t event_mask) { + LLDB_RECORD_METHOD(bool, SBListener, StopListeningForEventClass, + (lldb::SBDebugger &, const char *, uint32_t), debugger, + broadcaster_class, event_mask); + if (m_opaque_sp) { Debugger *lldb_debugger = debugger.get(); if (!lldb_debugger) @@ -91,47 +114,25 @@ bool SBListener::StopListeningForEventClass(SBDebugger &debugger, uint32_t SBListener::StartListeningForEvents(const SBBroadcaster &broadcaster, uint32_t event_mask) { + LLDB_RECORD_METHOD(uint32_t, SBListener, StartListeningForEvents, + (const lldb::SBBroadcaster &, uint32_t), broadcaster, + event_mask); + uint32_t acquired_event_mask = 0; if (m_opaque_sp && broadcaster.IsValid()) { acquired_event_mask = m_opaque_sp->StartListeningForEvents(broadcaster.get(), event_mask); } - Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API); - if (log) { - StreamString sstr_requested; - StreamString sstr_acquired; - - Broadcaster *lldb_broadcaster = broadcaster.get(); - if (lldb_broadcaster) { - const bool got_requested_names = - lldb_broadcaster->GetEventNames(sstr_requested, event_mask, false); - const bool got_acquired_names = lldb_broadcaster->GetEventNames( - sstr_acquired, acquired_event_mask, false); - log->Printf("SBListener(%p)::StartListeneingForEvents " - "(SBBroadcaster(%p): %s, event_mask=0x%8.8x%s%s%s) => " - "0x%8.8x%s%s%s", - static_cast<void *>(m_opaque_sp.get()), - static_cast<void *>(lldb_broadcaster), - lldb_broadcaster->GetBroadcasterName().GetCString(), - event_mask, got_requested_names ? " (" : "", - sstr_requested.GetData(), got_requested_names ? ")" : "", - acquired_event_mask, got_acquired_names ? " (" : "", - sstr_acquired.GetData(), got_acquired_names ? ")" : ""); - } else { - log->Printf("SBListener(%p)::StartListeneingForEvents " - "(SBBroadcaster(%p), event_mask=0x%8.8x) => 0x%8.8x", - static_cast<void *>(m_opaque_sp.get()), - static_cast<void *>(lldb_broadcaster), event_mask, - acquired_event_mask); - } - } - return acquired_event_mask; } bool SBListener::StopListeningForEvents(const SBBroadcaster &broadcaster, uint32_t event_mask) { + LLDB_RECORD_METHOD(bool, SBListener, StopListeningForEvents, + (const lldb::SBBroadcaster &, uint32_t), broadcaster, + event_mask); + if (m_opaque_sp && broadcaster.IsValid()) { return m_opaque_sp->StopListeningForEvents(broadcaster.get(), event_mask); } @@ -139,20 +140,9 @@ bool SBListener::StopListeningForEvents(const SBBroadcaster &broadcaster, } bool SBListener::WaitForEvent(uint32_t timeout_secs, SBEvent &event) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) { - if (timeout_secs == UINT32_MAX) { - log->Printf("SBListener(%p)::WaitForEvent (timeout_secs=INFINITE, " - "SBEvent(%p))...", - static_cast<void *>(m_opaque_sp.get()), - static_cast<void *>(event.get())); - } else { - log->Printf( - "SBListener(%p)::WaitForEvent (timeout_secs=%d, SBEvent(%p))...", - static_cast<void *>(m_opaque_sp.get()), timeout_secs, - static_cast<void *>(event.get())); - } - } + LLDB_RECORD_METHOD(bool, SBListener, WaitForEvent, + (uint32_t, lldb::SBEvent &), timeout_secs, event); + bool success = false; if (m_opaque_sp) { @@ -169,27 +159,18 @@ bool SBListener::WaitForEvent(uint32_t timeout_secs, SBEvent &event) { } } - if (log) { - if (timeout_secs == UINT32_MAX) { - log->Printf("SBListener(%p)::WaitForEvent (timeout_secs=INFINITE, " - "SBEvent(%p)) => %i", - static_cast<void *>(m_opaque_sp.get()), - static_cast<void *>(event.get()), success); - } else { - log->Printf( - "SBListener(%p)::WaitForEvent (timeout_secs=%d, SBEvent(%p)) => %i", - static_cast<void *>(m_opaque_sp.get()), timeout_secs, - static_cast<void *>(event.get()), success); - } - } if (!success) - event.reset(NULL); + event.reset(nullptr); return success; } bool SBListener::WaitForEventForBroadcaster(uint32_t num_seconds, const SBBroadcaster &broadcaster, SBEvent &event) { + LLDB_RECORD_METHOD(bool, SBListener, WaitForEventForBroadcaster, + (uint32_t, const lldb::SBBroadcaster &, lldb::SBEvent &), + num_seconds, broadcaster, event); + if (m_opaque_sp && broadcaster.IsValid()) { Timeout<std::micro> timeout(llvm::None); if (num_seconds != UINT32_MAX) @@ -201,13 +182,18 @@ bool SBListener::WaitForEventForBroadcaster(uint32_t num_seconds, return true; } } - event.reset(NULL); + event.reset(nullptr); return false; } bool SBListener::WaitForEventForBroadcasterWithType( uint32_t num_seconds, const SBBroadcaster &broadcaster, uint32_t event_type_mask, SBEvent &event) { + LLDB_RECORD_METHOD( + bool, SBListener, WaitForEventForBroadcasterWithType, + (uint32_t, const lldb::SBBroadcaster &, uint32_t, lldb::SBEvent &), + num_seconds, broadcaster, event_type_mask, event); + if (m_opaque_sp && broadcaster.IsValid()) { Timeout<std::micro> timeout(llvm::None); if (num_seconds != UINT32_MAX) @@ -219,42 +205,55 @@ bool SBListener::WaitForEventForBroadcasterWithType( return true; } } - event.reset(NULL); + event.reset(nullptr); return false; } bool SBListener::PeekAtNextEvent(SBEvent &event) { + LLDB_RECORD_METHOD(bool, SBListener, PeekAtNextEvent, (lldb::SBEvent &), + event); + if (m_opaque_sp) { event.reset(m_opaque_sp->PeekAtNextEvent()); return event.IsValid(); } - event.reset(NULL); + event.reset(nullptr); return false; } bool SBListener::PeekAtNextEventForBroadcaster(const SBBroadcaster &broadcaster, SBEvent &event) { + LLDB_RECORD_METHOD(bool, SBListener, PeekAtNextEventForBroadcaster, + (const lldb::SBBroadcaster &, lldb::SBEvent &), + broadcaster, event); + if (m_opaque_sp && broadcaster.IsValid()) { event.reset(m_opaque_sp->PeekAtNextEventForBroadcaster(broadcaster.get())); return event.IsValid(); } - event.reset(NULL); + event.reset(nullptr); return false; } bool SBListener::PeekAtNextEventForBroadcasterWithType( const SBBroadcaster &broadcaster, uint32_t event_type_mask, SBEvent &event) { + LLDB_RECORD_METHOD(bool, SBListener, PeekAtNextEventForBroadcasterWithType, + (const lldb::SBBroadcaster &, uint32_t, lldb::SBEvent &), + broadcaster, event_type_mask, event); + if (m_opaque_sp && broadcaster.IsValid()) { event.reset(m_opaque_sp->PeekAtNextEventForBroadcasterWithType( broadcaster.get(), event_type_mask)); return event.IsValid(); } - event.reset(NULL); + event.reset(nullptr); return false; } bool SBListener::GetNextEvent(SBEvent &event) { + LLDB_RECORD_METHOD(bool, SBListener, GetNextEvent, (lldb::SBEvent &), event); + if (m_opaque_sp) { EventSP event_sp; if (m_opaque_sp->GetEvent(event_sp, std::chrono::seconds(0))) { @@ -262,12 +261,16 @@ bool SBListener::GetNextEvent(SBEvent &event) { return true; } } - event.reset(NULL); + event.reset(nullptr); return false; } bool SBListener::GetNextEventForBroadcaster(const SBBroadcaster &broadcaster, SBEvent &event) { + LLDB_RECORD_METHOD(bool, SBListener, GetNextEventForBroadcaster, + (const lldb::SBBroadcaster &, lldb::SBEvent &), + broadcaster, event); + if (m_opaque_sp && broadcaster.IsValid()) { EventSP event_sp; if (m_opaque_sp->GetEventForBroadcaster(broadcaster.get(), event_sp, @@ -276,13 +279,17 @@ bool SBListener::GetNextEventForBroadcaster(const SBBroadcaster &broadcaster, return true; } } - event.reset(NULL); + event.reset(nullptr); return false; } bool SBListener::GetNextEventForBroadcasterWithType( const SBBroadcaster &broadcaster, uint32_t event_type_mask, SBEvent &event) { + LLDB_RECORD_METHOD(bool, SBListener, GetNextEventForBroadcasterWithType, + (const lldb::SBBroadcaster &, uint32_t, lldb::SBEvent &), + broadcaster, event_type_mask, event); + if (m_opaque_sp && broadcaster.IsValid()) { EventSP event_sp; if (m_opaque_sp->GetEventForBroadcasterWithType(broadcaster.get(), @@ -292,11 +299,14 @@ bool SBListener::GetNextEventForBroadcasterWithType( return true; } } - event.reset(NULL); + event.reset(nullptr); return false; } bool SBListener::HandleBroadcastEvent(const SBEvent &event) { + LLDB_RECORD_METHOD(bool, SBListener, HandleBroadcastEvent, + (const lldb::SBEvent &), event); + if (m_opaque_sp) return m_opaque_sp->HandleBroadcastEvent(event.GetSP()); return false; @@ -312,3 +322,52 @@ void SBListener::reset(ListenerSP listener_sp) { m_opaque_sp = listener_sp; m_unused_ptr = nullptr; } + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBListener>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBListener, ()); + LLDB_REGISTER_CONSTRUCTOR(SBListener, (const char *)); + LLDB_REGISTER_CONSTRUCTOR(SBListener, (const lldb::SBListener &)); + LLDB_REGISTER_METHOD(const lldb::SBListener &, + SBListener, operator=,(const lldb::SBListener &)); + LLDB_REGISTER_METHOD_CONST(bool, SBListener, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBListener, operator bool, ()); + LLDB_REGISTER_METHOD(void, SBListener, AddEvent, (const lldb::SBEvent &)); + LLDB_REGISTER_METHOD(void, SBListener, Clear, ()); + LLDB_REGISTER_METHOD(uint32_t, SBListener, StartListeningForEventClass, + (lldb::SBDebugger &, const char *, uint32_t)); + LLDB_REGISTER_METHOD(bool, SBListener, StopListeningForEventClass, + (lldb::SBDebugger &, const char *, uint32_t)); + LLDB_REGISTER_METHOD(uint32_t, SBListener, StartListeningForEvents, + (const lldb::SBBroadcaster &, uint32_t)); + LLDB_REGISTER_METHOD(bool, SBListener, StopListeningForEvents, + (const lldb::SBBroadcaster &, uint32_t)); + LLDB_REGISTER_METHOD(bool, SBListener, WaitForEvent, + (uint32_t, lldb::SBEvent &)); + LLDB_REGISTER_METHOD( + bool, SBListener, WaitForEventForBroadcaster, + (uint32_t, const lldb::SBBroadcaster &, lldb::SBEvent &)); + LLDB_REGISTER_METHOD( + bool, SBListener, WaitForEventForBroadcasterWithType, + (uint32_t, const lldb::SBBroadcaster &, uint32_t, lldb::SBEvent &)); + LLDB_REGISTER_METHOD(bool, SBListener, PeekAtNextEvent, (lldb::SBEvent &)); + LLDB_REGISTER_METHOD(bool, SBListener, PeekAtNextEventForBroadcaster, + (const lldb::SBBroadcaster &, lldb::SBEvent &)); + LLDB_REGISTER_METHOD( + bool, SBListener, PeekAtNextEventForBroadcasterWithType, + (const lldb::SBBroadcaster &, uint32_t, lldb::SBEvent &)); + LLDB_REGISTER_METHOD(bool, SBListener, GetNextEvent, (lldb::SBEvent &)); + LLDB_REGISTER_METHOD(bool, SBListener, GetNextEventForBroadcaster, + (const lldb::SBBroadcaster &, lldb::SBEvent &)); + LLDB_REGISTER_METHOD( + bool, SBListener, GetNextEventForBroadcasterWithType, + (const lldb::SBBroadcaster &, uint32_t, lldb::SBEvent &)); + LLDB_REGISTER_METHOD(bool, SBListener, HandleBroadcastEvent, + (const lldb::SBEvent &)); +} + +} +} diff --git a/source/API/SBMemoryRegionInfo.cpp b/source/API/SBMemoryRegionInfo.cpp index c4dbaec707bb9..d25570f51ce54 100644 --- a/source/API/SBMemoryRegionInfo.cpp +++ b/source/API/SBMemoryRegionInfo.cpp @@ -1,13 +1,14 @@ //===-- SBMemoryRegionInfo.cpp ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBMemoryRegionInfo.h" +#include "SBReproducerPrivate.h" +#include "Utils.h" #include "lldb/API/SBDefines.h" #include "lldb/API/SBError.h" #include "lldb/API/SBStream.h" @@ -17,82 +18,149 @@ using namespace lldb; using namespace lldb_private; -SBMemoryRegionInfo::SBMemoryRegionInfo() - : m_opaque_ap(new MemoryRegionInfo()) {} +SBMemoryRegionInfo::SBMemoryRegionInfo() : m_opaque_up(new MemoryRegionInfo()) { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBMemoryRegionInfo); +} SBMemoryRegionInfo::SBMemoryRegionInfo(const MemoryRegionInfo *lldb_object_ptr) - : m_opaque_ap(new MemoryRegionInfo()) { + : m_opaque_up(new MemoryRegionInfo()) { if (lldb_object_ptr) ref() = *lldb_object_ptr; } SBMemoryRegionInfo::SBMemoryRegionInfo(const SBMemoryRegionInfo &rhs) - : m_opaque_ap(new MemoryRegionInfo()) { - ref() = rhs.ref(); + : m_opaque_up() { + LLDB_RECORD_CONSTRUCTOR(SBMemoryRegionInfo, + (const lldb::SBMemoryRegionInfo &), rhs); + m_opaque_up = clone(rhs.m_opaque_up); } const SBMemoryRegionInfo &SBMemoryRegionInfo:: operator=(const SBMemoryRegionInfo &rhs) { - if (this != &rhs) { - ref() = rhs.ref(); - } - return *this; + LLDB_RECORD_METHOD( + const lldb::SBMemoryRegionInfo &, + SBMemoryRegionInfo, operator=,(const lldb::SBMemoryRegionInfo &), rhs); + + if (this != &rhs) + m_opaque_up = clone(rhs.m_opaque_up); + return LLDB_RECORD_RESULT(*this); } SBMemoryRegionInfo::~SBMemoryRegionInfo() {} -void SBMemoryRegionInfo::Clear() { m_opaque_ap->Clear(); } +void SBMemoryRegionInfo::Clear() { + LLDB_RECORD_METHOD_NO_ARGS(void, SBMemoryRegionInfo, Clear); + + m_opaque_up->Clear(); +} bool SBMemoryRegionInfo::operator==(const SBMemoryRegionInfo &rhs) const { + LLDB_RECORD_METHOD_CONST( + bool, SBMemoryRegionInfo, operator==,(const lldb::SBMemoryRegionInfo &), + rhs); + return ref() == rhs.ref(); } bool SBMemoryRegionInfo::operator!=(const SBMemoryRegionInfo &rhs) const { + LLDB_RECORD_METHOD_CONST( + bool, SBMemoryRegionInfo, operator!=,(const lldb::SBMemoryRegionInfo &), + rhs); + return ref() != rhs.ref(); } -MemoryRegionInfo &SBMemoryRegionInfo::ref() { return *m_opaque_ap; } +MemoryRegionInfo &SBMemoryRegionInfo::ref() { return *m_opaque_up; } -const MemoryRegionInfo &SBMemoryRegionInfo::ref() const { return *m_opaque_ap; } +const MemoryRegionInfo &SBMemoryRegionInfo::ref() const { return *m_opaque_up; } lldb::addr_t SBMemoryRegionInfo::GetRegionBase() { - return m_opaque_ap->GetRange().GetRangeBase(); + LLDB_RECORD_METHOD_NO_ARGS(lldb::addr_t, SBMemoryRegionInfo, GetRegionBase); + + return m_opaque_up->GetRange().GetRangeBase(); } lldb::addr_t SBMemoryRegionInfo::GetRegionEnd() { - return m_opaque_ap->GetRange().GetRangeEnd(); + LLDB_RECORD_METHOD_NO_ARGS(lldb::addr_t, SBMemoryRegionInfo, GetRegionEnd); + + return m_opaque_up->GetRange().GetRangeEnd(); } bool SBMemoryRegionInfo::IsReadable() { - return m_opaque_ap->GetReadable() == MemoryRegionInfo::eYes; + LLDB_RECORD_METHOD_NO_ARGS(bool, SBMemoryRegionInfo, IsReadable); + + return m_opaque_up->GetReadable() == MemoryRegionInfo::eYes; } bool SBMemoryRegionInfo::IsWritable() { - return m_opaque_ap->GetWritable() == MemoryRegionInfo::eYes; + LLDB_RECORD_METHOD_NO_ARGS(bool, SBMemoryRegionInfo, IsWritable); + + return m_opaque_up->GetWritable() == MemoryRegionInfo::eYes; } bool SBMemoryRegionInfo::IsExecutable() { - return m_opaque_ap->GetExecutable() == MemoryRegionInfo::eYes; + LLDB_RECORD_METHOD_NO_ARGS(bool, SBMemoryRegionInfo, IsExecutable); + + return m_opaque_up->GetExecutable() == MemoryRegionInfo::eYes; } bool SBMemoryRegionInfo::IsMapped() { - return m_opaque_ap->GetMapped() == MemoryRegionInfo::eYes; + LLDB_RECORD_METHOD_NO_ARGS(bool, SBMemoryRegionInfo, IsMapped); + + return m_opaque_up->GetMapped() == MemoryRegionInfo::eYes; } const char *SBMemoryRegionInfo::GetName() { - return m_opaque_ap->GetName().AsCString(); + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBMemoryRegionInfo, GetName); + + return m_opaque_up->GetName().AsCString(); } bool SBMemoryRegionInfo::GetDescription(SBStream &description) { + LLDB_RECORD_METHOD(bool, SBMemoryRegionInfo, GetDescription, + (lldb::SBStream &), description); + Stream &strm = description.ref(); - const addr_t load_addr = m_opaque_ap->GetRange().base; + const addr_t load_addr = m_opaque_up->GetRange().base; strm.Printf("[0x%16.16" PRIx64 "-0x%16.16" PRIx64 " ", load_addr, - load_addr + m_opaque_ap->GetRange().size); - strm.Printf(m_opaque_ap->GetReadable() ? "R" : "-"); - strm.Printf(m_opaque_ap->GetWritable() ? "W" : "-"); - strm.Printf(m_opaque_ap->GetExecutable() ? "X" : "-"); + load_addr + m_opaque_up->GetRange().size); + strm.Printf(m_opaque_up->GetReadable() ? "R" : "-"); + strm.Printf(m_opaque_up->GetWritable() ? "W" : "-"); + strm.Printf(m_opaque_up->GetExecutable() ? "X" : "-"); strm.Printf("]"); return true; } + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBMemoryRegionInfo>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBMemoryRegionInfo, ()); + LLDB_REGISTER_CONSTRUCTOR(SBMemoryRegionInfo, + (const lldb::SBMemoryRegionInfo &)); + LLDB_REGISTER_METHOD( + const lldb::SBMemoryRegionInfo &, + SBMemoryRegionInfo, operator=,(const lldb::SBMemoryRegionInfo &)); + LLDB_REGISTER_METHOD(void, SBMemoryRegionInfo, Clear, ()); + LLDB_REGISTER_METHOD_CONST( + bool, + SBMemoryRegionInfo, operator==,(const lldb::SBMemoryRegionInfo &)); + LLDB_REGISTER_METHOD_CONST( + bool, + SBMemoryRegionInfo, operator!=,(const lldb::SBMemoryRegionInfo &)); + LLDB_REGISTER_METHOD(lldb::addr_t, SBMemoryRegionInfo, GetRegionBase, ()); + LLDB_REGISTER_METHOD(lldb::addr_t, SBMemoryRegionInfo, GetRegionEnd, ()); + LLDB_REGISTER_METHOD(bool, SBMemoryRegionInfo, IsReadable, ()); + LLDB_REGISTER_METHOD(bool, SBMemoryRegionInfo, IsWritable, ()); + LLDB_REGISTER_METHOD(bool, SBMemoryRegionInfo, IsExecutable, ()); + LLDB_REGISTER_METHOD(bool, SBMemoryRegionInfo, IsMapped, ()); + LLDB_REGISTER_METHOD(const char *, SBMemoryRegionInfo, GetName, ()); + LLDB_REGISTER_METHOD(bool, SBMemoryRegionInfo, GetDescription, + (lldb::SBStream &)); +} + +} +} diff --git a/source/API/SBMemoryRegionInfoList.cpp b/source/API/SBMemoryRegionInfoList.cpp index 1cefc9dcc0448..32a3afb84af0e 100644 --- a/source/API/SBMemoryRegionInfoList.cpp +++ b/source/API/SBMemoryRegionInfoList.cpp @@ -1,17 +1,16 @@ //===-- SBMemoryRegionInfoList.cpp ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBMemoryRegionInfoList.h" +#include "SBReproducerPrivate.h" #include "lldb/API/SBMemoryRegionInfo.h" #include "lldb/API/SBStream.h" #include "lldb/Target/MemoryRegionInfo.h" -#include "lldb/Utility/Log.h" #include <vector> @@ -65,69 +64,103 @@ private: MemoryRegionInfos m_regions; }; -MemoryRegionInfos &SBMemoryRegionInfoList::ref() { - return m_opaque_ap->Ref(); -} +MemoryRegionInfos &SBMemoryRegionInfoList::ref() { return m_opaque_up->Ref(); } const MemoryRegionInfos &SBMemoryRegionInfoList::ref() const { - return m_opaque_ap->Ref(); + return m_opaque_up->Ref(); } SBMemoryRegionInfoList::SBMemoryRegionInfoList() - : m_opaque_ap(new MemoryRegionInfoListImpl()) {} + : m_opaque_up(new MemoryRegionInfoListImpl()) { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBMemoryRegionInfoList); +} SBMemoryRegionInfoList::SBMemoryRegionInfoList( const SBMemoryRegionInfoList &rhs) - : m_opaque_ap(new MemoryRegionInfoListImpl(*rhs.m_opaque_ap)) {} + : m_opaque_up(new MemoryRegionInfoListImpl(*rhs.m_opaque_up)) { + LLDB_RECORD_CONSTRUCTOR(SBMemoryRegionInfoList, + (const lldb::SBMemoryRegionInfoList &), rhs); +} SBMemoryRegionInfoList::~SBMemoryRegionInfoList() {} const SBMemoryRegionInfoList &SBMemoryRegionInfoList:: operator=(const SBMemoryRegionInfoList &rhs) { + LLDB_RECORD_METHOD( + const lldb::SBMemoryRegionInfoList &, + SBMemoryRegionInfoList, operator=,(const lldb::SBMemoryRegionInfoList &), + rhs); + if (this != &rhs) { - *m_opaque_ap = *rhs.m_opaque_ap; + *m_opaque_up = *rhs.m_opaque_up; } - return *this; + return LLDB_RECORD_RESULT(*this); } uint32_t SBMemoryRegionInfoList::GetSize() const { - return m_opaque_ap->GetSize(); + LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBMemoryRegionInfoList, GetSize); + + return m_opaque_up->GetSize(); } bool SBMemoryRegionInfoList::GetMemoryRegionAtIndex( uint32_t idx, SBMemoryRegionInfo ®ion_info) { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - - bool result = m_opaque_ap->GetMemoryRegionInfoAtIndex(idx, region_info.ref()); - - if (log) { - SBStream sstr; - region_info.GetDescription(sstr); - log->Printf("SBMemoryRegionInfoList::GetMemoryRegionAtIndex (this.ap=%p, " - "idx=%d) => SBMemoryRegionInfo (this.ap=%p, '%s')", - static_cast<void *>(m_opaque_ap.get()), idx, - static_cast<void *>(region_info.m_opaque_ap.get()), - sstr.GetData()); - } + LLDB_RECORD_METHOD(bool, SBMemoryRegionInfoList, GetMemoryRegionAtIndex, + (uint32_t, lldb::SBMemoryRegionInfo &), idx, region_info); - return result; + return m_opaque_up->GetMemoryRegionInfoAtIndex(idx, region_info.ref()); } -void SBMemoryRegionInfoList::Clear() { m_opaque_ap->Clear(); } +void SBMemoryRegionInfoList::Clear() { + LLDB_RECORD_METHOD_NO_ARGS(void, SBMemoryRegionInfoList, Clear); + + m_opaque_up->Clear(); +} void SBMemoryRegionInfoList::Append(SBMemoryRegionInfo &sb_region) { - m_opaque_ap->Append(sb_region.ref()); + LLDB_RECORD_METHOD(void, SBMemoryRegionInfoList, Append, + (lldb::SBMemoryRegionInfo &), sb_region); + + m_opaque_up->Append(sb_region.ref()); } void SBMemoryRegionInfoList::Append(SBMemoryRegionInfoList &sb_region_list) { - m_opaque_ap->Append(*sb_region_list); + LLDB_RECORD_METHOD(void, SBMemoryRegionInfoList, Append, + (lldb::SBMemoryRegionInfoList &), sb_region_list); + + m_opaque_up->Append(*sb_region_list); } const MemoryRegionInfoListImpl *SBMemoryRegionInfoList::operator->() const { - return m_opaque_ap.get(); + return m_opaque_up.get(); } const MemoryRegionInfoListImpl &SBMemoryRegionInfoList::operator*() const { - assert(m_opaque_ap.get()); - return *m_opaque_ap; + assert(m_opaque_up.get()); + return *m_opaque_up; +} + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBMemoryRegionInfoList>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBMemoryRegionInfoList, ()); + LLDB_REGISTER_CONSTRUCTOR(SBMemoryRegionInfoList, + (const lldb::SBMemoryRegionInfoList &)); + LLDB_REGISTER_METHOD( + const lldb::SBMemoryRegionInfoList &, + SBMemoryRegionInfoList, operator=,( + const lldb::SBMemoryRegionInfoList &)); + LLDB_REGISTER_METHOD_CONST(uint32_t, SBMemoryRegionInfoList, GetSize, ()); + LLDB_REGISTER_METHOD(bool, SBMemoryRegionInfoList, GetMemoryRegionAtIndex, + (uint32_t, lldb::SBMemoryRegionInfo &)); + LLDB_REGISTER_METHOD(void, SBMemoryRegionInfoList, Clear, ()); + LLDB_REGISTER_METHOD(void, SBMemoryRegionInfoList, Append, + (lldb::SBMemoryRegionInfo &)); + LLDB_REGISTER_METHOD(void, SBMemoryRegionInfoList, Append, + (lldb::SBMemoryRegionInfoList &)); +} + +} } diff --git a/source/API/SBModule.cpp b/source/API/SBModule.cpp index 31980793bce0a..4bd32bce1c532 100644 --- a/source/API/SBModule.cpp +++ b/source/API/SBModule.cpp @@ -1,13 +1,13 @@ //===-- SBModule.cpp --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBModule.h" +#include "SBReproducerPrivate.h" #include "lldb/API/SBAddress.h" #include "lldb/API/SBFileSpec.h" #include "lldb/API/SBModuleSpec.h" @@ -25,28 +25,36 @@ #include "lldb/Symbol/TypeSystem.h" #include "lldb/Symbol/VariableList.h" #include "lldb/Target/Target.h" -#include "lldb/Utility/Log.h" #include "lldb/Utility/StreamString.h" using namespace lldb; using namespace lldb_private; -SBModule::SBModule() : m_opaque_sp() {} +SBModule::SBModule() : m_opaque_sp() { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBModule); +} SBModule::SBModule(const lldb::ModuleSP &module_sp) : m_opaque_sp(module_sp) {} SBModule::SBModule(const SBModuleSpec &module_spec) : m_opaque_sp() { + LLDB_RECORD_CONSTRUCTOR(SBModule, (const lldb::SBModuleSpec &), module_spec); + ModuleSP module_sp; - Status error = ModuleList::GetSharedModule(*module_spec.m_opaque_ap, - module_sp, NULL, NULL, NULL); + Status error = ModuleList::GetSharedModule( + *module_spec.m_opaque_up, module_sp, nullptr, nullptr, nullptr); if (module_sp) SetSP(module_sp); } -SBModule::SBModule(const SBModule &rhs) : m_opaque_sp(rhs.m_opaque_sp) {} +SBModule::SBModule(const SBModule &rhs) : m_opaque_sp(rhs.m_opaque_sp) { + LLDB_RECORD_CONSTRUCTOR(SBModule, (const lldb::SBModule &), rhs); +} SBModule::SBModule(lldb::SBProcess &process, lldb::addr_t header_addr) : m_opaque_sp() { + LLDB_RECORD_CONSTRUCTOR(SBModule, (lldb::SBProcess &, lldb::addr_t), process, + header_addr); + ProcessSP process_sp(process.GetSP()); if (process_sp) { m_opaque_sp = process_sp->ReadModuleFromMemory(FileSpec(), header_addr); @@ -60,52 +68,61 @@ SBModule::SBModule(lldb::SBProcess &process, lldb::addr_t header_addr) } const SBModule &SBModule::operator=(const SBModule &rhs) { + LLDB_RECORD_METHOD(const lldb::SBModule &, + SBModule, operator=,(const lldb::SBModule &), rhs); + if (this != &rhs) m_opaque_sp = rhs.m_opaque_sp; - return *this; + return LLDB_RECORD_RESULT(*this); } SBModule::~SBModule() {} -bool SBModule::IsValid() const { return m_opaque_sp.get() != NULL; } +bool SBModule::IsValid() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBModule, IsValid); + return this->operator bool(); +} +SBModule::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBModule, operator bool); -void SBModule::Clear() { m_opaque_sp.reset(); } + return m_opaque_sp.get() != nullptr; +} + +void SBModule::Clear() { + LLDB_RECORD_METHOD_NO_ARGS(void, SBModule, Clear); + + m_opaque_sp.reset(); +} SBFileSpec SBModule::GetFileSpec() const { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBFileSpec, SBModule, GetFileSpec); SBFileSpec file_spec; ModuleSP module_sp(GetSP()); if (module_sp) file_spec.SetFileSpec(module_sp->GetFileSpec()); - if (log) - log->Printf("SBModule(%p)::GetFileSpec () => SBFileSpec(%p)", - static_cast<void *>(module_sp.get()), - static_cast<const void *>(file_spec.get())); - - return file_spec; + return LLDB_RECORD_RESULT(file_spec); } lldb::SBFileSpec SBModule::GetPlatformFileSpec() const { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBFileSpec, SBModule, + GetPlatformFileSpec); + SBFileSpec file_spec; ModuleSP module_sp(GetSP()); if (module_sp) file_spec.SetFileSpec(module_sp->GetPlatformFileSpec()); - if (log) - log->Printf("SBModule(%p)::GetPlatformFileSpec () => SBFileSpec(%p)", - static_cast<void *>(module_sp.get()), - static_cast<const void *>(file_spec.get())); - - return file_spec; + return LLDB_RECORD_RESULT(file_spec); } bool SBModule::SetPlatformFileSpec(const lldb::SBFileSpec &platform_file) { + LLDB_RECORD_METHOD(bool, SBModule, SetPlatformFileSpec, + (const lldb::SBFileSpec &), platform_file); + bool result = false; - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); ModuleSP module_sp(GetSP()); if (module_sp) { @@ -113,23 +130,24 @@ bool SBModule::SetPlatformFileSpec(const lldb::SBFileSpec &platform_file) { result = true; } - if (log) - log->Printf("SBModule(%p)::SetPlatformFileSpec (SBFileSpec(%p (%s)) => %i", - static_cast<void *>(module_sp.get()), - static_cast<const void *>(platform_file.get()), - platform_file->GetPath().c_str(), result); return result; } lldb::SBFileSpec SBModule::GetRemoteInstallFileSpec() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFileSpec, SBModule, + GetRemoteInstallFileSpec); + SBFileSpec sb_file_spec; ModuleSP module_sp(GetSP()); if (module_sp) sb_file_spec.SetFileSpec(module_sp->GetRemoteInstallFileSpec()); - return sb_file_spec; + return LLDB_RECORD_RESULT(sb_file_spec); } bool SBModule::SetRemoteInstallFileSpec(lldb::SBFileSpec &file) { + LLDB_RECORD_METHOD(bool, SBModule, SetRemoteInstallFileSpec, + (lldb::SBFileSpec &), file); + ModuleSP module_sp(GetSP()); if (module_sp) { module_sp->SetRemoteInstallFileSpec(file.ref()); @@ -139,30 +157,20 @@ bool SBModule::SetRemoteInstallFileSpec(lldb::SBFileSpec &file) { } const uint8_t *SBModule::GetUUIDBytes() const { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_CONST_NO_ARGS(const uint8_t *, SBModule, GetUUIDBytes); - const uint8_t *uuid_bytes = NULL; + const uint8_t *uuid_bytes = nullptr; ModuleSP module_sp(GetSP()); if (module_sp) uuid_bytes = module_sp->GetUUID().GetBytes().data(); - if (log) { - if (uuid_bytes) { - StreamString s; - module_sp->GetUUID().Dump(&s); - log->Printf("SBModule(%p)::GetUUIDBytes () => %s", - static_cast<void *>(module_sp.get()), s.GetData()); - } else - log->Printf("SBModule(%p)::GetUUIDBytes () => NULL", - static_cast<void *>(module_sp.get())); - } return uuid_bytes; } const char *SBModule::GetUUIDString() const { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBModule, GetUUIDString); - const char *uuid_cstr = NULL; + const char *uuid_cstr = nullptr; ModuleSP module_sp(GetSP()); if (module_sp) { // We are going to return a "const char *" value through the public API, so @@ -173,25 +181,25 @@ const char *SBModule::GetUUIDString() const { } if (uuid_cstr && uuid_cstr[0]) { - if (log) - log->Printf("SBModule(%p)::GetUUIDString () => %s", - static_cast<void *>(module_sp.get()), uuid_cstr); return uuid_cstr; } - if (log) - log->Printf("SBModule(%p)::GetUUIDString () => NULL", - static_cast<void *>(module_sp.get())); - return NULL; + return nullptr; } bool SBModule::operator==(const SBModule &rhs) const { + LLDB_RECORD_METHOD_CONST(bool, SBModule, operator==,(const lldb::SBModule &), + rhs); + if (m_opaque_sp) return m_opaque_sp.get() == rhs.m_opaque_sp.get(); return false; } bool SBModule::operator!=(const SBModule &rhs) const { + LLDB_RECORD_METHOD_CONST(bool, SBModule, operator!=,(const lldb::SBModule &), + rhs); + if (m_opaque_sp) return m_opaque_sp.get() != rhs.m_opaque_sp.get(); return false; @@ -202,6 +210,9 @@ ModuleSP SBModule::GetSP() const { return m_opaque_sp; } void SBModule::SetSP(const ModuleSP &module_sp) { m_opaque_sp = module_sp; } SBAddress SBModule::ResolveFileAddress(lldb::addr_t vm_addr) { + LLDB_RECORD_METHOD(lldb::SBAddress, SBModule, ResolveFileAddress, + (lldb::addr_t), vm_addr); + lldb::SBAddress sb_addr; ModuleSP module_sp(GetSP()); if (module_sp) { @@ -209,21 +220,28 @@ SBAddress SBModule::ResolveFileAddress(lldb::addr_t vm_addr) { if (module_sp->ResolveFileAddress(vm_addr, addr)) sb_addr.ref() = addr; } - return sb_addr; + return LLDB_RECORD_RESULT(sb_addr); } SBSymbolContext SBModule::ResolveSymbolContextForAddress(const SBAddress &addr, uint32_t resolve_scope) { + LLDB_RECORD_METHOD(lldb::SBSymbolContext, SBModule, + ResolveSymbolContextForAddress, + (const lldb::SBAddress &, uint32_t), addr, resolve_scope); + SBSymbolContext sb_sc; ModuleSP module_sp(GetSP()); SymbolContextItem scope = static_cast<SymbolContextItem>(resolve_scope); if (module_sp && addr.IsValid()) module_sp->ResolveSymbolContextForAddress(addr.ref(), scope, *sb_sc); - return sb_sc; + return LLDB_RECORD_RESULT(sb_sc); } bool SBModule::GetDescription(SBStream &description) { + LLDB_RECORD_METHOD(bool, SBModule, GetDescription, (lldb::SBStream &), + description); + Stream &strm = description.ref(); ModuleSP module_sp(GetSP()); @@ -236,6 +254,8 @@ bool SBModule::GetDescription(SBStream &description) { } uint32_t SBModule::GetNumCompileUnits() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBModule, GetNumCompileUnits); + ModuleSP module_sp(GetSP()); if (module_sp) { return module_sp->GetNumCompileUnits(); @@ -244,24 +264,29 @@ uint32_t SBModule::GetNumCompileUnits() { } SBCompileUnit SBModule::GetCompileUnitAtIndex(uint32_t index) { + LLDB_RECORD_METHOD(lldb::SBCompileUnit, SBModule, GetCompileUnitAtIndex, + (uint32_t), index); + SBCompileUnit sb_cu; ModuleSP module_sp(GetSP()); if (module_sp) { CompUnitSP cu_sp = module_sp->GetCompileUnitAtIndex(index); sb_cu.reset(cu_sp.get()); } - return sb_cu; + return LLDB_RECORD_RESULT(sb_cu); } -SBSymbolContextList -SBModule::FindCompileUnits(const SBFileSpec &sb_file_spec) { +SBSymbolContextList SBModule::FindCompileUnits(const SBFileSpec &sb_file_spec) { + LLDB_RECORD_METHOD(lldb::SBSymbolContextList, SBModule, FindCompileUnits, + (const lldb::SBFileSpec &), sb_file_spec); + SBSymbolContextList sb_sc_list; const ModuleSP module_sp(GetSP()); if (sb_file_spec.IsValid() && module_sp) { const bool append = true; module_sp->FindCompileUnits(*sb_file_spec, append, *sb_sc_list); } - return sb_sc_list; + return LLDB_RECORD_RESULT(sb_sc_list); } static Symtab *GetUnifiedSymbolTable(const lldb::ModuleSP &module_sp) { @@ -270,10 +295,12 @@ static Symtab *GetUnifiedSymbolTable(const lldb::ModuleSP &module_sp) { if (symbols) return symbols->GetSymtab(); } - return NULL; + return nullptr; } size_t SBModule::GetNumSymbols() { + LLDB_RECORD_METHOD_NO_ARGS(size_t, SBModule, GetNumSymbols); + ModuleSP module_sp(GetSP()); if (module_sp) { Symtab *symtab = GetUnifiedSymbolTable(module_sp); @@ -284,16 +311,21 @@ size_t SBModule::GetNumSymbols() { } SBSymbol SBModule::GetSymbolAtIndex(size_t idx) { + LLDB_RECORD_METHOD(lldb::SBSymbol, SBModule, GetSymbolAtIndex, (size_t), idx); + SBSymbol sb_symbol; ModuleSP module_sp(GetSP()); Symtab *symtab = GetUnifiedSymbolTable(module_sp); if (symtab) sb_symbol.SetSymbol(symtab->SymbolAtIndex(idx)); - return sb_symbol; + return LLDB_RECORD_RESULT(sb_symbol); } lldb::SBSymbol SBModule::FindSymbol(const char *name, lldb::SymbolType symbol_type) { + LLDB_RECORD_METHOD(lldb::SBSymbol, SBModule, FindSymbol, + (const char *, lldb::SymbolType), name, symbol_type); + SBSymbol sb_symbol; if (name && name[0]) { ModuleSP module_sp(GetSP()); @@ -303,11 +335,14 @@ lldb::SBSymbol SBModule::FindSymbol(const char *name, ConstString(name), symbol_type, Symtab::eDebugAny, Symtab::eVisibilityAny)); } - return sb_symbol; + return LLDB_RECORD_RESULT(sb_symbol); } lldb::SBSymbolContextList SBModule::FindSymbols(const char *name, lldb::SymbolType symbol_type) { + LLDB_RECORD_METHOD(lldb::SBSymbolContextList, SBModule, FindSymbols, + (const char *, lldb::SymbolType), name, symbol_type); + SBSymbolContextList sb_sc_list; if (name && name[0]) { ModuleSP module_sp(GetSP()); @@ -328,10 +363,12 @@ lldb::SBSymbolContextList SBModule::FindSymbols(const char *name, } } } - return sb_sc_list; + return LLDB_RECORD_RESULT(sb_sc_list); } size_t SBModule::GetNumSections() { + LLDB_RECORD_METHOD_NO_ARGS(size_t, SBModule, GetNumSections); + ModuleSP module_sp(GetSP()); if (module_sp) { // Give the symbol vendor a chance to add to the unified section list. @@ -344,6 +381,9 @@ size_t SBModule::GetNumSections() { } SBSection SBModule::GetSectionAtIndex(size_t idx) { + LLDB_RECORD_METHOD(lldb::SBSection, SBModule, GetSectionAtIndex, (size_t), + idx); + SBSection sb_section; ModuleSP module_sp(GetSP()); if (module_sp) { @@ -354,11 +394,14 @@ SBSection SBModule::GetSectionAtIndex(size_t idx) { if (section_list) sb_section.SetSP(section_list->GetSectionAtIndex(idx)); } - return sb_section; + return LLDB_RECORD_RESULT(sb_section); } lldb::SBSymbolContextList SBModule::FindFunctions(const char *name, uint32_t name_type_mask) { + LLDB_RECORD_METHOD(lldb::SBSymbolContextList, SBModule, FindFunctions, + (const char *, uint32_t), name, name_type_mask); + lldb::SBSymbolContextList sb_sc_list; ModuleSP module_sp(GetSP()); if (name && module_sp) { @@ -366,20 +409,24 @@ lldb::SBSymbolContextList SBModule::FindFunctions(const char *name, const bool symbols_ok = true; const bool inlines_ok = true; FunctionNameType type = static_cast<FunctionNameType>(name_type_mask); - module_sp->FindFunctions(ConstString(name), NULL, type, symbols_ok, + module_sp->FindFunctions(ConstString(name), nullptr, type, symbols_ok, inlines_ok, append, *sb_sc_list); } - return sb_sc_list; + return LLDB_RECORD_RESULT(sb_sc_list); } SBValueList SBModule::FindGlobalVariables(SBTarget &target, const char *name, uint32_t max_matches) { + LLDB_RECORD_METHOD(lldb::SBValueList, SBModule, FindGlobalVariables, + (lldb::SBTarget &, const char *, uint32_t), target, name, + max_matches); + SBValueList sb_value_list; ModuleSP module_sp(GetSP()); if (name && module_sp) { VariableList variable_list; const uint32_t match_count = module_sp->FindGlobalVariables( - ConstString(name), NULL, max_matches, variable_list); + ConstString(name), nullptr, max_matches, variable_list); if (match_count > 0) { for (uint32_t i = 0; i < match_count; ++i) { @@ -393,18 +440,24 @@ SBValueList SBModule::FindGlobalVariables(SBTarget &target, const char *name, } } - return sb_value_list; + return LLDB_RECORD_RESULT(sb_value_list); } lldb::SBValue SBModule::FindFirstGlobalVariable(lldb::SBTarget &target, const char *name) { + LLDB_RECORD_METHOD(lldb::SBValue, SBModule, FindFirstGlobalVariable, + (lldb::SBTarget &, const char *), target, name); + SBValueList sb_value_list(FindGlobalVariables(target, name, 1)); if (sb_value_list.IsValid() && sb_value_list.GetSize() > 0) - return sb_value_list.GetValueAtIndex(0); - return SBValue(); + return LLDB_RECORD_RESULT(sb_value_list.GetValueAtIndex(0)); + return LLDB_RECORD_RESULT(SBValue()); } lldb::SBType SBModule::FindFirstType(const char *name_cstr) { + LLDB_RECORD_METHOD(lldb::SBType, SBModule, FindFirstType, (const char *), + name_cstr); + SBType sb_type; ModuleSP module_sp(GetSP()); if (name_cstr && module_sp) { @@ -421,21 +474,27 @@ lldb::SBType SBModule::FindFirstType(const char *name_cstr) { sb_type = SBType(type_system->GetBuiltinTypeByName(name)); } } - return sb_type; + return LLDB_RECORD_RESULT(sb_type); } lldb::SBType SBModule::GetBasicType(lldb::BasicType type) { + LLDB_RECORD_METHOD(lldb::SBType, SBModule, GetBasicType, (lldb::BasicType), + type); + ModuleSP module_sp(GetSP()); if (module_sp) { TypeSystem *type_system = module_sp->GetTypeSystemForLanguage(eLanguageTypeC); if (type_system) - return SBType(type_system->GetBasicTypeFromAST(type)); + return LLDB_RECORD_RESULT(SBType(type_system->GetBasicTypeFromAST(type))); } - return SBType(); + return LLDB_RECORD_RESULT(SBType()); } lldb::SBTypeList SBModule::FindTypes(const char *type) { + LLDB_RECORD_METHOD(lldb::SBTypeList, SBModule, FindTypes, (const char *), + type); + SBTypeList retval; ModuleSP module_sp(GetSP()); @@ -464,40 +523,49 @@ lldb::SBTypeList SBModule::FindTypes(const char *type) { } } - return retval; + return LLDB_RECORD_RESULT(retval); } lldb::SBType SBModule::GetTypeByID(lldb::user_id_t uid) { + LLDB_RECORD_METHOD(lldb::SBType, SBModule, GetTypeByID, (lldb::user_id_t), + uid); + ModuleSP module_sp(GetSP()); if (module_sp) { SymbolVendor *vendor = module_sp->GetSymbolVendor(); if (vendor) { Type *type_ptr = vendor->ResolveTypeUID(uid); if (type_ptr) - return SBType(type_ptr->shared_from_this()); + return LLDB_RECORD_RESULT(SBType(type_ptr->shared_from_this())); } } - return SBType(); + return LLDB_RECORD_RESULT(SBType()); } lldb::SBTypeList SBModule::GetTypes(uint32_t type_mask) { + LLDB_RECORD_METHOD(lldb::SBTypeList, SBModule, GetTypes, (uint32_t), + type_mask); + SBTypeList sb_type_list; ModuleSP module_sp(GetSP()); if (!module_sp) - return sb_type_list; + return LLDB_RECORD_RESULT(sb_type_list); SymbolVendor *vendor = module_sp->GetSymbolVendor(); if (!vendor) - return sb_type_list; + return LLDB_RECORD_RESULT(sb_type_list); TypeClass type_class = static_cast<TypeClass>(type_mask); TypeList type_list; - vendor->GetTypes(NULL, type_class, type_list); - sb_type_list.m_opaque_ap->Append(type_list); - return sb_type_list; + vendor->GetTypes(nullptr, type_class, type_list); + sb_type_list.m_opaque_up->Append(type_list); + return LLDB_RECORD_RESULT(sb_type_list); } SBSection SBModule::FindSection(const char *sect_name) { + LLDB_RECORD_METHOD(lldb::SBSection, SBModule, FindSection, (const char *), + sect_name); + SBSection sb_section; ModuleSP module_sp(GetSP()); @@ -513,10 +581,12 @@ SBSection SBModule::FindSection(const char *sect_name) { } } } - return sb_section; + return LLDB_RECORD_RESULT(sb_section); } lldb::ByteOrder SBModule::GetByteOrder() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::ByteOrder, SBModule, GetByteOrder); + ModuleSP module_sp(GetSP()); if (module_sp) return module_sp->GetArchitecture().GetByteOrder(); @@ -524,6 +594,8 @@ lldb::ByteOrder SBModule::GetByteOrder() { } const char *SBModule::GetTriple() { + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBModule, GetTriple); + ModuleSP module_sp(GetSP()); if (module_sp) { std::string triple(module_sp->GetArchitecture().GetTriple().str()); @@ -533,10 +605,12 @@ const char *SBModule::GetTriple() { ConstString const_triple(triple.c_str()); return const_triple.GetCString(); } - return NULL; + return nullptr; } uint32_t SBModule::GetAddressByteSize() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBModule, GetAddressByteSize); + ModuleSP module_sp(GetSP()); if (module_sp) return module_sp->GetArchitecture().GetAddressByteSize(); @@ -544,6 +618,9 @@ uint32_t SBModule::GetAddressByteSize() { } uint32_t SBModule::GetVersion(uint32_t *versions, uint32_t num_versions) { + LLDB_RECORD_METHOD(uint32_t, SBModule, GetVersion, (uint32_t *, uint32_t), + versions, num_versions); + llvm::VersionTuple version; if (ModuleSP module_sp = GetSP()) version = module_sp->GetVersion(); @@ -570,6 +647,9 @@ uint32_t SBModule::GetVersion(uint32_t *versions, uint32_t num_versions) { } lldb::SBFileSpec SBModule::GetSymbolFileSpec() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBFileSpec, SBModule, + GetSymbolFileSpec); + lldb::SBFileSpec sb_file_spec; ModuleSP module_sp(GetSP()); if (module_sp) { @@ -577,10 +657,13 @@ lldb::SBFileSpec SBModule::GetSymbolFileSpec() const { if (symbol_vendor_ptr) sb_file_spec.SetFileSpec(symbol_vendor_ptr->GetMainFileSpec()); } - return sb_file_spec; + return LLDB_RECORD_RESULT(sb_file_spec); } lldb::SBAddress SBModule::GetObjectFileHeaderAddress() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBAddress, SBModule, + GetObjectFileHeaderAddress); + lldb::SBAddress sb_addr; ModuleSP module_sp(GetSP()); if (module_sp) { @@ -588,10 +671,13 @@ lldb::SBAddress SBModule::GetObjectFileHeaderAddress() const { if (objfile_ptr) sb_addr.ref() = objfile_ptr->GetBaseAddress(); } - return sb_addr; + return LLDB_RECORD_RESULT(sb_addr); } lldb::SBAddress SBModule::GetObjectFileEntryPointAddress() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBAddress, SBModule, + GetObjectFileEntryPointAddress); + lldb::SBAddress sb_addr; ModuleSP module_sp(GetSP()); if (module_sp) { @@ -599,5 +685,84 @@ lldb::SBAddress SBModule::GetObjectFileEntryPointAddress() const { if (objfile_ptr) sb_addr.ref() = objfile_ptr->GetEntryPointAddress(); } - return sb_addr; + return LLDB_RECORD_RESULT(sb_addr); +} + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBModule>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBModule, ()); + LLDB_REGISTER_CONSTRUCTOR(SBModule, (const lldb::SBModuleSpec &)); + LLDB_REGISTER_CONSTRUCTOR(SBModule, (const lldb::SBModule &)); + LLDB_REGISTER_CONSTRUCTOR(SBModule, (lldb::SBProcess &, lldb::addr_t)); + LLDB_REGISTER_METHOD(const lldb::SBModule &, + SBModule, operator=,(const lldb::SBModule &)); + LLDB_REGISTER_METHOD_CONST(bool, SBModule, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBModule, operator bool, ()); + LLDB_REGISTER_METHOD(void, SBModule, Clear, ()); + LLDB_REGISTER_METHOD_CONST(lldb::SBFileSpec, SBModule, GetFileSpec, ()); + LLDB_REGISTER_METHOD_CONST(lldb::SBFileSpec, SBModule, GetPlatformFileSpec, + ()); + LLDB_REGISTER_METHOD(bool, SBModule, SetPlatformFileSpec, + (const lldb::SBFileSpec &)); + LLDB_REGISTER_METHOD(lldb::SBFileSpec, SBModule, GetRemoteInstallFileSpec, + ()); + LLDB_REGISTER_METHOD(bool, SBModule, SetRemoteInstallFileSpec, + (lldb::SBFileSpec &)); + LLDB_REGISTER_METHOD_CONST(const char *, SBModule, GetUUIDString, ()); + LLDB_REGISTER_METHOD_CONST(bool, + SBModule, operator==,(const lldb::SBModule &)); + LLDB_REGISTER_METHOD_CONST(bool, + SBModule, operator!=,(const lldb::SBModule &)); + LLDB_REGISTER_METHOD(lldb::SBAddress, SBModule, ResolveFileAddress, + (lldb::addr_t)); + LLDB_REGISTER_METHOD(lldb::SBSymbolContext, SBModule, + ResolveSymbolContextForAddress, + (const lldb::SBAddress &, uint32_t)); + LLDB_REGISTER_METHOD(bool, SBModule, GetDescription, (lldb::SBStream &)); + LLDB_REGISTER_METHOD(uint32_t, SBModule, GetNumCompileUnits, ()); + LLDB_REGISTER_METHOD(lldb::SBCompileUnit, SBModule, GetCompileUnitAtIndex, + (uint32_t)); + LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBModule, FindCompileUnits, + (const lldb::SBFileSpec &)); + LLDB_REGISTER_METHOD(size_t, SBModule, GetNumSymbols, ()); + LLDB_REGISTER_METHOD(lldb::SBSymbol, SBModule, GetSymbolAtIndex, (size_t)); + LLDB_REGISTER_METHOD(lldb::SBSymbol, SBModule, FindSymbol, + (const char *, lldb::SymbolType)); + LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBModule, FindSymbols, + (const char *, lldb::SymbolType)); + LLDB_REGISTER_METHOD(size_t, SBModule, GetNumSections, ()); + LLDB_REGISTER_METHOD(lldb::SBSection, SBModule, GetSectionAtIndex, + (size_t)); + LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBModule, FindFunctions, + (const char *, uint32_t)); + LLDB_REGISTER_METHOD(lldb::SBValueList, SBModule, FindGlobalVariables, + (lldb::SBTarget &, const char *, uint32_t)); + LLDB_REGISTER_METHOD(lldb::SBValue, SBModule, FindFirstGlobalVariable, + (lldb::SBTarget &, const char *)); + LLDB_REGISTER_METHOD(lldb::SBType, SBModule, FindFirstType, (const char *)); + LLDB_REGISTER_METHOD(lldb::SBType, SBModule, GetBasicType, + (lldb::BasicType)); + LLDB_REGISTER_METHOD(lldb::SBTypeList, SBModule, FindTypes, (const char *)); + LLDB_REGISTER_METHOD(lldb::SBType, SBModule, GetTypeByID, + (lldb::user_id_t)); + LLDB_REGISTER_METHOD(lldb::SBTypeList, SBModule, GetTypes, (uint32_t)); + LLDB_REGISTER_METHOD(lldb::SBSection, SBModule, FindSection, + (const char *)); + LLDB_REGISTER_METHOD(lldb::ByteOrder, SBModule, GetByteOrder, ()); + LLDB_REGISTER_METHOD(const char *, SBModule, GetTriple, ()); + LLDB_REGISTER_METHOD(uint32_t, SBModule, GetAddressByteSize, ()); + LLDB_REGISTER_METHOD(uint32_t, SBModule, GetVersion, + (uint32_t *, uint32_t)); + LLDB_REGISTER_METHOD_CONST(lldb::SBFileSpec, SBModule, GetSymbolFileSpec, + ()); + LLDB_REGISTER_METHOD_CONST(lldb::SBAddress, SBModule, + GetObjectFileHeaderAddress, ()); + LLDB_REGISTER_METHOD_CONST(lldb::SBAddress, SBModule, + GetObjectFileEntryPointAddress, ()); +} + +} } diff --git a/source/API/SBModuleSpec.cpp b/source/API/SBModuleSpec.cpp index 65492f58b0158..a5e9ad26fac12 100644 --- a/source/API/SBModuleSpec.cpp +++ b/source/API/SBModuleSpec.cpp @@ -1,13 +1,14 @@ //===-- SBModuleSpec.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBModuleSpec.h" +#include "SBReproducerPrivate.h" +#include "Utils.h" #include "lldb/API/SBStream.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" @@ -18,58 +19,100 @@ using namespace lldb; using namespace lldb_private; -SBModuleSpec::SBModuleSpec() : m_opaque_ap(new lldb_private::ModuleSpec()) {} +SBModuleSpec::SBModuleSpec() : m_opaque_up(new lldb_private::ModuleSpec()) { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBModuleSpec); +} -SBModuleSpec::SBModuleSpec(const SBModuleSpec &rhs) - : m_opaque_ap(new lldb_private::ModuleSpec(*rhs.m_opaque_ap)) {} +SBModuleSpec::SBModuleSpec(const SBModuleSpec &rhs) : m_opaque_up() { + LLDB_RECORD_CONSTRUCTOR(SBModuleSpec, (const lldb::SBModuleSpec &), rhs); + + m_opaque_up = clone(rhs.m_opaque_up); +} const SBModuleSpec &SBModuleSpec::operator=(const SBModuleSpec &rhs) { + LLDB_RECORD_METHOD(const lldb::SBModuleSpec &, + SBModuleSpec, operator=,(const lldb::SBModuleSpec &), rhs); + if (this != &rhs) - *m_opaque_ap = *(rhs.m_opaque_ap); - return *this; + m_opaque_up = clone(rhs.m_opaque_up); + return LLDB_RECORD_RESULT(*this); } SBModuleSpec::~SBModuleSpec() {} -bool SBModuleSpec::IsValid() const { return m_opaque_ap->operator bool(); } +bool SBModuleSpec::IsValid() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBModuleSpec, IsValid); + return this->operator bool(); +} +SBModuleSpec::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBModuleSpec, operator bool); + + return m_opaque_up->operator bool(); +} -void SBModuleSpec::Clear() { m_opaque_ap->Clear(); } +void SBModuleSpec::Clear() { + LLDB_RECORD_METHOD_NO_ARGS(void, SBModuleSpec, Clear); + + m_opaque_up->Clear(); +} SBFileSpec SBModuleSpec::GetFileSpec() { - SBFileSpec sb_spec(m_opaque_ap->GetFileSpec()); - return sb_spec; + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFileSpec, SBModuleSpec, GetFileSpec); + + SBFileSpec sb_spec(m_opaque_up->GetFileSpec()); + return LLDB_RECORD_RESULT(sb_spec); } void SBModuleSpec::SetFileSpec(const lldb::SBFileSpec &sb_spec) { - m_opaque_ap->GetFileSpec() = *sb_spec; + LLDB_RECORD_METHOD(void, SBModuleSpec, SetFileSpec, + (const lldb::SBFileSpec &), sb_spec); + + m_opaque_up->GetFileSpec() = *sb_spec; } lldb::SBFileSpec SBModuleSpec::GetPlatformFileSpec() { - return SBFileSpec(m_opaque_ap->GetPlatformFileSpec()); + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFileSpec, SBModuleSpec, + GetPlatformFileSpec); + + return LLDB_RECORD_RESULT(SBFileSpec(m_opaque_up->GetPlatformFileSpec())); } void SBModuleSpec::SetPlatformFileSpec(const lldb::SBFileSpec &sb_spec) { - m_opaque_ap->GetPlatformFileSpec() = *sb_spec; + LLDB_RECORD_METHOD(void, SBModuleSpec, SetPlatformFileSpec, + (const lldb::SBFileSpec &), sb_spec); + + m_opaque_up->GetPlatformFileSpec() = *sb_spec; } lldb::SBFileSpec SBModuleSpec::GetSymbolFileSpec() { - return SBFileSpec(m_opaque_ap->GetSymbolFileSpec()); + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFileSpec, SBModuleSpec, GetSymbolFileSpec); + + return LLDB_RECORD_RESULT(SBFileSpec(m_opaque_up->GetSymbolFileSpec())); } void SBModuleSpec::SetSymbolFileSpec(const lldb::SBFileSpec &sb_spec) { - m_opaque_ap->GetSymbolFileSpec() = *sb_spec; + LLDB_RECORD_METHOD(void, SBModuleSpec, SetSymbolFileSpec, + (const lldb::SBFileSpec &), sb_spec); + + m_opaque_up->GetSymbolFileSpec() = *sb_spec; } const char *SBModuleSpec::GetObjectName() { - return m_opaque_ap->GetObjectName().GetCString(); + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBModuleSpec, GetObjectName); + + return m_opaque_up->GetObjectName().GetCString(); } void SBModuleSpec::SetObjectName(const char *name) { - m_opaque_ap->GetObjectName().SetCString(name); + LLDB_RECORD_METHOD(void, SBModuleSpec, SetObjectName, (const char *), name); + + m_opaque_up->GetObjectName().SetCString(name); } const char *SBModuleSpec::GetTriple() { - std::string triple(m_opaque_ap->GetArchitecture().GetTriple().str()); + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBModuleSpec, GetTriple); + + std::string triple(m_opaque_up->GetArchitecture().GetTriple().str()); // Unique the string so we don't run into ownership issues since the const // strings put the string into the string pool once and the strings never // comes out @@ -78,82 +121,180 @@ const char *SBModuleSpec::GetTriple() { } void SBModuleSpec::SetTriple(const char *triple) { - m_opaque_ap->GetArchitecture().SetTriple(triple); + LLDB_RECORD_METHOD(void, SBModuleSpec, SetTriple, (const char *), triple); + + m_opaque_up->GetArchitecture().SetTriple(triple); } const uint8_t *SBModuleSpec::GetUUIDBytes() { - return m_opaque_ap->GetUUID().GetBytes().data(); + return m_opaque_up->GetUUID().GetBytes().data(); } size_t SBModuleSpec::GetUUIDLength() { - return m_opaque_ap->GetUUID().GetBytes().size(); + LLDB_RECORD_METHOD_NO_ARGS(size_t, SBModuleSpec, GetUUIDLength); + + return m_opaque_up->GetUUID().GetBytes().size(); } bool SBModuleSpec::SetUUIDBytes(const uint8_t *uuid, size_t uuid_len) { - m_opaque_ap->GetUUID() = UUID::fromOptionalData(uuid, uuid_len); - return m_opaque_ap->GetUUID().IsValid(); + m_opaque_up->GetUUID() = UUID::fromOptionalData(uuid, uuid_len); + return m_opaque_up->GetUUID().IsValid(); } bool SBModuleSpec::GetDescription(lldb::SBStream &description) { - m_opaque_ap->Dump(description.ref()); + LLDB_RECORD_METHOD(bool, SBModuleSpec, GetDescription, (lldb::SBStream &), + description); + + m_opaque_up->Dump(description.ref()); return true; } -SBModuleSpecList::SBModuleSpecList() : m_opaque_ap(new ModuleSpecList()) {} +SBModuleSpecList::SBModuleSpecList() : m_opaque_up(new ModuleSpecList()) { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBModuleSpecList); +} SBModuleSpecList::SBModuleSpecList(const SBModuleSpecList &rhs) - : m_opaque_ap(new ModuleSpecList(*rhs.m_opaque_ap)) {} + : m_opaque_up(new ModuleSpecList(*rhs.m_opaque_up)) { + LLDB_RECORD_CONSTRUCTOR(SBModuleSpecList, (const lldb::SBModuleSpecList &), + rhs); +} SBModuleSpecList &SBModuleSpecList::operator=(const SBModuleSpecList &rhs) { + LLDB_RECORD_METHOD( + lldb::SBModuleSpecList &, + SBModuleSpecList, operator=,(const lldb::SBModuleSpecList &), rhs); + if (this != &rhs) - *m_opaque_ap = *rhs.m_opaque_ap; - return *this; + *m_opaque_up = *rhs.m_opaque_up; + return LLDB_RECORD_RESULT(*this); } SBModuleSpecList::~SBModuleSpecList() {} SBModuleSpecList SBModuleSpecList::GetModuleSpecifications(const char *path) { + LLDB_RECORD_STATIC_METHOD(lldb::SBModuleSpecList, SBModuleSpecList, + GetModuleSpecifications, (const char *), path); + SBModuleSpecList specs; FileSpec file_spec(path); FileSystem::Instance().Resolve(file_spec); Host::ResolveExecutableInBundle(file_spec); - ObjectFile::GetModuleSpecifications(file_spec, 0, 0, *specs.m_opaque_ap); - return specs; + ObjectFile::GetModuleSpecifications(file_spec, 0, 0, *specs.m_opaque_up); + return LLDB_RECORD_RESULT(specs); } void SBModuleSpecList::Append(const SBModuleSpec &spec) { - m_opaque_ap->Append(*spec.m_opaque_ap); + LLDB_RECORD_METHOD(void, SBModuleSpecList, Append, + (const lldb::SBModuleSpec &), spec); + + m_opaque_up->Append(*spec.m_opaque_up); } void SBModuleSpecList::Append(const SBModuleSpecList &spec_list) { - m_opaque_ap->Append(*spec_list.m_opaque_ap); + LLDB_RECORD_METHOD(void, SBModuleSpecList, Append, + (const lldb::SBModuleSpecList &), spec_list); + + m_opaque_up->Append(*spec_list.m_opaque_up); } -size_t SBModuleSpecList::GetSize() { return m_opaque_ap->GetSize(); } +size_t SBModuleSpecList::GetSize() { + LLDB_RECORD_METHOD_NO_ARGS(size_t, SBModuleSpecList, GetSize); + + return m_opaque_up->GetSize(); +} SBModuleSpec SBModuleSpecList::GetSpecAtIndex(size_t i) { + LLDB_RECORD_METHOD(lldb::SBModuleSpec, SBModuleSpecList, GetSpecAtIndex, + (size_t), i); + SBModuleSpec sb_module_spec; - m_opaque_ap->GetModuleSpecAtIndex(i, *sb_module_spec.m_opaque_ap); - return sb_module_spec; + m_opaque_up->GetModuleSpecAtIndex(i, *sb_module_spec.m_opaque_up); + return LLDB_RECORD_RESULT(sb_module_spec); } SBModuleSpec SBModuleSpecList::FindFirstMatchingSpec(const SBModuleSpec &match_spec) { + LLDB_RECORD_METHOD(lldb::SBModuleSpec, SBModuleSpecList, + FindFirstMatchingSpec, (const lldb::SBModuleSpec &), + match_spec); + SBModuleSpec sb_module_spec; - m_opaque_ap->FindMatchingModuleSpec(*match_spec.m_opaque_ap, - *sb_module_spec.m_opaque_ap); - return sb_module_spec; + m_opaque_up->FindMatchingModuleSpec(*match_spec.m_opaque_up, + *sb_module_spec.m_opaque_up); + return LLDB_RECORD_RESULT(sb_module_spec); } SBModuleSpecList SBModuleSpecList::FindMatchingSpecs(const SBModuleSpec &match_spec) { + LLDB_RECORD_METHOD(lldb::SBModuleSpecList, SBModuleSpecList, + FindMatchingSpecs, (const lldb::SBModuleSpec &), + match_spec); + SBModuleSpecList specs; - m_opaque_ap->FindMatchingModuleSpecs(*match_spec.m_opaque_ap, - *specs.m_opaque_ap); - return specs; + m_opaque_up->FindMatchingModuleSpecs(*match_spec.m_opaque_up, + *specs.m_opaque_up); + return LLDB_RECORD_RESULT(specs); } bool SBModuleSpecList::GetDescription(lldb::SBStream &description) { - m_opaque_ap->Dump(description.ref()); + LLDB_RECORD_METHOD(bool, SBModuleSpecList, GetDescription, (lldb::SBStream &), + description); + + m_opaque_up->Dump(description.ref()); return true; } + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBModuleSpec>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBModuleSpec, ()); + LLDB_REGISTER_CONSTRUCTOR(SBModuleSpec, (const lldb::SBModuleSpec &)); + LLDB_REGISTER_METHOD(const lldb::SBModuleSpec &, + SBModuleSpec, operator=,(const lldb::SBModuleSpec &)); + LLDB_REGISTER_METHOD_CONST(bool, SBModuleSpec, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBModuleSpec, operator bool, ()); + LLDB_REGISTER_METHOD(void, SBModuleSpec, Clear, ()); + LLDB_REGISTER_METHOD(lldb::SBFileSpec, SBModuleSpec, GetFileSpec, ()); + LLDB_REGISTER_METHOD(void, SBModuleSpec, SetFileSpec, + (const lldb::SBFileSpec &)); + LLDB_REGISTER_METHOD(lldb::SBFileSpec, SBModuleSpec, GetPlatformFileSpec, + ()); + LLDB_REGISTER_METHOD(void, SBModuleSpec, SetPlatformFileSpec, + (const lldb::SBFileSpec &)); + LLDB_REGISTER_METHOD(lldb::SBFileSpec, SBModuleSpec, GetSymbolFileSpec, ()); + LLDB_REGISTER_METHOD(void, SBModuleSpec, SetSymbolFileSpec, + (const lldb::SBFileSpec &)); + LLDB_REGISTER_METHOD(const char *, SBModuleSpec, GetObjectName, ()); + LLDB_REGISTER_METHOD(void, SBModuleSpec, SetObjectName, (const char *)); + LLDB_REGISTER_METHOD(const char *, SBModuleSpec, GetTriple, ()); + LLDB_REGISTER_METHOD(void, SBModuleSpec, SetTriple, (const char *)); + LLDB_REGISTER_METHOD(size_t, SBModuleSpec, GetUUIDLength, ()); + LLDB_REGISTER_METHOD(bool, SBModuleSpec, GetDescription, + (lldb::SBStream &)); + LLDB_REGISTER_CONSTRUCTOR(SBModuleSpecList, ()); + LLDB_REGISTER_CONSTRUCTOR(SBModuleSpecList, + (const lldb::SBModuleSpecList &)); + LLDB_REGISTER_METHOD( + lldb::SBModuleSpecList &, + SBModuleSpecList, operator=,(const lldb::SBModuleSpecList &)); + LLDB_REGISTER_STATIC_METHOD(lldb::SBModuleSpecList, SBModuleSpecList, + GetModuleSpecifications, (const char *)); + LLDB_REGISTER_METHOD(void, SBModuleSpecList, Append, + (const lldb::SBModuleSpec &)); + LLDB_REGISTER_METHOD(void, SBModuleSpecList, Append, + (const lldb::SBModuleSpecList &)); + LLDB_REGISTER_METHOD(size_t, SBModuleSpecList, GetSize, ()); + LLDB_REGISTER_METHOD(lldb::SBModuleSpec, SBModuleSpecList, GetSpecAtIndex, + (size_t)); + LLDB_REGISTER_METHOD(lldb::SBModuleSpec, SBModuleSpecList, + FindFirstMatchingSpec, (const lldb::SBModuleSpec &)); + LLDB_REGISTER_METHOD(lldb::SBModuleSpecList, SBModuleSpecList, + FindMatchingSpecs, (const lldb::SBModuleSpec &)); + LLDB_REGISTER_METHOD(bool, SBModuleSpecList, GetDescription, + (lldb::SBStream &)); +} + +} +} diff --git a/source/API/SBPlatform.cpp b/source/API/SBPlatform.cpp index aedad871cd208..f3708d8e084f3 100644 --- a/source/API/SBPlatform.cpp +++ b/source/API/SBPlatform.cpp @@ -1,13 +1,13 @@ //===-- SBPlatform.cpp ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBPlatform.h" +#include "SBReproducerPrivate.h" #include "lldb/API/SBError.h" #include "lldb/API/SBFileSpec.h" #include "lldb/API/SBLaunchInfo.h" @@ -26,11 +26,9 @@ using namespace lldb; using namespace lldb_private; -//---------------------------------------------------------------------- // PlatformConnectOptions -//---------------------------------------------------------------------- struct PlatformConnectOptions { - PlatformConnectOptions(const char *url = NULL) + PlatformConnectOptions(const char *url = nullptr) : m_url(), m_rsync_options(), m_rsync_remote_path_prefix(), m_rsync_enabled(false), m_rsync_omit_hostname_from_remote_path(false), m_local_cache_directory() { @@ -48,11 +46,9 @@ struct PlatformConnectOptions { ConstString m_local_cache_directory; }; -//---------------------------------------------------------------------- // PlatformShellCommand -//---------------------------------------------------------------------- struct PlatformShellCommand { - PlatformShellCommand(const char *shell_command = NULL) + PlatformShellCommand(const char *shell_command = nullptr) : m_command(), m_working_dir(), m_status(0), m_signo(0) { if (shell_command && shell_command[0]) m_command = shell_command; @@ -67,31 +63,45 @@ struct PlatformShellCommand { int m_signo; Timeout<std::ratio<1>> m_timeout = llvm::None; }; -//---------------------------------------------------------------------- // SBPlatformConnectOptions -//---------------------------------------------------------------------- SBPlatformConnectOptions::SBPlatformConnectOptions(const char *url) - : m_opaque_ptr(new PlatformConnectOptions(url)) {} + : m_opaque_ptr(new PlatformConnectOptions(url)) { + LLDB_RECORD_CONSTRUCTOR(SBPlatformConnectOptions, (const char *), url); +} SBPlatformConnectOptions::SBPlatformConnectOptions( const SBPlatformConnectOptions &rhs) : m_opaque_ptr(new PlatformConnectOptions()) { + LLDB_RECORD_CONSTRUCTOR(SBPlatformConnectOptions, + (const lldb::SBPlatformConnectOptions &), rhs); + *m_opaque_ptr = *rhs.m_opaque_ptr; } SBPlatformConnectOptions::~SBPlatformConnectOptions() { delete m_opaque_ptr; } void SBPlatformConnectOptions::operator=(const SBPlatformConnectOptions &rhs) { + LLDB_RECORD_METHOD( + void, + SBPlatformConnectOptions, operator=,( + const lldb::SBPlatformConnectOptions &), + rhs); + *m_opaque_ptr = *rhs.m_opaque_ptr; } const char *SBPlatformConnectOptions::GetURL() { + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatformConnectOptions, GetURL); + if (m_opaque_ptr->m_url.empty()) - return NULL; + return nullptr; return m_opaque_ptr->m_url.c_str(); } void SBPlatformConnectOptions::SetURL(const char *url) { + LLDB_RECORD_METHOD(void, SBPlatformConnectOptions, SetURL, (const char *), + url); + if (url && url[0]) m_opaque_ptr->m_url = url; else @@ -99,12 +109,18 @@ void SBPlatformConnectOptions::SetURL(const char *url) { } bool SBPlatformConnectOptions::GetRsyncEnabled() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBPlatformConnectOptions, GetRsyncEnabled); + return m_opaque_ptr->m_rsync_enabled; } void SBPlatformConnectOptions::EnableRsync( const char *options, const char *remote_path_prefix, bool omit_hostname_from_remote_path) { + LLDB_RECORD_METHOD(void, SBPlatformConnectOptions, EnableRsync, + (const char *, const char *, bool), options, + remote_path_prefix, omit_hostname_from_remote_path); + m_opaque_ptr->m_rsync_enabled = true; m_opaque_ptr->m_rsync_omit_hostname_from_remote_path = omit_hostname_from_remote_path; @@ -120,47 +136,66 @@ void SBPlatformConnectOptions::EnableRsync( } void SBPlatformConnectOptions::DisableRsync() { + LLDB_RECORD_METHOD_NO_ARGS(void, SBPlatformConnectOptions, DisableRsync); + m_opaque_ptr->m_rsync_enabled = false; } const char *SBPlatformConnectOptions::GetLocalCacheDirectory() { + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatformConnectOptions, + GetLocalCacheDirectory); + return m_opaque_ptr->m_local_cache_directory.GetCString(); } void SBPlatformConnectOptions::SetLocalCacheDirectory(const char *path) { + LLDB_RECORD_METHOD(void, SBPlatformConnectOptions, SetLocalCacheDirectory, + (const char *), path); + if (path && path[0]) m_opaque_ptr->m_local_cache_directory.SetCString(path); else m_opaque_ptr->m_local_cache_directory = ConstString(); } -//---------------------------------------------------------------------- // SBPlatformShellCommand -//---------------------------------------------------------------------- SBPlatformShellCommand::SBPlatformShellCommand(const char *shell_command) - : m_opaque_ptr(new PlatformShellCommand(shell_command)) {} + : m_opaque_ptr(new PlatformShellCommand(shell_command)) { + LLDB_RECORD_CONSTRUCTOR(SBPlatformShellCommand, (const char *), + shell_command); +} SBPlatformShellCommand::SBPlatformShellCommand( const SBPlatformShellCommand &rhs) : m_opaque_ptr(new PlatformShellCommand()) { + LLDB_RECORD_CONSTRUCTOR(SBPlatformShellCommand, + (const lldb::SBPlatformShellCommand &), rhs); + *m_opaque_ptr = *rhs.m_opaque_ptr; } SBPlatformShellCommand::~SBPlatformShellCommand() { delete m_opaque_ptr; } void SBPlatformShellCommand::Clear() { + LLDB_RECORD_METHOD_NO_ARGS(void, SBPlatformShellCommand, Clear); + m_opaque_ptr->m_output = std::string(); m_opaque_ptr->m_status = 0; m_opaque_ptr->m_signo = 0; } const char *SBPlatformShellCommand::GetCommand() { + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatformShellCommand, GetCommand); + if (m_opaque_ptr->m_command.empty()) - return NULL; + return nullptr; return m_opaque_ptr->m_command.c_str(); } void SBPlatformShellCommand::SetCommand(const char *shell_command) { + LLDB_RECORD_METHOD(void, SBPlatformShellCommand, SetCommand, (const char *), + shell_command); + if (shell_command && shell_command[0]) m_opaque_ptr->m_command = shell_command; else @@ -168,12 +203,18 @@ void SBPlatformShellCommand::SetCommand(const char *shell_command) { } const char *SBPlatformShellCommand::GetWorkingDirectory() { + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatformShellCommand, + GetWorkingDirectory); + if (m_opaque_ptr->m_working_dir.empty()) - return NULL; + return nullptr; return m_opaque_ptr->m_working_dir.c_str(); } void SBPlatformShellCommand::SetWorkingDirectory(const char *path) { + LLDB_RECORD_METHOD(void, SBPlatformShellCommand, SetWorkingDirectory, + (const char *), path); + if (path && path[0]) m_opaque_ptr->m_working_dir = path; else @@ -181,34 +222,52 @@ void SBPlatformShellCommand::SetWorkingDirectory(const char *path) { } uint32_t SBPlatformShellCommand::GetTimeoutSeconds() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBPlatformShellCommand, + GetTimeoutSeconds); + if (m_opaque_ptr->m_timeout) return m_opaque_ptr->m_timeout->count(); return UINT32_MAX; } void SBPlatformShellCommand::SetTimeoutSeconds(uint32_t sec) { + LLDB_RECORD_METHOD(void, SBPlatformShellCommand, SetTimeoutSeconds, + (uint32_t), sec); + if (sec == UINT32_MAX) m_opaque_ptr->m_timeout = llvm::None; else m_opaque_ptr->m_timeout = std::chrono::seconds(sec); } -int SBPlatformShellCommand::GetSignal() { return m_opaque_ptr->m_signo; } +int SBPlatformShellCommand::GetSignal() { + LLDB_RECORD_METHOD_NO_ARGS(int, SBPlatformShellCommand, GetSignal); + + return m_opaque_ptr->m_signo; +} -int SBPlatformShellCommand::GetStatus() { return m_opaque_ptr->m_status; } +int SBPlatformShellCommand::GetStatus() { + LLDB_RECORD_METHOD_NO_ARGS(int, SBPlatformShellCommand, GetStatus); + + return m_opaque_ptr->m_status; +} const char *SBPlatformShellCommand::GetOutput() { + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatformShellCommand, GetOutput); + if (m_opaque_ptr->m_output.empty()) - return NULL; + return nullptr; return m_opaque_ptr->m_output.c_str(); } -//---------------------------------------------------------------------- // SBPlatform -//---------------------------------------------------------------------- -SBPlatform::SBPlatform() : m_opaque_sp() {} +SBPlatform::SBPlatform() : m_opaque_sp() { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBPlatform); +} SBPlatform::SBPlatform(const char *platform_name) : m_opaque_sp() { + LLDB_RECORD_CONSTRUCTOR(SBPlatform, (const char *), platform_name); + Status error; if (platform_name && platform_name[0]) m_opaque_sp = Platform::Create(ConstString(platform_name), error); @@ -216,15 +275,29 @@ SBPlatform::SBPlatform(const char *platform_name) : m_opaque_sp() { SBPlatform::~SBPlatform() {} -bool SBPlatform::IsValid() const { return m_opaque_sp.get() != NULL; } +bool SBPlatform::IsValid() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBPlatform, IsValid); + return this->operator bool(); +} +SBPlatform::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBPlatform, operator bool); + + return m_opaque_sp.get() != nullptr; +} + +void SBPlatform::Clear() { + LLDB_RECORD_METHOD_NO_ARGS(void, SBPlatform, Clear); -void SBPlatform::Clear() { m_opaque_sp.reset(); } + m_opaque_sp.reset(); +} const char *SBPlatform::GetName() { + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatform, GetName); + PlatformSP platform_sp(GetSP()); if (platform_sp) return platform_sp->GetName().GetCString(); - return NULL; + return nullptr; } lldb::PlatformSP SBPlatform::GetSP() const { return m_opaque_sp; } @@ -234,13 +307,18 @@ void SBPlatform::SetSP(const lldb::PlatformSP &platform_sp) { } const char *SBPlatform::GetWorkingDirectory() { + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatform, GetWorkingDirectory); + PlatformSP platform_sp(GetSP()); if (platform_sp) return platform_sp->GetWorkingDirectory().GetCString(); - return NULL; + return nullptr; } bool SBPlatform::SetWorkingDirectory(const char *path) { + LLDB_RECORD_METHOD(bool, SBPlatform, SetWorkingDirectory, (const char *), + path); + PlatformSP platform_sp(GetSP()); if (platform_sp) { if (path) @@ -253,6 +331,9 @@ bool SBPlatform::SetWorkingDirectory(const char *path) { } SBError SBPlatform::ConnectRemote(SBPlatformConnectOptions &connect_options) { + LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, ConnectRemote, + (lldb::SBPlatformConnectOptions &), connect_options); + SBError sb_error; PlatformSP platform_sp(GetSP()); if (platform_sp && connect_options.GetURL()) { @@ -263,16 +344,20 @@ SBError SBPlatform::ConnectRemote(SBPlatformConnectOptions &connect_options) { } else { sb_error.SetErrorString("invalid platform"); } - return sb_error; + return LLDB_RECORD_RESULT(sb_error); } void SBPlatform::DisconnectRemote() { + LLDB_RECORD_METHOD_NO_ARGS(void, SBPlatform, DisconnectRemote); + PlatformSP platform_sp(GetSP()); if (platform_sp) platform_sp->DisconnectRemote(); } bool SBPlatform::IsConnected() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBPlatform, IsConnected); + PlatformSP platform_sp(GetSP()); if (platform_sp) return platform_sp->IsConnected(); @@ -280,6 +365,8 @@ bool SBPlatform::IsConnected() { } const char *SBPlatform::GetTriple() { + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatform, GetTriple); + PlatformSP platform_sp(GetSP()); if (platform_sp) { ArchSpec arch(platform_sp->GetSystemArchitecture()); @@ -289,10 +376,12 @@ const char *SBPlatform::GetTriple() { return ConstString(arch.GetTriple().getTriple().c_str()).GetCString(); } } - return NULL; + return nullptr; } const char *SBPlatform::GetOSBuild() { + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatform, GetOSBuild); + PlatformSP platform_sp(GetSP()); if (platform_sp) { std::string s; @@ -304,10 +393,12 @@ const char *SBPlatform::GetOSBuild() { } } } - return NULL; + return nullptr; } const char *SBPlatform::GetOSDescription() { + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatform, GetOSDescription); + PlatformSP platform_sp(GetSP()); if (platform_sp) { std::string s; @@ -319,17 +410,21 @@ const char *SBPlatform::GetOSDescription() { } } } - return NULL; + return nullptr; } const char *SBPlatform::GetHostname() { + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatform, GetHostname); + PlatformSP platform_sp(GetSP()); if (platform_sp) return platform_sp->GetHostname(); - return NULL; + return nullptr; } uint32_t SBPlatform::GetOSMajorVersion() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBPlatform, GetOSMajorVersion); + llvm::VersionTuple version; if (PlatformSP platform_sp = GetSP()) version = platform_sp->GetOSVersion(); @@ -337,6 +432,8 @@ uint32_t SBPlatform::GetOSMajorVersion() { } uint32_t SBPlatform::GetOSMinorVersion() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBPlatform, GetOSMinorVersion); + llvm::VersionTuple version; if (PlatformSP platform_sp = GetSP()) version = platform_sp->GetOSVersion(); @@ -344,6 +441,8 @@ uint32_t SBPlatform::GetOSMinorVersion() { } uint32_t SBPlatform::GetOSUpdateVersion() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBPlatform, GetOSUpdateVersion); + llvm::VersionTuple version; if (PlatformSP platform_sp = GetSP()) version = platform_sp->GetOSVersion(); @@ -351,6 +450,9 @@ uint32_t SBPlatform::GetOSUpdateVersion() { } SBError SBPlatform::Get(SBFileSpec &src, SBFileSpec &dst) { + LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, Get, + (lldb::SBFileSpec &, lldb::SBFileSpec &), src, dst); + SBError sb_error; PlatformSP platform_sp(GetSP()); if (platform_sp) { @@ -358,50 +460,60 @@ SBError SBPlatform::Get(SBFileSpec &src, SBFileSpec &dst) { } else { sb_error.SetErrorString("invalid platform"); } - return sb_error; + return LLDB_RECORD_RESULT(sb_error); } SBError SBPlatform::Put(SBFileSpec &src, SBFileSpec &dst) { - return ExecuteConnected([&](const lldb::PlatformSP &platform_sp) { - if (src.Exists()) { - uint32_t permissions = FileSystem::Instance().GetPermissions(src.ref()); - if (permissions == 0) { - if (FileSystem::Instance().IsDirectory(src.ref())) - permissions = eFilePermissionsDirectoryDefault; - else - permissions = eFilePermissionsFileDefault; - } - - return platform_sp->PutFile(src.ref(), dst.ref(), permissions); - } - - Status error; - error.SetErrorStringWithFormat("'src' argument doesn't exist: '%s'", - src.ref().GetPath().c_str()); - return error; - }); + LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, Put, + (lldb::SBFileSpec &, lldb::SBFileSpec &), src, dst); + return LLDB_RECORD_RESULT( + ExecuteConnected([&](const lldb::PlatformSP &platform_sp) { + if (src.Exists()) { + uint32_t permissions = + FileSystem::Instance().GetPermissions(src.ref()); + if (permissions == 0) { + if (FileSystem::Instance().IsDirectory(src.ref())) + permissions = eFilePermissionsDirectoryDefault; + else + permissions = eFilePermissionsFileDefault; + } + + return platform_sp->PutFile(src.ref(), dst.ref(), permissions); + } + + Status error; + error.SetErrorStringWithFormat("'src' argument doesn't exist: '%s'", + src.ref().GetPath().c_str()); + return error; + })); } SBError SBPlatform::Install(SBFileSpec &src, SBFileSpec &dst) { - return ExecuteConnected([&](const lldb::PlatformSP &platform_sp) { - if (src.Exists()) - return platform_sp->Install(src.ref(), dst.ref()); + LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, Install, + (lldb::SBFileSpec &, lldb::SBFileSpec &), src, dst); + return LLDB_RECORD_RESULT( + ExecuteConnected([&](const lldb::PlatformSP &platform_sp) { + if (src.Exists()) + return platform_sp->Install(src.ref(), dst.ref()); - Status error; - error.SetErrorStringWithFormat("'src' argument doesn't exist: '%s'", - src.ref().GetPath().c_str()); - return error; - }); + Status error; + error.SetErrorStringWithFormat("'src' argument doesn't exist: '%s'", + src.ref().GetPath().c_str()); + return error; + })); } SBError SBPlatform::Run(SBPlatformShellCommand &shell_command) { - return ExecuteConnected([&](const lldb::PlatformSP &platform_sp) { + LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, Run, + (lldb::SBPlatformShellCommand &), shell_command); + return LLDB_RECORD_RESULT(ExecuteConnected([&](const lldb::PlatformSP + &platform_sp) { const char *command = shell_command.GetCommand(); if (!command) return Status("invalid shell command (empty)"); const char *working_dir = shell_command.GetWorkingDirectory(); - if (working_dir == NULL) { + if (working_dir == nullptr) { working_dir = platform_sp->GetWorkingDirectory().GetCString(); if (working_dir) shell_command.SetWorkingDirectory(working_dir); @@ -411,22 +523,27 @@ SBError SBPlatform::Run(SBPlatformShellCommand &shell_command) { &shell_command.m_opaque_ptr->m_signo, &shell_command.m_opaque_ptr->m_output, shell_command.m_opaque_ptr->m_timeout); - }); + })); } SBError SBPlatform::Launch(SBLaunchInfo &launch_info) { - return ExecuteConnected([&](const lldb::PlatformSP &platform_sp) { - ProcessLaunchInfo info = launch_info.ref(); - Status error = platform_sp->LaunchProcess(info); - launch_info.set_ref(info); - return error; - }); + LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, Launch, (lldb::SBLaunchInfo &), + launch_info); + return LLDB_RECORD_RESULT( + ExecuteConnected([&](const lldb::PlatformSP &platform_sp) { + ProcessLaunchInfo info = launch_info.ref(); + Status error = platform_sp->LaunchProcess(info); + launch_info.set_ref(info); + return error; + })); } SBError SBPlatform::Kill(const lldb::pid_t pid) { - return ExecuteConnected([&](const lldb::PlatformSP &platform_sp) { - return platform_sp->KillProcess(pid); - }); + LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, Kill, (const lldb::pid_t), pid); + return LLDB_RECORD_RESULT( + ExecuteConnected([&](const lldb::PlatformSP &platform_sp) { + return platform_sp->KillProcess(pid); + })); } SBError SBPlatform::ExecuteConnected( @@ -445,6 +562,9 @@ SBError SBPlatform::ExecuteConnected( } SBError SBPlatform::MakeDirectory(const char *path, uint32_t file_permissions) { + LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, MakeDirectory, + (const char *, uint32_t), path, file_permissions); + SBError sb_error; PlatformSP platform_sp(GetSP()); if (platform_sp) { @@ -453,10 +573,13 @@ SBError SBPlatform::MakeDirectory(const char *path, uint32_t file_permissions) { } else { sb_error.SetErrorString("invalid platform"); } - return sb_error; + return LLDB_RECORD_RESULT(sb_error); } uint32_t SBPlatform::GetFilePermissions(const char *path) { + LLDB_RECORD_METHOD(uint32_t, SBPlatform, GetFilePermissions, (const char *), + path); + PlatformSP platform_sp(GetSP()); if (platform_sp) { uint32_t file_permissions = 0; @@ -468,6 +591,9 @@ uint32_t SBPlatform::GetFilePermissions(const char *path) { SBError SBPlatform::SetFilePermissions(const char *path, uint32_t file_permissions) { + LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, SetFilePermissions, + (const char *, uint32_t), path, file_permissions); + SBError sb_error; PlatformSP platform_sp(GetSP()); if (platform_sp) { @@ -476,12 +602,107 @@ SBError SBPlatform::SetFilePermissions(const char *path, } else { sb_error.SetErrorString("invalid platform"); } - return sb_error; + return LLDB_RECORD_RESULT(sb_error); } SBUnixSignals SBPlatform::GetUnixSignals() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBUnixSignals, SBPlatform, + GetUnixSignals); + if (auto platform_sp = GetSP()) - return SBUnixSignals{platform_sp}; + return LLDB_RECORD_RESULT(SBUnixSignals{platform_sp}); + + return LLDB_RECORD_RESULT(SBUnixSignals()); +} + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBPlatformConnectOptions>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBPlatformConnectOptions, (const char *)); + LLDB_REGISTER_CONSTRUCTOR(SBPlatformConnectOptions, + (const lldb::SBPlatformConnectOptions &)); + LLDB_REGISTER_METHOD( + void, + SBPlatformConnectOptions, operator=,( + const lldb::SBPlatformConnectOptions &)); + LLDB_REGISTER_METHOD(const char *, SBPlatformConnectOptions, GetURL, ()); + LLDB_REGISTER_METHOD(void, SBPlatformConnectOptions, SetURL, + (const char *)); + LLDB_REGISTER_METHOD(bool, SBPlatformConnectOptions, GetRsyncEnabled, ()); + LLDB_REGISTER_METHOD(void, SBPlatformConnectOptions, EnableRsync, + (const char *, const char *, bool)); + LLDB_REGISTER_METHOD(void, SBPlatformConnectOptions, DisableRsync, ()); + LLDB_REGISTER_METHOD(const char *, SBPlatformConnectOptions, + GetLocalCacheDirectory, ()); + LLDB_REGISTER_METHOD(void, SBPlatformConnectOptions, SetLocalCacheDirectory, + (const char *)); +} + +template <> +void RegisterMethods<SBPlatformShellCommand>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBPlatformShellCommand, (const char *)); + LLDB_REGISTER_CONSTRUCTOR(SBPlatformShellCommand, + (const lldb::SBPlatformShellCommand &)); + LLDB_REGISTER_METHOD(void, SBPlatformShellCommand, Clear, ()); + LLDB_REGISTER_METHOD(const char *, SBPlatformShellCommand, GetCommand, ()); + LLDB_REGISTER_METHOD(void, SBPlatformShellCommand, SetCommand, + (const char *)); + LLDB_REGISTER_METHOD(const char *, SBPlatformShellCommand, + GetWorkingDirectory, ()); + LLDB_REGISTER_METHOD(void, SBPlatformShellCommand, SetWorkingDirectory, + (const char *)); + LLDB_REGISTER_METHOD(uint32_t, SBPlatformShellCommand, GetTimeoutSeconds, + ()); + LLDB_REGISTER_METHOD(void, SBPlatformShellCommand, SetTimeoutSeconds, + (uint32_t)); + LLDB_REGISTER_METHOD(int, SBPlatformShellCommand, GetSignal, ()); + LLDB_REGISTER_METHOD(int, SBPlatformShellCommand, GetStatus, ()); + LLDB_REGISTER_METHOD(const char *, SBPlatformShellCommand, GetOutput, ()); +} + +template <> +void RegisterMethods<SBPlatform>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBPlatform, ()); + LLDB_REGISTER_CONSTRUCTOR(SBPlatform, (const char *)); + LLDB_REGISTER_METHOD_CONST(bool, SBPlatform, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBPlatform, operator bool, ()); + LLDB_REGISTER_METHOD(void, SBPlatform, Clear, ()); + LLDB_REGISTER_METHOD(const char *, SBPlatform, GetName, ()); + LLDB_REGISTER_METHOD(const char *, SBPlatform, GetWorkingDirectory, ()); + LLDB_REGISTER_METHOD(bool, SBPlatform, SetWorkingDirectory, (const char *)); + LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, ConnectRemote, + (lldb::SBPlatformConnectOptions &)); + LLDB_REGISTER_METHOD(void, SBPlatform, DisconnectRemote, ()); + LLDB_REGISTER_METHOD(bool, SBPlatform, IsConnected, ()); + LLDB_REGISTER_METHOD(const char *, SBPlatform, GetTriple, ()); + LLDB_REGISTER_METHOD(const char *, SBPlatform, GetOSBuild, ()); + LLDB_REGISTER_METHOD(const char *, SBPlatform, GetOSDescription, ()); + LLDB_REGISTER_METHOD(const char *, SBPlatform, GetHostname, ()); + LLDB_REGISTER_METHOD(uint32_t, SBPlatform, GetOSMajorVersion, ()); + LLDB_REGISTER_METHOD(uint32_t, SBPlatform, GetOSMinorVersion, ()); + LLDB_REGISTER_METHOD(uint32_t, SBPlatform, GetOSUpdateVersion, ()); + LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, Get, + (lldb::SBFileSpec &, lldb::SBFileSpec &)); + LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, Put, + (lldb::SBFileSpec &, lldb::SBFileSpec &)); + LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, Install, + (lldb::SBFileSpec &, lldb::SBFileSpec &)); + LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, Run, + (lldb::SBPlatformShellCommand &)); + LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, Launch, + (lldb::SBLaunchInfo &)); + LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, Kill, (const lldb::pid_t)); + LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, MakeDirectory, + (const char *, uint32_t)); + LLDB_REGISTER_METHOD(uint32_t, SBPlatform, GetFilePermissions, + (const char *)); + LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, SetFilePermissions, + (const char *, uint32_t)); + LLDB_REGISTER_METHOD_CONST(lldb::SBUnixSignals, SBPlatform, GetUnixSignals, + ()); +} - return {}; +} } diff --git a/source/API/SBProcess.cpp b/source/API/SBProcess.cpp index cb1124607ec01..4226ff77ecdc3 100644 --- a/source/API/SBProcess.cpp +++ b/source/API/SBProcess.cpp @@ -1,13 +1,13 @@ //===-- SBProcess.cpp -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBProcess.h" +#include "SBReproducerPrivate.h" #include <inttypes.h> @@ -25,7 +25,7 @@ #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/Args.h" -#include "lldb/Utility/Log.h" +#include "lldb/Utility/ProcessInfo.h" #include "lldb/Utility/State.h" #include "lldb/Utility/Stream.h" @@ -49,33 +49,43 @@ using namespace lldb; using namespace lldb_private; -SBProcess::SBProcess() : m_opaque_wp() {} +SBProcess::SBProcess() : m_opaque_wp() { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBProcess); +} -//---------------------------------------------------------------------- // SBProcess constructor -//---------------------------------------------------------------------- -SBProcess::SBProcess(const SBProcess &rhs) : m_opaque_wp(rhs.m_opaque_wp) {} +SBProcess::SBProcess(const SBProcess &rhs) : m_opaque_wp(rhs.m_opaque_wp) { + LLDB_RECORD_CONSTRUCTOR(SBProcess, (const lldb::SBProcess &), rhs); +} SBProcess::SBProcess(const lldb::ProcessSP &process_sp) - : m_opaque_wp(process_sp) {} + : m_opaque_wp(process_sp) { + LLDB_RECORD_CONSTRUCTOR(SBProcess, (const lldb::ProcessSP &), process_sp); +} const SBProcess &SBProcess::operator=(const SBProcess &rhs) { + LLDB_RECORD_METHOD(const lldb::SBProcess &, + SBProcess, operator=,(const lldb::SBProcess &), rhs); + if (this != &rhs) m_opaque_wp = rhs.m_opaque_wp; - return *this; + return LLDB_RECORD_RESULT(*this); } -//---------------------------------------------------------------------- // Destructor -//---------------------------------------------------------------------- SBProcess::~SBProcess() {} const char *SBProcess::GetBroadcasterClassName() { + LLDB_RECORD_STATIC_METHOD_NO_ARGS(const char *, SBProcess, + GetBroadcasterClassName); + return Process::GetStaticBroadcasterClass().AsCString(); } const char *SBProcess::GetPluginName() { + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBProcess, GetPluginName); + ProcessSP process_sp(GetSP()); if (process_sp) { return process_sp->GetPluginName().GetCString(); @@ -84,6 +94,8 @@ const char *SBProcess::GetPluginName() { } const char *SBProcess::GetShortPluginName() { + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBProcess, GetShortPluginName); + ProcessSP process_sp(GetSP()); if (process_sp) { return process_sp->GetPluginName().GetCString(); @@ -95,9 +107,19 @@ lldb::ProcessSP SBProcess::GetSP() const { return m_opaque_wp.lock(); } void SBProcess::SetSP(const ProcessSP &process_sp) { m_opaque_wp = process_sp; } -void SBProcess::Clear() { m_opaque_wp.reset(); } +void SBProcess::Clear() { + LLDB_RECORD_METHOD_NO_ARGS(void, SBProcess, Clear); + + m_opaque_wp.reset(); +} bool SBProcess::IsValid() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBProcess, IsValid); + return this->operator bool(); +} +SBProcess::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBProcess, operator bool); + ProcessSP process_sp(m_opaque_wp.lock()); return ((bool)process_sp && process_sp->IsValid()); } @@ -108,18 +130,12 @@ bool SBProcess::RemoteLaunch(char const **argv, char const **envp, const char *working_directory, uint32_t launch_flags, bool stop_at_entry, lldb::SBError &error) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBProcess(%p)::RemoteLaunch (argv=%p, envp=%p, stdin=%s, " - "stdout=%s, stderr=%s, working-dir=%s, launch_flags=0x%x, " - "stop_at_entry=%i, &error (%p))...", - static_cast<void *>(m_opaque_wp.lock().get()), - static_cast<void *>(argv), static_cast<void *>(envp), - stdin_path ? stdin_path : "NULL", - stdout_path ? stdout_path : "NULL", - stderr_path ? stderr_path : "NULL", - working_directory ? working_directory : "NULL", launch_flags, - stop_at_entry, static_cast<void *>(error.get())); + LLDB_RECORD_METHOD(bool, SBProcess, RemoteLaunch, + (const char **, const char **, const char *, const char *, + const char *, const char *, uint32_t, bool, + lldb::SBError &), + argv, envp, stdin_path, stdout_path, stderr_path, + working_directory, launch_flags, stop_at_entry, error); ProcessSP process_sp(GetSP()); if (process_sp) { @@ -146,19 +162,14 @@ bool SBProcess::RemoteLaunch(char const **argv, char const **envp, error.SetErrorString("unable to attach pid"); } - if (log) { - SBStream sstr; - error.GetDescription(sstr); - log->Printf("SBProcess(%p)::RemoteLaunch (...) => SBError (%p): %s", - static_cast<void *>(process_sp.get()), - static_cast<void *>(error.get()), sstr.GetData()); - } - return error.Success(); } bool SBProcess::RemoteAttachToProcessWithID(lldb::pid_t pid, lldb::SBError &error) { + LLDB_RECORD_METHOD(bool, SBProcess, RemoteAttachToProcessWithID, + (lldb::pid_t, lldb::SBError &), pid, error); + ProcessSP process_sp(GetSP()); if (process_sp) { std::lock_guard<std::recursive_mutex> guard( @@ -175,21 +186,11 @@ bool SBProcess::RemoteAttachToProcessWithID(lldb::pid_t pid, error.SetErrorString("unable to attach pid"); } - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) { - SBStream sstr; - error.GetDescription(sstr); - log->Printf("SBProcess(%p)::RemoteAttachToProcessWithID (%" PRIu64 - ") => SBError (%p): %s", - static_cast<void *>(process_sp.get()), pid, - static_cast<void *>(error.get()), sstr.GetData()); - } - return error.Success(); } uint32_t SBProcess::GetNumThreads() { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBProcess, GetNumThreads); uint32_t num_threads = 0; ProcessSP process_sp(GetSP()); @@ -202,15 +203,12 @@ uint32_t SBProcess::GetNumThreads() { num_threads = process_sp->GetThreadList().GetSize(can_update); } - if (log) - log->Printf("SBProcess(%p)::GetNumThreads () => %d", - static_cast<void *>(process_sp.get()), num_threads); - return num_threads; } SBThread SBProcess::GetSelectedThread() const { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBThread, SBProcess, + GetSelectedThread); SBThread sb_thread; ThreadSP thread_sp; @@ -222,17 +220,13 @@ SBThread SBProcess::GetSelectedThread() const { sb_thread.SetThread(thread_sp); } - if (log) - log->Printf("SBProcess(%p)::GetSelectedThread () => SBThread(%p)", - static_cast<void *>(process_sp.get()), - static_cast<void *>(thread_sp.get())); - - return sb_thread; + return LLDB_RECORD_RESULT(sb_thread); } SBThread SBProcess::CreateOSPluginThread(lldb::tid_t tid, lldb::addr_t context) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(lldb::SBThread, SBProcess, CreateOSPluginThread, + (lldb::tid_t, lldb::addr_t), tid, context); SBThread sb_thread; ThreadSP thread_sp; @@ -244,17 +238,11 @@ SBThread SBProcess::CreateOSPluginThread(lldb::tid_t tid, sb_thread.SetThread(thread_sp); } - if (log) - log->Printf("SBProcess(%p)::CreateOSPluginThread (tid=0x%" PRIx64 - ", context=0x%" PRIx64 ") => SBThread(%p)", - static_cast<void *>(process_sp.get()), tid, context, - static_cast<void *>(thread_sp.get())); - - return sb_thread; + return LLDB_RECORD_RESULT(sb_thread); } SBTarget SBProcess::GetTarget() const { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBTarget, SBProcess, GetTarget); SBTarget sb_target; TargetSP target_sp; @@ -264,16 +252,12 @@ SBTarget SBProcess::GetTarget() const { sb_target.SetSP(target_sp); } - if (log) - log->Printf("SBProcess(%p)::GetTarget () => SBTarget(%p)", - static_cast<void *>(process_sp.get()), - static_cast<void *>(target_sp.get())); - - return sb_target; + return LLDB_RECORD_RESULT(sb_target); } size_t SBProcess::PutSTDIN(const char *src, size_t src_len) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(size_t, SBProcess, PutSTDIN, (const char *, size_t), src, + src_len); size_t ret_val = 0; ProcessSP process_sp(GetSP()); @@ -282,16 +266,13 @@ size_t SBProcess::PutSTDIN(const char *src, size_t src_len) { ret_val = process_sp->PutSTDIN(src, src_len, error); } - if (log) - log->Printf("SBProcess(%p)::PutSTDIN (src=\"%s\", src_len=%" PRIu64 - ") => %" PRIu64, - static_cast<void *>(process_sp.get()), src, - static_cast<uint64_t>(src_len), static_cast<uint64_t>(ret_val)); - return ret_val; } size_t SBProcess::GetSTDOUT(char *dst, size_t dst_len) const { + LLDB_RECORD_METHOD_CONST(size_t, SBProcess, GetSTDOUT, (char *, size_t), dst, + dst_len); + size_t bytes_read = 0; ProcessSP process_sp(GetSP()); if (process_sp) { @@ -299,18 +280,13 @@ size_t SBProcess::GetSTDOUT(char *dst, size_t dst_len) const { bytes_read = process_sp->GetSTDOUT(dst, dst_len, error); } - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf( - "SBProcess(%p)::GetSTDOUT (dst=\"%.*s\", dst_len=%" PRIu64 - ") => %" PRIu64, - static_cast<void *>(process_sp.get()), static_cast<int>(bytes_read), - dst, static_cast<uint64_t>(dst_len), static_cast<uint64_t>(bytes_read)); - return bytes_read; } size_t SBProcess::GetSTDERR(char *dst, size_t dst_len) const { + LLDB_RECORD_METHOD_CONST(size_t, SBProcess, GetSTDERR, (char *, size_t), dst, + dst_len); + size_t bytes_read = 0; ProcessSP process_sp(GetSP()); if (process_sp) { @@ -318,18 +294,13 @@ size_t SBProcess::GetSTDERR(char *dst, size_t dst_len) const { bytes_read = process_sp->GetSTDERR(dst, dst_len, error); } - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf( - "SBProcess(%p)::GetSTDERR (dst=\"%.*s\", dst_len=%" PRIu64 - ") => %" PRIu64, - static_cast<void *>(process_sp.get()), static_cast<int>(bytes_read), - dst, static_cast<uint64_t>(dst_len), static_cast<uint64_t>(bytes_read)); - return bytes_read; } size_t SBProcess::GetAsyncProfileData(char *dst, size_t dst_len) const { + LLDB_RECORD_METHOD_CONST(size_t, SBProcess, GetAsyncProfileData, + (char *, size_t), dst, dst_len); + size_t bytes_read = 0; ProcessSP process_sp(GetSP()); if (process_sp) { @@ -337,20 +308,14 @@ size_t SBProcess::GetAsyncProfileData(char *dst, size_t dst_len) const { bytes_read = process_sp->GetAsyncProfileData(dst, dst_len, error); } - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf( - "SBProcess(%p)::GetAsyncProfileData (dst=\"%.*s\", dst_len=%" PRIu64 - ") => %" PRIu64, - static_cast<void *>(process_sp.get()), static_cast<int>(bytes_read), - dst, static_cast<uint64_t>(dst_len), static_cast<uint64_t>(bytes_read)); - return bytes_read; } lldb::SBTrace SBProcess::StartTrace(SBTraceOptions &options, lldb::SBError &error) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(lldb::SBTrace, SBProcess, StartTrace, + (lldb::SBTraceOptions &, lldb::SBError &), options, error); + ProcessSP process_sp(GetSP()); error.Clear(); SBTrace trace_instance; @@ -362,13 +327,15 @@ lldb::SBTrace SBProcess::StartTrace(SBTraceOptions &options, } else { uid = process_sp->StartTrace(*(options.m_traceoptions_sp), error.ref()); trace_instance.SetTraceUID(uid); - LLDB_LOG(log, "SBProcess::returned uid - {0}", uid); } - return trace_instance; + return LLDB_RECORD_RESULT(trace_instance); } void SBProcess::ReportEventState(const SBEvent &event, FILE *out) const { - if (out == NULL) + LLDB_RECORD_METHOD_CONST(void, SBProcess, ReportEventState, + (const lldb::SBEvent &, FILE *), event, out); + + if (out == nullptr) return; ProcessSP process_sp(GetSP()); @@ -386,6 +353,10 @@ void SBProcess::ReportEventState(const SBEvent &event, FILE *out) const { void SBProcess::AppendEventStateReport(const SBEvent &event, SBCommandReturnObject &result) { + LLDB_RECORD_METHOD(void, SBProcess, AppendEventStateReport, + (const lldb::SBEvent &, lldb::SBCommandReturnObject &), + event, result); + ProcessSP process_sp(GetSP()); if (process_sp) { const StateType event_state = SBProcess::GetStateFromEvent(event); @@ -398,6 +369,9 @@ void SBProcess::AppendEventStateReport(const SBEvent &event, } bool SBProcess::SetSelectedThread(const SBThread &thread) { + LLDB_RECORD_METHOD(bool, SBProcess, SetSelectedThread, + (const lldb::SBThread &), thread); + ProcessSP process_sp(GetSP()); if (process_sp) { std::lock_guard<std::recursive_mutex> guard( @@ -409,7 +383,9 @@ bool SBProcess::SetSelectedThread(const SBThread &thread) { } bool SBProcess::SetSelectedThreadByID(lldb::tid_t tid) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(bool, SBProcess, SetSelectedThreadByID, (lldb::tid_t), + tid); + bool ret_val = false; ProcessSP process_sp(GetSP()); @@ -419,17 +395,12 @@ bool SBProcess::SetSelectedThreadByID(lldb::tid_t tid) { ret_val = process_sp->GetThreadList().SetSelectedThreadByID(tid); } - if (log) - log->Printf("SBProcess(%p)::SetSelectedThreadByID (tid=0x%4.4" PRIx64 - ") => %s", - static_cast<void *>(process_sp.get()), tid, - (ret_val ? "true" : "false")); - return ret_val; } bool SBProcess::SetSelectedThreadByIndexID(uint32_t index_id) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(bool, SBProcess, SetSelectedThreadByIndexID, (uint32_t), + index_id); bool ret_val = false; ProcessSP process_sp(GetSP()); @@ -439,16 +410,13 @@ bool SBProcess::SetSelectedThreadByIndexID(uint32_t index_id) { ret_val = process_sp->GetThreadList().SetSelectedThreadByIndexID(index_id); } - if (log) - log->Printf("SBProcess(%p)::SetSelectedThreadByID (tid=0x%x) => %s", - static_cast<void *>(process_sp.get()), index_id, - (ret_val ? "true" : "false")); return ret_val; } SBThread SBProcess::GetThreadAtIndex(size_t index) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(lldb::SBThread, SBProcess, GetThreadAtIndex, (size_t), + index); SBThread sb_thread; ThreadSP thread_sp; @@ -462,17 +430,11 @@ SBThread SBProcess::GetThreadAtIndex(size_t index) { sb_thread.SetThread(thread_sp); } - if (log) - log->Printf("SBProcess(%p)::GetThreadAtIndex (index=%d) => SBThread(%p)", - static_cast<void *>(process_sp.get()), - static_cast<uint32_t>(index), - static_cast<void *>(thread_sp.get())); - - return sb_thread; + return LLDB_RECORD_RESULT(sb_thread); } uint32_t SBProcess::GetNumQueues() { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBProcess, GetNumQueues); uint32_t num_queues = 0; ProcessSP process_sp(GetSP()); @@ -485,15 +447,12 @@ uint32_t SBProcess::GetNumQueues() { } } - if (log) - log->Printf("SBProcess(%p)::GetNumQueues () => %d", - static_cast<void *>(process_sp.get()), num_queues); - return num_queues; } SBQueue SBProcess::GetQueueAtIndex(size_t index) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(lldb::SBQueue, SBProcess, GetQueueAtIndex, (size_t), + index); SBQueue sb_queue; QueueSP queue_sp; @@ -508,16 +467,13 @@ SBQueue SBProcess::GetQueueAtIndex(size_t index) { } } - if (log) - log->Printf("SBProcess(%p)::GetQueueAtIndex (index=%d) => SBQueue(%p)", - static_cast<void *>(process_sp.get()), - static_cast<uint32_t>(index), - static_cast<void *>(queue_sp.get())); - - return sb_queue; + return LLDB_RECORD_RESULT(sb_queue); } uint32_t SBProcess::GetStopID(bool include_expression_stops) { + LLDB_RECORD_METHOD(uint32_t, SBProcess, GetStopID, (bool), + include_expression_stops); + ProcessSP process_sp(GetSP()); if (process_sp) { std::lock_guard<std::recursive_mutex> guard( @@ -531,7 +487,8 @@ uint32_t SBProcess::GetStopID(bool include_expression_stops) { } SBEvent SBProcess::GetStopEventForStopID(uint32_t stop_id) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(lldb::SBEvent, SBProcess, GetStopEventForStopID, + (uint32_t), stop_id); SBEvent sb_event; EventSP event_sp; @@ -543,16 +500,11 @@ SBEvent SBProcess::GetStopEventForStopID(uint32_t stop_id) { sb_event.reset(event_sp); } - if (log) - log->Printf("SBProcess(%p)::GetStopEventForStopID (stop_id=%" PRIu32 - ") => SBEvent(%p)", - static_cast<void *>(process_sp.get()), stop_id, - static_cast<void *>(event_sp.get())); - - return sb_event; + return LLDB_RECORD_RESULT(sb_event); } StateType SBProcess::GetState() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::StateType, SBProcess, GetState); StateType ret_val = eStateInvalid; ProcessSP process_sp(GetSP()); @@ -562,16 +514,12 @@ StateType SBProcess::GetState() { ret_val = process_sp->GetState(); } - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBProcess(%p)::GetState () => %s", - static_cast<void *>(process_sp.get()), - lldb_private::StateAsCString(ret_val)); - return ret_val; } int SBProcess::GetExitStatus() { + LLDB_RECORD_METHOD_NO_ARGS(int, SBProcess, GetExitStatus); + int exit_status = 0; ProcessSP process_sp(GetSP()); if (process_sp) { @@ -579,94 +527,74 @@ int SBProcess::GetExitStatus() { process_sp->GetTarget().GetAPIMutex()); exit_status = process_sp->GetExitStatus(); } - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBProcess(%p)::GetExitStatus () => %i (0x%8.8x)", - static_cast<void *>(process_sp.get()), exit_status, - exit_status); return exit_status; } const char *SBProcess::GetExitDescription() { - const char *exit_desc = NULL; + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBProcess, GetExitDescription); + + const char *exit_desc = nullptr; ProcessSP process_sp(GetSP()); if (process_sp) { std::lock_guard<std::recursive_mutex> guard( process_sp->GetTarget().GetAPIMutex()); exit_desc = process_sp->GetExitDescription(); } - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBProcess(%p)::GetExitDescription () => %s", - static_cast<void *>(process_sp.get()), exit_desc); return exit_desc; } lldb::pid_t SBProcess::GetProcessID() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::pid_t, SBProcess, GetProcessID); + lldb::pid_t ret_val = LLDB_INVALID_PROCESS_ID; ProcessSP process_sp(GetSP()); if (process_sp) ret_val = process_sp->GetID(); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBProcess(%p)::GetProcessID () => %" PRIu64, - static_cast<void *>(process_sp.get()), ret_val); - return ret_val; } uint32_t SBProcess::GetUniqueID() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBProcess, GetUniqueID); + uint32_t ret_val = 0; ProcessSP process_sp(GetSP()); if (process_sp) ret_val = process_sp->GetUniqueID(); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBProcess(%p)::GetUniqueID () => %" PRIu32, - static_cast<void *>(process_sp.get()), ret_val); return ret_val; } ByteOrder SBProcess::GetByteOrder() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::ByteOrder, SBProcess, GetByteOrder); + ByteOrder byteOrder = eByteOrderInvalid; ProcessSP process_sp(GetSP()); if (process_sp) byteOrder = process_sp->GetTarget().GetArchitecture().GetByteOrder(); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBProcess(%p)::GetByteOrder () => %d", - static_cast<void *>(process_sp.get()), byteOrder); return byteOrder; } uint32_t SBProcess::GetAddressByteSize() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBProcess, GetAddressByteSize); + uint32_t size = 0; ProcessSP process_sp(GetSP()); if (process_sp) size = process_sp->GetTarget().GetArchitecture().GetAddressByteSize(); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBProcess(%p)::GetAddressByteSize () => %d", - static_cast<void *>(process_sp.get()), size); return size; } SBError SBProcess::Continue() { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBProcess, Continue); SBError sb_error; ProcessSP process_sp(GetSP()); - if (log) - log->Printf("SBProcess(%p)::Continue ()...", - static_cast<void *>(process_sp.get())); - if (process_sp) { std::lock_guard<std::recursive_mutex> guard( process_sp->GetTarget().GetAPIMutex()); @@ -674,22 +602,16 @@ SBError SBProcess::Continue() { if (process_sp->GetTarget().GetDebugger().GetAsyncExecution()) sb_error.ref() = process_sp->Resume(); else - sb_error.ref() = process_sp->ResumeSynchronous(NULL); + sb_error.ref() = process_sp->ResumeSynchronous(nullptr); } else sb_error.SetErrorString("SBProcess is invalid"); - if (log) { - SBStream sstr; - sb_error.GetDescription(sstr); - log->Printf("SBProcess(%p)::Continue () => SBError (%p): %s", - static_cast<void *>(process_sp.get()), - static_cast<void *>(sb_error.get()), sstr.GetData()); - } - - return sb_error; + return LLDB_RECORD_RESULT(sb_error); } SBError SBProcess::Destroy() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBProcess, Destroy); + SBError sb_error; ProcessSP process_sp(GetSP()); if (process_sp) { @@ -699,19 +621,12 @@ SBError SBProcess::Destroy() { } else sb_error.SetErrorString("SBProcess is invalid"); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) { - SBStream sstr; - sb_error.GetDescription(sstr); - log->Printf("SBProcess(%p)::Destroy () => SBError (%p): %s", - static_cast<void *>(process_sp.get()), - static_cast<void *>(sb_error.get()), sstr.GetData()); - } - - return sb_error; + return LLDB_RECORD_RESULT(sb_error); } SBError SBProcess::Stop() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBProcess, Stop); + SBError sb_error; ProcessSP process_sp(GetSP()); if (process_sp) { @@ -721,19 +636,12 @@ SBError SBProcess::Stop() { } else sb_error.SetErrorString("SBProcess is invalid"); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) { - SBStream sstr; - sb_error.GetDescription(sstr); - log->Printf("SBProcess(%p)::Stop () => SBError (%p): %s", - static_cast<void *>(process_sp.get()), - static_cast<void *>(sb_error.get()), sstr.GetData()); - } - - return sb_error; + return LLDB_RECORD_RESULT(sb_error); } SBError SBProcess::Kill() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBProcess, Kill); + SBError sb_error; ProcessSP process_sp(GetSP()); if (process_sp) { @@ -743,25 +651,20 @@ SBError SBProcess::Kill() { } else sb_error.SetErrorString("SBProcess is invalid"); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) { - SBStream sstr; - sb_error.GetDescription(sstr); - log->Printf("SBProcess(%p)::Kill () => SBError (%p): %s", - static_cast<void *>(process_sp.get()), - static_cast<void *>(sb_error.get()), sstr.GetData()); - } - - return sb_error; + return LLDB_RECORD_RESULT(sb_error); } SBError SBProcess::Detach() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBProcess, Detach); + // FIXME: This should come from a process default. bool keep_stopped = false; - return Detach(keep_stopped); + return LLDB_RECORD_RESULT(Detach(keep_stopped)); } SBError SBProcess::Detach(bool keep_stopped) { + LLDB_RECORD_METHOD(lldb::SBError, SBProcess, Detach, (bool), keep_stopped); + SBError sb_error; ProcessSP process_sp(GetSP()); if (process_sp) { @@ -771,10 +674,12 @@ SBError SBProcess::Detach(bool keep_stopped) { } else sb_error.SetErrorString("SBProcess is invalid"); - return sb_error; + return LLDB_RECORD_RESULT(sb_error); } SBError SBProcess::Signal(int signo) { + LLDB_RECORD_METHOD(lldb::SBError, SBProcess, Signal, (int), signo); + SBError sb_error; ProcessSP process_sp(GetSP()); if (process_sp) { @@ -783,25 +688,22 @@ SBError SBProcess::Signal(int signo) { sb_error.SetError(process_sp->Signal(signo)); } else sb_error.SetErrorString("SBProcess is invalid"); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) { - SBStream sstr; - sb_error.GetDescription(sstr); - log->Printf("SBProcess(%p)::Signal (signo=%i) => SBError (%p): %s", - static_cast<void *>(process_sp.get()), signo, - static_cast<void *>(sb_error.get()), sstr.GetData()); - } - return sb_error; + + return LLDB_RECORD_RESULT(sb_error); } SBUnixSignals SBProcess::GetUnixSignals() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBUnixSignals, SBProcess, GetUnixSignals); + if (auto process_sp = GetSP()) - return SBUnixSignals{process_sp}; + return LLDB_RECORD_RESULT(SBUnixSignals{process_sp}); - return {}; + return LLDB_RECORD_RESULT(SBUnixSignals{}); } void SBProcess::SendAsyncInterrupt() { + LLDB_RECORD_METHOD_NO_ARGS(void, SBProcess, SendAsyncInterrupt); + ProcessSP process_sp(GetSP()); if (process_sp) { process_sp->SendAsyncInterrupt(); @@ -809,6 +711,9 @@ void SBProcess::SendAsyncInterrupt() { } SBThread SBProcess::GetThreadByID(tid_t tid) { + LLDB_RECORD_METHOD(lldb::SBThread, SBProcess, GetThreadByID, (lldb::tid_t), + tid); + SBThread sb_thread; ThreadSP thread_sp; ProcessSP process_sp(GetSP()); @@ -821,17 +726,13 @@ SBThread SBProcess::GetThreadByID(tid_t tid) { sb_thread.SetThread(thread_sp); } - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBProcess(%p)::GetThreadByID (tid=0x%4.4" PRIx64 - ") => SBThread (%p)", - static_cast<void *>(process_sp.get()), tid, - static_cast<void *>(thread_sp.get())); - - return sb_thread; + return LLDB_RECORD_RESULT(sb_thread); } SBThread SBProcess::GetThreadByIndexID(uint32_t index_id) { + LLDB_RECORD_METHOD(lldb::SBThread, SBProcess, GetThreadByIndexID, (uint32_t), + index_id); + SBThread sb_thread; ThreadSP thread_sp; ProcessSP process_sp(GetSP()); @@ -845,51 +746,48 @@ SBThread SBProcess::GetThreadByIndexID(uint32_t index_id) { sb_thread.SetThread(thread_sp); } - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBProcess(%p)::GetThreadByID (tid=0x%x) => SBThread (%p)", - static_cast<void *>(process_sp.get()), index_id, - static_cast<void *>(thread_sp.get())); - - return sb_thread; + return LLDB_RECORD_RESULT(sb_thread); } StateType SBProcess::GetStateFromEvent(const SBEvent &event) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_STATIC_METHOD(lldb::StateType, SBProcess, GetStateFromEvent, + (const lldb::SBEvent &), event); StateType ret_val = Process::ProcessEventData::GetStateFromEvent(event.get()); - if (log) - log->Printf("SBProcess::GetStateFromEvent (event.sp=%p) => %s", - static_cast<void *>(event.get()), - lldb_private::StateAsCString(ret_val)); - return ret_val; } bool SBProcess::GetRestartedFromEvent(const SBEvent &event) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_STATIC_METHOD(bool, SBProcess, GetRestartedFromEvent, + (const lldb::SBEvent &), event); bool ret_val = Process::ProcessEventData::GetRestartedFromEvent(event.get()); - if (log) - log->Printf("SBProcess::%s (event.sp=%p) => %d", __FUNCTION__, - static_cast<void *>(event.get()), ret_val); - return ret_val; } size_t SBProcess::GetNumRestartedReasonsFromEvent(const lldb::SBEvent &event) { + LLDB_RECORD_STATIC_METHOD(size_t, SBProcess, GetNumRestartedReasonsFromEvent, + (const lldb::SBEvent &), event); + return Process::ProcessEventData::GetNumRestartedReasons(event.get()); } const char * SBProcess::GetRestartedReasonAtIndexFromEvent(const lldb::SBEvent &event, size_t idx) { + LLDB_RECORD_STATIC_METHOD(const char *, SBProcess, + GetRestartedReasonAtIndexFromEvent, + (const lldb::SBEvent &, size_t), event, idx); + return Process::ProcessEventData::GetRestartedReasonAtIndex(event.get(), idx); } SBProcess SBProcess::GetProcessFromEvent(const SBEvent &event) { + LLDB_RECORD_STATIC_METHOD(lldb::SBProcess, SBProcess, GetProcessFromEvent, + (const lldb::SBEvent &), event); + ProcessSP process_sp = Process::ProcessEventData::GetProcessFromEvent(event.get()); if (!process_sp) { @@ -897,24 +795,37 @@ SBProcess SBProcess::GetProcessFromEvent(const SBEvent &event) { process_sp = EventDataStructuredData::GetProcessFromEvent(event.get()); } - return SBProcess(process_sp); + return LLDB_RECORD_RESULT(SBProcess(process_sp)); } bool SBProcess::GetInterruptedFromEvent(const SBEvent &event) { + LLDB_RECORD_STATIC_METHOD(bool, SBProcess, GetInterruptedFromEvent, + (const lldb::SBEvent &), event); + return Process::ProcessEventData::GetInterruptedFromEvent(event.get()); } lldb::SBStructuredData SBProcess::GetStructuredDataFromEvent(const lldb::SBEvent &event) { - return SBStructuredData(event.GetSP()); + LLDB_RECORD_STATIC_METHOD(lldb::SBStructuredData, SBProcess, + GetStructuredDataFromEvent, (const lldb::SBEvent &), + event); + + return LLDB_RECORD_RESULT(SBStructuredData(event.GetSP())); } bool SBProcess::EventIsProcessEvent(const SBEvent &event) { + LLDB_RECORD_STATIC_METHOD(bool, SBProcess, EventIsProcessEvent, + (const lldb::SBEvent &), event); + return (event.GetBroadcasterClass() == SBProcess::GetBroadcasterClass()) && !EventIsStructuredDataEvent(event); } bool SBProcess::EventIsStructuredDataEvent(const lldb::SBEvent &event) { + LLDB_RECORD_STATIC_METHOD(bool, SBProcess, EventIsStructuredDataEvent, + (const lldb::SBEvent &), event); + EventSP event_sp = event.GetSP(); EventData *event_data = event_sp ? event_sp->GetData() : nullptr; return event_data && (event_data->GetFlavor() == @@ -922,38 +833,35 @@ bool SBProcess::EventIsStructuredDataEvent(const lldb::SBEvent &event) { } SBBroadcaster SBProcess::GetBroadcaster() const { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBBroadcaster, SBProcess, + GetBroadcaster); + ProcessSP process_sp(GetSP()); SBBroadcaster broadcaster(process_sp.get(), false); - if (log) - log->Printf("SBProcess(%p)::GetBroadcaster () => SBBroadcaster (%p)", - static_cast<void *>(process_sp.get()), - static_cast<void *>(broadcaster.get())); - return broadcaster; + return LLDB_RECORD_RESULT(broadcaster); } const char *SBProcess::GetBroadcasterClass() { + LLDB_RECORD_STATIC_METHOD_NO_ARGS(const char *, SBProcess, + GetBroadcasterClass); + return Process::GetStaticBroadcasterClass().AsCString(); } size_t SBProcess::ReadMemory(addr_t addr, void *dst, size_t dst_len, SBError &sb_error) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_DUMMY(size_t, SBProcess, ReadMemory, + (lldb::addr_t, void *, size_t, lldb::SBError &), addr, dst, + dst_len, sb_error); size_t bytes_read = 0; ProcessSP process_sp(GetSP()); - if (log) - log->Printf("SBProcess(%p)::ReadMemory (addr=0x%" PRIx64 - ", dst=%p, dst_len=%" PRIu64 ", SBError (%p))...", - static_cast<void *>(process_sp.get()), addr, - static_cast<void *>(dst), static_cast<uint64_t>(dst_len), - static_cast<void *>(sb_error.get())); if (process_sp) { Process::StopLocker stop_locker; @@ -962,31 +870,21 @@ size_t SBProcess::ReadMemory(addr_t addr, void *dst, size_t dst_len, process_sp->GetTarget().GetAPIMutex()); bytes_read = process_sp->ReadMemory(addr, dst, dst_len, sb_error.ref()); } else { - if (log) - log->Printf("SBProcess(%p)::ReadMemory() => error: process is running", - static_cast<void *>(process_sp.get())); sb_error.SetErrorString("process is running"); } } else { sb_error.SetErrorString("SBProcess is invalid"); } - if (log) { - SBStream sstr; - sb_error.GetDescription(sstr); - log->Printf("SBProcess(%p)::ReadMemory (addr=0x%" PRIx64 - ", dst=%p, dst_len=%" PRIu64 ", SBError (%p): %s) => %" PRIu64, - static_cast<void *>(process_sp.get()), addr, - static_cast<void *>(dst), static_cast<uint64_t>(dst_len), - static_cast<void *>(sb_error.get()), sstr.GetData(), - static_cast<uint64_t>(bytes_read)); - } - return bytes_read; } size_t SBProcess::ReadCStringFromMemory(addr_t addr, void *buf, size_t size, lldb::SBError &sb_error) { + LLDB_RECORD_DUMMY(size_t, SBProcess, ReadCStringFromMemory, + (lldb::addr_t, void *, size_t, lldb::SBError &), addr, buf, + size, sb_error); + size_t bytes_read = 0; ProcessSP process_sp(GetSP()); if (process_sp) { @@ -997,11 +895,6 @@ size_t SBProcess::ReadCStringFromMemory(addr_t addr, void *buf, size_t size, bytes_read = process_sp->ReadCStringFromMemory(addr, (char *)buf, size, sb_error.ref()); } else { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBProcess(%p)::ReadCStringFromMemory() => error: process " - "is running", - static_cast<void *>(process_sp.get())); sb_error.SetErrorString("process is running"); } } else { @@ -1012,6 +905,10 @@ size_t SBProcess::ReadCStringFromMemory(addr_t addr, void *buf, size_t size, uint64_t SBProcess::ReadUnsignedFromMemory(addr_t addr, uint32_t byte_size, lldb::SBError &sb_error) { + LLDB_RECORD_METHOD(uint64_t, SBProcess, ReadUnsignedFromMemory, + (lldb::addr_t, uint32_t, lldb::SBError &), addr, byte_size, + sb_error); + uint64_t value = 0; ProcessSP process_sp(GetSP()); if (process_sp) { @@ -1022,11 +919,6 @@ uint64_t SBProcess::ReadUnsignedFromMemory(addr_t addr, uint32_t byte_size, value = process_sp->ReadUnsignedIntegerFromMemory(addr, byte_size, 0, sb_error.ref()); } else { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBProcess(%p)::ReadUnsignedFromMemory() => error: process " - "is running", - static_cast<void *>(process_sp.get())); sb_error.SetErrorString("process is running"); } } else { @@ -1037,6 +929,9 @@ uint64_t SBProcess::ReadUnsignedFromMemory(addr_t addr, uint32_t byte_size, lldb::addr_t SBProcess::ReadPointerFromMemory(addr_t addr, lldb::SBError &sb_error) { + LLDB_RECORD_METHOD(lldb::addr_t, SBProcess, ReadPointerFromMemory, + (lldb::addr_t, lldb::SBError &), addr, sb_error); + lldb::addr_t ptr = LLDB_INVALID_ADDRESS; ProcessSP process_sp(GetSP()); if (process_sp) { @@ -1046,11 +941,6 @@ lldb::addr_t SBProcess::ReadPointerFromMemory(addr_t addr, process_sp->GetTarget().GetAPIMutex()); ptr = process_sp->ReadPointerFromMemory(addr, sb_error.ref()); } else { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBProcess(%p)::ReadPointerFromMemory() => error: process " - "is running", - static_cast<void *>(process_sp.get())); sb_error.SetErrorString("process is running"); } } else { @@ -1061,19 +951,14 @@ lldb::addr_t SBProcess::ReadPointerFromMemory(addr_t addr, size_t SBProcess::WriteMemory(addr_t addr, const void *src, size_t src_len, SBError &sb_error) { - size_t bytes_written = 0; + LLDB_RECORD_DUMMY(size_t, SBProcess, WriteMemory, + (lldb::addr_t, const void *, size_t, lldb::SBError &), addr, + src, src_len, sb_error); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + size_t bytes_written = 0; ProcessSP process_sp(GetSP()); - if (log) - log->Printf("SBProcess(%p)::WriteMemory (addr=0x%" PRIx64 - ", src=%p, src_len=%" PRIu64 ", SBError (%p))...", - static_cast<void *>(process_sp.get()), addr, - static_cast<const void *>(src), static_cast<uint64_t>(src_len), - static_cast<void *>(sb_error.get())); - if (process_sp) { Process::StopLocker stop_locker; if (stop_locker.TryLock(&process_sp->GetRunLock())) { @@ -1082,28 +967,17 @@ size_t SBProcess::WriteMemory(addr_t addr, const void *src, size_t src_len, bytes_written = process_sp->WriteMemory(addr, src, src_len, sb_error.ref()); } else { - if (log) - log->Printf("SBProcess(%p)::WriteMemory() => error: process is running", - static_cast<void *>(process_sp.get())); sb_error.SetErrorString("process is running"); } } - if (log) { - SBStream sstr; - sb_error.GetDescription(sstr); - log->Printf("SBProcess(%p)::WriteMemory (addr=0x%" PRIx64 - ", src=%p, src_len=%" PRIu64 ", SBError (%p): %s) => %" PRIu64, - static_cast<void *>(process_sp.get()), addr, - static_cast<const void *>(src), static_cast<uint64_t>(src_len), - static_cast<void *>(sb_error.get()), sstr.GetData(), - static_cast<uint64_t>(bytes_written)); - } - return bytes_written; } bool SBProcess::GetDescription(SBStream &description) { + LLDB_RECORD_METHOD(bool, SBProcess, GetDescription, (lldb::SBStream &), + description); + Stream &strm = description.ref(); ProcessSP process_sp(GetSP()); @@ -1111,7 +985,7 @@ bool SBProcess::GetDescription(SBStream &description) { char path[PATH_MAX]; GetTarget().GetExecutable().GetPath(path, sizeof(path)); Module *exe_module = process_sp->GetTarget().GetExecutableModulePointer(); - const char *exe_name = NULL; + const char *exe_name = nullptr; if (exe_module) exe_name = exe_module->GetFileSpec().GetFilename().AsCString(); @@ -1127,7 +1001,9 @@ bool SBProcess::GetDescription(SBStream &description) { uint32_t SBProcess::GetNumSupportedHardwareWatchpoints(lldb::SBError &sb_error) const { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_CONST(uint32_t, SBProcess, + GetNumSupportedHardwareWatchpoints, + (lldb::SBError &), sb_error); uint32_t num = 0; ProcessSP process_sp(GetSP()); @@ -1135,9 +1011,6 @@ SBProcess::GetNumSupportedHardwareWatchpoints(lldb::SBError &sb_error) const { std::lock_guard<std::recursive_mutex> guard( process_sp->GetTarget().GetAPIMutex()); sb_error.SetError(process_sp->GetWatchpointSupportInfo(num)); - if (log) - log->Printf("SBProcess(%p)::GetNumSupportedHardwareWatchpoints () => %u", - static_cast<void *>(process_sp.get()), num); } else { sb_error.SetErrorString("SBProcess is invalid"); } @@ -1146,39 +1019,34 @@ SBProcess::GetNumSupportedHardwareWatchpoints(lldb::SBError &sb_error) const { uint32_t SBProcess::LoadImage(lldb::SBFileSpec &sb_remote_image_spec, lldb::SBError &sb_error) { + LLDB_RECORD_METHOD(uint32_t, SBProcess, LoadImage, + (lldb::SBFileSpec &, lldb::SBError &), + sb_remote_image_spec, sb_error); + return LoadImage(SBFileSpec(), sb_remote_image_spec, sb_error); } uint32_t SBProcess::LoadImage(const lldb::SBFileSpec &sb_local_image_spec, const lldb::SBFileSpec &sb_remote_image_spec, lldb::SBError &sb_error) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD( + uint32_t, SBProcess, LoadImage, + (const lldb::SBFileSpec &, const lldb::SBFileSpec &, lldb::SBError &), + sb_local_image_spec, sb_remote_image_spec, sb_error); + ProcessSP process_sp(GetSP()); if (process_sp) { Process::StopLocker stop_locker; if (stop_locker.TryLock(&process_sp->GetRunLock())) { - if (log) - log->Printf("SBProcess(%p)::LoadImage() => calling Platform::LoadImage" - "for: %s", - static_cast<void *>(process_sp.get()), - sb_local_image_spec.GetFilename()); - std::lock_guard<std::recursive_mutex> guard( process_sp->GetTarget().GetAPIMutex()); PlatformSP platform_sp = process_sp->GetTarget().GetPlatform(); return platform_sp->LoadImage(process_sp.get(), *sb_local_image_spec, *sb_remote_image_spec, sb_error.ref()); } else { - if (log) - log->Printf("SBProcess(%p)::LoadImage() => error: process is running", - static_cast<void *>(process_sp.get())); sb_error.SetErrorString("process is running"); } - } else { - if (log) - log->Printf("SBProcess(%p)::LoadImage() => error: called with invalid" - " process", - static_cast<void *>(process_sp.get())); + } else { sb_error.SetErrorString("process is invalid"); } return LLDB_INVALID_IMAGE_TOKEN; @@ -1186,19 +1054,17 @@ uint32_t SBProcess::LoadImage(const lldb::SBFileSpec &sb_local_image_spec, uint32_t SBProcess::LoadImageUsingPaths(const lldb::SBFileSpec &image_spec, SBStringList &paths, - lldb::SBFileSpec &loaded_path, + lldb::SBFileSpec &loaded_path, lldb::SBError &error) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(uint32_t, SBProcess, LoadImageUsingPaths, + (const lldb::SBFileSpec &, lldb::SBStringList &, + lldb::SBFileSpec &, lldb::SBError &), + image_spec, paths, loaded_path, error); + ProcessSP process_sp(GetSP()); if (process_sp) { Process::StopLocker stop_locker; if (stop_locker.TryLock(&process_sp->GetRunLock())) { - if (log) - log->Printf("SBProcess(%p)::LoadImageUsingPaths() => " - "calling Platform::LoadImageUsingPaths for: %s", - static_cast<void *>(process_sp.get()), - image_spec.GetFilename()); - std::lock_guard<std::recursive_mutex> guard( process_sp->GetTarget().GetAPIMutex()); PlatformSP platform_sp = process_sp->GetTarget().GetPlatform(); @@ -1208,34 +1074,26 @@ uint32_t SBProcess::LoadImageUsingPaths(const lldb::SBFileSpec &image_spec, for (size_t i = 0; i < num_paths; i++) paths_vec.push_back(paths.GetStringAtIndex(i)); FileSpec loaded_spec; - - uint32_t token = platform_sp->LoadImageUsingPaths(process_sp.get(), - *image_spec, - paths_vec, - error.ref(), - &loaded_spec); - if (token != LLDB_INVALID_IMAGE_TOKEN) - loaded_path = loaded_spec; - return token; + + uint32_t token = platform_sp->LoadImageUsingPaths( + process_sp.get(), *image_spec, paths_vec, error.ref(), &loaded_spec); + if (token != LLDB_INVALID_IMAGE_TOKEN) + loaded_path = loaded_spec; + return token; } else { - if (log) - log->Printf("SBProcess(%p)::LoadImageUsingPaths() => error: " - "process is running", - static_cast<void *>(process_sp.get())); error.SetErrorString("process is running"); } - } else { - if (log) - log->Printf("SBProcess(%p)::LoadImageUsingPaths() => error: " - "called with invalid process", - static_cast<void *>(process_sp.get())); + } else { error.SetErrorString("process is invalid"); } - + return LLDB_INVALID_IMAGE_TOKEN; } lldb::SBError SBProcess::UnloadImage(uint32_t image_token) { + LLDB_RECORD_METHOD(lldb::SBError, SBProcess, UnloadImage, (uint32_t), + image_token); + lldb::SBError sb_error; ProcessSP process_sp(GetSP()); if (process_sp) { @@ -1247,18 +1105,17 @@ lldb::SBError SBProcess::UnloadImage(uint32_t image_token) { sb_error.SetError( platform_sp->UnloadImage(process_sp.get(), image_token)); } else { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBProcess(%p)::UnloadImage() => error: process is running", - static_cast<void *>(process_sp.get())); sb_error.SetErrorString("process is running"); } } else sb_error.SetErrorString("invalid process"); - return sb_error; + return LLDB_RECORD_RESULT(sb_error); } lldb::SBError SBProcess::SendEventData(const char *event_data) { + LLDB_RECORD_METHOD(lldb::SBError, SBProcess, SendEventData, (const char *), + event_data); + lldb::SBError sb_error; ProcessSP process_sp(GetSP()); if (process_sp) { @@ -1268,19 +1125,16 @@ lldb::SBError SBProcess::SendEventData(const char *event_data) { process_sp->GetTarget().GetAPIMutex()); sb_error.SetError(process_sp->SendEventData(event_data)); } else { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf( - "SBProcess(%p)::SendEventData() => error: process is running", - static_cast<void *>(process_sp.get())); sb_error.SetErrorString("process is running"); } } else sb_error.SetErrorString("invalid process"); - return sb_error; + return LLDB_RECORD_RESULT(sb_error); } uint32_t SBProcess::GetNumExtendedBacktraceTypes() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBProcess, GetNumExtendedBacktraceTypes); + ProcessSP process_sp(GetSP()); if (process_sp && process_sp->GetSystemRuntime()) { SystemRuntime *runtime = process_sp->GetSystemRuntime(); @@ -1290,6 +1144,9 @@ uint32_t SBProcess::GetNumExtendedBacktraceTypes() { } const char *SBProcess::GetExtendedBacktraceTypeAtIndex(uint32_t idx) { + LLDB_RECORD_METHOD(const char *, SBProcess, GetExtendedBacktraceTypeAtIndex, + (uint32_t), idx); + ProcessSP process_sp(GetSP()); if (process_sp && process_sp->GetSystemRuntime()) { SystemRuntime *runtime = process_sp->GetSystemRuntime(); @@ -1297,28 +1154,28 @@ const char *SBProcess::GetExtendedBacktraceTypeAtIndex(uint32_t idx) { runtime->GetExtendedBacktraceTypes(); if (idx < names.size()) { return names[idx].AsCString(); - } else { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBProcess(%p)::GetExtendedBacktraceTypeAtIndex() => " - "error: requested extended backtrace name out of bounds", - static_cast<void *>(process_sp.get())); } } - return NULL; + return nullptr; } SBThreadCollection SBProcess::GetHistoryThreads(addr_t addr) { + LLDB_RECORD_METHOD(lldb::SBThreadCollection, SBProcess, GetHistoryThreads, + (lldb::addr_t), addr); + ProcessSP process_sp(GetSP()); SBThreadCollection threads; if (process_sp) { threads = SBThreadCollection(process_sp->GetHistoryThreads(addr)); } - return threads; + return LLDB_RECORD_RESULT(threads); } bool SBProcess::IsInstrumentationRuntimePresent( InstrumentationRuntimeType type) { + LLDB_RECORD_METHOD(bool, SBProcess, IsInstrumentationRuntimePresent, + (lldb::InstrumentationRuntimeType), type); + ProcessSP process_sp(GetSP()); if (!process_sp) return false; @@ -1333,11 +1190,14 @@ bool SBProcess::IsInstrumentationRuntimePresent( } lldb::SBError SBProcess::SaveCore(const char *file_name) { + LLDB_RECORD_METHOD(lldb::SBError, SBProcess, SaveCore, (const char *), + file_name); + lldb::SBError error; ProcessSP process_sp(GetSP()); if (!process_sp) { error.SetErrorString("SBProcess is invalid"); - return error; + return LLDB_RECORD_RESULT(error); } std::lock_guard<std::recursive_mutex> guard( @@ -1345,17 +1205,21 @@ lldb::SBError SBProcess::SaveCore(const char *file_name) { if (process_sp->GetState() != eStateStopped) { error.SetErrorString("the process is not stopped"); - return error; + return LLDB_RECORD_RESULT(error); } FileSpec core_file(file_name); error.ref() = PluginManager::SaveCore(process_sp, core_file); - return error; + return LLDB_RECORD_RESULT(error); } lldb::SBError SBProcess::GetMemoryRegionInfo(lldb::addr_t load_addr, SBMemoryRegionInfo &sb_region_info) { + LLDB_RECORD_METHOD(lldb::SBError, SBProcess, GetMemoryRegionInfo, + (lldb::addr_t, lldb::SBMemoryRegionInfo &), load_addr, + sb_region_info); + lldb::SBError sb_error; ProcessSP process_sp(GetSP()); if (process_sp) { @@ -1367,20 +1231,18 @@ SBProcess::GetMemoryRegionInfo(lldb::addr_t load_addr, sb_error.ref() = process_sp->GetMemoryRegionInfo(load_addr, sb_region_info.ref()); } else { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf( - "SBProcess(%p)::GetMemoryRegionInfo() => error: process is running", - static_cast<void *>(process_sp.get())); sb_error.SetErrorString("process is running"); } } else { sb_error.SetErrorString("SBProcess is invalid"); } - return sb_error; + return LLDB_RECORD_RESULT(sb_error); } lldb::SBMemoryRegionInfoList SBProcess::GetMemoryRegions() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBMemoryRegionInfoList, SBProcess, + GetMemoryRegions); + lldb::SBMemoryRegionInfoList sb_region_list; ProcessSP process_sp(GetSP()); @@ -1390,23 +1252,153 @@ lldb::SBMemoryRegionInfoList SBProcess::GetMemoryRegions() { process_sp->GetTarget().GetAPIMutex()); process_sp->GetMemoryRegions(sb_region_list.ref()); - } else { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf( - "SBProcess(%p)::GetMemoryRegionInfo() => error: process is running", - static_cast<void *>(process_sp.get())); } - return sb_region_list; + return LLDB_RECORD_RESULT(sb_region_list); } lldb::SBProcessInfo SBProcess::GetProcessInfo() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBProcessInfo, SBProcess, GetProcessInfo); + lldb::SBProcessInfo sb_proc_info; ProcessSP process_sp(GetSP()); ProcessInstanceInfo proc_info; if (process_sp && process_sp->GetProcessInfo(proc_info)) { sb_proc_info.SetProcessInfo(proc_info); } - return sb_proc_info; + return LLDB_RECORD_RESULT(sb_proc_info); +} + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBProcess>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBProcess, ()); + LLDB_REGISTER_CONSTRUCTOR(SBProcess, (const lldb::SBProcess &)); + LLDB_REGISTER_CONSTRUCTOR(SBProcess, (const lldb::ProcessSP &)); + LLDB_REGISTER_METHOD(const lldb::SBProcess &, + SBProcess, operator=,(const lldb::SBProcess &)); + LLDB_REGISTER_STATIC_METHOD(const char *, SBProcess, + GetBroadcasterClassName, ()); + LLDB_REGISTER_METHOD(const char *, SBProcess, GetPluginName, ()); + LLDB_REGISTER_METHOD(const char *, SBProcess, GetShortPluginName, ()); + LLDB_REGISTER_METHOD(void, SBProcess, Clear, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBProcess, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBProcess, operator bool, ()); + LLDB_REGISTER_METHOD(bool, SBProcess, RemoteLaunch, + (const char **, const char **, const char *, + const char *, const char *, const char *, uint32_t, + bool, lldb::SBError &)); + LLDB_REGISTER_METHOD(bool, SBProcess, RemoteAttachToProcessWithID, + (lldb::pid_t, lldb::SBError &)); + LLDB_REGISTER_METHOD(uint32_t, SBProcess, GetNumThreads, ()); + LLDB_REGISTER_METHOD_CONST(lldb::SBThread, SBProcess, GetSelectedThread, + ()); + LLDB_REGISTER_METHOD(lldb::SBThread, SBProcess, CreateOSPluginThread, + (lldb::tid_t, lldb::addr_t)); + LLDB_REGISTER_METHOD_CONST(lldb::SBTarget, SBProcess, GetTarget, ()); + LLDB_REGISTER_METHOD(size_t, SBProcess, PutSTDIN, (const char *, size_t)); + LLDB_REGISTER_METHOD_CONST(size_t, SBProcess, GetSTDOUT, (char *, size_t)); + LLDB_REGISTER_METHOD_CONST(size_t, SBProcess, GetSTDERR, (char *, size_t)); + LLDB_REGISTER_METHOD_CONST(size_t, SBProcess, GetAsyncProfileData, + (char *, size_t)); + LLDB_REGISTER_METHOD(lldb::SBTrace, SBProcess, StartTrace, + (lldb::SBTraceOptions &, lldb::SBError &)); + LLDB_REGISTER_METHOD_CONST(void, SBProcess, ReportEventState, + (const lldb::SBEvent &, FILE *)); + LLDB_REGISTER_METHOD( + void, SBProcess, AppendEventStateReport, + (const lldb::SBEvent &, lldb::SBCommandReturnObject &)); + LLDB_REGISTER_METHOD(bool, SBProcess, SetSelectedThread, + (const lldb::SBThread &)); + LLDB_REGISTER_METHOD(bool, SBProcess, SetSelectedThreadByID, (lldb::tid_t)); + LLDB_REGISTER_METHOD(bool, SBProcess, SetSelectedThreadByIndexID, + (uint32_t)); + LLDB_REGISTER_METHOD(lldb::SBThread, SBProcess, GetThreadAtIndex, (size_t)); + LLDB_REGISTER_METHOD(uint32_t, SBProcess, GetNumQueues, ()); + LLDB_REGISTER_METHOD(lldb::SBQueue, SBProcess, GetQueueAtIndex, (size_t)); + LLDB_REGISTER_METHOD(uint32_t, SBProcess, GetStopID, (bool)); + LLDB_REGISTER_METHOD(lldb::SBEvent, SBProcess, GetStopEventForStopID, + (uint32_t)); + LLDB_REGISTER_METHOD(lldb::StateType, SBProcess, GetState, ()); + LLDB_REGISTER_METHOD(int, SBProcess, GetExitStatus, ()); + LLDB_REGISTER_METHOD(const char *, SBProcess, GetExitDescription, ()); + LLDB_REGISTER_METHOD(lldb::pid_t, SBProcess, GetProcessID, ()); + LLDB_REGISTER_METHOD(uint32_t, SBProcess, GetUniqueID, ()); + LLDB_REGISTER_METHOD_CONST(lldb::ByteOrder, SBProcess, GetByteOrder, ()); + LLDB_REGISTER_METHOD_CONST(uint32_t, SBProcess, GetAddressByteSize, ()); + LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, Continue, ()); + LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, Destroy, ()); + LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, Stop, ()); + LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, Kill, ()); + LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, Detach, ()); + LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, Detach, (bool)); + LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, Signal, (int)); + LLDB_REGISTER_METHOD(lldb::SBUnixSignals, SBProcess, GetUnixSignals, ()); + LLDB_REGISTER_METHOD(void, SBProcess, SendAsyncInterrupt, ()); + LLDB_REGISTER_METHOD(lldb::SBThread, SBProcess, GetThreadByID, + (lldb::tid_t)); + LLDB_REGISTER_METHOD(lldb::SBThread, SBProcess, GetThreadByIndexID, + (uint32_t)); + LLDB_REGISTER_STATIC_METHOD(lldb::StateType, SBProcess, GetStateFromEvent, + (const lldb::SBEvent &)); + LLDB_REGISTER_STATIC_METHOD(bool, SBProcess, GetRestartedFromEvent, + (const lldb::SBEvent &)); + LLDB_REGISTER_STATIC_METHOD(size_t, SBProcess, + GetNumRestartedReasonsFromEvent, + (const lldb::SBEvent &)); + LLDB_REGISTER_STATIC_METHOD(const char *, SBProcess, + GetRestartedReasonAtIndexFromEvent, + (const lldb::SBEvent &, size_t)); + LLDB_REGISTER_STATIC_METHOD(lldb::SBProcess, SBProcess, GetProcessFromEvent, + (const lldb::SBEvent &)); + LLDB_REGISTER_STATIC_METHOD(bool, SBProcess, GetInterruptedFromEvent, + (const lldb::SBEvent &)); + LLDB_REGISTER_STATIC_METHOD(lldb::SBStructuredData, SBProcess, + GetStructuredDataFromEvent, + (const lldb::SBEvent &)); + LLDB_REGISTER_STATIC_METHOD(bool, SBProcess, EventIsProcessEvent, + (const lldb::SBEvent &)); + LLDB_REGISTER_STATIC_METHOD(bool, SBProcess, EventIsStructuredDataEvent, + (const lldb::SBEvent &)); + LLDB_REGISTER_METHOD_CONST(lldb::SBBroadcaster, SBProcess, GetBroadcaster, + ()); + LLDB_REGISTER_STATIC_METHOD(const char *, SBProcess, GetBroadcasterClass, + ()); + LLDB_REGISTER_METHOD(uint64_t, SBProcess, ReadUnsignedFromMemory, + (lldb::addr_t, uint32_t, lldb::SBError &)); + LLDB_REGISTER_METHOD(lldb::addr_t, SBProcess, ReadPointerFromMemory, + (lldb::addr_t, lldb::SBError &)); + LLDB_REGISTER_METHOD(bool, SBProcess, GetDescription, (lldb::SBStream &)); + LLDB_REGISTER_METHOD_CONST(uint32_t, SBProcess, + GetNumSupportedHardwareWatchpoints, + (lldb::SBError &)); + LLDB_REGISTER_METHOD(uint32_t, SBProcess, LoadImage, + (lldb::SBFileSpec &, lldb::SBError &)); + LLDB_REGISTER_METHOD( + uint32_t, SBProcess, LoadImage, + (const lldb::SBFileSpec &, const lldb::SBFileSpec &, lldb::SBError &)); + LLDB_REGISTER_METHOD(uint32_t, SBProcess, LoadImageUsingPaths, + (const lldb::SBFileSpec &, lldb::SBStringList &, + lldb::SBFileSpec &, lldb::SBError &)); + LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, UnloadImage, (uint32_t)); + LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, SendEventData, + (const char *)); + LLDB_REGISTER_METHOD(uint32_t, SBProcess, GetNumExtendedBacktraceTypes, ()); + LLDB_REGISTER_METHOD(const char *, SBProcess, + GetExtendedBacktraceTypeAtIndex, (uint32_t)); + LLDB_REGISTER_METHOD(lldb::SBThreadCollection, SBProcess, GetHistoryThreads, + (lldb::addr_t)); + LLDB_REGISTER_METHOD(bool, SBProcess, IsInstrumentationRuntimePresent, + (lldb::InstrumentationRuntimeType)); + LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, SaveCore, (const char *)); + LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, GetMemoryRegionInfo, + (lldb::addr_t, lldb::SBMemoryRegionInfo &)); + LLDB_REGISTER_METHOD(lldb::SBMemoryRegionInfoList, SBProcess, + GetMemoryRegions, ()); + LLDB_REGISTER_METHOD(lldb::SBProcessInfo, SBProcess, GetProcessInfo, ()); +} + +} } diff --git a/source/API/SBProcessInfo.cpp b/source/API/SBProcessInfo.cpp index 2b3ebfb2465f1..be242ec5872d9 100644 --- a/source/API/SBProcessInfo.cpp +++ b/source/API/SBProcessInfo.cpp @@ -1,145 +1,210 @@ //===-- SBProcessInfo.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBProcessInfo.h" - +#include "SBReproducerPrivate.h" +#include "Utils.h" #include "lldb/API/SBFileSpec.h" -#include "lldb/Target/Process.h" +#include "lldb/Utility/ProcessInfo.h" using namespace lldb; using namespace lldb_private; -SBProcessInfo::SBProcessInfo() : m_opaque_ap() {} +SBProcessInfo::SBProcessInfo() : m_opaque_up() { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBProcessInfo); +} -SBProcessInfo::SBProcessInfo(const SBProcessInfo &rhs) : m_opaque_ap() { - if (rhs.IsValid()) { - ref() = *rhs.m_opaque_ap; - } +SBProcessInfo::SBProcessInfo(const SBProcessInfo &rhs) : m_opaque_up() { + LLDB_RECORD_CONSTRUCTOR(SBProcessInfo, (const lldb::SBProcessInfo &), rhs); + + m_opaque_up = clone(rhs.m_opaque_up); } SBProcessInfo::~SBProcessInfo() {} SBProcessInfo &SBProcessInfo::operator=(const SBProcessInfo &rhs) { - if (this != &rhs) { - if (rhs.IsValid()) - ref() = *rhs.m_opaque_ap; - else - m_opaque_ap.reset(); - } - return *this; + LLDB_RECORD_METHOD(lldb::SBProcessInfo &, + SBProcessInfo, operator=,(const lldb::SBProcessInfo &), + rhs); + + if (this != &rhs) + m_opaque_up = clone(rhs.m_opaque_up); + return LLDB_RECORD_RESULT(*this); } ProcessInstanceInfo &SBProcessInfo::ref() { - if (m_opaque_ap == nullptr) { - m_opaque_ap.reset(new ProcessInstanceInfo()); + if (m_opaque_up == nullptr) { + m_opaque_up.reset(new ProcessInstanceInfo()); } - return *m_opaque_ap; + return *m_opaque_up; } void SBProcessInfo::SetProcessInfo(const ProcessInstanceInfo &proc_info_ref) { ref() = proc_info_ref; } -bool SBProcessInfo::IsValid() const { return m_opaque_ap != nullptr; } +bool SBProcessInfo::IsValid() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBProcessInfo, IsValid); + return this->operator bool(); +} +SBProcessInfo::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBProcessInfo, operator bool); + + return m_opaque_up != nullptr; +} const char *SBProcessInfo::GetName() { + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBProcessInfo, GetName); + const char *name = nullptr; - if (m_opaque_ap) { - name = m_opaque_ap->GetName(); + if (m_opaque_up) { + name = m_opaque_up->GetName(); } return name; } SBFileSpec SBProcessInfo::GetExecutableFile() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFileSpec, SBProcessInfo, + GetExecutableFile); + SBFileSpec file_spec; - if (m_opaque_ap) { - file_spec.SetFileSpec(m_opaque_ap->GetExecutableFile()); + if (m_opaque_up) { + file_spec.SetFileSpec(m_opaque_up->GetExecutableFile()); } - return file_spec; + return LLDB_RECORD_RESULT(file_spec); } lldb::pid_t SBProcessInfo::GetProcessID() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::pid_t, SBProcessInfo, GetProcessID); + lldb::pid_t proc_id = LLDB_INVALID_PROCESS_ID; - if (m_opaque_ap) { - proc_id = m_opaque_ap->GetProcessID(); + if (m_opaque_up) { + proc_id = m_opaque_up->GetProcessID(); } return proc_id; } uint32_t SBProcessInfo::GetUserID() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBProcessInfo, GetUserID); + uint32_t user_id = UINT32_MAX; - if (m_opaque_ap) { - user_id = m_opaque_ap->GetUserID(); + if (m_opaque_up) { + user_id = m_opaque_up->GetUserID(); } return user_id; } uint32_t SBProcessInfo::GetGroupID() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBProcessInfo, GetGroupID); + uint32_t group_id = UINT32_MAX; - if (m_opaque_ap) { - group_id = m_opaque_ap->GetGroupID(); + if (m_opaque_up) { + group_id = m_opaque_up->GetGroupID(); } return group_id; } bool SBProcessInfo::UserIDIsValid() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBProcessInfo, UserIDIsValid); + bool is_valid = false; - if (m_opaque_ap) { - is_valid = m_opaque_ap->UserIDIsValid(); + if (m_opaque_up) { + is_valid = m_opaque_up->UserIDIsValid(); } return is_valid; } bool SBProcessInfo::GroupIDIsValid() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBProcessInfo, GroupIDIsValid); + bool is_valid = false; - if (m_opaque_ap) { - is_valid = m_opaque_ap->GroupIDIsValid(); + if (m_opaque_up) { + is_valid = m_opaque_up->GroupIDIsValid(); } return is_valid; } uint32_t SBProcessInfo::GetEffectiveUserID() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBProcessInfo, GetEffectiveUserID); + uint32_t user_id = UINT32_MAX; - if (m_opaque_ap) { - user_id = m_opaque_ap->GetEffectiveUserID(); + if (m_opaque_up) { + user_id = m_opaque_up->GetEffectiveUserID(); } return user_id; } uint32_t SBProcessInfo::GetEffectiveGroupID() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBProcessInfo, GetEffectiveGroupID); + uint32_t group_id = UINT32_MAX; - if (m_opaque_ap) { - group_id = m_opaque_ap->GetEffectiveGroupID(); + if (m_opaque_up) { + group_id = m_opaque_up->GetEffectiveGroupID(); } return group_id; } bool SBProcessInfo::EffectiveUserIDIsValid() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBProcessInfo, EffectiveUserIDIsValid); + bool is_valid = false; - if (m_opaque_ap) { - is_valid = m_opaque_ap->EffectiveUserIDIsValid(); + if (m_opaque_up) { + is_valid = m_opaque_up->EffectiveUserIDIsValid(); } return is_valid; } bool SBProcessInfo::EffectiveGroupIDIsValid() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBProcessInfo, EffectiveGroupIDIsValid); + bool is_valid = false; - if (m_opaque_ap) { - is_valid = m_opaque_ap->EffectiveGroupIDIsValid(); + if (m_opaque_up) { + is_valid = m_opaque_up->EffectiveGroupIDIsValid(); } return is_valid; } lldb::pid_t SBProcessInfo::GetParentProcessID() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::pid_t, SBProcessInfo, GetParentProcessID); + lldb::pid_t proc_id = LLDB_INVALID_PROCESS_ID; - if (m_opaque_ap) { - proc_id = m_opaque_ap->GetParentProcessID(); + if (m_opaque_up) { + proc_id = m_opaque_up->GetParentProcessID(); } return proc_id; } + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBProcessInfo>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBProcessInfo, ()); + LLDB_REGISTER_CONSTRUCTOR(SBProcessInfo, (const lldb::SBProcessInfo &)); + LLDB_REGISTER_METHOD( + lldb::SBProcessInfo &, + SBProcessInfo, operator=,(const lldb::SBProcessInfo &)); + LLDB_REGISTER_METHOD_CONST(bool, SBProcessInfo, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBProcessInfo, operator bool, ()); + LLDB_REGISTER_METHOD(const char *, SBProcessInfo, GetName, ()); + LLDB_REGISTER_METHOD(lldb::SBFileSpec, SBProcessInfo, GetExecutableFile, + ()); + LLDB_REGISTER_METHOD(lldb::pid_t, SBProcessInfo, GetProcessID, ()); + LLDB_REGISTER_METHOD(uint32_t, SBProcessInfo, GetUserID, ()); + LLDB_REGISTER_METHOD(uint32_t, SBProcessInfo, GetGroupID, ()); + LLDB_REGISTER_METHOD(bool, SBProcessInfo, UserIDIsValid, ()); + LLDB_REGISTER_METHOD(bool, SBProcessInfo, GroupIDIsValid, ()); + LLDB_REGISTER_METHOD(uint32_t, SBProcessInfo, GetEffectiveUserID, ()); + LLDB_REGISTER_METHOD(uint32_t, SBProcessInfo, GetEffectiveGroupID, ()); + LLDB_REGISTER_METHOD(bool, SBProcessInfo, EffectiveUserIDIsValid, ()); + LLDB_REGISTER_METHOD(bool, SBProcessInfo, EffectiveGroupIDIsValid, ()); + LLDB_REGISTER_METHOD(lldb::pid_t, SBProcessInfo, GetParentProcessID, ()); +} + +} +} diff --git a/source/API/SBQueue.cpp b/source/API/SBQueue.cpp index b4a3cd0c52fb9..7d1581c42f60a 100644 --- a/source/API/SBQueue.cpp +++ b/source/API/SBQueue.cpp @@ -1,14 +1,14 @@ //===-- SBQueue.cpp ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include <inttypes.h> +#include "SBReproducerPrivate.h" #include "lldb/API/SBQueue.h" #include "lldb/API/SBProcess.h" @@ -19,7 +19,6 @@ #include "lldb/Target/Queue.h" #include "lldb/Target/QueueItem.h" #include "lldb/Target/Thread.h" -#include "lldb/Utility/Log.h" using namespace lldb; using namespace lldb_private; @@ -50,7 +49,7 @@ public: ~QueueImpl() {} - bool IsValid() { return m_queue_wp.lock() != NULL; } + bool IsValid() { return m_queue_wp.lock() != nullptr; } void Clear() { m_queue_wp.reset(); @@ -71,10 +70,6 @@ public: if (queue_sp) { result = queue_sp->GetID(); } - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBQueue(%p)::GetQueueID () => 0x%" PRIx64, - static_cast<const void *>(this), result); return result; } @@ -84,25 +79,15 @@ public: if (queue_sp) { result = queue_sp->GetIndexID(); } - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBQueueImpl(%p)::GetIndexID () => %d", - static_cast<const void *>(this), result); return result; } const char *GetName() const { - const char *name = NULL; + const char *name = nullptr; lldb::QueueSP queue_sp = m_queue_wp.lock(); if (queue_sp.get()) { name = queue_sp->GetName(); } - - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBQueueImpl(%p)::GetName () => %s", - static_cast<const void *>(this), name ? name : "NULL"); - return name; } @@ -232,12 +217,18 @@ private: }; } -SBQueue::SBQueue() : m_opaque_sp(new QueueImpl()) {} +SBQueue::SBQueue() : m_opaque_sp(new QueueImpl()) { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBQueue); +} SBQueue::SBQueue(const QueueSP &queue_sp) - : m_opaque_sp(new QueueImpl(queue_sp)) {} + : m_opaque_sp(new QueueImpl(queue_sp)) { + LLDB_RECORD_CONSTRUCTOR(SBQueue, (const lldb::QueueSP &), queue_sp); +} SBQueue::SBQueue(const SBQueue &rhs) { + LLDB_RECORD_CONSTRUCTOR(SBQueue, (const lldb::SBQueue &), rhs); + if (&rhs == this) return; @@ -245,25 +236,28 @@ SBQueue::SBQueue(const SBQueue &rhs) { } const lldb::SBQueue &SBQueue::operator=(const lldb::SBQueue &rhs) { + LLDB_RECORD_METHOD(const lldb::SBQueue &, + SBQueue, operator=,(const lldb::SBQueue &), rhs); + m_opaque_sp = rhs.m_opaque_sp; - return *this; + return LLDB_RECORD_RESULT(*this); } SBQueue::~SBQueue() {} bool SBQueue::IsValid() const { - bool is_valid = m_opaque_sp->IsValid(); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBQueue(0x%" PRIx64 ")::IsValid() == %s", - m_opaque_sp->GetQueueID(), is_valid ? "true" : "false"); - return is_valid; + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBQueue, IsValid); + return this->operator bool(); +} +SBQueue::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBQueue, operator bool); + + return m_opaque_sp->IsValid(); } void SBQueue::Clear() { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBQueue(0x%" PRIx64 ")::Clear()", m_opaque_sp->GetQueueID()); + LLDB_RECORD_METHOD_NO_ARGS(void, SBQueue, Clear); + m_opaque_sp->Clear(); } @@ -272,76 +266,94 @@ void SBQueue::SetQueue(const QueueSP &queue_sp) { } lldb::queue_id_t SBQueue::GetQueueID() const { - lldb::queue_id_t qid = m_opaque_sp->GetQueueID(); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBQueue(0x%" PRIx64 ")::GetQueueID() == 0x%" PRIx64, - m_opaque_sp->GetQueueID(), (uint64_t)qid); - return qid; + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::queue_id_t, SBQueue, GetQueueID); + + return m_opaque_sp->GetQueueID(); } uint32_t SBQueue::GetIndexID() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBQueue, GetIndexID); + uint32_t index_id = m_opaque_sp->GetIndexID(); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBQueue(0x%" PRIx64 ")::GetIndexID() == 0x%" PRIx32, - m_opaque_sp->GetQueueID(), index_id); return index_id; } const char *SBQueue::GetName() const { - const char *name = m_opaque_sp->GetName(); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBQueue(0x%" PRIx64 ")::GetName() == %s", - m_opaque_sp->GetQueueID(), name ? name : ""); - return name; + LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBQueue, GetName); + + return m_opaque_sp->GetName(); } uint32_t SBQueue::GetNumThreads() { - uint32_t numthreads = m_opaque_sp->GetNumThreads(); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBQueue(0x%" PRIx64 ")::GetNumThreads() == %d", - m_opaque_sp->GetQueueID(), numthreads); - return numthreads; + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBQueue, GetNumThreads); + + return m_opaque_sp->GetNumThreads(); } SBThread SBQueue::GetThreadAtIndex(uint32_t idx) { + LLDB_RECORD_METHOD(lldb::SBThread, SBQueue, GetThreadAtIndex, (uint32_t), + idx); + SBThread th = m_opaque_sp->GetThreadAtIndex(idx); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBQueue(0x%" PRIx64 ")::GetThreadAtIndex(%d)", - m_opaque_sp->GetQueueID(), idx); - return th; + return LLDB_RECORD_RESULT(th); } uint32_t SBQueue::GetNumPendingItems() { - uint32_t pending_items = m_opaque_sp->GetNumPendingItems(); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBQueue(0x%" PRIx64 ")::GetNumPendingItems() == %d", - m_opaque_sp->GetQueueID(), pending_items); - return pending_items; + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBQueue, GetNumPendingItems); + + return m_opaque_sp->GetNumPendingItems(); } SBQueueItem SBQueue::GetPendingItemAtIndex(uint32_t idx) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBQueue(0x%" PRIx64 ")::GetPendingItemAtIndex(%d)", - m_opaque_sp->GetQueueID(), idx); - return m_opaque_sp->GetPendingItemAtIndex(idx); + LLDB_RECORD_METHOD(lldb::SBQueueItem, SBQueue, GetPendingItemAtIndex, + (uint32_t), idx); + + return LLDB_RECORD_RESULT(m_opaque_sp->GetPendingItemAtIndex(idx)); } uint32_t SBQueue::GetNumRunningItems() { - uint32_t running_items = m_opaque_sp->GetNumRunningItems(); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBQueue(0x%" PRIx64 ")::GetNumRunningItems() == %d", - m_opaque_sp->GetQueueID(), running_items); - return running_items; + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBQueue, GetNumRunningItems); + + return m_opaque_sp->GetNumRunningItems(); +} + +SBProcess SBQueue::GetProcess() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBProcess, SBQueue, GetProcess); + + return LLDB_RECORD_RESULT(m_opaque_sp->GetProcess()); } -SBProcess SBQueue::GetProcess() { return m_opaque_sp->GetProcess(); } +lldb::QueueKind SBQueue::GetKind() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::QueueKind, SBQueue, GetKind); -lldb::QueueKind SBQueue::GetKind() { return m_opaque_sp->GetKind(); } + return m_opaque_sp->GetKind(); +} + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBQueue>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBQueue, ()); + LLDB_REGISTER_CONSTRUCTOR(SBQueue, (const lldb::QueueSP &)); + LLDB_REGISTER_CONSTRUCTOR(SBQueue, (const lldb::SBQueue &)); + LLDB_REGISTER_METHOD(const lldb::SBQueue &, + SBQueue, operator=,(const lldb::SBQueue &)); + LLDB_REGISTER_METHOD_CONST(bool, SBQueue, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBQueue, operator bool, ()); + LLDB_REGISTER_METHOD(void, SBQueue, Clear, ()); + LLDB_REGISTER_METHOD_CONST(lldb::queue_id_t, SBQueue, GetQueueID, ()); + LLDB_REGISTER_METHOD_CONST(uint32_t, SBQueue, GetIndexID, ()); + LLDB_REGISTER_METHOD_CONST(const char *, SBQueue, GetName, ()); + LLDB_REGISTER_METHOD(uint32_t, SBQueue, GetNumThreads, ()); + LLDB_REGISTER_METHOD(lldb::SBThread, SBQueue, GetThreadAtIndex, (uint32_t)); + LLDB_REGISTER_METHOD(uint32_t, SBQueue, GetNumPendingItems, ()); + LLDB_REGISTER_METHOD(lldb::SBQueueItem, SBQueue, GetPendingItemAtIndex, + (uint32_t)); + LLDB_REGISTER_METHOD(uint32_t, SBQueue, GetNumRunningItems, ()); + LLDB_REGISTER_METHOD(lldb::SBProcess, SBQueue, GetProcess, ()); + LLDB_REGISTER_METHOD(lldb::QueueKind, SBQueue, GetKind, ()); +} + +} +} diff --git a/source/API/SBQueueItem.cpp b/source/API/SBQueueItem.cpp index aac5844240fba..5f2cbd1bdbfb9 100644 --- a/source/API/SBQueueItem.cpp +++ b/source/API/SBQueueItem.cpp @@ -1,14 +1,14 @@ //===-- SBQueueItem.cpp -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/lldb-forward.h" +#include "SBReproducerPrivate.h" #include "lldb/API/SBAddress.h" #include "lldb/API/SBQueueItem.h" #include "lldb/API/SBThread.h" @@ -16,93 +16,88 @@ #include "lldb/Target/Process.h" #include "lldb/Target/QueueItem.h" #include "lldb/Target/Thread.h" -#include "lldb/Utility/Log.h" using namespace lldb; using namespace lldb_private; -//---------------------------------------------------------------------- // Constructors -//---------------------------------------------------------------------- -SBQueueItem::SBQueueItem() : m_queue_item_sp() {} +SBQueueItem::SBQueueItem() : m_queue_item_sp() { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBQueueItem); +} SBQueueItem::SBQueueItem(const QueueItemSP &queue_item_sp) - : m_queue_item_sp(queue_item_sp) {} + : m_queue_item_sp(queue_item_sp) { + LLDB_RECORD_CONSTRUCTOR(SBQueueItem, (const lldb::QueueItemSP &), + queue_item_sp); +} -//---------------------------------------------------------------------- // Destructor -//---------------------------------------------------------------------- SBQueueItem::~SBQueueItem() { m_queue_item_sp.reset(); } bool SBQueueItem::IsValid() const { - bool is_valid = m_queue_item_sp.get() != NULL; - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBQueueItem(%p)::IsValid() == %s", - static_cast<void *>(m_queue_item_sp.get()), - is_valid ? "true" : "false"); - return is_valid; + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBQueueItem, IsValid); + return this->operator bool(); +} +SBQueueItem::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBQueueItem, operator bool); + + return m_queue_item_sp.get() != nullptr; } void SBQueueItem::Clear() { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBQueueItem(%p)::Clear()", - static_cast<void *>(m_queue_item_sp.get())); + LLDB_RECORD_METHOD_NO_ARGS(void, SBQueueItem, Clear); + m_queue_item_sp.reset(); } void SBQueueItem::SetQueueItem(const QueueItemSP &queue_item_sp) { + LLDB_RECORD_METHOD(void, SBQueueItem, SetQueueItem, + (const lldb::QueueItemSP &), queue_item_sp); + m_queue_item_sp = queue_item_sp; } lldb::QueueItemKind SBQueueItem::GetKind() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::QueueItemKind, SBQueueItem, GetKind); + QueueItemKind result = eQueueItemKindUnknown; - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); if (m_queue_item_sp) { result = m_queue_item_sp->GetKind(); } - if (log) - log->Printf("SBQueueItem(%p)::GetKind() == %d", - static_cast<void *>(m_queue_item_sp.get()), - static_cast<int>(result)); return result; } void SBQueueItem::SetKind(lldb::QueueItemKind kind) { + LLDB_RECORD_METHOD(void, SBQueueItem, SetKind, (lldb::QueueItemKind), kind); + if (m_queue_item_sp) { m_queue_item_sp->SetKind(kind); } } SBAddress SBQueueItem::GetAddress() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBAddress, SBQueueItem, GetAddress); + SBAddress result; - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); if (m_queue_item_sp) { result.SetAddress(&m_queue_item_sp->GetAddress()); } - if (log) { - StreamString sstr; - const Address *addr = result.get(); - if (addr) - addr->Dump(&sstr, NULL, Address::DumpStyleModuleWithFileAddress, - Address::DumpStyleInvalid, 4); - log->Printf("SBQueueItem(%p)::GetAddress() == SBAddress(%p): %s", - static_cast<void *>(m_queue_item_sp.get()), - static_cast<void *>(result.get()), sstr.GetData()); - } - return result; + return LLDB_RECORD_RESULT(result); } void SBQueueItem::SetAddress(SBAddress addr) { + LLDB_RECORD_METHOD(void, SBQueueItem, SetAddress, (lldb::SBAddress), addr); + if (m_queue_item_sp) { m_queue_item_sp->SetAddress(addr.ref()); } } SBThread SBQueueItem::GetExtendedBacktraceThread(const char *type) { + LLDB_RECORD_METHOD(lldb::SBThread, SBQueueItem, GetExtendedBacktraceThread, + (const char *), type); + SBThread result; - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); if (m_queue_item_sp) { ProcessSP process_sp = m_queue_item_sp->GetProcessSP(); Process::StopLocker stop_locker; @@ -115,19 +110,31 @@ SBThread SBQueueItem::GetExtendedBacktraceThread(const char *type) { // retains the object process_sp->GetExtendedThreadList().AddThread(thread_sp); result.SetThread(thread_sp); - if (log) { - const char *queue_name = thread_sp->GetQueueName(); - if (queue_name == NULL) - queue_name = ""; - log->Printf( - "SBQueueItem(%p)::GetExtendedBacktraceThread() = new extended " - "Thread created (%p) with queue_id 0x%" PRIx64 " queue name '%s'", - static_cast<void *>(m_queue_item_sp.get()), - static_cast<void *>(thread_sp.get()), - static_cast<uint64_t>(thread_sp->GetQueueID()), queue_name); - } } } } - return result; + return LLDB_RECORD_RESULT(result); +} + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBQueueItem>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBQueueItem, ()); + LLDB_REGISTER_CONSTRUCTOR(SBQueueItem, (const lldb::QueueItemSP &)); + LLDB_REGISTER_METHOD_CONST(bool, SBQueueItem, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBQueueItem, operator bool, ()); + LLDB_REGISTER_METHOD(void, SBQueueItem, Clear, ()); + LLDB_REGISTER_METHOD(void, SBQueueItem, SetQueueItem, + (const lldb::QueueItemSP &)); + LLDB_REGISTER_METHOD_CONST(lldb::QueueItemKind, SBQueueItem, GetKind, ()); + LLDB_REGISTER_METHOD(void, SBQueueItem, SetKind, (lldb::QueueItemKind)); + LLDB_REGISTER_METHOD_CONST(lldb::SBAddress, SBQueueItem, GetAddress, ()); + LLDB_REGISTER_METHOD(void, SBQueueItem, SetAddress, (lldb::SBAddress)); + LLDB_REGISTER_METHOD(lldb::SBThread, SBQueueItem, + GetExtendedBacktraceThread, (const char *)); +} + +} } diff --git a/source/API/SBReproducer.cpp b/source/API/SBReproducer.cpp new file mode 100644 index 0000000000000..439ee5a704603 --- /dev/null +++ b/source/API/SBReproducer.cpp @@ -0,0 +1,153 @@ +//===-- SBReproducer.cpp ----------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "SBReproducerPrivate.h" + +#include "SBReproducerPrivate.h" +#include "lldb/API/LLDB.h" +#include "lldb/API/SBAddress.h" +#include "lldb/API/SBAttachInfo.h" +#include "lldb/API/SBBlock.h" +#include "lldb/API/SBBreakpoint.h" +#include "lldb/API/SBCommandInterpreter.h" +#include "lldb/API/SBData.h" +#include "lldb/API/SBDebugger.h" +#include "lldb/API/SBDeclaration.h" +#include "lldb/API/SBError.h" +#include "lldb/API/SBFileSpec.h" +#include "lldb/API/SBHostOS.h" +#include "lldb/API/SBReproducer.h" + +#include "lldb/Host/FileSystem.h" + +using namespace lldb; +using namespace lldb_private; +using namespace lldb_private::repro; + +SBRegistry::SBRegistry() { + Registry& R = *this; + + RegisterMethods<SBAddress>(R); + RegisterMethods<SBAttachInfo>(R); + RegisterMethods<SBBlock>(R); + RegisterMethods<SBBreakpoint>(R); + RegisterMethods<SBBreakpointList>(R); + RegisterMethods<SBBreakpointLocation>(R); + RegisterMethods<SBBreakpointName>(R); + RegisterMethods<SBBroadcaster>(R); + RegisterMethods<SBCommandInterpreterRunOptions>(R); + RegisterMethods<SBCommandReturnObject>(R); + RegisterMethods<SBCommunication>(R); + RegisterMethods<SBCompileUnit>(R); + RegisterMethods<SBData>(R); + RegisterMethods<SBInputReader>(R); + RegisterMethods<SBDebugger>(R); + RegisterMethods<SBDeclaration>(R); + RegisterMethods<SBError>(R); + RegisterMethods<SBEvent>(R); + RegisterMethods<SBExecutionContext>(R); + RegisterMethods<SBExpressionOptions>(R); + RegisterMethods<SBFileSpec>(R); + RegisterMethods<SBFileSpecList>(R); + RegisterMethods<SBFrame>(R); + RegisterMethods<SBFunction>(R); + RegisterMethods<SBHostOS>(R); + RegisterMethods<SBInstruction>(R); + RegisterMethods<SBInstructionList>(R); + RegisterMethods<SBLanguageRuntime>(R); + RegisterMethods<SBLaunchInfo>(R); + RegisterMethods<SBLineEntry>(R); + RegisterMethods<SBListener>(R); + RegisterMethods<SBMemoryRegionInfo>(R); + RegisterMethods<SBMemoryRegionInfoList>(R); + RegisterMethods<SBModule>(R); + RegisterMethods<SBModuleSpec>(R); + RegisterMethods<SBPlatformConnectOptions>(R); + RegisterMethods<SBPlatformShellCommand>(R); + RegisterMethods<SBPlatform>(R); + RegisterMethods<SBProcess>(R); + RegisterMethods<SBProcessInfo>(R); + RegisterMethods<SBQueue>(R); + RegisterMethods<SBQueueItem>(R); + RegisterMethods<SBSection>(R); + RegisterMethods<SBSourceManager>(R); + RegisterMethods<SBStream>(R); + RegisterMethods<SBStringList>(R); + RegisterMethods<SBStructuredData>(R); + RegisterMethods<SBSymbol>(R); + RegisterMethods<SBSymbolContext>(R); + RegisterMethods<SBSymbolContextList>(R); + RegisterMethods<SBTarget>(R); + RegisterMethods<SBThread>(R); + RegisterMethods<SBThreadCollection>(R); + RegisterMethods<SBThreadPlan>(R); + RegisterMethods<SBTrace>(R); + RegisterMethods<SBTraceOptions>(R); + RegisterMethods<SBType>(R); + RegisterMethods<SBTypeCategory>(R); + RegisterMethods<SBTypeEnumMember>(R); + RegisterMethods<SBTypeFilter>(R); + RegisterMethods<SBTypeFormat>(R); + RegisterMethods<SBTypeNameSpecifier>(R); + RegisterMethods<SBTypeSummaryOptions>(R); + RegisterMethods<SBTypeSummary>(R); + RegisterMethods<SBTypeSynthetic>(R); + RegisterMethods<SBUnixSignals>(R); + RegisterMethods<SBValue>(R); + RegisterMethods<SBValueList>(R); + RegisterMethods<SBVariablesOptions>(R); + RegisterMethods<SBWatchpoint>(R); +} + +const char *SBReproducer::Capture() { + static std::string error; + if (auto e = Reproducer::Initialize(ReproducerMode::Capture, llvm::None)) { + error = llvm::toString(std::move(e)); + return error.c_str(); + } + return nullptr; +} + +const char *SBReproducer::Capture(const char *path) { + static std::string error; + if (auto e = + Reproducer::Initialize(ReproducerMode::Capture, FileSpec(path))) { + error = llvm::toString(std::move(e)); + return error.c_str(); + } + return nullptr; +} + +const char *SBReproducer::Replay(const char *path) { + static std::string error; + if (auto e = Reproducer::Initialize(ReproducerMode::Replay, FileSpec(path))) { + error = llvm::toString(std::move(e)); + return error.c_str(); + } + + repro::Loader *loader = repro::Reproducer::Instance().GetLoader(); + if (!loader) { + error = "unable to get replay loader."; + return error.c_str(); + } + + FileSpec file = loader->GetFile<SBProvider::Info>(); + if (!file) { + error = "unable to get replay data from reproducer."; + return error.c_str(); + } + + SBRegistry registry; + registry.Replay(file); + + return nullptr; +} + +char lldb_private::repro::SBProvider::ID = 0; +const char *SBProvider::Info::name = "sbapi"; +const char *SBProvider::Info::file = "sbapi.bin"; diff --git a/source/API/SBReproducerPrivate.h b/source/API/SBReproducerPrivate.h new file mode 100644 index 0000000000000..84b6ce967c0be --- /dev/null +++ b/source/API/SBReproducerPrivate.h @@ -0,0 +1,75 @@ +//===-- SBReproducerPrivate.h -----------------------------------*- C++ -*-===// +// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_API_SBREPRODUCER_PRIVATE_H +#define LLDB_API_SBREPRODUCER_PRIVATE_H + +#include "lldb/API/SBReproducer.h" + +#include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/Reproducer.h" +#include "lldb/Utility/ReproducerInstrumentation.h" + +#include "llvm/ADT/DenseMap.h" + +#define LLDB_GET_INSTRUMENTATION_DATA() \ + lldb_private::repro::GetInstrumentationData() + +namespace lldb_private { +namespace repro { + +class SBRegistry : public Registry { +public: + SBRegistry(); +}; + +class SBProvider : public Provider<SBProvider> { +public: + struct Info { + static const char *name; + static const char *file; + }; + + SBProvider(const FileSpec &directory) + : Provider(directory), + m_stream(directory.CopyByAppendingPathComponent("sbapi.bin").GetPath(), + m_ec, llvm::sys::fs::OpenFlags::F_None), + m_serializer(m_stream) {} + + Serializer &GetSerializer() { return m_serializer; } + Registry &GetRegistry() { return m_registry; } + + static char ID; + +private: + std::error_code m_ec; + llvm::raw_fd_ostream m_stream; + Serializer m_serializer; + SBRegistry m_registry; +}; + +inline InstrumentationData GetInstrumentationData() { + if (!lldb_private::repro::Reproducer::Initialized()) + return {}; + + if (auto *g = lldb_private::repro::Reproducer::Instance().GetGenerator()) { + auto &p = g->GetOrCreate<SBProvider>(); + return {p.GetSerializer(), p.GetRegistry()}; + } + + return {}; +} + +template <typename T> void RegisterMethods(Registry &R); + +} // namespace repro +} // namespace lldb_private + +#endif diff --git a/source/API/SBSection.cpp b/source/API/SBSection.cpp index 7193857d1281e..14e1e14f59aa1 100644 --- a/source/API/SBSection.cpp +++ b/source/API/SBSection.cpp @@ -1,13 +1,13 @@ //===-- SBSection.cpp -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBSection.h" +#include "SBReproducerPrivate.h" #include "lldb/API/SBStream.h" #include "lldb/API/SBTarget.h" #include "lldb/Core/Module.h" @@ -15,15 +15,18 @@ #include "lldb/Symbol/ObjectFile.h" #include "lldb/Utility/DataBuffer.h" #include "lldb/Utility/DataExtractor.h" -#include "lldb/Utility/Log.h" #include "lldb/Utility/StreamString.h" using namespace lldb; using namespace lldb_private; -SBSection::SBSection() : m_opaque_wp() {} +SBSection::SBSection() : m_opaque_wp() { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBSection); +} -SBSection::SBSection(const SBSection &rhs) : m_opaque_wp(rhs.m_opaque_wp) {} +SBSection::SBSection(const SBSection &rhs) : m_opaque_wp(rhs.m_opaque_wp) { + LLDB_RECORD_CONSTRUCTOR(SBSection, (const lldb::SBSection &), rhs); +} SBSection::SBSection(const lldb::SectionSP §ion_sp) : m_opaque_wp() // Don't init with section_sp otherwise this will throw if @@ -34,25 +37,38 @@ SBSection::SBSection(const lldb::SectionSP §ion_sp) } const SBSection &SBSection::operator=(const SBSection &rhs) { + LLDB_RECORD_METHOD(const lldb::SBSection &, + SBSection, operator=,(const lldb::SBSection &), rhs); + m_opaque_wp = rhs.m_opaque_wp; - return *this; + return LLDB_RECORD_RESULT(*this); } SBSection::~SBSection() {} bool SBSection::IsValid() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBSection, IsValid); + return this->operator bool(); +} +SBSection::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBSection, operator bool); + SectionSP section_sp(GetSP()); - return section_sp && section_sp->GetModule().get() != NULL; + return section_sp && section_sp->GetModule().get() != nullptr; } const char *SBSection::GetName() { + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBSection, GetName); + SectionSP section_sp(GetSP()); if (section_sp) return section_sp->GetName().GetCString(); - return NULL; + return nullptr; } lldb::SBSection SBSection::GetParent() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBSection, SBSection, GetParent); + lldb::SBSection sb_section; SectionSP section_sp(GetSP()); if (section_sp) { @@ -60,10 +76,13 @@ lldb::SBSection SBSection::GetParent() { if (parent_section_sp) sb_section.SetSP(parent_section_sp); } - return sb_section; + return LLDB_RECORD_RESULT(sb_section); } lldb::SBSection SBSection::FindSubSection(const char *sect_name) { + LLDB_RECORD_METHOD(lldb::SBSection, SBSection, FindSubSection, (const char *), + sect_name); + lldb::SBSection sb_section; if (sect_name) { SectionSP section_sp(GetSP()); @@ -73,10 +92,12 @@ lldb::SBSection SBSection::FindSubSection(const char *sect_name) { section_sp->GetChildren().FindSectionByName(const_sect_name)); } } - return sb_section; + return LLDB_RECORD_RESULT(sb_section); } size_t SBSection::GetNumSubSections() { + LLDB_RECORD_METHOD_NO_ARGS(size_t, SBSection, GetNumSubSections); + SectionSP section_sp(GetSP()); if (section_sp) return section_sp->GetChildren().GetSize(); @@ -84,11 +105,14 @@ size_t SBSection::GetNumSubSections() { } lldb::SBSection SBSection::GetSubSectionAtIndex(size_t idx) { + LLDB_RECORD_METHOD(lldb::SBSection, SBSection, GetSubSectionAtIndex, (size_t), + idx); + lldb::SBSection sb_section; SectionSP section_sp(GetSP()); if (section_sp) sb_section.SetSP(section_sp->GetChildren().GetSectionAtIndex(idx)); - return sb_section; + return LLDB_RECORD_RESULT(sb_section); } lldb::SectionSP SBSection::GetSP() const { return m_opaque_wp.lock(); } @@ -98,6 +122,8 @@ void SBSection::SetSP(const lldb::SectionSP §ion_sp) { } lldb::addr_t SBSection::GetFileAddress() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::addr_t, SBSection, GetFileAddress); + lldb::addr_t file_addr = LLDB_INVALID_ADDRESS; SectionSP section_sp(GetSP()); if (section_sp) @@ -106,6 +132,9 @@ lldb::addr_t SBSection::GetFileAddress() { } lldb::addr_t SBSection::GetLoadAddress(lldb::SBTarget &sb_target) { + LLDB_RECORD_METHOD(lldb::addr_t, SBSection, GetLoadAddress, + (lldb::SBTarget &), sb_target); + TargetSP target_sp(sb_target.GetSP()); if (target_sp) { SectionSP section_sp(GetSP()); @@ -116,6 +145,8 @@ lldb::addr_t SBSection::GetLoadAddress(lldb::SBTarget &sb_target) { } lldb::addr_t SBSection::GetByteSize() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::addr_t, SBSection, GetByteSize); + SectionSP section_sp(GetSP()); if (section_sp) return section_sp->GetByteSize(); @@ -123,6 +154,8 @@ lldb::addr_t SBSection::GetByteSize() { } uint64_t SBSection::GetFileOffset() { + LLDB_RECORD_METHOD_NO_ARGS(uint64_t, SBSection, GetFileOffset); + SectionSP section_sp(GetSP()); if (section_sp) { ModuleSP module_sp(section_sp->GetModule()); @@ -136,15 +169,24 @@ uint64_t SBSection::GetFileOffset() { } uint64_t SBSection::GetFileByteSize() { + LLDB_RECORD_METHOD_NO_ARGS(uint64_t, SBSection, GetFileByteSize); + SectionSP section_sp(GetSP()); if (section_sp) return section_sp->GetFileSize(); return 0; } -SBData SBSection::GetSectionData() { return GetSectionData(0, UINT64_MAX); } +SBData SBSection::GetSectionData() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBData, SBSection, GetSectionData); + + return LLDB_RECORD_RESULT(GetSectionData(0, UINT64_MAX)); +} SBData SBSection::GetSectionData(uint64_t offset, uint64_t size) { + LLDB_RECORD_METHOD(lldb::SBData, SBSection, GetSectionData, + (uint64_t, uint64_t), offset, size); + SBData sb_data; SectionSP section_sp(GetSP()); if (section_sp) { @@ -178,26 +220,30 @@ SBData SBSection::GetSectionData(uint64_t offset, uint64_t size) { } } } - return sb_data; + return LLDB_RECORD_RESULT(sb_data); } SectionType SBSection::GetSectionType() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SectionType, SBSection, GetSectionType); + SectionSP section_sp(GetSP()); if (section_sp.get()) return section_sp->GetType(); return eSectionTypeInvalid; } -uint32_t -SBSection::GetPermissions() const -{ - SectionSP section_sp(GetSP()); - if (section_sp) - return section_sp->GetPermissions(); - return 0; +uint32_t SBSection::GetPermissions() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBSection, GetPermissions); + + SectionSP section_sp(GetSP()); + if (section_sp) + return section_sp->GetPermissions(); + return 0; } uint32_t SBSection::GetTargetByteSize() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBSection, GetTargetByteSize); + SectionSP section_sp(GetSP()); if (section_sp.get()) return section_sp->GetTargetByteSize(); @@ -205,6 +251,9 @@ uint32_t SBSection::GetTargetByteSize() { } bool SBSection::operator==(const SBSection &rhs) { + LLDB_RECORD_METHOD(bool, SBSection, operator==,(const lldb::SBSection &), + rhs); + SectionSP lhs_section_sp(GetSP()); SectionSP rhs_section_sp(rhs.GetSP()); if (lhs_section_sp && rhs_section_sp) @@ -213,12 +262,18 @@ bool SBSection::operator==(const SBSection &rhs) { } bool SBSection::operator!=(const SBSection &rhs) { + LLDB_RECORD_METHOD(bool, SBSection, operator!=,(const lldb::SBSection &), + rhs); + SectionSP lhs_section_sp(GetSP()); SectionSP rhs_section_sp(rhs.GetSP()); return lhs_section_sp != rhs_section_sp; } bool SBSection::GetDescription(SBStream &description) { + LLDB_RECORD_METHOD(bool, SBSection, GetDescription, (lldb::SBStream &), + description); + Stream &strm = description.ref(); SectionSP section_sp(GetSP()); @@ -233,3 +288,41 @@ bool SBSection::GetDescription(SBStream &description) { return true; } + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBSection>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBSection, ()); + LLDB_REGISTER_CONSTRUCTOR(SBSection, (const lldb::SBSection &)); + LLDB_REGISTER_METHOD(const lldb::SBSection &, + SBSection, operator=,(const lldb::SBSection &)); + LLDB_REGISTER_METHOD_CONST(bool, SBSection, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBSection, operator bool, ()); + LLDB_REGISTER_METHOD(const char *, SBSection, GetName, ()); + LLDB_REGISTER_METHOD(lldb::SBSection, SBSection, GetParent, ()); + LLDB_REGISTER_METHOD(lldb::SBSection, SBSection, FindSubSection, + (const char *)); + LLDB_REGISTER_METHOD(size_t, SBSection, GetNumSubSections, ()); + LLDB_REGISTER_METHOD(lldb::SBSection, SBSection, GetSubSectionAtIndex, + (size_t)); + LLDB_REGISTER_METHOD(lldb::addr_t, SBSection, GetFileAddress, ()); + LLDB_REGISTER_METHOD(lldb::addr_t, SBSection, GetLoadAddress, + (lldb::SBTarget &)); + LLDB_REGISTER_METHOD(lldb::addr_t, SBSection, GetByteSize, ()); + LLDB_REGISTER_METHOD(uint64_t, SBSection, GetFileOffset, ()); + LLDB_REGISTER_METHOD(uint64_t, SBSection, GetFileByteSize, ()); + LLDB_REGISTER_METHOD(lldb::SBData, SBSection, GetSectionData, ()); + LLDB_REGISTER_METHOD(lldb::SBData, SBSection, GetSectionData, + (uint64_t, uint64_t)); + LLDB_REGISTER_METHOD(lldb::SectionType, SBSection, GetSectionType, ()); + LLDB_REGISTER_METHOD_CONST(uint32_t, SBSection, GetPermissions, ()); + LLDB_REGISTER_METHOD(uint32_t, SBSection, GetTargetByteSize, ()); + LLDB_REGISTER_METHOD(bool, SBSection, operator==,(const lldb::SBSection &)); + LLDB_REGISTER_METHOD(bool, SBSection, operator!=,(const lldb::SBSection &)); + LLDB_REGISTER_METHOD(bool, SBSection, GetDescription, (lldb::SBStream &)); +} + +} +} diff --git a/source/API/SBSourceManager.cpp b/source/API/SBSourceManager.cpp index 1d47cc034e351..9c4ce3c7f4e3a 100644 --- a/source/API/SBSourceManager.cpp +++ b/source/API/SBSourceManager.cpp @@ -1,13 +1,13 @@ //===-- SBSourceManager.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBSourceManager.h" +#include "SBReproducerPrivate.h" #include "lldb/API/SBDebugger.h" #include "lldb/API/SBStream.h" #include "lldb/API/SBTarget.h" @@ -72,24 +72,36 @@ using namespace lldb; using namespace lldb_private; SBSourceManager::SBSourceManager(const SBDebugger &debugger) { - m_opaque_ap.reset(new SourceManagerImpl(debugger.get_sp())); + LLDB_RECORD_CONSTRUCTOR(SBSourceManager, (const lldb::SBDebugger &), + debugger); + + m_opaque_up.reset(new SourceManagerImpl(debugger.get_sp())); } SBSourceManager::SBSourceManager(const SBTarget &target) { - m_opaque_ap.reset(new SourceManagerImpl(target.GetSP())); + LLDB_RECORD_CONSTRUCTOR(SBSourceManager, (const lldb::SBTarget &), target); + + m_opaque_up.reset(new SourceManagerImpl(target.GetSP())); } SBSourceManager::SBSourceManager(const SBSourceManager &rhs) { + LLDB_RECORD_CONSTRUCTOR(SBSourceManager, (const lldb::SBSourceManager &), + rhs); + if (&rhs == this) return; - m_opaque_ap.reset(new SourceManagerImpl(*(rhs.m_opaque_ap.get()))); + m_opaque_up.reset(new SourceManagerImpl(*(rhs.m_opaque_up.get()))); } const lldb::SBSourceManager &SBSourceManager:: operator=(const lldb::SBSourceManager &rhs) { - m_opaque_ap.reset(new SourceManagerImpl(*(rhs.m_opaque_ap.get()))); - return *this; + LLDB_RECORD_METHOD(const lldb::SBSourceManager &, + SBSourceManager, operator=,(const lldb::SBSourceManager &), + rhs); + + m_opaque_up.reset(new SourceManagerImpl(*(rhs.m_opaque_up.get()))); + return LLDB_RECORD_RESULT(*this); } SBSourceManager::~SBSourceManager() {} @@ -97,6 +109,12 @@ SBSourceManager::~SBSourceManager() {} size_t SBSourceManager::DisplaySourceLinesWithLineNumbers( const SBFileSpec &file, uint32_t line, uint32_t context_before, uint32_t context_after, const char *current_line_cstr, SBStream &s) { + LLDB_RECORD_METHOD(size_t, SBSourceManager, DisplaySourceLinesWithLineNumbers, + (const lldb::SBFileSpec &, uint32_t, uint32_t, uint32_t, + const char *, lldb::SBStream &), + file, line, context_before, context_after, + current_line_cstr, s); + const uint32_t column = 0; return DisplaySourceLinesWithLineNumbersAndColumn( file.ref(), line, column, context_before, context_after, @@ -107,10 +125,40 @@ size_t SBSourceManager::DisplaySourceLinesWithLineNumbersAndColumn( const SBFileSpec &file, uint32_t line, uint32_t column, uint32_t context_before, uint32_t context_after, const char *current_line_cstr, SBStream &s) { - if (m_opaque_ap == NULL) + LLDB_RECORD_METHOD( + size_t, SBSourceManager, DisplaySourceLinesWithLineNumbersAndColumn, + (const lldb::SBFileSpec &, uint32_t, uint32_t, uint32_t, uint32_t, + const char *, lldb::SBStream &), + file, line, column, context_before, context_after, current_line_cstr, s); + + if (m_opaque_up == nullptr) return 0; - return m_opaque_ap->DisplaySourceLinesWithLineNumbers( + return m_opaque_up->DisplaySourceLinesWithLineNumbers( file.ref(), line, column, context_before, context_after, current_line_cstr, s.get()); } + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBSourceManager>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBSourceManager, (const lldb::SBDebugger &)); + LLDB_REGISTER_CONSTRUCTOR(SBSourceManager, (const lldb::SBTarget &)); + LLDB_REGISTER_CONSTRUCTOR(SBSourceManager, (const lldb::SBSourceManager &)); + LLDB_REGISTER_METHOD( + const lldb::SBSourceManager &, + SBSourceManager, operator=,(const lldb::SBSourceManager &)); + LLDB_REGISTER_METHOD(size_t, SBSourceManager, + DisplaySourceLinesWithLineNumbers, + (const lldb::SBFileSpec &, uint32_t, uint32_t, + uint32_t, const char *, lldb::SBStream &)); + LLDB_REGISTER_METHOD(size_t, SBSourceManager, + DisplaySourceLinesWithLineNumbersAndColumn, + (const lldb::SBFileSpec &, uint32_t, uint32_t, + uint32_t, uint32_t, const char *, lldb::SBStream &)); +} + +} +} diff --git a/source/API/SBStream.cpp b/source/API/SBStream.cpp index 876ef02170d2f..ae652338e1ea5 100644 --- a/source/API/SBStream.cpp +++ b/source/API/SBStream.cpp @@ -1,14 +1,14 @@ //===-- SBStream.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBStream.h" +#include "SBReproducerPrivate.h" #include "lldb/Core/StreamFile.h" #include "lldb/Host/FileSystem.h" #include "lldb/Utility/Status.h" @@ -18,31 +18,45 @@ using namespace lldb; using namespace lldb_private; -SBStream::SBStream() : m_opaque_ap(new StreamString()), m_is_file(false) {} +SBStream::SBStream() : m_opaque_up(new StreamString()), m_is_file(false) { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBStream); +} SBStream::SBStream(SBStream &&rhs) - : m_opaque_ap(std::move(rhs.m_opaque_ap)), m_is_file(rhs.m_is_file) {} + : m_opaque_up(std::move(rhs.m_opaque_up)), m_is_file(rhs.m_is_file) {} SBStream::~SBStream() {} -bool SBStream::IsValid() const { return (m_opaque_ap != NULL); } +bool SBStream::IsValid() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBStream, IsValid); + return this->operator bool(); +} +SBStream::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBStream, operator bool); + + return (m_opaque_up != nullptr); +} // If this stream is not redirected to a file, it will maintain a local cache // for the stream data which can be accessed using this accessor. const char *SBStream::GetData() { - if (m_is_file || m_opaque_ap == NULL) - return NULL; + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBStream, GetData); + + if (m_is_file || m_opaque_up == nullptr) + return nullptr; - return static_cast<StreamString *>(m_opaque_ap.get())->GetData(); + return static_cast<StreamString *>(m_opaque_up.get())->GetData(); } // If this stream is not redirected to a file, it will maintain a local cache // for the stream output whose length can be accessed using this accessor. size_t SBStream::GetSize() { - if (m_is_file || m_opaque_ap == NULL) + LLDB_RECORD_METHOD_NO_ARGS(size_t, SBStream, GetSize); + + if (m_is_file || m_opaque_up == nullptr) return 0; - return static_cast<StreamString *>(m_opaque_ap.get())->GetSize(); + return static_cast<StreamString *>(m_opaque_up.get())->GetSize(); } void SBStream::Printf(const char *format, ...) { @@ -55,15 +69,18 @@ void SBStream::Printf(const char *format, ...) { } void SBStream::RedirectToFile(const char *path, bool append) { + LLDB_RECORD_METHOD(void, SBStream, RedirectToFile, (const char *, bool), path, + append); + if (path == nullptr) return; std::string local_data; - if (m_opaque_ap) { + if (m_opaque_up) { // See if we have any locally backed data. If so, copy it so we can then // redirect it to the file so we don't lose the data if (!m_is_file) - local_data = static_cast<StreamString *>(m_opaque_ap.get())->GetString(); + local_data = static_cast<StreamString *>(m_opaque_up.get())->GetString(); } StreamFile *stream_file = new StreamFile; uint32_t open_options = File::eOpenOptionWrite | File::eOpenOptionCanCreate; @@ -74,81 +91,108 @@ void SBStream::RedirectToFile(const char *path, bool append) { FileSystem::Instance().Open(stream_file->GetFile(), FileSpec(path), open_options); - m_opaque_ap.reset(stream_file); + m_opaque_up.reset(stream_file); - if (m_opaque_ap) { + if (m_opaque_up) { m_is_file = true; // If we had any data locally in our StreamString, then pass that along to // the to new file we are redirecting to. if (!local_data.empty()) - m_opaque_ap->Write(&local_data[0], local_data.size()); + m_opaque_up->Write(&local_data[0], local_data.size()); } else m_is_file = false; } void SBStream::RedirectToFileHandle(FILE *fh, bool transfer_fh_ownership) { + LLDB_RECORD_METHOD(void, SBStream, RedirectToFileHandle, (FILE *, bool), fh, + transfer_fh_ownership); + if (fh == nullptr) return; std::string local_data; - if (m_opaque_ap) { + if (m_opaque_up) { // See if we have any locally backed data. If so, copy it so we can then // redirect it to the file so we don't lose the data if (!m_is_file) - local_data = static_cast<StreamString *>(m_opaque_ap.get())->GetString(); + local_data = static_cast<StreamString *>(m_opaque_up.get())->GetString(); } - m_opaque_ap.reset(new StreamFile(fh, transfer_fh_ownership)); + m_opaque_up.reset(new StreamFile(fh, transfer_fh_ownership)); - if (m_opaque_ap) { + if (m_opaque_up) { m_is_file = true; // If we had any data locally in our StreamString, then pass that along to // the to new file we are redirecting to. if (!local_data.empty()) - m_opaque_ap->Write(&local_data[0], local_data.size()); + m_opaque_up->Write(&local_data[0], local_data.size()); } else m_is_file = false; } void SBStream::RedirectToFileDescriptor(int fd, bool transfer_fh_ownership) { + LLDB_RECORD_METHOD(void, SBStream, RedirectToFileDescriptor, (int, bool), fd, + transfer_fh_ownership); + std::string local_data; - if (m_opaque_ap) { + if (m_opaque_up) { // See if we have any locally backed data. If so, copy it so we can then // redirect it to the file so we don't lose the data if (!m_is_file) - local_data = static_cast<StreamString *>(m_opaque_ap.get())->GetString(); + local_data = static_cast<StreamString *>(m_opaque_up.get())->GetString(); } - m_opaque_ap.reset(new StreamFile(::fdopen(fd, "w"), transfer_fh_ownership)); - if (m_opaque_ap) { + m_opaque_up.reset(new StreamFile(::fdopen(fd, "w"), transfer_fh_ownership)); + if (m_opaque_up) { m_is_file = true; // If we had any data locally in our StreamString, then pass that along to // the to new file we are redirecting to. if (!local_data.empty()) - m_opaque_ap->Write(&local_data[0], local_data.size()); + m_opaque_up->Write(&local_data[0], local_data.size()); } else m_is_file = false; } -lldb_private::Stream *SBStream::operator->() { return m_opaque_ap.get(); } +lldb_private::Stream *SBStream::operator->() { return m_opaque_up.get(); } -lldb_private::Stream *SBStream::get() { return m_opaque_ap.get(); } +lldb_private::Stream *SBStream::get() { return m_opaque_up.get(); } lldb_private::Stream &SBStream::ref() { - if (m_opaque_ap == NULL) - m_opaque_ap.reset(new StreamString()); - return *m_opaque_ap; + if (m_opaque_up == nullptr) + m_opaque_up.reset(new StreamString()); + return *m_opaque_up; } void SBStream::Clear() { - if (m_opaque_ap) { + LLDB_RECORD_METHOD_NO_ARGS(void, SBStream, Clear); + + if (m_opaque_up) { // See if we have any locally backed data. If so, copy it so we can then // redirect it to the file so we don't lose the data if (m_is_file) - m_opaque_ap.reset(); + m_opaque_up.reset(); else - static_cast<StreamString *>(m_opaque_ap.get())->Clear(); + static_cast<StreamString *>(m_opaque_up.get())->Clear(); } } + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBStream>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBStream, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBStream, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBStream, operator bool, ()); + LLDB_REGISTER_METHOD(const char *, SBStream, GetData, ()); + LLDB_REGISTER_METHOD(size_t, SBStream, GetSize, ()); + LLDB_REGISTER_METHOD(void, SBStream, RedirectToFile, (const char *, bool)); + LLDB_REGISTER_METHOD(void, SBStream, RedirectToFileHandle, (FILE *, bool)); + LLDB_REGISTER_METHOD(void, SBStream, RedirectToFileDescriptor, (int, bool)); + LLDB_REGISTER_METHOD(void, SBStream, Clear, ()); +} + +} +} diff --git a/source/API/SBStringList.cpp b/source/API/SBStringList.cpp index 6ed4d4b7fb824..2f8bd55855a11 100644 --- a/source/API/SBStringList.cpp +++ b/source/API/SBStringList.cpp @@ -1,109 +1,163 @@ //===-- SBStringList.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBStringList.h" - +#include "SBReproducerPrivate.h" +#include "Utils.h" #include "lldb/Utility/StringList.h" using namespace lldb; using namespace lldb_private; -SBStringList::SBStringList() : m_opaque_ap() {} +SBStringList::SBStringList() : m_opaque_up() { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBStringList); +} SBStringList::SBStringList(const lldb_private::StringList *lldb_strings_ptr) - : m_opaque_ap() { + : m_opaque_up() { if (lldb_strings_ptr) - m_opaque_ap.reset(new lldb_private::StringList(*lldb_strings_ptr)); + m_opaque_up = llvm::make_unique<StringList>(*lldb_strings_ptr); } -SBStringList::SBStringList(const SBStringList &rhs) : m_opaque_ap() { - if (rhs.IsValid()) - m_opaque_ap.reset(new lldb_private::StringList(*rhs)); +SBStringList::SBStringList(const SBStringList &rhs) : m_opaque_up() { + LLDB_RECORD_CONSTRUCTOR(SBStringList, (const lldb::SBStringList &), rhs); + + m_opaque_up = clone(rhs.m_opaque_up); } const SBStringList &SBStringList::operator=(const SBStringList &rhs) { - if (this != &rhs) { - if (rhs.IsValid()) - m_opaque_ap.reset(new lldb_private::StringList(*rhs)); - else - m_opaque_ap.reset(); - } - return *this; + LLDB_RECORD_METHOD(const lldb::SBStringList &, + SBStringList, operator=,(const lldb::SBStringList &), rhs); + + if (this != &rhs) + m_opaque_up = clone(rhs.m_opaque_up); + return LLDB_RECORD_RESULT(*this); } SBStringList::~SBStringList() {} const lldb_private::StringList *SBStringList::operator->() const { - return m_opaque_ap.get(); + return m_opaque_up.get(); } const lldb_private::StringList &SBStringList::operator*() const { - return *m_opaque_ap; + return *m_opaque_up; } -bool SBStringList::IsValid() const { return (m_opaque_ap != NULL); } +bool SBStringList::IsValid() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBStringList, IsValid); + return this->operator bool(); +} +SBStringList::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBStringList, operator bool); + + return (m_opaque_up != nullptr); +} void SBStringList::AppendString(const char *str) { - if (str != NULL) { + LLDB_RECORD_METHOD(void, SBStringList, AppendString, (const char *), str); + + if (str != nullptr) { if (IsValid()) - m_opaque_ap->AppendString(str); + m_opaque_up->AppendString(str); else - m_opaque_ap.reset(new lldb_private::StringList(str)); + m_opaque_up.reset(new lldb_private::StringList(str)); } } void SBStringList::AppendList(const char **strv, int strc) { - if ((strv != NULL) && (strc > 0)) { + LLDB_RECORD_METHOD(void, SBStringList, AppendList, (const char **, int), strv, + strc); + + if ((strv != nullptr) && (strc > 0)) { if (IsValid()) - m_opaque_ap->AppendList(strv, strc); + m_opaque_up->AppendList(strv, strc); else - m_opaque_ap.reset(new lldb_private::StringList(strv, strc)); + m_opaque_up.reset(new lldb_private::StringList(strv, strc)); } } void SBStringList::AppendList(const SBStringList &strings) { + LLDB_RECORD_METHOD(void, SBStringList, AppendList, + (const lldb::SBStringList &), strings); + if (strings.IsValid()) { if (!IsValid()) - m_opaque_ap.reset(new lldb_private::StringList()); - m_opaque_ap->AppendList(*(strings.m_opaque_ap)); + m_opaque_up.reset(new lldb_private::StringList()); + m_opaque_up->AppendList(*(strings.m_opaque_up)); } } void SBStringList::AppendList(const StringList &strings) { if (!IsValid()) - m_opaque_ap.reset(new lldb_private::StringList()); - m_opaque_ap->AppendList(strings); + m_opaque_up.reset(new lldb_private::StringList()); + m_opaque_up->AppendList(strings); } uint32_t SBStringList::GetSize() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBStringList, GetSize); + if (IsValid()) { - return m_opaque_ap->GetSize(); + return m_opaque_up->GetSize(); } return 0; } const char *SBStringList::GetStringAtIndex(size_t idx) { + LLDB_RECORD_METHOD(const char *, SBStringList, GetStringAtIndex, (size_t), + idx); + if (IsValid()) { - return m_opaque_ap->GetStringAtIndex(idx); + return m_opaque_up->GetStringAtIndex(idx); } - return NULL; + return nullptr; } const char *SBStringList::GetStringAtIndex(size_t idx) const { + LLDB_RECORD_METHOD_CONST(const char *, SBStringList, GetStringAtIndex, + (size_t), idx); + if (IsValid()) { - return m_opaque_ap->GetStringAtIndex(idx); + return m_opaque_up->GetStringAtIndex(idx); } - return NULL; + return nullptr; } void SBStringList::Clear() { + LLDB_RECORD_METHOD_NO_ARGS(void, SBStringList, Clear); + if (IsValid()) { - m_opaque_ap->Clear(); + m_opaque_up->Clear(); } } + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBStringList>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBStringList, ()); + LLDB_REGISTER_CONSTRUCTOR(SBStringList, (const lldb::SBStringList &)); + LLDB_REGISTER_METHOD(const lldb::SBStringList &, + SBStringList, operator=,(const lldb::SBStringList &)); + LLDB_REGISTER_METHOD_CONST(bool, SBStringList, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBStringList, operator bool, ()); + LLDB_REGISTER_METHOD(void, SBStringList, AppendString, (const char *)); + LLDB_REGISTER_METHOD(void, SBStringList, AppendList, (const char **, int)); + LLDB_REGISTER_METHOD(void, SBStringList, AppendList, + (const lldb::SBStringList &)); + LLDB_REGISTER_METHOD_CONST(uint32_t, SBStringList, GetSize, ()); + LLDB_REGISTER_METHOD(const char *, SBStringList, GetStringAtIndex, + (size_t)); + LLDB_REGISTER_METHOD_CONST(const char *, SBStringList, GetStringAtIndex, + (size_t)); + LLDB_REGISTER_METHOD(void, SBStringList, Clear, ()); +} + +} +} diff --git a/source/API/SBStructuredData.cpp b/source/API/SBStructuredData.cpp index 277193424e99b..6b973e82c858b 100644 --- a/source/API/SBStructuredData.cpp +++ b/source/API/SBStructuredData.cpp @@ -1,13 +1,13 @@ //===-- SBStructuredData.cpp ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBStructuredData.h" +#include "SBReproducerPrivate.h" #include "lldb/API/SBStream.h" #include "lldb/API/SBStringList.h" @@ -24,26 +24,43 @@ using namespace lldb_private; #pragma mark-- #pragma mark SBStructuredData -SBStructuredData::SBStructuredData() : m_impl_up(new StructuredDataImpl()) {} +SBStructuredData::SBStructuredData() : m_impl_up(new StructuredDataImpl()) { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBStructuredData); +} SBStructuredData::SBStructuredData(const lldb::SBStructuredData &rhs) - : m_impl_up(new StructuredDataImpl(*rhs.m_impl_up.get())) {} + : m_impl_up(new StructuredDataImpl(*rhs.m_impl_up.get())) { + LLDB_RECORD_CONSTRUCTOR(SBStructuredData, (const lldb::SBStructuredData &), + rhs); +} SBStructuredData::SBStructuredData(const lldb::EventSP &event_sp) - : m_impl_up(new StructuredDataImpl(event_sp)) {} + : m_impl_up(new StructuredDataImpl(event_sp)) { + LLDB_RECORD_CONSTRUCTOR(SBStructuredData, (const lldb::EventSP &), event_sp); +} SBStructuredData::SBStructuredData(lldb_private::StructuredDataImpl *impl) - : m_impl_up(impl) {} + : m_impl_up(impl) { + LLDB_RECORD_CONSTRUCTOR(SBStructuredData, + (lldb_private::StructuredDataImpl *), impl); +} SBStructuredData::~SBStructuredData() {} SBStructuredData &SBStructuredData:: operator=(const lldb::SBStructuredData &rhs) { + LLDB_RECORD_METHOD( + lldb::SBStructuredData &, + SBStructuredData, operator=,(const lldb::SBStructuredData &), rhs); + *m_impl_up = *rhs.m_impl_up; - return *this; + return LLDB_RECORD_RESULT(*this); } lldb::SBError SBStructuredData::SetFromJSON(lldb::SBStream &stream) { + LLDB_RECORD_METHOD(lldb::SBError, SBStructuredData, SetFromJSON, + (lldb::SBStream &), stream); + lldb::SBError error; std::string json_str(stream.GetData()); @@ -52,35 +69,61 @@ lldb::SBError SBStructuredData::SetFromJSON(lldb::SBStream &stream) { if (!json_obj || json_obj->GetType() != eStructuredDataTypeDictionary) error.SetErrorString("Invalid Syntax"); - return error; + return LLDB_RECORD_RESULT(error); } -bool SBStructuredData::IsValid() const { return m_impl_up->IsValid(); } +bool SBStructuredData::IsValid() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBStructuredData, IsValid); + return this->operator bool(); +} +SBStructuredData::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBStructuredData, operator bool); + + return m_impl_up->IsValid(); +} -void SBStructuredData::Clear() { m_impl_up->Clear(); } +void SBStructuredData::Clear() { + LLDB_RECORD_METHOD_NO_ARGS(void, SBStructuredData, Clear); + + m_impl_up->Clear(); +} SBError SBStructuredData::GetAsJSON(lldb::SBStream &stream) const { + LLDB_RECORD_METHOD_CONST(lldb::SBError, SBStructuredData, GetAsJSON, + (lldb::SBStream &), stream); + SBError error; error.SetError(m_impl_up->GetAsJSON(stream.ref())); - return error; + return LLDB_RECORD_RESULT(error); } lldb::SBError SBStructuredData::GetDescription(lldb::SBStream &stream) const { + LLDB_RECORD_METHOD_CONST(lldb::SBError, SBStructuredData, GetDescription, + (lldb::SBStream &), stream); + Status error = m_impl_up->GetDescription(stream.ref()); SBError sb_error; sb_error.SetError(error); - return sb_error; + return LLDB_RECORD_RESULT(sb_error); } StructuredDataType SBStructuredData::GetType() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::StructuredDataType, SBStructuredData, + GetType); + return (m_impl_up ? m_impl_up->GetType() : eStructuredDataTypeInvalid); } size_t SBStructuredData::GetSize() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(size_t, SBStructuredData, GetSize); + return (m_impl_up ? m_impl_up->GetSize() : 0); } bool SBStructuredData::GetKeys(lldb::SBStringList &keys) const { + LLDB_RECORD_METHOD_CONST(bool, SBStructuredData, GetKeys, + (lldb::SBStringList &), keys); + if (!m_impl_up) return false; @@ -108,35 +151,97 @@ bool SBStructuredData::GetKeys(lldb::SBStringList &keys) const { } lldb::SBStructuredData SBStructuredData::GetValueForKey(const char *key) const { + LLDB_RECORD_METHOD_CONST(lldb::SBStructuredData, SBStructuredData, + GetValueForKey, (const char *), key); + if (!m_impl_up) - return SBStructuredData(); + return LLDB_RECORD_RESULT(SBStructuredData()); SBStructuredData result; result.m_impl_up->SetObjectSP(m_impl_up->GetValueForKey(key)); - return result; + return LLDB_RECORD_RESULT(result); } lldb::SBStructuredData SBStructuredData::GetItemAtIndex(size_t idx) const { + LLDB_RECORD_METHOD_CONST(lldb::SBStructuredData, SBStructuredData, + GetItemAtIndex, (size_t), idx); + if (!m_impl_up) - return SBStructuredData(); + return LLDB_RECORD_RESULT(SBStructuredData()); SBStructuredData result; result.m_impl_up->SetObjectSP(m_impl_up->GetItemAtIndex(idx)); - return result; + return LLDB_RECORD_RESULT(result); } uint64_t SBStructuredData::GetIntegerValue(uint64_t fail_value) const { + LLDB_RECORD_METHOD_CONST(uint64_t, SBStructuredData, GetIntegerValue, + (uint64_t), fail_value); + return (m_impl_up ? m_impl_up->GetIntegerValue(fail_value) : fail_value); } double SBStructuredData::GetFloatValue(double fail_value) const { + LLDB_RECORD_METHOD_CONST(double, SBStructuredData, GetFloatValue, (double), + fail_value); + return (m_impl_up ? m_impl_up->GetFloatValue(fail_value) : fail_value); } bool SBStructuredData::GetBooleanValue(bool fail_value) const { + LLDB_RECORD_METHOD_CONST(bool, SBStructuredData, GetBooleanValue, (bool), + fail_value); + return (m_impl_up ? m_impl_up->GetBooleanValue(fail_value) : fail_value); } size_t SBStructuredData::GetStringValue(char *dst, size_t dst_len) const { + LLDB_RECORD_METHOD_CONST(size_t, SBStructuredData, GetStringValue, + (char *, size_t), dst, dst_len); + return (m_impl_up ? m_impl_up->GetStringValue(dst, dst_len) : 0); } + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBStructuredData>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBStructuredData, ()); + LLDB_REGISTER_CONSTRUCTOR(SBStructuredData, + (const lldb::SBStructuredData &)); + LLDB_REGISTER_CONSTRUCTOR(SBStructuredData, (const lldb::EventSP &)); + LLDB_REGISTER_CONSTRUCTOR(SBStructuredData, + (lldb_private::StructuredDataImpl *)); + LLDB_REGISTER_METHOD( + lldb::SBStructuredData &, + SBStructuredData, operator=,(const lldb::SBStructuredData &)); + LLDB_REGISTER_METHOD(lldb::SBError, SBStructuredData, SetFromJSON, + (lldb::SBStream &)); + LLDB_REGISTER_METHOD_CONST(bool, SBStructuredData, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBStructuredData, operator bool, ()); + LLDB_REGISTER_METHOD(void, SBStructuredData, Clear, ()); + LLDB_REGISTER_METHOD_CONST(lldb::SBError, SBStructuredData, GetAsJSON, + (lldb::SBStream &)); + LLDB_REGISTER_METHOD_CONST(lldb::SBError, SBStructuredData, GetDescription, + (lldb::SBStream &)); + LLDB_REGISTER_METHOD_CONST(lldb::StructuredDataType, SBStructuredData, + GetType, ()); + LLDB_REGISTER_METHOD_CONST(size_t, SBStructuredData, GetSize, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBStructuredData, GetKeys, + (lldb::SBStringList &)); + LLDB_REGISTER_METHOD_CONST(lldb::SBStructuredData, SBStructuredData, + GetValueForKey, (const char *)); + LLDB_REGISTER_METHOD_CONST(lldb::SBStructuredData, SBStructuredData, + GetItemAtIndex, (size_t)); + LLDB_REGISTER_METHOD_CONST(uint64_t, SBStructuredData, GetIntegerValue, + (uint64_t)); + LLDB_REGISTER_METHOD_CONST(double, SBStructuredData, GetFloatValue, + (double)); + LLDB_REGISTER_METHOD_CONST(bool, SBStructuredData, GetBooleanValue, (bool)); + LLDB_REGISTER_METHOD_CONST(size_t, SBStructuredData, GetStringValue, + (char *, size_t)); +} + +} +} diff --git a/source/API/SBSymbol.cpp b/source/API/SBSymbol.cpp index 5be20a124982b..6cc90e0ee368b 100644 --- a/source/API/SBSymbol.cpp +++ b/source/API/SBSymbol.cpp @@ -1,96 +1,111 @@ //===-- SBSymbol.cpp --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBSymbol.h" +#include "SBReproducerPrivate.h" #include "lldb/API/SBStream.h" #include "lldb/Core/Disassembler.h" #include "lldb/Core/Module.h" #include "lldb/Symbol/Symbol.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Target.h" -#include "lldb/Utility/Log.h" using namespace lldb; using namespace lldb_private; -SBSymbol::SBSymbol() : m_opaque_ptr(NULL) {} +SBSymbol::SBSymbol() : m_opaque_ptr(nullptr) { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBSymbol); +} SBSymbol::SBSymbol(lldb_private::Symbol *lldb_object_ptr) : m_opaque_ptr(lldb_object_ptr) {} -SBSymbol::SBSymbol(const lldb::SBSymbol &rhs) - : m_opaque_ptr(rhs.m_opaque_ptr) {} +SBSymbol::SBSymbol(const lldb::SBSymbol &rhs) : m_opaque_ptr(rhs.m_opaque_ptr) { + LLDB_RECORD_CONSTRUCTOR(SBSymbol, (const lldb::SBSymbol &), rhs); +} const SBSymbol &SBSymbol::operator=(const SBSymbol &rhs) { + LLDB_RECORD_METHOD(const lldb::SBSymbol &, + SBSymbol, operator=,(const lldb::SBSymbol &), rhs); + m_opaque_ptr = rhs.m_opaque_ptr; - return *this; + return LLDB_RECORD_RESULT(*this); } -SBSymbol::~SBSymbol() { m_opaque_ptr = NULL; } +SBSymbol::~SBSymbol() { m_opaque_ptr = nullptr; } void SBSymbol::SetSymbol(lldb_private::Symbol *lldb_object_ptr) { m_opaque_ptr = lldb_object_ptr; } -bool SBSymbol::IsValid() const { return m_opaque_ptr != NULL; } +bool SBSymbol::IsValid() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBSymbol, IsValid); + return this->operator bool(); +} +SBSymbol::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBSymbol, operator bool); + + return m_opaque_ptr != nullptr; +} const char *SBSymbol::GetName() const { - const char *name = NULL; + LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBSymbol, GetName); + + const char *name = nullptr; if (m_opaque_ptr) name = m_opaque_ptr->GetName().AsCString(); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBSymbol(%p)::GetName () => \"%s\"", - static_cast<void *>(m_opaque_ptr), name ? name : ""); return name; } const char *SBSymbol::GetDisplayName() const { - const char *name = NULL; + LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBSymbol, GetDisplayName); + + const char *name = nullptr; if (m_opaque_ptr) name = m_opaque_ptr->GetMangled() .GetDisplayDemangledName(m_opaque_ptr->GetLanguage()) .AsCString(); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBSymbol(%p)::GetDisplayName () => \"%s\"", - static_cast<void *>(m_opaque_ptr), name ? name : ""); return name; } const char *SBSymbol::GetMangledName() const { - const char *name = NULL; + LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBSymbol, GetMangledName); + + const char *name = nullptr; if (m_opaque_ptr) name = m_opaque_ptr->GetMangled().GetMangledName().AsCString(); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBSymbol(%p)::GetMangledName () => \"%s\"", - static_cast<void *>(m_opaque_ptr), name ? name : ""); - return name; } bool SBSymbol::operator==(const SBSymbol &rhs) const { + LLDB_RECORD_METHOD_CONST(bool, SBSymbol, operator==,(const lldb::SBSymbol &), + rhs); + return m_opaque_ptr == rhs.m_opaque_ptr; } bool SBSymbol::operator!=(const SBSymbol &rhs) const { + LLDB_RECORD_METHOD_CONST(bool, SBSymbol, operator!=,(const lldb::SBSymbol &), + rhs); + return m_opaque_ptr != rhs.m_opaque_ptr; } bool SBSymbol::GetDescription(SBStream &description) { + LLDB_RECORD_METHOD(bool, SBSymbol, GetDescription, (lldb::SBStream &), + description); + Stream &strm = description.ref(); if (m_opaque_ptr) { - m_opaque_ptr->GetDescription(&strm, lldb::eDescriptionLevelFull, NULL); + m_opaque_ptr->GetDescription(&strm, lldb::eDescriptionLevelFull, nullptr); } else strm.PutCString("No value"); @@ -98,11 +113,17 @@ bool SBSymbol::GetDescription(SBStream &description) { } SBInstructionList SBSymbol::GetInstructions(SBTarget target) { - return GetInstructions(target, NULL); + LLDB_RECORD_METHOD(lldb::SBInstructionList, SBSymbol, GetInstructions, + (lldb::SBTarget), target); + + return LLDB_RECORD_RESULT(GetInstructions(target, nullptr)); } SBInstructionList SBSymbol::GetInstructions(SBTarget target, const char *flavor_string) { + LLDB_RECORD_METHOD(lldb::SBInstructionList, SBSymbol, GetInstructions, + (lldb::SBTarget, const char *), target, flavor_string); + SBInstructionList sb_instructions; if (m_opaque_ptr) { ExecutionContext exe_ctx; @@ -120,12 +141,12 @@ SBInstructionList SBSymbol::GetInstructions(SBTarget target, AddressRange symbol_range(symbol_addr, m_opaque_ptr->GetByteSize()); const bool prefer_file_cache = false; sb_instructions.SetDisassembler(Disassembler::DisassembleRange( - module_sp->GetArchitecture(), NULL, flavor_string, exe_ctx, + module_sp->GetArchitecture(), nullptr, flavor_string, exe_ctx, symbol_range, prefer_file_cache)); } } } - return sb_instructions; + return LLDB_RECORD_RESULT(sb_instructions); } lldb_private::Symbol *SBSymbol::get() { return m_opaque_ptr; } @@ -133,14 +154,18 @@ lldb_private::Symbol *SBSymbol::get() { return m_opaque_ptr; } void SBSymbol::reset(lldb_private::Symbol *symbol) { m_opaque_ptr = symbol; } SBAddress SBSymbol::GetStartAddress() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBAddress, SBSymbol, GetStartAddress); + SBAddress addr; if (m_opaque_ptr && m_opaque_ptr->ValueIsAddress()) { addr.SetAddress(&m_opaque_ptr->GetAddressRef()); } - return addr; + return LLDB_RECORD_RESULT(addr); } SBAddress SBSymbol::GetEndAddress() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBAddress, SBSymbol, GetEndAddress); + SBAddress addr; if (m_opaque_ptr && m_opaque_ptr->ValueIsAddress()) { lldb::addr_t range_size = m_opaque_ptr->GetByteSize(); @@ -149,29 +174,71 @@ SBAddress SBSymbol::GetEndAddress() { addr->Slide(m_opaque_ptr->GetByteSize()); } } - return addr; + return LLDB_RECORD_RESULT(addr); } uint32_t SBSymbol::GetPrologueByteSize() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBSymbol, GetPrologueByteSize); + if (m_opaque_ptr) return m_opaque_ptr->GetPrologueByteSize(); return 0; } SymbolType SBSymbol::GetType() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SymbolType, SBSymbol, GetType); + if (m_opaque_ptr) return m_opaque_ptr->GetType(); return eSymbolTypeInvalid; } bool SBSymbol::IsExternal() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBSymbol, IsExternal); + if (m_opaque_ptr) return m_opaque_ptr->IsExternal(); return false; } bool SBSymbol::IsSynthetic() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBSymbol, IsSynthetic); + if (m_opaque_ptr) return m_opaque_ptr->IsSynthetic(); return false; } + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBSymbol>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBSymbol, ()); + LLDB_REGISTER_CONSTRUCTOR(SBSymbol, (const lldb::SBSymbol &)); + LLDB_REGISTER_METHOD(const lldb::SBSymbol &, + SBSymbol, operator=,(const lldb::SBSymbol &)); + LLDB_REGISTER_METHOD_CONST(bool, SBSymbol, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBSymbol, operator bool, ()); + LLDB_REGISTER_METHOD_CONST(const char *, SBSymbol, GetName, ()); + LLDB_REGISTER_METHOD_CONST(const char *, SBSymbol, GetDisplayName, ()); + LLDB_REGISTER_METHOD_CONST(const char *, SBSymbol, GetMangledName, ()); + LLDB_REGISTER_METHOD_CONST(bool, + SBSymbol, operator==,(const lldb::SBSymbol &)); + LLDB_REGISTER_METHOD_CONST(bool, + SBSymbol, operator!=,(const lldb::SBSymbol &)); + LLDB_REGISTER_METHOD(bool, SBSymbol, GetDescription, (lldb::SBStream &)); + LLDB_REGISTER_METHOD(lldb::SBInstructionList, SBSymbol, GetInstructions, + (lldb::SBTarget)); + LLDB_REGISTER_METHOD(lldb::SBInstructionList, SBSymbol, GetInstructions, + (lldb::SBTarget, const char *)); + LLDB_REGISTER_METHOD(lldb::SBAddress, SBSymbol, GetStartAddress, ()); + LLDB_REGISTER_METHOD(lldb::SBAddress, SBSymbol, GetEndAddress, ()); + LLDB_REGISTER_METHOD(uint32_t, SBSymbol, GetPrologueByteSize, ()); + LLDB_REGISTER_METHOD(lldb::SymbolType, SBSymbol, GetType, ()); + LLDB_REGISTER_METHOD(bool, SBSymbol, IsExternal, ()); + LLDB_REGISTER_METHOD(bool, SBSymbol, IsSynthetic, ()); +} + +} +} diff --git a/source/API/SBSymbolContext.cpp b/source/API/SBSymbolContext.cpp index ab70c6f6ca68f..365f0ccc2fbf1 100644 --- a/source/API/SBSymbolContext.cpp +++ b/source/API/SBSymbolContext.cpp @@ -1,161 +1,166 @@ //===-- SBSymbolContext.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBSymbolContext.h" +#include "SBReproducerPrivate.h" +#include "Utils.h" #include "lldb/API/SBStream.h" #include "lldb/Core/Module.h" #include "lldb/Symbol/Function.h" #include "lldb/Symbol/Symbol.h" #include "lldb/Symbol/SymbolContext.h" -#include "lldb/Utility/Log.h" using namespace lldb; using namespace lldb_private; -SBSymbolContext::SBSymbolContext() : m_opaque_ap() {} +SBSymbolContext::SBSymbolContext() : m_opaque_up() { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBSymbolContext); +} + +SBSymbolContext::SBSymbolContext(const SymbolContext *sc_ptr) : m_opaque_up() { + LLDB_RECORD_CONSTRUCTOR(SBSymbolContext, + (const lldb_private::SymbolContext *), sc_ptr); -SBSymbolContext::SBSymbolContext(const SymbolContext *sc_ptr) : m_opaque_ap() { if (sc_ptr) - m_opaque_ap.reset(new SymbolContext(*sc_ptr)); + m_opaque_up = llvm::make_unique<SymbolContext>(*sc_ptr); } -SBSymbolContext::SBSymbolContext(const SBSymbolContext &rhs) : m_opaque_ap() { - if (rhs.IsValid()) { - if (m_opaque_ap) - *m_opaque_ap = *rhs.m_opaque_ap; - else - ref() = *rhs.m_opaque_ap; - } +SBSymbolContext::SBSymbolContext(const SBSymbolContext &rhs) : m_opaque_up() { + LLDB_RECORD_CONSTRUCTOR(SBSymbolContext, (const lldb::SBSymbolContext &), + rhs); + + m_opaque_up = clone(rhs.m_opaque_up); } SBSymbolContext::~SBSymbolContext() {} const SBSymbolContext &SBSymbolContext::operator=(const SBSymbolContext &rhs) { - if (this != &rhs) { - if (rhs.IsValid()) - m_opaque_ap.reset(new lldb_private::SymbolContext(*rhs.m_opaque_ap)); - } - return *this; + LLDB_RECORD_METHOD(const lldb::SBSymbolContext &, + SBSymbolContext, operator=,(const lldb::SBSymbolContext &), + rhs); + + if (this != &rhs) + m_opaque_up = clone(rhs.m_opaque_up); + return LLDB_RECORD_RESULT(*this); } void SBSymbolContext::SetSymbolContext(const SymbolContext *sc_ptr) { - if (sc_ptr) { - if (m_opaque_ap) - *m_opaque_ap = *sc_ptr; - else - m_opaque_ap.reset(new SymbolContext(*sc_ptr)); - } else { - if (m_opaque_ap) - m_opaque_ap->Clear(true); - } + if (sc_ptr) + m_opaque_up = llvm::make_unique<SymbolContext>(*sc_ptr); + else + m_opaque_up->Clear(true); +} + +bool SBSymbolContext::IsValid() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBSymbolContext, IsValid); + return this->operator bool(); } +SBSymbolContext::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBSymbolContext, operator bool); -bool SBSymbolContext::IsValid() const { return m_opaque_ap != NULL; } + return m_opaque_up != nullptr; +} SBModule SBSymbolContext::GetModule() { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBModule, SBSymbolContext, GetModule); SBModule sb_module; ModuleSP module_sp; - if (m_opaque_ap) { - module_sp = m_opaque_ap->module_sp; + if (m_opaque_up) { + module_sp = m_opaque_up->module_sp; sb_module.SetSP(module_sp); } - if (log) { - SBStream sstr; - sb_module.GetDescription(sstr); - log->Printf("SBSymbolContext(%p)::GetModule () => SBModule(%p): %s", - static_cast<void *>(m_opaque_ap.get()), - static_cast<void *>(module_sp.get()), sstr.GetData()); - } - - return sb_module; + return LLDB_RECORD_RESULT(sb_module); } SBCompileUnit SBSymbolContext::GetCompileUnit() { - return SBCompileUnit(m_opaque_ap ? m_opaque_ap->comp_unit : NULL); + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBCompileUnit, SBSymbolContext, + GetCompileUnit); + + return LLDB_RECORD_RESULT( + SBCompileUnit(m_opaque_up ? m_opaque_up->comp_unit : nullptr)); } SBFunction SBSymbolContext::GetFunction() { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFunction, SBSymbolContext, GetFunction); - Function *function = NULL; + Function *function = nullptr; - if (m_opaque_ap) - function = m_opaque_ap->function; + if (m_opaque_up) + function = m_opaque_up->function; SBFunction sb_function(function); - if (log) - log->Printf("SBSymbolContext(%p)::GetFunction () => SBFunction(%p)", - static_cast<void *>(m_opaque_ap.get()), - static_cast<void *>(function)); - - return sb_function; + return LLDB_RECORD_RESULT(sb_function); } SBBlock SBSymbolContext::GetBlock() { - return SBBlock(m_opaque_ap ? m_opaque_ap->block : NULL); + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBBlock, SBSymbolContext, GetBlock); + + return LLDB_RECORD_RESULT( + SBBlock(m_opaque_up ? m_opaque_up->block : nullptr)); } SBLineEntry SBSymbolContext::GetLineEntry() { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBLineEntry, SBSymbolContext, GetLineEntry); SBLineEntry sb_line_entry; - if (m_opaque_ap) - sb_line_entry.SetLineEntry(m_opaque_ap->line_entry); - - if (log) { - log->Printf("SBSymbolContext(%p)::GetLineEntry () => SBLineEntry(%p)", - static_cast<void *>(m_opaque_ap.get()), - static_cast<void *>(sb_line_entry.get())); - } + if (m_opaque_up) + sb_line_entry.SetLineEntry(m_opaque_up->line_entry); - return sb_line_entry; + return LLDB_RECORD_RESULT(sb_line_entry); } SBSymbol SBSymbolContext::GetSymbol() { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBSymbol, SBSymbolContext, GetSymbol); - Symbol *symbol = NULL; + Symbol *symbol = nullptr; - if (m_opaque_ap) - symbol = m_opaque_ap->symbol; + if (m_opaque_up) + symbol = m_opaque_up->symbol; SBSymbol sb_symbol(symbol); - if (log) - log->Printf("SBSymbolContext(%p)::GetSymbol () => SBSymbol(%p)", - static_cast<void *>(m_opaque_ap.get()), - static_cast<void *>(symbol)); - - return sb_symbol; + return LLDB_RECORD_RESULT(sb_symbol); } void SBSymbolContext::SetModule(lldb::SBModule module) { + LLDB_RECORD_METHOD(void, SBSymbolContext, SetModule, (lldb::SBModule), + module); + ref().module_sp = module.GetSP(); } void SBSymbolContext::SetCompileUnit(lldb::SBCompileUnit compile_unit) { + LLDB_RECORD_METHOD(void, SBSymbolContext, SetCompileUnit, + (lldb::SBCompileUnit), compile_unit); + ref().comp_unit = compile_unit.get(); } void SBSymbolContext::SetFunction(lldb::SBFunction function) { + LLDB_RECORD_METHOD(void, SBSymbolContext, SetFunction, (lldb::SBFunction), + function); + ref().function = function.get(); } void SBSymbolContext::SetBlock(lldb::SBBlock block) { + LLDB_RECORD_METHOD(void, SBSymbolContext, SetBlock, (lldb::SBBlock), block); + ref().block = block.GetPtr(); } void SBSymbolContext::SetLineEntry(lldb::SBLineEntry line_entry) { + LLDB_RECORD_METHOD(void, SBSymbolContext, SetLineEntry, (lldb::SBLineEntry), + line_entry); + if (line_entry.IsValid()) ref().line_entry = line_entry.ref(); else @@ -163,39 +168,45 @@ void SBSymbolContext::SetLineEntry(lldb::SBLineEntry line_entry) { } void SBSymbolContext::SetSymbol(lldb::SBSymbol symbol) { + LLDB_RECORD_METHOD(void, SBSymbolContext, SetSymbol, (lldb::SBSymbol), + symbol); + ref().symbol = symbol.get(); } lldb_private::SymbolContext *SBSymbolContext::operator->() const { - return m_opaque_ap.get(); + return m_opaque_up.get(); } const lldb_private::SymbolContext &SBSymbolContext::operator*() const { - assert(m_opaque_ap.get()); - return *m_opaque_ap; + assert(m_opaque_up.get()); + return *m_opaque_up; } lldb_private::SymbolContext &SBSymbolContext::operator*() { - if (m_opaque_ap == NULL) - m_opaque_ap.reset(new SymbolContext); - return *m_opaque_ap; + if (m_opaque_up == nullptr) + m_opaque_up.reset(new SymbolContext); + return *m_opaque_up; } lldb_private::SymbolContext &SBSymbolContext::ref() { - if (m_opaque_ap == NULL) - m_opaque_ap.reset(new SymbolContext); - return *m_opaque_ap; + if (m_opaque_up == nullptr) + m_opaque_up.reset(new SymbolContext); + return *m_opaque_up; } lldb_private::SymbolContext *SBSymbolContext::get() const { - return m_opaque_ap.get(); + return m_opaque_up.get(); } bool SBSymbolContext::GetDescription(SBStream &description) { + LLDB_RECORD_METHOD(bool, SBSymbolContext, GetDescription, (lldb::SBStream &), + description); + Stream &strm = description.ref(); - if (m_opaque_ap) { - m_opaque_ap->GetDescription(&strm, lldb::eDescriptionLevelFull, NULL); + if (m_opaque_up) { + m_opaque_up->GetDescription(&strm, lldb::eDescriptionLevelFull, nullptr); } else strm.PutCString("No value"); @@ -205,11 +216,56 @@ bool SBSymbolContext::GetDescription(SBStream &description) { SBSymbolContext SBSymbolContext::GetParentOfInlinedScope(const SBAddress &curr_frame_pc, SBAddress &parent_frame_addr) const { + LLDB_RECORD_METHOD_CONST(lldb::SBSymbolContext, SBSymbolContext, + GetParentOfInlinedScope, + (const lldb::SBAddress &, lldb::SBAddress &), + curr_frame_pc, parent_frame_addr); + SBSymbolContext sb_sc; - if (m_opaque_ap.get() && curr_frame_pc.IsValid()) { - if (m_opaque_ap->GetParentOfInlinedScope(curr_frame_pc.ref(), sb_sc.ref(), + if (m_opaque_up.get() && curr_frame_pc.IsValid()) { + if (m_opaque_up->GetParentOfInlinedScope(curr_frame_pc.ref(), sb_sc.ref(), parent_frame_addr.ref())) - return sb_sc; + return LLDB_RECORD_RESULT(sb_sc); } - return SBSymbolContext(); + return LLDB_RECORD_RESULT(SBSymbolContext()); +} + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBSymbolContext>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBSymbolContext, ()); + LLDB_REGISTER_CONSTRUCTOR(SBSymbolContext, + (const lldb_private::SymbolContext *)); + LLDB_REGISTER_CONSTRUCTOR(SBSymbolContext, (const lldb::SBSymbolContext &)); + LLDB_REGISTER_METHOD( + const lldb::SBSymbolContext &, + SBSymbolContext, operator=,(const lldb::SBSymbolContext &)); + LLDB_REGISTER_METHOD_CONST(bool, SBSymbolContext, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBSymbolContext, operator bool, ()); + LLDB_REGISTER_METHOD(lldb::SBModule, SBSymbolContext, GetModule, ()); + LLDB_REGISTER_METHOD(lldb::SBCompileUnit, SBSymbolContext, GetCompileUnit, + ()); + LLDB_REGISTER_METHOD(lldb::SBFunction, SBSymbolContext, GetFunction, ()); + LLDB_REGISTER_METHOD(lldb::SBBlock, SBSymbolContext, GetBlock, ()); + LLDB_REGISTER_METHOD(lldb::SBLineEntry, SBSymbolContext, GetLineEntry, ()); + LLDB_REGISTER_METHOD(lldb::SBSymbol, SBSymbolContext, GetSymbol, ()); + LLDB_REGISTER_METHOD(void, SBSymbolContext, SetModule, (lldb::SBModule)); + LLDB_REGISTER_METHOD(void, SBSymbolContext, SetCompileUnit, + (lldb::SBCompileUnit)); + LLDB_REGISTER_METHOD(void, SBSymbolContext, SetFunction, + (lldb::SBFunction)); + LLDB_REGISTER_METHOD(void, SBSymbolContext, SetBlock, (lldb::SBBlock)); + LLDB_REGISTER_METHOD(void, SBSymbolContext, SetLineEntry, + (lldb::SBLineEntry)); + LLDB_REGISTER_METHOD(void, SBSymbolContext, SetSymbol, (lldb::SBSymbol)); + LLDB_REGISTER_METHOD(bool, SBSymbolContext, GetDescription, + (lldb::SBStream &)); + LLDB_REGISTER_METHOD_CONST(lldb::SBSymbolContext, SBSymbolContext, + GetParentOfInlinedScope, + (const lldb::SBAddress &, lldb::SBAddress &)); +} + +} } diff --git a/source/API/SBSymbolContextList.cpp b/source/API/SBSymbolContextList.cpp index b07ab2afd554c..915d04a0282a2 100644 --- a/source/API/SBSymbolContextList.cpp +++ b/source/API/SBSymbolContextList.cpp @@ -1,13 +1,14 @@ //===-- SBSymbolContextList.cpp ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBSymbolContextList.h" +#include "SBReproducerPrivate.h" +#include "Utils.h" #include "lldb/API/SBStream.h" #include "lldb/Symbol/SymbolContext.h" @@ -15,67 +16,129 @@ using namespace lldb; using namespace lldb_private; SBSymbolContextList::SBSymbolContextList() - : m_opaque_ap(new SymbolContextList()) {} + : m_opaque_up(new SymbolContextList()) { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBSymbolContextList); +} SBSymbolContextList::SBSymbolContextList(const SBSymbolContextList &rhs) - : m_opaque_ap(new SymbolContextList(*rhs.m_opaque_ap)) {} + : m_opaque_up() { + LLDB_RECORD_CONSTRUCTOR(SBSymbolContextList, + (const lldb::SBSymbolContextList &), rhs); + + m_opaque_up = clone(rhs.m_opaque_up); +} SBSymbolContextList::~SBSymbolContextList() {} const SBSymbolContextList &SBSymbolContextList:: operator=(const SBSymbolContextList &rhs) { - if (this != &rhs) { - *m_opaque_ap = *rhs.m_opaque_ap; - } - return *this; + LLDB_RECORD_METHOD( + const lldb::SBSymbolContextList &, + SBSymbolContextList, operator=,(const lldb::SBSymbolContextList &), rhs); + + if (this != &rhs) + m_opaque_up = clone(rhs.m_opaque_up); + return LLDB_RECORD_RESULT(*this); } uint32_t SBSymbolContextList::GetSize() const { - if (m_opaque_ap) - return m_opaque_ap->GetSize(); + LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBSymbolContextList, GetSize); + + if (m_opaque_up) + return m_opaque_up->GetSize(); return 0; } SBSymbolContext SBSymbolContextList::GetContextAtIndex(uint32_t idx) { + LLDB_RECORD_METHOD(lldb::SBSymbolContext, SBSymbolContextList, + GetContextAtIndex, (uint32_t), idx); + SBSymbolContext sb_sc; - if (m_opaque_ap) { + if (m_opaque_up) { SymbolContext sc; - if (m_opaque_ap->GetContextAtIndex(idx, sc)) { + if (m_opaque_up->GetContextAtIndex(idx, sc)) { sb_sc.SetSymbolContext(&sc); } } - return sb_sc; + return LLDB_RECORD_RESULT(sb_sc); } void SBSymbolContextList::Clear() { - if (m_opaque_ap) - m_opaque_ap->Clear(); + LLDB_RECORD_METHOD_NO_ARGS(void, SBSymbolContextList, Clear); + + if (m_opaque_up) + m_opaque_up->Clear(); } void SBSymbolContextList::Append(SBSymbolContext &sc) { - if (sc.IsValid() && m_opaque_ap.get()) - m_opaque_ap->Append(*sc); + LLDB_RECORD_METHOD(void, SBSymbolContextList, Append, + (lldb::SBSymbolContext &), sc); + + if (sc.IsValid() && m_opaque_up.get()) + m_opaque_up->Append(*sc); } void SBSymbolContextList::Append(SBSymbolContextList &sc_list) { - if (sc_list.IsValid() && m_opaque_ap.get()) - m_opaque_ap->Append(*sc_list); + LLDB_RECORD_METHOD(void, SBSymbolContextList, Append, + (lldb::SBSymbolContextList &), sc_list); + + if (sc_list.IsValid() && m_opaque_up.get()) + m_opaque_up->Append(*sc_list); } -bool SBSymbolContextList::IsValid() const { return m_opaque_ap != NULL; } +bool SBSymbolContextList::IsValid() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBSymbolContextList, IsValid); + return this->operator bool(); +} +SBSymbolContextList::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBSymbolContextList, operator bool); + + return m_opaque_up != nullptr; +} lldb_private::SymbolContextList *SBSymbolContextList::operator->() const { - return m_opaque_ap.get(); + return m_opaque_up.get(); } lldb_private::SymbolContextList &SBSymbolContextList::operator*() const { - assert(m_opaque_ap.get()); - return *m_opaque_ap; + assert(m_opaque_up.get()); + return *m_opaque_up; } bool SBSymbolContextList::GetDescription(lldb::SBStream &description) { + LLDB_RECORD_METHOD(bool, SBSymbolContextList, GetDescription, + (lldb::SBStream &), description); + Stream &strm = description.ref(); - if (m_opaque_ap) - m_opaque_ap->GetDescription(&strm, lldb::eDescriptionLevelFull, NULL); + if (m_opaque_up) + m_opaque_up->GetDescription(&strm, lldb::eDescriptionLevelFull, nullptr); return true; } + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBSymbolContextList>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBSymbolContextList, ()); + LLDB_REGISTER_CONSTRUCTOR(SBSymbolContextList, + (const lldb::SBSymbolContextList &)); + LLDB_REGISTER_METHOD( + const lldb::SBSymbolContextList &, + SBSymbolContextList, operator=,(const lldb::SBSymbolContextList &)); + LLDB_REGISTER_METHOD_CONST(uint32_t, SBSymbolContextList, GetSize, ()); + LLDB_REGISTER_METHOD(lldb::SBSymbolContext, SBSymbolContextList, + GetContextAtIndex, (uint32_t)); + LLDB_REGISTER_METHOD(void, SBSymbolContextList, Clear, ()); + LLDB_REGISTER_METHOD(void, SBSymbolContextList, Append, + (lldb::SBSymbolContext &)); + LLDB_REGISTER_METHOD(void, SBSymbolContextList, Append, + (lldb::SBSymbolContextList &)); + LLDB_REGISTER_METHOD_CONST(bool, SBSymbolContextList, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBSymbolContextList, operator bool, ()); + LLDB_REGISTER_METHOD(bool, SBSymbolContextList, GetDescription, + (lldb::SBStream &)); +} + +} +} diff --git a/source/API/SBTarget.cpp b/source/API/SBTarget.cpp index 98587e7d7677c..5e87eb6273b3d 100644 --- a/source/API/SBTarget.cpp +++ b/source/API/SBTarget.cpp @@ -1,13 +1,13 @@ //===-- SBTarget.cpp --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBTarget.h" +#include "SBReproducerPrivate.h" #include "lldb/lldb-public.h" @@ -53,7 +53,6 @@ #include "lldb/Target/ABI.h" #include "lldb/Target/Language.h" #include "lldb/Target/LanguageRuntime.h" -#include "lldb/Target/ObjCLanguageRuntime.h" #include "lldb/Target/Process.h" #include "lldb/Target/StackFrame.h" #include "lldb/Target/Target.h" @@ -61,7 +60,7 @@ #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/Args.h" #include "lldb/Utility/FileSpec.h" -#include "lldb/Utility/Log.h" +#include "lldb/Utility/ProcessInfo.h" #include "lldb/Utility/RegularExpression.h" #include "Commands/CommandObjectBreakpoint.h" @@ -97,35 +96,50 @@ Status AttachToProcess(ProcessAttachInfo &attach_info, Target &target) { } // namespace -//---------------------------------------------------------------------- // SBTarget constructor -//---------------------------------------------------------------------- -SBTarget::SBTarget() : m_opaque_sp() {} +SBTarget::SBTarget() : m_opaque_sp() { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTarget); +} -SBTarget::SBTarget(const SBTarget &rhs) : m_opaque_sp(rhs.m_opaque_sp) {} +SBTarget::SBTarget(const SBTarget &rhs) : m_opaque_sp(rhs.m_opaque_sp) { + LLDB_RECORD_CONSTRUCTOR(SBTarget, (const lldb::SBTarget &), rhs); +} -SBTarget::SBTarget(const TargetSP &target_sp) : m_opaque_sp(target_sp) {} +SBTarget::SBTarget(const TargetSP &target_sp) : m_opaque_sp(target_sp) { + LLDB_RECORD_CONSTRUCTOR(SBTarget, (const lldb::TargetSP &), target_sp); +} const SBTarget &SBTarget::operator=(const SBTarget &rhs) { + LLDB_RECORD_METHOD(const lldb::SBTarget &, + SBTarget, operator=,(const lldb::SBTarget &), rhs); + if (this != &rhs) m_opaque_sp = rhs.m_opaque_sp; - return *this; + return LLDB_RECORD_RESULT(*this); } -//---------------------------------------------------------------------- // Destructor -//---------------------------------------------------------------------- SBTarget::~SBTarget() {} bool SBTarget::EventIsTargetEvent(const SBEvent &event) { - return Target::TargetEventData::GetEventDataFromEvent(event.get()) != NULL; + LLDB_RECORD_STATIC_METHOD(bool, SBTarget, EventIsTargetEvent, + (const lldb::SBEvent &), event); + + return Target::TargetEventData::GetEventDataFromEvent(event.get()) != nullptr; } SBTarget SBTarget::GetTargetFromEvent(const SBEvent &event) { - return Target::TargetEventData::GetTargetFromEvent(event.get()); + LLDB_RECORD_STATIC_METHOD(lldb::SBTarget, SBTarget, GetTargetFromEvent, + (const lldb::SBEvent &), event); + + return LLDB_RECORD_RESULT( + Target::TargetEventData::GetTargetFromEvent(event.get())); } uint32_t SBTarget::GetNumModulesFromEvent(const SBEvent &event) { + LLDB_RECORD_STATIC_METHOD(uint32_t, SBTarget, GetNumModulesFromEvent, + (const lldb::SBEvent &), event); + const ModuleList module_list = Target::TargetEventData::GetModuleListFromEvent(event.get()); return module_list.GetSize(); @@ -133,20 +147,35 @@ uint32_t SBTarget::GetNumModulesFromEvent(const SBEvent &event) { SBModule SBTarget::GetModuleAtIndexFromEvent(const uint32_t idx, const SBEvent &event) { + LLDB_RECORD_STATIC_METHOD(lldb::SBModule, SBTarget, GetModuleAtIndexFromEvent, + (const uint32_t, const lldb::SBEvent &), idx, + event); + const ModuleList module_list = Target::TargetEventData::GetModuleListFromEvent(event.get()); - return SBModule(module_list.GetModuleAtIndex(idx)); + return LLDB_RECORD_RESULT(SBModule(module_list.GetModuleAtIndex(idx))); } const char *SBTarget::GetBroadcasterClassName() { + LLDB_RECORD_STATIC_METHOD_NO_ARGS(const char *, SBTarget, + GetBroadcasterClassName); + return Target::GetStaticBroadcasterClass().AsCString(); } bool SBTarget::IsValid() const { - return m_opaque_sp.get() != NULL && m_opaque_sp->IsValid(); + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTarget, IsValid); + return this->operator bool(); +} +SBTarget::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTarget, operator bool); + + return m_opaque_sp.get() != nullptr && m_opaque_sp->IsValid(); } SBProcess SBTarget::GetProcess() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBProcess, SBTarget, GetProcess); + SBProcess sb_process; ProcessSP process_sp; TargetSP target_sp(GetSP()); @@ -155,39 +184,39 @@ SBProcess SBTarget::GetProcess() { sb_process.SetSP(process_sp); } - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBTarget(%p)::GetProcess () => SBProcess(%p)", - static_cast<void *>(target_sp.get()), - static_cast<void *>(process_sp.get())); - - return sb_process; + return LLDB_RECORD_RESULT(sb_process); } SBPlatform SBTarget::GetPlatform() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBPlatform, SBTarget, GetPlatform); + TargetSP target_sp(GetSP()); if (!target_sp) - return SBPlatform(); + return LLDB_RECORD_RESULT(SBPlatform()); SBPlatform platform; platform.m_opaque_sp = target_sp->GetPlatform(); - return platform; + return LLDB_RECORD_RESULT(platform); } SBDebugger SBTarget::GetDebugger() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBDebugger, SBTarget, GetDebugger); + SBDebugger debugger; TargetSP target_sp(GetSP()); if (target_sp) debugger.reset(target_sp->GetDebugger().shared_from_this()); - return debugger; + return LLDB_RECORD_RESULT(debugger); } SBStructuredData SBTarget::GetStatistics() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBStructuredData, SBTarget, GetStatistics); + SBStructuredData data; TargetSP target_sp(GetSP()); if (!target_sp) - return data; + return LLDB_RECORD_RESULT(data); auto stats_up = llvm::make_unique<StructuredData::Dictionary>(); int i = 0; @@ -199,10 +228,12 @@ SBStructuredData SBTarget::GetStatistics() { } data.m_impl_up->SetObjectSP(std::move(stats_up)); - return data; + return LLDB_RECORD_RESULT(data); } void SBTarget::SetCollectingStats(bool v) { + LLDB_RECORD_METHOD(void, SBTarget, SetCollectingStats, (bool), v); + TargetSP target_sp(GetSP()); if (!target_sp) return; @@ -210,19 +241,26 @@ void SBTarget::SetCollectingStats(bool v) { } bool SBTarget::GetCollectingStats() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, GetCollectingStats); + TargetSP target_sp(GetSP()); if (!target_sp) return false; return target_sp->GetCollectingStats(); } - SBProcess SBTarget::LoadCore(const char *core_file) { + LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, LoadCore, (const char *), + core_file); + lldb::SBError error; // Ignored - return LoadCore(core_file, error); + return LLDB_RECORD_RESULT(LoadCore(core_file, error)); } SBProcess SBTarget::LoadCore(const char *core_file, lldb::SBError &error) { + LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, LoadCore, + (const char *, lldb::SBError &), core_file, error); + SBProcess sb_process; TargetSP target_sp(GetSP()); if (target_sp) { @@ -240,30 +278,37 @@ SBProcess SBTarget::LoadCore(const char *core_file, lldb::SBError &error) { } else { error.SetErrorString("SBTarget is invalid"); } - return sb_process; + return LLDB_RECORD_RESULT(sb_process); } SBProcess SBTarget::LaunchSimple(char const **argv, char const **envp, const char *working_directory) { - char *stdin_path = NULL; - char *stdout_path = NULL; - char *stderr_path = NULL; + LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, LaunchSimple, + (const char **, const char **, const char *), argv, envp, + working_directory); + + char *stdin_path = nullptr; + char *stdout_path = nullptr; + char *stderr_path = nullptr; uint32_t launch_flags = 0; bool stop_at_entry = false; SBError error; SBListener listener = GetDebugger().GetListener(); - return Launch(listener, argv, envp, stdin_path, stdout_path, stderr_path, - working_directory, launch_flags, stop_at_entry, error); + return LLDB_RECORD_RESULT(Launch(listener, argv, envp, stdin_path, + stdout_path, stderr_path, working_directory, + launch_flags, stop_at_entry, error)); } SBError SBTarget::Install() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBTarget, Install); + SBError sb_error; TargetSP target_sp(GetSP()); if (target_sp) { std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); - sb_error.ref() = target_sp->Install(NULL); + sb_error.ref() = target_sp->Install(nullptr); } - return sb_error; + return LLDB_RECORD_RESULT(sb_error); } SBProcess SBTarget::Launch(SBListener &listener, char const **argv, @@ -272,23 +317,17 @@ SBProcess SBTarget::Launch(SBListener &listener, char const **argv, const char *working_directory, uint32_t launch_flags, // See LaunchFlags bool stop_at_entry, lldb::SBError &error) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, Launch, + (lldb::SBListener &, const char **, const char **, + const char *, const char *, const char *, const char *, + uint32_t, bool, lldb::SBError &), + listener, argv, envp, stdin_path, stdout_path, stderr_path, + working_directory, launch_flags, stop_at_entry, error); SBProcess sb_process; ProcessSP process_sp; TargetSP target_sp(GetSP()); - if (log) - log->Printf("SBTarget(%p)::Launch (argv=%p, envp=%p, stdin=%s, stdout=%s, " - "stderr=%s, working-dir=%s, launch_flags=0x%x, " - "stop_at_entry=%i, &error (%p))...", - static_cast<void *>(target_sp.get()), static_cast<void *>(argv), - static_cast<void *>(envp), stdin_path ? stdin_path : "NULL", - stdout_path ? stdout_path : "NULL", - stderr_path ? stderr_path : "NULL", - working_directory ? working_directory : "NULL", launch_flags, - stop_at_entry, static_cast<void *>(error.get())); - if (target_sp) { std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); @@ -308,7 +347,7 @@ SBProcess SBTarget::Launch(SBListener &listener, char const **argv, error.SetErrorString("process attach is in progress"); else error.SetErrorString("a process is already being debugged"); - return sb_process; + return LLDB_RECORD_RESULT(sb_process); } } @@ -319,7 +358,7 @@ SBProcess SBTarget::Launch(SBListener &listener, char const **argv, if (listener.IsValid()) { error.SetErrorString("process is connected and already has a listener, " "pass empty listener"); - return sb_process; + return LLDB_RECORD_RESULT(sb_process); } } @@ -341,33 +380,25 @@ SBProcess SBTarget::Launch(SBListener &listener, char const **argv, if (listener.IsValid()) launch_info.SetListener(listener.GetSP()); - error.SetError(target_sp->Launch(launch_info, NULL)); + error.SetError(target_sp->Launch(launch_info, nullptr)); sb_process.SetSP(target_sp->GetProcessSP()); } else { error.SetErrorString("SBTarget is invalid"); } - log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API); - if (log) - log->Printf("SBTarget(%p)::Launch (...) => SBProcess(%p), SBError(%s)", - static_cast<void *>(target_sp.get()), - static_cast<void *>(sb_process.GetSP().get()), - error.GetCString()); - - return sb_process; + return LLDB_RECORD_RESULT(sb_process); } SBProcess SBTarget::Launch(SBLaunchInfo &sb_launch_info, SBError &error) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, Launch, + (lldb::SBLaunchInfo &, lldb::SBError &), sb_launch_info, + error); + SBProcess sb_process; TargetSP target_sp(GetSP()); - if (log) - log->Printf("SBTarget(%p)::Launch (launch_info, error)...", - static_cast<void *>(target_sp.get())); - if (target_sp) { std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); StateType state = eStateInvalid; @@ -381,7 +412,7 @@ SBProcess SBTarget::Launch(SBLaunchInfo &sb_launch_info, SBError &error) { error.SetErrorString("process attach is in progress"); else error.SetErrorString("a process is already being debugged"); - return sb_process; + return LLDB_RECORD_RESULT(sb_process); } } } @@ -398,32 +429,24 @@ SBProcess SBTarget::Launch(SBLaunchInfo &sb_launch_info, SBError &error) { if (arch_spec.IsValid()) launch_info.GetArchitecture() = arch_spec; - error.SetError(target_sp->Launch(launch_info, NULL)); + error.SetError(target_sp->Launch(launch_info, nullptr)); sb_launch_info.set_ref(launch_info); sb_process.SetSP(target_sp->GetProcessSP()); } else { error.SetErrorString("SBTarget is invalid"); } - log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API); - if (log) - log->Printf("SBTarget(%p)::Launch (...) => SBProcess(%p)", - static_cast<void *>(target_sp.get()), - static_cast<void *>(sb_process.GetSP().get())); - - return sb_process; + return LLDB_RECORD_RESULT(sb_process); } lldb::SBProcess SBTarget::Attach(SBAttachInfo &sb_attach_info, SBError &error) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, Attach, + (lldb::SBAttachInfo &, lldb::SBError &), sb_attach_info, + error); SBProcess sb_process; TargetSP target_sp(GetSP()); - if (log) - log->Printf("SBTarget(%p)::Attach (sb_attach_info, error)...", - static_cast<void *>(target_sp.get())); - if (target_sp) { ProcessAttachInfo &attach_info = sb_attach_info.ref(); if (attach_info.ProcessIDIsValid() && !attach_info.UserIDIsValid()) { @@ -437,12 +460,7 @@ lldb::SBProcess SBTarget::Attach(SBAttachInfo &sb_attach_info, SBError &error) { } else { error.ref().SetErrorStringWithFormat( "no process found with process ID %" PRIu64, attach_pid); - if (log) { - log->Printf("SBTarget(%p)::Attach (...) => error %s", - static_cast<void *>(target_sp.get()), - error.GetCString()); - } - return sb_process; + return LLDB_RECORD_RESULT(sb_process); } } } @@ -453,28 +471,21 @@ lldb::SBProcess SBTarget::Attach(SBAttachInfo &sb_attach_info, SBError &error) { error.SetErrorString("SBTarget is invalid"); } - if (log) - log->Printf("SBTarget(%p)::Attach (...) => SBProcess(%p)", - static_cast<void *>(target_sp.get()), - static_cast<void *>(sb_process.GetSP().get())); - - return sb_process; + return LLDB_RECORD_RESULT(sb_process); } lldb::SBProcess SBTarget::AttachToProcessWithID( SBListener &listener, lldb::pid_t pid, // The process ID to attach to SBError &error // An error explaining what went wrong if attach fails - ) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); +) { + LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, AttachToProcessWithID, + (lldb::SBListener &, lldb::pid_t, lldb::SBError &), + listener, pid, error); SBProcess sb_process; TargetSP target_sp(GetSP()); - if (log) - log->Printf("SBTarget(%p)::%s (listener, pid=%" PRId64 ", error)...", - static_cast<void *>(target_sp.get()), __FUNCTION__, pid); - if (target_sp) { ProcessAttachInfo attach_info; attach_info.SetProcessID(pid); @@ -491,11 +502,7 @@ lldb::SBProcess SBTarget::AttachToProcessWithID( } else error.SetErrorString("SBTarget is invalid"); - if (log) - log->Printf("SBTarget(%p)::%s (...) => SBProcess(%p)", - static_cast<void *>(target_sp.get()), __FUNCTION__, - static_cast<void *>(sb_process.GetSP().get())); - return sb_process; + return LLDB_RECORD_RESULT(sb_process); } lldb::SBProcess SBTarget::AttachToProcessWithName( @@ -503,17 +510,14 @@ lldb::SBProcess SBTarget::AttachToProcessWithName( const char *name, // basename of process to attach to bool wait_for, // if true wait for a new instance of "name" to be launched SBError &error // An error explaining what went wrong if attach fails - ) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); +) { + LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, AttachToProcessWithName, + (lldb::SBListener &, const char *, bool, lldb::SBError &), + listener, name, wait_for, error); SBProcess sb_process; TargetSP target_sp(GetSP()); - if (log) - log->Printf("SBTarget(%p)::%s (listener, name=%s, wait_for=%s, error)...", - static_cast<void *>(target_sp.get()), __FUNCTION__, name, - wait_for ? "true" : "false"); - if (name && target_sp) { ProcessAttachInfo attach_info; attach_info.GetExecutableFile().SetFile(name, FileSpec::Style::native); @@ -527,39 +531,33 @@ lldb::SBProcess SBTarget::AttachToProcessWithName( } else error.SetErrorString("SBTarget is invalid"); - if (log) - log->Printf("SBTarget(%p)::%s (...) => SBProcess(%p)", - static_cast<void *>(target_sp.get()), __FUNCTION__, - static_cast<void *>(sb_process.GetSP().get())); - return sb_process; + return LLDB_RECORD_RESULT(sb_process); } lldb::SBProcess SBTarget::ConnectRemote(SBListener &listener, const char *url, const char *plugin_name, SBError &error) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD( + lldb::SBProcess, SBTarget, ConnectRemote, + (lldb::SBListener &, const char *, const char *, lldb::SBError &), + listener, url, plugin_name, error); SBProcess sb_process; ProcessSP process_sp; TargetSP target_sp(GetSP()); - if (log) - log->Printf("SBTarget(%p)::ConnectRemote (listener, url=%s, " - "plugin_name=%s, error)...", - static_cast<void *>(target_sp.get()), url, plugin_name); - if (target_sp) { std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); if (listener.IsValid()) process_sp = - target_sp->CreateProcess(listener.m_opaque_sp, plugin_name, NULL); + target_sp->CreateProcess(listener.m_opaque_sp, plugin_name, nullptr); else process_sp = target_sp->CreateProcess( - target_sp->GetDebugger().GetListener(), plugin_name, NULL); + target_sp->GetDebugger().GetListener(), plugin_name, nullptr); if (process_sp) { sb_process.SetSP(process_sp); - error.SetError(process_sp->ConnectRemote(NULL, url)); + error.SetError(process_sp->ConnectRemote(nullptr, url)); } else { error.SetErrorString("unable to create lldb_private::Process"); } @@ -567,14 +565,11 @@ lldb::SBProcess SBTarget::ConnectRemote(SBListener &listener, const char *url, error.SetErrorString("SBTarget is invalid"); } - if (log) - log->Printf("SBTarget(%p)::ConnectRemote (...) => SBProcess(%p)", - static_cast<void *>(target_sp.get()), - static_cast<void *>(process_sp.get())); - return sb_process; + return LLDB_RECORD_RESULT(sb_process); } SBFileSpec SBTarget::GetExecutable() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFileSpec, SBTarget, GetExecutable); SBFileSpec exe_file_spec; TargetSP target_sp(GetSP()); @@ -584,21 +579,20 @@ SBFileSpec SBTarget::GetExecutable() { exe_file_spec.SetFileSpec(exe_module->GetFileSpec()); } - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) { - log->Printf("SBTarget(%p)::GetExecutable () => SBFileSpec(%p)", - static_cast<void *>(target_sp.get()), - static_cast<const void *>(exe_file_spec.get())); - } - - return exe_file_spec; + return LLDB_RECORD_RESULT(exe_file_spec); } bool SBTarget::operator==(const SBTarget &rhs) const { + LLDB_RECORD_METHOD_CONST(bool, SBTarget, operator==,(const lldb::SBTarget &), + rhs); + return m_opaque_sp.get() == rhs.m_opaque_sp.get(); } bool SBTarget::operator!=(const SBTarget &rhs) const { + LLDB_RECORD_METHOD_CONST(bool, SBTarget, operator!=,(const lldb::SBTarget &), + rhs); + return m_opaque_sp.get() != rhs.m_opaque_sp.get(); } @@ -609,55 +603,68 @@ void SBTarget::SetSP(const lldb::TargetSP &target_sp) { } lldb::SBAddress SBTarget::ResolveLoadAddress(lldb::addr_t vm_addr) { + LLDB_RECORD_METHOD(lldb::SBAddress, SBTarget, ResolveLoadAddress, + (lldb::addr_t), vm_addr); + lldb::SBAddress sb_addr; Address &addr = sb_addr.ref(); TargetSP target_sp(GetSP()); if (target_sp) { std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); if (target_sp->ResolveLoadAddress(vm_addr, addr)) - return sb_addr; + return LLDB_RECORD_RESULT(sb_addr); } // We have a load address that isn't in a section, just return an address // with the offset filled in (the address) and the section set to NULL addr.SetRawAddress(vm_addr); - return sb_addr; + return LLDB_RECORD_RESULT(sb_addr); } lldb::SBAddress SBTarget::ResolveFileAddress(lldb::addr_t file_addr) { + LLDB_RECORD_METHOD(lldb::SBAddress, SBTarget, ResolveFileAddress, + (lldb::addr_t), file_addr); + lldb::SBAddress sb_addr; Address &addr = sb_addr.ref(); TargetSP target_sp(GetSP()); if (target_sp) { std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); if (target_sp->ResolveFileAddress(file_addr, addr)) - return sb_addr; + return LLDB_RECORD_RESULT(sb_addr); } addr.SetRawAddress(file_addr); - return sb_addr; + return LLDB_RECORD_RESULT(sb_addr); } lldb::SBAddress SBTarget::ResolvePastLoadAddress(uint32_t stop_id, lldb::addr_t vm_addr) { + LLDB_RECORD_METHOD(lldb::SBAddress, SBTarget, ResolvePastLoadAddress, + (uint32_t, lldb::addr_t), stop_id, vm_addr); + lldb::SBAddress sb_addr; Address &addr = sb_addr.ref(); TargetSP target_sp(GetSP()); if (target_sp) { std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); if (target_sp->ResolveLoadAddress(vm_addr, addr)) - return sb_addr; + return LLDB_RECORD_RESULT(sb_addr); } // We have a load address that isn't in a section, just return an address // with the offset filled in (the address) and the section set to NULL addr.SetRawAddress(vm_addr); - return sb_addr; + return LLDB_RECORD_RESULT(sb_addr); } SBSymbolContext SBTarget::ResolveSymbolContextForAddress(const SBAddress &addr, uint32_t resolve_scope) { + LLDB_RECORD_METHOD(lldb::SBSymbolContext, SBTarget, + ResolveSymbolContextForAddress, + (const lldb::SBAddress &, uint32_t), addr, resolve_scope); + SBSymbolContext sc; SymbolContextItem scope = static_cast<SymbolContextItem>(resolve_scope); if (addr.IsValid()) { @@ -666,11 +673,15 @@ SBTarget::ResolveSymbolContextForAddress(const SBAddress &addr, target_sp->GetImages().ResolveSymbolContextForAddress(addr.ref(), scope, sc.ref()); } - return sc; + return LLDB_RECORD_RESULT(sc); } size_t SBTarget::ReadMemory(const SBAddress addr, void *buf, size_t size, lldb::SBError &error) { + LLDB_RECORD_DUMMY(size_t, SBTarget, ReadMemory, + (const lldb::SBAddress, void *, size_t, lldb::SBError &), + addr, buf, size, error); + SBError sb_error; size_t bytes_read = 0; TargetSP target_sp(GetSP()); @@ -687,35 +698,54 @@ size_t SBTarget::ReadMemory(const SBAddress addr, void *buf, size_t size, SBBreakpoint SBTarget::BreakpointCreateByLocation(const char *file, uint32_t line) { - return SBBreakpoint( - BreakpointCreateByLocation(SBFileSpec(file, false), line)); + LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation, + (const char *, uint32_t), file, line); + + return LLDB_RECORD_RESULT( + SBBreakpoint(BreakpointCreateByLocation(SBFileSpec(file, false), line))); } SBBreakpoint SBTarget::BreakpointCreateByLocation(const SBFileSpec &sb_file_spec, uint32_t line) { - return BreakpointCreateByLocation(sb_file_spec, line, 0); + LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation, + (const lldb::SBFileSpec &, uint32_t), sb_file_spec, line); + + return LLDB_RECORD_RESULT(BreakpointCreateByLocation(sb_file_spec, line, 0)); } SBBreakpoint SBTarget::BreakpointCreateByLocation(const SBFileSpec &sb_file_spec, uint32_t line, lldb::addr_t offset) { + LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation, + (const lldb::SBFileSpec &, uint32_t, lldb::addr_t), + sb_file_spec, line, offset); + SBFileSpecList empty_list; - return BreakpointCreateByLocation(sb_file_spec, line, offset, empty_list); + return LLDB_RECORD_RESULT( + BreakpointCreateByLocation(sb_file_spec, line, offset, empty_list)); } SBBreakpoint SBTarget::BreakpointCreateByLocation(const SBFileSpec &sb_file_spec, uint32_t line, lldb::addr_t offset, SBFileSpecList &sb_module_list) { - return BreakpointCreateByLocation(sb_file_spec, line, 0, offset, - sb_module_list); + LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation, + (const lldb::SBFileSpec &, uint32_t, lldb::addr_t, + lldb::SBFileSpecList &), + sb_file_spec, line, offset, sb_module_list); + + return LLDB_RECORD_RESULT(BreakpointCreateByLocation(sb_file_spec, line, 0, + offset, sb_module_list)); } SBBreakpoint SBTarget::BreakpointCreateByLocation( const SBFileSpec &sb_file_spec, uint32_t line, uint32_t column, lldb::addr_t offset, SBFileSpecList &sb_module_list) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation, + (const lldb::SBFileSpec &, uint32_t, uint32_t, + lldb::addr_t, lldb::SBFileSpecList &), + sb_file_spec, line, column, offset, sb_module_list); SBBreakpoint sb_bp; TargetSP target_sp(GetSP()); @@ -736,23 +766,13 @@ SBBreakpoint SBTarget::BreakpointCreateByLocation( skip_prologue, internal, hardware, move_to_nearest_code); } - if (log) { - SBStream sstr; - sb_bp.GetDescription(sstr); - char path[PATH_MAX]; - sb_file_spec->GetPath(path, sizeof(path)); - log->Printf("SBTarget(%p)::BreakpointCreateByLocation ( %s:%u ) => " - "SBBreakpoint(%p): %s", - static_cast<void *>(target_sp.get()), path, line, - static_cast<void *>(sb_bp.GetSP().get()), sstr.GetData()); - } - - return sb_bp; + return LLDB_RECORD_RESULT(sb_bp); } SBBreakpoint SBTarget::BreakpointCreateByName(const char *symbol_name, const char *module_name) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName, + (const char *, const char *), symbol_name, module_name); SBBreakpoint sb_bp; TargetSP target_sp(GetSP()); @@ -767,47 +787,56 @@ SBBreakpoint SBTarget::BreakpointCreateByName(const char *symbol_name, FileSpecList module_spec_list; module_spec_list.Append(FileSpec(module_name)); sb_bp = target_sp->CreateBreakpoint( - &module_spec_list, NULL, symbol_name, eFunctionNameTypeAuto, + &module_spec_list, nullptr, symbol_name, eFunctionNameTypeAuto, eLanguageTypeUnknown, offset, skip_prologue, internal, hardware); } else { sb_bp = target_sp->CreateBreakpoint( - NULL, NULL, symbol_name, eFunctionNameTypeAuto, eLanguageTypeUnknown, - offset, skip_prologue, internal, hardware); + nullptr, nullptr, symbol_name, eFunctionNameTypeAuto, + eLanguageTypeUnknown, offset, skip_prologue, internal, hardware); } } - if (log) - log->Printf("SBTarget(%p)::BreakpointCreateByName (symbol=\"%s\", " - "module=\"%s\") => SBBreakpoint(%p)", - static_cast<void *>(target_sp.get()), symbol_name, module_name, - static_cast<void *>(sb_bp.GetSP().get())); - - return sb_bp; + return LLDB_RECORD_RESULT(sb_bp); } lldb::SBBreakpoint SBTarget::BreakpointCreateByName(const char *symbol_name, const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) { + LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName, + (const char *, const lldb::SBFileSpecList &, + const lldb::SBFileSpecList &), + symbol_name, module_list, comp_unit_list); + lldb::FunctionNameType name_type_mask = eFunctionNameTypeAuto; - return BreakpointCreateByName(symbol_name, name_type_mask, - eLanguageTypeUnknown, module_list, - comp_unit_list); + return LLDB_RECORD_RESULT( + BreakpointCreateByName(symbol_name, name_type_mask, eLanguageTypeUnknown, + module_list, comp_unit_list)); } lldb::SBBreakpoint SBTarget::BreakpointCreateByName( const char *symbol_name, uint32_t name_type_mask, const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) { - return BreakpointCreateByName(symbol_name, name_type_mask, - eLanguageTypeUnknown, module_list, - comp_unit_list); + LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName, + (const char *, uint32_t, const lldb::SBFileSpecList &, + const lldb::SBFileSpecList &), + symbol_name, name_type_mask, module_list, comp_unit_list); + + return LLDB_RECORD_RESULT( + BreakpointCreateByName(symbol_name, name_type_mask, eLanguageTypeUnknown, + module_list, comp_unit_list)); } lldb::SBBreakpoint SBTarget::BreakpointCreateByName( const char *symbol_name, uint32_t name_type_mask, LanguageType symbol_language, const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName, + (const char *, uint32_t, lldb::LanguageType, + const lldb::SBFileSpecList &, + const lldb::SBFileSpecList &), + symbol_name, name_type_mask, symbol_language, module_list, + comp_unit_list); SBBreakpoint sb_bp; TargetSP target_sp(GetSP()); @@ -822,37 +851,49 @@ lldb::SBBreakpoint SBTarget::BreakpointCreateByName( skip_prologue, internal, hardware); } - if (log) - log->Printf("SBTarget(%p)::BreakpointCreateByName (symbol=\"%s\", " - "name_type: %d) => SBBreakpoint(%p)", - static_cast<void *>(target_sp.get()), symbol_name, - name_type_mask, static_cast<void *>(sb_bp.GetSP().get())); - - return sb_bp; + return LLDB_RECORD_RESULT(sb_bp); } lldb::SBBreakpoint SBTarget::BreakpointCreateByNames( const char *symbol_names[], uint32_t num_names, uint32_t name_type_mask, const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) { - return BreakpointCreateByNames(symbol_names, num_names, name_type_mask, - eLanguageTypeUnknown, module_list, - comp_unit_list); + LLDB_RECORD_METHOD( + lldb::SBBreakpoint, SBTarget, BreakpointCreateByNames, + (const char **, uint32_t, uint32_t, const lldb::SBFileSpecList &, + const lldb::SBFileSpecList &), + symbol_names, num_names, name_type_mask, module_list, comp_unit_list); + + return LLDB_RECORD_RESULT(BreakpointCreateByNames( + symbol_names, num_names, name_type_mask, eLanguageTypeUnknown, + module_list, comp_unit_list)); } lldb::SBBreakpoint SBTarget::BreakpointCreateByNames( const char *symbol_names[], uint32_t num_names, uint32_t name_type_mask, LanguageType symbol_language, const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) { - return BreakpointCreateByNames(symbol_names, num_names, name_type_mask, - eLanguageTypeUnknown, 0, module_list, - comp_unit_list); + LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByNames, + (const char **, uint32_t, uint32_t, lldb::LanguageType, + const lldb::SBFileSpecList &, + const lldb::SBFileSpecList &), + symbol_names, num_names, name_type_mask, symbol_language, + module_list, comp_unit_list); + + return LLDB_RECORD_RESULT(BreakpointCreateByNames( + symbol_names, num_names, name_type_mask, eLanguageTypeUnknown, 0, + module_list, comp_unit_list)); } lldb::SBBreakpoint SBTarget::BreakpointCreateByNames( const char *symbol_names[], uint32_t num_names, uint32_t name_type_mask, LanguageType symbol_language, lldb::addr_t offset, const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByNames, + (const char **, uint32_t, uint32_t, lldb::LanguageType, + lldb::addr_t, const lldb::SBFileSpecList &, + const lldb::SBFileSpecList &), + symbol_names, num_names, name_type_mask, symbol_language, + offset, module_list, comp_unit_list); SBBreakpoint sb_bp; TargetSP target_sp(GetSP()); @@ -867,50 +908,47 @@ lldb::SBBreakpoint SBTarget::BreakpointCreateByNames( symbol_language, offset, skip_prologue, internal, hardware); } - if (log) { - log->Printf("SBTarget(%p)::BreakpointCreateByName (symbols={", - static_cast<void *>(target_sp.get())); - for (uint32_t i = 0; i < num_names; i++) { - char sep; - if (i < num_names - 1) - sep = ','; - else - sep = '}'; - if (symbol_names[i] != NULL) - log->Printf("\"%s\"%c ", symbol_names[i], sep); - else - log->Printf("\"<NULL>\"%c ", sep); - } - log->Printf("name_type: %d) => SBBreakpoint(%p)", name_type_mask, - static_cast<void *>(sb_bp.GetSP().get())); - } - - return sb_bp; + return LLDB_RECORD_RESULT(sb_bp); } SBBreakpoint SBTarget::BreakpointCreateByRegex(const char *symbol_name_regex, const char *module_name) { + LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByRegex, + (const char *, const char *), symbol_name_regex, + module_name); + SBFileSpecList module_spec_list; SBFileSpecList comp_unit_list; if (module_name && module_name[0]) { module_spec_list.Append(FileSpec(module_name)); } - return BreakpointCreateByRegex(symbol_name_regex, eLanguageTypeUnknown, - module_spec_list, comp_unit_list); + return LLDB_RECORD_RESULT( + BreakpointCreateByRegex(symbol_name_regex, eLanguageTypeUnknown, + module_spec_list, comp_unit_list)); } lldb::SBBreakpoint SBTarget::BreakpointCreateByRegex(const char *symbol_name_regex, const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) { - return BreakpointCreateByRegex(symbol_name_regex, eLanguageTypeUnknown, - module_list, comp_unit_list); + LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByRegex, + (const char *, const lldb::SBFileSpecList &, + const lldb::SBFileSpecList &), + symbol_name_regex, module_list, comp_unit_list); + + return LLDB_RECORD_RESULT(BreakpointCreateByRegex( + symbol_name_regex, eLanguageTypeUnknown, module_list, comp_unit_list)); } lldb::SBBreakpoint SBTarget::BreakpointCreateByRegex( const char *symbol_name_regex, LanguageType symbol_language, const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD( + lldb::SBBreakpoint, SBTarget, BreakpointCreateByRegex, + (const char *, lldb::LanguageType, const lldb::SBFileSpecList &, + const lldb::SBFileSpecList &), + symbol_name_regex, symbol_language, module_list, comp_unit_list); + SBBreakpoint sb_bp; TargetSP target_sp(GetSP()); @@ -926,17 +964,12 @@ lldb::SBBreakpoint SBTarget::BreakpointCreateByRegex( skip_prologue, internal, hardware); } - if (log) - log->Printf("SBTarget(%p)::BreakpointCreateByRegex (symbol_regex=\"%s\") " - "=> SBBreakpoint(%p)", - static_cast<void *>(target_sp.get()), symbol_name_regex, - static_cast<void *>(sb_bp.GetSP().get())); - - return sb_bp; + return LLDB_RECORD_RESULT(sb_bp); } SBBreakpoint SBTarget::BreakpointCreateByAddress(addr_t address) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByAddress, + (lldb::addr_t), address); SBBreakpoint sb_bp; TargetSP target_sp(GetSP()); @@ -946,27 +979,17 @@ SBBreakpoint SBTarget::BreakpointCreateByAddress(addr_t address) { sb_bp = target_sp->CreateBreakpoint(address, false, hardware); } - if (log) - log->Printf("SBTarget(%p)::BreakpointCreateByAddress (address=%" PRIu64 - ") => SBBreakpoint(%p)", - static_cast<void *>(target_sp.get()), - static_cast<uint64_t>(address), - static_cast<void *>(sb_bp.GetSP().get())); - - return sb_bp; + return LLDB_RECORD_RESULT(sb_bp); } SBBreakpoint SBTarget::BreakpointCreateBySBAddress(SBAddress &sb_address) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateBySBAddress, + (lldb::SBAddress &), sb_address); SBBreakpoint sb_bp; TargetSP target_sp(GetSP()); if (!sb_address.IsValid()) { - if (log) - log->Printf("SBTarget(%p)::BreakpointCreateBySBAddress called with " - "invalid address", - static_cast<void *>(target_sp.get())); - return sb_bp; + return LLDB_RECORD_RESULT(sb_bp); } if (target_sp) { @@ -975,22 +998,18 @@ SBBreakpoint SBTarget::BreakpointCreateBySBAddress(SBAddress &sb_address) { sb_bp = target_sp->CreateBreakpoint(sb_address.ref(), false, hardware); } - if (log) { - SBStream s; - sb_address.GetDescription(s); - log->Printf("SBTarget(%p)::BreakpointCreateBySBAddress (address=%s) => " - "SBBreakpoint(%p)", - static_cast<void *>(target_sp.get()), s.GetData(), - static_cast<void *>(sb_bp.GetSP().get())); - } - - return sb_bp; + return LLDB_RECORD_RESULT(sb_bp); } lldb::SBBreakpoint SBTarget::BreakpointCreateBySourceRegex(const char *source_regex, const lldb::SBFileSpec &source_file, const char *module_name) { + LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, + BreakpointCreateBySourceRegex, + (const char *, const lldb::SBFileSpec &, const char *), + source_regex, source_file, module_name); + SBFileSpecList module_spec_list; if (module_name && module_name[0]) { @@ -1002,22 +1021,32 @@ SBTarget::BreakpointCreateBySourceRegex(const char *source_regex, source_file_list.Append(source_file); } - return BreakpointCreateBySourceRegex(source_regex, module_spec_list, - source_file_list); + return LLDB_RECORD_RESULT(BreakpointCreateBySourceRegex( + source_regex, module_spec_list, source_file_list)); } lldb::SBBreakpoint SBTarget::BreakpointCreateBySourceRegex( const char *source_regex, const SBFileSpecList &module_list, const lldb::SBFileSpecList &source_file_list) { - return BreakpointCreateBySourceRegex(source_regex, module_list, - source_file_list, SBStringList()); + LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, + BreakpointCreateBySourceRegex, + (const char *, const lldb::SBFileSpecList &, + const lldb::SBFileSpecList &), + source_regex, module_list, source_file_list); + + return LLDB_RECORD_RESULT(BreakpointCreateBySourceRegex( + source_regex, module_list, source_file_list, SBStringList())); } lldb::SBBreakpoint SBTarget::BreakpointCreateBySourceRegex( const char *source_regex, const SBFileSpecList &module_list, const lldb::SBFileSpecList &source_file_list, const SBStringList &func_names) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, + BreakpointCreateBySourceRegex, + (const char *, const lldb::SBFileSpecList &, + const lldb::SBFileSpecList &, const lldb::SBStringList &), + source_regex, module_list, source_file_list, func_names); SBBreakpoint sb_bp; TargetSP target_sp(GetSP()); @@ -1036,19 +1065,15 @@ lldb::SBBreakpoint SBTarget::BreakpointCreateBySourceRegex( false, hardware, move_to_nearest_code); } - if (log) - log->Printf("SBTarget(%p)::BreakpointCreateByRegex (source_regex=\"%s\") " - "=> SBBreakpoint(%p)", - static_cast<void *>(target_sp.get()), source_regex, - static_cast<void *>(sb_bp.GetSP().get())); - - return sb_bp; + return LLDB_RECORD_RESULT(sb_bp); } lldb::SBBreakpoint SBTarget::BreakpointCreateForException(lldb::LanguageType language, bool catch_bp, bool throw_bp) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateForException, + (lldb::LanguageType, bool, bool), language, catch_bp, + throw_bp); SBBreakpoint sb_bp; TargetSP target_sp(GetSP()); @@ -1059,32 +1084,25 @@ SBTarget::BreakpointCreateForException(lldb::LanguageType language, hardware); } - if (log) - log->Printf("SBTarget(%p)::BreakpointCreateForException (Language: %s, catch: " - "%s throw: %s) => SBBreakpoint(%p)", - static_cast<void *>(target_sp.get()), - Language::GetNameForLanguageType(language), - catch_bp ? "on" : "off", throw_bp ? "on" : "off", - static_cast<void *>(sb_bp.GetSP().get())); - - return sb_bp; + return LLDB_RECORD_RESULT(sb_bp); } -lldb::SBBreakpoint -SBTarget::BreakpointCreateFromScript(const char *class_name, - SBStructuredData &extra_args, - const SBFileSpecList &module_list, - const SBFileSpecList &file_list, - bool request_hardware) -{ - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); +lldb::SBBreakpoint SBTarget::BreakpointCreateFromScript( + const char *class_name, SBStructuredData &extra_args, + const SBFileSpecList &module_list, const SBFileSpecList &file_list, + bool request_hardware) { + LLDB_RECORD_METHOD( + lldb::SBBreakpoint, SBTarget, BreakpointCreateFromScript, + (const char *, lldb::SBStructuredData &, const lldb::SBFileSpecList &, + const lldb::SBFileSpecList &, bool), + class_name, extra_args, module_list, file_list, request_hardware); SBBreakpoint sb_bp; TargetSP target_sp(GetSP()); if (target_sp) { std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); Status error; - + StructuredData::ObjectSP obj_sp = extra_args.m_impl_up->GetObjectSP(); sb_bp = target_sp->CreateScriptedBreakpoint(class_name, @@ -1095,18 +1113,13 @@ SBTarget::BreakpointCreateFromScript(const char *class_name, obj_sp, &error); } - if (log) - log->Printf("SBTarget(%p)::BreakpointCreateFromScript (class name: %s) " - " => SBBreakpoint(%p)", - static_cast<void *>(target_sp.get()), - class_name, - static_cast<void *>(sb_bp.GetSP().get())); - return sb_bp; + return LLDB_RECORD_RESULT(sb_bp); } - uint32_t SBTarget::GetNumBreakpoints() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBTarget, GetNumBreakpoints); + TargetSP target_sp(GetSP()); if (target_sp) { // The breakpoint list is thread safe, no need to lock @@ -1116,17 +1129,21 @@ uint32_t SBTarget::GetNumBreakpoints() const { } SBBreakpoint SBTarget::GetBreakpointAtIndex(uint32_t idx) const { + LLDB_RECORD_METHOD_CONST(lldb::SBBreakpoint, SBTarget, GetBreakpointAtIndex, + (uint32_t), idx); + SBBreakpoint sb_breakpoint; TargetSP target_sp(GetSP()); if (target_sp) { // The breakpoint list is thread safe, no need to lock sb_breakpoint = target_sp->GetBreakpointList().GetBreakpointAtIndex(idx); } - return sb_breakpoint; + return LLDB_RECORD_RESULT(sb_breakpoint); } bool SBTarget::BreakpointDelete(break_id_t bp_id) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(bool, SBTarget, BreakpointDelete, (lldb::break_id_t), + bp_id); bool result = false; TargetSP target_sp(GetSP()); @@ -1135,16 +1152,12 @@ bool SBTarget::BreakpointDelete(break_id_t bp_id) { result = target_sp->RemoveBreakpointByID(bp_id); } - if (log) - log->Printf("SBTarget(%p)::BreakpointDelete (bp_id=%d) => %i", - static_cast<void *>(target_sp.get()), - static_cast<uint32_t>(bp_id), result); - return result; } SBBreakpoint SBTarget::FindBreakpointByID(break_id_t bp_id) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, FindBreakpointByID, + (lldb::break_id_t), bp_id); SBBreakpoint sb_breakpoint; TargetSP target_sp(GetSP()); @@ -1153,17 +1166,14 @@ SBBreakpoint SBTarget::FindBreakpointByID(break_id_t bp_id) { sb_breakpoint = target_sp->GetBreakpointByID(bp_id); } - if (log) - log->Printf( - "SBTarget(%p)::FindBreakpointByID (bp_id=%d) => SBBreakpoint(%p)", - static_cast<void *>(target_sp.get()), static_cast<uint32_t>(bp_id), - static_cast<void *>(sb_breakpoint.GetSP().get())); - - return sb_breakpoint; + return LLDB_RECORD_RESULT(sb_breakpoint); } bool SBTarget::FindBreakpointsByName(const char *name, SBBreakpointList &bkpts) { + LLDB_RECORD_METHOD(bool, SBTarget, FindBreakpointsByName, + (const char *, lldb::SBBreakpointList &), name, bkpts); + TargetSP target_sp(GetSP()); if (target_sp) { std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); @@ -1179,8 +1189,10 @@ bool SBTarget::FindBreakpointsByName(const char *name, return true; } -void SBTarget::GetBreakpointNames(SBStringList &names) -{ +void SBTarget::GetBreakpointNames(SBStringList &names) { + LLDB_RECORD_METHOD(void, SBTarget, GetBreakpointNames, (lldb::SBStringList &), + names); + names.Clear(); TargetSP target_sp(GetSP()); @@ -1194,8 +1206,10 @@ void SBTarget::GetBreakpointNames(SBStringList &names) } } -void SBTarget::DeleteBreakpointName(const char *name) -{ +void SBTarget::DeleteBreakpointName(const char *name) { + LLDB_RECORD_METHOD(void, SBTarget, DeleteBreakpointName, (const char *), + name); + TargetSP target_sp(GetSP()); if (target_sp) { std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); @@ -1204,6 +1218,8 @@ void SBTarget::DeleteBreakpointName(const char *name) } bool SBTarget::EnableAllBreakpoints() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, EnableAllBreakpoints); + TargetSP target_sp(GetSP()); if (target_sp) { std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); @@ -1214,6 +1230,8 @@ bool SBTarget::EnableAllBreakpoints() { } bool SBTarget::DisableAllBreakpoints() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, DisableAllBreakpoints); + TargetSP target_sp(GetSP()); if (target_sp) { std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); @@ -1224,6 +1242,8 @@ bool SBTarget::DisableAllBreakpoints() { } bool SBTarget::DeleteAllBreakpoints() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, DeleteAllBreakpoints); + TargetSP target_sp(GetSP()); if (target_sp) { std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); @@ -1235,19 +1255,29 @@ bool SBTarget::DeleteAllBreakpoints() { lldb::SBError SBTarget::BreakpointsCreateFromFile(SBFileSpec &source_file, SBBreakpointList &new_bps) { + LLDB_RECORD_METHOD(lldb::SBError, SBTarget, BreakpointsCreateFromFile, + (lldb::SBFileSpec &, lldb::SBBreakpointList &), + source_file, new_bps); + SBStringList empty_name_list; - return BreakpointsCreateFromFile(source_file, empty_name_list, new_bps); + return LLDB_RECORD_RESULT( + BreakpointsCreateFromFile(source_file, empty_name_list, new_bps)); } lldb::SBError SBTarget::BreakpointsCreateFromFile(SBFileSpec &source_file, SBStringList &matching_names, SBBreakpointList &new_bps) { + LLDB_RECORD_METHOD( + lldb::SBError, SBTarget, BreakpointsCreateFromFile, + (lldb::SBFileSpec &, lldb::SBStringList &, lldb::SBBreakpointList &), + source_file, matching_names, new_bps); + SBError sberr; TargetSP target_sp(GetSP()); if (!target_sp) { sberr.SetErrorString( "BreakpointCreateFromFile called with invalid target."); - return sberr; + return LLDB_RECORD_RESULT(sberr); } std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); @@ -1261,35 +1291,42 @@ lldb::SBError SBTarget::BreakpointsCreateFromFile(SBFileSpec &source_file, sberr.ref() = target_sp->CreateBreakpointsFromFile(source_file.ref(), name_vector, bp_ids); if (sberr.Fail()) - return sberr; + return LLDB_RECORD_RESULT(sberr); size_t num_bkpts = bp_ids.GetSize(); for (size_t i = 0; i < num_bkpts; i++) { BreakpointID bp_id = bp_ids.GetBreakpointIDAtIndex(i); new_bps.AppendByID(bp_id.GetBreakpointID()); } - return sberr; + return LLDB_RECORD_RESULT(sberr); } lldb::SBError SBTarget::BreakpointsWriteToFile(SBFileSpec &dest_file) { + LLDB_RECORD_METHOD(lldb::SBError, SBTarget, BreakpointsWriteToFile, + (lldb::SBFileSpec &), dest_file); + SBError sberr; TargetSP target_sp(GetSP()); if (!target_sp) { sberr.SetErrorString("BreakpointWriteToFile called with invalid target."); - return sberr; + return LLDB_RECORD_RESULT(sberr); } SBBreakpointList bkpt_list(*this); - return BreakpointsWriteToFile(dest_file, bkpt_list); + return LLDB_RECORD_RESULT(BreakpointsWriteToFile(dest_file, bkpt_list)); } lldb::SBError SBTarget::BreakpointsWriteToFile(SBFileSpec &dest_file, SBBreakpointList &bkpt_list, bool append) { + LLDB_RECORD_METHOD(lldb::SBError, SBTarget, BreakpointsWriteToFile, + (lldb::SBFileSpec &, lldb::SBBreakpointList &, bool), + dest_file, bkpt_list, append); + SBError sberr; TargetSP target_sp(GetSP()); if (!target_sp) { sberr.SetErrorString("BreakpointWriteToFile called with invalid target."); - return sberr; + return LLDB_RECORD_RESULT(sberr); } std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); @@ -1297,10 +1334,12 @@ lldb::SBError SBTarget::BreakpointsWriteToFile(SBFileSpec &dest_file, bkpt_list.CopyToBreakpointIDList(bp_id_list); sberr.ref() = target_sp->SerializeBreakpointsToFile(dest_file.ref(), bp_id_list, append); - return sberr; + return LLDB_RECORD_RESULT(sberr); } uint32_t SBTarget::GetNumWatchpoints() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBTarget, GetNumWatchpoints); + TargetSP target_sp(GetSP()); if (target_sp) { // The watchpoint list is thread safe, no need to lock @@ -1310,17 +1349,22 @@ uint32_t SBTarget::GetNumWatchpoints() const { } SBWatchpoint SBTarget::GetWatchpointAtIndex(uint32_t idx) const { + LLDB_RECORD_METHOD_CONST(lldb::SBWatchpoint, SBTarget, GetWatchpointAtIndex, + (uint32_t), idx); + SBWatchpoint sb_watchpoint; TargetSP target_sp(GetSP()); if (target_sp) { // The watchpoint list is thread safe, no need to lock sb_watchpoint.SetSP(target_sp->GetWatchpointList().GetByIndex(idx)); } - return sb_watchpoint; + return LLDB_RECORD_RESULT(sb_watchpoint); } bool SBTarget::DeleteWatchpoint(watch_id_t wp_id) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(bool, SBTarget, DeleteWatchpoint, (lldb::watch_id_t), + wp_id); + bool result = false; TargetSP target_sp(GetSP()); @@ -1331,16 +1375,13 @@ bool SBTarget::DeleteWatchpoint(watch_id_t wp_id) { result = target_sp->RemoveWatchpointByID(wp_id); } - if (log) - log->Printf("SBTarget(%p)::WatchpointDelete (wp_id=%d) => %i", - static_cast<void *>(target_sp.get()), - static_cast<uint32_t>(wp_id), result); - return result; } SBWatchpoint SBTarget::FindWatchpointByID(lldb::watch_id_t wp_id) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(lldb::SBWatchpoint, SBTarget, FindWatchpointByID, + (lldb::watch_id_t), wp_id); + SBWatchpoint sb_watchpoint; lldb::WatchpointSP watchpoint_sp; @@ -1353,19 +1394,15 @@ SBWatchpoint SBTarget::FindWatchpointByID(lldb::watch_id_t wp_id) { sb_watchpoint.SetSP(watchpoint_sp); } - if (log) - log->Printf( - "SBTarget(%p)::FindWatchpointByID (bp_id=%d) => SBWatchpoint(%p)", - static_cast<void *>(target_sp.get()), static_cast<uint32_t>(wp_id), - static_cast<void *>(watchpoint_sp.get())); - - return sb_watchpoint; + return LLDB_RECORD_RESULT(sb_watchpoint); } lldb::SBWatchpoint SBTarget::WatchAddress(lldb::addr_t addr, size_t size, bool read, bool write, SBError &error) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(lldb::SBWatchpoint, SBTarget, WatchAddress, + (lldb::addr_t, size_t, bool, bool, lldb::SBError &), addr, + size, read, write, error); SBWatchpoint sb_watchpoint; lldb::WatchpointSP watchpoint_sp; @@ -1381,30 +1418,25 @@ lldb::SBWatchpoint SBTarget::WatchAddress(lldb::addr_t addr, size_t size, if (watch_type == 0) { error.SetErrorString( "Can't create a watchpoint that is neither read nor write."); - return sb_watchpoint; + return LLDB_RECORD_RESULT(sb_watchpoint); } // Target::CreateWatchpoint() is thread safe. Status cw_error; // This API doesn't take in a type, so we can't figure out what it is. - CompilerType *type = NULL; + CompilerType *type = nullptr; watchpoint_sp = target_sp->CreateWatchpoint(addr, size, type, watch_type, cw_error); error.SetError(cw_error); sb_watchpoint.SetSP(watchpoint_sp); } - if (log) - log->Printf("SBTarget(%p)::WatchAddress (addr=0x%" PRIx64 - ", 0x%u) => SBWatchpoint(%p)", - static_cast<void *>(target_sp.get()), addr, - static_cast<uint32_t>(size), - static_cast<void *>(watchpoint_sp.get())); - - return sb_watchpoint; + return LLDB_RECORD_RESULT(sb_watchpoint); } bool SBTarget::EnableAllWatchpoints() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, EnableAllWatchpoints); + TargetSP target_sp(GetSP()); if (target_sp) { std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); @@ -1417,6 +1449,8 @@ bool SBTarget::EnableAllWatchpoints() { } bool SBTarget::DisableAllWatchpoints() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, DisableAllWatchpoints); + TargetSP target_sp(GetSP()); if (target_sp) { std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); @@ -1430,6 +1464,10 @@ bool SBTarget::DisableAllWatchpoints() { SBValue SBTarget::CreateValueFromAddress(const char *name, SBAddress addr, SBType type) { + LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, CreateValueFromAddress, + (const char *, lldb::SBAddress, lldb::SBType), name, addr, + type); + SBValue sb_value; lldb::ValueObjectSP new_value_sp; if (IsValid() && name && *name && addr.IsValid() && type.IsValid()) { @@ -1441,21 +1479,15 @@ SBValue SBTarget::CreateValueFromAddress(const char *name, SBAddress addr, exe_ctx, ast_type); } sb_value.SetSP(new_value_sp); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) { - if (new_value_sp) - log->Printf("SBTarget(%p)::CreateValueFromAddress => \"%s\"", - static_cast<void *>(m_opaque_sp.get()), - new_value_sp->GetName().AsCString()); - else - log->Printf("SBTarget(%p)::CreateValueFromAddress => NULL", - static_cast<void *>(m_opaque_sp.get())); - } - return sb_value; + return LLDB_RECORD_RESULT(sb_value); } lldb::SBValue SBTarget::CreateValueFromData(const char *name, lldb::SBData data, lldb::SBType type) { + LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, CreateValueFromData, + (const char *, lldb::SBData, lldb::SBType), name, data, + type); + SBValue sb_value; lldb::ValueObjectSP new_value_sp; if (IsValid() && name && *name && data.IsValid() && type.IsValid()) { @@ -1467,21 +1499,14 @@ lldb::SBValue SBTarget::CreateValueFromData(const char *name, lldb::SBData data, exe_ctx, ast_type); } sb_value.SetSP(new_value_sp); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) { - if (new_value_sp) - log->Printf("SBTarget(%p)::CreateValueFromData => \"%s\"", - static_cast<void *>(m_opaque_sp.get()), - new_value_sp->GetName().AsCString()); - else - log->Printf("SBTarget(%p)::CreateValueFromData => NULL", - static_cast<void *>(m_opaque_sp.get())); - } - return sb_value; + return LLDB_RECORD_RESULT(sb_value); } lldb::SBValue SBTarget::CreateValueFromExpression(const char *name, const char *expr) { + LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, CreateValueFromExpression, + (const char *, const char *), name, expr); + SBValue sb_value; lldb::ValueObjectSP new_value_sp; if (IsValid() && name && *name && expr && *expr) { @@ -1491,20 +1516,12 @@ lldb::SBValue SBTarget::CreateValueFromExpression(const char *name, ValueObject::CreateValueObjectFromExpression(name, expr, exe_ctx); } sb_value.SetSP(new_value_sp); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) { - if (new_value_sp) - log->Printf("SBTarget(%p)::CreateValueFromExpression => \"%s\"", - static_cast<void *>(m_opaque_sp.get()), - new_value_sp->GetName().AsCString()); - else - log->Printf("SBTarget(%p)::CreateValueFromExpression => NULL", - static_cast<void *>(m_opaque_sp.get())); - } - return sb_value; + return LLDB_RECORD_RESULT(sb_value); } bool SBTarget::DeleteAllWatchpoints() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, DeleteAllWatchpoints); + TargetSP target_sp(GetSP()); if (target_sp) { std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); @@ -1518,6 +1535,10 @@ bool SBTarget::DeleteAllWatchpoints() { void SBTarget::AppendImageSearchPath(const char *from, const char *to, lldb::SBError &error) { + LLDB_RECORD_METHOD(void, SBTarget, AppendImageSearchPath, + (const char *, const char *, lldb::SBError &), from, to, + error); + TargetSP target_sp(GetSP()); if (!target_sp) return error.SetErrorString("invalid target"); @@ -1528,21 +1549,24 @@ void SBTarget::AppendImageSearchPath(const char *from, const char *to, if (!csTo) return error.SetErrorString("<to> path can't be empty"); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBTarget(%p)::%s: '%s' -> '%s'", - static_cast<void *>(target_sp.get()), __FUNCTION__, - from, to); target_sp->GetImageSearchPathList().Append(csFrom, csTo, true); } lldb::SBModule SBTarget::AddModule(const char *path, const char *triple, const char *uuid_cstr) { - return AddModule(path, triple, uuid_cstr, NULL); + LLDB_RECORD_METHOD(lldb::SBModule, SBTarget, AddModule, + (const char *, const char *, const char *), path, triple, + uuid_cstr); + + return LLDB_RECORD_RESULT(AddModule(path, triple, uuid_cstr, nullptr)); } lldb::SBModule SBTarget::AddModule(const char *path, const char *triple, const char *uuid_cstr, const char *symfile) { + LLDB_RECORD_METHOD(lldb::SBModule, SBTarget, AddModule, + (const char *, const char *, const char *, const char *), + path, triple, uuid_cstr, symfile); + lldb::SBModule sb_module; TargetSP target_sp(GetSP()); if (target_sp) { @@ -1562,20 +1586,26 @@ lldb::SBModule SBTarget::AddModule(const char *path, const char *triple, if (symfile) module_spec.GetSymbolFileSpec().SetFile(symfile, FileSpec::Style::native); - sb_module.SetSP(target_sp->GetSharedModule(module_spec)); + sb_module.SetSP(target_sp->GetOrCreateModule(module_spec, true /* notify */)); } - return sb_module; + return LLDB_RECORD_RESULT(sb_module); } lldb::SBModule SBTarget::AddModule(const SBModuleSpec &module_spec) { + LLDB_RECORD_METHOD(lldb::SBModule, SBTarget, AddModule, + (const lldb::SBModuleSpec &), module_spec); + lldb::SBModule sb_module; TargetSP target_sp(GetSP()); if (target_sp) - sb_module.SetSP(target_sp->GetSharedModule(*module_spec.m_opaque_ap)); - return sb_module; + sb_module.SetSP(target_sp->GetOrCreateModule(*module_spec.m_opaque_up, + true /* notify */)); + return LLDB_RECORD_RESULT(sb_module); } bool SBTarget::AddModule(lldb::SBModule &module) { + LLDB_RECORD_METHOD(bool, SBTarget, AddModule, (lldb::SBModule &), module); + TargetSP target_sp(GetSP()); if (target_sp) { target_sp->GetImages().AppendIfNeeded(module.GetSP()); @@ -1585,7 +1615,7 @@ bool SBTarget::AddModule(lldb::SBModule &module) { } uint32_t SBTarget::GetNumModules() const { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBTarget, GetNumModules); uint32_t num = 0; TargetSP target_sp(GetSP()); @@ -1594,24 +1624,19 @@ uint32_t SBTarget::GetNumModules() const { num = target_sp->GetImages().GetSize(); } - if (log) - log->Printf("SBTarget(%p)::GetNumModules () => %d", - static_cast<void *>(target_sp.get()), num); - return num; } void SBTarget::Clear() { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - - if (log) - log->Printf("SBTarget(%p)::Clear ()", - static_cast<void *>(m_opaque_sp.get())); + LLDB_RECORD_METHOD_NO_ARGS(void, SBTarget, Clear); m_opaque_sp.reset(); } SBModule SBTarget::FindModule(const SBFileSpec &sb_file_spec) { + LLDB_RECORD_METHOD(lldb::SBModule, SBTarget, FindModule, + (const lldb::SBFileSpec &), sb_file_spec); + SBModule sb_module; TargetSP target_sp(GetSP()); if (target_sp && sb_file_spec.IsValid()) { @@ -1619,11 +1644,13 @@ SBModule SBTarget::FindModule(const SBFileSpec &sb_file_spec) { // The module list is thread safe, no need to lock sb_module.SetSP(target_sp->GetImages().FindFirstModule(module_spec)); } - return sb_module; + return LLDB_RECORD_RESULT(sb_module); } -SBSymbolContextList -SBTarget::FindCompileUnits(const SBFileSpec &sb_file_spec) { +SBSymbolContextList SBTarget::FindCompileUnits(const SBFileSpec &sb_file_spec) { + LLDB_RECORD_METHOD(lldb::SBSymbolContextList, SBTarget, FindCompileUnits, + (const lldb::SBFileSpec &), sb_file_spec); + SBSymbolContextList sb_sc_list; const TargetSP target_sp(GetSP()); if (target_sp && sb_file_spec.IsValid()) { @@ -1631,10 +1658,12 @@ SBTarget::FindCompileUnits(const SBFileSpec &sb_file_spec) { target_sp->GetImages().FindCompileUnits(*sb_file_spec, append, *sb_sc_list); } - return sb_sc_list; + return LLDB_RECORD_RESULT(sb_sc_list); } lldb::ByteOrder SBTarget::GetByteOrder() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::ByteOrder, SBTarget, GetByteOrder); + TargetSP target_sp(GetSP()); if (target_sp) return target_sp->GetArchitecture().GetByteOrder(); @@ -1642,6 +1671,8 @@ lldb::ByteOrder SBTarget::GetByteOrder() { } const char *SBTarget::GetTriple() { + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTarget, GetTriple); + TargetSP target_sp(GetSP()); if (target_sp) { std::string triple(target_sp->GetArchitecture().GetTriple().str()); @@ -1651,10 +1682,12 @@ const char *SBTarget::GetTriple() { ConstString const_triple(triple.c_str()); return const_triple.GetCString(); } - return NULL; + return nullptr; } uint32_t SBTarget::GetDataByteSize() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTarget, GetDataByteSize); + TargetSP target_sp(GetSP()); if (target_sp) { return target_sp->GetArchitecture().GetDataByteSize(); @@ -1663,6 +1696,8 @@ uint32_t SBTarget::GetDataByteSize() { } uint32_t SBTarget::GetCodeByteSize() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTarget, GetCodeByteSize); + TargetSP target_sp(GetSP()); if (target_sp) { return target_sp->GetArchitecture().GetCodeByteSize(); @@ -1671,6 +1706,8 @@ uint32_t SBTarget::GetCodeByteSize() { } uint32_t SBTarget::GetAddressByteSize() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTarget, GetAddressByteSize); + TargetSP target_sp(GetSP()); if (target_sp) return target_sp->GetArchitecture().GetAddressByteSize(); @@ -1678,7 +1715,8 @@ uint32_t SBTarget::GetAddressByteSize() { } SBModule SBTarget::GetModuleAtIndex(uint32_t idx) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(lldb::SBModule, SBTarget, GetModuleAtIndex, (uint32_t), + idx); SBModule sb_module; ModuleSP module_sp; @@ -1689,15 +1727,12 @@ SBModule SBTarget::GetModuleAtIndex(uint32_t idx) { sb_module.SetSP(module_sp); } - if (log) - log->Printf("SBTarget(%p)::GetModuleAtIndex (idx=%d) => SBModule(%p)", - static_cast<void *>(target_sp.get()), idx, - static_cast<void *>(module_sp.get())); - - return sb_module; + return LLDB_RECORD_RESULT(sb_module); } bool SBTarget::RemoveModule(lldb::SBModule module) { + LLDB_RECORD_METHOD(bool, SBTarget, RemoveModule, (lldb::SBModule), module); + TargetSP target_sp(GetSP()); if (target_sp) return target_sp->GetImages().Remove(module.GetSP()); @@ -1705,21 +1740,23 @@ bool SBTarget::RemoveModule(lldb::SBModule module) { } SBBroadcaster SBTarget::GetBroadcaster() const { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBBroadcaster, SBTarget, + GetBroadcaster); + TargetSP target_sp(GetSP()); SBBroadcaster broadcaster(target_sp.get(), false); - if (log) - log->Printf("SBTarget(%p)::GetBroadcaster () => SBBroadcaster(%p)", - static_cast<void *>(target_sp.get()), - static_cast<void *>(broadcaster.get())); - return broadcaster; + return LLDB_RECORD_RESULT(broadcaster); } bool SBTarget::GetDescription(SBStream &description, lldb::DescriptionLevel description_level) { + LLDB_RECORD_METHOD(bool, SBTarget, GetDescription, + (lldb::SBStream &, lldb::DescriptionLevel), description, + description_level); + Stream &strm = description.ref(); TargetSP target_sp(GetSP()); @@ -1733,13 +1770,16 @@ bool SBTarget::GetDescription(SBStream &description, lldb::SBSymbolContextList SBTarget::FindFunctions(const char *name, uint32_t name_type_mask) { + LLDB_RECORD_METHOD(lldb::SBSymbolContextList, SBTarget, FindFunctions, + (const char *, uint32_t), name, name_type_mask); + lldb::SBSymbolContextList sb_sc_list; if (!name | !name[0]) - return sb_sc_list; + return LLDB_RECORD_RESULT(sb_sc_list); TargetSP target_sp(GetSP()); if (!target_sp) - return sb_sc_list; + return LLDB_RECORD_RESULT(sb_sc_list); const bool symbols_ok = true; const bool inlines_ok = true; @@ -1747,12 +1787,16 @@ lldb::SBSymbolContextList SBTarget::FindFunctions(const char *name, FunctionNameType mask = static_cast<FunctionNameType>(name_type_mask); target_sp->GetImages().FindFunctions(ConstString(name), mask, symbols_ok, inlines_ok, append, *sb_sc_list); - return sb_sc_list; + return LLDB_RECORD_RESULT(sb_sc_list); } lldb::SBSymbolContextList SBTarget::FindGlobalFunctions(const char *name, uint32_t max_matches, MatchType matchtype) { + LLDB_RECORD_METHOD(lldb::SBSymbolContextList, SBTarget, FindGlobalFunctions, + (const char *, uint32_t, lldb::MatchType), name, + max_matches, matchtype); + lldb::SBSymbolContextList sb_sc_list; if (name && name[0]) { llvm::StringRef name_ref(name); @@ -1777,10 +1821,13 @@ lldb::SBSymbolContextList SBTarget::FindGlobalFunctions(const char *name, } } } - return sb_sc_list; + return LLDB_RECORD_RESULT(sb_sc_list); } lldb::SBType SBTarget::FindFirstType(const char *typename_cstr) { + LLDB_RECORD_METHOD(lldb::SBType, SBTarget, FindFirstType, (const char *), + typename_cstr); + TargetSP target_sp(GetSP()); if (typename_cstr && typename_cstr[0] && target_sp) { ConstString const_typename(typename_cstr); @@ -1795,30 +1842,17 @@ lldb::SBType SBTarget::FindFirstType(const char *typename_cstr) { TypeSP type_sp( module_sp->FindFirstType(sc, const_typename, exact_match)); if (type_sp) - return SBType(type_sp); + return LLDB_RECORD_RESULT(SBType(type_sp)); } } - // Didn't find the type in the symbols; try the Objective-C runtime if one - // is installed - - ProcessSP process_sp(target_sp->GetProcessSP()); - - if (process_sp) { - ObjCLanguageRuntime *objc_language_runtime = - process_sp->GetObjCLanguageRuntime(); - - if (objc_language_runtime) { - DeclVendor *objc_decl_vendor = objc_language_runtime->GetDeclVendor(); - - if (objc_decl_vendor) { - std::vector<clang::NamedDecl *> decls; - - if (objc_decl_vendor->FindDecls(const_typename, true, 1, decls) > 0) { - if (CompilerType type = ClangASTContext::GetTypeForDecl(decls[0])) { - return SBType(type); - } - } + // Didn't find the type in the symbols; Try the loaded language runtimes + if (auto process_sp = target_sp->GetProcessSP()) { + for (auto *runtime : process_sp->GetLanguageRuntimes()) { + if (auto vendor = runtime->GetDeclVendor()) { + auto types = vendor->FindTypes(const_typename, /*max_matches*/ 1); + if (!types.empty()) + return LLDB_RECORD_RESULT(SBType(types.front())); } } } @@ -1826,24 +1860,30 @@ lldb::SBType SBTarget::FindFirstType(const char *typename_cstr) { // No matches, search for basic typename matches ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext(); if (clang_ast) - return SBType(ClangASTContext::GetBasicType(clang_ast->getASTContext(), - const_typename)); + return LLDB_RECORD_RESULT(SBType(ClangASTContext::GetBasicType( + clang_ast->getASTContext(), const_typename))); } - return SBType(); + return LLDB_RECORD_RESULT(SBType()); } SBType SBTarget::GetBasicType(lldb::BasicType type) { + LLDB_RECORD_METHOD(lldb::SBType, SBTarget, GetBasicType, (lldb::BasicType), + type); + TargetSP target_sp(GetSP()); if (target_sp) { ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext(); if (clang_ast) - return SBType( - ClangASTContext::GetBasicType(clang_ast->getASTContext(), type)); + return LLDB_RECORD_RESULT(SBType( + ClangASTContext::GetBasicType(clang_ast->getASTContext(), type))); } - return SBType(); + return LLDB_RECORD_RESULT(SBType()); } lldb::SBTypeList SBTarget::FindTypes(const char *typename_cstr) { + LLDB_RECORD_METHOD(lldb::SBTypeList, SBTarget, FindTypes, (const char *), + typename_cstr); + SBTypeList sb_type_list; TargetSP target_sp(GetSP()); if (typename_cstr && typename_cstr[0] && target_sp) { @@ -1864,27 +1904,14 @@ lldb::SBTypeList SBTarget::FindTypes(const char *typename_cstr) { } } - // Try the Objective-C runtime if one is installed - - ProcessSP process_sp(target_sp->GetProcessSP()); - - if (process_sp) { - ObjCLanguageRuntime *objc_language_runtime = - process_sp->GetObjCLanguageRuntime(); - - if (objc_language_runtime) { - DeclVendor *objc_decl_vendor = objc_language_runtime->GetDeclVendor(); - - if (objc_decl_vendor) { - std::vector<clang::NamedDecl *> decls; - - if (objc_decl_vendor->FindDecls(const_typename, true, 1, decls) > 0) { - for (clang::NamedDecl *decl : decls) { - if (CompilerType type = ClangASTContext::GetTypeForDecl(decl)) { - sb_type_list.Append(SBType(type)); - } - } - } + // Try the loaded language runtimes + if (auto process_sp = target_sp->GetProcessSP()) { + for (auto *runtime : process_sp->GetLanguageRuntimes()) { + if (auto *vendor = runtime->GetDeclVendor()) { + auto types = + vendor->FindTypes(const_typename, /*max_matches*/ UINT32_MAX); + for (auto type : types) + sb_type_list.Append(SBType(type)); } } } @@ -1897,11 +1924,14 @@ lldb::SBTypeList SBTarget::FindTypes(const char *typename_cstr) { clang_ast->getASTContext(), const_typename))); } } - return sb_type_list; + return LLDB_RECORD_RESULT(sb_type_list); } SBValueList SBTarget::FindGlobalVariables(const char *name, uint32_t max_matches) { + LLDB_RECORD_METHOD(lldb::SBValueList, SBTarget, FindGlobalVariables, + (const char *, uint32_t), name, max_matches); + SBValueList sb_value_list; TargetSP target_sp(GetSP()); @@ -1912,7 +1942,7 @@ SBValueList SBTarget::FindGlobalVariables(const char *name, if (match_count > 0) { ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get(); - if (exe_scope == NULL) + if (exe_scope == nullptr) exe_scope = target_sp.get(); for (uint32_t i = 0; i < match_count; ++i) { lldb::ValueObjectSP valobj_sp(ValueObjectVariable::Create( @@ -1923,12 +1953,16 @@ SBValueList SBTarget::FindGlobalVariables(const char *name, } } - return sb_value_list; + return LLDB_RECORD_RESULT(sb_value_list); } SBValueList SBTarget::FindGlobalVariables(const char *name, uint32_t max_matches, MatchType matchtype) { + LLDB_RECORD_METHOD(lldb::SBValueList, SBTarget, FindGlobalVariables, + (const char *, uint32_t, lldb::MatchType), name, + max_matches, matchtype); + SBValueList sb_value_list; TargetSP target_sp(GetSP()); @@ -1956,7 +1990,7 @@ SBValueList SBTarget::FindGlobalVariables(const char *name, if (match_count > 0) { ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get(); - if (exe_scope == NULL) + if (exe_scope == nullptr) exe_scope = target_sp.get(); for (uint32_t i = 0; i < match_count; ++i) { lldb::ValueObjectSP valobj_sp(ValueObjectVariable::Create( @@ -1967,29 +2001,41 @@ SBValueList SBTarget::FindGlobalVariables(const char *name, } } - return sb_value_list; + return LLDB_RECORD_RESULT(sb_value_list); } lldb::SBValue SBTarget::FindFirstGlobalVariable(const char *name) { + LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, FindFirstGlobalVariable, + (const char *), name); + SBValueList sb_value_list(FindGlobalVariables(name, 1)); if (sb_value_list.IsValid() && sb_value_list.GetSize() > 0) - return sb_value_list.GetValueAtIndex(0); - return SBValue(); + return LLDB_RECORD_RESULT(sb_value_list.GetValueAtIndex(0)); + return LLDB_RECORD_RESULT(SBValue()); } SBSourceManager SBTarget::GetSourceManager() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBSourceManager, SBTarget, GetSourceManager); + SBSourceManager source_manager(*this); - return source_manager; + return LLDB_RECORD_RESULT(source_manager); } lldb::SBInstructionList SBTarget::ReadInstructions(lldb::SBAddress base_addr, uint32_t count) { - return ReadInstructions(base_addr, count, NULL); + LLDB_RECORD_METHOD(lldb::SBInstructionList, SBTarget, ReadInstructions, + (lldb::SBAddress, uint32_t), base_addr, count); + + return LLDB_RECORD_RESULT(ReadInstructions(base_addr, count, nullptr)); } lldb::SBInstructionList SBTarget::ReadInstructions(lldb::SBAddress base_addr, uint32_t count, const char *flavor_string) { + LLDB_RECORD_METHOD(lldb::SBInstructionList, SBTarget, ReadInstructions, + (lldb::SBAddress, uint32_t, const char *), base_addr, + count, flavor_string); + SBInstructionList sb_instructions; TargetSP target_sp(GetSP()); @@ -2007,24 +2053,33 @@ lldb::SBInstructionList SBTarget::ReadInstructions(lldb::SBAddress base_addr, data.GetByteSize(), error, &load_addr); const bool data_from_file = load_addr == LLDB_INVALID_ADDRESS; sb_instructions.SetDisassembler(Disassembler::DisassembleBytes( - target_sp->GetArchitecture(), NULL, flavor_string, *addr_ptr, + target_sp->GetArchitecture(), nullptr, flavor_string, *addr_ptr, data.GetBytes(), bytes_read, count, data_from_file)); } } - return sb_instructions; + return LLDB_RECORD_RESULT(sb_instructions); } lldb::SBInstructionList SBTarget::GetInstructions(lldb::SBAddress base_addr, const void *buf, size_t size) { - return GetInstructionsWithFlavor(base_addr, NULL, buf, size); + LLDB_RECORD_DUMMY(lldb::SBInstructionList, SBTarget, GetInstructions, + (lldb::SBAddress, const void *, size_t), base_addr, buf, + size); + + return GetInstructionsWithFlavor(base_addr, nullptr, buf, size); } lldb::SBInstructionList SBTarget::GetInstructionsWithFlavor(lldb::SBAddress base_addr, const char *flavor_string, const void *buf, size_t size) { + LLDB_RECORD_DUMMY(lldb::SBInstructionList, SBTarget, + GetInstructionsWithFlavor, + (lldb::SBAddress, const char *, const void *, size_t), + base_addr, flavor_string, buf, size); + SBInstructionList sb_instructions; TargetSP target_sp(GetSP()); @@ -2037,7 +2092,7 @@ SBTarget::GetInstructionsWithFlavor(lldb::SBAddress base_addr, const bool data_from_file = true; sb_instructions.SetDisassembler(Disassembler::DisassembleBytes( - target_sp->GetArchitecture(), NULL, flavor_string, addr, buf, size, + target_sp->GetArchitecture(), nullptr, flavor_string, addr, buf, size, UINT32_MAX, data_from_file)); } @@ -2047,7 +2102,10 @@ SBTarget::GetInstructionsWithFlavor(lldb::SBAddress base_addr, lldb::SBInstructionList SBTarget::GetInstructions(lldb::addr_t base_addr, const void *buf, size_t size) { - return GetInstructionsWithFlavor(ResolveLoadAddress(base_addr), NULL, buf, + LLDB_RECORD_DUMMY(lldb::SBInstructionList, SBTarget, GetInstructions, + (lldb::addr_t, const void *, size_t), base_addr, buf, size); + + return GetInstructionsWithFlavor(ResolveLoadAddress(base_addr), nullptr, buf, size); } @@ -2055,12 +2113,21 @@ lldb::SBInstructionList SBTarget::GetInstructionsWithFlavor(lldb::addr_t base_addr, const char *flavor_string, const void *buf, size_t size) { + LLDB_RECORD_DUMMY(lldb::SBInstructionList, SBTarget, + GetInstructionsWithFlavor, + (lldb::addr_t, const char *, const void *, size_t), + base_addr, flavor_string, buf, size); + return GetInstructionsWithFlavor(ResolveLoadAddress(base_addr), flavor_string, buf, size); } SBError SBTarget::SetSectionLoadAddress(lldb::SBSection section, lldb::addr_t section_base_addr) { + LLDB_RECORD_METHOD(lldb::SBError, SBTarget, SetSectionLoadAddress, + (lldb::SBSection, lldb::addr_t), section, + section_base_addr); + SBError sb_error; TargetSP target_sp(GetSP()); if (target_sp) { @@ -2091,10 +2158,13 @@ SBError SBTarget::SetSectionLoadAddress(lldb::SBSection section, } else { sb_error.SetErrorString("invalid target"); } - return sb_error; + return LLDB_RECORD_RESULT(sb_error); } SBError SBTarget::ClearSectionLoadAddress(lldb::SBSection section) { + LLDB_RECORD_METHOD(lldb::SBError, SBTarget, ClearSectionLoadAddress, + (lldb::SBSection), section); + SBError sb_error; TargetSP target_sp(GetSP()); @@ -2123,11 +2193,14 @@ SBError SBTarget::ClearSectionLoadAddress(lldb::SBSection section) { } else { sb_error.SetErrorStringWithFormat("invalid target"); } - return sb_error; + return LLDB_RECORD_RESULT(sb_error); } SBError SBTarget::SetModuleLoadAddress(lldb::SBModule module, int64_t slide_offset) { + LLDB_RECORD_METHOD(lldb::SBError, SBTarget, SetModuleLoadAddress, + (lldb::SBModule, int64_t), module, slide_offset); + SBError sb_error; TargetSP target_sp(GetSP()); @@ -2155,10 +2228,13 @@ SBError SBTarget::SetModuleLoadAddress(lldb::SBModule module, } else { sb_error.SetErrorStringWithFormat("invalid target"); } - return sb_error; + return LLDB_RECORD_RESULT(sb_error); } SBError SBTarget::ClearModuleLoadAddress(lldb::SBModule module) { + LLDB_RECORD_METHOD(lldb::SBError, SBTarget, ClearModuleLoadAddress, + (lldb::SBModule), module); + SBError sb_error; char path[PATH_MAX]; @@ -2204,11 +2280,14 @@ SBError SBTarget::ClearModuleLoadAddress(lldb::SBModule module) { } else { sb_error.SetErrorStringWithFormat("invalid target"); } - return sb_error; + return LLDB_RECORD_RESULT(sb_error); } lldb::SBSymbolContextList SBTarget::FindSymbols(const char *name, lldb::SymbolType symbol_type) { + LLDB_RECORD_METHOD(lldb::SBSymbolContextList, SBTarget, FindSymbols, + (const char *, lldb::SymbolType), name, symbol_type); + SBSymbolContextList sb_sc_list; if (name && name[0]) { TargetSP target_sp(GetSP()); @@ -2218,46 +2297,44 @@ lldb::SBSymbolContextList SBTarget::FindSymbols(const char *name, ConstString(name), symbol_type, *sb_sc_list, append); } } - return sb_sc_list; + return LLDB_RECORD_RESULT(sb_sc_list); } lldb::SBValue SBTarget::EvaluateExpression(const char *expr) { + LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, EvaluateExpression, + (const char *), expr); + TargetSP target_sp(GetSP()); if (!target_sp) - return SBValue(); + return LLDB_RECORD_RESULT(SBValue()); SBExpressionOptions options; lldb::DynamicValueType fetch_dynamic_value = target_sp->GetPreferDynamicValue(); options.SetFetchDynamicValue(fetch_dynamic_value); options.SetUnwindOnError(true); - return EvaluateExpression(expr, options); + return LLDB_RECORD_RESULT(EvaluateExpression(expr, options)); } lldb::SBValue SBTarget::EvaluateExpression(const char *expr, const SBExpressionOptions &options) { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); -#if !defined(LLDB_DISABLE_PYTHON) + LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, EvaluateExpression, + (const char *, const lldb::SBExpressionOptions &), expr, + options); + Log *expr_log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); -#endif SBValue expr_result; - ExpressionResults exe_results = eExpressionSetupError; ValueObjectSP expr_value_sp; TargetSP target_sp(GetSP()); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; if (target_sp) { - if (expr == NULL || expr[0] == '\0') { - if (log) - log->Printf( - "SBTarget::EvaluateExpression called with an empty expression"); - return expr_result; + if (expr == nullptr || expr[0] == '\0') { + return LLDB_RECORD_RESULT(expr_result); } std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); ExecutionContext exe_ctx(m_opaque_sp.get()); - if (log) - log->Printf("SBTarget()::EvaluateExpression (expr=\"%s\")...", expr); frame = exe_ctx.GetFramePtr(); Target *target = exe_ctx.GetTargetPtr(); @@ -2273,33 +2350,21 @@ lldb::SBValue SBTarget::EvaluateExpression(const char *expr, expr, options.GetFetchDynamicValue(), frame_description.GetString().str().c_str()); #endif - exe_results = - target->EvaluateExpression(expr, frame, expr_value_sp, options.ref()); + target->EvaluateExpression(expr, frame, expr_value_sp, options.ref()); expr_result.SetSP(expr_value_sp, options.GetFetchDynamicValue()); - } else { - if (log) - log->Printf("SBTarget::EvaluateExpression () => error: could not " - "reconstruct frame object for this SBTarget."); } } -#ifndef LLDB_DISABLE_PYTHON if (expr_log) expr_log->Printf("** [SBTarget::EvaluateExpression] Expression result is " "%s, summary %s **", expr_result.GetValue(), expr_result.GetSummary()); - - if (log) - log->Printf("SBTarget(%p)::EvaluateExpression (expr=\"%s\") => SBValue(%p) " - "(execution result=%d)", - static_cast<void *>(frame), expr, - static_cast<void *>(expr_value_sp.get()), exe_results); -#endif - - return expr_result; + return LLDB_RECORD_RESULT(expr_result); } lldb::addr_t SBTarget::GetStackRedZoneSize() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::addr_t, SBTarget, GetStackRedZoneSize); + TargetSP target_sp(GetSP()); if (target_sp) { ABISP abi_sp; @@ -2315,15 +2380,267 @@ lldb::addr_t SBTarget::GetStackRedZoneSize() { } lldb::SBLaunchInfo SBTarget::GetLaunchInfo() const { - lldb::SBLaunchInfo launch_info(NULL); + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBLaunchInfo, SBTarget, GetLaunchInfo); + + lldb::SBLaunchInfo launch_info(nullptr); TargetSP target_sp(GetSP()); if (target_sp) launch_info.set_ref(m_opaque_sp->GetProcessLaunchInfo()); - return launch_info; + return LLDB_RECORD_RESULT(launch_info); } void SBTarget::SetLaunchInfo(const lldb::SBLaunchInfo &launch_info) { + LLDB_RECORD_METHOD(void, SBTarget, SetLaunchInfo, + (const lldb::SBLaunchInfo &), launch_info); + TargetSP target_sp(GetSP()); if (target_sp) m_opaque_sp->SetProcessLaunchInfo(launch_info.ref()); } + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBTarget>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBTarget, ()); + LLDB_REGISTER_CONSTRUCTOR(SBTarget, (const lldb::SBTarget &)); + LLDB_REGISTER_CONSTRUCTOR(SBTarget, (const lldb::TargetSP &)); + LLDB_REGISTER_METHOD(const lldb::SBTarget &, + SBTarget, operator=,(const lldb::SBTarget &)); + LLDB_REGISTER_STATIC_METHOD(bool, SBTarget, EventIsTargetEvent, + (const lldb::SBEvent &)); + LLDB_REGISTER_STATIC_METHOD(lldb::SBTarget, SBTarget, GetTargetFromEvent, + (const lldb::SBEvent &)); + LLDB_REGISTER_STATIC_METHOD(uint32_t, SBTarget, GetNumModulesFromEvent, + (const lldb::SBEvent &)); + LLDB_REGISTER_STATIC_METHOD(lldb::SBModule, SBTarget, + GetModuleAtIndexFromEvent, + (const uint32_t, const lldb::SBEvent &)); + LLDB_REGISTER_STATIC_METHOD(const char *, SBTarget, GetBroadcasterClassName, + ()); + LLDB_REGISTER_METHOD_CONST(bool, SBTarget, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBTarget, operator bool, ()); + LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, GetProcess, ()); + LLDB_REGISTER_METHOD(lldb::SBPlatform, SBTarget, GetPlatform, ()); + LLDB_REGISTER_METHOD_CONST(lldb::SBDebugger, SBTarget, GetDebugger, ()); + LLDB_REGISTER_METHOD(lldb::SBStructuredData, SBTarget, GetStatistics, ()); + LLDB_REGISTER_METHOD(void, SBTarget, SetCollectingStats, (bool)); + LLDB_REGISTER_METHOD(bool, SBTarget, GetCollectingStats, ()); + LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, LoadCore, (const char *)); + LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, LoadCore, + (const char *, lldb::SBError &)); + LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, LaunchSimple, + (const char **, const char **, const char *)); + LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, Install, ()); + LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, Launch, + (lldb::SBListener &, const char **, const char **, + const char *, const char *, const char *, + const char *, uint32_t, bool, lldb::SBError &)); + LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, Launch, + (lldb::SBLaunchInfo &, lldb::SBError &)); + LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, Attach, + (lldb::SBAttachInfo &, lldb::SBError &)); + LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, AttachToProcessWithID, + (lldb::SBListener &, lldb::pid_t, lldb::SBError &)); + LLDB_REGISTER_METHOD( + lldb::SBProcess, SBTarget, AttachToProcessWithName, + (lldb::SBListener &, const char *, bool, lldb::SBError &)); + LLDB_REGISTER_METHOD( + lldb::SBProcess, SBTarget, ConnectRemote, + (lldb::SBListener &, const char *, const char *, lldb::SBError &)); + LLDB_REGISTER_METHOD(lldb::SBFileSpec, SBTarget, GetExecutable, ()); + LLDB_REGISTER_METHOD_CONST(bool, + SBTarget, operator==,(const lldb::SBTarget &)); + LLDB_REGISTER_METHOD_CONST(bool, + SBTarget, operator!=,(const lldb::SBTarget &)); + LLDB_REGISTER_METHOD(lldb::SBAddress, SBTarget, ResolveLoadAddress, + (lldb::addr_t)); + LLDB_REGISTER_METHOD(lldb::SBAddress, SBTarget, ResolveFileAddress, + (lldb::addr_t)); + LLDB_REGISTER_METHOD(lldb::SBAddress, SBTarget, ResolvePastLoadAddress, + (uint32_t, lldb::addr_t)); + LLDB_REGISTER_METHOD(lldb::SBSymbolContext, SBTarget, + ResolveSymbolContextForAddress, + (const lldb::SBAddress &, uint32_t)); + LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, + BreakpointCreateByLocation, (const char *, uint32_t)); + LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, + BreakpointCreateByLocation, + (const lldb::SBFileSpec &, uint32_t)); + LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, + BreakpointCreateByLocation, + (const lldb::SBFileSpec &, uint32_t, lldb::addr_t)); + LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, + BreakpointCreateByLocation, + (const lldb::SBFileSpec &, uint32_t, lldb::addr_t, + lldb::SBFileSpecList &)); + LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, + BreakpointCreateByLocation, + (const lldb::SBFileSpec &, uint32_t, uint32_t, + lldb::addr_t, lldb::SBFileSpecList &)); + LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName, + (const char *, const char *)); + LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName, + (const char *, const lldb::SBFileSpecList &, + const lldb::SBFileSpecList &)); + LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName, + (const char *, uint32_t, const lldb::SBFileSpecList &, + const lldb::SBFileSpecList &)); + LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName, + (const char *, uint32_t, lldb::LanguageType, + const lldb::SBFileSpecList &, + const lldb::SBFileSpecList &)); + LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByNames, + (const char **, uint32_t, uint32_t, + const lldb::SBFileSpecList &, + const lldb::SBFileSpecList &)); + LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByNames, + (const char **, uint32_t, uint32_t, lldb::LanguageType, + const lldb::SBFileSpecList &, + const lldb::SBFileSpecList &)); + LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByNames, + (const char **, uint32_t, uint32_t, lldb::LanguageType, + lldb::addr_t, const lldb::SBFileSpecList &, + const lldb::SBFileSpecList &)); + LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByRegex, + (const char *, const char *)); + LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByRegex, + (const char *, const lldb::SBFileSpecList &, + const lldb::SBFileSpecList &)); + LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByRegex, + (const char *, lldb::LanguageType, + const lldb::SBFileSpecList &, + const lldb::SBFileSpecList &)); + LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, + BreakpointCreateByAddress, (lldb::addr_t)); + LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, + BreakpointCreateBySBAddress, (lldb::SBAddress &)); + LLDB_REGISTER_METHOD( + lldb::SBBreakpoint, SBTarget, BreakpointCreateBySourceRegex, + (const char *, const lldb::SBFileSpec &, const char *)); + LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, + BreakpointCreateBySourceRegex, + (const char *, const lldb::SBFileSpecList &, + const lldb::SBFileSpecList &)); + LLDB_REGISTER_METHOD( + lldb::SBBreakpoint, SBTarget, BreakpointCreateBySourceRegex, + (const char *, const lldb::SBFileSpecList &, + const lldb::SBFileSpecList &, const lldb::SBStringList &)); + LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, + BreakpointCreateForException, + (lldb::LanguageType, bool, bool)); + LLDB_REGISTER_METHOD( + lldb::SBBreakpoint, SBTarget, BreakpointCreateFromScript, + (const char *, lldb::SBStructuredData &, const lldb::SBFileSpecList &, + const lldb::SBFileSpecList &, bool)); + LLDB_REGISTER_METHOD_CONST(uint32_t, SBTarget, GetNumBreakpoints, ()); + LLDB_REGISTER_METHOD_CONST(lldb::SBBreakpoint, SBTarget, + GetBreakpointAtIndex, (uint32_t)); + LLDB_REGISTER_METHOD(bool, SBTarget, BreakpointDelete, (lldb::break_id_t)); + LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, FindBreakpointByID, + (lldb::break_id_t)); + LLDB_REGISTER_METHOD(bool, SBTarget, FindBreakpointsByName, + (const char *, lldb::SBBreakpointList &)); + LLDB_REGISTER_METHOD(void, SBTarget, GetBreakpointNames, + (lldb::SBStringList &)); + LLDB_REGISTER_METHOD(void, SBTarget, DeleteBreakpointName, (const char *)); + LLDB_REGISTER_METHOD(bool, SBTarget, EnableAllBreakpoints, ()); + LLDB_REGISTER_METHOD(bool, SBTarget, DisableAllBreakpoints, ()); + LLDB_REGISTER_METHOD(bool, SBTarget, DeleteAllBreakpoints, ()); + LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, BreakpointsCreateFromFile, + (lldb::SBFileSpec &, lldb::SBBreakpointList &)); + LLDB_REGISTER_METHOD( + lldb::SBError, SBTarget, BreakpointsCreateFromFile, + (lldb::SBFileSpec &, lldb::SBStringList &, lldb::SBBreakpointList &)); + LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, BreakpointsWriteToFile, + (lldb::SBFileSpec &)); + LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, BreakpointsWriteToFile, + (lldb::SBFileSpec &, lldb::SBBreakpointList &, bool)); + LLDB_REGISTER_METHOD_CONST(uint32_t, SBTarget, GetNumWatchpoints, ()); + LLDB_REGISTER_METHOD_CONST(lldb::SBWatchpoint, SBTarget, + GetWatchpointAtIndex, (uint32_t)); + LLDB_REGISTER_METHOD(bool, SBTarget, DeleteWatchpoint, (lldb::watch_id_t)); + LLDB_REGISTER_METHOD(lldb::SBWatchpoint, SBTarget, FindWatchpointByID, + (lldb::watch_id_t)); + LLDB_REGISTER_METHOD(lldb::SBWatchpoint, SBTarget, WatchAddress, + (lldb::addr_t, size_t, bool, bool, lldb::SBError &)); + LLDB_REGISTER_METHOD(bool, SBTarget, EnableAllWatchpoints, ()); + LLDB_REGISTER_METHOD(bool, SBTarget, DisableAllWatchpoints, ()); + LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, CreateValueFromAddress, + (const char *, lldb::SBAddress, lldb::SBType)); + LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, CreateValueFromData, + (const char *, lldb::SBData, lldb::SBType)); + LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, CreateValueFromExpression, + (const char *, const char *)); + LLDB_REGISTER_METHOD(bool, SBTarget, DeleteAllWatchpoints, ()); + LLDB_REGISTER_METHOD(void, SBTarget, AppendImageSearchPath, + (const char *, const char *, lldb::SBError &)); + LLDB_REGISTER_METHOD(lldb::SBModule, SBTarget, AddModule, + (const char *, const char *, const char *)); + LLDB_REGISTER_METHOD( + lldb::SBModule, SBTarget, AddModule, + (const char *, const char *, const char *, const char *)); + LLDB_REGISTER_METHOD(lldb::SBModule, SBTarget, AddModule, + (const lldb::SBModuleSpec &)); + LLDB_REGISTER_METHOD(bool, SBTarget, AddModule, (lldb::SBModule &)); + LLDB_REGISTER_METHOD_CONST(uint32_t, SBTarget, GetNumModules, ()); + LLDB_REGISTER_METHOD(void, SBTarget, Clear, ()); + LLDB_REGISTER_METHOD(lldb::SBModule, SBTarget, FindModule, + (const lldb::SBFileSpec &)); + LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBTarget, FindCompileUnits, + (const lldb::SBFileSpec &)); + LLDB_REGISTER_METHOD(lldb::ByteOrder, SBTarget, GetByteOrder, ()); + LLDB_REGISTER_METHOD(const char *, SBTarget, GetTriple, ()); + LLDB_REGISTER_METHOD(uint32_t, SBTarget, GetDataByteSize, ()); + LLDB_REGISTER_METHOD(uint32_t, SBTarget, GetCodeByteSize, ()); + LLDB_REGISTER_METHOD(uint32_t, SBTarget, GetAddressByteSize, ()); + LLDB_REGISTER_METHOD(lldb::SBModule, SBTarget, GetModuleAtIndex, + (uint32_t)); + LLDB_REGISTER_METHOD(bool, SBTarget, RemoveModule, (lldb::SBModule)); + LLDB_REGISTER_METHOD_CONST(lldb::SBBroadcaster, SBTarget, GetBroadcaster, + ()); + LLDB_REGISTER_METHOD(bool, SBTarget, GetDescription, + (lldb::SBStream &, lldb::DescriptionLevel)); + LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBTarget, FindFunctions, + (const char *, uint32_t)); + LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBTarget, + FindGlobalFunctions, + (const char *, uint32_t, lldb::MatchType)); + LLDB_REGISTER_METHOD(lldb::SBType, SBTarget, FindFirstType, (const char *)); + LLDB_REGISTER_METHOD(lldb::SBType, SBTarget, GetBasicType, + (lldb::BasicType)); + LLDB_REGISTER_METHOD(lldb::SBTypeList, SBTarget, FindTypes, (const char *)); + LLDB_REGISTER_METHOD(lldb::SBValueList, SBTarget, FindGlobalVariables, + (const char *, uint32_t)); + LLDB_REGISTER_METHOD(lldb::SBValueList, SBTarget, FindGlobalVariables, + (const char *, uint32_t, lldb::MatchType)); + LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, FindFirstGlobalVariable, + (const char *)); + LLDB_REGISTER_METHOD(lldb::SBSourceManager, SBTarget, GetSourceManager, ()); + LLDB_REGISTER_METHOD(lldb::SBInstructionList, SBTarget, ReadInstructions, + (lldb::SBAddress, uint32_t)); + LLDB_REGISTER_METHOD(lldb::SBInstructionList, SBTarget, ReadInstructions, + (lldb::SBAddress, uint32_t, const char *)); + LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, SetSectionLoadAddress, + (lldb::SBSection, lldb::addr_t)); + LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, ClearSectionLoadAddress, + (lldb::SBSection)); + LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, SetModuleLoadAddress, + (lldb::SBModule, int64_t)); + LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, ClearModuleLoadAddress, + (lldb::SBModule)); + LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBTarget, FindSymbols, + (const char *, lldb::SymbolType)); + LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, EvaluateExpression, + (const char *)); + LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, EvaluateExpression, + (const char *, const lldb::SBExpressionOptions &)); + LLDB_REGISTER_METHOD(lldb::addr_t, SBTarget, GetStackRedZoneSize, ()); + LLDB_REGISTER_METHOD_CONST(lldb::SBLaunchInfo, SBTarget, GetLaunchInfo, ()); + LLDB_REGISTER_METHOD(void, SBTarget, SetLaunchInfo, + (const lldb::SBLaunchInfo &)); +} + +} +} diff --git a/source/API/SBThread.cpp b/source/API/SBThread.cpp index 2c859d5222d6c..85e9a6b47955a 100644 --- a/source/API/SBThread.cpp +++ b/source/API/SBThread.cpp @@ -1,17 +1,25 @@ //===-- SBThread.cpp --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBThread.h" - +#include "SBReproducerPrivate.h" +#include "Utils.h" +#include "lldb/API/SBAddress.h" +#include "lldb/API/SBDebugger.h" +#include "lldb/API/SBEvent.h" #include "lldb/API/SBFileSpec.h" +#include "lldb/API/SBFrame.h" +#include "lldb/API/SBProcess.h" #include "lldb/API/SBStream.h" #include "lldb/API/SBSymbolContext.h" +#include "lldb/API/SBThreadCollection.h" +#include "lldb/API/SBThreadPlan.h" +#include "lldb/API/SBValue.h" #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/StreamFile.h" @@ -34,57 +42,58 @@ #include "lldb/Utility/State.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/StructuredData.h" - -#include "lldb/API/SBAddress.h" -#include "lldb/API/SBDebugger.h" -#include "lldb/API/SBEvent.h" -#include "lldb/API/SBFrame.h" -#include "lldb/API/SBProcess.h" -#include "lldb/API/SBThreadCollection.h" -#include "lldb/API/SBThreadPlan.h" -#include "lldb/API/SBValue.h" #include "lldb/lldb-enumerations.h" +#include <memory> + using namespace lldb; using namespace lldb_private; const char *SBThread::GetBroadcasterClassName() { + LLDB_RECORD_STATIC_METHOD_NO_ARGS(const char *, SBThread, + GetBroadcasterClassName); + return Thread::GetStaticBroadcasterClass().AsCString(); } -//---------------------------------------------------------------------- // Constructors -//---------------------------------------------------------------------- -SBThread::SBThread() : m_opaque_sp(new ExecutionContextRef()) {} +SBThread::SBThread() : m_opaque_sp(new ExecutionContextRef()) { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBThread); +} SBThread::SBThread(const ThreadSP &lldb_object_sp) - : m_opaque_sp(new ExecutionContextRef(lldb_object_sp)) {} + : m_opaque_sp(new ExecutionContextRef(lldb_object_sp)) { + LLDB_RECORD_CONSTRUCTOR(SBThread, (const lldb::ThreadSP &), lldb_object_sp); +} -SBThread::SBThread(const SBThread &rhs) - : m_opaque_sp(new ExecutionContextRef(*rhs.m_opaque_sp)) {} +SBThread::SBThread(const SBThread &rhs) : m_opaque_sp() { + LLDB_RECORD_CONSTRUCTOR(SBThread, (const lldb::SBThread &), rhs); + + m_opaque_sp = clone(rhs.m_opaque_sp); +} -//---------------------------------------------------------------------- // Assignment operator -//---------------------------------------------------------------------- const lldb::SBThread &SBThread::operator=(const SBThread &rhs) { + LLDB_RECORD_METHOD(const lldb::SBThread &, + SBThread, operator=,(const lldb::SBThread &), rhs); + if (this != &rhs) - *m_opaque_sp = *rhs.m_opaque_sp; - return *this; + m_opaque_sp = clone(rhs.m_opaque_sp); + return LLDB_RECORD_RESULT(*this); } -//---------------------------------------------------------------------- // Destructor -//---------------------------------------------------------------------- SBThread::~SBThread() {} lldb::SBQueue SBThread::GetQueue() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBQueue, SBThread, GetQueue); + SBQueue sb_queue; QueueSP queue_sp; std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); if (exe_ctx.HasThreadScope()) { Process::StopLocker stop_locker; if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) { @@ -92,22 +101,19 @@ lldb::SBQueue SBThread::GetQueue() const { if (queue_sp) { sb_queue.SetQueue(queue_sp); } - } else { - if (log) - log->Printf("SBThread(%p)::GetQueue() => error: process is running", - static_cast<void *>(exe_ctx.GetThreadPtr())); } } - if (log) - log->Printf("SBThread(%p)::GetQueue () => SBQueue(%p)", - static_cast<void *>(exe_ctx.GetThreadPtr()), - static_cast<void *>(queue_sp.get())); - - return sb_queue; + return LLDB_RECORD_RESULT(sb_queue); } bool SBThread::IsValid() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBThread, IsValid); + return this->operator bool(); +} +SBThread::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBThread, operator bool); + std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -116,16 +122,20 @@ bool SBThread::IsValid() const { if (target && process) { Process::StopLocker stop_locker; if (stop_locker.TryLock(&process->GetRunLock())) - return m_opaque_sp->GetThreadSP().get() != NULL; + return m_opaque_sp->GetThreadSP().get() != nullptr; } // Without a valid target & process, this thread can't be valid. return false; } -void SBThread::Clear() { m_opaque_sp->Clear(); } +void SBThread::Clear() { + LLDB_RECORD_METHOD_NO_ARGS(void, SBThread, Clear); + + m_opaque_sp->Clear(); +} StopReason SBThread::GetStopReason() { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_NO_ARGS(lldb::StopReason, SBThread, GetStopReason); StopReason reason = eStopReasonInvalid; std::unique_lock<std::recursive_mutex> lock; @@ -135,23 +145,15 @@ StopReason SBThread::GetStopReason() { Process::StopLocker stop_locker; if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) { return exe_ctx.GetThreadPtr()->GetStopReason(); - } else { - if (log) - log->Printf( - "SBThread(%p)::GetStopReason() => error: process is running", - static_cast<void *>(exe_ctx.GetThreadPtr())); } } - if (log) - log->Printf("SBThread(%p)::GetStopReason () => %s", - static_cast<void *>(exe_ctx.GetThreadPtr()), - Thread::StopReasonAsCString(reason)); - return reason; } size_t SBThread::GetStopReasonDataCount() { + LLDB_RECORD_METHOD_NO_ARGS(size_t, SBThread, GetStopReasonDataCount); + std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -193,18 +195,15 @@ size_t SBThread::GetStopReasonDataCount() { return 1; } } - } else { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBThread(%p)::GetStopReasonDataCount() => error: process " - "is running", - static_cast<void *>(exe_ctx.GetThreadPtr())); } } return 0; } uint64_t SBThread::GetStopReasonDataAtIndex(uint32_t idx) { + LLDB_RECORD_METHOD(uint64_t, SBThread, GetStopReasonDataAtIndex, (uint32_t), + idx); + std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -258,18 +257,15 @@ uint64_t SBThread::GetStopReasonDataAtIndex(uint32_t idx) { return stop_info_sp->GetValue(); } } - } else { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBThread(%p)::GetStopReasonDataAtIndex() => error: " - "process is running", - static_cast<void *>(exe_ctx.GetThreadPtr())); } } return 0; } bool SBThread::GetStopReasonExtendedInfoAsJSON(lldb::SBStream &stream) { + LLDB_RECORD_METHOD(bool, SBThread, GetStopReasonExtendedInfoAsJSON, + (lldb::SBStream &), stream); + Stream &strm = stream.ref(); std::unique_lock<std::recursive_mutex> lock; @@ -290,28 +286,33 @@ bool SBThread::GetStopReasonExtendedInfoAsJSON(lldb::SBStream &stream) { SBThreadCollection SBThread::GetStopReasonExtendedBacktraces(InstrumentationRuntimeType type) { + LLDB_RECORD_METHOD(lldb::SBThreadCollection, SBThread, + GetStopReasonExtendedBacktraces, + (lldb::InstrumentationRuntimeType), type); + ThreadCollectionSP threads; - threads.reset(new ThreadCollection()); + threads = std::make_shared<ThreadCollection>(); std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (!exe_ctx.HasThreadScope()) - return threads; + return LLDB_RECORD_RESULT(threads); ProcessSP process_sp = exe_ctx.GetProcessSP(); StopInfoSP stop_info = exe_ctx.GetThreadPtr()->GetStopInfo(); StructuredData::ObjectSP info = stop_info->GetExtendedInfo(); if (!info) - return threads; + return LLDB_RECORD_RESULT(threads); - return process_sp->GetInstrumentationRuntime(type) - ->GetBacktracesFromExtendedStopInfo(info); + return LLDB_RECORD_RESULT(process_sp->GetInstrumentationRuntime(type) + ->GetBacktracesFromExtendedStopInfo(info)); } size_t SBThread::GetStopDescription(char *dst, size_t dst_len) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(size_t, SBThread, GetStopDescription, (char *, size_t), + dst, dst_len); std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -324,10 +325,6 @@ size_t SBThread::GetStopDescription(char *dst, size_t dst_len) { if (stop_info_sp) { const char *stop_desc = stop_info_sp->GetDescription(); if (stop_desc) { - if (log) - log->Printf( - "SBThread(%p)::GetStopDescription (dst, dst_len) => \"%s\"", - static_cast<void *>(exe_ctx.GetThreadPtr()), stop_desc); if (dst) return ::snprintf(dst, dst_len, "%s", stop_desc); else { @@ -362,7 +359,7 @@ size_t SBThread::GetStopDescription(char *dst, size_t dst_len) { stop_desc = exe_ctx.GetProcessPtr()->GetUnixSignals()->GetSignalAsCString( stop_info_sp->GetValue()); - if (stop_desc == NULL || stop_desc[0] == '\0') { + if (stop_desc == nullptr || stop_desc[0] == '\0') { static char signal_desc[] = "signal"; stop_desc = signal_desc; stop_desc_len = @@ -392,11 +389,6 @@ size_t SBThread::GetStopDescription(char *dst, size_t dst_len) { } if (stop_desc && stop_desc[0]) { - if (log) - log->Printf( - "SBThread(%p)::GetStopDescription (dst, dst_len) => '%s'", - static_cast<void *>(exe_ctx.GetThreadPtr()), stop_desc); - if (dst) return ::snprintf(dst, dst_len, "%s", stop_desc) + 1; // Include the NULL byte @@ -408,12 +400,6 @@ size_t SBThread::GetStopDescription(char *dst, size_t dst_len) { } } } - } else { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf( - "SBThread(%p)::GetStopDescription() => error: process is running", - static_cast<void *>(exe_ctx.GetThreadPtr())); } } if (dst) @@ -422,7 +408,8 @@ size_t SBThread::GetStopDescription(char *dst, size_t dst_len) { } SBValue SBThread::GetStopReturnValue() { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBValue, SBThread, GetStopReturnValue); + ValueObjectSP return_valobj_sp; std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -434,21 +421,10 @@ SBValue SBThread::GetStopReturnValue() { if (stop_info_sp) { return_valobj_sp = StopInfo::GetReturnValueObject(stop_info_sp); } - } else { - if (log) - log->Printf( - "SBThread(%p)::GetStopReturnValue() => error: process is running", - static_cast<void *>(exe_ctx.GetThreadPtr())); } } - if (log) - log->Printf("SBThread(%p)::GetStopReturnValue () => %s", - static_cast<void *>(exe_ctx.GetThreadPtr()), - return_valobj_sp.get() ? return_valobj_sp->GetValueAsCString() - : "<no return value>"); - - return SBValue(return_valobj_sp); + return LLDB_RECORD_RESULT(SBValue(return_valobj_sp)); } void SBThread::SetThread(const ThreadSP &lldb_object_sp) { @@ -456,6 +432,8 @@ void SBThread::SetThread(const ThreadSP &lldb_object_sp) { } lldb::tid_t SBThread::GetThreadID() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::tid_t, SBThread, GetThreadID); + ThreadSP thread_sp(m_opaque_sp->GetThreadSP()); if (thread_sp) return thread_sp->GetID(); @@ -463,6 +441,8 @@ lldb::tid_t SBThread::GetThreadID() const { } uint32_t SBThread::GetIndexID() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBThread, GetIndexID); + ThreadSP thread_sp(m_opaque_sp->GetThreadSP()); if (thread_sp) return thread_sp->GetIndexID(); @@ -470,8 +450,9 @@ uint32_t SBThread::GetIndexID() const { } const char *SBThread::GetName() const { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - const char *name = NULL; + LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBThread, GetName); + + const char *name = nullptr; std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -479,72 +460,50 @@ const char *SBThread::GetName() const { Process::StopLocker stop_locker; if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) { name = exe_ctx.GetThreadPtr()->GetName(); - } else { - if (log) - log->Printf("SBThread(%p)::GetName() => error: process is running", - static_cast<void *>(exe_ctx.GetThreadPtr())); } } - if (log) - log->Printf("SBThread(%p)::GetName () => %s", - static_cast<void *>(exe_ctx.GetThreadPtr()), - name ? name : "NULL"); - return name; } const char *SBThread::GetQueueName() const { - const char *name = NULL; + LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBThread, GetQueueName); + + const char *name = nullptr; std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); if (exe_ctx.HasThreadScope()) { Process::StopLocker stop_locker; if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) { name = exe_ctx.GetThreadPtr()->GetQueueName(); - } else { - if (log) - log->Printf("SBThread(%p)::GetQueueName() => error: process is running", - static_cast<void *>(exe_ctx.GetThreadPtr())); } } - if (log) - log->Printf("SBThread(%p)::GetQueueName () => %s", - static_cast<void *>(exe_ctx.GetThreadPtr()), - name ? name : "NULL"); - return name; } lldb::queue_id_t SBThread::GetQueueID() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::queue_id_t, SBThread, GetQueueID); + queue_id_t id = LLDB_INVALID_QUEUE_ID; std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); if (exe_ctx.HasThreadScope()) { Process::StopLocker stop_locker; if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) { id = exe_ctx.GetThreadPtr()->GetQueueID(); - } else { - if (log) - log->Printf("SBThread(%p)::GetQueueID() => error: process is running", - static_cast<void *>(exe_ctx.GetThreadPtr())); } } - if (log) - log->Printf("SBThread(%p)::GetQueueID () => 0x%" PRIx64, - static_cast<void *>(exe_ctx.GetThreadPtr()), id); - return id; } bool SBThread::GetInfoItemByPathAsString(const char *path, SBStream &strm) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(bool, SBThread, GetInfoItemByPathAsString, + (const char *, lldb::SBStream &), path, strm); + bool success = false; std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -583,18 +542,9 @@ bool SBThread::GetInfoItemByPathAsString(const char *path, SBStream &strm) { } } } - } else { - if (log) - log->Printf("SBThread(%p)::GetInfoItemByPathAsString() => error: " - "process is running", - static_cast<void *>(exe_ctx.GetThreadPtr())); } } - if (log) - log->Printf("SBThread(%p)::GetInfoItemByPathAsString (\"%s\") => \"%s\"", - static_cast<void *>(exe_ctx.GetThreadPtr()), path, strm.GetData()); - return success; } @@ -616,7 +566,7 @@ SBError SBThread::ResumeNewPlan(ExecutionContext &exe_ctx, // User level plans should be Master Plans so they can be interrupted, other // plans executed, and then a "continue" will resume the plan. - if (new_plan != NULL) { + if (new_plan != nullptr) { new_plan->SetIsMasterPlan(true); new_plan->SetOkayToDiscard(false); } @@ -627,27 +577,26 @@ SBError SBThread::ResumeNewPlan(ExecutionContext &exe_ctx, if (process->GetTarget().GetDebugger().GetAsyncExecution()) sb_error.ref() = process->Resume(); else - sb_error.ref() = process->ResumeSynchronous(NULL); + sb_error.ref() = process->ResumeSynchronous(nullptr); return sb_error; } void SBThread::StepOver(lldb::RunMode stop_other_threads) { + LLDB_RECORD_METHOD(void, SBThread, StepOver, (lldb::RunMode), + stop_other_threads); + SBError error; // Ignored StepOver(stop_other_threads, error); } void SBThread::StepOver(lldb::RunMode stop_other_threads, SBError &error) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(void, SBThread, StepOver, (lldb::RunMode, lldb::SBError &), + stop_other_threads, error); std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); - if (log) - log->Printf("SBThread(%p)::StepOver (stop_other_threads='%s')", - static_cast<void *>(exe_ctx.GetThreadPtr()), - Thread::RunModeAsCString(stop_other_threads)); - if (!exe_ctx.HasThreadScope()) { error.SetErrorString("this SBThread object is invalid"); return; @@ -675,29 +624,31 @@ void SBThread::StepOver(lldb::RunMode stop_other_threads, SBError &error) { } void SBThread::StepInto(lldb::RunMode stop_other_threads) { - StepInto(NULL, stop_other_threads); + LLDB_RECORD_METHOD(void, SBThread, StepInto, (lldb::RunMode), + stop_other_threads); + + StepInto(nullptr, stop_other_threads); } void SBThread::StepInto(const char *target_name, lldb::RunMode stop_other_threads) { + LLDB_RECORD_METHOD(void, SBThread, StepInto, (const char *, lldb::RunMode), + target_name, stop_other_threads); + SBError error; // Ignored StepInto(target_name, LLDB_INVALID_LINE_NUMBER, error, stop_other_threads); } void SBThread::StepInto(const char *target_name, uint32_t end_line, SBError &error, lldb::RunMode stop_other_threads) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(void, SBThread, StepInto, + (const char *, uint32_t, lldb::SBError &, lldb::RunMode), + target_name, end_line, error, stop_other_threads); + std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); - if (log) - log->Printf( - "SBThread(%p)::StepInto (target_name='%s', stop_other_threads='%s')", - static_cast<void *>(exe_ctx.GetThreadPtr()), - target_name ? target_name : "<NULL>", - Thread::RunModeAsCString(stop_other_threads)); - if (!exe_ctx.HasThreadScope()) { error.SetErrorString("this SBThread object is invalid"); return; @@ -740,20 +691,18 @@ void SBThread::StepInto(const char *target_name, uint32_t end_line, } void SBThread::StepOut() { + LLDB_RECORD_METHOD_NO_ARGS(void, SBThread, StepOut); + SBError error; // Ignored StepOut(error); } void SBThread::StepOut(SBError &error) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(void, SBThread, StepOut, (lldb::SBError &), error); std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); - if (log) - log->Printf("SBThread(%p)::StepOut ()", - static_cast<void *>(exe_ctx.GetThreadPtr())); - if (!exe_ctx.HasThreadScope()) { error.SetErrorString("this SBThread object is invalid"); return; @@ -767,7 +716,7 @@ void SBThread::StepOut(SBError &error) { const LazyBool avoid_no_debug = eLazyBoolCalculate; Status new_plan_status; ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepOut( - abort_other_plans, NULL, false, stop_other_threads, eVoteYes, + abort_other_plans, nullptr, false, stop_other_threads, eVoteYes, eVoteNoOpinion, 0, new_plan_status, avoid_no_debug)); if (new_plan_status.Success()) @@ -777,33 +726,27 @@ void SBThread::StepOut(SBError &error) { } void SBThread::StepOutOfFrame(SBFrame &sb_frame) { + LLDB_RECORD_METHOD(void, SBThread, StepOutOfFrame, (lldb::SBFrame &), + sb_frame); + SBError error; // Ignored StepOutOfFrame(sb_frame, error); } void SBThread::StepOutOfFrame(SBFrame &sb_frame, SBError &error) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(void, SBThread, StepOutOfFrame, + (lldb::SBFrame &, lldb::SBError &), sb_frame, error); + std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (!sb_frame.IsValid()) { - if (log) - log->Printf( - "SBThread(%p)::StepOutOfFrame passed an invalid frame, returning.", - static_cast<void *>(exe_ctx.GetThreadPtr())); error.SetErrorString("passed invalid SBFrame object"); return; } StackFrameSP frame_sp(sb_frame.GetFrameSP()); - if (log) { - SBStream frame_desc_strm; - sb_frame.GetDescription(frame_desc_strm); - log->Printf("SBThread(%p)::StepOutOfFrame (frame = SBFrame(%p): %s)", - static_cast<void *>(exe_ctx.GetThreadPtr()), - static_cast<void *>(frame_sp.get()), frame_desc_strm.GetData()); - } if (!exe_ctx.HasThreadScope()) { error.SetErrorString("this SBThread object is invalid"); @@ -814,17 +757,13 @@ void SBThread::StepOutOfFrame(SBFrame &sb_frame, SBError &error) { bool stop_other_threads = false; Thread *thread = exe_ctx.GetThreadPtr(); if (sb_frame.GetThread().GetThreadID() != thread->GetID()) { - log->Printf("SBThread(%p)::StepOutOfFrame passed a frame from another " - "thread (0x%" PRIx64 " vrs. 0x%" PRIx64 ", returning.", - static_cast<void *>(exe_ctx.GetThreadPtr()), - sb_frame.GetThread().GetThreadID(), thread->GetID()); error.SetErrorString("passed a frame from another thread"); return; } Status new_plan_status; ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepOut( - abort_other_plans, NULL, false, stop_other_threads, eVoteYes, + abort_other_plans, nullptr, false, stop_other_threads, eVoteYes, eVoteNoOpinion, frame_sp->GetFrameIndex(), new_plan_status)); if (new_plan_status.Success()) @@ -834,20 +773,19 @@ void SBThread::StepOutOfFrame(SBFrame &sb_frame, SBError &error) { } void SBThread::StepInstruction(bool step_over) { + LLDB_RECORD_METHOD(void, SBThread, StepInstruction, (bool), step_over); + SBError error; // Ignored StepInstruction(step_over, error); } void SBThread::StepInstruction(bool step_over, SBError &error) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(void, SBThread, StepInstruction, (bool, lldb::SBError &), + step_over, error); std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); - if (log) - log->Printf("SBThread(%p)::StepInstruction (step_over=%i)", - static_cast<void *>(exe_ctx.GetThreadPtr()), step_over); - if (!exe_ctx.HasThreadScope()) { error.SetErrorString("this SBThread object is invalid"); return; @@ -865,20 +803,19 @@ void SBThread::StepInstruction(bool step_over, SBError &error) { } void SBThread::RunToAddress(lldb::addr_t addr) { + LLDB_RECORD_METHOD(void, SBThread, RunToAddress, (lldb::addr_t), addr); + SBError error; // Ignored RunToAddress(addr, error); } void SBThread::RunToAddress(lldb::addr_t addr, SBError &error) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(void, SBThread, RunToAddress, + (lldb::addr_t, lldb::SBError &), addr, error); std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); - if (log) - log->Printf("SBThread(%p)::RunToAddress (addr=0x%" PRIx64 ")", - static_cast<void *>(exe_ctx.GetThreadPtr()), addr); - if (!exe_ctx.HasThreadScope()) { error.SetErrorString("this SBThread object is invalid"); return; @@ -903,8 +840,11 @@ void SBThread::RunToAddress(lldb::addr_t addr, SBError &error) { SBError SBThread::StepOverUntil(lldb::SBFrame &sb_frame, lldb::SBFileSpec &sb_file_spec, uint32_t line) { + LLDB_RECORD_METHOD(lldb::SBError, SBThread, StepOverUntil, + (lldb::SBFrame &, lldb::SBFileSpec &, uint32_t), sb_frame, + sb_file_spec, line); + SBError sb_error; - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); char path[PATH_MAX]; std::unique_lock<std::recursive_mutex> lock; @@ -912,24 +852,13 @@ SBError SBThread::StepOverUntil(lldb::SBFrame &sb_frame, StackFrameSP frame_sp(sb_frame.GetFrameSP()); - if (log) { - SBStream frame_desc_strm; - sb_frame.GetDescription(frame_desc_strm); - sb_file_spec->GetPath(path, sizeof(path)); - log->Printf("SBThread(%p)::StepOverUntil (frame = SBFrame(%p): %s, " - "file+line = %s:%u)", - static_cast<void *>(exe_ctx.GetThreadPtr()), - static_cast<void *>(frame_sp.get()), frame_desc_strm.GetData(), - path, line); - } - if (exe_ctx.HasThreadScope()) { Target *target = exe_ctx.GetTargetPtr(); Thread *thread = exe_ctx.GetThreadPtr(); if (line == 0) { sb_error.SetErrorString("invalid line argument"); - return sb_error; + return LLDB_RECORD_RESULT(sb_error); } if (!frame_sp) { @@ -941,7 +870,7 @@ SBError SBThread::StepOverUntil(lldb::SBFrame &sb_frame, SymbolContext frame_sc; if (!frame_sp) { sb_error.SetErrorString("no valid frames in thread to step"); - return sb_error; + return LLDB_RECORD_RESULT(sb_error); } // If we have a frame, get its line @@ -949,10 +878,10 @@ SBError SBThread::StepOverUntil(lldb::SBFrame &sb_frame, eSymbolContextCompUnit | eSymbolContextFunction | eSymbolContextLineEntry | eSymbolContextSymbol); - if (frame_sc.comp_unit == NULL) { + if (frame_sc.comp_unit == nullptr) { sb_error.SetErrorStringWithFormat( "frame %u doesn't have debug information", frame_sp->GetFrameIndex()); - return sb_error; + return LLDB_RECORD_RESULT(sb_error); } FileSpec step_file_spec; @@ -964,7 +893,7 @@ SBError SBThread::StepOverUntil(lldb::SBFrame &sb_frame, step_file_spec = frame_sc.line_entry.file; else { sb_error.SetErrorString("invalid file argument or no file for frame"); - return sb_error; + return LLDB_RECORD_RESULT(sb_error); } } @@ -1024,29 +953,31 @@ SBError SBThread::StepOverUntil(lldb::SBFrame &sb_frame, } else { sb_error.SetErrorString("this SBThread object is invalid"); } - return sb_error; + return LLDB_RECORD_RESULT(sb_error); } SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name) { - return StepUsingScriptedThreadPlan(script_class_name, true); + LLDB_RECORD_METHOD(lldb::SBError, SBThread, StepUsingScriptedThreadPlan, + (const char *), script_class_name); + + return LLDB_RECORD_RESULT( + StepUsingScriptedThreadPlan(script_class_name, true)); } SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name, bool resume_immediately) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(lldb::SBError, SBThread, StepUsingScriptedThreadPlan, + (const char *, bool), script_class_name, + resume_immediately); + SBError error; std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); - if (log) { - log->Printf("SBThread(%p)::StepUsingScriptedThreadPlan: class name: %s", - static_cast<void *>(exe_ctx.GetThreadPtr()), script_class_name); - } - if (!exe_ctx.HasThreadScope()) { error.SetErrorString("this SBThread object is invalid"); - return error; + return LLDB_RECORD_RESULT(error); } Thread *thread = exe_ctx.GetThreadPtr(); @@ -1056,78 +987,68 @@ SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name, if (new_plan_status.Fail()) { error.SetErrorString(new_plan_status.AsCString()); - return error; + return LLDB_RECORD_RESULT(error); } if (!resume_immediately) - return error; + return LLDB_RECORD_RESULT(error); if (new_plan_status.Success()) error = ResumeNewPlan(exe_ctx, new_plan_sp.get()); else error.SetErrorString(new_plan_status.AsCString()); - return error; + return LLDB_RECORD_RESULT(error); } SBError SBThread::JumpToLine(lldb::SBFileSpec &file_spec, uint32_t line) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(lldb::SBError, SBThread, JumpToLine, + (lldb::SBFileSpec &, uint32_t), file_spec, line); + SBError sb_error; std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); - if (log) - log->Printf("SBThread(%p)::JumpToLine (file+line = %s:%u)", - static_cast<void *>(exe_ctx.GetThreadPtr()), - file_spec->GetPath().c_str(), line); - if (!exe_ctx.HasThreadScope()) { sb_error.SetErrorString("this SBThread object is invalid"); - return sb_error; + return LLDB_RECORD_RESULT(sb_error); } Thread *thread = exe_ctx.GetThreadPtr(); Status err = thread->JumpToLine(file_spec.get(), line, true); sb_error.SetError(err); - return sb_error; + return LLDB_RECORD_RESULT(sb_error); } SBError SBThread::ReturnFromFrame(SBFrame &frame, SBValue &return_value) { - SBError sb_error; + LLDB_RECORD_METHOD(lldb::SBError, SBThread, ReturnFromFrame, + (lldb::SBFrame &, lldb::SBValue &), frame, return_value); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + SBError sb_error; std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); - if (log) - log->Printf("SBThread(%p)::ReturnFromFrame (frame=%d)", - static_cast<void *>(exe_ctx.GetThreadPtr()), - frame.GetFrameID()); - if (exe_ctx.HasThreadScope()) { Thread *thread = exe_ctx.GetThreadPtr(); sb_error.SetError( thread->ReturnFromFrame(frame.GetFrameSP(), return_value.GetSP())); } - return sb_error; + return LLDB_RECORD_RESULT(sb_error); } SBError SBThread::UnwindInnermostExpression() { - SBError sb_error; + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBThread, + UnwindInnermostExpression); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + SBError sb_error; std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); - if (log) - log->Printf("SBThread(%p)::UnwindExpressionEvaluation", - static_cast<void *>(exe_ctx.GetThreadPtr())); - if (exe_ctx.HasThreadScope()) { Thread *thread = exe_ctx.GetThreadPtr(); sb_error.SetError(thread->UnwindInnermostExpression()); @@ -1135,16 +1056,19 @@ SBError SBThread::UnwindInnermostExpression() { thread->SetSelectedFrameByIndex(0, false); } - return sb_error; + return LLDB_RECORD_RESULT(sb_error); } bool SBThread::Suspend() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBThread, Suspend); + SBError error; // Ignored return Suspend(error); } bool SBThread::Suspend(SBError &error) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(bool, SBThread, Suspend, (lldb::SBError &), error); + std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -1156,25 +1080,22 @@ bool SBThread::Suspend(SBError &error) { result = true; } else { error.SetErrorString("process is running"); - if (log) - log->Printf("SBThread(%p)::Suspend() => error: process is running", - static_cast<void *>(exe_ctx.GetThreadPtr())); } } else error.SetErrorString("this SBThread object is invalid"); - if (log) - log->Printf("SBThread(%p)::Suspend() => %i", - static_cast<void *>(exe_ctx.GetThreadPtr()), result); return result; } bool SBThread::Resume() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBThread, Resume); + SBError error; // Ignored return Resume(error); } bool SBThread::Resume(SBError &error) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(bool, SBThread, Resume, (lldb::SBError &), error); + std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -1187,19 +1108,15 @@ bool SBThread::Resume(SBError &error) { result = true; } else { error.SetErrorString("process is running"); - if (log) - log->Printf("SBThread(%p)::Resume() => error: process is running", - static_cast<void *>(exe_ctx.GetThreadPtr())); } } else error.SetErrorString("this SBThread object is invalid"); - if (log) - log->Printf("SBThread(%p)::Resume() => %i", - static_cast<void *>(exe_ctx.GetThreadPtr()), result); return result; } bool SBThread::IsSuspended() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBThread, IsSuspended); + std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -1209,6 +1126,8 @@ bool SBThread::IsSuspended() { } bool SBThread::IsStopped() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBThread, IsStopped); + std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -1218,6 +1137,8 @@ bool SBThread::IsStopped() { } SBProcess SBThread::GetProcess() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBProcess, SBThread, GetProcess); + SBProcess sb_process; std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -1228,21 +1149,11 @@ SBProcess SBThread::GetProcess() { sb_process.SetSP(exe_ctx.GetProcessSP()); } - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) { - SBStream frame_desc_strm; - sb_process.GetDescription(frame_desc_strm); - log->Printf("SBThread(%p)::GetProcess () => SBProcess(%p): %s", - static_cast<void *>(exe_ctx.GetThreadPtr()), - static_cast<void *>(sb_process.GetSP().get()), - frame_desc_strm.GetData()); - } - - return sb_process; + return LLDB_RECORD_RESULT(sb_process); } uint32_t SBThread::GetNumFrames() { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBThread, GetNumFrames); uint32_t num_frames = 0; std::unique_lock<std::recursive_mutex> lock; @@ -1252,22 +1163,14 @@ uint32_t SBThread::GetNumFrames() { Process::StopLocker stop_locker; if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) { num_frames = exe_ctx.GetThreadPtr()->GetStackFrameCount(); - } else { - if (log) - log->Printf("SBThread(%p)::GetNumFrames() => error: process is running", - static_cast<void *>(exe_ctx.GetThreadPtr())); } } - if (log) - log->Printf("SBThread(%p)::GetNumFrames () => %u", - static_cast<void *>(exe_ctx.GetThreadPtr()), num_frames); - return num_frames; } SBFrame SBThread::GetFrameAtIndex(uint32_t idx) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(lldb::SBFrame, SBThread, GetFrameAtIndex, (uint32_t), idx); SBFrame sb_frame; StackFrameSP frame_sp; @@ -1279,27 +1182,14 @@ SBFrame SBThread::GetFrameAtIndex(uint32_t idx) { if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) { frame_sp = exe_ctx.GetThreadPtr()->GetStackFrameAtIndex(idx); sb_frame.SetFrameSP(frame_sp); - } else { - if (log) - log->Printf( - "SBThread(%p)::GetFrameAtIndex() => error: process is running", - static_cast<void *>(exe_ctx.GetThreadPtr())); } } - if (log) { - SBStream frame_desc_strm; - sb_frame.GetDescription(frame_desc_strm); - log->Printf("SBThread(%p)::GetFrameAtIndex (idx=%d) => SBFrame(%p): %s", - static_cast<void *>(exe_ctx.GetThreadPtr()), idx, - static_cast<void *>(frame_sp.get()), frame_desc_strm.GetData()); - } - - return sb_frame; + return LLDB_RECORD_RESULT(sb_frame); } lldb::SBFrame SBThread::GetSelectedFrame() { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFrame, SBThread, GetSelectedFrame); SBFrame sb_frame; StackFrameSP frame_sp; @@ -1311,27 +1201,15 @@ lldb::SBFrame SBThread::GetSelectedFrame() { if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) { frame_sp = exe_ctx.GetThreadPtr()->GetSelectedFrame(); sb_frame.SetFrameSP(frame_sp); - } else { - if (log) - log->Printf( - "SBThread(%p)::GetSelectedFrame() => error: process is running", - static_cast<void *>(exe_ctx.GetThreadPtr())); } } - if (log) { - SBStream frame_desc_strm; - sb_frame.GetDescription(frame_desc_strm); - log->Printf("SBThread(%p)::GetSelectedFrame () => SBFrame(%p): %s", - static_cast<void *>(exe_ctx.GetThreadPtr()), - static_cast<void *>(frame_sp.get()), frame_desc_strm.GetData()); - } - - return sb_frame; + return LLDB_RECORD_RESULT(sb_frame); } lldb::SBFrame SBThread::SetSelectedFrame(uint32_t idx) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(lldb::SBFrame, SBThread, SetSelectedFrame, (uint32_t), + idx); SBFrame sb_frame; StackFrameSP frame_sp; @@ -1347,47 +1225,55 @@ lldb::SBFrame SBThread::SetSelectedFrame(uint32_t idx) { thread->SetSelectedFrame(frame_sp.get()); sb_frame.SetFrameSP(frame_sp); } - } else { - if (log) - log->Printf( - "SBThread(%p)::SetSelectedFrame() => error: process is running", - static_cast<void *>(exe_ctx.GetThreadPtr())); } } - if (log) { - SBStream frame_desc_strm; - sb_frame.GetDescription(frame_desc_strm); - log->Printf("SBThread(%p)::SetSelectedFrame (idx=%u) => SBFrame(%p): %s", - static_cast<void *>(exe_ctx.GetThreadPtr()), idx, - static_cast<void *>(frame_sp.get()), frame_desc_strm.GetData()); - } - return sb_frame; + return LLDB_RECORD_RESULT(sb_frame); } bool SBThread::EventIsThreadEvent(const SBEvent &event) { - return Thread::ThreadEventData::GetEventDataFromEvent(event.get()) != NULL; + LLDB_RECORD_STATIC_METHOD(bool, SBThread, EventIsThreadEvent, + (const lldb::SBEvent &), event); + + return Thread::ThreadEventData::GetEventDataFromEvent(event.get()) != nullptr; } SBFrame SBThread::GetStackFrameFromEvent(const SBEvent &event) { - return Thread::ThreadEventData::GetStackFrameFromEvent(event.get()); + LLDB_RECORD_STATIC_METHOD(lldb::SBFrame, SBThread, GetStackFrameFromEvent, + (const lldb::SBEvent &), event); + + return LLDB_RECORD_RESULT( + Thread::ThreadEventData::GetStackFrameFromEvent(event.get())); } SBThread SBThread::GetThreadFromEvent(const SBEvent &event) { - return Thread::ThreadEventData::GetThreadFromEvent(event.get()); + LLDB_RECORD_STATIC_METHOD(lldb::SBThread, SBThread, GetThreadFromEvent, + (const lldb::SBEvent &), event); + + return LLDB_RECORD_RESULT( + Thread::ThreadEventData::GetThreadFromEvent(event.get())); } bool SBThread::operator==(const SBThread &rhs) const { + LLDB_RECORD_METHOD_CONST(bool, SBThread, operator==,(const lldb::SBThread &), + rhs); + return m_opaque_sp->GetThreadSP().get() == rhs.m_opaque_sp->GetThreadSP().get(); } bool SBThread::operator!=(const SBThread &rhs) const { + LLDB_RECORD_METHOD_CONST(bool, SBThread, operator!=,(const lldb::SBThread &), + rhs); + return m_opaque_sp->GetThreadSP().get() != rhs.m_opaque_sp->GetThreadSP().get(); } bool SBThread::GetStatus(SBStream &status) const { + LLDB_RECORD_METHOD_CONST(bool, SBThread, GetStatus, (lldb::SBStream &), + status); + Stream &strm = status.ref(); std::unique_lock<std::recursive_mutex> lock; @@ -1402,10 +1288,16 @@ bool SBThread::GetStatus(SBStream &status) const { } bool SBThread::GetDescription(SBStream &description) const { - return GetDescription(description, false); + LLDB_RECORD_METHOD_CONST(bool, SBThread, GetDescription, (lldb::SBStream &), + description); + + return GetDescription(description, false); } bool SBThread::GetDescription(SBStream &description, bool stop_format) const { + LLDB_RECORD_METHOD_CONST(bool, SBThread, GetDescription, + (lldb::SBStream &, bool), description, stop_format); + Stream &strm = description.ref(); std::unique_lock<std::recursive_mutex> lock; @@ -1424,14 +1316,16 @@ bool SBThread::GetDescription(SBStream &description, bool stop_format) const { } SBThread SBThread::GetExtendedBacktraceThread(const char *type) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(lldb::SBThread, SBThread, GetExtendedBacktraceThread, + (const char *), type); + std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); SBThread sb_origin_thread; - if (exe_ctx.HasThreadScope()) { - Process::StopLocker stop_locker; - if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) { + Process::StopLocker stop_locker; + if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) { + if (exe_ctx.HasThreadScope()) { ThreadSP real_thread(exe_ctx.GetThreadSP()); if (real_thread) { ConstString type_const(type); @@ -1446,38 +1340,20 @@ SBThread SBThread::GetExtendedBacktraceThread(const char *type) { // pointer retains the object. process->GetExtendedThreadList().AddThread(new_thread_sp); sb_origin_thread.SetThread(new_thread_sp); - if (log) { - const char *queue_name = new_thread_sp->GetQueueName(); - if (queue_name == NULL) - queue_name = ""; - log->Printf("SBThread(%p)::GetExtendedBacktraceThread() => new " - "extended Thread " - "created (%p) with queue_id 0x%" PRIx64 - " queue name '%s'", - static_cast<void *>(exe_ctx.GetThreadPtr()), - static_cast<void *>(new_thread_sp.get()), - new_thread_sp->GetQueueID(), queue_name); - } } } } } - } else { - if (log) - log->Printf("SBThread(%p)::GetExtendedBacktraceThread() => error: " - "process is running", - static_cast<void *>(exe_ctx.GetThreadPtr())); } } - if (log && !sb_origin_thread.IsValid()) - log->Printf("SBThread(%p)::GetExtendedBacktraceThread() is not returning a " - "Valid thread", - static_cast<void *>(exe_ctx.GetThreadPtr())); - return sb_origin_thread; + return LLDB_RECORD_RESULT(sb_origin_thread); } uint32_t SBThread::GetExtendedBacktraceOriginatingIndexID() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBThread, + GetExtendedBacktraceOriginatingIndexID); + ThreadSP thread_sp(m_opaque_sp->GetThreadSP()); if (thread_sp) return thread_sp->GetExtendedBacktraceOriginatingIndexID(); @@ -1485,20 +1361,30 @@ uint32_t SBThread::GetExtendedBacktraceOriginatingIndexID() { } SBValue SBThread::GetCurrentException() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBValue, SBThread, GetCurrentException); + ThreadSP thread_sp(m_opaque_sp->GetThreadSP()); - if (!thread_sp) return SBValue(); + if (!thread_sp) + return LLDB_RECORD_RESULT(SBValue()); - return SBValue(thread_sp->GetCurrentException()); + return LLDB_RECORD_RESULT(SBValue(thread_sp->GetCurrentException())); } SBThread SBThread::GetCurrentExceptionBacktrace() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBThread, SBThread, + GetCurrentExceptionBacktrace); + ThreadSP thread_sp(m_opaque_sp->GetThreadSP()); - if (!thread_sp) return SBThread(); + if (!thread_sp) + return LLDB_RECORD_RESULT(SBThread()); - return SBThread(thread_sp->GetCurrentExceptionBacktrace()); + return LLDB_RECORD_RESULT( + SBThread(thread_sp->GetCurrentExceptionBacktrace())); } bool SBThread::SafeToCallFunctions() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBThread, SafeToCallFunctions); + ThreadSP thread_sp(m_opaque_sp->GetThreadSP()); if (thread_sp) return thread_sp->SafeToCallFunctions(); @@ -1506,17 +1392,115 @@ bool SBThread::SafeToCallFunctions() { } lldb_private::Thread *SBThread::operator->() { - ThreadSP thread_sp(m_opaque_sp->GetThreadSP()); - if (thread_sp) - return thread_sp.get(); - else - return NULL; + return get(); } lldb_private::Thread *SBThread::get() { - ThreadSP thread_sp(m_opaque_sp->GetThreadSP()); - if (thread_sp) - return thread_sp.get(); - else - return NULL; + return m_opaque_sp->GetThreadSP().get(); +} + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBThread>(Registry &R) { + LLDB_REGISTER_STATIC_METHOD(const char *, SBThread, GetBroadcasterClassName, + ()); + LLDB_REGISTER_CONSTRUCTOR(SBThread, ()); + LLDB_REGISTER_CONSTRUCTOR(SBThread, (const lldb::ThreadSP &)); + LLDB_REGISTER_CONSTRUCTOR(SBThread, (const lldb::SBThread &)); + LLDB_REGISTER_METHOD(const lldb::SBThread &, + SBThread, operator=,(const lldb::SBThread &)); + LLDB_REGISTER_METHOD_CONST(lldb::SBQueue, SBThread, GetQueue, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBThread, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBThread, operator bool, ()); + LLDB_REGISTER_METHOD(void, SBThread, Clear, ()); + LLDB_REGISTER_METHOD(lldb::StopReason, SBThread, GetStopReason, ()); + LLDB_REGISTER_METHOD(size_t, SBThread, GetStopReasonDataCount, ()); + LLDB_REGISTER_METHOD(uint64_t, SBThread, GetStopReasonDataAtIndex, + (uint32_t)); + LLDB_REGISTER_METHOD(bool, SBThread, GetStopReasonExtendedInfoAsJSON, + (lldb::SBStream &)); + LLDB_REGISTER_METHOD(lldb::SBThreadCollection, SBThread, + GetStopReasonExtendedBacktraces, + (lldb::InstrumentationRuntimeType)); + LLDB_REGISTER_METHOD(size_t, SBThread, GetStopDescription, + (char *, size_t)); + LLDB_REGISTER_METHOD(lldb::SBValue, SBThread, GetStopReturnValue, ()); + LLDB_REGISTER_METHOD_CONST(lldb::tid_t, SBThread, GetThreadID, ()); + LLDB_REGISTER_METHOD_CONST(uint32_t, SBThread, GetIndexID, ()); + LLDB_REGISTER_METHOD_CONST(const char *, SBThread, GetName, ()); + LLDB_REGISTER_METHOD_CONST(const char *, SBThread, GetQueueName, ()); + LLDB_REGISTER_METHOD_CONST(lldb::queue_id_t, SBThread, GetQueueID, ()); + LLDB_REGISTER_METHOD(bool, SBThread, GetInfoItemByPathAsString, + (const char *, lldb::SBStream &)); + LLDB_REGISTER_METHOD(void, SBThread, StepOver, (lldb::RunMode)); + LLDB_REGISTER_METHOD(void, SBThread, StepOver, + (lldb::RunMode, lldb::SBError &)); + LLDB_REGISTER_METHOD(void, SBThread, StepInto, (lldb::RunMode)); + LLDB_REGISTER_METHOD(void, SBThread, StepInto, + (const char *, lldb::RunMode)); + LLDB_REGISTER_METHOD( + void, SBThread, StepInto, + (const char *, uint32_t, lldb::SBError &, lldb::RunMode)); + LLDB_REGISTER_METHOD(void, SBThread, StepOut, ()); + LLDB_REGISTER_METHOD(void, SBThread, StepOut, (lldb::SBError &)); + LLDB_REGISTER_METHOD(void, SBThread, StepOutOfFrame, (lldb::SBFrame &)); + LLDB_REGISTER_METHOD(void, SBThread, StepOutOfFrame, + (lldb::SBFrame &, lldb::SBError &)); + LLDB_REGISTER_METHOD(void, SBThread, StepInstruction, (bool)); + LLDB_REGISTER_METHOD(void, SBThread, StepInstruction, + (bool, lldb::SBError &)); + LLDB_REGISTER_METHOD(void, SBThread, RunToAddress, (lldb::addr_t)); + LLDB_REGISTER_METHOD(void, SBThread, RunToAddress, + (lldb::addr_t, lldb::SBError &)); + LLDB_REGISTER_METHOD(lldb::SBError, SBThread, StepOverUntil, + (lldb::SBFrame &, lldb::SBFileSpec &, uint32_t)); + LLDB_REGISTER_METHOD(lldb::SBError, SBThread, StepUsingScriptedThreadPlan, + (const char *)); + LLDB_REGISTER_METHOD(lldb::SBError, SBThread, StepUsingScriptedThreadPlan, + (const char *, bool)); + LLDB_REGISTER_METHOD(lldb::SBError, SBThread, JumpToLine, + (lldb::SBFileSpec &, uint32_t)); + LLDB_REGISTER_METHOD(lldb::SBError, SBThread, ReturnFromFrame, + (lldb::SBFrame &, lldb::SBValue &)); + LLDB_REGISTER_METHOD(lldb::SBError, SBThread, UnwindInnermostExpression, + ()); + LLDB_REGISTER_METHOD(bool, SBThread, Suspend, ()); + LLDB_REGISTER_METHOD(bool, SBThread, Suspend, (lldb::SBError &)); + LLDB_REGISTER_METHOD(bool, SBThread, Resume, ()); + LLDB_REGISTER_METHOD(bool, SBThread, Resume, (lldb::SBError &)); + LLDB_REGISTER_METHOD(bool, SBThread, IsSuspended, ()); + LLDB_REGISTER_METHOD(bool, SBThread, IsStopped, ()); + LLDB_REGISTER_METHOD(lldb::SBProcess, SBThread, GetProcess, ()); + LLDB_REGISTER_METHOD(uint32_t, SBThread, GetNumFrames, ()); + LLDB_REGISTER_METHOD(lldb::SBFrame, SBThread, GetFrameAtIndex, (uint32_t)); + LLDB_REGISTER_METHOD(lldb::SBFrame, SBThread, GetSelectedFrame, ()); + LLDB_REGISTER_METHOD(lldb::SBFrame, SBThread, SetSelectedFrame, (uint32_t)); + LLDB_REGISTER_STATIC_METHOD(bool, SBThread, EventIsThreadEvent, + (const lldb::SBEvent &)); + LLDB_REGISTER_STATIC_METHOD(lldb::SBFrame, SBThread, GetStackFrameFromEvent, + (const lldb::SBEvent &)); + LLDB_REGISTER_STATIC_METHOD(lldb::SBThread, SBThread, GetThreadFromEvent, + (const lldb::SBEvent &)); + LLDB_REGISTER_METHOD_CONST(bool, + SBThread, operator==,(const lldb::SBThread &)); + LLDB_REGISTER_METHOD_CONST(bool, + SBThread, operator!=,(const lldb::SBThread &)); + LLDB_REGISTER_METHOD_CONST(bool, SBThread, GetStatus, (lldb::SBStream &)); + LLDB_REGISTER_METHOD_CONST(bool, SBThread, GetDescription, + (lldb::SBStream &)); + LLDB_REGISTER_METHOD_CONST(bool, SBThread, GetDescription, + (lldb::SBStream &, bool)); + LLDB_REGISTER_METHOD(lldb::SBThread, SBThread, GetExtendedBacktraceThread, + (const char *)); + LLDB_REGISTER_METHOD(uint32_t, SBThread, + GetExtendedBacktraceOriginatingIndexID, ()); + LLDB_REGISTER_METHOD(lldb::SBValue, SBThread, GetCurrentException, ()); + LLDB_REGISTER_METHOD(lldb::SBThread, SBThread, GetCurrentExceptionBacktrace, + ()); + LLDB_REGISTER_METHOD(bool, SBThread, SafeToCallFunctions, ()); +} + +} } diff --git a/source/API/SBThreadCollection.cpp b/source/API/SBThreadCollection.cpp index c424d47b40981..3c1cf98650620 100644 --- a/source/API/SBThreadCollection.cpp +++ b/source/API/SBThreadCollection.cpp @@ -1,29 +1,38 @@ //===-- SBThreadCollection.cpp ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBThreadCollection.h" +#include "SBReproducerPrivate.h" #include "lldb/API/SBThread.h" #include "lldb/Target/ThreadList.h" using namespace lldb; using namespace lldb_private; -SBThreadCollection::SBThreadCollection() : m_opaque_sp() {} +SBThreadCollection::SBThreadCollection() : m_opaque_sp() { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBThreadCollection); +} SBThreadCollection::SBThreadCollection(const SBThreadCollection &rhs) - : m_opaque_sp(rhs.m_opaque_sp) {} + : m_opaque_sp(rhs.m_opaque_sp) { + LLDB_RECORD_CONSTRUCTOR(SBThreadCollection, + (const lldb::SBThreadCollection &), rhs); +} const SBThreadCollection &SBThreadCollection:: operator=(const SBThreadCollection &rhs) { + LLDB_RECORD_METHOD( + const lldb::SBThreadCollection &, + SBThreadCollection, operator=,(const lldb::SBThreadCollection &), rhs); + if (this != &rhs) m_opaque_sp = rhs.m_opaque_sp; - return *this; + return LLDB_RECORD_RESULT(*this); } SBThreadCollection::SBThreadCollection(const ThreadCollectionSP &threads) @@ -51,17 +60,51 @@ const lldb::ThreadCollectionSP &SBThreadCollection::operator*() const { return m_opaque_sp; } -bool SBThreadCollection::IsValid() const { return m_opaque_sp.get() != NULL; } +bool SBThreadCollection::IsValid() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBThreadCollection, IsValid); + return this->operator bool(); +} +SBThreadCollection::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBThreadCollection, operator bool); + + return m_opaque_sp.get() != nullptr; +} size_t SBThreadCollection::GetSize() { + LLDB_RECORD_METHOD_NO_ARGS(size_t, SBThreadCollection, GetSize); + if (m_opaque_sp) return m_opaque_sp->GetSize(); return 0; } SBThread SBThreadCollection::GetThreadAtIndex(size_t idx) { + LLDB_RECORD_METHOD(lldb::SBThread, SBThreadCollection, GetThreadAtIndex, + (size_t), idx); + SBThread thread; if (m_opaque_sp && idx < m_opaque_sp->GetSize()) thread = m_opaque_sp->GetThreadAtIndex(idx); - return thread; + return LLDB_RECORD_RESULT(thread); +} + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBThreadCollection>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBThreadCollection, ()); + LLDB_REGISTER_CONSTRUCTOR(SBThreadCollection, + (const lldb::SBThreadCollection &)); + LLDB_REGISTER_METHOD( + const lldb::SBThreadCollection &, + SBThreadCollection, operator=,(const lldb::SBThreadCollection &)); + LLDB_REGISTER_METHOD_CONST(bool, SBThreadCollection, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBThreadCollection, operator bool, ()); + LLDB_REGISTER_METHOD(size_t, SBThreadCollection, GetSize, ()); + LLDB_REGISTER_METHOD(lldb::SBThread, SBThreadCollection, GetThreadAtIndex, + (size_t)); +} + +} } diff --git a/source/API/SBThreadPlan.cpp b/source/API/SBThreadPlan.cpp index fc54f5b5f87e4..8f6802fe9cef4 100644 --- a/source/API/SBThreadPlan.cpp +++ b/source/API/SBThreadPlan.cpp @@ -1,12 +1,12 @@ //===-- SBThreadPlan.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// +#include "SBReproducerPrivate.h" #include "lldb/API/SBThread.h" #include "lldb/API/SBFileSpec.h" @@ -42,60 +42,98 @@ #include "lldb/API/SBThreadPlan.h" #include "lldb/API/SBValue.h" +#include <memory> + using namespace lldb; using namespace lldb_private; -//---------------------------------------------------------------------- // Constructors -//---------------------------------------------------------------------- -SBThreadPlan::SBThreadPlan() {} +SBThreadPlan::SBThreadPlan() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBThreadPlan); } SBThreadPlan::SBThreadPlan(const ThreadPlanSP &lldb_object_sp) - : m_opaque_sp(lldb_object_sp) {} + : m_opaque_sp(lldb_object_sp) { + LLDB_RECORD_CONSTRUCTOR(SBThreadPlan, (const lldb::ThreadPlanSP &), + lldb_object_sp); +} SBThreadPlan::SBThreadPlan(const SBThreadPlan &rhs) - : m_opaque_sp(rhs.m_opaque_sp) {} + : m_opaque_sp(rhs.m_opaque_sp) { + LLDB_RECORD_CONSTRUCTOR(SBThreadPlan, (const lldb::SBThreadPlan &), rhs); +} SBThreadPlan::SBThreadPlan(lldb::SBThread &sb_thread, const char *class_name) { + LLDB_RECORD_CONSTRUCTOR(SBThreadPlan, (lldb::SBThread &, const char *), + sb_thread, class_name); + Thread *thread = sb_thread.get(); if (thread) - m_opaque_sp.reset(new ThreadPlanPython(*thread, class_name)); + m_opaque_sp = std::make_shared<ThreadPlanPython>(*thread, class_name); } -//---------------------------------------------------------------------- // Assignment operator -//---------------------------------------------------------------------- const lldb::SBThreadPlan &SBThreadPlan::operator=(const SBThreadPlan &rhs) { + LLDB_RECORD_METHOD(const lldb::SBThreadPlan &, + SBThreadPlan, operator=,(const lldb::SBThreadPlan &), rhs); + if (this != &rhs) m_opaque_sp = rhs.m_opaque_sp; - return *this; + return LLDB_RECORD_RESULT(*this); } -//---------------------------------------------------------------------- // Destructor -//---------------------------------------------------------------------- SBThreadPlan::~SBThreadPlan() {} lldb_private::ThreadPlan *SBThreadPlan::get() { return m_opaque_sp.get(); } -bool SBThreadPlan::IsValid() const { return m_opaque_sp.get() != NULL; } +bool SBThreadPlan::IsValid() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBThreadPlan, IsValid); + return this->operator bool(); +} +SBThreadPlan::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBThreadPlan, operator bool); -void SBThreadPlan::Clear() { m_opaque_sp.reset(); } + return m_opaque_sp.get() != nullptr; +} -lldb::StopReason SBThreadPlan::GetStopReason() { return eStopReasonNone; } +void SBThreadPlan::Clear() { + LLDB_RECORD_METHOD_NO_ARGS(void, SBThreadPlan, Clear); -size_t SBThreadPlan::GetStopReasonDataCount() { return 0; } + m_opaque_sp.reset(); +} -uint64_t SBThreadPlan::GetStopReasonDataAtIndex(uint32_t idx) { return 0; } +lldb::StopReason SBThreadPlan::GetStopReason() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::StopReason, SBThreadPlan, GetStopReason); + + return eStopReasonNone; +} + +size_t SBThreadPlan::GetStopReasonDataCount() { + LLDB_RECORD_METHOD_NO_ARGS(size_t, SBThreadPlan, GetStopReasonDataCount); + + return 0; +} + +uint64_t SBThreadPlan::GetStopReasonDataAtIndex(uint32_t idx) { + LLDB_RECORD_METHOD(uint64_t, SBThreadPlan, GetStopReasonDataAtIndex, + (uint32_t), idx); + + return 0; +} SBThread SBThreadPlan::GetThread() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBThread, SBThreadPlan, GetThread); + if (m_opaque_sp) { - return SBThread(m_opaque_sp->GetThread().shared_from_this()); + return LLDB_RECORD_RESULT( + SBThread(m_opaque_sp->GetThread().shared_from_this())); } else - return SBThread(); + return LLDB_RECORD_RESULT(SBThread()); } bool SBThreadPlan::GetDescription(lldb::SBStream &description) const { + LLDB_RECORD_METHOD_CONST(bool, SBThreadPlan, GetDescription, + (lldb::SBStream &), description); + if (m_opaque_sp) { m_opaque_sp->GetDescription(description.get(), eDescriptionLevelFull); } else { @@ -109,11 +147,15 @@ void SBThreadPlan::SetThreadPlan(const ThreadPlanSP &lldb_object_sp) { } void SBThreadPlan::SetPlanComplete(bool success) { + LLDB_RECORD_METHOD(void, SBThreadPlan, SetPlanComplete, (bool), success); + if (m_opaque_sp) m_opaque_sp->SetPlanComplete(success); } bool SBThreadPlan::IsPlanComplete() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBThreadPlan, IsPlanComplete); + if (m_opaque_sp) return m_opaque_sp->IsPlanComplete(); else @@ -121,6 +163,8 @@ bool SBThreadPlan::IsPlanComplete() { } bool SBThreadPlan::IsPlanStale() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBThreadPlan, IsPlanStale); + if (m_opaque_sp) return m_opaque_sp->IsPlanStale(); else @@ -128,6 +172,8 @@ bool SBThreadPlan::IsPlanStale() { } bool SBThreadPlan::IsValid() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBThreadPlan, IsValid); + if (m_opaque_sp) return m_opaque_sp->ValidatePlan(nullptr); else @@ -143,16 +189,26 @@ bool SBThreadPlan::IsValid() { SBThreadPlan SBThreadPlan::QueueThreadPlanForStepOverRange(SBAddress &sb_start_address, lldb::addr_t size) { + LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan, + QueueThreadPlanForStepOverRange, + (lldb::SBAddress &, lldb::addr_t), sb_start_address, size); + SBError error; - return QueueThreadPlanForStepOverRange(sb_start_address, size, error); + return LLDB_RECORD_RESULT( + QueueThreadPlanForStepOverRange(sb_start_address, size, error)); } SBThreadPlan SBThreadPlan::QueueThreadPlanForStepOverRange( SBAddress &sb_start_address, lldb::addr_t size, SBError &error) { + LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan, + QueueThreadPlanForStepOverRange, + (lldb::SBAddress &, lldb::addr_t, lldb::SBError &), + sb_start_address, size, error); + if (m_opaque_sp) { Address *start_address = sb_start_address.get(); if (!start_address) { - return SBThreadPlan(); + return LLDB_RECORD_RESULT(SBThreadPlan()); } AddressRange range(*start_address, size); @@ -167,26 +223,36 @@ SBThreadPlan SBThreadPlan::QueueThreadPlanForStepOverRange( if (plan_status.Fail()) error.SetErrorString(plan_status.AsCString()); - return plan; + return LLDB_RECORD_RESULT(plan); } else { - return SBThreadPlan(); + return LLDB_RECORD_RESULT(SBThreadPlan()); } } SBThreadPlan SBThreadPlan::QueueThreadPlanForStepInRange(SBAddress &sb_start_address, lldb::addr_t size) { + LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan, + QueueThreadPlanForStepInRange, + (lldb::SBAddress &, lldb::addr_t), sb_start_address, size); + SBError error; - return QueueThreadPlanForStepInRange(sb_start_address, size, error); + return LLDB_RECORD_RESULT( + QueueThreadPlanForStepInRange(sb_start_address, size, error)); } SBThreadPlan SBThreadPlan::QueueThreadPlanForStepInRange(SBAddress &sb_start_address, lldb::addr_t size, SBError &error) { + LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan, + QueueThreadPlanForStepInRange, + (lldb::SBAddress &, lldb::addr_t, lldb::SBError &), + sb_start_address, size, error); + if (m_opaque_sp) { Address *start_address = sb_start_address.get(); if (!start_address) { - return SBThreadPlan(); + return LLDB_RECORD_RESULT(SBThreadPlan()); } AddressRange range(*start_address, size); @@ -196,27 +262,37 @@ SBThreadPlan::QueueThreadPlanForStepInRange(SBAddress &sb_start_address, Status plan_status; SBThreadPlan plan = SBThreadPlan(m_opaque_sp->GetThread().QueueThreadPlanForStepInRange( - false, range, sc, NULL, eAllThreads, plan_status)); + false, range, sc, nullptr, eAllThreads, plan_status)); if (plan_status.Fail()) error.SetErrorString(plan_status.AsCString()); - return plan; + return LLDB_RECORD_RESULT(plan); } else { - return SBThreadPlan(); + return LLDB_RECORD_RESULT(SBThreadPlan()); } } SBThreadPlan SBThreadPlan::QueueThreadPlanForStepOut(uint32_t frame_idx_to_step_to, bool first_insn) { + LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan, + QueueThreadPlanForStepOut, (uint32_t, bool), + frame_idx_to_step_to, first_insn); + SBError error; - return QueueThreadPlanForStepOut(frame_idx_to_step_to, first_insn, error); + return LLDB_RECORD_RESULT( + QueueThreadPlanForStepOut(frame_idx_to_step_to, first_insn, error)); } SBThreadPlan SBThreadPlan::QueueThreadPlanForStepOut(uint32_t frame_idx_to_step_to, bool first_insn, SBError &error) { + LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan, + QueueThreadPlanForStepOut, + (uint32_t, bool, lldb::SBError &), frame_idx_to_step_to, + first_insn, error); + if (m_opaque_sp) { SymbolContext sc; sc = m_opaque_sp->GetThread().GetStackFrameAtIndex(0)->GetSymbolContext( @@ -231,24 +307,32 @@ SBThreadPlan::QueueThreadPlanForStepOut(uint32_t frame_idx_to_step_to, if (plan_status.Fail()) error.SetErrorString(plan_status.AsCString()); - return plan; + return LLDB_RECORD_RESULT(plan); } else { - return SBThreadPlan(); + return LLDB_RECORD_RESULT(SBThreadPlan()); } } SBThreadPlan SBThreadPlan::QueueThreadPlanForRunToAddress(SBAddress sb_address) { + LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan, + QueueThreadPlanForRunToAddress, (lldb::SBAddress), + sb_address); + SBError error; - return QueueThreadPlanForRunToAddress(sb_address, error); + return LLDB_RECORD_RESULT(QueueThreadPlanForRunToAddress(sb_address, error)); } SBThreadPlan SBThreadPlan::QueueThreadPlanForRunToAddress(SBAddress sb_address, SBError &error) { + LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan, + QueueThreadPlanForRunToAddress, + (lldb::SBAddress, lldb::SBError &), sb_address, error); + if (m_opaque_sp) { Address *address = sb_address.get(); if (!address) - return SBThreadPlan(); + return LLDB_RECORD_RESULT(SBThreadPlan()); Status plan_status; SBThreadPlan plan = @@ -258,21 +342,30 @@ SBThreadPlan SBThreadPlan::QueueThreadPlanForRunToAddress(SBAddress sb_address, if (plan_status.Fail()) error.SetErrorString(plan_status.AsCString()); - return plan; + return LLDB_RECORD_RESULT(plan); } else { - return SBThreadPlan(); + return LLDB_RECORD_RESULT(SBThreadPlan()); } } SBThreadPlan SBThreadPlan::QueueThreadPlanForStepScripted(const char *script_class_name) { + LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan, + QueueThreadPlanForStepScripted, (const char *), + script_class_name); + SBError error; - return QueueThreadPlanForStepScripted(script_class_name, error); + return LLDB_RECORD_RESULT( + QueueThreadPlanForStepScripted(script_class_name, error)); } SBThreadPlan SBThreadPlan::QueueThreadPlanForStepScripted(const char *script_class_name, SBError &error) { + LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan, + QueueThreadPlanForStepScripted, + (const char *, lldb::SBError &), script_class_name, error); + if (m_opaque_sp) { Status plan_status; SBThreadPlan plan = @@ -282,8 +375,65 @@ SBThreadPlan::QueueThreadPlanForStepScripted(const char *script_class_name, if (plan_status.Fail()) error.SetErrorString(plan_status.AsCString()); - return plan; + return LLDB_RECORD_RESULT(plan); } else { - return SBThreadPlan(); + return LLDB_RECORD_RESULT(SBThreadPlan()); } } + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBThreadPlan>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBThreadPlan, ()); + LLDB_REGISTER_CONSTRUCTOR(SBThreadPlan, (const lldb::ThreadPlanSP &)); + LLDB_REGISTER_CONSTRUCTOR(SBThreadPlan, (const lldb::SBThreadPlan &)); + LLDB_REGISTER_CONSTRUCTOR(SBThreadPlan, (lldb::SBThread &, const char *)); + LLDB_REGISTER_METHOD(const lldb::SBThreadPlan &, + SBThreadPlan, operator=,(const lldb::SBThreadPlan &)); + LLDB_REGISTER_METHOD_CONST(bool, SBThreadPlan, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBThreadPlan, operator bool, ()); + LLDB_REGISTER_METHOD(void, SBThreadPlan, Clear, ()); + LLDB_REGISTER_METHOD(lldb::StopReason, SBThreadPlan, GetStopReason, ()); + LLDB_REGISTER_METHOD(size_t, SBThreadPlan, GetStopReasonDataCount, ()); + LLDB_REGISTER_METHOD(uint64_t, SBThreadPlan, GetStopReasonDataAtIndex, + (uint32_t)); + LLDB_REGISTER_METHOD_CONST(lldb::SBThread, SBThreadPlan, GetThread, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBThreadPlan, GetDescription, + (lldb::SBStream &)); + LLDB_REGISTER_METHOD(void, SBThreadPlan, SetPlanComplete, (bool)); + LLDB_REGISTER_METHOD(bool, SBThreadPlan, IsPlanComplete, ()); + LLDB_REGISTER_METHOD(bool, SBThreadPlan, IsPlanStale, ()); + LLDB_REGISTER_METHOD(bool, SBThreadPlan, IsValid, ()); + LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan, + QueueThreadPlanForStepOverRange, + (lldb::SBAddress &, lldb::addr_t)); + LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan, + QueueThreadPlanForStepOverRange, + (lldb::SBAddress &, lldb::addr_t, lldb::SBError &)); + LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan, + QueueThreadPlanForStepInRange, + (lldb::SBAddress &, lldb::addr_t)); + LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan, + QueueThreadPlanForStepInRange, + (lldb::SBAddress &, lldb::addr_t, lldb::SBError &)); + LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan, + QueueThreadPlanForStepOut, (uint32_t, bool)); + LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan, + QueueThreadPlanForStepOut, + (uint32_t, bool, lldb::SBError &)); + LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan, + QueueThreadPlanForRunToAddress, (lldb::SBAddress)); + LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan, + QueueThreadPlanForRunToAddress, + (lldb::SBAddress, lldb::SBError &)); + LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan, + QueueThreadPlanForStepScripted, (const char *)); + LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan, + QueueThreadPlanForStepScripted, + (const char *, lldb::SBError &)); +} + +} +} diff --git a/source/API/SBTrace.cpp b/source/API/SBTrace.cpp index 9a5fa4ed4f462..9b871e6781d9b 100644 --- a/source/API/SBTrace.cpp +++ b/source/API/SBTrace.cpp @@ -1,18 +1,19 @@ //===-- SBTrace.cpp ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// +#include "SBReproducerPrivate.h" #include "lldb/Target/Process.h" -#include "lldb/Utility/Log.h" #include "lldb/API/SBTrace.h" #include "lldb/API/SBTraceOptions.h" +#include <memory> + using namespace lldb; using namespace lldb_private; @@ -25,8 +26,11 @@ lldb::ProcessSP SBTrace::GetSP() const { return m_opaque_wp.lock(); } size_t SBTrace::GetTraceData(SBError &error, void *buf, size_t size, size_t offset, lldb::tid_t thread_id) { + LLDB_RECORD_DUMMY(size_t, SBTrace, GetTraceData, + (lldb::SBError &, void *, size_t, size_t, lldb::tid_t), + error, buf, size, offset, thread_id); + ProcessSP process_sp(GetSP()); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); llvm::MutableArrayRef<uint8_t> buffer(static_cast<uint8_t *>(buf), size); error.Clear(); @@ -35,30 +39,33 @@ size_t SBTrace::GetTraceData(SBError &error, void *buf, size_t size, } else { error.SetError( process_sp->GetData(GetTraceUID(), thread_id, buffer, offset)); - LLDB_LOG(log, "SBTrace::bytes_read - {0}", buffer.size()); } return buffer.size(); } size_t SBTrace::GetMetaData(SBError &error, void *buf, size_t size, size_t offset, lldb::tid_t thread_id) { + LLDB_RECORD_DUMMY(size_t, SBTrace, GetMetaData, + (lldb::SBError &, void *, size_t, size_t, lldb::tid_t), + error, buf, size, offset, thread_id); + ProcessSP process_sp(GetSP()); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); llvm::MutableArrayRef<uint8_t> buffer(static_cast<uint8_t *>(buf), size); error.Clear(); if (!process_sp) { error.SetErrorString("invalid process"); } else { - error.SetError( process_sp->GetMetaData(GetTraceUID(), thread_id, buffer, offset)); - LLDB_LOG(log, "SBTrace::bytes_read - {0}", buffer.size()); } return buffer.size(); } void SBTrace::StopTrace(SBError &error, lldb::tid_t thread_id) { + LLDB_RECORD_METHOD(void, SBTrace, StopTrace, (lldb::SBError &, lldb::tid_t), + error, thread_id); + ProcessSP process_sp(GetSP()); error.Clear(); @@ -70,6 +77,9 @@ void SBTrace::StopTrace(SBError &error, lldb::tid_t thread_id) { } void SBTrace::GetTraceConfig(SBTraceOptions &options, SBError &error) { + LLDB_RECORD_METHOD(void, SBTrace, GetTraceConfig, + (lldb::SBTraceOptions &, lldb::SBError &), options, error); + ProcessSP process_sp(GetSP()); error.Clear(); @@ -82,6 +92,8 @@ void SBTrace::GetTraceConfig(SBTraceOptions &options, SBError &error) { } lldb::user_id_t SBTrace::GetTraceUID() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::user_id_t, SBTrace, GetTraceUID); + if (m_trace_impl_sp) return m_trace_impl_sp->uid; return LLDB_INVALID_UID; @@ -93,7 +105,9 @@ void SBTrace::SetTraceUID(lldb::user_id_t uid) { } SBTrace::SBTrace() { - m_trace_impl_sp.reset(new TraceImpl); + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTrace); + + m_trace_impl_sp = std::make_shared<TraceImpl>(); if (m_trace_impl_sp) m_trace_impl_sp->uid = LLDB_INVALID_UID; } @@ -101,9 +115,33 @@ SBTrace::SBTrace() { void SBTrace::SetSP(const ProcessSP &process_sp) { m_opaque_wp = process_sp; } bool SBTrace::IsValid() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBTrace, IsValid); + return this->operator bool(); +} +SBTrace::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTrace, operator bool); + if (!m_trace_impl_sp) return false; if (!GetSP()) return false; return true; } + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBTrace>(Registry &R) { + LLDB_REGISTER_METHOD(void, SBTrace, StopTrace, + (lldb::SBError &, lldb::tid_t)); + LLDB_REGISTER_METHOD(void, SBTrace, GetTraceConfig, + (lldb::SBTraceOptions &, lldb::SBError &)); + LLDB_REGISTER_METHOD(lldb::user_id_t, SBTrace, GetTraceUID, ()); + LLDB_REGISTER_CONSTRUCTOR(SBTrace, ()); + LLDB_REGISTER_METHOD(bool, SBTrace, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBTrace, operator bool, ()); +} + +} +} diff --git a/source/API/SBTraceOptions.cpp b/source/API/SBTraceOptions.cpp index 20a8f25a768b1..a24cdd59af0bf 100644 --- a/source/API/SBTraceOptions.cpp +++ b/source/API/SBTraceOptions.cpp @@ -1,39 +1,51 @@ //===-- SBTraceOptions.cpp --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBTraceOptions.h" +#include "SBReproducerPrivate.h" #include "lldb/API/SBError.h" #include "lldb/API/SBStructuredData.h" #include "lldb/Core/StructuredDataImpl.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/TraceOptions.h" +#include <memory> + using namespace lldb; using namespace lldb_private; SBTraceOptions::SBTraceOptions() { - m_traceoptions_sp.reset(new TraceOptions()); + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTraceOptions); + + m_traceoptions_sp = std::make_shared<TraceOptions>(); } lldb::TraceType SBTraceOptions::getType() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::TraceType, SBTraceOptions, getType); + if (m_traceoptions_sp) return m_traceoptions_sp->getType(); return lldb::TraceType::eTraceTypeNone; } uint64_t SBTraceOptions::getTraceBufferSize() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(uint64_t, SBTraceOptions, + getTraceBufferSize); + if (m_traceoptions_sp) return m_traceoptions_sp->getTraceBufferSize(); return 0; } lldb::SBStructuredData SBTraceOptions::getTraceParams(lldb::SBError &error) { + LLDB_RECORD_METHOD(lldb::SBStructuredData, SBTraceOptions, getTraceParams, + (lldb::SBError &), error); + error.Clear(); const lldb_private::StructuredData::DictionarySP dict_obj = m_traceoptions_sp->getTraceParams(); @@ -42,16 +54,22 @@ lldb::SBStructuredData SBTraceOptions::getTraceParams(lldb::SBError &error) { structData.m_impl_up->SetObjectSP(dict_obj->shared_from_this()); else error.SetErrorString("Empty trace params"); - return structData; + return LLDB_RECORD_RESULT(structData); } uint64_t SBTraceOptions::getMetaDataBufferSize() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(uint64_t, SBTraceOptions, + getMetaDataBufferSize); + if (m_traceoptions_sp) return m_traceoptions_sp->getTraceBufferSize(); return 0; } void SBTraceOptions::setTraceParams(lldb::SBStructuredData ¶ms) { + LLDB_RECORD_METHOD(void, SBTraceOptions, setTraceParams, + (lldb::SBStructuredData &), params); + if (m_traceoptions_sp && params.m_impl_up) { StructuredData::ObjectSP obj_sp = params.m_impl_up->GetObjectSP(); if (obj_sp && obj_sp->GetAsDictionary() != nullptr) @@ -62,33 +80,80 @@ void SBTraceOptions::setTraceParams(lldb::SBStructuredData ¶ms) { } void SBTraceOptions::setType(lldb::TraceType type) { + LLDB_RECORD_METHOD(void, SBTraceOptions, setType, (lldb::TraceType), type); + if (m_traceoptions_sp) m_traceoptions_sp->setType(type); } void SBTraceOptions::setTraceBufferSize(uint64_t size) { + LLDB_RECORD_METHOD(void, SBTraceOptions, setTraceBufferSize, (uint64_t), + size); + if (m_traceoptions_sp) m_traceoptions_sp->setTraceBufferSize(size); } void SBTraceOptions::setMetaDataBufferSize(uint64_t size) { + LLDB_RECORD_METHOD(void, SBTraceOptions, setMetaDataBufferSize, (uint64_t), + size); + if (m_traceoptions_sp) m_traceoptions_sp->setMetaDataBufferSize(size); } bool SBTraceOptions::IsValid() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBTraceOptions, IsValid); + return this->operator bool(); +} +SBTraceOptions::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTraceOptions, operator bool); + if (m_traceoptions_sp) return true; return false; } void SBTraceOptions::setThreadID(lldb::tid_t thread_id) { + LLDB_RECORD_METHOD(void, SBTraceOptions, setThreadID, (lldb::tid_t), + thread_id); + if (m_traceoptions_sp) m_traceoptions_sp->setThreadID(thread_id); } lldb::tid_t SBTraceOptions::getThreadID() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::tid_t, SBTraceOptions, getThreadID); + if (m_traceoptions_sp) return m_traceoptions_sp->getThreadID(); return LLDB_INVALID_THREAD_ID; } + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBTraceOptions>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBTraceOptions, ()); + LLDB_REGISTER_METHOD_CONST(lldb::TraceType, SBTraceOptions, getType, ()); + LLDB_REGISTER_METHOD_CONST(uint64_t, SBTraceOptions, getTraceBufferSize, + ()); + LLDB_REGISTER_METHOD(lldb::SBStructuredData, SBTraceOptions, getTraceParams, + (lldb::SBError &)); + LLDB_REGISTER_METHOD_CONST(uint64_t, SBTraceOptions, getMetaDataBufferSize, + ()); + LLDB_REGISTER_METHOD(void, SBTraceOptions, setTraceParams, + (lldb::SBStructuredData &)); + LLDB_REGISTER_METHOD(void, SBTraceOptions, setType, (lldb::TraceType)); + LLDB_REGISTER_METHOD(void, SBTraceOptions, setTraceBufferSize, (uint64_t)); + LLDB_REGISTER_METHOD(void, SBTraceOptions, setMetaDataBufferSize, + (uint64_t)); + LLDB_REGISTER_METHOD(bool, SBTraceOptions, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBTraceOptions, operator bool, ()); + LLDB_REGISTER_METHOD(void, SBTraceOptions, setThreadID, (lldb::tid_t)); + LLDB_REGISTER_METHOD(lldb::tid_t, SBTraceOptions, getThreadID, ()); +} + +} +} diff --git a/source/API/SBType.cpp b/source/API/SBType.cpp index 77d7dc654100a..5402128b3faeb 100644 --- a/source/API/SBType.cpp +++ b/source/API/SBType.cpp @@ -1,13 +1,13 @@ //===-- SBType.cpp ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBType.h" +#include "SBReproducerPrivate.h" #include "lldb/API/SBDefines.h" #include "lldb/API/SBStream.h" #include "lldb/API/SBTypeEnumMember.h" @@ -16,15 +16,16 @@ #include "lldb/Symbol/Type.h" #include "lldb/Symbol/TypeSystem.h" #include "lldb/Utility/ConstString.h" -#include "lldb/Utility/Log.h" #include "lldb/Utility/Stream.h" #include "llvm/ADT/APSInt.h" +#include <memory> + using namespace lldb; using namespace lldb_private; -SBType::SBType() : m_opaque_sp() {} +SBType::SBType() : m_opaque_sp() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBType); } SBType::SBType(const CompilerType &type) : m_opaque_sp(new TypeImpl( @@ -37,16 +38,20 @@ SBType::SBType(const lldb::TypeImplSP &type_impl_sp) : m_opaque_sp(type_impl_sp) {} SBType::SBType(const SBType &rhs) : m_opaque_sp() { + LLDB_RECORD_CONSTRUCTOR(SBType, (const lldb::SBType &), rhs); + if (this != &rhs) { m_opaque_sp = rhs.m_opaque_sp; } } // SBType::SBType (TypeImpl* impl) : -// m_opaque_ap(impl) +// m_opaque_up(impl) //{} // bool SBType::operator==(SBType &rhs) { + LLDB_RECORD_METHOD(bool, SBType, operator==,(lldb::SBType &), rhs); + if (!IsValid()) return !rhs.IsValid(); @@ -57,6 +62,8 @@ bool SBType::operator==(SBType &rhs) { } bool SBType::operator!=(SBType &rhs) { + LLDB_RECORD_METHOD(bool, SBType, operator!=,(lldb::SBType &), rhs); + if (!IsValid()) return rhs.IsValid(); @@ -73,17 +80,20 @@ void SBType::SetSP(const lldb::TypeImplSP &type_impl_sp) { } SBType &SBType::operator=(const SBType &rhs) { + LLDB_RECORD_METHOD(lldb::SBType &, SBType, operator=,(const lldb::SBType &), + rhs); + if (this != &rhs) { m_opaque_sp = rhs.m_opaque_sp; } - return *this; + return LLDB_RECORD_RESULT(*this); } SBType::~SBType() {} TypeImpl &SBType::ref() { - if (m_opaque_sp.get() == NULL) - m_opaque_sp.reset(new TypeImpl()); + if (m_opaque_sp.get() == nullptr) + m_opaque_sp = std::make_shared<TypeImpl>(); return *m_opaque_sp; } @@ -96,13 +106,21 @@ const TypeImpl &SBType::ref() const { } bool SBType::IsValid() const { - if (m_opaque_sp.get() == NULL) + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBType, IsValid); + return this->operator bool(); +} +SBType::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBType, operator bool); + + if (m_opaque_sp.get() == nullptr) return false; return m_opaque_sp->IsValid(); } uint64_t SBType::GetByteSize() { + LLDB_RECORD_METHOD_NO_ARGS(uint64_t, SBType, GetByteSize); + if (IsValid()) if (llvm::Optional<uint64_t> size = m_opaque_sp->GetCompilerType(false).GetByteSize(nullptr)) @@ -111,12 +129,16 @@ uint64_t SBType::GetByteSize() { } bool SBType::IsPointerType() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBType, IsPointerType); + if (!IsValid()) return false; return m_opaque_sp->GetCompilerType(true).IsPointerType(); } bool SBType::IsArrayType() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBType, IsArrayType); + if (!IsValid()) return false; return m_opaque_sp->GetCompilerType(true).IsArrayType(nullptr, nullptr, @@ -124,63 +146,88 @@ bool SBType::IsArrayType() { } bool SBType::IsVectorType() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBType, IsVectorType); + if (!IsValid()) return false; return m_opaque_sp->GetCompilerType(true).IsVectorType(nullptr, nullptr); } bool SBType::IsReferenceType() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBType, IsReferenceType); + if (!IsValid()) return false; return m_opaque_sp->GetCompilerType(true).IsReferenceType(); } SBType SBType::GetPointerType() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetPointerType); + if (!IsValid()) - return SBType(); + return LLDB_RECORD_RESULT(SBType()); - return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetPointerType()))); + return LLDB_RECORD_RESULT( + SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetPointerType())))); } SBType SBType::GetPointeeType() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetPointeeType); + if (!IsValid()) - return SBType(); - return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetPointeeType()))); + return LLDB_RECORD_RESULT(SBType()); + return LLDB_RECORD_RESULT( + SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetPointeeType())))); } SBType SBType::GetReferenceType() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetReferenceType); + if (!IsValid()) - return SBType(); - return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetReferenceType()))); + return LLDB_RECORD_RESULT(SBType()); + return LLDB_RECORD_RESULT( + SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetReferenceType())))); } SBType SBType::GetTypedefedType() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetTypedefedType); + if (!IsValid()) - return SBType(); - return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetTypedefedType()))); + return LLDB_RECORD_RESULT(SBType()); + return LLDB_RECORD_RESULT( + SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetTypedefedType())))); } SBType SBType::GetDereferencedType() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetDereferencedType); + if (!IsValid()) - return SBType(); - return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetDereferencedType()))); + return LLDB_RECORD_RESULT(SBType()); + return LLDB_RECORD_RESULT( + SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetDereferencedType())))); } SBType SBType::GetArrayElementType() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetArrayElementType); + if (!IsValid()) - return SBType(); - return SBType(TypeImplSP( - new TypeImpl(m_opaque_sp->GetCompilerType(true).GetArrayElementType()))); + return LLDB_RECORD_RESULT(SBType()); + return LLDB_RECORD_RESULT(SBType(TypeImplSP( + new TypeImpl(m_opaque_sp->GetCompilerType(true).GetArrayElementType())))); } SBType SBType::GetArrayType(uint64_t size) { + LLDB_RECORD_METHOD(lldb::SBType, SBType, GetArrayType, (uint64_t), size); + if (!IsValid()) - return SBType(); - return SBType(TypeImplSP( - new TypeImpl(m_opaque_sp->GetCompilerType(true).GetArrayType(size)))); + return LLDB_RECORD_RESULT(SBType()); + return LLDB_RECORD_RESULT(SBType(TypeImplSP( + new TypeImpl(m_opaque_sp->GetCompilerType(true).GetArrayType(size))))); } SBType SBType::GetVectorElementType() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetVectorElementType); + SBType type_sb; if (IsValid()) { CompilerType vector_element_type; @@ -188,44 +235,57 @@ SBType SBType::GetVectorElementType() { nullptr)) type_sb.SetSP(TypeImplSP(new TypeImpl(vector_element_type))); } - return type_sb; + return LLDB_RECORD_RESULT(type_sb); } bool SBType::IsFunctionType() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBType, IsFunctionType); + if (!IsValid()) return false; return m_opaque_sp->GetCompilerType(true).IsFunctionType(); } bool SBType::IsPolymorphicClass() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBType, IsPolymorphicClass); + if (!IsValid()) return false; return m_opaque_sp->GetCompilerType(true).IsPolymorphicClass(); } bool SBType::IsTypedefType() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBType, IsTypedefType); + if (!IsValid()) return false; return m_opaque_sp->GetCompilerType(true).IsTypedefType(); } bool SBType::IsAnonymousType() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBType, IsAnonymousType); + if (!IsValid()) return false; return m_opaque_sp->GetCompilerType(true).IsAnonymousType(); } lldb::SBType SBType::GetFunctionReturnType() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetFunctionReturnType); + if (IsValid()) { CompilerType return_type( m_opaque_sp->GetCompilerType(true).GetFunctionReturnType()); if (return_type.IsValid()) - return SBType(return_type); + return LLDB_RECORD_RESULT(SBType(return_type)); } - return lldb::SBType(); + return LLDB_RECORD_RESULT(lldb::SBType()); } lldb::SBTypeList SBType::GetFunctionArgumentTypes() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTypeList, SBType, + GetFunctionArgumentTypes); + SBTypeList sb_type_list; if (IsValid()) { CompilerType func_type(m_opaque_sp->GetCompilerType(true)); @@ -234,10 +294,12 @@ lldb::SBTypeList SBType::GetFunctionArgumentTypes() { sb_type_list.Append(SBType(func_type.GetFunctionArgumentAtIndex(i))); } } - return sb_type_list; + return LLDB_RECORD_RESULT(sb_type_list); } uint32_t SBType::GetNumberOfMemberFunctions() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBType, GetNumberOfMemberFunctions); + if (IsValid()) { return m_opaque_sp->GetCompilerType(true).GetNumMemberFunctions(); } @@ -245,51 +307,71 @@ uint32_t SBType::GetNumberOfMemberFunctions() { } lldb::SBTypeMemberFunction SBType::GetMemberFunctionAtIndex(uint32_t idx) { + LLDB_RECORD_METHOD(lldb::SBTypeMemberFunction, SBType, + GetMemberFunctionAtIndex, (uint32_t), idx); + SBTypeMemberFunction sb_func_type; if (IsValid()) sb_func_type.reset(new TypeMemberFunctionImpl( m_opaque_sp->GetCompilerType(true).GetMemberFunctionAtIndex(idx))); - return sb_func_type; + return LLDB_RECORD_RESULT(sb_func_type); } lldb::SBType SBType::GetUnqualifiedType() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetUnqualifiedType); + if (!IsValid()) - return SBType(); - return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetUnqualifiedType()))); + return LLDB_RECORD_RESULT(SBType()); + return LLDB_RECORD_RESULT( + SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetUnqualifiedType())))); } lldb::SBType SBType::GetCanonicalType() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetCanonicalType); + if (IsValid()) - return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetCanonicalType()))); - return SBType(); + return LLDB_RECORD_RESULT( + SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetCanonicalType())))); + return LLDB_RECORD_RESULT(SBType()); } lldb::BasicType SBType::GetBasicType() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::BasicType, SBType, GetBasicType); + if (IsValid()) return m_opaque_sp->GetCompilerType(false).GetBasicTypeEnumeration(); return eBasicTypeInvalid; } SBType SBType::GetBasicType(lldb::BasicType basic_type) { + LLDB_RECORD_METHOD(lldb::SBType, SBType, GetBasicType, (lldb::BasicType), + basic_type); + if (IsValid() && m_opaque_sp->IsValid()) - return SBType( - m_opaque_sp->GetTypeSystem(false)->GetBasicTypeFromAST(basic_type)); - return SBType(); + return LLDB_RECORD_RESULT(SBType( + m_opaque_sp->GetTypeSystem(false)->GetBasicTypeFromAST(basic_type))); + return LLDB_RECORD_RESULT(SBType()); } uint32_t SBType::GetNumberOfDirectBaseClasses() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBType, GetNumberOfDirectBaseClasses); + if (IsValid()) return m_opaque_sp->GetCompilerType(true).GetNumDirectBaseClasses(); return 0; } uint32_t SBType::GetNumberOfVirtualBaseClasses() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBType, GetNumberOfVirtualBaseClasses); + if (IsValid()) return m_opaque_sp->GetCompilerType(true).GetNumVirtualBaseClasses(); return 0; } uint32_t SBType::GetNumberOfFields() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBType, GetNumberOfFields); + if (IsValid()) return m_opaque_sp->GetCompilerType(true).GetNumFields(); return 0; @@ -297,6 +379,10 @@ uint32_t SBType::GetNumberOfFields() { bool SBType::GetDescription(SBStream &description, lldb::DescriptionLevel description_level) { + LLDB_RECORD_METHOD(bool, SBType, GetDescription, + (lldb::SBStream &, lldb::DescriptionLevel), description, + description_level); + Stream &strm = description.ref(); if (m_opaque_sp) { @@ -308,6 +394,9 @@ bool SBType::GetDescription(SBStream &description, } SBTypeMember SBType::GetDirectBaseClassAtIndex(uint32_t idx) { + LLDB_RECORD_METHOD(lldb::SBTypeMember, SBType, GetDirectBaseClassAtIndex, + (uint32_t), idx); + SBTypeMember sb_type_member; if (IsValid()) { uint32_t bit_offset = 0; @@ -318,10 +407,13 @@ SBTypeMember SBType::GetDirectBaseClassAtIndex(uint32_t idx) { sb_type_member.reset(new TypeMemberImpl( TypeImplSP(new TypeImpl(base_class_type)), bit_offset)); } - return sb_type_member; + return LLDB_RECORD_RESULT(sb_type_member); } SBTypeMember SBType::GetVirtualBaseClassAtIndex(uint32_t idx) { + LLDB_RECORD_METHOD(lldb::SBTypeMember, SBType, GetVirtualBaseClassAtIndex, + (uint32_t), idx); + SBTypeMember sb_type_member; if (IsValid()) { uint32_t bit_offset = 0; @@ -332,17 +424,20 @@ SBTypeMember SBType::GetVirtualBaseClassAtIndex(uint32_t idx) { sb_type_member.reset(new TypeMemberImpl( TypeImplSP(new TypeImpl(base_class_type)), bit_offset)); } - return sb_type_member; + return LLDB_RECORD_RESULT(sb_type_member); } SBTypeEnumMemberList SBType::GetEnumMembers() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTypeEnumMemberList, SBType, + GetEnumMembers); + SBTypeEnumMemberList sb_enum_member_list; if (IsValid()) { CompilerType this_type(m_opaque_sp->GetCompilerType(true)); if (this_type.IsValid()) { this_type.ForEachEnumerator([&sb_enum_member_list]( const CompilerType &integer_type, - const ConstString &name, + ConstString name, const llvm::APSInt &value) -> bool { SBTypeEnumMember enum_member( lldb::TypeEnumMemberImplSP(new TypeEnumMemberImpl( @@ -352,10 +447,13 @@ SBTypeEnumMemberList SBType::GetEnumMembers() { }); } } - return sb_enum_member_list; + return LLDB_RECORD_RESULT(sb_enum_member_list); } SBTypeMember SBType::GetFieldAtIndex(uint32_t idx) { + LLDB_RECORD_METHOD(lldb::SBTypeMember, SBType, GetFieldAtIndex, (uint32_t), + idx); + SBTypeMember sb_type_member; if (IsValid()) { CompilerType this_type(m_opaque_sp->GetCompilerType(false)); @@ -376,48 +474,63 @@ SBTypeMember SBType::GetFieldAtIndex(uint32_t idx) { } } } - return sb_type_member; + return LLDB_RECORD_RESULT(sb_type_member); } bool SBType::IsTypeComplete() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBType, IsTypeComplete); + if (!IsValid()) return false; return m_opaque_sp->GetCompilerType(false).IsCompleteType(); } uint32_t SBType::GetTypeFlags() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBType, GetTypeFlags); + if (!IsValid()) return 0; return m_opaque_sp->GetCompilerType(true).GetTypeInfo(); } const char *SBType::GetName() { + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBType, GetName); + if (!IsValid()) return ""; return m_opaque_sp->GetName().GetCString(); } const char *SBType::GetDisplayTypeName() { + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBType, GetDisplayTypeName); + if (!IsValid()) return ""; return m_opaque_sp->GetDisplayTypeName().GetCString(); } lldb::TypeClass SBType::GetTypeClass() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::TypeClass, SBType, GetTypeClass); + if (IsValid()) return m_opaque_sp->GetCompilerType(true).GetTypeClass(); return lldb::eTypeClassInvalid; } uint32_t SBType::GetNumberOfTemplateArguments() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBType, GetNumberOfTemplateArguments); + if (IsValid()) return m_opaque_sp->GetCompilerType(false).GetNumTemplateArguments(); return 0; } lldb::SBType SBType::GetTemplateArgumentType(uint32_t idx) { + LLDB_RECORD_METHOD(lldb::SBType, SBType, GetTemplateArgumentType, (uint32_t), + idx); + if (!IsValid()) - return SBType(); + return LLDB_RECORD_RESULT(SBType()); CompilerType type; switch(GetTemplateArgumentKind(idx)) { @@ -433,132 +546,190 @@ lldb::SBType SBType::GetTemplateArgumentType(uint32_t idx) { break; } if (type.IsValid()) - return SBType(type); - return SBType(); + return LLDB_RECORD_RESULT(SBType(type)); + return LLDB_RECORD_RESULT(SBType()); } lldb::TemplateArgumentKind SBType::GetTemplateArgumentKind(uint32_t idx) { + LLDB_RECORD_METHOD(lldb::TemplateArgumentKind, SBType, + GetTemplateArgumentKind, (uint32_t), idx); + if (IsValid()) return m_opaque_sp->GetCompilerType(false).GetTemplateArgumentKind(idx); return eTemplateArgumentKindNull; } -SBTypeList::SBTypeList() : m_opaque_ap(new TypeListImpl()) {} +SBTypeList::SBTypeList() : m_opaque_up(new TypeListImpl()) { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeList); +} SBTypeList::SBTypeList(const SBTypeList &rhs) - : m_opaque_ap(new TypeListImpl()) { + : m_opaque_up(new TypeListImpl()) { + LLDB_RECORD_CONSTRUCTOR(SBTypeList, (const lldb::SBTypeList &), rhs); + for (uint32_t i = 0, rhs_size = const_cast<SBTypeList &>(rhs).GetSize(); i < rhs_size; i++) Append(const_cast<SBTypeList &>(rhs).GetTypeAtIndex(i)); } -bool SBTypeList::IsValid() { return (m_opaque_ap != NULL); } +bool SBTypeList::IsValid() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBTypeList, IsValid); + return this->operator bool(); +} +SBTypeList::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeList, operator bool); + + return (m_opaque_up != nullptr); +} SBTypeList &SBTypeList::operator=(const SBTypeList &rhs) { + LLDB_RECORD_METHOD(lldb::SBTypeList &, + SBTypeList, operator=,(const lldb::SBTypeList &), rhs); + if (this != &rhs) { - m_opaque_ap.reset(new TypeListImpl()); + m_opaque_up.reset(new TypeListImpl()); for (uint32_t i = 0, rhs_size = const_cast<SBTypeList &>(rhs).GetSize(); i < rhs_size; i++) Append(const_cast<SBTypeList &>(rhs).GetTypeAtIndex(i)); } - return *this; + return LLDB_RECORD_RESULT(*this); } void SBTypeList::Append(SBType type) { + LLDB_RECORD_METHOD(void, SBTypeList, Append, (lldb::SBType), type); + if (type.IsValid()) - m_opaque_ap->Append(type.m_opaque_sp); + m_opaque_up->Append(type.m_opaque_sp); } SBType SBTypeList::GetTypeAtIndex(uint32_t index) { - if (m_opaque_ap) - return SBType(m_opaque_ap->GetTypeAtIndex(index)); - return SBType(); + LLDB_RECORD_METHOD(lldb::SBType, SBTypeList, GetTypeAtIndex, (uint32_t), + index); + + if (m_opaque_up) + return LLDB_RECORD_RESULT(SBType(m_opaque_up->GetTypeAtIndex(index))); + return LLDB_RECORD_RESULT(SBType()); } -uint32_t SBTypeList::GetSize() { return m_opaque_ap->GetSize(); } +uint32_t SBTypeList::GetSize() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeList, GetSize); + + return m_opaque_up->GetSize(); +} SBTypeList::~SBTypeList() {} -SBTypeMember::SBTypeMember() : m_opaque_ap() {} +SBTypeMember::SBTypeMember() : m_opaque_up() { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeMember); +} SBTypeMember::~SBTypeMember() {} -SBTypeMember::SBTypeMember(const SBTypeMember &rhs) : m_opaque_ap() { +SBTypeMember::SBTypeMember(const SBTypeMember &rhs) : m_opaque_up() { + LLDB_RECORD_CONSTRUCTOR(SBTypeMember, (const lldb::SBTypeMember &), rhs); + if (this != &rhs) { if (rhs.IsValid()) - m_opaque_ap.reset(new TypeMemberImpl(rhs.ref())); + m_opaque_up.reset(new TypeMemberImpl(rhs.ref())); } } lldb::SBTypeMember &SBTypeMember::operator=(const lldb::SBTypeMember &rhs) { + LLDB_RECORD_METHOD(lldb::SBTypeMember &, + SBTypeMember, operator=,(const lldb::SBTypeMember &), rhs); + if (this != &rhs) { if (rhs.IsValid()) - m_opaque_ap.reset(new TypeMemberImpl(rhs.ref())); + m_opaque_up.reset(new TypeMemberImpl(rhs.ref())); } - return *this; + return LLDB_RECORD_RESULT(*this); } -bool SBTypeMember::IsValid() const { return m_opaque_ap.get(); } +bool SBTypeMember::IsValid() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeMember, IsValid); + return this->operator bool(); +} +SBTypeMember::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeMember, operator bool); + + return m_opaque_up.get(); +} const char *SBTypeMember::GetName() { - if (m_opaque_ap) - return m_opaque_ap->GetName().GetCString(); - return NULL; + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTypeMember, GetName); + + if (m_opaque_up) + return m_opaque_up->GetName().GetCString(); + return nullptr; } SBType SBTypeMember::GetType() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBTypeMember, GetType); + SBType sb_type; - if (m_opaque_ap) { - sb_type.SetSP(m_opaque_ap->GetTypeImpl()); + if (m_opaque_up) { + sb_type.SetSP(m_opaque_up->GetTypeImpl()); } - return sb_type; + return LLDB_RECORD_RESULT(sb_type); } uint64_t SBTypeMember::GetOffsetInBytes() { - if (m_opaque_ap) - return m_opaque_ap->GetBitOffset() / 8u; + LLDB_RECORD_METHOD_NO_ARGS(uint64_t, SBTypeMember, GetOffsetInBytes); + + if (m_opaque_up) + return m_opaque_up->GetBitOffset() / 8u; return 0; } uint64_t SBTypeMember::GetOffsetInBits() { - if (m_opaque_ap) - return m_opaque_ap->GetBitOffset(); + LLDB_RECORD_METHOD_NO_ARGS(uint64_t, SBTypeMember, GetOffsetInBits); + + if (m_opaque_up) + return m_opaque_up->GetBitOffset(); return 0; } bool SBTypeMember::IsBitfield() { - if (m_opaque_ap) - return m_opaque_ap->GetIsBitfield(); + LLDB_RECORD_METHOD_NO_ARGS(bool, SBTypeMember, IsBitfield); + + if (m_opaque_up) + return m_opaque_up->GetIsBitfield(); return false; } uint32_t SBTypeMember::GetBitfieldSizeInBits() { - if (m_opaque_ap) - return m_opaque_ap->GetBitfieldBitSize(); + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeMember, GetBitfieldSizeInBits); + + if (m_opaque_up) + return m_opaque_up->GetBitfieldBitSize(); return 0; } bool SBTypeMember::GetDescription(lldb::SBStream &description, lldb::DescriptionLevel description_level) { + LLDB_RECORD_METHOD(bool, SBTypeMember, GetDescription, + (lldb::SBStream &, lldb::DescriptionLevel), description, + description_level); + Stream &strm = description.ref(); - if (m_opaque_ap) { - const uint32_t bit_offset = m_opaque_ap->GetBitOffset(); + if (m_opaque_up) { + const uint32_t bit_offset = m_opaque_up->GetBitOffset(); const uint32_t byte_offset = bit_offset / 8u; const uint32_t byte_bit_offset = bit_offset % 8u; - const char *name = m_opaque_ap->GetName().GetCString(); + const char *name = m_opaque_up->GetName().GetCString(); if (byte_bit_offset) strm.Printf("+%u + %u bits: (", byte_offset, byte_bit_offset); else strm.Printf("+%u: (", byte_offset); - TypeImplSP type_impl_sp(m_opaque_ap->GetTypeImpl()); + TypeImplSP type_impl_sp(m_opaque_up->GetTypeImpl()); if (type_impl_sp) type_impl_sp->GetDescription(strm, description_level); strm.Printf(") %s", name); - if (m_opaque_ap->GetIsBitfield()) { - const uint32_t bitfield_bit_size = m_opaque_ap->GetBitfieldBitSize(); + if (m_opaque_up->GetIsBitfield()) { + const uint32_t bitfield_bit_size = m_opaque_up->GetBitfieldBitSize(); strm.Printf(" : %u", bitfield_bit_size); } } else { @@ -568,40 +739,63 @@ bool SBTypeMember::GetDescription(lldb::SBStream &description, } void SBTypeMember::reset(TypeMemberImpl *type_member_impl) { - m_opaque_ap.reset(type_member_impl); + m_opaque_up.reset(type_member_impl); } TypeMemberImpl &SBTypeMember::ref() { - if (m_opaque_ap == NULL) - m_opaque_ap.reset(new TypeMemberImpl()); - return *m_opaque_ap; + if (m_opaque_up == nullptr) + m_opaque_up.reset(new TypeMemberImpl()); + return *m_opaque_up; } -const TypeMemberImpl &SBTypeMember::ref() const { return *m_opaque_ap; } +const TypeMemberImpl &SBTypeMember::ref() const { return *m_opaque_up; } -SBTypeMemberFunction::SBTypeMemberFunction() : m_opaque_sp() {} +SBTypeMemberFunction::SBTypeMemberFunction() : m_opaque_sp() { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeMemberFunction); +} SBTypeMemberFunction::~SBTypeMemberFunction() {} SBTypeMemberFunction::SBTypeMemberFunction(const SBTypeMemberFunction &rhs) - : m_opaque_sp(rhs.m_opaque_sp) {} + : m_opaque_sp(rhs.m_opaque_sp) { + LLDB_RECORD_CONSTRUCTOR(SBTypeMemberFunction, + (const lldb::SBTypeMemberFunction &), rhs); +} lldb::SBTypeMemberFunction &SBTypeMemberFunction:: operator=(const lldb::SBTypeMemberFunction &rhs) { + LLDB_RECORD_METHOD( + lldb::SBTypeMemberFunction &, + SBTypeMemberFunction, operator=,(const lldb::SBTypeMemberFunction &), + rhs); + if (this != &rhs) m_opaque_sp = rhs.m_opaque_sp; - return *this; + return LLDB_RECORD_RESULT(*this); } -bool SBTypeMemberFunction::IsValid() const { return m_opaque_sp.get(); } +bool SBTypeMemberFunction::IsValid() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeMemberFunction, IsValid); + return this->operator bool(); +} +SBTypeMemberFunction::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeMemberFunction, operator bool); + + return m_opaque_sp.get(); +} const char *SBTypeMemberFunction::GetName() { + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTypeMemberFunction, GetName); + if (m_opaque_sp) return m_opaque_sp->GetName().GetCString(); - return NULL; + return nullptr; } const char *SBTypeMemberFunction::GetDemangledName() { + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTypeMemberFunction, + GetDemangledName); + if (m_opaque_sp) { ConstString mangled_str = m_opaque_sp->GetMangledName(); if (mangled_str) { @@ -609,47 +803,63 @@ const char *SBTypeMemberFunction::GetDemangledName() { return mangled.GetDemangledName(mangled.GuessLanguage()).GetCString(); } } - return NULL; + return nullptr; } const char *SBTypeMemberFunction::GetMangledName() { + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTypeMemberFunction, + GetMangledName); + if (m_opaque_sp) return m_opaque_sp->GetMangledName().GetCString(); - return NULL; + return nullptr; } SBType SBTypeMemberFunction::GetType() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBTypeMemberFunction, GetType); + SBType sb_type; if (m_opaque_sp) { sb_type.SetSP(lldb::TypeImplSP(new TypeImpl(m_opaque_sp->GetType()))); } - return sb_type; + return LLDB_RECORD_RESULT(sb_type); } lldb::SBType SBTypeMemberFunction::GetReturnType() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBTypeMemberFunction, GetReturnType); + SBType sb_type; if (m_opaque_sp) { sb_type.SetSP(lldb::TypeImplSP(new TypeImpl(m_opaque_sp->GetReturnType()))); } - return sb_type; + return LLDB_RECORD_RESULT(sb_type); } uint32_t SBTypeMemberFunction::GetNumberOfArguments() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeMemberFunction, + GetNumberOfArguments); + if (m_opaque_sp) return m_opaque_sp->GetNumArguments(); return 0; } lldb::SBType SBTypeMemberFunction::GetArgumentTypeAtIndex(uint32_t i) { + LLDB_RECORD_METHOD(lldb::SBType, SBTypeMemberFunction, GetArgumentTypeAtIndex, + (uint32_t), i); + SBType sb_type; if (m_opaque_sp) { sb_type.SetSP( lldb::TypeImplSP(new TypeImpl(m_opaque_sp->GetArgumentAtIndex(i)))); } - return sb_type; + return LLDB_RECORD_RESULT(sb_type); } lldb::MemberFunctionKind SBTypeMemberFunction::GetKind() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::MemberFunctionKind, SBTypeMemberFunction, + GetKind); + if (m_opaque_sp) return m_opaque_sp->GetKind(); return lldb::eMemberFunctionKindUnknown; @@ -657,6 +867,10 @@ lldb::MemberFunctionKind SBTypeMemberFunction::GetKind() { bool SBTypeMemberFunction::GetDescription( lldb::SBStream &description, lldb::DescriptionLevel description_level) { + LLDB_RECORD_METHOD(bool, SBTypeMemberFunction, GetDescription, + (lldb::SBStream &, lldb::DescriptionLevel), description, + description_level); + Stream &strm = description.ref(); if (m_opaque_sp) @@ -671,10 +885,124 @@ void SBTypeMemberFunction::reset(TypeMemberFunctionImpl *type_member_impl) { TypeMemberFunctionImpl &SBTypeMemberFunction::ref() { if (!m_opaque_sp) - m_opaque_sp.reset(new TypeMemberFunctionImpl()); + m_opaque_sp = std::make_shared<TypeMemberFunctionImpl>(); return *m_opaque_sp.get(); } const TypeMemberFunctionImpl &SBTypeMemberFunction::ref() const { return *m_opaque_sp.get(); } + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBType>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBType, ()); + LLDB_REGISTER_CONSTRUCTOR(SBType, (const lldb::SBType &)); + LLDB_REGISTER_METHOD(bool, SBType, operator==,(lldb::SBType &)); + LLDB_REGISTER_METHOD(bool, SBType, operator!=,(lldb::SBType &)); + LLDB_REGISTER_METHOD(lldb::SBType &, + SBType, operator=,(const lldb::SBType &)); + LLDB_REGISTER_METHOD_CONST(bool, SBType, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBType, operator bool, ()); + LLDB_REGISTER_METHOD(uint64_t, SBType, GetByteSize, ()); + LLDB_REGISTER_METHOD(bool, SBType, IsPointerType, ()); + LLDB_REGISTER_METHOD(bool, SBType, IsArrayType, ()); + LLDB_REGISTER_METHOD(bool, SBType, IsVectorType, ()); + LLDB_REGISTER_METHOD(bool, SBType, IsReferenceType, ()); + LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetPointerType, ()); + LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetPointeeType, ()); + LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetReferenceType, ()); + LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetTypedefedType, ()); + LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetDereferencedType, ()); + LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetArrayElementType, ()); + LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetArrayType, (uint64_t)); + LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetVectorElementType, ()); + LLDB_REGISTER_METHOD(bool, SBType, IsFunctionType, ()); + LLDB_REGISTER_METHOD(bool, SBType, IsPolymorphicClass, ()); + LLDB_REGISTER_METHOD(bool, SBType, IsTypedefType, ()); + LLDB_REGISTER_METHOD(bool, SBType, IsAnonymousType, ()); + LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetFunctionReturnType, ()); + LLDB_REGISTER_METHOD(lldb::SBTypeList, SBType, GetFunctionArgumentTypes, + ()); + LLDB_REGISTER_METHOD(uint32_t, SBType, GetNumberOfMemberFunctions, ()); + LLDB_REGISTER_METHOD(lldb::SBTypeMemberFunction, SBType, + GetMemberFunctionAtIndex, (uint32_t)); + LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetUnqualifiedType, ()); + LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetCanonicalType, ()); + LLDB_REGISTER_METHOD(lldb::BasicType, SBType, GetBasicType, ()); + LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetBasicType, (lldb::BasicType)); + LLDB_REGISTER_METHOD(uint32_t, SBType, GetNumberOfDirectBaseClasses, ()); + LLDB_REGISTER_METHOD(uint32_t, SBType, GetNumberOfVirtualBaseClasses, ()); + LLDB_REGISTER_METHOD(uint32_t, SBType, GetNumberOfFields, ()); + LLDB_REGISTER_METHOD(bool, SBType, GetDescription, + (lldb::SBStream &, lldb::DescriptionLevel)); + LLDB_REGISTER_METHOD(lldb::SBTypeMember, SBType, GetDirectBaseClassAtIndex, + (uint32_t)); + LLDB_REGISTER_METHOD(lldb::SBTypeMember, SBType, GetVirtualBaseClassAtIndex, + (uint32_t)); + LLDB_REGISTER_METHOD(lldb::SBTypeEnumMemberList, SBType, GetEnumMembers, + ()); + LLDB_REGISTER_METHOD(lldb::SBTypeMember, SBType, GetFieldAtIndex, + (uint32_t)); + LLDB_REGISTER_METHOD(bool, SBType, IsTypeComplete, ()); + LLDB_REGISTER_METHOD(uint32_t, SBType, GetTypeFlags, ()); + LLDB_REGISTER_METHOD(const char *, SBType, GetName, ()); + LLDB_REGISTER_METHOD(const char *, SBType, GetDisplayTypeName, ()); + LLDB_REGISTER_METHOD(lldb::TypeClass, SBType, GetTypeClass, ()); + LLDB_REGISTER_METHOD(uint32_t, SBType, GetNumberOfTemplateArguments, ()); + LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetTemplateArgumentType, + (uint32_t)); + LLDB_REGISTER_METHOD(lldb::TemplateArgumentKind, SBType, + GetTemplateArgumentKind, (uint32_t)); + LLDB_REGISTER_CONSTRUCTOR(SBTypeList, ()); + LLDB_REGISTER_CONSTRUCTOR(SBTypeList, (const lldb::SBTypeList &)); + LLDB_REGISTER_METHOD(bool, SBTypeList, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBTypeList, operator bool, ()); + LLDB_REGISTER_METHOD(lldb::SBTypeList &, + SBTypeList, operator=,(const lldb::SBTypeList &)); + LLDB_REGISTER_METHOD(void, SBTypeList, Append, (lldb::SBType)); + LLDB_REGISTER_METHOD(lldb::SBType, SBTypeList, GetTypeAtIndex, (uint32_t)); + LLDB_REGISTER_METHOD(uint32_t, SBTypeList, GetSize, ()); + LLDB_REGISTER_CONSTRUCTOR(SBTypeMember, ()); + LLDB_REGISTER_CONSTRUCTOR(SBTypeMember, (const lldb::SBTypeMember &)); + LLDB_REGISTER_METHOD(lldb::SBTypeMember &, + SBTypeMember, operator=,(const lldb::SBTypeMember &)); + LLDB_REGISTER_METHOD_CONST(bool, SBTypeMember, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBTypeMember, operator bool, ()); + LLDB_REGISTER_METHOD(const char *, SBTypeMember, GetName, ()); + LLDB_REGISTER_METHOD(lldb::SBType, SBTypeMember, GetType, ()); + LLDB_REGISTER_METHOD(uint64_t, SBTypeMember, GetOffsetInBytes, ()); + LLDB_REGISTER_METHOD(uint64_t, SBTypeMember, GetOffsetInBits, ()); + LLDB_REGISTER_METHOD(bool, SBTypeMember, IsBitfield, ()); + LLDB_REGISTER_METHOD(uint32_t, SBTypeMember, GetBitfieldSizeInBits, ()); + LLDB_REGISTER_METHOD(bool, SBTypeMember, GetDescription, + (lldb::SBStream &, lldb::DescriptionLevel)); + LLDB_REGISTER_CONSTRUCTOR(SBTypeMemberFunction, ()); + LLDB_REGISTER_CONSTRUCTOR(SBTypeMemberFunction, + (const lldb::SBTypeMemberFunction &)); + LLDB_REGISTER_METHOD( + lldb::SBTypeMemberFunction &, + SBTypeMemberFunction, operator=,(const lldb::SBTypeMemberFunction &)); + LLDB_REGISTER_METHOD_CONST(bool, SBTypeMemberFunction, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBTypeMemberFunction, operator bool, ()); + LLDB_REGISTER_METHOD(const char *, SBTypeMemberFunction, GetName, ()); + LLDB_REGISTER_METHOD(const char *, SBTypeMemberFunction, GetDemangledName, + ()); + LLDB_REGISTER_METHOD(const char *, SBTypeMemberFunction, GetMangledName, + ()); + LLDB_REGISTER_METHOD(lldb::SBType, SBTypeMemberFunction, GetType, ()); + LLDB_REGISTER_METHOD(lldb::SBType, SBTypeMemberFunction, GetReturnType, ()); + LLDB_REGISTER_METHOD(uint32_t, SBTypeMemberFunction, GetNumberOfArguments, + ()); + LLDB_REGISTER_METHOD(lldb::SBType, SBTypeMemberFunction, + GetArgumentTypeAtIndex, (uint32_t)); + LLDB_REGISTER_METHOD(lldb::MemberFunctionKind, SBTypeMemberFunction, + GetKind, ()); + LLDB_REGISTER_METHOD(bool, SBTypeMemberFunction, GetDescription, + (lldb::SBStream &, lldb::DescriptionLevel)); +} + +} +} diff --git a/source/API/SBTypeCategory.cpp b/source/API/SBTypeCategory.cpp index 7c2a37e7cf215..43d5a3ab140fb 100644 --- a/source/API/SBTypeCategory.cpp +++ b/source/API/SBTypeCategory.cpp @@ -1,14 +1,14 @@ //===-- SBTypeCategory.cpp ----------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBTypeCategory.h" +#include "SBReproducerPrivate.h" #include "lldb/API/SBStream.h" #include "lldb/API/SBTypeFilter.h" @@ -27,26 +27,42 @@ using namespace lldb_private; typedef std::pair<lldb::TypeCategoryImplSP, user_id_t> ImplType; -SBTypeCategory::SBTypeCategory() : m_opaque_sp() {} +SBTypeCategory::SBTypeCategory() : m_opaque_sp() { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeCategory); +} SBTypeCategory::SBTypeCategory(const char *name) : m_opaque_sp() { DataVisualization::Categories::GetCategory(ConstString(name), m_opaque_sp); } SBTypeCategory::SBTypeCategory(const lldb::SBTypeCategory &rhs) - : m_opaque_sp(rhs.m_opaque_sp) {} + : m_opaque_sp(rhs.m_opaque_sp) { + LLDB_RECORD_CONSTRUCTOR(SBTypeCategory, (const lldb::SBTypeCategory &), rhs); +} SBTypeCategory::~SBTypeCategory() {} -bool SBTypeCategory::IsValid() const { return (m_opaque_sp.get() != NULL); } +bool SBTypeCategory::IsValid() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeCategory, IsValid); + return this->operator bool(); +} +SBTypeCategory::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeCategory, operator bool); + + return (m_opaque_sp.get() != nullptr); +} bool SBTypeCategory::GetEnabled() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBTypeCategory, GetEnabled); + if (!IsValid()) return false; return m_opaque_sp->IsEnabled(); } void SBTypeCategory::SetEnabled(bool enabled) { + LLDB_RECORD_METHOD(void, SBTypeCategory, SetEnabled, (bool), enabled); + if (!IsValid()) return; if (enabled) @@ -56,29 +72,41 @@ void SBTypeCategory::SetEnabled(bool enabled) { } const char *SBTypeCategory::GetName() { + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTypeCategory, GetName); + if (!IsValid()) - return NULL; + return nullptr; return m_opaque_sp->GetName(); } lldb::LanguageType SBTypeCategory::GetLanguageAtIndex(uint32_t idx) { + LLDB_RECORD_METHOD(lldb::LanguageType, SBTypeCategory, GetLanguageAtIndex, + (uint32_t), idx); + if (IsValid()) return m_opaque_sp->GetLanguageAtIndex(idx); return lldb::eLanguageTypeUnknown; } uint32_t SBTypeCategory::GetNumLanguages() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeCategory, GetNumLanguages); + if (IsValid()) return m_opaque_sp->GetNumLanguages(); return 0; } void SBTypeCategory::AddLanguage(lldb::LanguageType language) { + LLDB_RECORD_METHOD(void, SBTypeCategory, AddLanguage, (lldb::LanguageType), + language); + if (IsValid()) m_opaque_sp->AddLanguage(language); } uint32_t SBTypeCategory::GetNumFormats() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeCategory, GetNumFormats); + if (!IsValid()) return 0; @@ -87,6 +115,8 @@ uint32_t SBTypeCategory::GetNumFormats() { } uint32_t SBTypeCategory::GetNumSummaries() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeCategory, GetNumSummaries); + if (!IsValid()) return 0; return m_opaque_sp->GetTypeSummariesContainer()->GetCount() + @@ -94,61 +124,77 @@ uint32_t SBTypeCategory::GetNumSummaries() { } uint32_t SBTypeCategory::GetNumFilters() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeCategory, GetNumFilters); + if (!IsValid()) return 0; return m_opaque_sp->GetTypeFiltersContainer()->GetCount() + m_opaque_sp->GetRegexTypeFiltersContainer()->GetCount(); } -#ifndef LLDB_DISABLE_PYTHON uint32_t SBTypeCategory::GetNumSynthetics() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeCategory, GetNumSynthetics); + if (!IsValid()) return 0; return m_opaque_sp->GetTypeSyntheticsContainer()->GetCount() + m_opaque_sp->GetRegexTypeSyntheticsContainer()->GetCount(); } -#endif lldb::SBTypeNameSpecifier SBTypeCategory::GetTypeNameSpecifierForFilterAtIndex(uint32_t index) { + LLDB_RECORD_METHOD(lldb::SBTypeNameSpecifier, SBTypeCategory, + GetTypeNameSpecifierForFilterAtIndex, (uint32_t), index); + if (!IsValid()) - return SBTypeNameSpecifier(); - return SBTypeNameSpecifier( - m_opaque_sp->GetTypeNameSpecifierForFilterAtIndex(index)); + return LLDB_RECORD_RESULT(SBTypeNameSpecifier()); + return LLDB_RECORD_RESULT(SBTypeNameSpecifier( + m_opaque_sp->GetTypeNameSpecifierForFilterAtIndex(index))); } lldb::SBTypeNameSpecifier SBTypeCategory::GetTypeNameSpecifierForFormatAtIndex(uint32_t index) { + LLDB_RECORD_METHOD(lldb::SBTypeNameSpecifier, SBTypeCategory, + GetTypeNameSpecifierForFormatAtIndex, (uint32_t), index); + if (!IsValid()) - return SBTypeNameSpecifier(); - return SBTypeNameSpecifier( - m_opaque_sp->GetTypeNameSpecifierForFormatAtIndex(index)); + return LLDB_RECORD_RESULT(SBTypeNameSpecifier()); + return LLDB_RECORD_RESULT(SBTypeNameSpecifier( + m_opaque_sp->GetTypeNameSpecifierForFormatAtIndex(index))); } lldb::SBTypeNameSpecifier SBTypeCategory::GetTypeNameSpecifierForSummaryAtIndex(uint32_t index) { + LLDB_RECORD_METHOD(lldb::SBTypeNameSpecifier, SBTypeCategory, + GetTypeNameSpecifierForSummaryAtIndex, (uint32_t), index); + if (!IsValid()) - return SBTypeNameSpecifier(); - return SBTypeNameSpecifier( - m_opaque_sp->GetTypeNameSpecifierForSummaryAtIndex(index)); + return LLDB_RECORD_RESULT(SBTypeNameSpecifier()); + return LLDB_RECORD_RESULT(SBTypeNameSpecifier( + m_opaque_sp->GetTypeNameSpecifierForSummaryAtIndex(index))); } -#ifndef LLDB_DISABLE_PYTHON lldb::SBTypeNameSpecifier SBTypeCategory::GetTypeNameSpecifierForSyntheticAtIndex(uint32_t index) { + LLDB_RECORD_METHOD(lldb::SBTypeNameSpecifier, SBTypeCategory, + GetTypeNameSpecifierForSyntheticAtIndex, (uint32_t), + index); + if (!IsValid()) - return SBTypeNameSpecifier(); - return SBTypeNameSpecifier( - m_opaque_sp->GetTypeNameSpecifierForSyntheticAtIndex(index)); + return LLDB_RECORD_RESULT(SBTypeNameSpecifier()); + return LLDB_RECORD_RESULT(SBTypeNameSpecifier( + m_opaque_sp->GetTypeNameSpecifierForSyntheticAtIndex(index))); } -#endif SBTypeFilter SBTypeCategory::GetFilterForType(SBTypeNameSpecifier spec) { + LLDB_RECORD_METHOD(lldb::SBTypeFilter, SBTypeCategory, GetFilterForType, + (lldb::SBTypeNameSpecifier), spec); + if (!IsValid()) - return SBTypeFilter(); + return LLDB_RECORD_RESULT(SBTypeFilter()); if (!spec.IsValid()) - return SBTypeFilter(); + return LLDB_RECORD_RESULT(SBTypeFilter()); lldb::TypeFilterImplSP children_sp; @@ -160,19 +206,22 @@ SBTypeFilter SBTypeCategory::GetFilterForType(SBTypeNameSpecifier spec) { ConstString(spec.GetName()), children_sp); if (!children_sp) - return lldb::SBTypeFilter(); + return LLDB_RECORD_RESULT(lldb::SBTypeFilter()); TypeFilterImplSP filter_sp = std::static_pointer_cast<TypeFilterImpl>(children_sp); - return lldb::SBTypeFilter(filter_sp); + return LLDB_RECORD_RESULT(lldb::SBTypeFilter(filter_sp)); } SBTypeFormat SBTypeCategory::GetFormatForType(SBTypeNameSpecifier spec) { + LLDB_RECORD_METHOD(lldb::SBTypeFormat, SBTypeCategory, GetFormatForType, + (lldb::SBTypeNameSpecifier), spec); + if (!IsValid()) - return SBTypeFormat(); + return LLDB_RECORD_RESULT(SBTypeFormat()); if (!spec.IsValid()) - return SBTypeFormat(); + return LLDB_RECORD_RESULT(SBTypeFormat()); lldb::TypeFormatImplSP format_sp; @@ -184,18 +233,20 @@ SBTypeFormat SBTypeCategory::GetFormatForType(SBTypeNameSpecifier spec) { ConstString(spec.GetName()), format_sp); if (!format_sp) - return lldb::SBTypeFormat(); + return LLDB_RECORD_RESULT(lldb::SBTypeFormat()); - return lldb::SBTypeFormat(format_sp); + return LLDB_RECORD_RESULT(lldb::SBTypeFormat(format_sp)); } -#ifndef LLDB_DISABLE_PYTHON SBTypeSummary SBTypeCategory::GetSummaryForType(SBTypeNameSpecifier spec) { + LLDB_RECORD_METHOD(lldb::SBTypeSummary, SBTypeCategory, GetSummaryForType, + (lldb::SBTypeNameSpecifier), spec); + if (!IsValid()) - return SBTypeSummary(); + return LLDB_RECORD_RESULT(SBTypeSummary()); if (!spec.IsValid()) - return SBTypeSummary(); + return LLDB_RECORD_RESULT(SBTypeSummary()); lldb::TypeSummaryImplSP summary_sp; @@ -207,19 +258,20 @@ SBTypeSummary SBTypeCategory::GetSummaryForType(SBTypeNameSpecifier spec) { ConstString(spec.GetName()), summary_sp); if (!summary_sp) - return lldb::SBTypeSummary(); + return LLDB_RECORD_RESULT(lldb::SBTypeSummary()); - return lldb::SBTypeSummary(summary_sp); + return LLDB_RECORD_RESULT(lldb::SBTypeSummary(summary_sp)); } -#endif // LLDB_DISABLE_PYTHON -#ifndef LLDB_DISABLE_PYTHON SBTypeSynthetic SBTypeCategory::GetSyntheticForType(SBTypeNameSpecifier spec) { + LLDB_RECORD_METHOD(lldb::SBTypeSynthetic, SBTypeCategory, GetSyntheticForType, + (lldb::SBTypeNameSpecifier), spec); + if (!IsValid()) - return SBTypeSynthetic(); + return LLDB_RECORD_RESULT(SBTypeSynthetic()); if (!spec.IsValid()) - return SBTypeSynthetic(); + return LLDB_RECORD_RESULT(SBTypeSynthetic()); lldb::SyntheticChildrenSP children_sp; @@ -231,65 +283,76 @@ SBTypeSynthetic SBTypeCategory::GetSyntheticForType(SBTypeNameSpecifier spec) { ConstString(spec.GetName()), children_sp); if (!children_sp) - return lldb::SBTypeSynthetic(); + return LLDB_RECORD_RESULT(lldb::SBTypeSynthetic()); ScriptedSyntheticChildrenSP synth_sp = std::static_pointer_cast<ScriptedSyntheticChildren>(children_sp); - return lldb::SBTypeSynthetic(synth_sp); + return LLDB_RECORD_RESULT(lldb::SBTypeSynthetic(synth_sp)); } -#endif -#ifndef LLDB_DISABLE_PYTHON SBTypeFilter SBTypeCategory::GetFilterAtIndex(uint32_t index) { + LLDB_RECORD_METHOD(lldb::SBTypeFilter, SBTypeCategory, GetFilterAtIndex, + (uint32_t), index); + if (!IsValid()) - return SBTypeFilter(); + return LLDB_RECORD_RESULT(SBTypeFilter()); lldb::SyntheticChildrenSP children_sp = m_opaque_sp->GetSyntheticAtIndex((index)); if (!children_sp.get()) - return lldb::SBTypeFilter(); + return LLDB_RECORD_RESULT(lldb::SBTypeFilter()); TypeFilterImplSP filter_sp = std::static_pointer_cast<TypeFilterImpl>(children_sp); - return lldb::SBTypeFilter(filter_sp); + return LLDB_RECORD_RESULT(lldb::SBTypeFilter(filter_sp)); } -#endif SBTypeFormat SBTypeCategory::GetFormatAtIndex(uint32_t index) { + LLDB_RECORD_METHOD(lldb::SBTypeFormat, SBTypeCategory, GetFormatAtIndex, + (uint32_t), index); + if (!IsValid()) - return SBTypeFormat(); - return SBTypeFormat(m_opaque_sp->GetFormatAtIndex((index))); + return LLDB_RECORD_RESULT(SBTypeFormat()); + return LLDB_RECORD_RESULT( + SBTypeFormat(m_opaque_sp->GetFormatAtIndex((index)))); } -#ifndef LLDB_DISABLE_PYTHON SBTypeSummary SBTypeCategory::GetSummaryAtIndex(uint32_t index) { + LLDB_RECORD_METHOD(lldb::SBTypeSummary, SBTypeCategory, GetSummaryAtIndex, + (uint32_t), index); + if (!IsValid()) - return SBTypeSummary(); - return SBTypeSummary(m_opaque_sp->GetSummaryAtIndex((index))); + return LLDB_RECORD_RESULT(SBTypeSummary()); + return LLDB_RECORD_RESULT( + SBTypeSummary(m_opaque_sp->GetSummaryAtIndex((index)))); } -#endif -#ifndef LLDB_DISABLE_PYTHON SBTypeSynthetic SBTypeCategory::GetSyntheticAtIndex(uint32_t index) { + LLDB_RECORD_METHOD(lldb::SBTypeSynthetic, SBTypeCategory, GetSyntheticAtIndex, + (uint32_t), index); + if (!IsValid()) - return SBTypeSynthetic(); + return LLDB_RECORD_RESULT(SBTypeSynthetic()); lldb::SyntheticChildrenSP children_sp = m_opaque_sp->GetSyntheticAtIndex((index)); if (!children_sp.get()) - return lldb::SBTypeSynthetic(); + return LLDB_RECORD_RESULT(lldb::SBTypeSynthetic()); ScriptedSyntheticChildrenSP synth_sp = std::static_pointer_cast<ScriptedSyntheticChildren>(children_sp); - return lldb::SBTypeSynthetic(synth_sp); + return LLDB_RECORD_RESULT(lldb::SBTypeSynthetic(synth_sp)); } -#endif bool SBTypeCategory::AddTypeFormat(SBTypeNameSpecifier type_name, SBTypeFormat format) { + LLDB_RECORD_METHOD(bool, SBTypeCategory, AddTypeFormat, + (lldb::SBTypeNameSpecifier, lldb::SBTypeFormat), type_name, + format); + if (!IsValid()) return false; @@ -312,6 +375,9 @@ bool SBTypeCategory::AddTypeFormat(SBTypeNameSpecifier type_name, } bool SBTypeCategory::DeleteTypeFormat(SBTypeNameSpecifier type_name) { + LLDB_RECORD_METHOD(bool, SBTypeCategory, DeleteTypeFormat, + (lldb::SBTypeNameSpecifier), type_name); + if (!IsValid()) return false; @@ -326,9 +392,12 @@ bool SBTypeCategory::DeleteTypeFormat(SBTypeNameSpecifier type_name) { ConstString(type_name.GetName())); } -#ifndef LLDB_DISABLE_PYTHON bool SBTypeCategory::AddTypeSummary(SBTypeNameSpecifier type_name, SBTypeSummary summary) { + LLDB_RECORD_METHOD(bool, SBTypeCategory, AddTypeSummary, + (lldb::SBTypeNameSpecifier, lldb::SBTypeSummary), + type_name, summary); + if (!IsValid()) return false; @@ -356,7 +425,7 @@ bool SBTypeCategory::AddTypeSummary(SBTypeNameSpecifier type_name, DebuggerSP debugger_sp = lldb_private::Debugger::GetDebuggerAtIndex(j); if (debugger_sp) { ScriptInterpreter *interpreter_ptr = - debugger_sp->GetCommandInterpreter().GetScriptInterpreter(); + debugger_sp->GetScriptInterpreter(); if (interpreter_ptr) { std::string output; if (interpreter_ptr->GenerateTypeScriptFunction(input, output, @@ -383,9 +452,11 @@ bool SBTypeCategory::AddTypeSummary(SBTypeNameSpecifier type_name, return true; } -#endif bool SBTypeCategory::DeleteTypeSummary(SBTypeNameSpecifier type_name) { + LLDB_RECORD_METHOD(bool, SBTypeCategory, DeleteTypeSummary, + (lldb::SBTypeNameSpecifier), type_name); + if (!IsValid()) return false; @@ -402,6 +473,10 @@ bool SBTypeCategory::DeleteTypeSummary(SBTypeNameSpecifier type_name) { bool SBTypeCategory::AddTypeFilter(SBTypeNameSpecifier type_name, SBTypeFilter filter) { + LLDB_RECORD_METHOD(bool, SBTypeCategory, AddTypeFilter, + (lldb::SBTypeNameSpecifier, lldb::SBTypeFilter), type_name, + filter); + if (!IsValid()) return false; @@ -424,6 +499,9 @@ bool SBTypeCategory::AddTypeFilter(SBTypeNameSpecifier type_name, } bool SBTypeCategory::DeleteTypeFilter(SBTypeNameSpecifier type_name) { + LLDB_RECORD_METHOD(bool, SBTypeCategory, DeleteTypeFilter, + (lldb::SBTypeNameSpecifier), type_name); + if (!IsValid()) return false; @@ -438,9 +516,12 @@ bool SBTypeCategory::DeleteTypeFilter(SBTypeNameSpecifier type_name) { ConstString(type_name.GetName())); } -#ifndef LLDB_DISABLE_PYTHON bool SBTypeCategory::AddTypeSynthetic(SBTypeNameSpecifier type_name, SBTypeSynthetic synth) { + LLDB_RECORD_METHOD(bool, SBTypeCategory, AddTypeSynthetic, + (lldb::SBTypeNameSpecifier, lldb::SBTypeSynthetic), + type_name, synth); + if (!IsValid()) return false; @@ -468,7 +549,7 @@ bool SBTypeCategory::AddTypeSynthetic(SBTypeNameSpecifier type_name, DebuggerSP debugger_sp = lldb_private::Debugger::GetDebuggerAtIndex(j); if (debugger_sp) { ScriptInterpreter *interpreter_ptr = - debugger_sp->GetCommandInterpreter().GetScriptInterpreter(); + debugger_sp->GetScriptInterpreter(); if (interpreter_ptr) { std::string output; if (interpreter_ptr->GenerateTypeSynthClass(input, output, @@ -497,6 +578,9 @@ bool SBTypeCategory::AddTypeSynthetic(SBTypeNameSpecifier type_name, } bool SBTypeCategory::DeleteTypeSynthetic(SBTypeNameSpecifier type_name) { + LLDB_RECORD_METHOD(bool, SBTypeCategory, DeleteTypeSynthetic, + (lldb::SBTypeNameSpecifier), type_name); + if (!IsValid()) return false; @@ -510,10 +594,13 @@ bool SBTypeCategory::DeleteTypeSynthetic(SBTypeNameSpecifier type_name) { return m_opaque_sp->GetTypeSyntheticsContainer()->Delete( ConstString(type_name.GetName())); } -#endif // LLDB_DISABLE_PYTHON bool SBTypeCategory::GetDescription(lldb::SBStream &description, lldb::DescriptionLevel description_level) { + LLDB_RECORD_METHOD(bool, SBTypeCategory, GetDescription, + (lldb::SBStream &, lldb::DescriptionLevel), description, + description_level); + if (!IsValid()) return false; description.Printf("Category name: %s\n", GetName()); @@ -522,13 +609,20 @@ bool SBTypeCategory::GetDescription(lldb::SBStream &description, lldb::SBTypeCategory &SBTypeCategory:: operator=(const lldb::SBTypeCategory &rhs) { + LLDB_RECORD_METHOD(lldb::SBTypeCategory &, + SBTypeCategory, operator=,(const lldb::SBTypeCategory &), + rhs); + if (this != &rhs) { m_opaque_sp = rhs.m_opaque_sp; } - return *this; + return LLDB_RECORD_RESULT(*this); } bool SBTypeCategory::operator==(lldb::SBTypeCategory &rhs) { + LLDB_RECORD_METHOD(bool, SBTypeCategory, operator==,(lldb::SBTypeCategory &), + rhs); + if (!IsValid()) return !rhs.IsValid(); @@ -536,6 +630,9 @@ bool SBTypeCategory::operator==(lldb::SBTypeCategory &rhs) { } bool SBTypeCategory::operator!=(lldb::SBTypeCategory &rhs) { + LLDB_RECORD_METHOD(bool, SBTypeCategory, operator!=,(lldb::SBTypeCategory &), + rhs); + if (!IsValid()) return rhs.IsValid(); @@ -563,3 +660,78 @@ bool SBTypeCategory::IsDefaultCategory() { return (strcmp(m_opaque_sp->GetName(), "default") == 0); } + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBTypeCategory>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBTypeCategory, ()); + LLDB_REGISTER_CONSTRUCTOR(SBTypeCategory, (const lldb::SBTypeCategory &)); + LLDB_REGISTER_METHOD_CONST(bool, SBTypeCategory, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBTypeCategory, operator bool, ()); + LLDB_REGISTER_METHOD(bool, SBTypeCategory, GetEnabled, ()); + LLDB_REGISTER_METHOD(void, SBTypeCategory, SetEnabled, (bool)); + LLDB_REGISTER_METHOD(const char *, SBTypeCategory, GetName, ()); + LLDB_REGISTER_METHOD(lldb::LanguageType, SBTypeCategory, GetLanguageAtIndex, + (uint32_t)); + LLDB_REGISTER_METHOD(uint32_t, SBTypeCategory, GetNumLanguages, ()); + LLDB_REGISTER_METHOD(void, SBTypeCategory, AddLanguage, + (lldb::LanguageType)); + LLDB_REGISTER_METHOD(uint32_t, SBTypeCategory, GetNumFormats, ()); + LLDB_REGISTER_METHOD(uint32_t, SBTypeCategory, GetNumSummaries, ()); + LLDB_REGISTER_METHOD(uint32_t, SBTypeCategory, GetNumFilters, ()); + LLDB_REGISTER_METHOD(uint32_t, SBTypeCategory, GetNumSynthetics, ()); + LLDB_REGISTER_METHOD(lldb::SBTypeNameSpecifier, SBTypeCategory, + GetTypeNameSpecifierForSyntheticAtIndex, (uint32_t)); + LLDB_REGISTER_METHOD(lldb::SBTypeSummary, SBTypeCategory, GetSummaryForType, + (lldb::SBTypeNameSpecifier)); + LLDB_REGISTER_METHOD(lldb::SBTypeSynthetic, SBTypeCategory, + GetSyntheticForType, (lldb::SBTypeNameSpecifier)); + LLDB_REGISTER_METHOD(lldb::SBTypeFilter, SBTypeCategory, GetFilterAtIndex, + (uint32_t)); + LLDB_REGISTER_METHOD(lldb::SBTypeSummary, SBTypeCategory, GetSummaryAtIndex, + (uint32_t)); + LLDB_REGISTER_METHOD(lldb::SBTypeSynthetic, SBTypeCategory, + GetSyntheticAtIndex, (uint32_t)); + LLDB_REGISTER_METHOD(bool, SBTypeCategory, AddTypeSummary, + (lldb::SBTypeNameSpecifier, lldb::SBTypeSummary)); + LLDB_REGISTER_METHOD(bool, SBTypeCategory, AddTypeSynthetic, + (lldb::SBTypeNameSpecifier, lldb::SBTypeSynthetic)); + LLDB_REGISTER_METHOD(bool, SBTypeCategory, DeleteTypeSynthetic, + (lldb::SBTypeNameSpecifier)); + LLDB_REGISTER_METHOD(lldb::SBTypeNameSpecifier, SBTypeCategory, + GetTypeNameSpecifierForFilterAtIndex, (uint32_t)); + LLDB_REGISTER_METHOD(lldb::SBTypeNameSpecifier, SBTypeCategory, + GetTypeNameSpecifierForFormatAtIndex, (uint32_t)); + LLDB_REGISTER_METHOD(lldb::SBTypeNameSpecifier, SBTypeCategory, + GetTypeNameSpecifierForSummaryAtIndex, (uint32_t)); + LLDB_REGISTER_METHOD(lldb::SBTypeFilter, SBTypeCategory, GetFilterForType, + (lldb::SBTypeNameSpecifier)); + LLDB_REGISTER_METHOD(lldb::SBTypeFormat, SBTypeCategory, GetFormatForType, + (lldb::SBTypeNameSpecifier)); + LLDB_REGISTER_METHOD(lldb::SBTypeFormat, SBTypeCategory, GetFormatAtIndex, + (uint32_t)); + LLDB_REGISTER_METHOD(bool, SBTypeCategory, AddTypeFormat, + (lldb::SBTypeNameSpecifier, lldb::SBTypeFormat)); + LLDB_REGISTER_METHOD(bool, SBTypeCategory, DeleteTypeFormat, + (lldb::SBTypeNameSpecifier)); + LLDB_REGISTER_METHOD(bool, SBTypeCategory, DeleteTypeSummary, + (lldb::SBTypeNameSpecifier)); + LLDB_REGISTER_METHOD(bool, SBTypeCategory, AddTypeFilter, + (lldb::SBTypeNameSpecifier, lldb::SBTypeFilter)); + LLDB_REGISTER_METHOD(bool, SBTypeCategory, DeleteTypeFilter, + (lldb::SBTypeNameSpecifier)); + LLDB_REGISTER_METHOD(bool, SBTypeCategory, GetDescription, + (lldb::SBStream &, lldb::DescriptionLevel)); + LLDB_REGISTER_METHOD( + lldb::SBTypeCategory &, + SBTypeCategory, operator=,(const lldb::SBTypeCategory &)); + LLDB_REGISTER_METHOD(bool, + SBTypeCategory, operator==,(lldb::SBTypeCategory &)); + LLDB_REGISTER_METHOD(bool, + SBTypeCategory, operator!=,(lldb::SBTypeCategory &)); +} + +} +} diff --git a/source/API/SBTypeEnumMember.cpp b/source/API/SBTypeEnumMember.cpp index 87be40e8b1418..bd0755a140c33 100644 --- a/source/API/SBTypeEnumMember.cpp +++ b/source/API/SBTypeEnumMember.cpp @@ -1,13 +1,14 @@ //===-- SBTypeEnumMember.cpp ---------------------------------- -*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBTypeEnumMember.h" +#include "SBReproducerPrivate.h" +#include "Utils.h" #include "lldb/API/SBDefines.h" #include "lldb/API/SBStream.h" #include "lldb/API/SBType.h" @@ -15,58 +16,81 @@ #include "lldb/Symbol/Type.h" #include "lldb/Utility/Stream.h" +#include <memory> + using namespace lldb; using namespace lldb_private; -SBTypeEnumMember::SBTypeEnumMember() : m_opaque_sp() {} +SBTypeEnumMember::SBTypeEnumMember() : m_opaque_sp() { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeEnumMember); +} SBTypeEnumMember::~SBTypeEnumMember() {} + SBTypeEnumMember::SBTypeEnumMember( const lldb::TypeEnumMemberImplSP &enum_member_sp) : m_opaque_sp(enum_member_sp) {} SBTypeEnumMember::SBTypeEnumMember(const SBTypeEnumMember &rhs) : m_opaque_sp() { - if (this != &rhs) { - if (rhs.IsValid()) - m_opaque_sp.reset(new TypeEnumMemberImpl(rhs.ref())); - } + LLDB_RECORD_CONSTRUCTOR(SBTypeEnumMember, (const lldb::SBTypeEnumMember &), + rhs); + + m_opaque_sp = clone(rhs.m_opaque_sp); } SBTypeEnumMember &SBTypeEnumMember::operator=(const SBTypeEnumMember &rhs) { - if (this != &rhs) { - if (rhs.IsValid()) - m_opaque_sp.reset(new TypeEnumMemberImpl(rhs.ref())); - } - return *this; + LLDB_RECORD_METHOD( + SBTypeEnumMember &, + SBTypeEnumMember, operator=,(const lldb::SBTypeEnumMember &), rhs); + + if (this != &rhs) + m_opaque_sp = clone(rhs.m_opaque_sp); + return LLDB_RECORD_RESULT(*this); +} + +bool SBTypeEnumMember::IsValid() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeEnumMember, IsValid); + return this->operator bool(); } +SBTypeEnumMember::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeEnumMember, operator bool); -bool SBTypeEnumMember::IsValid() const { return m_opaque_sp.get(); } + return m_opaque_sp.get(); +} const char *SBTypeEnumMember::GetName() { + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTypeEnumMember, GetName); + if (m_opaque_sp.get()) return m_opaque_sp->GetName().GetCString(); - return NULL; + return nullptr; } int64_t SBTypeEnumMember::GetValueAsSigned() { + LLDB_RECORD_METHOD_NO_ARGS(int64_t, SBTypeEnumMember, GetValueAsSigned); + if (m_opaque_sp.get()) return m_opaque_sp->GetValueAsSigned(); return 0; } uint64_t SBTypeEnumMember::GetValueAsUnsigned() { + LLDB_RECORD_METHOD_NO_ARGS(uint64_t, SBTypeEnumMember, GetValueAsUnsigned); + if (m_opaque_sp.get()) return m_opaque_sp->GetValueAsUnsigned(); return 0; } SBType SBTypeEnumMember::GetType() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBTypeEnumMember, GetType); + SBType sb_type; if (m_opaque_sp.get()) { sb_type.SetSP(m_opaque_sp->GetIntegerType()); } - return sb_type; + return LLDB_RECORD_RESULT(sb_type); } void SBTypeEnumMember::reset(TypeEnumMemberImpl *type_member_impl) { @@ -74,8 +98,8 @@ void SBTypeEnumMember::reset(TypeEnumMemberImpl *type_member_impl) { } TypeEnumMemberImpl &SBTypeEnumMember::ref() { - if (m_opaque_sp.get() == NULL) - m_opaque_sp.reset(new TypeEnumMemberImpl()); + if (m_opaque_sp.get() == nullptr) + m_opaque_sp = std::make_shared<TypeEnumMemberImpl>(); return *m_opaque_sp.get(); } @@ -84,49 +108,82 @@ const TypeEnumMemberImpl &SBTypeEnumMember::ref() const { } SBTypeEnumMemberList::SBTypeEnumMemberList() - : m_opaque_ap(new TypeEnumMemberListImpl()) {} + : m_opaque_up(new TypeEnumMemberListImpl()) { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeEnumMemberList); +} SBTypeEnumMemberList::SBTypeEnumMemberList(const SBTypeEnumMemberList &rhs) - : m_opaque_ap(new TypeEnumMemberListImpl()) { + : m_opaque_up(new TypeEnumMemberListImpl()) { + LLDB_RECORD_CONSTRUCTOR(SBTypeEnumMemberList, + (const lldb::SBTypeEnumMemberList &), rhs); + for (uint32_t i = 0, rhs_size = const_cast<SBTypeEnumMemberList &>(rhs).GetSize(); i < rhs_size; i++) Append(const_cast<SBTypeEnumMemberList &>(rhs).GetTypeEnumMemberAtIndex(i)); } -bool SBTypeEnumMemberList::IsValid() { return (m_opaque_ap != NULL); } +bool SBTypeEnumMemberList::IsValid() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBTypeEnumMemberList, IsValid); + return this->operator bool(); +} +SBTypeEnumMemberList::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeEnumMemberList, operator bool); + + return (m_opaque_up != nullptr); +} SBTypeEnumMemberList &SBTypeEnumMemberList:: operator=(const SBTypeEnumMemberList &rhs) { + LLDB_RECORD_METHOD( + lldb::SBTypeEnumMemberList &, + SBTypeEnumMemberList, operator=,(const lldb::SBTypeEnumMemberList &), + rhs); + if (this != &rhs) { - m_opaque_ap.reset(new TypeEnumMemberListImpl()); + m_opaque_up.reset(new TypeEnumMemberListImpl()); for (uint32_t i = 0, rhs_size = const_cast<SBTypeEnumMemberList &>(rhs).GetSize(); i < rhs_size; i++) Append( const_cast<SBTypeEnumMemberList &>(rhs).GetTypeEnumMemberAtIndex(i)); } - return *this; + return LLDB_RECORD_RESULT(*this); } void SBTypeEnumMemberList::Append(SBTypeEnumMember enum_member) { + LLDB_RECORD_METHOD(void, SBTypeEnumMemberList, Append, + (lldb::SBTypeEnumMember), enum_member); + if (enum_member.IsValid()) - m_opaque_ap->Append(enum_member.m_opaque_sp); + m_opaque_up->Append(enum_member.m_opaque_sp); } SBTypeEnumMember SBTypeEnumMemberList::GetTypeEnumMemberAtIndex(uint32_t index) { - if (m_opaque_ap) - return SBTypeEnumMember(m_opaque_ap->GetTypeEnumMemberAtIndex(index)); - return SBTypeEnumMember(); + LLDB_RECORD_METHOD(lldb::SBTypeEnumMember, SBTypeEnumMemberList, + GetTypeEnumMemberAtIndex, (uint32_t), index); + + if (m_opaque_up) + return LLDB_RECORD_RESULT( + SBTypeEnumMember(m_opaque_up->GetTypeEnumMemberAtIndex(index))); + return LLDB_RECORD_RESULT(SBTypeEnumMember()); } -uint32_t SBTypeEnumMemberList::GetSize() { return m_opaque_ap->GetSize(); } +uint32_t SBTypeEnumMemberList::GetSize() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeEnumMemberList, GetSize); + + return m_opaque_up->GetSize(); +} SBTypeEnumMemberList::~SBTypeEnumMemberList() {} bool SBTypeEnumMember::GetDescription( lldb::SBStream &description, lldb::DescriptionLevel description_level) { + LLDB_RECORD_METHOD(bool, SBTypeEnumMember, GetDescription, + (lldb::SBStream &, lldb::DescriptionLevel), description, + description_level); + Stream &strm = description.ref(); if (m_opaque_sp.get()) { @@ -139,3 +196,40 @@ bool SBTypeEnumMember::GetDescription( } return true; } + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBTypeEnumMember>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBTypeEnumMember, ()); + LLDB_REGISTER_CONSTRUCTOR(SBTypeEnumMember, + (const lldb::SBTypeEnumMember &)); + LLDB_REGISTER_METHOD( + lldb::SBTypeEnumMember &, + SBTypeEnumMember, operator=,(const lldb::SBTypeEnumMember &)); + LLDB_REGISTER_METHOD_CONST(bool, SBTypeEnumMember, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBTypeEnumMember, operator bool, ()); + LLDB_REGISTER_METHOD(const char *, SBTypeEnumMember, GetName, ()); + LLDB_REGISTER_METHOD(int64_t, SBTypeEnumMember, GetValueAsSigned, ()); + LLDB_REGISTER_METHOD(uint64_t, SBTypeEnumMember, GetValueAsUnsigned, ()); + LLDB_REGISTER_METHOD(lldb::SBType, SBTypeEnumMember, GetType, ()); + LLDB_REGISTER_CONSTRUCTOR(SBTypeEnumMemberList, ()); + LLDB_REGISTER_CONSTRUCTOR(SBTypeEnumMemberList, + (const lldb::SBTypeEnumMemberList &)); + LLDB_REGISTER_METHOD(bool, SBTypeEnumMemberList, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBTypeEnumMemberList, operator bool, ()); + LLDB_REGISTER_METHOD( + lldb::SBTypeEnumMemberList &, + SBTypeEnumMemberList, operator=,(const lldb::SBTypeEnumMemberList &)); + LLDB_REGISTER_METHOD(void, SBTypeEnumMemberList, Append, + (lldb::SBTypeEnumMember)); + LLDB_REGISTER_METHOD(lldb::SBTypeEnumMember, SBTypeEnumMemberList, + GetTypeEnumMemberAtIndex, (uint32_t)); + LLDB_REGISTER_METHOD(uint32_t, SBTypeEnumMemberList, GetSize, ()); + LLDB_REGISTER_METHOD(bool, SBTypeEnumMember, GetDescription, + (lldb::SBStream &, lldb::DescriptionLevel)); +} + +} +} diff --git a/source/API/SBTypeFilter.cpp b/source/API/SBTypeFilter.cpp index 9709d2e5da101..d40301b4c1538 100644 --- a/source/API/SBTypeFilter.cpp +++ b/source/API/SBTypeFilter.cpp @@ -1,14 +1,14 @@ //===-- SBTypeFilter.cpp ------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBTypeFilter.h" +#include "SBReproducerPrivate.h" #include "lldb/API/SBStream.h" @@ -17,31 +17,53 @@ using namespace lldb; using namespace lldb_private; -SBTypeFilter::SBTypeFilter() : m_opaque_sp() {} +SBTypeFilter::SBTypeFilter() : m_opaque_sp() { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeFilter); +} SBTypeFilter::SBTypeFilter(uint32_t options) - : m_opaque_sp(TypeFilterImplSP(new TypeFilterImpl(options))) {} + : m_opaque_sp(TypeFilterImplSP(new TypeFilterImpl(options))) { + LLDB_RECORD_CONSTRUCTOR(SBTypeFilter, (uint32_t), options); +} SBTypeFilter::SBTypeFilter(const lldb::SBTypeFilter &rhs) - : m_opaque_sp(rhs.m_opaque_sp) {} + : m_opaque_sp(rhs.m_opaque_sp) { + LLDB_RECORD_CONSTRUCTOR(SBTypeFilter, (const lldb::SBTypeFilter &), rhs); +} SBTypeFilter::~SBTypeFilter() {} -bool SBTypeFilter::IsValid() const { return m_opaque_sp.get() != NULL; } +bool SBTypeFilter::IsValid() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeFilter, IsValid); + return this->operator bool(); +} +SBTypeFilter::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeFilter, operator bool); + + return m_opaque_sp.get() != nullptr; +} uint32_t SBTypeFilter::GetOptions() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeFilter, GetOptions); + if (IsValid()) return m_opaque_sp->GetOptions(); return 0; } void SBTypeFilter::SetOptions(uint32_t value) { + LLDB_RECORD_METHOD(void, SBTypeFilter, SetOptions, (uint32_t), value); + if (CopyOnWrite_Impl()) m_opaque_sp->SetOptions(value); } bool SBTypeFilter::GetDescription(lldb::SBStream &description, lldb::DescriptionLevel description_level) { + LLDB_RECORD_METHOD(bool, SBTypeFilter, GetDescription, + (lldb::SBStream &, lldb::DescriptionLevel), description, + description_level); + if (!IsValid()) return false; else { @@ -51,27 +73,38 @@ bool SBTypeFilter::GetDescription(lldb::SBStream &description, } void SBTypeFilter::Clear() { + LLDB_RECORD_METHOD_NO_ARGS(void, SBTypeFilter, Clear); + if (CopyOnWrite_Impl()) m_opaque_sp->Clear(); } uint32_t SBTypeFilter::GetNumberOfExpressionPaths() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeFilter, + GetNumberOfExpressionPaths); + if (IsValid()) return m_opaque_sp->GetCount(); return 0; } const char *SBTypeFilter::GetExpressionPathAtIndex(uint32_t i) { + LLDB_RECORD_METHOD(const char *, SBTypeFilter, GetExpressionPathAtIndex, + (uint32_t), i); + if (IsValid()) { const char *item = m_opaque_sp->GetExpressionPathAtIndex(i); if (item && *item == '.') item++; return item; } - return NULL; + return nullptr; } bool SBTypeFilter::ReplaceExpressionPathAtIndex(uint32_t i, const char *item) { + LLDB_RECORD_METHOD(bool, SBTypeFilter, ReplaceExpressionPathAtIndex, + (uint32_t, const char *), i, item); + if (CopyOnWrite_Impl()) return m_opaque_sp->SetExpressionPathAtIndex(i, item); else @@ -79,18 +112,27 @@ bool SBTypeFilter::ReplaceExpressionPathAtIndex(uint32_t i, const char *item) { } void SBTypeFilter::AppendExpressionPath(const char *item) { + LLDB_RECORD_METHOD(void, SBTypeFilter, AppendExpressionPath, (const char *), + item); + if (CopyOnWrite_Impl()) m_opaque_sp->AddExpressionPath(item); } lldb::SBTypeFilter &SBTypeFilter::operator=(const lldb::SBTypeFilter &rhs) { + LLDB_RECORD_METHOD(lldb::SBTypeFilter &, + SBTypeFilter, operator=,(const lldb::SBTypeFilter &), rhs); + if (this != &rhs) { m_opaque_sp = rhs.m_opaque_sp; } - return *this; + return LLDB_RECORD_RESULT(*this); } bool SBTypeFilter::operator==(lldb::SBTypeFilter &rhs) { + LLDB_RECORD_METHOD(bool, SBTypeFilter, operator==,(lldb::SBTypeFilter &), + rhs); + if (!IsValid()) return !rhs.IsValid(); @@ -98,6 +140,9 @@ bool SBTypeFilter::operator==(lldb::SBTypeFilter &rhs) { } bool SBTypeFilter::IsEqualTo(lldb::SBTypeFilter &rhs) { + LLDB_RECORD_METHOD(bool, SBTypeFilter, IsEqualTo, (lldb::SBTypeFilter &), + rhs); + if (!IsValid()) return !rhs.IsValid(); @@ -113,6 +158,9 @@ bool SBTypeFilter::IsEqualTo(lldb::SBTypeFilter &rhs) { } bool SBTypeFilter::operator!=(lldb::SBTypeFilter &rhs) { + LLDB_RECORD_METHOD(bool, SBTypeFilter, operator!=,(lldb::SBTypeFilter &), + rhs); + if (!IsValid()) return !rhs.IsValid(); @@ -143,3 +191,36 @@ bool SBTypeFilter::CopyOnWrite_Impl() { return true; } + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBTypeFilter>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBTypeFilter, ()); + LLDB_REGISTER_CONSTRUCTOR(SBTypeFilter, (uint32_t)); + LLDB_REGISTER_CONSTRUCTOR(SBTypeFilter, (const lldb::SBTypeFilter &)); + LLDB_REGISTER_METHOD_CONST(bool, SBTypeFilter, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBTypeFilter, operator bool, ()); + LLDB_REGISTER_METHOD(uint32_t, SBTypeFilter, GetOptions, ()); + LLDB_REGISTER_METHOD(void, SBTypeFilter, SetOptions, (uint32_t)); + LLDB_REGISTER_METHOD(bool, SBTypeFilter, GetDescription, + (lldb::SBStream &, lldb::DescriptionLevel)); + LLDB_REGISTER_METHOD(void, SBTypeFilter, Clear, ()); + LLDB_REGISTER_METHOD(uint32_t, SBTypeFilter, GetNumberOfExpressionPaths, + ()); + LLDB_REGISTER_METHOD(const char *, SBTypeFilter, GetExpressionPathAtIndex, + (uint32_t)); + LLDB_REGISTER_METHOD(bool, SBTypeFilter, ReplaceExpressionPathAtIndex, + (uint32_t, const char *)); + LLDB_REGISTER_METHOD(void, SBTypeFilter, AppendExpressionPath, + (const char *)); + LLDB_REGISTER_METHOD(lldb::SBTypeFilter &, + SBTypeFilter, operator=,(const lldb::SBTypeFilter &)); + LLDB_REGISTER_METHOD(bool, SBTypeFilter, operator==,(lldb::SBTypeFilter &)); + LLDB_REGISTER_METHOD(bool, SBTypeFilter, IsEqualTo, (lldb::SBTypeFilter &)); + LLDB_REGISTER_METHOD(bool, SBTypeFilter, operator!=,(lldb::SBTypeFilter &)); +} + +} +} diff --git a/source/API/SBTypeFormat.cpp b/source/API/SBTypeFormat.cpp index 66bfd36717361..6024631e7054f 100644 --- a/source/API/SBTypeFormat.cpp +++ b/source/API/SBTypeFormat.cpp @@ -1,14 +1,14 @@ //===-- SBTypeFormat.cpp ------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBTypeFormat.h" +#include "SBReproducerPrivate.h" #include "lldb/API/SBStream.h" @@ -17,30 +17,52 @@ using namespace lldb; using namespace lldb_private; -SBTypeFormat::SBTypeFormat() : m_opaque_sp() {} +SBTypeFormat::SBTypeFormat() : m_opaque_sp() { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeFormat); +} SBTypeFormat::SBTypeFormat(lldb::Format format, uint32_t options) : m_opaque_sp( - TypeFormatImplSP(new TypeFormatImpl_Format(format, options))) {} + TypeFormatImplSP(new TypeFormatImpl_Format(format, options))) { + LLDB_RECORD_CONSTRUCTOR(SBTypeFormat, (lldb::Format, uint32_t), format, + options); +} SBTypeFormat::SBTypeFormat(const char *type, uint32_t options) : m_opaque_sp(TypeFormatImplSP(new TypeFormatImpl_EnumType( - ConstString(type ? type : ""), options))) {} + ConstString(type ? type : ""), options))) { + LLDB_RECORD_CONSTRUCTOR(SBTypeFormat, (const char *, uint32_t), type, + options); +} SBTypeFormat::SBTypeFormat(const lldb::SBTypeFormat &rhs) - : m_opaque_sp(rhs.m_opaque_sp) {} + : m_opaque_sp(rhs.m_opaque_sp) { + LLDB_RECORD_CONSTRUCTOR(SBTypeFormat, (const lldb::SBTypeFormat &), rhs); +} SBTypeFormat::~SBTypeFormat() {} -bool SBTypeFormat::IsValid() const { return m_opaque_sp.get() != NULL; } +bool SBTypeFormat::IsValid() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeFormat, IsValid); + return this->operator bool(); +} +SBTypeFormat::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeFormat, operator bool); + + return m_opaque_sp.get() != nullptr; +} lldb::Format SBTypeFormat::GetFormat() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::Format, SBTypeFormat, GetFormat); + if (IsValid() && m_opaque_sp->GetType() == TypeFormatImpl::Type::eTypeFormat) return ((TypeFormatImpl_Format *)m_opaque_sp.get())->GetFormat(); return lldb::eFormatInvalid; } const char *SBTypeFormat::GetTypeName() { + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTypeFormat, GetTypeName); + if (IsValid() && m_opaque_sp->GetType() == TypeFormatImpl::Type::eTypeEnum) return ((TypeFormatImpl_EnumType *)m_opaque_sp.get()) ->GetTypeName() @@ -49,29 +71,41 @@ const char *SBTypeFormat::GetTypeName() { } uint32_t SBTypeFormat::GetOptions() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeFormat, GetOptions); + if (IsValid()) return m_opaque_sp->GetOptions(); return 0; } void SBTypeFormat::SetFormat(lldb::Format fmt) { + LLDB_RECORD_METHOD(void, SBTypeFormat, SetFormat, (lldb::Format), fmt); + if (CopyOnWrite_Impl(Type::eTypeFormat)) ((TypeFormatImpl_Format *)m_opaque_sp.get())->SetFormat(fmt); } void SBTypeFormat::SetTypeName(const char *type) { + LLDB_RECORD_METHOD(void, SBTypeFormat, SetTypeName, (const char *), type); + if (CopyOnWrite_Impl(Type::eTypeEnum)) ((TypeFormatImpl_EnumType *)m_opaque_sp.get()) ->SetTypeName(ConstString(type ? type : "")); } void SBTypeFormat::SetOptions(uint32_t value) { + LLDB_RECORD_METHOD(void, SBTypeFormat, SetOptions, (uint32_t), value); + if (CopyOnWrite_Impl(Type::eTypeKeepSame)) m_opaque_sp->SetOptions(value); } bool SBTypeFormat::GetDescription(lldb::SBStream &description, lldb::DescriptionLevel description_level) { + LLDB_RECORD_METHOD(bool, SBTypeFormat, GetDescription, + (lldb::SBStream &, lldb::DescriptionLevel), description, + description_level); + if (!IsValid()) return false; else { @@ -81,19 +115,28 @@ bool SBTypeFormat::GetDescription(lldb::SBStream &description, } lldb::SBTypeFormat &SBTypeFormat::operator=(const lldb::SBTypeFormat &rhs) { + LLDB_RECORD_METHOD(lldb::SBTypeFormat &, + SBTypeFormat, operator=,(const lldb::SBTypeFormat &), rhs); + if (this != &rhs) { m_opaque_sp = rhs.m_opaque_sp; } - return *this; + return LLDB_RECORD_RESULT(*this); } bool SBTypeFormat::operator==(lldb::SBTypeFormat &rhs) { + LLDB_RECORD_METHOD(bool, SBTypeFormat, operator==,(lldb::SBTypeFormat &), + rhs); + if (!IsValid()) return !rhs.IsValid(); return m_opaque_sp == rhs.m_opaque_sp; } bool SBTypeFormat::IsEqualTo(lldb::SBTypeFormat &rhs) { + LLDB_RECORD_METHOD(bool, SBTypeFormat, IsEqualTo, (lldb::SBTypeFormat &), + rhs); + if (!IsValid()) return !rhs.IsValid(); @@ -104,6 +147,9 @@ bool SBTypeFormat::IsEqualTo(lldb::SBTypeFormat &rhs) { } bool SBTypeFormat::operator!=(lldb::SBTypeFormat &rhs) { + LLDB_RECORD_METHOD(bool, SBTypeFormat, operator!=,(lldb::SBTypeFormat &), + rhs); + if (!IsValid()) return !rhs.IsValid(); return m_opaque_sp != rhs.m_opaque_sp; @@ -146,3 +192,32 @@ bool SBTypeFormat::CopyOnWrite_Impl(Type type) { return true; } + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBTypeFormat>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBTypeFormat, ()); + LLDB_REGISTER_CONSTRUCTOR(SBTypeFormat, (lldb::Format, uint32_t)); + LLDB_REGISTER_CONSTRUCTOR(SBTypeFormat, (const char *, uint32_t)); + LLDB_REGISTER_CONSTRUCTOR(SBTypeFormat, (const lldb::SBTypeFormat &)); + LLDB_REGISTER_METHOD_CONST(bool, SBTypeFormat, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBTypeFormat, operator bool, ()); + LLDB_REGISTER_METHOD(lldb::Format, SBTypeFormat, GetFormat, ()); + LLDB_REGISTER_METHOD(const char *, SBTypeFormat, GetTypeName, ()); + LLDB_REGISTER_METHOD(uint32_t, SBTypeFormat, GetOptions, ()); + LLDB_REGISTER_METHOD(void, SBTypeFormat, SetFormat, (lldb::Format)); + LLDB_REGISTER_METHOD(void, SBTypeFormat, SetTypeName, (const char *)); + LLDB_REGISTER_METHOD(void, SBTypeFormat, SetOptions, (uint32_t)); + LLDB_REGISTER_METHOD(bool, SBTypeFormat, GetDescription, + (lldb::SBStream &, lldb::DescriptionLevel)); + LLDB_REGISTER_METHOD(lldb::SBTypeFormat &, + SBTypeFormat, operator=,(const lldb::SBTypeFormat &)); + LLDB_REGISTER_METHOD(bool, SBTypeFormat, operator==,(lldb::SBTypeFormat &)); + LLDB_REGISTER_METHOD(bool, SBTypeFormat, IsEqualTo, (lldb::SBTypeFormat &)); + LLDB_REGISTER_METHOD(bool, SBTypeFormat, operator!=,(lldb::SBTypeFormat &)); +} + +} +} diff --git a/source/API/SBTypeNameSpecifier.cpp b/source/API/SBTypeNameSpecifier.cpp index 5ffb3d98a0f2f..895f697756598 100644 --- a/source/API/SBTypeNameSpecifier.cpp +++ b/source/API/SBTypeNameSpecifier.cpp @@ -1,14 +1,14 @@ //===-- SBTypeNameSpecifier.cpp ------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBTypeNameSpecifier.h" +#include "SBReproducerPrivate.h" #include "lldb/API/SBStream.h" #include "lldb/API/SBType.h" @@ -18,44 +18,68 @@ using namespace lldb; using namespace lldb_private; -SBTypeNameSpecifier::SBTypeNameSpecifier() : m_opaque_sp() {} +SBTypeNameSpecifier::SBTypeNameSpecifier() : m_opaque_sp() { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeNameSpecifier); +} SBTypeNameSpecifier::SBTypeNameSpecifier(const char *name, bool is_regex) : m_opaque_sp(new TypeNameSpecifierImpl(name, is_regex)) { - if (name == NULL || (*name) == 0) + LLDB_RECORD_CONSTRUCTOR(SBTypeNameSpecifier, (const char *, bool), name, + is_regex); + + if (name == nullptr || (*name) == 0) m_opaque_sp.reset(); } SBTypeNameSpecifier::SBTypeNameSpecifier(SBType type) : m_opaque_sp() { + LLDB_RECORD_CONSTRUCTOR(SBTypeNameSpecifier, (lldb::SBType), type); + if (type.IsValid()) m_opaque_sp = TypeNameSpecifierImplSP( new TypeNameSpecifierImpl(type.m_opaque_sp->GetCompilerType(true))); } SBTypeNameSpecifier::SBTypeNameSpecifier(const lldb::SBTypeNameSpecifier &rhs) - : m_opaque_sp(rhs.m_opaque_sp) {} + : m_opaque_sp(rhs.m_opaque_sp) { + LLDB_RECORD_CONSTRUCTOR(SBTypeNameSpecifier, + (const lldb::SBTypeNameSpecifier &), rhs); +} SBTypeNameSpecifier::~SBTypeNameSpecifier() {} -bool SBTypeNameSpecifier::IsValid() const { return m_opaque_sp.get() != NULL; } +bool SBTypeNameSpecifier::IsValid() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeNameSpecifier, IsValid); + return this->operator bool(); +} +SBTypeNameSpecifier::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeNameSpecifier, operator bool); + + return m_opaque_sp.get() != nullptr; +} const char *SBTypeNameSpecifier::GetName() { + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTypeNameSpecifier, GetName); + if (!IsValid()) - return NULL; + return nullptr; return m_opaque_sp->GetName(); } SBType SBTypeNameSpecifier::GetType() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBTypeNameSpecifier, GetType); + if (!IsValid()) - return SBType(); + return LLDB_RECORD_RESULT(SBType()); lldb_private::CompilerType c_type = m_opaque_sp->GetCompilerType(); if (c_type.IsValid()) - return SBType(c_type); - return SBType(); + return LLDB_RECORD_RESULT(SBType(c_type)); + return LLDB_RECORD_RESULT(SBType()); } bool SBTypeNameSpecifier::IsRegex() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBTypeNameSpecifier, IsRegex); + if (!IsValid()) return false; @@ -64,6 +88,10 @@ bool SBTypeNameSpecifier::IsRegex() { bool SBTypeNameSpecifier::GetDescription( lldb::SBStream &description, lldb::DescriptionLevel description_level) { + LLDB_RECORD_METHOD(bool, SBTypeNameSpecifier, GetDescription, + (lldb::SBStream &, lldb::DescriptionLevel), description, + description_level); + if (!IsValid()) return false; description.Printf("SBTypeNameSpecifier(%s,%s)", GetName(), @@ -73,31 +101,44 @@ bool SBTypeNameSpecifier::GetDescription( lldb::SBTypeNameSpecifier &SBTypeNameSpecifier:: operator=(const lldb::SBTypeNameSpecifier &rhs) { + LLDB_RECORD_METHOD( + lldb::SBTypeNameSpecifier &, + SBTypeNameSpecifier, operator=,(const lldb::SBTypeNameSpecifier &), rhs); + if (this != &rhs) { m_opaque_sp = rhs.m_opaque_sp; } - return *this; + return LLDB_RECORD_RESULT(*this); } bool SBTypeNameSpecifier::operator==(lldb::SBTypeNameSpecifier &rhs) { + LLDB_RECORD_METHOD( + bool, SBTypeNameSpecifier, operator==,(lldb::SBTypeNameSpecifier &), rhs); + if (!IsValid()) return !rhs.IsValid(); return m_opaque_sp == rhs.m_opaque_sp; } bool SBTypeNameSpecifier::IsEqualTo(lldb::SBTypeNameSpecifier &rhs) { + LLDB_RECORD_METHOD(bool, SBTypeNameSpecifier, IsEqualTo, + (lldb::SBTypeNameSpecifier &), rhs); + if (!IsValid()) return !rhs.IsValid(); if (IsRegex() != rhs.IsRegex()) return false; - if (GetName() == NULL || rhs.GetName() == NULL) + if (GetName() == nullptr || rhs.GetName() == nullptr) return false; return (strcmp(GetName(), rhs.GetName()) == 0); } bool SBTypeNameSpecifier::operator!=(lldb::SBTypeNameSpecifier &rhs) { + LLDB_RECORD_METHOD( + bool, SBTypeNameSpecifier, operator!=,(lldb::SBTypeNameSpecifier &), rhs); + if (!IsValid()) return !rhs.IsValid(); return m_opaque_sp != rhs.m_opaque_sp; @@ -115,3 +156,34 @@ void SBTypeNameSpecifier::SetSP( SBTypeNameSpecifier::SBTypeNameSpecifier( const lldb::TypeNameSpecifierImplSP &type_namespec_sp) : m_opaque_sp(type_namespec_sp) {} + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBTypeNameSpecifier>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBTypeNameSpecifier, ()); + LLDB_REGISTER_CONSTRUCTOR(SBTypeNameSpecifier, (const char *, bool)); + LLDB_REGISTER_CONSTRUCTOR(SBTypeNameSpecifier, (lldb::SBType)); + LLDB_REGISTER_CONSTRUCTOR(SBTypeNameSpecifier, + (const lldb::SBTypeNameSpecifier &)); + LLDB_REGISTER_METHOD_CONST(bool, SBTypeNameSpecifier, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBTypeNameSpecifier, operator bool, ()); + LLDB_REGISTER_METHOD(const char *, SBTypeNameSpecifier, GetName, ()); + LLDB_REGISTER_METHOD(lldb::SBType, SBTypeNameSpecifier, GetType, ()); + LLDB_REGISTER_METHOD(bool, SBTypeNameSpecifier, IsRegex, ()); + LLDB_REGISTER_METHOD(bool, SBTypeNameSpecifier, GetDescription, + (lldb::SBStream &, lldb::DescriptionLevel)); + LLDB_REGISTER_METHOD( + lldb::SBTypeNameSpecifier &, + SBTypeNameSpecifier, operator=,(const lldb::SBTypeNameSpecifier &)); + LLDB_REGISTER_METHOD( + bool, SBTypeNameSpecifier, operator==,(lldb::SBTypeNameSpecifier &)); + LLDB_REGISTER_METHOD(bool, SBTypeNameSpecifier, IsEqualTo, + (lldb::SBTypeNameSpecifier &)); + LLDB_REGISTER_METHOD( + bool, SBTypeNameSpecifier, operator!=,(lldb::SBTypeNameSpecifier &)); +} + +} +} diff --git a/source/API/SBTypeSummary.cpp b/source/API/SBTypeSummary.cpp index 76c94ae834443..8ffb234357572 100644 --- a/source/API/SBTypeSummary.cpp +++ b/source/API/SBTypeSummary.cpp @@ -1,14 +1,15 @@ //===-- SBTypeSummary.cpp -----------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBTypeSummary.h" +#include "SBReproducerPrivate.h" +#include "Utils.h" #include "lldb/API/SBStream.h" #include "lldb/API/SBValue.h" #include "lldb/DataFormatters/DataVisualization.h" @@ -19,109 +20,154 @@ using namespace lldb; using namespace lldb_private; SBTypeSummaryOptions::SBTypeSummaryOptions() { - m_opaque_ap.reset(new TypeSummaryOptions()); + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeSummaryOptions); + + m_opaque_up.reset(new TypeSummaryOptions()); } SBTypeSummaryOptions::SBTypeSummaryOptions( const lldb::SBTypeSummaryOptions &rhs) { - if (rhs.m_opaque_ap) - m_opaque_ap.reset(new TypeSummaryOptions(*rhs.m_opaque_ap)); - else - m_opaque_ap.reset(new TypeSummaryOptions()); + LLDB_RECORD_CONSTRUCTOR(SBTypeSummaryOptions, + (const lldb::SBTypeSummaryOptions &), rhs); + + m_opaque_up = clone(rhs.m_opaque_up); } SBTypeSummaryOptions::~SBTypeSummaryOptions() {} -bool SBTypeSummaryOptions::IsValid() { return m_opaque_ap.get(); } +bool SBTypeSummaryOptions::IsValid() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBTypeSummaryOptions, IsValid); + return this->operator bool(); +} +SBTypeSummaryOptions::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeSummaryOptions, operator bool); + + return m_opaque_up.get(); +} lldb::LanguageType SBTypeSummaryOptions::GetLanguage() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::LanguageType, SBTypeSummaryOptions, + GetLanguage); + if (IsValid()) - return m_opaque_ap->GetLanguage(); + return m_opaque_up->GetLanguage(); return lldb::eLanguageTypeUnknown; } lldb::TypeSummaryCapping SBTypeSummaryOptions::GetCapping() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::TypeSummaryCapping, SBTypeSummaryOptions, + GetCapping); + if (IsValid()) - return m_opaque_ap->GetCapping(); + return m_opaque_up->GetCapping(); return eTypeSummaryCapped; } void SBTypeSummaryOptions::SetLanguage(lldb::LanguageType l) { + LLDB_RECORD_METHOD(void, SBTypeSummaryOptions, SetLanguage, + (lldb::LanguageType), l); + if (IsValid()) - m_opaque_ap->SetLanguage(l); + m_opaque_up->SetLanguage(l); } void SBTypeSummaryOptions::SetCapping(lldb::TypeSummaryCapping c) { + LLDB_RECORD_METHOD(void, SBTypeSummaryOptions, SetCapping, + (lldb::TypeSummaryCapping), c); + if (IsValid()) - m_opaque_ap->SetCapping(c); + m_opaque_up->SetCapping(c); } lldb_private::TypeSummaryOptions *SBTypeSummaryOptions::operator->() { - return m_opaque_ap.get(); + return m_opaque_up.get(); } const lldb_private::TypeSummaryOptions *SBTypeSummaryOptions:: operator->() const { - return m_opaque_ap.get(); + return m_opaque_up.get(); } lldb_private::TypeSummaryOptions *SBTypeSummaryOptions::get() { - return m_opaque_ap.get(); + return m_opaque_up.get(); } lldb_private::TypeSummaryOptions &SBTypeSummaryOptions::ref() { - return *m_opaque_ap; + return *m_opaque_up; } const lldb_private::TypeSummaryOptions &SBTypeSummaryOptions::ref() const { - return *m_opaque_ap; + return *m_opaque_up; } SBTypeSummaryOptions::SBTypeSummaryOptions( const lldb_private::TypeSummaryOptions *lldb_object_ptr) { + LLDB_RECORD_CONSTRUCTOR(SBTypeSummaryOptions, + (const lldb_private::TypeSummaryOptions *), + lldb_object_ptr); + SetOptions(lldb_object_ptr); } void SBTypeSummaryOptions::SetOptions( const lldb_private::TypeSummaryOptions *lldb_object_ptr) { if (lldb_object_ptr) - m_opaque_ap.reset(new TypeSummaryOptions(*lldb_object_ptr)); + m_opaque_up.reset(new TypeSummaryOptions(*lldb_object_ptr)); else - m_opaque_ap.reset(new TypeSummaryOptions()); + m_opaque_up.reset(new TypeSummaryOptions()); } -SBTypeSummary::SBTypeSummary() : m_opaque_sp() {} +SBTypeSummary::SBTypeSummary() : m_opaque_sp() { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeSummary); +} SBTypeSummary SBTypeSummary::CreateWithSummaryString(const char *data, uint32_t options) { + LLDB_RECORD_STATIC_METHOD(lldb::SBTypeSummary, SBTypeSummary, + CreateWithSummaryString, (const char *, uint32_t), + data, options); + if (!data || data[0] == 0) - return SBTypeSummary(); + return LLDB_RECORD_RESULT(SBTypeSummary()); - return SBTypeSummary( - TypeSummaryImplSP(new StringSummaryFormat(options, data))); + return LLDB_RECORD_RESULT( + SBTypeSummary(TypeSummaryImplSP(new StringSummaryFormat(options, data)))); } SBTypeSummary SBTypeSummary::CreateWithFunctionName(const char *data, uint32_t options) { + LLDB_RECORD_STATIC_METHOD(lldb::SBTypeSummary, SBTypeSummary, + CreateWithFunctionName, (const char *, uint32_t), + data, options); + if (!data || data[0] == 0) - return SBTypeSummary(); + return LLDB_RECORD_RESULT(SBTypeSummary()); - return SBTypeSummary( - TypeSummaryImplSP(new ScriptSummaryFormat(options, data))); + return LLDB_RECORD_RESULT( + SBTypeSummary(TypeSummaryImplSP(new ScriptSummaryFormat(options, data)))); } SBTypeSummary SBTypeSummary::CreateWithScriptCode(const char *data, uint32_t options) { + LLDB_RECORD_STATIC_METHOD(lldb::SBTypeSummary, SBTypeSummary, + CreateWithScriptCode, (const char *, uint32_t), + data, options); + if (!data || data[0] == 0) - return SBTypeSummary(); + return LLDB_RECORD_RESULT(SBTypeSummary()); - return SBTypeSummary( - TypeSummaryImplSP(new ScriptSummaryFormat(options, "", data))); + return LLDB_RECORD_RESULT(SBTypeSummary( + TypeSummaryImplSP(new ScriptSummaryFormat(options, "", data)))); } SBTypeSummary SBTypeSummary::CreateWithCallback(FormatCallback cb, uint32_t options, const char *description) { + LLDB_RECORD_DUMMY( + lldb::SBTypeSummary, SBTypeSummary, CreateWithCallback, + (lldb::SBTypeSummary::FormatCallback, uint32_t, const char *), cb, + options, description); + SBTypeSummary retval; if (cb) { retval.SetSP(TypeSummaryImplSP(new CXXFunctionSummaryFormat( @@ -143,13 +189,25 @@ SBTypeSummary SBTypeSummary::CreateWithCallback(FormatCallback cb, } SBTypeSummary::SBTypeSummary(const lldb::SBTypeSummary &rhs) - : m_opaque_sp(rhs.m_opaque_sp) {} + : m_opaque_sp(rhs.m_opaque_sp) { + LLDB_RECORD_CONSTRUCTOR(SBTypeSummary, (const lldb::SBTypeSummary &), rhs); +} SBTypeSummary::~SBTypeSummary() {} -bool SBTypeSummary::IsValid() const { return m_opaque_sp.get() != NULL; } +bool SBTypeSummary::IsValid() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeSummary, IsValid); + return this->operator bool(); +} +SBTypeSummary::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeSummary, operator bool); + + return m_opaque_sp.get() != nullptr; +} bool SBTypeSummary::IsFunctionCode() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBTypeSummary, IsFunctionCode); + if (!IsValid()) return false; if (ScriptSummaryFormat *script_summary_ptr = @@ -161,6 +219,8 @@ bool SBTypeSummary::IsFunctionCode() { } bool SBTypeSummary::IsFunctionName() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBTypeSummary, IsFunctionName); + if (!IsValid()) return false; if (ScriptSummaryFormat *script_summary_ptr = @@ -172,6 +232,8 @@ bool SBTypeSummary::IsFunctionName() { } bool SBTypeSummary::IsSummaryString() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBTypeSummary, IsSummaryString); + if (!IsValid()) return false; @@ -179,8 +241,10 @@ bool SBTypeSummary::IsSummaryString() { } const char *SBTypeSummary::GetData() { + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTypeSummary, GetData); + if (!IsValid()) - return NULL; + return nullptr; if (ScriptSummaryFormat *script_summary_ptr = llvm::dyn_cast<ScriptSummaryFormat>(m_opaque_sp.get())) { const char *fname = script_summary_ptr->GetFunctionName(); @@ -195,18 +259,25 @@ const char *SBTypeSummary::GetData() { } uint32_t SBTypeSummary::GetOptions() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeSummary, GetOptions); + if (!IsValid()) return lldb::eTypeOptionNone; return m_opaque_sp->GetOptions(); } void SBTypeSummary::SetOptions(uint32_t value) { + LLDB_RECORD_METHOD(void, SBTypeSummary, SetOptions, (uint32_t), value); + if (!CopyOnWrite_Impl()) return; m_opaque_sp->SetOptions(value); } void SBTypeSummary::SetSummaryString(const char *data) { + LLDB_RECORD_METHOD(void, SBTypeSummary, SetSummaryString, (const char *), + data); + if (!IsValid()) return; if (!llvm::isa<StringSummaryFormat>(m_opaque_sp.get())) @@ -217,6 +288,9 @@ void SBTypeSummary::SetSummaryString(const char *data) { } void SBTypeSummary::SetFunctionName(const char *data) { + LLDB_RECORD_METHOD(void, SBTypeSummary, SetFunctionName, (const char *), + data); + if (!IsValid()) return; if (!llvm::isa<ScriptSummaryFormat>(m_opaque_sp.get())) @@ -227,6 +301,9 @@ void SBTypeSummary::SetFunctionName(const char *data) { } void SBTypeSummary::SetFunctionCode(const char *data) { + LLDB_RECORD_METHOD(void, SBTypeSummary, SetFunctionCode, (const char *), + data); + if (!IsValid()) return; if (!llvm::isa<ScriptSummaryFormat>(m_opaque_sp.get())) @@ -238,6 +315,10 @@ void SBTypeSummary::SetFunctionCode(const char *data) { bool SBTypeSummary::GetDescription(lldb::SBStream &description, lldb::DescriptionLevel description_level) { + LLDB_RECORD_METHOD(bool, SBTypeSummary, GetDescription, + (lldb::SBStream &, lldb::DescriptionLevel), description, + description_level); + if (!CopyOnWrite_Impl()) return false; else { @@ -247,6 +328,9 @@ bool SBTypeSummary::GetDescription(lldb::SBStream &description, } bool SBTypeSummary::DoesPrintValue(lldb::SBValue value) { + LLDB_RECORD_METHOD(bool, SBTypeSummary, DoesPrintValue, (lldb::SBValue), + value); + if (!IsValid()) return false; lldb::ValueObjectSP value_sp = value.GetSP(); @@ -254,19 +338,29 @@ bool SBTypeSummary::DoesPrintValue(lldb::SBValue value) { } lldb::SBTypeSummary &SBTypeSummary::operator=(const lldb::SBTypeSummary &rhs) { + LLDB_RECORD_METHOD(lldb::SBTypeSummary &, + SBTypeSummary, operator=,(const lldb::SBTypeSummary &), + rhs); + if (this != &rhs) { m_opaque_sp = rhs.m_opaque_sp; } - return *this; + return LLDB_RECORD_RESULT(*this); } bool SBTypeSummary::operator==(lldb::SBTypeSummary &rhs) { + LLDB_RECORD_METHOD(bool, SBTypeSummary, operator==,(lldb::SBTypeSummary &), + rhs); + if (!IsValid()) return !rhs.IsValid(); return m_opaque_sp == rhs.m_opaque_sp; } bool SBTypeSummary::IsEqualTo(lldb::SBTypeSummary &rhs) { + LLDB_RECORD_METHOD(bool, SBTypeSummary, IsEqualTo, (lldb::SBTypeSummary &), + rhs); + if (IsValid()) { // valid and invalid are different if (!rhs.IsValid()) @@ -305,6 +399,9 @@ bool SBTypeSummary::IsEqualTo(lldb::SBTypeSummary &rhs) { } bool SBTypeSummary::operator!=(lldb::SBTypeSummary &rhs) { + LLDB_RECORD_METHOD(bool, SBTypeSummary, operator!=,(lldb::SBTypeSummary &), + rhs); + if (!IsValid()) return !rhs.IsValid(); return m_opaque_sp != rhs.m_opaque_sp; @@ -376,3 +473,65 @@ bool SBTypeSummary::ChangeSummaryType(bool want_script) { return true; } + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBTypeSummaryOptions>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBTypeSummaryOptions, ()); + LLDB_REGISTER_CONSTRUCTOR(SBTypeSummaryOptions, + (const lldb::SBTypeSummaryOptions &)); + LLDB_REGISTER_METHOD(bool, SBTypeSummaryOptions, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBTypeSummaryOptions, operator bool, ()); + LLDB_REGISTER_METHOD(lldb::LanguageType, SBTypeSummaryOptions, GetLanguage, + ()); + LLDB_REGISTER_METHOD(lldb::TypeSummaryCapping, SBTypeSummaryOptions, + GetCapping, ()); + LLDB_REGISTER_METHOD(void, SBTypeSummaryOptions, SetLanguage, + (lldb::LanguageType)); + LLDB_REGISTER_METHOD(void, SBTypeSummaryOptions, SetCapping, + (lldb::TypeSummaryCapping)); + LLDB_REGISTER_CONSTRUCTOR(SBTypeSummaryOptions, + (const lldb_private::TypeSummaryOptions *)); +} + +template <> +void RegisterMethods<SBTypeSummary>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBTypeSummary, ()); + LLDB_REGISTER_STATIC_METHOD(lldb::SBTypeSummary, SBTypeSummary, + CreateWithSummaryString, + (const char *, uint32_t)); + LLDB_REGISTER_STATIC_METHOD(lldb::SBTypeSummary, SBTypeSummary, + CreateWithFunctionName, + (const char *, uint32_t)); + LLDB_REGISTER_STATIC_METHOD(lldb::SBTypeSummary, SBTypeSummary, + CreateWithScriptCode, (const char *, uint32_t)); + LLDB_REGISTER_CONSTRUCTOR(SBTypeSummary, (const lldb::SBTypeSummary &)); + LLDB_REGISTER_METHOD_CONST(bool, SBTypeSummary, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBTypeSummary, operator bool, ()); + LLDB_REGISTER_METHOD(bool, SBTypeSummary, IsFunctionCode, ()); + LLDB_REGISTER_METHOD(bool, SBTypeSummary, IsFunctionName, ()); + LLDB_REGISTER_METHOD(bool, SBTypeSummary, IsSummaryString, ()); + LLDB_REGISTER_METHOD(const char *, SBTypeSummary, GetData, ()); + LLDB_REGISTER_METHOD(uint32_t, SBTypeSummary, GetOptions, ()); + LLDB_REGISTER_METHOD(void, SBTypeSummary, SetOptions, (uint32_t)); + LLDB_REGISTER_METHOD(void, SBTypeSummary, SetSummaryString, (const char *)); + LLDB_REGISTER_METHOD(void, SBTypeSummary, SetFunctionName, (const char *)); + LLDB_REGISTER_METHOD(void, SBTypeSummary, SetFunctionCode, (const char *)); + LLDB_REGISTER_METHOD(bool, SBTypeSummary, GetDescription, + (lldb::SBStream &, lldb::DescriptionLevel)); + LLDB_REGISTER_METHOD(bool, SBTypeSummary, DoesPrintValue, (lldb::SBValue)); + LLDB_REGISTER_METHOD( + lldb::SBTypeSummary &, + SBTypeSummary, operator=,(const lldb::SBTypeSummary &)); + LLDB_REGISTER_METHOD(bool, + SBTypeSummary, operator==,(lldb::SBTypeSummary &)); + LLDB_REGISTER_METHOD(bool, SBTypeSummary, IsEqualTo, + (lldb::SBTypeSummary &)); + LLDB_REGISTER_METHOD(bool, + SBTypeSummary, operator!=,(lldb::SBTypeSummary &)); +} + +} +} diff --git a/source/API/SBTypeSynthetic.cpp b/source/API/SBTypeSynthetic.cpp index 750d917e67f15..df6fce1269f09 100644 --- a/source/API/SBTypeSynthetic.cpp +++ b/source/API/SBTypeSynthetic.cpp @@ -1,14 +1,14 @@ //===-- SBTypeSynthetic.cpp -----------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBTypeSynthetic.h" +#include "SBReproducerPrivate.h" #include "lldb/API/SBStream.h" @@ -17,34 +17,55 @@ using namespace lldb; using namespace lldb_private; -#ifndef LLDB_DISABLE_PYTHON - -SBTypeSynthetic::SBTypeSynthetic() : m_opaque_sp() {} +SBTypeSynthetic::SBTypeSynthetic() : m_opaque_sp() { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeSynthetic); +} SBTypeSynthetic SBTypeSynthetic::CreateWithClassName(const char *data, uint32_t options) { + LLDB_RECORD_STATIC_METHOD(lldb::SBTypeSynthetic, SBTypeSynthetic, + CreateWithClassName, (const char *, uint32_t), data, + options); + if (!data || data[0] == 0) - return SBTypeSynthetic(); - return SBTypeSynthetic(ScriptedSyntheticChildrenSP( - new ScriptedSyntheticChildren(options, data, ""))); + return LLDB_RECORD_RESULT(SBTypeSynthetic()); + return LLDB_RECORD_RESULT(SBTypeSynthetic(ScriptedSyntheticChildrenSP( + new ScriptedSyntheticChildren(options, data, "")))); } SBTypeSynthetic SBTypeSynthetic::CreateWithScriptCode(const char *data, uint32_t options) { + LLDB_RECORD_STATIC_METHOD(lldb::SBTypeSynthetic, SBTypeSynthetic, + CreateWithScriptCode, (const char *, uint32_t), + data, options); + if (!data || data[0] == 0) - return SBTypeSynthetic(); - return SBTypeSynthetic(ScriptedSyntheticChildrenSP( - new ScriptedSyntheticChildren(options, "", data))); + return LLDB_RECORD_RESULT(SBTypeSynthetic()); + return LLDB_RECORD_RESULT(SBTypeSynthetic(ScriptedSyntheticChildrenSP( + new ScriptedSyntheticChildren(options, "", data)))); } SBTypeSynthetic::SBTypeSynthetic(const lldb::SBTypeSynthetic &rhs) - : m_opaque_sp(rhs.m_opaque_sp) {} + : m_opaque_sp(rhs.m_opaque_sp) { + LLDB_RECORD_CONSTRUCTOR(SBTypeSynthetic, (const lldb::SBTypeSynthetic &), + rhs); +} SBTypeSynthetic::~SBTypeSynthetic() {} -bool SBTypeSynthetic::IsValid() const { return m_opaque_sp.get() != NULL; } +bool SBTypeSynthetic::IsValid() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeSynthetic, IsValid); + return this->operator bool(); +} +SBTypeSynthetic::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeSynthetic, operator bool); + + return m_opaque_sp.get() != nullptr; +} bool SBTypeSynthetic::IsClassCode() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBTypeSynthetic, IsClassCode); + if (!IsValid()) return false; const char *code = m_opaque_sp->GetPythonCode(); @@ -52,14 +73,18 @@ bool SBTypeSynthetic::IsClassCode() { } bool SBTypeSynthetic::IsClassName() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBTypeSynthetic, IsClassName); + if (!IsValid()) return false; return !IsClassCode(); } const char *SBTypeSynthetic::GetData() { + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTypeSynthetic, GetData); + if (!IsValid()) - return NULL; + return nullptr; if (IsClassCode()) return m_opaque_sp->GetPythonCode(); else @@ -67,22 +92,30 @@ const char *SBTypeSynthetic::GetData() { } void SBTypeSynthetic::SetClassName(const char *data) { + LLDB_RECORD_METHOD(void, SBTypeSynthetic, SetClassName, (const char *), data); + if (IsValid() && data && *data) m_opaque_sp->SetPythonClassName(data); } void SBTypeSynthetic::SetClassCode(const char *data) { + LLDB_RECORD_METHOD(void, SBTypeSynthetic, SetClassCode, (const char *), data); + if (IsValid() && data && *data) m_opaque_sp->SetPythonCode(data); } uint32_t SBTypeSynthetic::GetOptions() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeSynthetic, GetOptions); + if (!IsValid()) return lldb::eTypeOptionNone; return m_opaque_sp->GetOptions(); } void SBTypeSynthetic::SetOptions(uint32_t value) { + LLDB_RECORD_METHOD(void, SBTypeSynthetic, SetOptions, (uint32_t), value); + if (!CopyOnWrite_Impl()) return; m_opaque_sp->SetOptions(value); @@ -90,6 +123,10 @@ void SBTypeSynthetic::SetOptions(uint32_t value) { bool SBTypeSynthetic::GetDescription(lldb::SBStream &description, lldb::DescriptionLevel description_level) { + LLDB_RECORD_METHOD(bool, SBTypeSynthetic, GetDescription, + (lldb::SBStream &, lldb::DescriptionLevel), description, + description_level); + if (m_opaque_sp) { description.Printf("%s\n", m_opaque_sp->GetDescription().c_str()); return true; @@ -99,19 +136,29 @@ bool SBTypeSynthetic::GetDescription(lldb::SBStream &description, lldb::SBTypeSynthetic &SBTypeSynthetic:: operator=(const lldb::SBTypeSynthetic &rhs) { + LLDB_RECORD_METHOD(lldb::SBTypeSynthetic &, + SBTypeSynthetic, operator=,(const lldb::SBTypeSynthetic &), + rhs); + if (this != &rhs) { m_opaque_sp = rhs.m_opaque_sp; } - return *this; + return LLDB_RECORD_RESULT(*this); } bool SBTypeSynthetic::operator==(lldb::SBTypeSynthetic &rhs) { + LLDB_RECORD_METHOD( + bool, SBTypeSynthetic, operator==,(lldb::SBTypeSynthetic &), rhs); + if (!IsValid()) return !rhs.IsValid(); return m_opaque_sp == rhs.m_opaque_sp; } bool SBTypeSynthetic::IsEqualTo(lldb::SBTypeSynthetic &rhs) { + LLDB_RECORD_METHOD(bool, SBTypeSynthetic, IsEqualTo, + (lldb::SBTypeSynthetic &), rhs); + if (!IsValid()) return !rhs.IsValid(); @@ -128,6 +175,9 @@ bool SBTypeSynthetic::IsEqualTo(lldb::SBTypeSynthetic &rhs) { } bool SBTypeSynthetic::operator!=(lldb::SBTypeSynthetic &rhs) { + LLDB_RECORD_METHOD( + bool, SBTypeSynthetic, operator!=,(lldb::SBTypeSynthetic &), rhs); + if (!IsValid()) return !rhs.IsValid(); return m_opaque_sp != rhs.m_opaque_sp; @@ -161,4 +211,38 @@ bool SBTypeSynthetic::CopyOnWrite_Impl() { return true; } -#endif // LLDB_DISABLE_PYTHON +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBTypeSynthetic>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBTypeSynthetic, ()); + LLDB_REGISTER_STATIC_METHOD(lldb::SBTypeSynthetic, SBTypeSynthetic, + CreateWithClassName, (const char *, uint32_t)); + LLDB_REGISTER_STATIC_METHOD(lldb::SBTypeSynthetic, SBTypeSynthetic, + CreateWithScriptCode, (const char *, uint32_t)); + LLDB_REGISTER_CONSTRUCTOR(SBTypeSynthetic, (const lldb::SBTypeSynthetic &)); + LLDB_REGISTER_METHOD_CONST(bool, SBTypeSynthetic, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBTypeSynthetic, operator bool, ()); + LLDB_REGISTER_METHOD(bool, SBTypeSynthetic, IsClassCode, ()); + LLDB_REGISTER_METHOD(bool, SBTypeSynthetic, IsClassName, ()); + LLDB_REGISTER_METHOD(const char *, SBTypeSynthetic, GetData, ()); + LLDB_REGISTER_METHOD(void, SBTypeSynthetic, SetClassName, (const char *)); + LLDB_REGISTER_METHOD(void, SBTypeSynthetic, SetClassCode, (const char *)); + LLDB_REGISTER_METHOD(uint32_t, SBTypeSynthetic, GetOptions, ()); + LLDB_REGISTER_METHOD(void, SBTypeSynthetic, SetOptions, (uint32_t)); + LLDB_REGISTER_METHOD(bool, SBTypeSynthetic, GetDescription, + (lldb::SBStream &, lldb::DescriptionLevel)); + LLDB_REGISTER_METHOD( + lldb::SBTypeSynthetic &, + SBTypeSynthetic, operator=,(const lldb::SBTypeSynthetic &)); + LLDB_REGISTER_METHOD(bool, + SBTypeSynthetic, operator==,(lldb::SBTypeSynthetic &)); + LLDB_REGISTER_METHOD(bool, SBTypeSynthetic, IsEqualTo, + (lldb::SBTypeSynthetic &)); + LLDB_REGISTER_METHOD(bool, + SBTypeSynthetic, operator!=,(lldb::SBTypeSynthetic &)); +} + +} +} diff --git a/source/API/SBUnixSignals.cpp b/source/API/SBUnixSignals.cpp index 14bdd39919c3c..277a92d21ae98 100644 --- a/source/API/SBUnixSignals.cpp +++ b/source/API/SBUnixSignals.cpp @@ -1,17 +1,16 @@ //===-- SBUnixSignals.cpp -------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// +#include "SBReproducerPrivate.h" #include "lldb/Target/Platform.h" #include "lldb/Target/Process.h" #include "lldb/Target/UnixSignals.h" -#include "lldb/Utility/Log.h" #include "lldb/lldb-defines.h" #include "lldb/API/SBUnixSignals.h" @@ -19,10 +18,14 @@ using namespace lldb; using namespace lldb_private; -SBUnixSignals::SBUnixSignals() {} +SBUnixSignals::SBUnixSignals() { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBUnixSignals); +} SBUnixSignals::SBUnixSignals(const SBUnixSignals &rhs) - : m_opaque_wp(rhs.m_opaque_wp) {} + : m_opaque_wp(rhs.m_opaque_wp) { + LLDB_RECORD_CONSTRUCTOR(SBUnixSignals, (const lldb::SBUnixSignals &), rhs); +} SBUnixSignals::SBUnixSignals(ProcessSP &process_sp) : m_opaque_wp(process_sp ? process_sp->GetUnixSignals() : nullptr) {} @@ -31,9 +34,13 @@ SBUnixSignals::SBUnixSignals(PlatformSP &platform_sp) : m_opaque_wp(platform_sp ? platform_sp->GetUnixSignals() : nullptr) {} const SBUnixSignals &SBUnixSignals::operator=(const SBUnixSignals &rhs) { + LLDB_RECORD_METHOD(const lldb::SBUnixSignals &, + SBUnixSignals, operator=,(const lldb::SBUnixSignals &), + rhs); + if (this != &rhs) m_opaque_wp = rhs.m_opaque_wp; - return *this; + return LLDB_RECORD_RESULT(*this); } SBUnixSignals::~SBUnixSignals() {} @@ -44,11 +51,26 @@ void SBUnixSignals::SetSP(const UnixSignalsSP &signals_sp) { m_opaque_wp = signals_sp; } -void SBUnixSignals::Clear() { m_opaque_wp.reset(); } +void SBUnixSignals::Clear() { + LLDB_RECORD_METHOD_NO_ARGS(void, SBUnixSignals, Clear); + + m_opaque_wp.reset(); +} + +bool SBUnixSignals::IsValid() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBUnixSignals, IsValid); + return this->operator bool(); +} +SBUnixSignals::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBUnixSignals, operator bool); -bool SBUnixSignals::IsValid() const { return static_cast<bool>(GetSP()); } + return static_cast<bool>(GetSP()); +} const char *SBUnixSignals::GetSignalAsCString(int32_t signo) const { + LLDB_RECORD_METHOD_CONST(const char *, SBUnixSignals, GetSignalAsCString, + (int32_t), signo); + if (auto signals_sp = GetSP()) return signals_sp->GetSignalAsCString(signo); @@ -56,6 +78,9 @@ const char *SBUnixSignals::GetSignalAsCString(int32_t signo) const { } int32_t SBUnixSignals::GetSignalNumberFromName(const char *name) const { + LLDB_RECORD_METHOD_CONST(int32_t, SBUnixSignals, GetSignalNumberFromName, + (const char *), name); + if (auto signals_sp = GetSP()) return signals_sp->GetSignalNumberFromName(name); @@ -63,6 +88,9 @@ int32_t SBUnixSignals::GetSignalNumberFromName(const char *name) const { } bool SBUnixSignals::GetShouldSuppress(int32_t signo) const { + LLDB_RECORD_METHOD_CONST(bool, SBUnixSignals, GetShouldSuppress, (int32_t), + signo); + if (auto signals_sp = GetSP()) return signals_sp->GetShouldSuppress(signo); @@ -70,13 +98,10 @@ bool SBUnixSignals::GetShouldSuppress(int32_t signo) const { } bool SBUnixSignals::SetShouldSuppress(int32_t signo, bool value) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - auto signals_sp = GetSP(); + LLDB_RECORD_METHOD(bool, SBUnixSignals, SetShouldSuppress, (int32_t, bool), + signo, value); - if (log) { - log->Printf("SBUnixSignals(%p)::SetShouldSuppress (signo=%d, value=%d)", - static_cast<void *>(signals_sp.get()), signo, value); - } + auto signals_sp = GetSP(); if (signals_sp) return signals_sp->SetShouldSuppress(signo, value); @@ -85,6 +110,9 @@ bool SBUnixSignals::SetShouldSuppress(int32_t signo, bool value) { } bool SBUnixSignals::GetShouldStop(int32_t signo) const { + LLDB_RECORD_METHOD_CONST(bool, SBUnixSignals, GetShouldStop, (int32_t), + signo); + if (auto signals_sp = GetSP()) return signals_sp->GetShouldStop(signo); @@ -92,13 +120,10 @@ bool SBUnixSignals::GetShouldStop(int32_t signo) const { } bool SBUnixSignals::SetShouldStop(int32_t signo, bool value) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - auto signals_sp = GetSP(); + LLDB_RECORD_METHOD(bool, SBUnixSignals, SetShouldStop, (int32_t, bool), signo, + value); - if (log) { - log->Printf("SBUnixSignals(%p)::SetShouldStop (signo=%d, value=%d)", - static_cast<void *>(signals_sp.get()), signo, value); - } + auto signals_sp = GetSP(); if (signals_sp) return signals_sp->SetShouldStop(signo, value); @@ -107,6 +132,9 @@ bool SBUnixSignals::SetShouldStop(int32_t signo, bool value) { } bool SBUnixSignals::GetShouldNotify(int32_t signo) const { + LLDB_RECORD_METHOD_CONST(bool, SBUnixSignals, GetShouldNotify, (int32_t), + signo); + if (auto signals_sp = GetSP()) return signals_sp->GetShouldNotify(signo); @@ -114,13 +142,10 @@ bool SBUnixSignals::GetShouldNotify(int32_t signo) const { } bool SBUnixSignals::SetShouldNotify(int32_t signo, bool value) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - auto signals_sp = GetSP(); + LLDB_RECORD_METHOD(bool, SBUnixSignals, SetShouldNotify, (int32_t, bool), + signo, value); - if (log) { - log->Printf("SBUnixSignals(%p)::SetShouldNotify (signo=%d, value=%d)", - static_cast<void *>(signals_sp.get()), signo, value); - } + auto signals_sp = GetSP(); if (signals_sp) return signals_sp->SetShouldNotify(signo, value); @@ -129,6 +154,8 @@ bool SBUnixSignals::SetShouldNotify(int32_t signo, bool value) { } int32_t SBUnixSignals::GetNumSignals() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(int32_t, SBUnixSignals, GetNumSignals); + if (auto signals_sp = GetSP()) return signals_sp->GetNumSignals(); @@ -136,8 +163,44 @@ int32_t SBUnixSignals::GetNumSignals() const { } int32_t SBUnixSignals::GetSignalAtIndex(int32_t index) const { + LLDB_RECORD_METHOD_CONST(int32_t, SBUnixSignals, GetSignalAtIndex, (int32_t), + index); + if (auto signals_sp = GetSP()) return signals_sp->GetSignalAtIndex(index); return LLDB_INVALID_SIGNAL_NUMBER; } + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBUnixSignals>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBUnixSignals, ()); + LLDB_REGISTER_CONSTRUCTOR(SBUnixSignals, (const lldb::SBUnixSignals &)); + LLDB_REGISTER_METHOD( + const lldb::SBUnixSignals &, + SBUnixSignals, operator=,(const lldb::SBUnixSignals &)); + LLDB_REGISTER_METHOD(void, SBUnixSignals, Clear, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBUnixSignals, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBUnixSignals, operator bool, ()); + LLDB_REGISTER_METHOD_CONST(const char *, SBUnixSignals, GetSignalAsCString, + (int32_t)); + LLDB_REGISTER_METHOD_CONST(int32_t, SBUnixSignals, GetSignalNumberFromName, + (const char *)); + LLDB_REGISTER_METHOD_CONST(bool, SBUnixSignals, GetShouldSuppress, + (int32_t)); + LLDB_REGISTER_METHOD(bool, SBUnixSignals, SetShouldSuppress, + (int32_t, bool)); + LLDB_REGISTER_METHOD_CONST(bool, SBUnixSignals, GetShouldStop, (int32_t)); + LLDB_REGISTER_METHOD(bool, SBUnixSignals, SetShouldStop, (int32_t, bool)); + LLDB_REGISTER_METHOD_CONST(bool, SBUnixSignals, GetShouldNotify, (int32_t)); + LLDB_REGISTER_METHOD(bool, SBUnixSignals, SetShouldNotify, (int32_t, bool)); + LLDB_REGISTER_METHOD_CONST(int32_t, SBUnixSignals, GetNumSignals, ()); + LLDB_REGISTER_METHOD_CONST(int32_t, SBUnixSignals, GetSignalAtIndex, + (int32_t)); +} + +} +} diff --git a/source/API/SBValue.cpp b/source/API/SBValue.cpp index a61a2a19a6216..8383007635229 100644 --- a/source/API/SBValue.cpp +++ b/source/API/SBValue.cpp @@ -1,13 +1,13 @@ //===-- SBValue.cpp ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBValue.h" +#include "SBReproducerPrivate.h" #include "lldb/API/SBDeclaration.h" #include "lldb/API/SBStream.h" @@ -36,7 +36,6 @@ #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/DataExtractor.h" -#include "lldb/Utility/Log.h" #include "lldb/Utility/Scalar.h" #include "lldb/Utility/Stream.h" @@ -47,6 +46,8 @@ #include "lldb/API/SBTarget.h" #include "lldb/API/SBThread.h" +#include <memory> + using namespace lldb; using namespace lldb_private; @@ -56,7 +57,7 @@ public: ValueImpl(lldb::ValueObjectSP in_valobj_sp, lldb::DynamicValueType use_dynamic, bool use_synthetic, - const char *name = NULL) + const char *name = nullptr) : m_valobj_sp(), m_use_dynamic(use_dynamic), m_use_synthetic(use_synthetic), m_name(name) { if (in_valobj_sp) { @@ -83,7 +84,7 @@ public: } bool IsValid() { - if (m_valobj_sp.get() == NULL) + if (m_valobj_sp.get() == nullptr) return false; else { // FIXME: This check is necessary but not sufficient. We for sure don't @@ -107,7 +108,6 @@ public: lldb::ValueObjectSP GetSP(Process::StopLocker &stop_locker, std::unique_lock<std::recursive_mutex> &lock, Status &error) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); if (!m_valobj_sp) { error.SetErrorString("invalid value object"); return m_valobj_sp; @@ -126,9 +126,6 @@ public: // We don't allow people to play around with ValueObject if the process // is running. If you want to look at values, pause the process, then // look. - if (log) - log->Printf("SBValue(%p)::GetSP() => error: process is running", - static_cast<void *>(value_sp.get())); error.SetErrorString("process must be stopped."); return ValueObjectSP(); } @@ -218,32 +215,55 @@ private: Status m_lock_error; }; -SBValue::SBValue() : m_opaque_sp() {} +SBValue::SBValue() : m_opaque_sp() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBValue); } + +SBValue::SBValue(const lldb::ValueObjectSP &value_sp) { + LLDB_RECORD_CONSTRUCTOR(SBValue, (const lldb::ValueObjectSP &), value_sp); -SBValue::SBValue(const lldb::ValueObjectSP &value_sp) { SetSP(value_sp); } + SetSP(value_sp); +} + +SBValue::SBValue(const SBValue &rhs) { + LLDB_RECORD_CONSTRUCTOR(SBValue, (const lldb::SBValue &), rhs); -SBValue::SBValue(const SBValue &rhs) { SetSP(rhs.m_opaque_sp); } + SetSP(rhs.m_opaque_sp); +} SBValue &SBValue::operator=(const SBValue &rhs) { + LLDB_RECORD_METHOD(lldb::SBValue &, + SBValue, operator=,(const lldb::SBValue &), rhs); + if (this != &rhs) { SetSP(rhs.m_opaque_sp); } - return *this; + return LLDB_RECORD_RESULT(*this); } SBValue::~SBValue() {} bool SBValue::IsValid() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBValue, IsValid); + return this->operator bool(); +} +SBValue::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBValue, operator bool); + // If this function ever changes to anything that does more than just check // if the opaque shared pointer is non NULL, then we need to update all "if // (m_opaque_sp)" code in this file. - return m_opaque_sp.get() != NULL && m_opaque_sp->IsValid() && - m_opaque_sp->GetRootSP().get() != NULL; + return m_opaque_sp.get() != nullptr && m_opaque_sp->IsValid() && + m_opaque_sp->GetRootSP().get() != nullptr; } -void SBValue::Clear() { m_opaque_sp.reset(); } +void SBValue::Clear() { + LLDB_RECORD_METHOD_NO_ARGS(void, SBValue, Clear); + + m_opaque_sp.reset(); +} SBError SBValue::GetError() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBValue, GetError); + SBError sb_error; ValueLocker locker; @@ -254,10 +274,12 @@ SBError SBValue::GetError() { sb_error.SetErrorStringWithFormat("error: %s", locker.GetError().AsCString()); - return sb_error; + return LLDB_RECORD_RESULT(sb_error); } user_id_t SBValue::GetID() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::user_id_t, SBValue, GetID); + ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); if (value_sp) @@ -266,69 +288,46 @@ user_id_t SBValue::GetID() { } const char *SBValue::GetName() { - const char *name = NULL; + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBValue, GetName); + + const char *name = nullptr; ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); if (value_sp) name = value_sp->GetName().GetCString(); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) { - if (name) - log->Printf("SBValue(%p)::GetName () => \"%s\"", - static_cast<void *>(value_sp.get()), name); - else - log->Printf("SBValue(%p)::GetName () => NULL", - static_cast<void *>(value_sp.get())); - } - return name; } const char *SBValue::GetTypeName() { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - const char *name = NULL; + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBValue, GetTypeName); + + const char *name = nullptr; ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); if (value_sp) { name = value_sp->GetQualifiedTypeName().GetCString(); } - if (log) { - if (name) - log->Printf("SBValue(%p)::GetTypeName () => \"%s\"", - static_cast<void *>(value_sp.get()), name); - else - log->Printf("SBValue(%p)::GetTypeName () => NULL", - static_cast<void *>(value_sp.get())); - } - return name; } const char *SBValue::GetDisplayTypeName() { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - const char *name = NULL; + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBValue, GetDisplayTypeName); + + const char *name = nullptr; ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); if (value_sp) { name = value_sp->GetDisplayTypeName().GetCString(); } - if (log) { - if (name) - log->Printf("SBValue(%p)::GetTypeName () => \"%s\"", - static_cast<void *>(value_sp.get()), name); - else - log->Printf("SBValue(%p)::GetTypeName () => NULL", - static_cast<void *>(value_sp.get())); - } - return name; } size_t SBValue::GetByteSize() { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_NO_ARGS(size_t, SBValue, GetByteSize); + size_t result = 0; ValueLocker locker; @@ -337,15 +336,12 @@ size_t SBValue::GetByteSize() { result = value_sp->GetByteSize(); } - if (log) - log->Printf("SBValue(%p)::GetByteSize () => %" PRIu64, - static_cast<void *>(value_sp.get()), - static_cast<uint64_t>(result)); - return result; } bool SBValue::IsInScope() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBValue, IsInScope); + bool result = false; ValueLocker locker; @@ -354,109 +350,51 @@ bool SBValue::IsInScope() { result = value_sp->IsInScope(); } - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBValue(%p)::IsInScope () => %i", - static_cast<void *>(value_sp.get()), result); - return result; } const char *SBValue::GetValue() { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBValue, GetValue); - const char *cstr = NULL; + const char *cstr = nullptr; ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); if (value_sp) { cstr = value_sp->GetValueAsCString(); } - if (log) { - if (cstr) - log->Printf("SBValue(%p)::GetValue() => \"%s\"", - static_cast<void *>(value_sp.get()), cstr); - else - log->Printf("SBValue(%p)::GetValue() => NULL", - static_cast<void *>(value_sp.get())); - } return cstr; } ValueType SBValue::GetValueType() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::ValueType, SBValue, GetValueType); + ValueType result = eValueTypeInvalid; ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); if (value_sp) result = value_sp->GetValueType(); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) { - switch (result) { - case eValueTypeInvalid: - log->Printf("SBValue(%p)::GetValueType () => eValueTypeInvalid", - static_cast<void *>(value_sp.get())); - break; - case eValueTypeVariableGlobal: - log->Printf("SBValue(%p)::GetValueType () => eValueTypeVariableGlobal", - static_cast<void *>(value_sp.get())); - break; - case eValueTypeVariableStatic: - log->Printf("SBValue(%p)::GetValueType () => eValueTypeVariableStatic", - static_cast<void *>(value_sp.get())); - break; - case eValueTypeVariableArgument: - log->Printf("SBValue(%p)::GetValueType () => eValueTypeVariableArgument", - static_cast<void *>(value_sp.get())); - break; - case eValueTypeVariableLocal: - log->Printf("SBValue(%p)::GetValueType () => eValueTypeVariableLocal", - static_cast<void *>(value_sp.get())); - break; - case eValueTypeRegister: - log->Printf("SBValue(%p)::GetValueType () => eValueTypeRegister", - static_cast<void *>(value_sp.get())); - break; - case eValueTypeRegisterSet: - log->Printf("SBValue(%p)::GetValueType () => eValueTypeRegisterSet", - static_cast<void *>(value_sp.get())); - break; - case eValueTypeConstResult: - log->Printf("SBValue(%p)::GetValueType () => eValueTypeConstResult", - static_cast<void *>(value_sp.get())); - break; - case eValueTypeVariableThreadLocal: - log->Printf( - "SBValue(%p)::GetValueType () => eValueTypeVariableThreadLocal", - static_cast<void *>(value_sp.get())); - break; - } - } return result; } const char *SBValue::GetObjectDescription() { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - const char *cstr = NULL; + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBValue, GetObjectDescription); + + const char *cstr = nullptr; ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); if (value_sp) { cstr = value_sp->GetObjectDescription(); } - if (log) { - if (cstr) - log->Printf("SBValue(%p)::GetObjectDescription() => \"%s\"", - static_cast<void *>(value_sp.get()), cstr); - else - log->Printf("SBValue(%p)::GetObjectDescription() => NULL", - static_cast<void *>(value_sp.get())); - } + return cstr; } const char *SBValue::GetTypeValidatorResult() { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - const char *cstr = NULL; + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBValue, GetTypeValidatorResult); + + const char *cstr = nullptr; ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); if (value_sp) { @@ -468,41 +406,28 @@ const char *SBValue::GetTypeValidatorResult() { cstr = validation.second.c_str(); } } - if (log) { - if (cstr) - log->Printf("SBValue(%p)::GetTypeValidatorResult() => \"%s\"", - static_cast<void *>(value_sp.get()), cstr); - else - log->Printf("SBValue(%p)::GetTypeValidatorResult() => NULL", - static_cast<void *>(value_sp.get())); - } + return cstr; } SBType SBValue::GetType() { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBValue, GetType); + SBType sb_type; ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); TypeImplSP type_sp; if (value_sp) { - type_sp.reset(new TypeImpl(value_sp->GetTypeImpl())); + type_sp = std::make_shared<TypeImpl>(value_sp->GetTypeImpl()); sb_type.SetSP(type_sp); } - if (log) { - if (type_sp) - log->Printf("SBValue(%p)::GetType => SBType(%p)", - static_cast<void *>(value_sp.get()), - static_cast<void *>(type_sp.get())); - else - log->Printf("SBValue(%p)::GetType => NULL", - static_cast<void *>(value_sp.get())); - } - return sb_type; + + return LLDB_RECORD_RESULT(sb_type); } bool SBValue::GetValueDidChange() { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_NO_ARGS(bool, SBValue, GetValueDidChange); + bool result = false; ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); @@ -510,35 +435,29 @@ bool SBValue::GetValueDidChange() { if (value_sp->UpdateValueIfNeeded(false)) result = value_sp->GetValueDidChange(); } - if (log) - log->Printf("SBValue(%p)::GetValueDidChange() => %i", - static_cast<void *>(value_sp.get()), result); return result; } const char *SBValue::GetSummary() { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - const char *cstr = NULL; + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBValue, GetSummary); + + const char *cstr = nullptr; ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); if (value_sp) { cstr = value_sp->GetSummaryAsCString(); } - if (log) { - if (cstr) - log->Printf("SBValue(%p)::GetSummary() => \"%s\"", - static_cast<void *>(value_sp.get()), cstr); - else - log->Printf("SBValue(%p)::GetSummary() => NULL", - static_cast<void *>(value_sp.get())); - } + return cstr; } const char *SBValue::GetSummary(lldb::SBStream &stream, lldb::SBTypeSummaryOptions &options) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(const char *, SBValue, GetSummary, + (lldb::SBStream &, lldb::SBTypeSummaryOptions &), stream, + options); + ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); if (value_sp) { @@ -547,61 +466,49 @@ const char *SBValue::GetSummary(lldb::SBStream &stream, stream.Printf("%s", buffer.c_str()); } const char *cstr = stream.GetData(); - if (log) { - if (cstr) - log->Printf("SBValue(%p)::GetSummary() => \"%s\"", - static_cast<void *>(value_sp.get()), cstr); - else - log->Printf("SBValue(%p)::GetSummary() => NULL", - static_cast<void *>(value_sp.get())); - } return cstr; } const char *SBValue::GetLocation() { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - const char *cstr = NULL; + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBValue, GetLocation); + + const char *cstr = nullptr; ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); if (value_sp) { cstr = value_sp->GetLocationAsCString(); } - if (log) { - if (cstr) - log->Printf("SBValue(%p)::GetLocation() => \"%s\"", - static_cast<void *>(value_sp.get()), cstr); - else - log->Printf("SBValue(%p)::GetLocation() => NULL", - static_cast<void *>(value_sp.get())); - } return cstr; } // Deprecated - use the one that takes an lldb::SBError bool SBValue::SetValueFromCString(const char *value_str) { + LLDB_RECORD_METHOD(bool, SBValue, SetValueFromCString, (const char *), + value_str); + lldb::SBError dummy; return SetValueFromCString(value_str, dummy); } bool SBValue::SetValueFromCString(const char *value_str, lldb::SBError &error) { + LLDB_RECORD_METHOD(bool, SBValue, SetValueFromCString, + (const char *, lldb::SBError &), value_str, error); + bool success = false; ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); if (value_sp) { success = value_sp->SetValueFromCString(value_str, error.ref()); } else error.SetErrorStringWithFormat("Could not get value: %s", locker.GetError().AsCString()); - if (log) - log->Printf("SBValue(%p)::SetValueFromCString(\"%s\") => %i", - static_cast<void *>(value_sp.get()), value_str, success); - return success; } lldb::SBTypeFormat SBValue::GetTypeFormat() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTypeFormat, SBValue, GetTypeFormat); + lldb::SBTypeFormat format; ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); @@ -612,10 +519,12 @@ lldb::SBTypeFormat SBValue::GetTypeFormat() { format.SetSP(format_sp); } } - return format; + return LLDB_RECORD_RESULT(format); } lldb::SBTypeSummary SBValue::GetTypeSummary() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTypeSummary, SBValue, GetTypeSummary); + lldb::SBTypeSummary summary; ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); @@ -626,10 +535,12 @@ lldb::SBTypeSummary SBValue::GetTypeSummary() { summary.SetSP(summary_sp); } } - return summary; + return LLDB_RECORD_RESULT(summary); } lldb::SBTypeFilter SBValue::GetTypeFilter() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTypeFilter, SBValue, GetTypeFilter); + lldb::SBTypeFilter filter; ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); @@ -644,11 +555,12 @@ lldb::SBTypeFilter SBValue::GetTypeFilter() { } } } - return filter; + return LLDB_RECORD_RESULT(filter); } -#ifndef LLDB_DISABLE_PYTHON lldb::SBTypeSynthetic SBValue::GetTypeSynthetic() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTypeSynthetic, SBValue, GetTypeSynthetic); + lldb::SBTypeSynthetic synthetic; ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); @@ -663,12 +575,15 @@ lldb::SBTypeSynthetic SBValue::GetTypeSynthetic() { } } } - return synthetic; + return LLDB_RECORD_RESULT(synthetic); } -#endif lldb::SBValue SBValue::CreateChildAtOffset(const char *name, uint32_t offset, SBType type) { + LLDB_RECORD_METHOD(lldb::SBValue, SBValue, CreateChildAtOffset, + (const char *, uint32_t, lldb::SBType), name, offset, + type); + lldb::SBValue sb_value; ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); @@ -681,20 +596,12 @@ lldb::SBValue SBValue::CreateChildAtOffset(const char *name, uint32_t offset, GetPreferDynamicValue(), GetPreferSyntheticValue(), name); } } - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) { - if (new_value_sp) - log->Printf("SBValue(%p)::CreateChildAtOffset => \"%s\"", - static_cast<void *>(value_sp.get()), - new_value_sp->GetName().AsCString()); - else - log->Printf("SBValue(%p)::CreateChildAtOffset => NULL", - static_cast<void *>(value_sp.get())); - } - return sb_value; + return LLDB_RECORD_RESULT(sb_value); } lldb::SBValue SBValue::Cast(SBType type) { + LLDB_RECORD_METHOD(lldb::SBValue, SBValue, Cast, (lldb::SBType), type); + lldb::SBValue sb_value; ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); @@ -702,20 +609,27 @@ lldb::SBValue SBValue::Cast(SBType type) { if (value_sp && type_sp) sb_value.SetSP(value_sp->Cast(type_sp->GetCompilerType(false)), GetPreferDynamicValue(), GetPreferSyntheticValue()); - return sb_value; + return LLDB_RECORD_RESULT(sb_value); } lldb::SBValue SBValue::CreateValueFromExpression(const char *name, const char *expression) { + LLDB_RECORD_METHOD(lldb::SBValue, SBValue, CreateValueFromExpression, + (const char *, const char *), name, expression); + SBExpressionOptions options; options.ref().SetKeepInMemory(true); - return CreateValueFromExpression(name, expression, options); + return LLDB_RECORD_RESULT( + CreateValueFromExpression(name, expression, options)); } lldb::SBValue SBValue::CreateValueFromExpression(const char *name, const char *expression, SBExpressionOptions &options) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(lldb::SBValue, SBValue, CreateValueFromExpression, + (const char *, const char *, lldb::SBExpressionOptions &), + name, expression, options); + lldb::SBValue sb_value; ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); @@ -728,23 +642,16 @@ lldb::SBValue SBValue::CreateValueFromExpression(const char *name, new_value_sp->SetName(ConstString(name)); } sb_value.SetSP(new_value_sp); - if (log) { - if (new_value_sp) - log->Printf("SBValue(%p)::CreateValueFromExpression(name=\"%s\", " - "expression=\"%s\") => SBValue (%p)", - static_cast<void *>(value_sp.get()), name, expression, - static_cast<void *>(new_value_sp.get())); - else - log->Printf("SBValue(%p)::CreateValueFromExpression(name=\"%s\", " - "expression=\"%s\") => NULL", - static_cast<void *>(value_sp.get()), name, expression); - } - return sb_value; + return LLDB_RECORD_RESULT(sb_value); } lldb::SBValue SBValue::CreateValueFromAddress(const char *name, lldb::addr_t address, SBType sb_type) { + LLDB_RECORD_METHOD(lldb::SBValue, SBValue, CreateValueFromAddress, + (const char *, lldb::addr_t, lldb::SBType), name, address, + sb_type); + lldb::SBValue sb_value; ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); @@ -757,21 +664,15 @@ lldb::SBValue SBValue::CreateValueFromAddress(const char *name, exe_ctx, ast_type); } sb_value.SetSP(new_value_sp); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) { - if (new_value_sp) - log->Printf("SBValue(%p)::CreateValueFromAddress => \"%s\"", - static_cast<void *>(value_sp.get()), - new_value_sp->GetName().AsCString()); - else - log->Printf("SBValue(%p)::CreateValueFromAddress => NULL", - static_cast<void *>(value_sp.get())); - } - return sb_value; + return LLDB_RECORD_RESULT(sb_value); } lldb::SBValue SBValue::CreateValueFromData(const char *name, SBData data, SBType sb_type) { + LLDB_RECORD_METHOD(lldb::SBValue, SBValue, CreateValueFromData, + (const char *, lldb::SBData, lldb::SBType), name, data, + sb_type); + lldb::SBValue sb_value; lldb::ValueObjectSP new_value_sp; ValueLocker locker; @@ -784,20 +685,12 @@ lldb::SBValue SBValue::CreateValueFromData(const char *name, SBData data, new_value_sp->SetAddressTypeOfChildren(eAddressTypeLoad); } sb_value.SetSP(new_value_sp); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) { - if (new_value_sp) - log->Printf("SBValue(%p)::CreateValueFromData => \"%s\"", - static_cast<void *>(value_sp.get()), - new_value_sp->GetName().AsCString()); - else - log->Printf("SBValue(%p)::CreateValueFromData => NULL", - static_cast<void *>(value_sp.get())); - } - return sb_value; + return LLDB_RECORD_RESULT(sb_value); } SBValue SBValue::GetChildAtIndex(uint32_t idx) { + LLDB_RECORD_METHOD(lldb::SBValue, SBValue, GetChildAtIndex, (uint32_t), idx); + const bool can_create_synthetic = false; lldb::DynamicValueType use_dynamic = eNoDynamicValues; TargetSP target_sp; @@ -807,14 +700,18 @@ SBValue SBValue::GetChildAtIndex(uint32_t idx) { if (target_sp) use_dynamic = target_sp->GetPreferDynamicValue(); - return GetChildAtIndex(idx, use_dynamic, can_create_synthetic); + return LLDB_RECORD_RESULT( + GetChildAtIndex(idx, use_dynamic, can_create_synthetic)); } SBValue SBValue::GetChildAtIndex(uint32_t idx, lldb::DynamicValueType use_dynamic, bool can_create_synthetic) { + LLDB_RECORD_METHOD(lldb::SBValue, SBValue, GetChildAtIndex, + (uint32_t, lldb::DynamicValueType, bool), idx, use_dynamic, + can_create_synthetic); + lldb::ValueObjectSP child_sp; - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); @@ -828,35 +725,27 @@ SBValue SBValue::GetChildAtIndex(uint32_t idx, SBValue sb_value; sb_value.SetSP(child_sp, use_dynamic, GetPreferSyntheticValue()); - if (log) - log->Printf("SBValue(%p)::GetChildAtIndex (%u) => SBValue(%p)", - static_cast<void *>(value_sp.get()), idx, - static_cast<void *>(value_sp.get())); - return sb_value; + return LLDB_RECORD_RESULT(sb_value); } uint32_t SBValue::GetIndexOfChildWithName(const char *name) { + LLDB_RECORD_METHOD(uint32_t, SBValue, GetIndexOfChildWithName, (const char *), + name); + uint32_t idx = UINT32_MAX; ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); if (value_sp) { idx = value_sp->GetIndexOfChildWithName(ConstString(name)); } - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) { - if (idx == UINT32_MAX) - log->Printf( - "SBValue(%p)::GetIndexOfChildWithName (name=\"%s\") => NOT FOUND", - static_cast<void *>(value_sp.get()), name); - else - log->Printf("SBValue(%p)::GetIndexOfChildWithName (name=\"%s\") => %u", - static_cast<void *>(value_sp.get()), name, idx); - } return idx; } SBValue SBValue::GetChildMemberWithName(const char *name) { + LLDB_RECORD_METHOD(lldb::SBValue, SBValue, GetChildMemberWithName, + (const char *), name); + lldb::DynamicValueType use_dynamic_value = eNoDynamicValues; TargetSP target_sp; if (m_opaque_sp) @@ -864,17 +753,19 @@ SBValue SBValue::GetChildMemberWithName(const char *name) { if (target_sp) use_dynamic_value = target_sp->GetPreferDynamicValue(); - return GetChildMemberWithName(name, use_dynamic_value); + return LLDB_RECORD_RESULT(GetChildMemberWithName(name, use_dynamic_value)); } SBValue SBValue::GetChildMemberWithName(const char *name, lldb::DynamicValueType use_dynamic_value) { + LLDB_RECORD_METHOD(lldb::SBValue, SBValue, GetChildMemberWithName, + (const char *, lldb::DynamicValueType), name, + use_dynamic_value); + lldb::ValueObjectSP child_sp; const ConstString str_name(name); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); if (value_sp) { @@ -884,26 +775,25 @@ SBValue::GetChildMemberWithName(const char *name, SBValue sb_value; sb_value.SetSP(child_sp, use_dynamic_value, GetPreferSyntheticValue()); - if (log) - log->Printf( - "SBValue(%p)::GetChildMemberWithName (name=\"%s\") => SBValue(%p)", - static_cast<void *>(value_sp.get()), name, - static_cast<void *>(value_sp.get())); - - return sb_value; + return LLDB_RECORD_RESULT(sb_value); } lldb::SBValue SBValue::GetDynamicValue(lldb::DynamicValueType use_dynamic) { + LLDB_RECORD_METHOD(lldb::SBValue, SBValue, GetDynamicValue, + (lldb::DynamicValueType), use_dynamic); + SBValue value_sb; if (IsValid()) { ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(), use_dynamic, m_opaque_sp->GetUseSynthetic())); value_sb.SetSP(proxy_sp); } - return value_sb; + return LLDB_RECORD_RESULT(value_sb); } lldb::SBValue SBValue::GetStaticValue() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBValue, SBValue, GetStaticValue); + SBValue value_sb; if (IsValid()) { ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(), @@ -911,42 +801,57 @@ lldb::SBValue SBValue::GetStaticValue() { m_opaque_sp->GetUseSynthetic())); value_sb.SetSP(proxy_sp); } - return value_sb; + return LLDB_RECORD_RESULT(value_sb); } lldb::SBValue SBValue::GetNonSyntheticValue() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBValue, SBValue, GetNonSyntheticValue); + SBValue value_sb; if (IsValid()) { ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(), m_opaque_sp->GetUseDynamic(), false)); value_sb.SetSP(proxy_sp); } - return value_sb; + return LLDB_RECORD_RESULT(value_sb); } lldb::DynamicValueType SBValue::GetPreferDynamicValue() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::DynamicValueType, SBValue, + GetPreferDynamicValue); + if (!IsValid()) return eNoDynamicValues; return m_opaque_sp->GetUseDynamic(); } void SBValue::SetPreferDynamicValue(lldb::DynamicValueType use_dynamic) { + LLDB_RECORD_METHOD(void, SBValue, SetPreferDynamicValue, + (lldb::DynamicValueType), use_dynamic); + if (IsValid()) return m_opaque_sp->SetUseDynamic(use_dynamic); } bool SBValue::GetPreferSyntheticValue() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBValue, GetPreferSyntheticValue); + if (!IsValid()) return false; return m_opaque_sp->GetUseSynthetic(); } void SBValue::SetPreferSyntheticValue(bool use_synthetic) { + LLDB_RECORD_METHOD(void, SBValue, SetPreferSyntheticValue, (bool), + use_synthetic); + if (IsValid()) return m_opaque_sp->SetUseSynthetic(use_synthetic); } bool SBValue::IsDynamic() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBValue, IsDynamic); + ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); if (value_sp) @@ -955,6 +860,8 @@ bool SBValue::IsDynamic() { } bool SBValue::IsSynthetic() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBValue, IsSynthetic); + ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); if (value_sp) @@ -963,6 +870,8 @@ bool SBValue::IsSynthetic() { } bool SBValue::IsSyntheticChildrenGenerated() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBValue, IsSyntheticChildrenGenerated); + ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); if (value_sp) @@ -971,6 +880,8 @@ bool SBValue::IsSyntheticChildrenGenerated() { } void SBValue::SetSyntheticChildrenGenerated(bool is) { + LLDB_RECORD_METHOD(void, SBValue, SetSyntheticChildrenGenerated, (bool), is); + ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); if (value_sp) @@ -978,7 +889,9 @@ void SBValue::SetSyntheticChildrenGenerated(bool is) { } lldb::SBValue SBValue::GetValueForExpressionPath(const char *expr_path) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(lldb::SBValue, SBValue, GetValueForExpressionPath, + (const char *), expr_path); + lldb::ValueObjectSP child_sp; ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); @@ -990,16 +903,13 @@ lldb::SBValue SBValue::GetValueForExpressionPath(const char *expr_path) { SBValue sb_value; sb_value.SetSP(child_sp, GetPreferDynamicValue(), GetPreferSyntheticValue()); - if (log) - log->Printf("SBValue(%p)::GetValueForExpressionPath (expr_path=\"%s\") => " - "SBValue(%p)", - static_cast<void *>(value_sp.get()), expr_path, - static_cast<void *>(value_sp.get())); - - return sb_value; + return LLDB_RECORD_RESULT(sb_value); } int64_t SBValue::GetValueAsSigned(SBError &error, int64_t fail_value) { + LLDB_RECORD_METHOD(int64_t, SBValue, GetValueAsSigned, + (lldb::SBError &, int64_t), error, fail_value); + error.Clear(); ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); @@ -1018,6 +928,9 @@ int64_t SBValue::GetValueAsSigned(SBError &error, int64_t fail_value) { } uint64_t SBValue::GetValueAsUnsigned(SBError &error, uint64_t fail_value) { + LLDB_RECORD_METHOD(uint64_t, SBValue, GetValueAsUnsigned, + (lldb::SBError &, uint64_t), error, fail_value); + error.Clear(); ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); @@ -1036,6 +949,8 @@ uint64_t SBValue::GetValueAsUnsigned(SBError &error, uint64_t fail_value) { } int64_t SBValue::GetValueAsSigned(int64_t fail_value) { + LLDB_RECORD_METHOD(int64_t, SBValue, GetValueAsSigned, (int64_t), fail_value); + ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); if (value_sp) { @@ -1045,6 +960,9 @@ int64_t SBValue::GetValueAsSigned(int64_t fail_value) { } uint64_t SBValue::GetValueAsUnsigned(uint64_t fail_value) { + LLDB_RECORD_METHOD(uint64_t, SBValue, GetValueAsUnsigned, (uint64_t), + fail_value); + ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); if (value_sp) { @@ -1054,52 +972,51 @@ uint64_t SBValue::GetValueAsUnsigned(uint64_t fail_value) { } bool SBValue::MightHaveChildren() { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_NO_ARGS(bool, SBValue, MightHaveChildren); + bool has_children = false; ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); if (value_sp) has_children = value_sp->MightHaveChildren(); - if (log) - log->Printf("SBValue(%p)::MightHaveChildren() => %i", - static_cast<void *>(value_sp.get()), has_children); return has_children; } bool SBValue::IsRuntimeSupportValue() { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_NO_ARGS(bool, SBValue, IsRuntimeSupportValue); + bool is_support = false; ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); if (value_sp) is_support = value_sp->IsRuntimeSupportValue(); - if (log) - log->Printf("SBValue(%p)::IsRuntimeSupportValue() => %i", - static_cast<void *>(value_sp.get()), is_support); return is_support; } -uint32_t SBValue::GetNumChildren() { return GetNumChildren(UINT32_MAX); } +uint32_t SBValue::GetNumChildren() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBValue, GetNumChildren); + + return GetNumChildren(UINT32_MAX); +} uint32_t SBValue::GetNumChildren(uint32_t max) { + LLDB_RECORD_METHOD(uint32_t, SBValue, GetNumChildren, (uint32_t), max); + uint32_t num_children = 0; - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); if (value_sp) num_children = value_sp->GetNumChildren(max); - if (log) - log->Printf("SBValue(%p)::GetNumChildren (%u) => %u", - static_cast<void *>(value_sp.get()), max, num_children); - return num_children; } SBValue SBValue::Dereference() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBValue, SBValue, Dereference); + SBValue sb_value; ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); @@ -1107,104 +1024,77 @@ SBValue SBValue::Dereference() { Status error; sb_value = value_sp->Dereference(error); } - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBValue(%p)::Dereference () => SBValue(%p)", - static_cast<void *>(value_sp.get()), - static_cast<void *>(value_sp.get())); - return sb_value; + return LLDB_RECORD_RESULT(sb_value); } // Deprecated - please use GetType().IsPointerType() instead. -bool SBValue::TypeIsPointerType() { return GetType().IsPointerType(); } +bool SBValue::TypeIsPointerType() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBValue, TypeIsPointerType); + + return GetType().IsPointerType(); +} void *SBValue::GetOpaqueType() { + LLDB_RECORD_METHOD_NO_ARGS(void *, SBValue, GetOpaqueType); + ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); if (value_sp) return value_sp->GetCompilerType().GetOpaqueQualType(); - return NULL; + return nullptr; } lldb::SBTarget SBValue::GetTarget() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTarget, SBValue, GetTarget); + SBTarget sb_target; TargetSP target_sp; if (m_opaque_sp) { target_sp = m_opaque_sp->GetTargetSP(); sb_target.SetSP(target_sp); } - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) { - if (target_sp.get() == NULL) - log->Printf("SBValue(%p)::GetTarget () => NULL", - static_cast<void *>(m_opaque_sp.get())); - else - log->Printf("SBValue(%p)::GetTarget () => %p", - static_cast<void *>(m_opaque_sp.get()), - static_cast<void *>(target_sp.get())); - } - return sb_target; + + return LLDB_RECORD_RESULT(sb_target); } lldb::SBProcess SBValue::GetProcess() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBProcess, SBValue, GetProcess); + SBProcess sb_process; ProcessSP process_sp; if (m_opaque_sp) { process_sp = m_opaque_sp->GetProcessSP(); sb_process.SetSP(process_sp); } - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) { - if (process_sp.get() == NULL) - log->Printf("SBValue(%p)::GetProcess () => NULL", - static_cast<void *>(m_opaque_sp.get())); - else - log->Printf("SBValue(%p)::GetProcess () => %p", - static_cast<void *>(m_opaque_sp.get()), - static_cast<void *>(process_sp.get())); - } - return sb_process; + + return LLDB_RECORD_RESULT(sb_process); } lldb::SBThread SBValue::GetThread() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBThread, SBValue, GetThread); + SBThread sb_thread; ThreadSP thread_sp; if (m_opaque_sp) { thread_sp = m_opaque_sp->GetThreadSP(); sb_thread.SetThread(thread_sp); } - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) { - if (thread_sp.get() == NULL) - log->Printf("SBValue(%p)::GetThread () => NULL", - static_cast<void *>(m_opaque_sp.get())); - else - log->Printf("SBValue(%p)::GetThread () => %p", - static_cast<void *>(m_opaque_sp.get()), - static_cast<void *>(thread_sp.get())); - } - return sb_thread; + + return LLDB_RECORD_RESULT(sb_thread); } lldb::SBFrame SBValue::GetFrame() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFrame, SBValue, GetFrame); + SBFrame sb_frame; StackFrameSP frame_sp; if (m_opaque_sp) { frame_sp = m_opaque_sp->GetFrameSP(); sb_frame.SetFrameSP(frame_sp); } - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) { - if (frame_sp.get() == NULL) - log->Printf("SBValue(%p)::GetFrame () => NULL", - static_cast<void *>(m_opaque_sp.get())); - else - log->Printf("SBValue(%p)::GetFrame () => %p", - static_cast<void *>(m_opaque_sp.get()), - static_cast<void *>(frame_sp.get())); - } - return sb_frame; + + return LLDB_RECORD_RESULT(sb_frame); } lldb::ValueObjectSP SBValue::GetSP(ValueLocker &locker) const { @@ -1216,8 +1106,10 @@ lldb::ValueObjectSP SBValue::GetSP(ValueLocker &locker) const { } lldb::ValueObjectSP SBValue::GetSP() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::ValueObjectSP, SBValue, GetSP); + ValueLocker locker; - return GetSP(locker); + return LLDB_RECORD_RESULT(GetSP(locker)); } void SBValue::SetSP(ValueImplSP impl_sp) { m_opaque_sp = impl_sp; } @@ -1275,6 +1167,9 @@ void SBValue::SetSP(const lldb::ValueObjectSP &sp, } bool SBValue::GetExpressionPath(SBStream &description) { + LLDB_RECORD_METHOD(bool, SBValue, GetExpressionPath, (lldb::SBStream &), + description); + ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); if (value_sp) { @@ -1286,6 +1181,9 @@ bool SBValue::GetExpressionPath(SBStream &description) { bool SBValue::GetExpressionPath(SBStream &description, bool qualify_cxx_base_classes) { + LLDB_RECORD_METHOD(bool, SBValue, GetExpressionPath, (lldb::SBStream &, bool), + description, qualify_cxx_base_classes); + ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); if (value_sp) { @@ -1295,7 +1193,86 @@ bool SBValue::GetExpressionPath(SBStream &description, return false; } +lldb::SBValue SBValue::EvaluateExpression(const char *expr) const { + LLDB_RECORD_METHOD_CONST(lldb::SBValue, SBValue, EvaluateExpression, + (const char *), expr); + + ValueLocker locker; + lldb::ValueObjectSP value_sp(GetSP(locker)); + if (!value_sp) + return LLDB_RECORD_RESULT(SBValue()); + + lldb::TargetSP target_sp = value_sp->GetTargetSP(); + if (!target_sp) + return LLDB_RECORD_RESULT(SBValue()); + + lldb::SBExpressionOptions options; + options.SetFetchDynamicValue(target_sp->GetPreferDynamicValue()); + options.SetUnwindOnError(true); + options.SetIgnoreBreakpoints(true); + + return LLDB_RECORD_RESULT(EvaluateExpression(expr, options, nullptr)); +} + +lldb::SBValue +SBValue::EvaluateExpression(const char *expr, + const SBExpressionOptions &options) const { + LLDB_RECORD_METHOD_CONST(lldb::SBValue, SBValue, EvaluateExpression, + (const char *, const lldb::SBExpressionOptions &), + expr, options); + + return LLDB_RECORD_RESULT(EvaluateExpression(expr, options, nullptr)); +} + +lldb::SBValue SBValue::EvaluateExpression(const char *expr, + const SBExpressionOptions &options, + const char *name) const { + LLDB_RECORD_METHOD_CONST( + lldb::SBValue, SBValue, EvaluateExpression, + (const char *, const lldb::SBExpressionOptions &, const char *), expr, + options, name); + + + if (!expr || expr[0] == '\0') { + return LLDB_RECORD_RESULT(SBValue()); + } + + + ValueLocker locker; + lldb::ValueObjectSP value_sp(GetSP(locker)); + if (!value_sp) { + return LLDB_RECORD_RESULT(SBValue()); + } + + lldb::TargetSP target_sp = value_sp->GetTargetSP(); + if (!target_sp) { + return LLDB_RECORD_RESULT(SBValue()); + } + + std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); + ExecutionContext exe_ctx(target_sp.get()); + + StackFrame *frame = exe_ctx.GetFramePtr(); + if (!frame) { + return LLDB_RECORD_RESULT(SBValue()); + } + + ValueObjectSP res_val_sp; + target_sp->EvaluateExpression(expr, frame, res_val_sp, options.ref(), nullptr, + value_sp.get()); + + if (name) + res_val_sp->SetName(ConstString(name)); + + SBValue result; + result.SetSP(res_val_sp, options.GetFetchDynamicValue()); + return LLDB_RECORD_RESULT(result); +} + bool SBValue::GetDescription(SBStream &description) { + LLDB_RECORD_METHOD(bool, SBValue, GetDescription, (lldb::SBStream &), + description); + Stream &strm = description.ref(); ValueLocker locker; @@ -1309,6 +1286,8 @@ bool SBValue::GetDescription(SBStream &description) { } lldb::Format SBValue::GetFormat() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::Format, SBValue, GetFormat); + ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); if (value_sp) @@ -1317,6 +1296,8 @@ lldb::Format SBValue::GetFormat() { } void SBValue::SetFormat(lldb::Format format) { + LLDB_RECORD_METHOD(void, SBValue, SetFormat, (lldb::Format), format); + ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); if (value_sp) @@ -1324,6 +1305,8 @@ void SBValue::SetFormat(lldb::Format format) { } lldb::SBValue SBValue::AddressOf() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBValue, SBValue, AddressOf); + SBValue sb_value; ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); @@ -1332,16 +1315,13 @@ lldb::SBValue SBValue::AddressOf() { sb_value.SetSP(value_sp->AddressOf(error), GetPreferDynamicValue(), GetPreferSyntheticValue()); } - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBValue(%p)::AddressOf () => SBValue(%p)", - static_cast<void *>(value_sp.get()), - static_cast<void *>(value_sp.get())); - return sb_value; + return LLDB_RECORD_RESULT(sb_value); } lldb::addr_t SBValue::GetLoadAddress() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::addr_t, SBValue, GetLoadAddress); + lldb::addr_t value = LLDB_INVALID_ADDRESS; ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); @@ -1365,15 +1345,13 @@ lldb::addr_t SBValue::GetLoadAddress() { value = LLDB_INVALID_ADDRESS; } } - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBValue(%p)::GetLoadAddress () => (%" PRIu64 ")", - static_cast<void *>(value_sp.get()), value); return value; } lldb::SBAddress SBValue::GetAddress() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBAddress, SBValue, GetAddress); + Address addr; ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); @@ -1396,18 +1374,14 @@ lldb::SBAddress SBValue::GetAddress() { } } } - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBValue(%p)::GetAddress () => (%s,%" PRIu64 ")", - static_cast<void *>(value_sp.get()), - (addr.GetSection() ? addr.GetSection()->GetName().GetCString() - : "NULL"), - addr.GetOffset()); - return SBAddress(new Address(addr)); + + return LLDB_RECORD_RESULT(SBAddress(new Address(addr))); } lldb::SBData SBValue::GetPointeeData(uint32_t item_idx, uint32_t item_count) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(lldb::SBData, SBValue, GetPointeeData, + (uint32_t, uint32_t), item_idx, item_count); + lldb::SBData sb_data; ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); @@ -1420,16 +1394,13 @@ lldb::SBData SBValue::GetPointeeData(uint32_t item_idx, uint32_t item_count) { *sb_data = data_sp; } } - if (log) - log->Printf("SBValue(%p)::GetPointeeData (%d, %d) => SBData(%p)", - static_cast<void *>(value_sp.get()), item_idx, item_count, - static_cast<void *>(sb_data.get())); - return sb_data; + return LLDB_RECORD_RESULT(sb_data); } lldb::SBData SBValue::GetData() { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBData, SBValue, GetData); + lldb::SBData sb_data; ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); @@ -1440,16 +1411,14 @@ lldb::SBData SBValue::GetData() { if (error.Success()) *sb_data = data_sp; } - if (log) - log->Printf("SBValue(%p)::GetData () => SBData(%p)", - static_cast<void *>(value_sp.get()), - static_cast<void *>(sb_data.get())); - return sb_data; + return LLDB_RECORD_RESULT(sb_data); } bool SBValue::SetData(lldb::SBData &data, SBError &error) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD(bool, SBValue, SetData, (lldb::SBData &, lldb::SBError &), + data, error); + ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); bool ret = true; @@ -1458,10 +1427,6 @@ bool SBValue::SetData(lldb::SBData &data, SBError &error) { DataExtractor *data_extractor = data.get(); if (!data_extractor) { - if (log) - log->Printf("SBValue(%p)::SetData() => error: no data to set", - static_cast<void *>(value_sp.get())); - error.SetErrorString("No data to set"); ret = false; } else { @@ -1482,14 +1447,12 @@ bool SBValue::SetData(lldb::SBData &data, SBError &error) { ret = false; } - if (log) - log->Printf("SBValue(%p)::SetData (%p) => %s", - static_cast<void *>(value_sp.get()), - static_cast<void *>(data.get()), ret ? "true" : "false"); return ret; } lldb::SBDeclaration SBValue::GetDeclaration() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBDeclaration, SBValue, GetDeclaration); + ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); SBDeclaration decl_sb; @@ -1498,11 +1461,15 @@ lldb::SBDeclaration SBValue::GetDeclaration() { if (value_sp->GetDeclaration(decl)) decl_sb.SetDeclaration(decl); } - return decl_sb; + return LLDB_RECORD_RESULT(decl_sb); } lldb::SBWatchpoint SBValue::Watch(bool resolve_location, bool read, bool write, SBError &error) { + LLDB_RECORD_METHOD(lldb::SBWatchpoint, SBValue, Watch, + (bool, bool, bool, lldb::SBError &), resolve_location, + read, write, error); + SBWatchpoint sb_watchpoint; // If the SBValue is not valid, there's no point in even trying to watch it. @@ -1512,18 +1479,18 @@ lldb::SBWatchpoint SBValue::Watch(bool resolve_location, bool read, bool write, if (value_sp && target_sp) { // Read and Write cannot both be false. if (!read && !write) - return sb_watchpoint; + return LLDB_RECORD_RESULT(sb_watchpoint); // If the value is not in scope, don't try and watch and invalid value if (!IsInScope()) - return sb_watchpoint; + return LLDB_RECORD_RESULT(sb_watchpoint); addr_t addr = GetLoadAddress(); if (addr == LLDB_INVALID_ADDRESS) - return sb_watchpoint; + return LLDB_RECORD_RESULT(sb_watchpoint); size_t byte_size = GetByteSize(); if (byte_size == 0) - return sb_watchpoint; + return LLDB_RECORD_RESULT(sb_watchpoint); uint32_t watch_type = 0; if (read) @@ -1550,23 +1517,13 @@ lldb::SBWatchpoint SBValue::Watch(bool resolve_location, bool read, bool write, } } } else if (target_sp) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBValue(%p)::Watch() => error getting SBValue: %s", - static_cast<void *>(value_sp.get()), - locker.GetError().AsCString()); - error.SetErrorStringWithFormat("could not get SBValue: %s", locker.GetError().AsCString()); } else { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBValue(%p)::Watch() => error getting SBValue: no target", - static_cast<void *>(value_sp.get())); error.SetErrorString("could not set watchpoint, a target is required"); } - return sb_watchpoint; + return LLDB_RECORD_RESULT(sb_watchpoint); } // FIXME: Remove this method impl (as well as the decl in .h) once it is no @@ -1574,24 +1531,160 @@ lldb::SBWatchpoint SBValue::Watch(bool resolve_location, bool read, bool write, // Backward compatibility fix in the interim. lldb::SBWatchpoint SBValue::Watch(bool resolve_location, bool read, bool write) { + LLDB_RECORD_METHOD(lldb::SBWatchpoint, SBValue, Watch, (bool, bool, bool), + resolve_location, read, write); + SBError error; - return Watch(resolve_location, read, write, error); + return LLDB_RECORD_RESULT(Watch(resolve_location, read, write, error)); } lldb::SBWatchpoint SBValue::WatchPointee(bool resolve_location, bool read, bool write, SBError &error) { + LLDB_RECORD_METHOD(lldb::SBWatchpoint, SBValue, WatchPointee, + (bool, bool, bool, lldb::SBError &), resolve_location, + read, write, error); + SBWatchpoint sb_watchpoint; if (IsInScope() && GetType().IsPointerType()) sb_watchpoint = Dereference().Watch(resolve_location, read, write, error); - return sb_watchpoint; + return LLDB_RECORD_RESULT(sb_watchpoint); } lldb::SBValue SBValue::Persist() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBValue, SBValue, Persist); + ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); SBValue persisted_sb; if (value_sp) { persisted_sb.SetSP(value_sp->Persist()); } - return persisted_sb; + return LLDB_RECORD_RESULT(persisted_sb); +} + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBValue>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBValue, ()); + LLDB_REGISTER_CONSTRUCTOR(SBValue, (const lldb::ValueObjectSP &)); + LLDB_REGISTER_CONSTRUCTOR(SBValue, (const lldb::SBValue &)); + LLDB_REGISTER_METHOD(lldb::SBValue &, + SBValue, operator=,(const lldb::SBValue &)); + LLDB_REGISTER_METHOD(bool, SBValue, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBValue, operator bool, ()); + LLDB_REGISTER_METHOD(void, SBValue, Clear, ()); + LLDB_REGISTER_METHOD(lldb::SBError, SBValue, GetError, ()); + LLDB_REGISTER_METHOD(lldb::user_id_t, SBValue, GetID, ()); + LLDB_REGISTER_METHOD(const char *, SBValue, GetName, ()); + LLDB_REGISTER_METHOD(const char *, SBValue, GetTypeName, ()); + LLDB_REGISTER_METHOD(const char *, SBValue, GetDisplayTypeName, ()); + LLDB_REGISTER_METHOD(size_t, SBValue, GetByteSize, ()); + LLDB_REGISTER_METHOD(bool, SBValue, IsInScope, ()); + LLDB_REGISTER_METHOD(const char *, SBValue, GetValue, ()); + LLDB_REGISTER_METHOD(lldb::ValueType, SBValue, GetValueType, ()); + LLDB_REGISTER_METHOD(const char *, SBValue, GetObjectDescription, ()); + LLDB_REGISTER_METHOD(const char *, SBValue, GetTypeValidatorResult, ()); + LLDB_REGISTER_METHOD(lldb::SBType, SBValue, GetType, ()); + LLDB_REGISTER_METHOD(bool, SBValue, GetValueDidChange, ()); + LLDB_REGISTER_METHOD(const char *, SBValue, GetSummary, ()); + LLDB_REGISTER_METHOD(const char *, SBValue, GetSummary, + (lldb::SBStream &, lldb::SBTypeSummaryOptions &)); + LLDB_REGISTER_METHOD(const char *, SBValue, GetLocation, ()); + LLDB_REGISTER_METHOD(bool, SBValue, SetValueFromCString, (const char *)); + LLDB_REGISTER_METHOD(bool, SBValue, SetValueFromCString, + (const char *, lldb::SBError &)); + LLDB_REGISTER_METHOD(lldb::SBTypeFormat, SBValue, GetTypeFormat, ()); + LLDB_REGISTER_METHOD(lldb::SBTypeSummary, SBValue, GetTypeSummary, ()); + LLDB_REGISTER_METHOD(lldb::SBTypeFilter, SBValue, GetTypeFilter, ()); + LLDB_REGISTER_METHOD(lldb::SBTypeSynthetic, SBValue, GetTypeSynthetic, ()); + LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, CreateChildAtOffset, + (const char *, uint32_t, lldb::SBType)); + LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, Cast, (lldb::SBType)); + LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, CreateValueFromExpression, + (const char *, const char *)); + LLDB_REGISTER_METHOD( + lldb::SBValue, SBValue, CreateValueFromExpression, + (const char *, const char *, lldb::SBExpressionOptions &)); + LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, CreateValueFromAddress, + (const char *, lldb::addr_t, lldb::SBType)); + LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, CreateValueFromData, + (const char *, lldb::SBData, lldb::SBType)); + LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, GetChildAtIndex, (uint32_t)); + LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, GetChildAtIndex, + (uint32_t, lldb::DynamicValueType, bool)); + LLDB_REGISTER_METHOD(uint32_t, SBValue, GetIndexOfChildWithName, + (const char *)); + LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, GetChildMemberWithName, + (const char *)); + LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, GetChildMemberWithName, + (const char *, lldb::DynamicValueType)); + LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, GetDynamicValue, + (lldb::DynamicValueType)); + LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, GetStaticValue, ()); + LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, GetNonSyntheticValue, ()); + LLDB_REGISTER_METHOD(lldb::DynamicValueType, SBValue, GetPreferDynamicValue, + ()); + LLDB_REGISTER_METHOD(void, SBValue, SetPreferDynamicValue, + (lldb::DynamicValueType)); + LLDB_REGISTER_METHOD(bool, SBValue, GetPreferSyntheticValue, ()); + LLDB_REGISTER_METHOD(void, SBValue, SetPreferSyntheticValue, (bool)); + LLDB_REGISTER_METHOD(bool, SBValue, IsDynamic, ()); + LLDB_REGISTER_METHOD(bool, SBValue, IsSynthetic, ()); + LLDB_REGISTER_METHOD(bool, SBValue, IsSyntheticChildrenGenerated, ()); + LLDB_REGISTER_METHOD(void, SBValue, SetSyntheticChildrenGenerated, (bool)); + LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, GetValueForExpressionPath, + (const char *)); + LLDB_REGISTER_METHOD(int64_t, SBValue, GetValueAsSigned, + (lldb::SBError &, int64_t)); + LLDB_REGISTER_METHOD(uint64_t, SBValue, GetValueAsUnsigned, + (lldb::SBError &, uint64_t)); + LLDB_REGISTER_METHOD(int64_t, SBValue, GetValueAsSigned, (int64_t)); + LLDB_REGISTER_METHOD(uint64_t, SBValue, GetValueAsUnsigned, (uint64_t)); + LLDB_REGISTER_METHOD(bool, SBValue, MightHaveChildren, ()); + LLDB_REGISTER_METHOD(bool, SBValue, IsRuntimeSupportValue, ()); + LLDB_REGISTER_METHOD(uint32_t, SBValue, GetNumChildren, ()); + LLDB_REGISTER_METHOD(uint32_t, SBValue, GetNumChildren, (uint32_t)); + LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, Dereference, ()); + LLDB_REGISTER_METHOD(bool, SBValue, TypeIsPointerType, ()); + LLDB_REGISTER_METHOD(void *, SBValue, GetOpaqueType, ()); + LLDB_REGISTER_METHOD(lldb::SBTarget, SBValue, GetTarget, ()); + LLDB_REGISTER_METHOD(lldb::SBProcess, SBValue, GetProcess, ()); + LLDB_REGISTER_METHOD(lldb::SBThread, SBValue, GetThread, ()); + LLDB_REGISTER_METHOD(lldb::SBFrame, SBValue, GetFrame, ()); + LLDB_REGISTER_METHOD_CONST(lldb::ValueObjectSP, SBValue, GetSP, ()); + LLDB_REGISTER_METHOD(bool, SBValue, GetExpressionPath, (lldb::SBStream &)); + LLDB_REGISTER_METHOD(bool, SBValue, GetExpressionPath, + (lldb::SBStream &, bool)); + LLDB_REGISTER_METHOD_CONST(lldb::SBValue, SBValue, EvaluateExpression, + (const char *)); + LLDB_REGISTER_METHOD_CONST( + lldb::SBValue, SBValue, EvaluateExpression, + (const char *, const lldb::SBExpressionOptions &)); + LLDB_REGISTER_METHOD_CONST( + lldb::SBValue, SBValue, EvaluateExpression, + (const char *, const lldb::SBExpressionOptions &, const char *)); + LLDB_REGISTER_METHOD(bool, SBValue, GetDescription, (lldb::SBStream &)); + LLDB_REGISTER_METHOD(lldb::Format, SBValue, GetFormat, ()); + LLDB_REGISTER_METHOD(void, SBValue, SetFormat, (lldb::Format)); + LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, AddressOf, ()); + LLDB_REGISTER_METHOD(lldb::addr_t, SBValue, GetLoadAddress, ()); + LLDB_REGISTER_METHOD(lldb::SBAddress, SBValue, GetAddress, ()); + LLDB_REGISTER_METHOD(lldb::SBData, SBValue, GetPointeeData, + (uint32_t, uint32_t)); + LLDB_REGISTER_METHOD(lldb::SBData, SBValue, GetData, ()); + LLDB_REGISTER_METHOD(bool, SBValue, SetData, + (lldb::SBData &, lldb::SBError &)); + LLDB_REGISTER_METHOD(lldb::SBDeclaration, SBValue, GetDeclaration, ()); + LLDB_REGISTER_METHOD(lldb::SBWatchpoint, SBValue, Watch, + (bool, bool, bool, lldb::SBError &)); + LLDB_REGISTER_METHOD(lldb::SBWatchpoint, SBValue, Watch, + (bool, bool, bool)); + LLDB_REGISTER_METHOD(lldb::SBWatchpoint, SBValue, WatchPointee, + (bool, bool, bool, lldb::SBError &)); + LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, Persist, ()); +} + +} } diff --git a/source/API/SBValueList.cpp b/source/API/SBValueList.cpp index 82b464bab9b90..7e909df260d7d 100644 --- a/source/API/SBValueList.cpp +++ b/source/API/SBValueList.cpp @@ -1,17 +1,16 @@ //===-- SBValueList.cpp -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBValueList.h" +#include "SBReproducerPrivate.h" #include "lldb/API/SBStream.h" #include "lldb/API/SBValue.h" #include "lldb/Core/ValueObjectList.h" -#include "lldb/Utility/Log.h" #include <vector> @@ -68,142 +67,165 @@ private: std::vector<lldb::SBValue> m_values; }; -SBValueList::SBValueList() : m_opaque_ap() {} +SBValueList::SBValueList() : m_opaque_up() { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBValueList); +} -SBValueList::SBValueList(const SBValueList &rhs) : m_opaque_ap() { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); +SBValueList::SBValueList(const SBValueList &rhs) : m_opaque_up() { + LLDB_RECORD_CONSTRUCTOR(SBValueList, (const lldb::SBValueList &), rhs); if (rhs.IsValid()) - m_opaque_ap.reset(new ValueListImpl(*rhs)); - - if (log) { - log->Printf( - "SBValueList::SBValueList (rhs.ap=%p) => this.ap = %p", - static_cast<void *>(rhs.IsValid() ? rhs.m_opaque_ap.get() : NULL), - static_cast<void *>(m_opaque_ap.get())); - } + m_opaque_up.reset(new ValueListImpl(*rhs)); } -SBValueList::SBValueList(const ValueListImpl *lldb_object_ptr) : m_opaque_ap() { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - +SBValueList::SBValueList(const ValueListImpl *lldb_object_ptr) : m_opaque_up() { if (lldb_object_ptr) - m_opaque_ap.reset(new ValueListImpl(*lldb_object_ptr)); - - if (log) { - log->Printf("SBValueList::SBValueList (lldb_object_ptr=%p) => this.ap = %p", - static_cast<const void *>(lldb_object_ptr), - static_cast<void *>(m_opaque_ap.get())); - } + m_opaque_up.reset(new ValueListImpl(*lldb_object_ptr)); } SBValueList::~SBValueList() {} -bool SBValueList::IsValid() const { return (m_opaque_ap != NULL); } +bool SBValueList::IsValid() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBValueList, IsValid); + return this->operator bool(); +} +SBValueList::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBValueList, operator bool); + + return (m_opaque_up != nullptr); +} -void SBValueList::Clear() { m_opaque_ap.reset(); } +void SBValueList::Clear() { + LLDB_RECORD_METHOD_NO_ARGS(void, SBValueList, Clear); + + m_opaque_up.reset(); +} const SBValueList &SBValueList::operator=(const SBValueList &rhs) { + LLDB_RECORD_METHOD(const lldb::SBValueList &, + SBValueList, operator=,(const lldb::SBValueList &), rhs); + if (this != &rhs) { if (rhs.IsValid()) - m_opaque_ap.reset(new ValueListImpl(*rhs)); + m_opaque_up.reset(new ValueListImpl(*rhs)); else - m_opaque_ap.reset(); + m_opaque_up.reset(); } - return *this; + return LLDB_RECORD_RESULT(*this); } -ValueListImpl *SBValueList::operator->() { return m_opaque_ap.get(); } +ValueListImpl *SBValueList::operator->() { return m_opaque_up.get(); } -ValueListImpl &SBValueList::operator*() { return *m_opaque_ap; } +ValueListImpl &SBValueList::operator*() { return *m_opaque_up; } const ValueListImpl *SBValueList::operator->() const { - return m_opaque_ap.get(); + return m_opaque_up.get(); } -const ValueListImpl &SBValueList::operator*() const { return *m_opaque_ap; } +const ValueListImpl &SBValueList::operator*() const { return *m_opaque_up; } void SBValueList::Append(const SBValue &val_obj) { + LLDB_RECORD_METHOD(void, SBValueList, Append, (const lldb::SBValue &), + val_obj); + CreateIfNeeded(); - m_opaque_ap->Append(val_obj); + m_opaque_up->Append(val_obj); } void SBValueList::Append(lldb::ValueObjectSP &val_obj_sp) { if (val_obj_sp) { CreateIfNeeded(); - m_opaque_ap->Append(SBValue(val_obj_sp)); + m_opaque_up->Append(SBValue(val_obj_sp)); } } void SBValueList::Append(const lldb::SBValueList &value_list) { + LLDB_RECORD_METHOD(void, SBValueList, Append, (const lldb::SBValueList &), + value_list); + if (value_list.IsValid()) { CreateIfNeeded(); - m_opaque_ap->Append(*value_list); + m_opaque_up->Append(*value_list); } } SBValue SBValueList::GetValueAtIndex(uint32_t idx) const { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_CONST(lldb::SBValue, SBValueList, GetValueAtIndex, + (uint32_t), idx); - // if (log) - // log->Printf ("SBValueList::GetValueAtIndex (uint32_t idx) idx = %d", - // idx); SBValue sb_value; - if (m_opaque_ap) - sb_value = m_opaque_ap->GetValueAtIndex(idx); - - if (log) { - SBStream sstr; - sb_value.GetDescription(sstr); - log->Printf("SBValueList::GetValueAtIndex (this.ap=%p, idx=%d) => SBValue " - "(this.sp = %p, '%s')", - static_cast<void *>(m_opaque_ap.get()), idx, - static_cast<void *>(sb_value.GetSP().get()), sstr.GetData()); - } + if (m_opaque_up) + sb_value = m_opaque_up->GetValueAtIndex(idx); - return sb_value; + return LLDB_RECORD_RESULT(sb_value); } uint32_t SBValueList::GetSize() const { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - - // if (log) - // log->Printf ("SBValueList::GetSize ()"); + LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBValueList, GetSize); uint32_t size = 0; - if (m_opaque_ap) - size = m_opaque_ap->GetSize(); - - if (log) - log->Printf("SBValueList::GetSize (this.ap=%p) => %d", - static_cast<void *>(m_opaque_ap.get()), size); + if (m_opaque_up) + size = m_opaque_up->GetSize(); return size; } void SBValueList::CreateIfNeeded() { - if (m_opaque_ap == NULL) - m_opaque_ap.reset(new ValueListImpl()); + if (m_opaque_up == nullptr) + m_opaque_up.reset(new ValueListImpl()); } SBValue SBValueList::FindValueObjectByUID(lldb::user_id_t uid) { + LLDB_RECORD_METHOD(lldb::SBValue, SBValueList, FindValueObjectByUID, + (lldb::user_id_t), uid); + SBValue sb_value; - if (m_opaque_ap) - sb_value = m_opaque_ap->FindValueByUID(uid); - return sb_value; + if (m_opaque_up) + sb_value = m_opaque_up->FindValueByUID(uid); + return LLDB_RECORD_RESULT(sb_value); } SBValue SBValueList::GetFirstValueByName(const char *name) const { + LLDB_RECORD_METHOD_CONST(lldb::SBValue, SBValueList, GetFirstValueByName, + (const char *), name); + SBValue sb_value; - if (m_opaque_ap) - sb_value = m_opaque_ap->GetFirstValueByName(name); - return sb_value; + if (m_opaque_up) + sb_value = m_opaque_up->GetFirstValueByName(name); + return LLDB_RECORD_RESULT(sb_value); } -void *SBValueList::opaque_ptr() { return m_opaque_ap.get(); } +void *SBValueList::opaque_ptr() { return m_opaque_up.get(); } ValueListImpl &SBValueList::ref() { CreateIfNeeded(); - return *m_opaque_ap; + return *m_opaque_up; +} + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBValueList>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBValueList, ()); + LLDB_REGISTER_CONSTRUCTOR(SBValueList, (const lldb::SBValueList &)); + LLDB_REGISTER_METHOD_CONST(bool, SBValueList, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBValueList, operator bool, ()); + LLDB_REGISTER_METHOD(void, SBValueList, Clear, ()); + LLDB_REGISTER_METHOD(const lldb::SBValueList &, + SBValueList, operator=,(const lldb::SBValueList &)); + LLDB_REGISTER_METHOD(void, SBValueList, Append, (const lldb::SBValue &)); + LLDB_REGISTER_METHOD(void, SBValueList, Append, + (const lldb::SBValueList &)); + LLDB_REGISTER_METHOD_CONST(lldb::SBValue, SBValueList, GetValueAtIndex, + (uint32_t)); + LLDB_REGISTER_METHOD_CONST(uint32_t, SBValueList, GetSize, ()); + LLDB_REGISTER_METHOD(lldb::SBValue, SBValueList, FindValueObjectByUID, + (lldb::user_id_t)); + LLDB_REGISTER_METHOD_CONST(lldb::SBValue, SBValueList, GetFirstValueByName, + (const char *)); +} + +} } diff --git a/source/API/SBVariablesOptions.cpp b/source/API/SBVariablesOptions.cpp index 2651ce11d02a8..bf0197cd960bd 100644 --- a/source/API/SBVariablesOptions.cpp +++ b/source/API/SBVariablesOptions.cpp @@ -1,14 +1,14 @@ //===-- SBVariablesOptions.cpp --------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBVariablesOptions.h" +#include "SBReproducerPrivate.h" #include "lldb/API/SBTarget.h" #include "lldb/Target/Target.h" @@ -81,98 +81,196 @@ private: }; SBVariablesOptions::SBVariablesOptions() - : m_opaque_ap(new VariablesOptionsImpl()) {} + : m_opaque_up(new VariablesOptionsImpl()) { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBVariablesOptions); +} SBVariablesOptions::SBVariablesOptions(const SBVariablesOptions &options) - : m_opaque_ap(new VariablesOptionsImpl(options.ref())) {} + : m_opaque_up(new VariablesOptionsImpl(options.ref())) { + LLDB_RECORD_CONSTRUCTOR(SBVariablesOptions, + (const lldb::SBVariablesOptions &), options); +} SBVariablesOptions &SBVariablesOptions:: operator=(const SBVariablesOptions &options) { - m_opaque_ap.reset(new VariablesOptionsImpl(options.ref())); - return *this; + LLDB_RECORD_METHOD( + lldb::SBVariablesOptions &, + SBVariablesOptions, operator=,(const lldb::SBVariablesOptions &), + options); + + m_opaque_up.reset(new VariablesOptionsImpl(options.ref())); + return LLDB_RECORD_RESULT(*this); } SBVariablesOptions::~SBVariablesOptions() = default; -bool SBVariablesOptions::IsValid() const { return m_opaque_ap != nullptr; } +bool SBVariablesOptions::IsValid() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions, IsValid); + return this->operator bool(); +} +SBVariablesOptions::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions, operator bool); + + return m_opaque_up != nullptr; +} bool SBVariablesOptions::GetIncludeArguments() const { - return m_opaque_ap->GetIncludeArguments(); + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions, + GetIncludeArguments); + + return m_opaque_up->GetIncludeArguments(); } void SBVariablesOptions::SetIncludeArguments(bool arguments) { - m_opaque_ap->SetIncludeArguments(arguments); + LLDB_RECORD_METHOD(void, SBVariablesOptions, SetIncludeArguments, (bool), + arguments); + + m_opaque_up->SetIncludeArguments(arguments); } bool SBVariablesOptions::GetIncludeRecognizedArguments( const lldb::SBTarget &target) const { - return m_opaque_ap->GetIncludeRecognizedArguments(target.GetSP()); + LLDB_RECORD_METHOD_CONST(bool, SBVariablesOptions, + GetIncludeRecognizedArguments, + (const lldb::SBTarget &), target); + + return m_opaque_up->GetIncludeRecognizedArguments(target.GetSP()); } void SBVariablesOptions::SetIncludeRecognizedArguments(bool arguments) { - m_opaque_ap->SetIncludeRecognizedArguments(arguments); + LLDB_RECORD_METHOD(void, SBVariablesOptions, SetIncludeRecognizedArguments, + (bool), arguments); + + m_opaque_up->SetIncludeRecognizedArguments(arguments); } bool SBVariablesOptions::GetIncludeLocals() const { - return m_opaque_ap->GetIncludeLocals(); + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions, GetIncludeLocals); + + return m_opaque_up->GetIncludeLocals(); } void SBVariablesOptions::SetIncludeLocals(bool locals) { - m_opaque_ap->SetIncludeLocals(locals); + LLDB_RECORD_METHOD(void, SBVariablesOptions, SetIncludeLocals, (bool), + locals); + + m_opaque_up->SetIncludeLocals(locals); } bool SBVariablesOptions::GetIncludeStatics() const { - return m_opaque_ap->GetIncludeStatics(); + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions, GetIncludeStatics); + + return m_opaque_up->GetIncludeStatics(); } void SBVariablesOptions::SetIncludeStatics(bool statics) { - m_opaque_ap->SetIncludeStatics(statics); + LLDB_RECORD_METHOD(void, SBVariablesOptions, SetIncludeStatics, (bool), + statics); + + m_opaque_up->SetIncludeStatics(statics); } bool SBVariablesOptions::GetInScopeOnly() const { - return m_opaque_ap->GetInScopeOnly(); + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions, GetInScopeOnly); + + return m_opaque_up->GetInScopeOnly(); } void SBVariablesOptions::SetInScopeOnly(bool in_scope_only) { - m_opaque_ap->SetInScopeOnly(in_scope_only); + LLDB_RECORD_METHOD(void, SBVariablesOptions, SetInScopeOnly, (bool), + in_scope_only); + + m_opaque_up->SetInScopeOnly(in_scope_only); } bool SBVariablesOptions::GetIncludeRuntimeSupportValues() const { - return m_opaque_ap->GetIncludeRuntimeSupportValues(); + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions, + GetIncludeRuntimeSupportValues); + + return m_opaque_up->GetIncludeRuntimeSupportValues(); } void SBVariablesOptions::SetIncludeRuntimeSupportValues( bool runtime_support_values) { - m_opaque_ap->SetIncludeRuntimeSupportValues(runtime_support_values); + LLDB_RECORD_METHOD(void, SBVariablesOptions, SetIncludeRuntimeSupportValues, + (bool), runtime_support_values); + + m_opaque_up->SetIncludeRuntimeSupportValues(runtime_support_values); } lldb::DynamicValueType SBVariablesOptions::GetUseDynamic() const { - return m_opaque_ap->GetUseDynamic(); + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::DynamicValueType, SBVariablesOptions, + GetUseDynamic); + + return m_opaque_up->GetUseDynamic(); } void SBVariablesOptions::SetUseDynamic(lldb::DynamicValueType dynamic) { - m_opaque_ap->SetUseDynamic(dynamic); + LLDB_RECORD_METHOD(void, SBVariablesOptions, SetUseDynamic, + (lldb::DynamicValueType), dynamic); + + m_opaque_up->SetUseDynamic(dynamic); } VariablesOptionsImpl *SBVariablesOptions::operator->() { - return m_opaque_ap.operator->(); + return m_opaque_up.operator->(); } const VariablesOptionsImpl *SBVariablesOptions::operator->() const { - return m_opaque_ap.operator->(); + return m_opaque_up.operator->(); } -VariablesOptionsImpl *SBVariablesOptions::get() { return m_opaque_ap.get(); } +VariablesOptionsImpl *SBVariablesOptions::get() { return m_opaque_up.get(); } -VariablesOptionsImpl &SBVariablesOptions::ref() { return *m_opaque_ap; } +VariablesOptionsImpl &SBVariablesOptions::ref() { return *m_opaque_up; } const VariablesOptionsImpl &SBVariablesOptions::ref() const { - return *m_opaque_ap; + return *m_opaque_up; } SBVariablesOptions::SBVariablesOptions(VariablesOptionsImpl *lldb_object_ptr) - : m_opaque_ap(std::move(lldb_object_ptr)) {} + : m_opaque_up(std::move(lldb_object_ptr)) {} void SBVariablesOptions::SetOptions(VariablesOptionsImpl *lldb_object_ptr) { - m_opaque_ap.reset(std::move(lldb_object_ptr)); + m_opaque_up.reset(std::move(lldb_object_ptr)); +} + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBVariablesOptions>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBVariablesOptions, ()); + LLDB_REGISTER_CONSTRUCTOR(SBVariablesOptions, + (const lldb::SBVariablesOptions &)); + LLDB_REGISTER_METHOD( + lldb::SBVariablesOptions &, + SBVariablesOptions, operator=,(const lldb::SBVariablesOptions &)); + LLDB_REGISTER_METHOD_CONST(bool, SBVariablesOptions, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBVariablesOptions, operator bool, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBVariablesOptions, GetIncludeArguments, + ()); + LLDB_REGISTER_METHOD(void, SBVariablesOptions, SetIncludeArguments, (bool)); + LLDB_REGISTER_METHOD_CONST(bool, SBVariablesOptions, + GetIncludeRecognizedArguments, + (const lldb::SBTarget &)); + LLDB_REGISTER_METHOD(void, SBVariablesOptions, + SetIncludeRecognizedArguments, (bool)); + LLDB_REGISTER_METHOD_CONST(bool, SBVariablesOptions, GetIncludeLocals, ()); + LLDB_REGISTER_METHOD(void, SBVariablesOptions, SetIncludeLocals, (bool)); + LLDB_REGISTER_METHOD_CONST(bool, SBVariablesOptions, GetIncludeStatics, ()); + LLDB_REGISTER_METHOD(void, SBVariablesOptions, SetIncludeStatics, (bool)); + LLDB_REGISTER_METHOD_CONST(bool, SBVariablesOptions, GetInScopeOnly, ()); + LLDB_REGISTER_METHOD(void, SBVariablesOptions, SetInScopeOnly, (bool)); + LLDB_REGISTER_METHOD_CONST(bool, SBVariablesOptions, + GetIncludeRuntimeSupportValues, ()); + LLDB_REGISTER_METHOD(void, SBVariablesOptions, + SetIncludeRuntimeSupportValues, (bool)); + LLDB_REGISTER_METHOD_CONST(lldb::DynamicValueType, SBVariablesOptions, + GetUseDynamic, ()); + LLDB_REGISTER_METHOD(void, SBVariablesOptions, SetUseDynamic, + (lldb::DynamicValueType)); +} + +} } diff --git a/source/API/SBWatchpoint.cpp b/source/API/SBWatchpoint.cpp index b7755373abc94..d0a36b71e5c18 100644 --- a/source/API/SBWatchpoint.cpp +++ b/source/API/SBWatchpoint.cpp @@ -1,13 +1,13 @@ //===-- SBWatchpoint.cpp --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/API/SBWatchpoint.h" +#include "SBReproducerPrivate.h" #include "lldb/API/SBAddress.h" #include "lldb/API/SBDebugger.h" #include "lldb/API/SBDefines.h" @@ -19,7 +19,6 @@ #include "lldb/Core/StreamFile.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" -#include "lldb/Utility/Log.h" #include "lldb/Utility/Stream.h" #include "lldb/lldb-defines.h" #include "lldb/lldb-types.h" @@ -27,61 +26,78 @@ using namespace lldb; using namespace lldb_private; -SBWatchpoint::SBWatchpoint() {} +SBWatchpoint::SBWatchpoint() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBWatchpoint); } SBWatchpoint::SBWatchpoint(const lldb::WatchpointSP &wp_sp) : m_opaque_wp(wp_sp) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - - if (log) { - SBStream sstr; - GetDescription(sstr, lldb::eDescriptionLevelBrief); - LLDB_LOG(log, "watchpoint = {0} ({1})", wp_sp.get(), sstr.GetData()); - } + LLDB_RECORD_CONSTRUCTOR(SBWatchpoint, (const lldb::WatchpointSP &), wp_sp); } SBWatchpoint::SBWatchpoint(const SBWatchpoint &rhs) - : m_opaque_wp(rhs.m_opaque_wp) {} + : m_opaque_wp(rhs.m_opaque_wp) { + LLDB_RECORD_CONSTRUCTOR(SBWatchpoint, (const lldb::SBWatchpoint &), rhs); +} const SBWatchpoint &SBWatchpoint::operator=(const SBWatchpoint &rhs) { + LLDB_RECORD_METHOD(const lldb::SBWatchpoint &, + SBWatchpoint, operator=,(const lldb::SBWatchpoint &), rhs); + m_opaque_wp = rhs.m_opaque_wp; - return *this; + return LLDB_RECORD_RESULT(*this); } SBWatchpoint::~SBWatchpoint() {} watch_id_t SBWatchpoint::GetID() { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + LLDB_RECORD_METHOD_NO_ARGS(lldb::watch_id_t, SBWatchpoint, GetID); + watch_id_t watch_id = LLDB_INVALID_WATCH_ID; lldb::WatchpointSP watchpoint_sp(GetSP()); if (watchpoint_sp) watch_id = watchpoint_sp->GetID(); - if (log) { - if (watch_id == LLDB_INVALID_WATCH_ID) - log->Printf("SBWatchpoint(%p)::GetID () => LLDB_INVALID_WATCH_ID", - static_cast<void *>(watchpoint_sp.get())); - else - log->Printf("SBWatchpoint(%p)::GetID () => %u", - static_cast<void *>(watchpoint_sp.get()), watch_id); - } - return watch_id; } -bool SBWatchpoint::IsValid() const { return bool(m_opaque_wp.lock()); } +bool SBWatchpoint::IsValid() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBWatchpoint, IsValid); + return this->operator bool(); +} +SBWatchpoint::operator bool() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBWatchpoint, operator bool); + + return bool(m_opaque_wp.lock()); +} + +bool SBWatchpoint::operator==(const SBWatchpoint &rhs) const { + LLDB_RECORD_METHOD_CONST( + bool, SBWatchpoint, operator==,(const SBWatchpoint &), rhs); + + return GetSP() == rhs.GetSP(); +} + +bool SBWatchpoint::operator!=(const SBWatchpoint &rhs) const { + LLDB_RECORD_METHOD_CONST( + bool, SBWatchpoint, operator!=,(const SBWatchpoint &), rhs); + + return !(*this == rhs); +} SBError SBWatchpoint::GetError() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBWatchpoint, GetError); + SBError sb_error; lldb::WatchpointSP watchpoint_sp(GetSP()); if (watchpoint_sp) { sb_error.SetError(watchpoint_sp->GetError()); } - return sb_error; + return LLDB_RECORD_RESULT(sb_error); } int32_t SBWatchpoint::GetHardwareIndex() { + LLDB_RECORD_METHOD_NO_ARGS(int32_t, SBWatchpoint, GetHardwareIndex); + int32_t hw_index = -1; lldb::WatchpointSP watchpoint_sp(GetSP()); @@ -95,6 +111,8 @@ int32_t SBWatchpoint::GetHardwareIndex() { } addr_t SBWatchpoint::GetWatchAddress() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::addr_t, SBWatchpoint, GetWatchAddress); + addr_t ret_addr = LLDB_INVALID_ADDRESS; lldb::WatchpointSP watchpoint_sp(GetSP()); @@ -108,6 +126,8 @@ addr_t SBWatchpoint::GetWatchAddress() { } size_t SBWatchpoint::GetWatchSize() { + LLDB_RECORD_METHOD_NO_ARGS(size_t, SBWatchpoint, GetWatchSize); + size_t watch_size = 0; lldb::WatchpointSP watchpoint_sp(GetSP()); @@ -121,6 +141,8 @@ size_t SBWatchpoint::GetWatchSize() { } void SBWatchpoint::SetEnabled(bool enabled) { + LLDB_RECORD_METHOD(void, SBWatchpoint, SetEnabled, (bool), enabled); + lldb::WatchpointSP watchpoint_sp(GetSP()); if (watchpoint_sp) { Target &target = watchpoint_sp->GetTarget(); @@ -139,6 +161,8 @@ void SBWatchpoint::SetEnabled(bool enabled) { } bool SBWatchpoint::IsEnabled() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBWatchpoint, IsEnabled); + lldb::WatchpointSP watchpoint_sp(GetSP()); if (watchpoint_sp) { std::lock_guard<std::recursive_mutex> guard( @@ -149,6 +173,8 @@ bool SBWatchpoint::IsEnabled() { } uint32_t SBWatchpoint::GetHitCount() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBWatchpoint, GetHitCount); + uint32_t count = 0; lldb::WatchpointSP watchpoint_sp(GetSP()); if (watchpoint_sp) { @@ -157,15 +183,12 @@ uint32_t SBWatchpoint::GetHitCount() { count = watchpoint_sp->GetHitCount(); } - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBWatchpoint(%p)::GetHitCount () => %u", - static_cast<void *>(watchpoint_sp.get()), count); - return count; } uint32_t SBWatchpoint::GetIgnoreCount() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBWatchpoint, GetIgnoreCount); + lldb::WatchpointSP watchpoint_sp(GetSP()); if (watchpoint_sp) { std::lock_guard<std::recursive_mutex> guard( @@ -176,6 +199,8 @@ uint32_t SBWatchpoint::GetIgnoreCount() { } void SBWatchpoint::SetIgnoreCount(uint32_t n) { + LLDB_RECORD_METHOD(void, SBWatchpoint, SetIgnoreCount, (uint32_t), n); + lldb::WatchpointSP watchpoint_sp(GetSP()); if (watchpoint_sp) { std::lock_guard<std::recursive_mutex> guard( @@ -185,16 +210,21 @@ void SBWatchpoint::SetIgnoreCount(uint32_t n) { } const char *SBWatchpoint::GetCondition() { + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBWatchpoint, GetCondition); + lldb::WatchpointSP watchpoint_sp(GetSP()); if (watchpoint_sp) { std::lock_guard<std::recursive_mutex> guard( watchpoint_sp->GetTarget().GetAPIMutex()); return watchpoint_sp->GetConditionText(); } - return NULL; + return nullptr; } void SBWatchpoint::SetCondition(const char *condition) { + LLDB_RECORD_METHOD(void, SBWatchpoint, SetCondition, (const char *), + condition); + lldb::WatchpointSP watchpoint_sp(GetSP()); if (watchpoint_sp) { std::lock_guard<std::recursive_mutex> guard( @@ -205,6 +235,10 @@ void SBWatchpoint::SetCondition(const char *condition) { bool SBWatchpoint::GetDescription(SBStream &description, DescriptionLevel level) { + LLDB_RECORD_METHOD(bool, SBWatchpoint, GetDescription, + (lldb::SBStream &, lldb::DescriptionLevel), description, + level); + Stream &strm = description.ref(); lldb::WatchpointSP watchpoint_sp(GetSP()); @@ -219,19 +253,39 @@ bool SBWatchpoint::GetDescription(SBStream &description, return true; } -void SBWatchpoint::Clear() { m_opaque_wp.reset(); } +void SBWatchpoint::Clear() { + LLDB_RECORD_METHOD_NO_ARGS(void, SBWatchpoint, Clear); + + m_opaque_wp.reset(); +} + +lldb::WatchpointSP SBWatchpoint::GetSP() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::WatchpointSP, SBWatchpoint, GetSP); -lldb::WatchpointSP SBWatchpoint::GetSP() const { return m_opaque_wp.lock(); } + return LLDB_RECORD_RESULT(m_opaque_wp.lock()); +} + +void SBWatchpoint::SetSP(const lldb::WatchpointSP &sp) { + LLDB_RECORD_METHOD(void, SBWatchpoint, SetSP, (const lldb::WatchpointSP &), + sp); -void SBWatchpoint::SetSP(const lldb::WatchpointSP &sp) { m_opaque_wp = sp; } + m_opaque_wp = sp; +} bool SBWatchpoint::EventIsWatchpointEvent(const lldb::SBEvent &event) { + LLDB_RECORD_STATIC_METHOD(bool, SBWatchpoint, EventIsWatchpointEvent, + (const lldb::SBEvent &), event); + return Watchpoint::WatchpointEventData::GetEventDataFromEvent(event.get()) != - NULL; + nullptr; } WatchpointEventType SBWatchpoint::GetWatchpointEventTypeFromEvent(const SBEvent &event) { + LLDB_RECORD_STATIC_METHOD(lldb::WatchpointEventType, SBWatchpoint, + GetWatchpointEventTypeFromEvent, + (const lldb::SBEvent &), event); + if (event.IsValid()) return Watchpoint::WatchpointEventData::GetWatchpointEventTypeFromEvent( event.GetSP()); @@ -239,9 +293,60 @@ SBWatchpoint::GetWatchpointEventTypeFromEvent(const SBEvent &event) { } SBWatchpoint SBWatchpoint::GetWatchpointFromEvent(const lldb::SBEvent &event) { + LLDB_RECORD_STATIC_METHOD(lldb::SBWatchpoint, SBWatchpoint, + GetWatchpointFromEvent, (const lldb::SBEvent &), + event); + SBWatchpoint sb_watchpoint; if (event.IsValid()) sb_watchpoint = Watchpoint::WatchpointEventData::GetWatchpointFromEvent(event.GetSP()); - return sb_watchpoint; + return LLDB_RECORD_RESULT(sb_watchpoint); +} + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBWatchpoint>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBWatchpoint, ()); + LLDB_REGISTER_CONSTRUCTOR(SBWatchpoint, (const lldb::WatchpointSP &)); + LLDB_REGISTER_CONSTRUCTOR(SBWatchpoint, (const lldb::SBWatchpoint &)); + LLDB_REGISTER_METHOD(const lldb::SBWatchpoint &, + SBWatchpoint, operator=,(const lldb::SBWatchpoint &)); + LLDB_REGISTER_METHOD(lldb::watch_id_t, SBWatchpoint, GetID, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBWatchpoint, IsValid, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBWatchpoint, operator bool, ()); + LLDB_REGISTER_METHOD_CONST( + bool, SBWatchpoint, operator==,(const lldb::SBWatchpoint &)); + LLDB_REGISTER_METHOD_CONST( + bool, SBWatchpoint, operator!=,(const lldb::SBWatchpoint &)); + LLDB_REGISTER_METHOD(lldb::SBError, SBWatchpoint, GetError, ()); + LLDB_REGISTER_METHOD(int32_t, SBWatchpoint, GetHardwareIndex, ()); + LLDB_REGISTER_METHOD(lldb::addr_t, SBWatchpoint, GetWatchAddress, ()); + LLDB_REGISTER_METHOD(size_t, SBWatchpoint, GetWatchSize, ()); + LLDB_REGISTER_METHOD(void, SBWatchpoint, SetEnabled, (bool)); + LLDB_REGISTER_METHOD(bool, SBWatchpoint, IsEnabled, ()); + LLDB_REGISTER_METHOD(uint32_t, SBWatchpoint, GetHitCount, ()); + LLDB_REGISTER_METHOD(uint32_t, SBWatchpoint, GetIgnoreCount, ()); + LLDB_REGISTER_METHOD(void, SBWatchpoint, SetIgnoreCount, (uint32_t)); + LLDB_REGISTER_METHOD(const char *, SBWatchpoint, GetCondition, ()); + LLDB_REGISTER_METHOD(void, SBWatchpoint, SetCondition, (const char *)); + LLDB_REGISTER_METHOD(bool, SBWatchpoint, GetDescription, + (lldb::SBStream &, lldb::DescriptionLevel)); + LLDB_REGISTER_METHOD(void, SBWatchpoint, Clear, ()); + LLDB_REGISTER_METHOD_CONST(lldb::WatchpointSP, SBWatchpoint, GetSP, ()); + LLDB_REGISTER_METHOD(void, SBWatchpoint, SetSP, + (const lldb::WatchpointSP &)); + LLDB_REGISTER_STATIC_METHOD(bool, SBWatchpoint, EventIsWatchpointEvent, + (const lldb::SBEvent &)); + LLDB_REGISTER_STATIC_METHOD(lldb::WatchpointEventType, SBWatchpoint, + GetWatchpointEventTypeFromEvent, + (const lldb::SBEvent &)); + LLDB_REGISTER_STATIC_METHOD(lldb::SBWatchpoint, SBWatchpoint, + GetWatchpointFromEvent, + (const lldb::SBEvent &)); +} + +} } diff --git a/source/API/SystemInitializerFull.cpp b/source/API/SystemInitializerFull.cpp index 42dea6a01abad..e7f2206b9a59d 100644 --- a/source/API/SystemInitializerFull.cpp +++ b/source/API/SystemInitializerFull.cpp @@ -1,16 +1,11 @@ //===-- SystemInitializerFull.cpp -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// -#if !defined(LLDB_DISABLE_PYTHON) -#include "Plugins/ScriptInterpreter/Python/lldb-python.h" -#endif - #include "SystemInitializerFull.h" #include "lldb/API/SBCommandInterpreter.h" @@ -39,6 +34,7 @@ #include "Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h" #include "Plugins/ABI/SysV-s390x/ABISysV_s390x.h" #include "Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h" +#include "Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h" #include "Plugins/Architecture/Arm/ArchitectureArm.h" #include "Plugins/Architecture/Mips/ArchitectureMips.h" #include "Plugins/Architecture/PPC64/ArchitecturePPC64.h" @@ -48,7 +44,10 @@ #include "Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h" #include "Plugins/DynamicLoader/Static/DynamicLoaderStatic.h" #include "Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h" +#include "Plugins/Instruction/ARM/EmulateInstructionARM.h" #include "Plugins/Instruction/ARM64/EmulateInstructionARM64.h" +#include "Plugins/Instruction/MIPS/EmulateInstructionMIPS.h" +#include "Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h" #include "Plugins/Instruction/PPC64/EmulateInstructionPPC64.h" #include "Plugins/InstrumentationRuntime/ASan/ASanRuntime.h" #include "Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.h" @@ -63,6 +62,8 @@ #include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h" #include "Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h" #include "Plugins/MemoryHistory/asan/MemoryHistoryASan.h" +#include "Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h" +#include "Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h" #include "Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h" #include "Plugins/ObjectFile/ELF/ObjectFileELF.h" #include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h" @@ -70,7 +71,6 @@ #include "Plugins/OperatingSystem/Python/OperatingSystemPython.h" #include "Plugins/Platform/Android/PlatformAndroid.h" #include "Plugins/Platform/FreeBSD/PlatformFreeBSD.h" -#include "Plugins/Platform/Kalimba/PlatformKalimba.h" #include "Plugins/Platform/Linux/PlatformLinux.h" #include "Plugins/Platform/MacOSX/PlatformMacOSX.h" #include "Plugins/Platform/MacOSX/PlatformRemoteiOS.h" @@ -98,9 +98,9 @@ #include "Plugins/Platform/MacOSX/PlatformAppleTVSimulator.h" #include "Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.h" #include "Plugins/Platform/MacOSX/PlatformDarwinKernel.h" +#include "Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.h" #include "Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h" #include "Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h" -#include "Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.h" #include "Plugins/Platform/MacOSX/PlatformiOSSimulator.h" #include "Plugins/Process/MacOSX-Kernel/ProcessKDP.h" #include "Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h" @@ -118,157 +118,21 @@ #include "llvm/Support/TargetSelect.h" +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wglobal-constructors" +#include "llvm/ExecutionEngine/MCJIT.h" +#pragma clang diagnostic pop + #include <string> using namespace lldb_private; -#ifndef LLDB_DISABLE_PYTHON - -// Defined in the SWIG source file -#if PY_MAJOR_VERSION >= 3 -extern "C" PyObject *PyInit__lldb(void); - -#define LLDBSwigPyInit PyInit__lldb - -#else -extern "C" void init_lldb(void); - -#define LLDBSwigPyInit init_lldb -#endif - -// these are the Pythonic implementations of the required callbacks these are -// scripting-language specific, which is why they belong here we still need to -// use function pointers to them instead of relying on linkage-time resolution -// because the SWIG stuff and this file get built at different times -extern "C" bool LLDBSwigPythonBreakpointCallbackFunction( - const char *python_function_name, const char *session_dictionary_name, - const lldb::StackFrameSP &sb_frame, - const lldb::BreakpointLocationSP &sb_bp_loc); - -extern "C" bool LLDBSwigPythonWatchpointCallbackFunction( - const char *python_function_name, const char *session_dictionary_name, - const lldb::StackFrameSP &sb_frame, const lldb::WatchpointSP &sb_wp); - -extern "C" bool LLDBSwigPythonCallTypeScript( - const char *python_function_name, void *session_dictionary, - const lldb::ValueObjectSP &valobj_sp, void **pyfunct_wrapper, - const lldb::TypeSummaryOptionsSP &options_sp, std::string &retval); - -extern "C" void * -LLDBSwigPythonCreateSyntheticProvider(const char *python_class_name, - const char *session_dictionary_name, - const lldb::ValueObjectSP &valobj_sp); - -extern "C" void * -LLDBSwigPythonCreateCommandObject(const char *python_class_name, - const char *session_dictionary_name, - const lldb::DebuggerSP debugger_sp); - -extern "C" void *LLDBSwigPythonCreateScriptedThreadPlan( - const char *python_class_name, const char *session_dictionary_name, - const lldb::ThreadPlanSP &thread_plan_sp); - -extern "C" bool LLDBSWIGPythonCallThreadPlan(void *implementor, - const char *method_name, - Event *event_sp, bool &got_error); - -extern "C" void *LLDBSwigPythonCreateScriptedBreakpointResolver( - const char *python_class_name, - const char *session_dictionary_name, - lldb_private::StructuredDataImpl *args, - lldb::BreakpointSP &bkpt_sp); - -extern "C" unsigned int LLDBSwigPythonCallBreakpointResolver( - void *implementor, - const char *method_name, - lldb_private::SymbolContext *sym_ctx -); - -extern "C" size_t LLDBSwigPython_CalculateNumChildren(void *implementor, - uint32_t max); - -extern "C" void *LLDBSwigPython_GetChildAtIndex(void *implementor, - uint32_t idx); - -extern "C" int LLDBSwigPython_GetIndexOfChildWithName(void *implementor, - const char *child_name); - -extern "C" void *LLDBSWIGPython_CastPyObjectToSBValue(void *data); - -extern lldb::ValueObjectSP -LLDBSWIGPython_GetValueObjectSPFromSBValue(void *data); - -extern "C" bool LLDBSwigPython_UpdateSynthProviderInstance(void *implementor); - -extern "C" bool -LLDBSwigPython_MightHaveChildrenSynthProviderInstance(void *implementor); - -extern "C" void * -LLDBSwigPython_GetValueSynthProviderInstance(void *implementor); - -extern "C" bool -LLDBSwigPythonCallCommand(const char *python_function_name, - const char *session_dictionary_name, - lldb::DebuggerSP &debugger, const char *args, - lldb_private::CommandReturnObject &cmd_retobj, - lldb::ExecutionContextRefSP exe_ctx_ref_sp); - -extern "C" bool -LLDBSwigPythonCallCommandObject(void *implementor, lldb::DebuggerSP &debugger, - const char *args, - lldb_private::CommandReturnObject &cmd_retobj, - lldb::ExecutionContextRefSP exe_ctx_ref_sp); - -extern "C" bool -LLDBSwigPythonCallModuleInit(const char *python_module_name, - const char *session_dictionary_name, - lldb::DebuggerSP &debugger); - -extern "C" void * -LLDBSWIGPythonCreateOSPlugin(const char *python_class_name, - const char *session_dictionary_name, - const lldb::ProcessSP &process_sp); - -extern "C" void *LLDBSWIGPython_CreateFrameRecognizer( - const char *python_class_name, - const char *session_dictionary_name); - -extern "C" void *LLDBSwigPython_GetRecognizedArguments(void *implementor, - const lldb::StackFrameSP& frame_sp); - -extern "C" bool LLDBSWIGPythonRunScriptKeywordProcess( - const char *python_function_name, const char *session_dictionary_name, - lldb::ProcessSP &process, std::string &output); - -extern "C" bool LLDBSWIGPythonRunScriptKeywordThread( - const char *python_function_name, const char *session_dictionary_name, - lldb::ThreadSP &thread, std::string &output); - -extern "C" bool LLDBSWIGPythonRunScriptKeywordTarget( - const char *python_function_name, const char *session_dictionary_name, - lldb::TargetSP &target, std::string &output); - -extern "C" bool LLDBSWIGPythonRunScriptKeywordFrame( - const char *python_function_name, const char *session_dictionary_name, - lldb::StackFrameSP &frame, std::string &output); - -extern "C" bool LLDBSWIGPythonRunScriptKeywordValue( - const char *python_function_name, const char *session_dictionary_name, - lldb::ValueObjectSP &value, std::string &output); - -extern "C" void * -LLDBSWIGPython_GetDynamicSetting(void *module, const char *setting, - const lldb::TargetSP &target_sp); - -#endif - SystemInitializerFull::SystemInitializerFull() {} SystemInitializerFull::~SystemInitializerFull() {} -llvm::Error -SystemInitializerFull::Initialize(const InitializerOptions &options) { - if (auto e = SystemInitializerCommon::Initialize(options)) +llvm::Error SystemInitializerFull::Initialize() { + if (auto e = SystemInitializerCommon::Initialize()) return e; breakpad::ObjectFileBreakpad::Initialize(); @@ -276,6 +140,9 @@ SystemInitializerFull::Initialize(const InitializerOptions &options) { ObjectFileMachO::Initialize(); ObjectFilePECOFF::Initialize(); + ObjectContainerBSDArchive::Initialize(); + ObjectContainerUniversalMachO::Initialize(); + ScriptInterpreterNone::Initialize(); #ifndef LLDB_DISABLE_PYTHON @@ -283,11 +150,6 @@ SystemInitializerFull::Initialize(const InitializerOptions &options) { #endif #if !defined(LLDB_DISABLE_PYTHON) - InitializeSWIG(); - - // ScriptInterpreterPython::Initialize() depends on things like HostInfo - // being initialized so it can compute the python directory etc, so we need - // to do this after SystemInitializerCommon::Initialize(). ScriptInterpreterPython::Initialize(); #endif @@ -296,7 +158,6 @@ SystemInitializerFull::Initialize(const InitializerOptions &options) { platform_netbsd::PlatformNetBSD::Initialize(); platform_openbsd::PlatformOpenBSD::Initialize(); PlatformWindows::Initialize(); - PlatformKalimba::Initialize(); platform_android::PlatformAndroid::Initialize(); PlatformRemoteiOS::Initialize(); PlatformMacOSX::Initialize(); @@ -326,6 +187,7 @@ SystemInitializerFull::Initialize(const InitializerOptions &options) { ABISysV_mips::Initialize(); ABISysV_mips64::Initialize(); ABISysV_s390x::Initialize(); + ABIWindows_x86_64::Initialize(); ArchitectureArm::Initialize(); ArchitectureMips::Initialize(); @@ -350,8 +212,13 @@ SystemInitializerFull::Initialize(const InitializerOptions &options) { SymbolFileSymtab::Initialize(); UnwindAssemblyInstEmulation::Initialize(); UnwindAssembly_x86::Initialize(); + + EmulateInstructionARM::Initialize(); EmulateInstructionARM64::Initialize(); + EmulateInstructionMIPS::Initialize(); + EmulateInstructionMIPS64::Initialize(); EmulateInstructionPPC64::Initialize(); + SymbolFileDWARFDebugMap::Initialize(); ItaniumABILanguageRuntime::Initialize(); AppleObjCRuntimeV2::Initialize(); @@ -384,9 +251,7 @@ SystemInitializerFull::Initialize(const InitializerOptions &options) { // shouldn't be limited to __APPLE__. StructuredDataDarwinLog::Initialize(); - //---------------------------------------------------------------------- // Platform agnostic plugins - //---------------------------------------------------------------------- platform_gdb_server::PlatformRemoteGDBServer::Initialize(); process_gdb_remote::ProcessGDBRemote::Initialize(); @@ -408,31 +273,6 @@ SystemInitializerFull::Initialize(const InitializerOptions &options) { return llvm::Error::success(); } -void SystemInitializerFull::InitializeSWIG() { -#if !defined(LLDB_DISABLE_PYTHON) - ScriptInterpreterPython::InitializeInterpreter( - LLDBSwigPyInit, LLDBSwigPythonBreakpointCallbackFunction, - LLDBSwigPythonWatchpointCallbackFunction, LLDBSwigPythonCallTypeScript, - LLDBSwigPythonCreateSyntheticProvider, LLDBSwigPythonCreateCommandObject, - LLDBSwigPython_CalculateNumChildren, LLDBSwigPython_GetChildAtIndex, - LLDBSwigPython_GetIndexOfChildWithName, - LLDBSWIGPython_CastPyObjectToSBValue, - LLDBSWIGPython_GetValueObjectSPFromSBValue, - LLDBSwigPython_UpdateSynthProviderInstance, - LLDBSwigPython_MightHaveChildrenSynthProviderInstance, - LLDBSwigPython_GetValueSynthProviderInstance, LLDBSwigPythonCallCommand, - LLDBSwigPythonCallCommandObject, LLDBSwigPythonCallModuleInit, - LLDBSWIGPythonCreateOSPlugin, LLDBSWIGPython_CreateFrameRecognizer, - LLDBSwigPython_GetRecognizedArguments, - LLDBSWIGPythonRunScriptKeywordProcess, - LLDBSWIGPythonRunScriptKeywordThread, - LLDBSWIGPythonRunScriptKeywordTarget, LLDBSWIGPythonRunScriptKeywordFrame, - LLDBSWIGPythonRunScriptKeywordValue, LLDBSWIGPython_GetDynamicSetting, - LLDBSwigPythonCreateScriptedThreadPlan, LLDBSWIGPythonCallThreadPlan, - LLDBSwigPythonCreateScriptedBreakpointResolver, LLDBSwigPythonCallBreakpointResolver); -#endif -} - void SystemInitializerFull::Terminate() { static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); Timer scoped_timer(func_cat, LLVM_PRETTY_FUNCTION); @@ -461,6 +301,7 @@ void SystemInitializerFull::Terminate() { ABISysV_mips::Terminate(); ABISysV_mips64::Terminate(); ABISysV_s390x::Terminate(); + ABIWindows_x86_64::Terminate(); DisassemblerLLVMC::Terminate(); JITLoaderGDB::Terminate(); @@ -479,8 +320,13 @@ void SystemInitializerFull::Terminate() { SymbolFileSymtab::Terminate(); UnwindAssembly_x86::Terminate(); UnwindAssemblyInstEmulation::Terminate(); + + EmulateInstructionARM::Terminate(); EmulateInstructionARM64::Terminate(); + EmulateInstructionMIPS::Terminate(); + EmulateInstructionMIPS64::Terminate(); EmulateInstructionPPC64::Terminate(); + SymbolFileDWARFDebugMap::Terminate(); ItaniumABILanguageRuntime::Terminate(); AppleObjCRuntimeV2::Terminate(); @@ -527,7 +373,6 @@ void SystemInitializerFull::Terminate() { platform_netbsd::PlatformNetBSD::Terminate(); platform_openbsd::PlatformOpenBSD::Terminate(); PlatformWindows::Terminate(); - PlatformKalimba::Terminate(); platform_android::PlatformAndroid::Terminate(); PlatformMacOSX::Terminate(); PlatformRemoteiOS::Terminate(); @@ -541,6 +386,9 @@ void SystemInitializerFull::Terminate() { ObjectFileMachO::Terminate(); ObjectFilePECOFF::Terminate(); + ObjectContainerBSDArchive::Terminate(); + ObjectContainerUniversalMachO::Terminate(); + // Now shutdown the common parts, in reverse order. SystemInitializerCommon::Terminate(); } diff --git a/source/API/SystemInitializerFull.h b/source/API/SystemInitializerFull.h index b0cf476e91936..cd88bae978585 100644 --- a/source/API/SystemInitializerFull.h +++ b/source/API/SystemInitializerFull.h @@ -1,9 +1,8 @@ //===-- SystemInitializerFull.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -13,24 +12,19 @@ #include "lldb/Initialization/SystemInitializerCommon.h" namespace lldb_private { -//------------------------------------------------------------------ /// Initializes lldb. /// /// This class is responsible for initializing all of lldb system /// services needed to use the full LLDB application. This class is /// not intended to be used externally, but is instead used /// internally by SBDebugger to initialize the system. -//------------------------------------------------------------------ class SystemInitializerFull : public SystemInitializerCommon { public: SystemInitializerFull(); ~SystemInitializerFull() override; - llvm::Error Initialize(const InitializerOptions &options) override; + llvm::Error Initialize() override; void Terminate() override; - -private: - void InitializeSWIG(); }; } // namespace lldb_private diff --git a/source/API/Utils.h b/source/API/Utils.h new file mode 100644 index 0000000000000..b1975e5421ddf --- /dev/null +++ b/source/API/Utils.h @@ -0,0 +1,30 @@ +//===-- Utils.h -------------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_API_UTILS_H +#define LLDB_API_UTILS_H + +#include "llvm/ADT/STLExtras.h" +#include <memory> + +namespace lldb_private { + +template <typename T> std::unique_ptr<T> clone(const std::unique_ptr<T> &src) { + if (src) + return llvm::make_unique<T>(*src); + return nullptr; +} + +template <typename T> std::shared_ptr<T> clone(const std::shared_ptr<T> &src) { + if (src) + return std::make_shared<T>(*src); + return nullptr; +} + +} // namespace lldb_private +#endif |