summaryrefslogtreecommitdiff
path: root/lldb/source/API/SBError.cpp
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2024-12-20 13:02:54 -0800
committerGitHub <noreply@github.com>2024-12-20 13:02:54 -0800
commitd9cc37fea7b02954079ca59e8f7f28cffacc7e9e (patch)
tree28688e2c0c66d88ffb7a60fe389f94d9dcbef6c5 /lldb/source/API/SBError.cpp
parentd8e10d13d7e31cb1695eb65f02696e682ec97097 (diff)
[lldb] Expose structured errors in SBError (#120784)
Building on top of previous work that exposed expression diagnostics via SBCommandReturnObject, this patch generalizes the support to expose any SBError as machine-readable structured data. One use-case of this is to allow IDEs to better visualize expression diagnostics. rdar://139997604
Diffstat (limited to 'lldb/source/API/SBError.cpp')
-rw-r--r--lldb/source/API/SBError.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/lldb/source/API/SBError.cpp b/lldb/source/API/SBError.cpp
index 31964931649d..aab4ddd3181d 100644
--- a/lldb/source/API/SBError.cpp
+++ b/lldb/source/API/SBError.cpp
@@ -9,6 +9,8 @@
#include "lldb/API/SBError.h"
#include "Utils.h"
#include "lldb/API/SBStream.h"
+#include "lldb/API/SBStructuredData.h"
+#include "lldb/Core/StructuredDataImpl.h"
#include "lldb/Utility/Instrumentation.h"
#include "lldb/Utility/Status.h"
#include "lldb/Utility/VASPrintf.h"
@@ -97,6 +99,18 @@ uint32_t SBError::GetError() const {
return err;
}
+SBStructuredData SBError::GetErrorData() const {
+ LLDB_INSTRUMENT_VA(this);
+
+ SBStructuredData sb_data;
+ if (!m_opaque_up)
+ return sb_data;
+
+ StructuredData::ObjectSP data(m_opaque_up->GetAsStructuredData());
+ sb_data.m_impl_up->SetObjectSP(data);
+ return sb_data;
+}
+
ErrorType SBError::GetType() const {
LLDB_INSTRUMENT_VA(this);