From eefda18227a2faeacbd5420cb482fa8b5836283b Mon Sep 17 00:00:00 2001 From: Med Ismail Bennani Date: Mon, 24 Feb 2020 10:04:16 -0500 Subject: [lldb/Plugins] Move SBTarget::GetExtendedCrashInformation to SBProcess This patch moves the SB API method GetExtendedCrashInformation from SBTarget to SBProcess since it only makes sense to call this method on a sane process which might not be the case on a SBTarget object. It also addresses some feedbacks received after landing the first patch for the 'crash-info' feature. Differential Revision: https://reviews.llvm.org/D75049 Signed-off-by: Med Ismail Bennani --- lldb/source/API/SBProcess.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'lldb/source/API/SBProcess.cpp') diff --git a/lldb/source/API/SBProcess.cpp b/lldb/source/API/SBProcess.cpp index 1a93950c3069..ab216015741f 100644 --- a/lldb/source/API/SBProcess.cpp +++ b/lldb/source/API/SBProcess.cpp @@ -18,6 +18,7 @@ #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/StreamFile.h" +#include "lldb/Core/StructuredDataImpl.h" #include "lldb/Target/MemoryRegionInfo.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" @@ -1010,6 +1011,30 @@ bool SBProcess::GetDescription(SBStream &description) { return true; } +SBStructuredData SBProcess::GetExtendedCrashInformation() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBStructuredData, SBProcess, + GetExtendedCrashInformation); + SBStructuredData data; + ProcessSP process_sp(GetSP()); + if (!process_sp) + return LLDB_RECORD_RESULT(data); + + PlatformSP platform_sp = process_sp->GetTarget().GetPlatform(); + + if (!platform_sp) + return LLDB_RECORD_RESULT(data); + + auto expected_data = + platform_sp->FetchExtendedCrashInformation(*process_sp.get()); + + if (!expected_data) + return LLDB_RECORD_RESULT(data); + + StructuredData::ObjectSP fetched_data = *expected_data; + data.m_impl_up->SetObjectSP(fetched_data); + return LLDB_RECORD_RESULT(data); +} + uint32_t SBProcess::GetNumSupportedHardwareWatchpoints(lldb::SBError &sb_error) const { LLDB_RECORD_METHOD_CONST(uint32_t, SBProcess, @@ -1385,6 +1410,8 @@ void RegisterMethods(Registry &R) { LLDB_REGISTER_METHOD(lldb::addr_t, SBProcess, ReadPointerFromMemory, (lldb::addr_t, lldb::SBError &)); LLDB_REGISTER_METHOD(bool, SBProcess, GetDescription, (lldb::SBStream &)); + LLDB_REGISTER_METHOD(lldb::SBStructuredData, SBProcess, + GetExtendedCrashInformation, ()); LLDB_REGISTER_METHOD_CONST(uint32_t, SBProcess, GetNumSupportedHardwareWatchpoints, (lldb::SBError &)); -- cgit v1.2.3