aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/API/SBThread.cpp
diff options
context:
space:
mode:
authorMichał Górny <mgorny@moritz.systems>2022-01-24 18:52:49 +0100
committerMichał Górny <mgorny@moritz.systems>2022-01-27 13:33:47 +0100
commit1a8f60f5f5b8638a3e8e7fb31ba7ae9e17a7ff2d (patch)
treef798b4dfd7ef1c861499e5f1e70abecdf7c68e25 /lldb/source/API/SBThread.cpp
parent3053e143bef273a2e65519cea15be8f7ce6cd854 (diff)
downloadllvm-1a8f60f5f5b8638a3e8e7fb31ba7ae9e17a7ff2d.zip
llvm-1a8f60f5f5b8638a3e8e7fb31ba7ae9e17a7ff2d.tar.gz
llvm-1a8f60f5f5b8638a3e8e7fb31ba7ae9e17a7ff2d.tar.bz2
[lldb] [gdb-remote] Support getting siginfo via API
Add Thread::GetSiginfo() and SBThread::GetSiginfo() methods to retrieve the siginfo value from server. Differential Revision: https://reviews.llvm.org/D118055
Diffstat (limited to 'lldb/source/API/SBThread.cpp')
-rw-r--r--lldb/source/API/SBThread.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/lldb/source/API/SBThread.cpp b/lldb/source/API/SBThread.cpp
index 46a6c27..dcc2a6e 100644
--- a/lldb/source/API/SBThread.cpp
+++ b/lldb/source/API/SBThread.cpp
@@ -1317,3 +1317,50 @@ lldb_private::Thread *SBThread::operator->() {
lldb_private::Thread *SBThread::get() {
return m_opaque_sp->GetThreadSP().get();
}
+
+SBValue SBThread::GetSiginfo(SBError &error) {
+ LLDB_INSTRUMENT_VA(this, error);
+
+ SBValue value;
+ SBProcess process = GetProcess();
+ if (!process.IsValid()) {
+ error.SetErrorString("no process");
+ return value;
+ }
+ SBTarget target = process.GetTarget();
+ if (!target.IsValid()) {
+ error.SetErrorString("unable to get target");
+ return value;
+ }
+ SBPlatform platform = target.GetPlatform();
+ if (!platform.IsValid()) {
+ error.SetErrorString("unable to get platform");
+ return value;
+ }
+ CompilerType type = platform.GetSP()->GetSiginfoType(
+ target.GetSP()->GetArchitecture().GetTriple());
+ if (!type.IsValid()) {
+ error.SetErrorString("no siginfo_t for the platform");
+ return value;
+ }
+ llvm::Optional<uint64_t> type_size = type.GetByteSize(nullptr);
+ assert(type_size);
+ ThreadSP thread_sp = m_opaque_sp->GetThreadSP();
+ if (!thread_sp) {
+ error.SetErrorString("unable to get thread");
+ return value;
+ }
+ llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>> data =
+ thread_sp->GetSiginfo(type_size.getValue());
+ if (!data) {
+ error.SetErrorString(llvm::toString(data.takeError()).c_str());
+ return value;
+ }
+ SBData sb_data;
+ sb_data.SetData(error, data.get()->getBufferStart(),
+ data.get()->getBufferSize(), process.GetByteOrder(), 0);
+ if (!sb_data.IsValid())
+ return value;
+
+ return target.CreateValueFromData("siginfo", sb_data, type);
+}