[Lldb-commits] [lldb] [lldb][Windows] Improve error messages in PlatformWindows.cpp (PR #213011)
Charles Zablit via lldb-commits
lldb-commits at lists.llvm.org
Thu Jul 30 05:27:49 PDT 2026
https://github.com/charles-zablit created https://github.com/llvm/llvm-project/pull/213011
The reason for the failure is known but is not in the log. Add a helper function to map the error to a string and log it.
>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] [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();
More information about the lldb-commits
mailing list