112 changes: 103 additions & 9 deletions lldb/source/API/SBAttachInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//

#include "lldb/API/SBAttachInfo.h"
#include "SBReproducerPrivate.h"
#include "Utils.h"
#include "lldb/API/SBFileSpec.h"
#include "lldb/API/SBListener.h"
Expand All @@ -15,22 +16,31 @@
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);
}

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);
Expand All @@ -39,6 +49,8 @@ SBAttachInfo::SBAttachInfo(const char *path, bool wait_for, bool async)

SBAttachInfo::SBAttachInfo(const SBAttachInfo &rhs)
: m_opaque_sp(new ProcessAttachInfo()) {
LLDB_RECORD_CONSTRUCTOR(SBAttachInfo, (const lldb::SBAttachInfo &), rhs);

m_opaque_sp = clone(rhs.m_opaque_sp);
}

Expand All @@ -47,120 +59,202 @@ 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 = clone(rhs.m_opaque_sp);
return *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
m_opaque_sp->GetExecutableFile().Clear();
}

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
m_opaque_sp->GetExecutableFile().Clear();
}

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);

uint32_t SBAttachInfo::GetGroupID() { return m_opaque_sp->GetGroupID(); }
return m_opaque_sp->GetUserID();
}

bool SBAttachInfo::UserIDIsValid() { return m_opaque_sp->UserIDIsValid(); }
uint32_t SBAttachInfo::GetGroupID() {
LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBAttachInfo, GetGroupID);

bool SBAttachInfo::GroupIDIsValid() { return m_opaque_sp->GroupIDIsValid(); }
return m_opaque_sp->GetGroupID();
}

void SBAttachInfo::SetUserID(uint32_t uid) { m_opaque_sp->SetUserID(uid); }
bool SBAttachInfo::UserIDIsValid() {
LLDB_RECORD_METHOD_NO_ARGS(bool, SBAttachInfo, UserIDIsValid);

void SBAttachInfo::SetGroupID(uint32_t gid) { m_opaque_sp->SetGroupID(gid); }
return m_opaque_sp->UserIDIsValid();
}

bool SBAttachInfo::GroupIDIsValid() {
LLDB_RECORD_METHOD_NO_ARGS(bool, SBAttachInfo, GroupIDIsValid);

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) {
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());
}
78 changes: 66 additions & 12 deletions lldb/source/API/SBBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//

#include "lldb/API/SBBlock.h"
#include "SBReproducerPrivate.h"
#include "lldb/API/SBAddress.h"
#include "lldb/API/SBFileSpec.h"
#include "lldb/API/SBFrame.h"
Expand All @@ -25,29 +26,44 @@
using namespace lldb;
using namespace lldb_private;

SBBlock::SBBlock() : m_opaque_ptr(NULL) {}
SBBlock::SBBlock() : m_opaque_ptr(NULL) {
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;
}

SBBlock::~SBBlock() { m_opaque_ptr = NULL; }

bool SBBlock::IsValid() const { return m_opaque_ptr != NULL; }
bool SBBlock::IsValid() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBlock, IsValid);

return m_opaque_ptr != NULL;
}

bool SBBlock::IsInlined() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBlock, IsInlined);

if (m_opaque_ptr)
return m_opaque_ptr->GetInlinedFunctionInfo() != NULL;
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();
Expand All @@ -65,17 +81,22 @@ const char *SBBlock::GetInlinedName() const {
}

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 =
m_opaque_ptr->GetInlinedFunctionInfo();
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();
Expand All @@ -86,6 +107,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();
Expand All @@ -105,38 +128,49 @@ 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; }

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) {
Expand All @@ -159,23 +193,31 @@ 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;
if (m_opaque_ptr->GetRangeAtIndex(idx, range)) {
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;
Expand All @@ -184,10 +226,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());
}
Expand All @@ -198,6 +243,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) {
Expand Down Expand Up @@ -244,11 +294,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;
Expand Down Expand Up @@ -292,5 +346,5 @@ lldb::SBValueList SBBlock::GetVariables(lldb::SBTarget &target, bool arguments,
}
}
}
return value_list;
return LLDB_RECORD_RESULT(value_list);
}
247 changes: 199 additions & 48 deletions lldb/source/API/SBBreakpoint.cpp

Large diffs are not rendered by default.

108 changes: 99 additions & 9 deletions lldb/source/API/SBBreakpointLocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//

#include "lldb/API/SBBreakpointLocation.h"
#include "SBReproducerPrivate.h"
#include "lldb/API/SBAddress.h"
#include "lldb/API/SBDebugger.h"
#include "lldb/API/SBDefines.h"
Expand All @@ -29,11 +30,16 @@
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) {
LLDB_RECORD_CONSTRUCTOR(SBBreakpointLocation,
(const lldb::BreakpointLocationSP &), break_loc_sp);

Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));

if (log) {
Expand All @@ -44,10 +50,18 @@ SBBreakpointLocation::SBBreakpointLocation(
}

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;
}
Expand All @@ -58,17 +72,27 @@ 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 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();

