[Lldb-commits] [lldb] [lldb][Windows] Improve error messages in PlatformWindows.cpp (PR #213011)
Charles Zablit via lldb-commits
lldb-commits at lists.llvm.org
Sat Aug 1 04:11:29 PDT 2026
https://github.com/charles-zablit updated https://github.com/llvm/llvm-project/pull/213011
>From 6e6ca760f3c110d22aabb8cf5f54c3088a4af817 Mon Sep 17 00:00:00 2001
From: Charles Zablit <c_zablit at apple.com>
Date: Thu, 30 Jul 2026 13:25:55 +0100
Subject: [PATCH 1/3] [lldb][Windows] Improve error messages in
PlatformWindows.cpp
---
.../Platform/Windows/PlatformWindows.cpp | 37 ++++++++++++++++++-
1 file changed, 35 insertions(+), 2 deletions(-)
diff --git a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
index fdf6983801ae5..df5d5a074ffb3 100644
--- a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
+++ b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
@@ -37,6 +37,7 @@
#include "llvm/ADT/ScopeExit.h"
#include "llvm/Support/ConvertUTF.h"
+#include "llvm/Support/FormatVariadic.h"
using namespace lldb;
using namespace lldb_private;
@@ -194,6 +195,32 @@ Status PlatformWindows::ConnectRemote(Args &args) {
return error;
}
+static llvm::StringRef ExpressionResultAsString(ExpressionResults result) {
+ switch (result) {
+ case eExpressionCompleted:
+ return "completed";
+ case eExpressionSetupError:
+ return "setup error";
+ case eExpressionParseError:
+ return "parse error";
+ case eExpressionDiscarded:
+ return "discarded";
+ case eExpressionInterrupted:
+ return "interrupted";
+ case eExpressionHitBreakpoint:
+ return "hit breakpoint";
+ case eExpressionTimedOut:
+ return "timed out";
+ case eExpressionResultUnavailable:
+ return "result unavailable";
+ case eExpressionStoppedForDebug:
+ return "stopped for debug";
+ case eExpressionThreadVanished:
+ return "thread vanished";
+ }
+ return "unknown error";
+}
+
uint32_t PlatformWindows::DoLoadImage(Process *process,
const FileSpec &remote_file,
const std::vector<std::string> *paths,
@@ -430,7 +457,10 @@ uint32_t PlatformWindows::DoLoadImage(Process *process,
if (result != eExpressionCompleted) {
error = Status::FromError(diagnostics.GetAsError(
eExpressionSetupError,
- "LoadLibrary error: failed to execute LoadLibrary helper:"));
+ llvm::formatv("LoadLibrary error: failed to execute LoadLibrary helper "
+ "({0}):",
+ ExpressionResultAsString(result))
+ .str()));
return LLDB_INVALID_IMAGE_TOKEN;
}
@@ -936,7 +966,10 @@ extern "C" {
ExpressionResults result = UserExpression::Evaluate(
context, options, expression, kLoaderDecls, value);
if (result != eExpressionCompleted)
- return value ? value->GetError().Clone() : Status("unknown error");
+ return value ? value->GetError().Clone()
+ : Status::FromErrorStringWithFormatv(
+ "failed to execute loader helper ({0})",
+ ExpressionResultAsString(result));
if (value && value->GetError().Fail())
return value->GetError().Clone();
>From f4b3bd9c5835a83cd6afcdf1346aac6feeb05e4f Mon Sep 17 00:00:00 2001
From: Charles Zablit <c_zablit at apple.com>
Date: Fri, 31 Jul 2026 17:55:08 +0100
Subject: [PATCH 2/3] fixup! [lldb][Windows] Improve error messages in
PlatformWindows.cpp
---
.../Platform/Windows/PlatformWindows.cpp | 37 +++----------------
1 file changed, 6 insertions(+), 31 deletions(-)
diff --git a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
index df5d5a074ffb3..dad0b16df05d5 100644
--- a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
+++ b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
@@ -33,6 +33,7 @@
#include "lldb/Host/HostInfo.h"
#include "lldb/Target/DynamicLoader.h"
#include "lldb/Target/Process.h"
+#include "lldb/Utility/ErrorMessages.h"
#include "lldb/Utility/Status.h"
#include "llvm/ADT/ScopeExit.h"
@@ -195,32 +196,6 @@ Status PlatformWindows::ConnectRemote(Args &args) {
return error;
}
-static llvm::StringRef ExpressionResultAsString(ExpressionResults result) {
- switch (result) {
- case eExpressionCompleted:
- return "completed";
- case eExpressionSetupError:
- return "setup error";
- case eExpressionParseError:
- return "parse error";
- case eExpressionDiscarded:
- return "discarded";
- case eExpressionInterrupted:
- return "interrupted";
- case eExpressionHitBreakpoint:
- return "hit breakpoint";
- case eExpressionTimedOut:
- return "timed out";
- case eExpressionResultUnavailable:
- return "result unavailable";
- case eExpressionStoppedForDebug:
- return "stopped for debug";
- case eExpressionThreadVanished:
- return "thread vanished";
- }
- return "unknown error";
-}
-
uint32_t PlatformWindows::DoLoadImage(Process *process,
const FileSpec &remote_file,
const std::vector<std::string> *paths,
@@ -459,7 +434,7 @@ uint32_t PlatformWindows::DoLoadImage(Process *process,
eExpressionSetupError,
llvm::formatv("LoadLibrary error: failed to execute LoadLibrary helper "
"({0}):",
- ExpressionResultAsString(result))
+ toString(result))
.str()));
return LLDB_INVALID_IMAGE_TOKEN;
}
@@ -966,10 +941,10 @@ extern "C" {
ExpressionResults result = UserExpression::Evaluate(
context, options, expression, kLoaderDecls, value);
if (result != eExpressionCompleted)
- return value ? value->GetError().Clone()
- : Status::FromErrorStringWithFormatv(
- "failed to execute loader helper ({0})",
- ExpressionResultAsString(result));
+ return value
+ ? value->GetError().Clone()
+ : Status::FromErrorStringWithFormatv(
+ "failed to execute loader helper ({0})", toString(result));
if (value && value->GetError().Fail())
return value->GetError().Clone();
>From aa6c4bc31ca9dff37aafe176d427fb21ac5117b6 Mon Sep 17 00:00:00 2001
From: Charles Zablit <zablitcharles at gmail.com>
Date: Sat, 1 Aug 2026 13:11:20 +0200
Subject: [PATCH 3/3] Update
lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
Co-authored-by: Jonas Devlieghere <jonas at devlieghere.com>
---
lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
index dad0b16df05d5..402c9b1e684bf 100644
--- a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
+++ b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
@@ -432,7 +432,7 @@ uint32_t PlatformWindows::DoLoadImage(Process *process,
if (result != eExpressionCompleted) {
error = Status::FromError(diagnostics.GetAsError(
eExpressionSetupError,
- llvm::formatv("LoadLibrary error: failed to execute LoadLibrary helper "
+ llvm::formatv("failed to execute LoadLibrary helper "
"({0}):",
toString(result))
.str()));
More information about the lldb-commits
mailing list