[Lldb-commits] [lldb] [lldb][NFC] Use UnimplementedError for GetSDKFromDebugInfo (PR #184199)
Ebuka Ezike via lldb-commits
lldb-commits at lists.llvm.org
Wed Mar 4 06:26:57 PST 2026
https://github.com/da-viper updated https://github.com/llvm/llvm-project/pull/184199
>From 0c230b710b57eb746c6de2616b7dba759aac975c Mon Sep 17 00:00:00 2001
From: Ebuka Ezike <yerimyah1 at gmail.com>
Date: Mon, 2 Mar 2026 18:29:42 +0000
Subject: [PATCH 1/2] [lldb][NFC] Use UnimplementedError for
GetSDKFromDebugInfo
We can now differenciate unimplemented errors from actual errors
that may be useful to the users.
---
lldb/include/lldb/Target/Platform.h | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/lldb/include/lldb/Target/Platform.h b/lldb/include/lldb/Target/Platform.h
index 637d4c37b90bc..3cf210cc84f76 100644
--- a/lldb/include/lldb/Target/Platform.h
+++ b/lldb/include/lldb/Target/Platform.h
@@ -27,6 +27,7 @@
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/StructuredData.h"
#include "lldb/Utility/Timeout.h"
+#include "lldb/Utility/UnimplementedError.h"
#include "lldb/Utility/UserIDResolver.h"
#include "lldb/Utility/XcodeSDK.h"
#include "lldb/lldb-private-forward.h"
@@ -452,10 +453,8 @@ class Platform : public PluginInterface {
/// a conflicting combination of SDKs when parsing the CUs
/// (e.g., a public and internal SDK).
virtual llvm::Expected<std::pair<XcodeSDK, bool>>
- GetSDKPathFromDebugInfo(Module &module) {
- return llvm::createStringError(
- llvm::formatv("{0} not implemented for '{1}' platform.",
- LLVM_PRETTY_FUNCTION, GetName()));
+ GetSDKPathFromDebugInfo(Module & /*module*/) {
+ return llvm::make_error<UnimplementedError>();
}
/// Returns the full path of the most appropriate SDK for the
@@ -478,11 +477,10 @@ class Platform : public PluginInterface {
///
/// \param[in] unit The CU
///
- /// \returns A parsed XcodeSDK object if successful, an Error otherwise.
- virtual llvm::Expected<XcodeSDK> GetSDKPathFromDebugInfo(CompileUnit &unit) {
- return llvm::createStringError(
- llvm::formatv("{0} not implemented for '{1}' platform.",
- LLVM_PRETTY_FUNCTION, GetName()));
+ /// \returns A parsed XcodeSDK object if successful, an Error otherwise.
+ virtual llvm::Expected<XcodeSDK>
+ GetSDKPathFromDebugInfo(CompileUnit & /*unit*/) {
+ return llvm::make_error<UnimplementedError>();
}
/// Returns the full path of the most appropriate SDK for the
>From cce48da2aeec537041c737f730f2bee3192d8eba Mon Sep 17 00:00:00 2001
From: Ebuka Ezike <yerimyah1 at gmail.com>
Date: Wed, 4 Mar 2026 14:25:42 +0000
Subject: [PATCH 2/2] Add review changes
Add a new constructor for the UnimplementedError class
---
lldb/include/lldb/Target/Platform.h | 14 +++++++++-----
lldb/include/lldb/Utility/UnimplementedError.h | 13 ++++++++++++-
2 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/lldb/include/lldb/Target/Platform.h b/lldb/include/lldb/Target/Platform.h
index 3cf210cc84f76..fe9d4f7982bbf 100644
--- a/lldb/include/lldb/Target/Platform.h
+++ b/lldb/include/lldb/Target/Platform.h
@@ -453,8 +453,10 @@ class Platform : public PluginInterface {
/// a conflicting combination of SDKs when parsing the CUs
/// (e.g., a public and internal SDK).
virtual llvm::Expected<std::pair<XcodeSDK, bool>>
- GetSDKPathFromDebugInfo(Module & /*module*/) {
- return llvm::make_error<UnimplementedError>();
+ GetSDKPathFromDebugInfo(Module &module) {
+ return llvm::make_error<UnimplementedError>(
+ llvm::formatv("{0} not implemented for '{1}' platform.",
+ LLVM_PRETTY_FUNCTION, GetName()));
}
/// Returns the full path of the most appropriate SDK for the
@@ -468,7 +470,7 @@ class Platform : public PluginInterface {
/// Xcode SDK.
virtual llvm::Expected<std::string>
ResolveSDKPathFromDebugInfo(Module &module) {
- return llvm::createStringError(
+ return llvm::make_error<UnimplementedError>(
llvm::formatv("{0} not implemented for '{1}' platform.",
LLVM_PRETTY_FUNCTION, GetName()));
}
@@ -480,7 +482,9 @@ class Platform : public PluginInterface {
/// \returns A parsed XcodeSDK object if successful, an Error otherwise.
virtual llvm::Expected<XcodeSDK>
GetSDKPathFromDebugInfo(CompileUnit & /*unit*/) {
- return llvm::make_error<UnimplementedError>();
+ return llvm::make_error<UnimplementedError>(
+ llvm::formatv("{0} not implemented for '{1}' platform.",
+ LLVM_PRETTY_FUNCTION, GetName()));
}
/// Returns the full path of the most appropriate SDK for the
@@ -493,7 +497,7 @@ class Platform : public PluginInterface {
/// Xcode SDK.
virtual llvm::Expected<std::string>
ResolveSDKPathFromDebugInfo(CompileUnit &unit) {
- return llvm::createStringError(
+ return llvm::make_error<UnimplementedError>(
llvm::formatv("{0} not implemented for '{1}' platform.",
LLVM_PRETTY_FUNCTION, GetName()));
}
diff --git a/lldb/include/lldb/Utility/UnimplementedError.h b/lldb/include/lldb/Utility/UnimplementedError.h
index c6fab0a9483c0..989c4ecc0084e 100644
--- a/lldb/include/lldb/Utility/UnimplementedError.h
+++ b/lldb/include/lldb/Utility/UnimplementedError.h
@@ -14,10 +14,21 @@
namespace lldb_private {
class UnimplementedError : public llvm::ErrorInfo<UnimplementedError> {
+ std::string m_message;
+
public:
static char ID;
- void log(llvm::raw_ostream &OS) const override { OS << "Not implemented"; }
+ UnimplementedError() = default;
+ explicit UnimplementedError(std::string message)
+ : m_message(std::move(message)) {}
+
+ void log(llvm::raw_ostream &OS) const override {
+ if (!m_message.empty())
+ OS << m_message;
+ else
+ OS << "Not implemented";
+ }
std::error_code convertToErrorCode() const override {
return llvm::errc::not_supported;
More information about the lldb-commits
mailing list