Expand All @@ -82,6 +106,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(
Expand All @@ -91,6 +117,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(
Expand All @@ -101,6 +129,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(
Expand All @@ -111,6 +141,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(
Expand All @@ -121,6 +153,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(
Expand All @@ -130,6 +164,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(
Expand All @@ -139,6 +176,8 @@ 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(
Expand All @@ -149,6 +188,9 @@ const char *SBBreakpointLocation::GetCondition() {
}

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(
Expand All @@ -158,6 +200,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(
Expand All @@ -169,6 +213,9 @@ bool SBBreakpointLocation::GetAutoContinue() {

void SBBreakpointLocation::SetScriptCallbackFunction(
const char *callback_function_name) {
LLDB_RECORD_METHOD(void, SBBreakpointLocation, SetScriptCallbackFunction,
(const char *), callback_function_name);

Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
BreakpointLocationSP loc_sp = GetSP();
LLDB_LOG(log, "location = {0}, callback = {1}", loc_sp.get(),
Expand All @@ -190,6 +237,9 @@ void SBBreakpointLocation::SetScriptCallbackFunction(

SBError
SBBreakpointLocation::SetScriptCallbackBody(const char *callback_body_text) {
LLDB_RECORD_METHOD(lldb::SBError, SBBreakpointLocation, SetScriptCallbackBody,
(const char *), callback_body_text);

Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
BreakpointLocationSP loc_sp = GetSP();
LLDB_LOG(log, "location = {0}: callback body:\n{1}", loc_sp.get(),
Expand All @@ -211,10 +261,13 @@ SBBreakpointLocation::SetScriptCallbackBody(const char *callback_body_text) {
} 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;
Expand All @@ -230,6 +283,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;
Expand All @@ -242,6 +298,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(
Expand All @@ -251,6 +310,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) {
Expand All @@ -262,6 +323,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(
Expand All @@ -271,6 +335,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) {
Expand All @@ -282,6 +349,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(
Expand All @@ -291,6 +361,9 @@ 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(
Expand All @@ -301,6 +374,9 @@ const char *SBBreakpointLocation::GetThreadName() const {
}

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(
Expand All @@ -310,6 +386,9 @@ 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(
Expand All @@ -320,6 +399,8 @@ const char *SBBreakpointLocation::GetQueueName() const {
}

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(
Expand All @@ -337,6 +418,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();

Expand All @@ -352,6 +437,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(
Expand All @@ -362,6 +449,9 @@ break_id_t SBBreakpointLocation::GetID() {
}

SBBreakpoint SBBreakpointLocation::GetBreakpoint() {
LLDB_RECORD_METHOD_NO_ARGS(lldb::SBBreakpoint, SBBreakpointLocation,
GetBreakpoint);

Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
BreakpointLocationSP loc_sp = GetSP();

Expand All @@ -378,5 +468,5 @@ SBBreakpoint SBBreakpointLocation::GetBreakpoint() {
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);
}
148 changes: 120 additions & 28 deletions lldb/source/API/SBBreakpointName.cpp

Large diffs are not rendered by default.

55 changes: 52 additions & 3 deletions lldb/source/API/SBBroadcaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//

#include "SBReproducerPrivate.h"
#include "lldb/Utility/Broadcaster.h"
#include "lldb/Utility/Log.h"

Expand All @@ -16,10 +17,14 @@
using namespace lldb;
using namespace lldb_private;

SBBroadcaster::SBBroadcaster() : m_opaque_sp(), m_opaque_ptr(NULL) {}
SBBroadcaster::SBBroadcaster() : m_opaque_sp(), m_opaque_ptr(NULL) {
LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBBroadcaster);
}

SBBroadcaster::SBBroadcaster(const char *name)
: m_opaque_sp(new Broadcaster(NULL, name)), m_opaque_ptr(NULL) {
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);
Expand All @@ -33,9 +38,15 @@ SBBroadcaster::SBBroadcaster(lldb_private::Broadcaster *broadcaster, bool owns)
}

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;
Expand All @@ -46,6 +57,9 @@ const SBBroadcaster &SBBroadcaster::operator=(const SBBroadcaster &rhs) {
SBBroadcaster::~SBBroadcaster() { reset(NULL, false); }

void SBBroadcaster::BroadcastEventByType(uint32_t event_type, bool unique) {
LLDB_RECORD_METHOD(void, SBBroadcaster, BroadcastEventByType,
(uint32_t, bool), event_type, unique);

Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));

if (log)
Expand All @@ -63,6 +77,9 @@ void SBBroadcaster::BroadcastEventByType(uint32_t event_type, bool unique) {
}

void SBBroadcaster::BroadcastEvent(const SBEvent &event, bool unique) {
LLDB_RECORD_METHOD(void, SBBroadcaster, BroadcastEvent,
(const lldb::SBEvent &, bool), event, unique);

Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));

if (log)
Expand All @@ -83,6 +100,10 @@ void SBBroadcaster::BroadcastEvent(const SBEvent &event, bool unique) {

void SBBroadcaster::AddInitialEventsToListener(const SBListener &listener,
uint32_t requested_events) {
LLDB_RECORD_METHOD(void, SBBroadcaster, AddInitialEventsToListener,
(const lldb::SBListener &, uint32_t), listener,
requested_events);

Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
if (log)
log->Printf("SBBroadcaster(%p)::AddInitialEventsToListener "
Expand All @@ -96,25 +117,38 @@ 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;
}

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;
}

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;
Expand All @@ -130,21 +164,36 @@ 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 m_opaque_ptr != NULL;
}

void SBBroadcaster::Clear() {
LLDB_RECORD_METHOD_NO_ARGS(void, SBBroadcaster, Clear);

m_opaque_sp.reset();
m_opaque_ptr = NULL;
}

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;
}
258 changes: 233 additions & 25 deletions lldb/source/API/SBCommandInterpreter.cpp

Large diffs are not rendered by default.

88 changes: 85 additions & 3 deletions lldb/source/API/SBCommandReturnObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//

#include "lldb/API/SBCommandReturnObject.h"
#include "SBReproducerPrivate.h"
#include "Utils.h"
#include "lldb/API/SBError.h"
#include "lldb/API/SBStream.h"
Expand All @@ -19,32 +20,54 @@ using namespace lldb;
using namespace lldb_private;

SBCommandReturnObject::SBCommandReturnObject()
: m_opaque_up(new CommandReturnObject()) {}
: m_opaque_up(new CommandReturnObject()) {
LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBCommandReturnObject);
}

SBCommandReturnObject::SBCommandReturnObject(const SBCommandReturnObject &rhs)
: 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_up(ptr) {}
: m_opaque_up(ptr) {
LLDB_RECORD_CONSTRUCTOR(SBCommandReturnObject,
(lldb_private::CommandReturnObject *), ptr);
}

SBCommandReturnObject::~SBCommandReturnObject() = default;

CommandReturnObject *SBCommandReturnObject::Release() {
LLDB_RECORD_METHOD_NO_ARGS(lldb_private::CommandReturnObject *,
SBCommandReturnObject, Release);

return m_opaque_up.release();
}

const SBCommandReturnObject &SBCommandReturnObject::
operator=(const SBCommandReturnObject &rhs) {
LLDB_RECORD_METHOD(
const lldb::SBCommandReturnObject &,
SBCommandReturnObject, operator=,(const lldb::SBCommandReturnObject &),
rhs);

if (this != &rhs)
m_opaque_up = clone(rhs.m_opaque_up);
return *this;
}

bool SBCommandReturnObject::IsValid() const { return m_opaque_up != nullptr; }
bool SBCommandReturnObject::IsValid() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandReturnObject, IsValid);

return m_opaque_up != nullptr;
}

const char *SBCommandReturnObject::GetOutput() {
LLDB_RECORD_METHOD_NO_ARGS(const char *, SBCommandReturnObject, GetOutput);

Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));

if (m_opaque_up) {
Expand All @@ -66,6 +89,8 @@ const char *SBCommandReturnObject::GetOutput() {
}

const char *SBCommandReturnObject::GetError() {
LLDB_RECORD_METHOD_NO_ARGS(const char *, SBCommandReturnObject, GetError);

Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));

if (m_opaque_up) {
Expand All @@ -86,14 +111,20 @@ const char *SBCommandReturnObject::GetError() {
}

size_t SBCommandReturnObject::GetOutputSize() {
LLDB_RECORD_METHOD_NO_ARGS(size_t, SBCommandReturnObject, GetOutputSize);

return (m_opaque_up ? m_opaque_up->GetOutputData().size() : 0);
}

size_t SBCommandReturnObject::GetErrorSize() {
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)
Expand All @@ -103,6 +134,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)
Expand All @@ -112,33 +145,51 @@ size_t SBCommandReturnObject::PutError(FILE *fh) {
}

void SBCommandReturnObject::Clear() {
LLDB_RECORD_METHOD_NO_ARGS(void, SBCommandReturnObject, Clear);

if (m_opaque_up)
m_opaque_up->Clear();
}

lldb::ReturnStatus SBCommandReturnObject::GetStatus() {
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) {
LLDB_RECORD_METHOD(void, SBCommandReturnObject, SetStatus,
(lldb::ReturnStatus), status);

if (m_opaque_up)
m_opaque_up->SetStatus(status);
}

bool SBCommandReturnObject::Succeeded() {
LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommandReturnObject, Succeeded);

return (m_opaque_up ? m_opaque_up->Succeeded() : false);
}

bool SBCommandReturnObject::HasResult() {
LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommandReturnObject, HasResult);

return (m_opaque_up ? m_opaque_up->HasResult() : false);
}

void SBCommandReturnObject::AppendMessage(const char *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) {
LLDB_RECORD_METHOD(void, SBCommandReturnObject, AppendWarning, (const char *),
message);

if (m_opaque_up)
m_opaque_up->AppendWarning(message);
}
Expand Down Expand Up @@ -167,6 +218,9 @@ void SBCommandReturnObject::SetLLDBObjectPtr(CommandReturnObject *ptr) {
}

bool SBCommandReturnObject::GetDescription(SBStream &description) {
LLDB_RECORD_METHOD(bool, SBCommandReturnObject, GetDescription,
(lldb::SBStream &), description);

Stream &strm = description.ref();

if (m_opaque_up) {
Expand All @@ -193,26 +247,41 @@ 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) {
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) {
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) {
LLDB_RECORD_METHOD(void, SBCommandReturnObject, PutCString,
(const char *, int), string, len);

if (m_opaque_up) {
if (len == 0 || string == nullptr || *string == 0) {
return;
Expand All @@ -225,6 +294,9 @@ void SBCommandReturnObject::PutCString(const char *string, int len) {
}

const char *SBCommandReturnObject::GetOutput(bool only_if_no_immediate) {
LLDB_RECORD_METHOD(const char *, SBCommandReturnObject, GetOutput, (bool),
only_if_no_immediate);

if (!m_opaque_up)
return nullptr;
if (!only_if_no_immediate ||
Expand All @@ -234,6 +306,9 @@ const char *SBCommandReturnObject::GetOutput(bool only_if_no_immediate) {
}

const char *SBCommandReturnObject::GetError(bool only_if_no_immediate) {
LLDB_RECORD_METHOD(const char *, SBCommandReturnObject, GetError, (bool),
only_if_no_immediate);

if (!m_opaque_up)
return nullptr;
if (!only_if_no_immediate ||
Expand All @@ -255,6 +330,10 @@ size_t SBCommandReturnObject::Printf(const char *format, ...) {

void SBCommandReturnObject::SetError(lldb::SBError &error,
const char *fallback_error_cstr) {
LLDB_RECORD_METHOD(void, SBCommandReturnObject, SetError,
(lldb::SBError &, const char *), error,
fallback_error_cstr);

if (m_opaque_up) {
if (error.IsValid())
m_opaque_up->SetError(error.ref(), fallback_error_cstr);
Expand All @@ -264,6 +343,9 @@ void SBCommandReturnObject::SetError(lldb::SBError &error,
}

void SBCommandReturnObject::SetError(const char *error_cstr) {
LLDB_RECORD_METHOD(void, SBCommandReturnObject, SetError, (const char *),
error_cstr);

if (m_opaque_up && error_cstr)
m_opaque_up->SetError(error_cstr);
}
42 changes: 39 additions & 3 deletions lldb/source/API/SBCommunication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//

#include "lldb/API/SBCommunication.h"
#include "SBReproducerPrivate.h"
#include "lldb/API/SBBroadcaster.h"
#include "lldb/Core/Communication.h"
#include "lldb/Host/ConnectionFileDescriptor.h"
Expand All @@ -16,10 +17,14 @@
using namespace lldb;
using namespace lldb_private;

SBCommunication::SBCommunication() : m_opaque(NULL), m_opaque_owned(false) {}
SBCommunication::SBCommunication() : m_opaque(NULL), 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) {
LLDB_RECORD_CONSTRUCTOR(SBCommunication, (const char *), broadcaster_name);

Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));

if (log)
Expand All @@ -35,20 +40,31 @@ SBCommunication::~SBCommunication() {
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 m_opaque != NULL;
}

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());
Expand All @@ -58,6 +74,9 @@ ConnectionStatus SBCommunication::Connect(const char *url) {
}

ConnectionStatus SBCommunication::AdoptFileDesriptor(int fd, bool owns_fd) {
LLDB_RECORD_METHOD(lldb::ConnectionStatus, SBCommunication,
AdoptFileDesriptor, (int, bool), fd, owns_fd);

Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));

ConnectionStatus status = eConnectionStatusNoConnection;
Expand All @@ -83,6 +102,9 @@ ConnectionStatus SBCommunication::AdoptFileDesriptor(int fd, bool owns_fd) {
}

ConnectionStatus SBCommunication::Disconnect() {
LLDB_RECORD_METHOD_NO_ARGS(lldb::ConnectionStatus, SBCommunication,
Disconnect);

Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));

ConnectionStatus status = eConnectionStatusNoConnection;
Expand All @@ -98,6 +120,8 @@ ConnectionStatus SBCommunication::Disconnect() {
}

bool SBCommunication::IsConnected() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommunication, IsConnected);

Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
bool result = false;
if (m_opaque)
Expand Down Expand Up @@ -158,6 +182,8 @@ size_t SBCommunication::Write(const void *src, size_t src_len,
}

bool SBCommunication::ReadThreadStart() {
LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommunication, ReadThreadStart);

Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));

bool success = false;
Expand All @@ -172,6 +198,8 @@ bool SBCommunication::ReadThreadStart() {
}

bool SBCommunication::ReadThreadStop() {
LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommunication, ReadThreadStop);

Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
if (log)
log->Printf("SBCommunication(%p)::ReadThreadStop ()...",
Expand All @@ -189,6 +217,8 @@ bool SBCommunication::ReadThreadStop() {
}

bool SBCommunication::ReadThreadIsRunning() {
LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommunication, ReadThreadIsRunning);

bool result = false;
if (m_opaque)
result = m_opaque->ReadThreadIsRunning();
Expand Down Expand Up @@ -220,6 +250,9 @@ bool SBCommunication::SetReadThreadBytesReceivedCallback(
}

SBBroadcaster SBCommunication::GetBroadcaster() {
LLDB_RECORD_METHOD_NO_ARGS(lldb::SBBroadcaster, SBCommunication,
GetBroadcaster);

SBBroadcaster broadcaster(m_opaque, false);

Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
Expand All @@ -229,10 +262,13 @@ SBBroadcaster SBCommunication::GetBroadcaster() {
static_cast<void *>(m_opaque),
static_cast<void *>(broadcaster.get()));

return broadcaster;
return LLDB_RECORD_RESULT(broadcaster);
}

const char *SBCommunication::GetBroadcasterClass() {
LLDB_RECORD_STATIC_METHOD_NO_ARGS(const char *, SBCommunication,
GetBroadcasterClass);

return Communication::GetStaticBroadcasterClass().AsCString();
}

Expand Down
72 changes: 62 additions & 10 deletions lldb/source/API/SBCompileUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//

#include "lldb/API/SBCompileUnit.h"
#include "SBReproducerPrivate.h"
#include "lldb/API/SBLineEntry.h"
#include "lldb/API/SBStream.h"
#include "lldb/Core/Module.h"
Expand All @@ -20,29 +21,42 @@
using namespace lldb;
using namespace lldb_private;

SBCompileUnit::SBCompileUnit() : m_opaque_ptr(NULL) {}
SBCompileUnit::SBCompileUnit() : m_opaque_ptr(NULL) {
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;
}

SBCompileUnit::~SBCompileUnit() { m_opaque_ptr = NULL; }

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)
Expand All @@ -52,6 +66,9 @@ uint32_t SBCompileUnit::GetNumLineEntries() const {
}

SBLineEntry SBCompileUnit::GetLineEntryAtIndex(uint32_t idx) const {
LLDB_RECORD_METHOD_CONST(lldb::SBLineEntry, SBCompileUnit,
GetLineEntryAtIndex, (uint32_t), idx);

Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));

SBLineEntry sb_line_entry;
Expand All @@ -73,18 +90,26 @@ SBLineEntry SBCompileUnit::GetLineEntryAtIndex(uint32_t idx) const {
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);
}

uint32_t SBCompileUnit::FindLineEntryIndex(uint32_t start_idx, uint32_t line,
SBFileSpec *inline_file_spec,
bool exact) const {
LLDB_RECORD_METHOD_CONST(uint32_t, SBCompileUnit, FindLineEntryIndex,
(uint32_t, uint32_t, lldb::SBFileSpec *, bool),
start_idx, line, inline_file_spec, exact);

Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));

uint32_t index = UINT32_MAX;
Expand Down Expand Up @@ -124,6 +149,8 @@ uint32_t SBCompileUnit::FindLineEntryIndex(uint32_t start_idx, uint32_t line,
}

uint32_t SBCompileUnit::GetNumSupportFiles() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBCompileUnit, GetNumSupportFiles);

if (m_opaque_ptr) {
FileSpecList &support_files = m_opaque_ptr->GetSupportFiles();
return support_files.GetSize();
Expand All @@ -132,27 +159,33 @@ uint32_t SBCompileUnit::GetNumSupportFiles() const {
}

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_up->Append(type_list);
return sb_type_list;
return LLDB_RECORD_RESULT(sb_type_list);
}

SBFileSpec SBCompileUnit::GetSupportFileAtIndex(uint32_t idx) const {
LLDB_RECORD_METHOD_CONST(lldb::SBFileSpec, SBCompileUnit,
GetSupportFileAtIndex, (uint32_t), idx);

Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));

SBFileSpec sb_file_spec;
Expand All @@ -171,12 +204,16 @@ SBFileSpec SBCompileUnit::GetSupportFileAtIndex(uint32_t idx) const {
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();
return support_files.FindFileIndex(start_idx, sb_file.ref(), full);
Expand All @@ -185,18 +222,30 @@ uint32_t SBCompileUnit::FindSupportFileIndex(uint32_t start_idx,
}

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 m_opaque_ptr != NULL;
}

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;
}

Expand All @@ -215,6 +264,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) {
Expand Down
140 changes: 125 additions & 15 deletions lldb/source/API/SBData.cpp

Large diffs are not rendered by default.

393 changes: 331 additions & 62 deletions lldb/source/API/SBDebugger.cpp

Large diffs are not rendered by default.

46 changes: 42 additions & 4 deletions lldb/source/API/SBDeclaration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//

#include "lldb/API/SBDeclaration.h"
#include "SBReproducerPrivate.h"
#include "Utils.h"
#include "lldb/API/SBStream.h"
#include "lldb/Host/PosixApi.h"
Expand All @@ -19,9 +20,13 @@
using namespace lldb;
using namespace lldb_private;

SBDeclaration::SBDeclaration() : m_opaque_up() {}
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);

m_opaque_up = clone(rhs.m_opaque_up);
}

Expand All @@ -32,6 +37,10 @@ SBDeclaration::SBDeclaration(const lldb_private::Declaration *lldb_object_ptr)
}

const SBDeclaration &SBDeclaration::operator=(const SBDeclaration &rhs) {
LLDB_RECORD_METHOD(const lldb::SBDeclaration &,
SBDeclaration, operator=,(const lldb::SBDeclaration &),
rhs);

if (this != &rhs)
m_opaque_up = clone(rhs.m_opaque_up);
return *this;
Expand All @@ -45,10 +54,15 @@ void SBDeclaration::SetDeclaration(
SBDeclaration::~SBDeclaration() {}

bool SBDeclaration::IsValid() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBDeclaration, IsValid);

return m_opaque_up.get() && m_opaque_up->IsValid();
}

SBFileSpec SBDeclaration::GetFileSpec() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBFileSpec, SBDeclaration,
GetFileSpec);

Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));

SBFileSpec sb_file_spec;
Expand All @@ -63,10 +77,12 @@ SBFileSpec SBDeclaration::GetFileSpec() const {
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 {
LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBDeclaration, GetLine);

Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));

uint32_t line = 0;
Expand All @@ -81,22 +97,38 @@ uint32_t SBDeclaration::GetLine() const {
}

uint32_t SBDeclaration::GetColumn() const {
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_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();

Expand All @@ -107,6 +139,9 @@ bool SBDeclaration::operator==(const SBDeclaration &rhs) const {
}

bool SBDeclaration::operator!=(const SBDeclaration &rhs) const {
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();

Expand All @@ -131,6 +166,9 @@ const lldb_private::Declaration &SBDeclaration::ref() const {
}

bool SBDeclaration::GetDescription(SBStream &description) {
LLDB_RECORD_METHOD(bool, SBDeclaration, GetDescription, (lldb::SBStream &),
description);

Stream &strm = description.ref();

if (m_opaque_up) {
Expand Down
38 changes: 36 additions & 2 deletions lldb/source/API/SBError.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//

#include "lldb/API/SBError.h"
#include "SBReproducerPrivate.h"
#include "Utils.h"
#include "lldb/API/SBStream.h"
#include "lldb/Utility/Log.h"
Expand All @@ -17,32 +18,43 @@
using namespace lldb;
using namespace lldb_private;

SBError::SBError() : m_opaque_up() {}
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);

m_opaque_up = clone(rhs.m_opaque_up);
}

SBError::~SBError() {}

const SBError &SBError::operator=(const SBError &rhs) {
LLDB_RECORD_METHOD(const lldb::SBError &,
SBError, operator=,(const lldb::SBError &), rhs);

if (this != &rhs)
m_opaque_up = clone(rhs.m_opaque_up);
return *this;
}

const char *SBError::GetCString() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBError, GetCString);

if (m_opaque_up)
return m_opaque_up->AsCString();
return NULL;
}

void SBError::Clear() {
LLDB_RECORD_METHOD_NO_ARGS(void, SBError, Clear);

if (m_opaque_up)
m_opaque_up->Clear();
}

bool SBError::Fail() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBError, Fail);

Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));

