diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2022-02-05 18:04:23 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2022-02-05 18:05:05 +0000 |
| commit | ecbca9f5fb7d7613d2b94982c4825eb0d33d6842 (patch) | |
| tree | 3a4038f3b7bafaeade9fd6146ea8021237616657 /lldb/source/Target/Thread.cpp | |
| parent | 6f8fc217eaa12bf657be1c6468ed9938d10168b3 (diff) | |
Diffstat (limited to 'lldb/source/Target/Thread.cpp')
| -rw-r--r-- | lldb/source/Target/Thread.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp index c5f16b4e6c1d..bde6dad554e7 100644 --- a/lldb/source/Target/Thread.cpp +++ b/lldb/source/Target/Thread.cpp @@ -13,6 +13,7 @@ #include "lldb/Core/Module.h" #include "lldb/Core/StructuredDataImpl.h" #include "lldb/Core/ValueObject.h" +#include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Host/Host.h" #include "lldb/Interpreter/OptionValueFileSpecList.h" #include "lldb/Interpreter/OptionValueProperties.h" @@ -2005,3 +2006,26 @@ ThreadSP Thread::GetCurrentExceptionBacktrace() { return ThreadSP(); } + +lldb::ValueObjectSP Thread::GetSiginfoValue() { + ProcessSP process_sp = GetProcess(); + assert(process_sp); + Target &target = process_sp->GetTarget(); + PlatformSP platform_sp = target.GetPlatform(); + assert(platform_sp); + ArchSpec arch = target.GetArchitecture(); + + CompilerType type = platform_sp->GetSiginfoType(arch.GetTriple()); + if (!type.IsValid()) + return ValueObjectConstResult::Create(&target, Status("no siginfo_t for the platform")); + + llvm::Optional<uint64_t> type_size = type.GetByteSize(nullptr); + assert(type_size); + llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>> data = GetSiginfo(type_size.getValue()); + if (!data) + return ValueObjectConstResult::Create(&target, Status(data.takeError())); + + DataExtractor data_extractor{data.get()->getBufferStart(), data.get()->getBufferSize(), + process_sp->GetByteOrder(), arch.GetAddressByteSize()}; + return ValueObjectConstResult::Create(&target, type, ConstString("__lldb_siginfo"), data_extractor); +} |
