[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 <medismail.bennani@gmail.com>
This commit is contained in:
Med Ismail Bennani
2020-02-24 10:04:16 -05:00
parent 6980782572
commit eefda18227
13 changed files with 65 additions and 73 deletions

View File

@@ -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<SBProcess>(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 &));