bool ret_value = false;
Expand All @@ -57,6 +69,8 @@ bool SBError::Fail() const {
}

bool SBError::Success() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBError, Success);

Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
bool ret_value = true;
if (m_opaque_up)
Expand All @@ -70,6 +84,8 @@ bool SBError::Success() const {
}

uint32_t SBError::GetError() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBError, GetError);

Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));

uint32_t err = 0;
Expand All @@ -84,6 +100,8 @@ uint32_t SBError::GetError() const {
}

ErrorType SBError::GetType() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::ErrorType, SBError, GetType);

Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
ErrorType err_type = eErrorTypeInvalid;
if (m_opaque_up)
Expand All @@ -97,6 +115,9 @@ ErrorType SBError::GetType() const {
}

void SBError::SetError(uint32_t err, ErrorType type) {
LLDB_RECORD_METHOD(void, SBError, SetError, (uint32_t, lldb::ErrorType), err,
type);

CreateIfNeeded();
m_opaque_up->SetError(err, type);
}
Expand All @@ -107,16 +128,22 @@ void SBError::SetError(const Status &lldb_error) {
}

void SBError::SetErrorToErrno() {
LLDB_RECORD_METHOD_NO_ARGS(void, SBError, SetErrorToErrno);

CreateIfNeeded();
m_opaque_up->SetErrorToErrno();
}

