diff options
Diffstat (limited to 'source/API/SBBreakpoint.cpp')
-rw-r--r-- | source/API/SBBreakpoint.cpp | 436 |
1 files changed, 315 insertions, 121 deletions
diff --git a/source/API/SBBreakpoint.cpp b/source/API/SBBreakpoint.cpp index b6720071e17c..45eaea6b6181 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, ()); +} + +} +} |