diff options
author | Davide Italiano <davide@freebsd.org> | 2018-04-16 22:55:34 +0000 |
---|---|---|
committer | Davide Italiano <davide@freebsd.org> | 2018-04-16 22:55:34 +0000 |
commit | 4a6a2b1ce313f0901c8c1e03a8c62fa0f7f526d8 (patch) | |
tree | 8c2d82677652c1e77ba491e8300fbac934cc51c7 /lldb/source/API/SBTarget.cpp | |
parent | 9c86a313076351134cd1e4f2a604466d7c0974b4 (diff) | |
download | bcm5719-llvm-4a6a2b1ce313f0901c8c1e03a8c62fa0f7f526d8.tar.gz bcm5719-llvm-4a6a2b1ce313f0901c8c1e03a8c62fa0f7f526d8.zip |
[Commands] Expose statistics through the SBAPI.
The API is `SBStructuredData GetStatistics()`. This allows
the command to be used in scripts.
<rdar://problem/36555975>
llvm-svn: 330165
Diffstat (limited to 'lldb/source/API/SBTarget.cpp')
-rw-r--r-- | lldb/source/API/SBTarget.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index 878f6edd5ca..e1cc6538bdf 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -23,6 +23,7 @@ #include "lldb/API/SBSourceManager.h" #include "lldb/API/SBStream.h" #include "lldb/API/SBStringList.h" +#include "lldb/API/SBStructuredData.h" #include "lldb/API/SBSymbolContextList.h" #include "lldb/Breakpoint/BreakpointID.h" #include "lldb/Breakpoint/BreakpointIDList.h" @@ -38,6 +39,7 @@ #include "lldb/Core/STLUtils.h" #include "lldb/Core/SearchFilter.h" #include "lldb/Core/Section.h" +#include "lldb/Core/StructuredDataImpl.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Core/ValueObjectList.h" #include "lldb/Core/ValueObjectVariable.h" @@ -181,6 +183,25 @@ SBDebugger SBTarget::GetDebugger() const { return debugger; } +SBStructuredData SBTarget::GetStatistics() { + SBStructuredData data; + TargetSP target_sp(GetSP()); + if (!target_sp) + return data; + + auto stats_up = llvm::make_unique<StructuredData::Dictionary>(); + int i = 0; + for (auto &Entry : target_sp->GetStatistics()) { + std::string Desc = lldb_private::GetStatDescription( + static_cast<lldb_private::StatisticKind>(i)); + stats_up->AddIntegerItem(Desc, Entry); + i += 1; + } + + data.m_impl_up->SetObjectSP(std::move(stats_up)); + return data; +} + SBProcess SBTarget::LoadCore(const char *core_file) { SBProcess sb_process; TargetSP target_sp(GetSP()); |