void SBError::SetErrorToGenericError() {
LLDB_RECORD_METHOD_NO_ARGS(void, SBError, SetErrorToGenericError);

CreateIfNeeded();
m_opaque_up->SetErrorToErrno();
}

void SBError::SetErrorString(const char *err_str) {
LLDB_RECORD_METHOD(void, SBError, SetErrorString, (const char *), err_str);

CreateIfNeeded();
m_opaque_up->SetErrorString(err_str);
}
Expand All @@ -130,7 +157,11 @@ int SBError::SetErrorStringWithFormat(const char *format, ...) {
return num_chars;
}

bool SBError::IsValid() const { return m_opaque_up != NULL; }
bool SBError::IsValid() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBError, IsValid);

return m_opaque_up != NULL;
}

void SBError::CreateIfNeeded() {
if (m_opaque_up == NULL)
Expand All @@ -152,6 +183,9 @@ const lldb_private::Status &SBError::operator*() const {
}

bool SBError::GetDescription(SBStream &description) {
LLDB_RECORD_METHOD(bool, SBError, GetDescription, (lldb::SBStream &),
description);

if (m_opaque_up) {
if (m_opaque_up->Success())
description.Printf("success");
Expand Down
54 changes: 48 additions & 6 deletions lldb/source/API/SBEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//

#include "lldb/API/SBEvent.h"
#include "SBReproducerPrivate.h"
#include "lldb/API/SBBroadcaster.h"
#include "lldb/API/SBStream.h"

Expand All @@ -21,21 +22,35 @@
using namespace lldb;
using namespace lldb_private;

SBEvent::SBEvent() : m_event_sp(), m_opaque_ptr(NULL) {}
SBEvent::SBEvent() : m_event_sp(), m_opaque_ptr(NULL) {
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;
Expand All @@ -46,6 +61,8 @@ const SBEvent &SBEvent::operator=(const SBEvent &rhs) {
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();
Expand All @@ -56,6 +73,8 @@ const char *SBEvent::GetDataFlavor() {
}

uint32_t SBEvent::GetType() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBEvent, GetType);

Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));

const Event *lldb_event = get();
Expand All @@ -78,14 +97,19 @@ uint32_t SBEvent::GetType() const {
}

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();
Expand All @@ -94,12 +118,17 @@ 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;
Expand All @@ -116,6 +145,8 @@ bool SBEvent::BroadcasterMatchesRef(const SBBroadcaster &broadcaster) {
}

void SBEvent::Clear() {
LLDB_RECORD_METHOD_NO_ARGS(void, SBEvent, Clear);

Event *lldb_event = get();
if (lldb_event)
lldb_event->Clear();
Expand Down Expand Up @@ -145,12 +176,17 @@ void SBEvent::reset(Event *event_ptr) {
}

bool SBEvent::IsValid() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBEvent, IsValid);

// Do NOT use m_opaque_ptr directly!!! Must use the SBEvent::get() accessor.
// See comments in SBEvent::get()....
return SBEvent::get() != NULL;
}

const char *SBEvent::GetCStringFromEvent(const SBEvent &event) {
LLDB_RECORD_STATIC_METHOD(const char *, SBEvent, GetCStringFromEvent,
(const lldb::SBEvent &), event);

Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));

