[lldb][Windows] Improve error messages in PlatformWindows.cpp (#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.

---------

Co-authored-by: Jonas Devlieghere <jonas@devlieghere.com>
This commit is contained in:
Charles Zablit 2026-08-01 18:03:40 +02:00 committed by GitHub
parent 67a20745d6
commit 6dfd733723
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -34,10 +34,12 @@
#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"
#include "llvm/Support/ConvertUTF.h"
#include "llvm/Support/FormatVariadic.h"
using namespace lldb;
using namespace lldb_private;
@ -433,7 +435,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("failed to execute LoadLibrary helper "
"({0}):",
toString(result))
.str()));
return LLDB_INVALID_IMAGE_TOKEN;
}
@ -941,7 +946,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})", toString(result));
if (value && value->GetError().Fail())
return value->GetError().Clone();