if (log)
Expand All @@ -164,6 +200,9 @@ const char *SBEvent::GetCStringFromEvent(const SBEvent &event) {
}

bool SBEvent::GetDescription(SBStream &description) {
LLDB_RECORD_METHOD(bool, SBEvent, GetDescription, (lldb::SBStream &),
description);

Stream &strm = description.ref();

if (get()) {
Expand All @@ -175,6 +214,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()) {
Expand Down
47 changes: 40 additions & 7 deletions lldb/source/API/SBExecutionContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//

#include "lldb/API/SBExecutionContext.h"
#include "SBReproducerPrivate.h"

#include "lldb/API/SBFrame.h"
#include "lldb/API/SBProcess.h"
Expand All @@ -19,39 +20,60 @@
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());
}

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;
}
Expand All @@ -61,41 +83,52 @@ 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);
}
95 changes: 94 additions & 1 deletion lldb/source/API/SBExpressionOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//

#include "lldb/API/SBExpressionOptions.h"
#include "SBReproducerPrivate.h"
#include "Utils.h"
#include "lldb/API/SBStream.h"
#include "lldb/Target/Target.h"
Expand All @@ -16,15 +17,24 @@ using namespace lldb;
using namespace lldb_private;

SBExpressionOptions::SBExpressionOptions()
: m_opaque_up(new EvaluateExpressionOptions()) {}
: m_opaque_up(new EvaluateExpressionOptions()) {
LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBExpressionOptions);
}

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) {
LLDB_RECORD_METHOD(
const lldb::SBExpressionOptions &,
SBExpressionOptions, operator=,(const lldb::SBExpressionOptions &), rhs);

if (this != &rhs)
m_opaque_up = clone(rhs.m_opaque_up);
return *this;
Expand All @@ -33,83 +43,137 @@ operator=(const SBExpressionOptions &rhs) {
SBExpressionOptions::~SBExpressionOptions() {}

bool SBExpressionOptions::GetCoerceResultToId() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions,
GetCoerceResultToId);

return m_opaque_up->DoesCoerceToId();
}

void SBExpressionOptions::SetCoerceResultToId(bool coerce) {
LLDB_RECORD_METHOD(void, SBExpressionOptions, SetCoerceResultToId, (bool),
coerce);

m_opaque_up->SetCoerceToId(coerce);
}

bool SBExpressionOptions::GetUnwindOnError() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions, GetUnwindOnError);

return m_opaque_up->DoesUnwindOnError();
}

void SBExpressionOptions::SetUnwindOnError(bool unwind) {
LLDB_RECORD_METHOD(void, SBExpressionOptions, SetUnwindOnError, (bool),
unwind);

m_opaque_up->SetUnwindOnError(unwind);
}

bool SBExpressionOptions::GetIgnoreBreakpoints() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions,
GetIgnoreBreakpoints);

return m_opaque_up->DoesIgnoreBreakpoints();
}

void SBExpressionOptions::SetIgnoreBreakpoints(bool ignore) {
LLDB_RECORD_METHOD(void, SBExpressionOptions, SetIgnoreBreakpoints, (bool),
ignore);

m_opaque_up->SetIgnoreBreakpoints(ignore);
}

lldb::DynamicValueType SBExpressionOptions::GetFetchDynamicValue() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::DynamicValueType, SBExpressionOptions,
GetFetchDynamicValue);

return m_opaque_up->GetUseDynamic();
}

void SBExpressionOptions::SetFetchDynamicValue(lldb::DynamicValueType dynamic) {
LLDB_RECORD_METHOD(void, SBExpressionOptions, SetFetchDynamicValue,
(lldb::DynamicValueType), dynamic);

m_opaque_up->SetUseDynamic(dynamic);
}

uint32_t SBExpressionOptions::GetTimeoutInMicroSeconds() const {
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) {
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 {
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) {
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 {
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions, GetTryAllThreads);

return m_opaque_up->GetTryAllThreads();
}

void SBExpressionOptions::SetTryAllThreads(bool run_others) {
LLDB_RECORD_METHOD(void, SBExpressionOptions, SetTryAllThreads, (bool),
run_others);

m_opaque_up->SetTryAllThreads(run_others);
}

bool SBExpressionOptions::GetStopOthers() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions, GetStopOthers);

return m_opaque_up->GetStopOthers();
}

void SBExpressionOptions::SetStopOthers(bool run_others) {
LLDB_RECORD_METHOD(void, SBExpressionOptions, SetStopOthers, (bool),
run_others);

m_opaque_up->SetStopOthers(run_others);
}

bool SBExpressionOptions::GetTrapExceptions() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions,
GetTrapExceptions);

return m_opaque_up->GetTrapExceptions();
}

void SBExpressionOptions::SetTrapExceptions(bool trap_exceptions) {
LLDB_RECORD_METHOD(void, SBExpressionOptions, SetTrapExceptions, (bool),
trap_exceptions);

m_opaque_up->SetTrapExceptions(trap_exceptions);
}

void SBExpressionOptions::SetLanguage(lldb::LanguageType language) {
LLDB_RECORD_METHOD(void, SBExpressionOptions, SetLanguage,
(lldb::LanguageType), language);

m_opaque_up->SetLanguage(language);
}

Expand All @@ -119,51 +183,80 @@ void SBExpressionOptions::SetCancelCallback(
}

bool SBExpressionOptions::GetGenerateDebugInfo() {
LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions, GetGenerateDebugInfo);

return m_opaque_up->GetGenerateDebugInfo();
}

void SBExpressionOptions::SetGenerateDebugInfo(bool b) {
LLDB_RECORD_METHOD(void, SBExpressionOptions, SetGenerateDebugInfo, (bool),
b);

return m_opaque_up->SetGenerateDebugInfo(b);
}

bool SBExpressionOptions::GetSuppressPersistentResult() {
LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions,
GetSuppressPersistentResult);

return m_opaque_up->GetResultIsInternal();
}

void SBExpressionOptions::SetSuppressPersistentResult(bool b) {
LLDB_RECORD_METHOD(void, SBExpressionOptions, SetSuppressPersistentResult,
(bool), b);

return m_opaque_up->SetResultIsInternal(b);
}

const char *SBExpressionOptions::GetPrefix() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBExpressionOptions,
GetPrefix);

return m_opaque_up->GetPrefix();
}

void SBExpressionOptions::SetPrefix(const char *prefix) {
LLDB_RECORD_METHOD(void, SBExpressionOptions, SetPrefix, (const char *),
prefix);

return m_opaque_up->SetPrefix(prefix);
}

bool SBExpressionOptions::GetAutoApplyFixIts() {
LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions, GetAutoApplyFixIts);

return m_opaque_up->GetAutoApplyFixIts();
}

void SBExpressionOptions::SetAutoApplyFixIts(bool b) {
LLDB_RECORD_METHOD(void, SBExpressionOptions, SetAutoApplyFixIts, (bool), b);

return m_opaque_up->SetAutoApplyFixIts(b);
}

bool SBExpressionOptions::GetTopLevel() {
LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions, GetTopLevel);

return m_opaque_up->GetExecutionPolicy() == eExecutionPolicyTopLevel;
}

void SBExpressionOptions::SetTopLevel(bool b) {
LLDB_RECORD_METHOD(void, SBExpressionOptions, SetTopLevel, (bool), b);

m_opaque_up->SetExecutionPolicy(b ? eExecutionPolicyTopLevel
: m_opaque_up->default_execution_policy);
}

bool SBExpressionOptions::GetAllowJIT() {
LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions, GetAllowJIT);

return m_opaque_up->GetExecutionPolicy() != eExecutionPolicyNever;
}

void SBExpressionOptions::SetAllowJIT(bool allow) {
LLDB_RECORD_METHOD(void, SBExpressionOptions, SetAllowJIT, (bool), allow);

m_opaque_up->SetExecutionPolicy(allow ? m_opaque_up->default_execution_policy
: eExecutionPolicyNever);
}
Expand Down
52 changes: 46 additions & 6 deletions lldb/source/API/SBFileSpec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
//
//===----------------------------------------------------------------------===//

#include <inttypes.h>
#include <limits.h>

#include "Utils.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"
Expand All @@ -20,12 +18,19 @@

#include "llvm/ADT/SmallString.h"

#include <inttypes.h>
#include <limits.h>

using namespace lldb;
using namespace lldb_private;

SBFileSpec::SBFileSpec() : m_opaque_up(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_up() {
LLDB_RECORD_CONSTRUCTOR(SBFileSpec, (const lldb::SBFileSpec &), rhs);

m_opaque_up = clone(rhs.m_opaque_up);
}

Expand All @@ -34,26 +39,39 @@ SBFileSpec::SBFileSpec(const lldb_private::FileSpec &fspec)

// Deprecated!!!
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_up(new FileSpec(path)) {
LLDB_RECORD_CONSTRUCTOR(SBFileSpec, (const char *, bool), path, resolve);

if (resolve)
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_up = clone(rhs.m_opaque_up);
return *this;
}

bool SBFileSpec::IsValid() const { return m_opaque_up->operator bool(); }
bool SBFileSpec::IsValid() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBFileSpec, IsValid);

return m_opaque_up->operator bool();
}

bool SBFileSpec::Exists() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBFileSpec, Exists);

Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));

bool result = FileSystem::Instance().Exists(*m_opaque_up);
Expand All @@ -67,18 +85,26 @@ bool SBFileSpec::Exists() const {
}

bool SBFileSpec::ResolveExecutableLocation() {
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());
return std::min(dst_len - 1, result.size());
}

const char *SBFileSpec::GetFilename() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBFileSpec, GetFilename);

const char *s = m_opaque_up->GetFilename().AsCString();

Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
Expand All @@ -95,6 +121,8 @@ const char *SBFileSpec::GetFilename() const {
}

const char *SBFileSpec::GetDirectory() const {
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));
Expand All @@ -111,20 +139,27 @@ const char *SBFileSpec::GetDirectory() const {
}

void SBFileSpec::SetFilename(const char *filename) {
LLDB_RECORD_METHOD(void, SBFileSpec, SetFilename, (const char *), filename);

if (filename && filename[0])
m_opaque_up->GetFilename().SetCString(filename);
else
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_up->GetDirectory().SetCString(directory);
else
m_opaque_up->GetDirectory().Clear();
}

uint32_t SBFileSpec::GetPath(char *dst_path, size_t dst_len) const {
LLDB_RECORD_METHOD_CONST(uint32_t, SBFileSpec, GetPath, (char *, size_t),
dst_path, dst_len);

Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));

uint32_t result = m_opaque_up->GetPath(dst_path, dst_len);
Expand Down Expand Up @@ -159,6 +194,9 @@ void SBFileSpec::SetFileSpec(const lldb_private::FileSpec &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_up->GetPath(path, sizeof(path)))
Expand All @@ -167,5 +205,7 @@ bool SBFileSpec::GetDescription(SBStream &description) const {
}

void SBFileSpec::AppendPathComponent(const char *fn) {
LLDB_RECORD_METHOD(void, SBFileSpec, AppendPathComponent, (const char *), fn);

m_opaque_up->AppendPathComponent(fn);
}
47 changes: 40 additions & 7 deletions lldb/source/API/SBFileSpecList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,29 @@
//
//===----------------------------------------------------------------------===//

#include <limits.h>

#include "lldb/API/SBFileSpecList.h"
#include "SBReproducerPrivate.h"
#include "Utils.h"
#include "lldb/API/SBFileSpec.h"
#include "lldb/API/SBFileSpecList.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_up(new FileSpecList()) {}
SBFileSpecList::SBFileSpecList() : m_opaque_up(new FileSpecList()) {
LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBFileSpecList);
}

SBFileSpecList::SBFileSpecList(const SBFileSpecList &rhs) : m_opaque_up() {
LLDB_RECORD_CONSTRUCTOR(SBFileSpecList, (const lldb::SBFileSpecList &), rhs);

Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));

m_opaque_up = clone(rhs.m_opaque_up);
Expand All @@ -39,32 +44,57 @@ SBFileSpecList::SBFileSpecList(const SBFileSpecList &rhs) : m_opaque_up() {
SBFileSpecList::~SBFileSpecList() {}

const SBFileSpecList &SBFileSpecList::operator=(const SBFileSpecList &rhs) {
LLDB_RECORD_METHOD(const lldb::SBFileSpecList &,
SBFileSpecList, operator=,(const lldb::SBFileSpecList &),
rhs);

if (this != &rhs)
m_opaque_up = clone(rhs.m_opaque_up);
return *this;
}

uint32_t SBFileSpecList::GetSize() const { return m_opaque_up->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) {
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) {
LLDB_RECORD_METHOD(bool, SBFileSpecList, AppendIfUnique,
(const lldb::SBFileSpec &), sb_file);

return m_opaque_up->AppendIfUnique(sb_file.ref());
}

void SBFileSpecList::Clear() { m_opaque_up->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) {
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_up->GetFileSpecAtIndex(idx));
return new_spec;
return LLDB_RECORD_RESULT(new_spec);
}

const lldb_private::FileSpecList *SBFileSpecList::operator->() const {
Expand All @@ -84,6 +114,9 @@ const lldb_private::FileSpecList &SBFileSpecList::ref() const {
}

bool SBFileSpecList::GetDescription(SBStream &description) const {
LLDB_RECORD_METHOD_CONST(bool, SBFileSpecList, GetDescription,
(lldb::SBStream &), description);

Stream &strm = description.ref();

if (m_opaque_up) {
Expand Down
Loading