Skip to content

Commit 3ea64a4

Browse files
committed
Addressing reviewer comments.
1 parent dd9232e commit 3ea64a4

File tree

3 files changed

+11
-21
lines changed

3 files changed

+11
-21
lines changed

lldb/tools/lldb-dap/Handler/EvaluateRequestHandler.cpp

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,9 @@
1313
#include "Protocol/ProtocolRequests.h"
1414
#include "Protocol/ProtocolTypes.h"
1515
#include "RequestHandler.h"
16-
#include "lldb/API/SBCommandInterpreter.h"
17-
#include "lldb/API/SBCommandReturnObject.h"
1816
#include "lldb/lldb-enumerations.h"
1917
#include "llvm/ADT/StringRef.h"
2018
#include "llvm/Support/Error.h"
21-
#include <future>
22-
#include <optional>
23-
#include <unistd.h>
2419

2520
using namespace llvm;
2621
using namespace lldb_dap;
@@ -53,11 +48,9 @@ EvaluateRequestHandler::Run(const EvaluateArguments &arguments) const {
5348
}
5449

5550
bool required_command_failed = false;
56-
std::string result = RunLLDBCommands(
51+
body.result = RunLLDBCommands(
5752
dap.debugger, llvm::StringRef(), {expression}, required_command_failed,
5853
/*parse_command_directives=*/false, /*echo_commands=*/false);
59-
60-
body.result = result;
6154
return body;
6255
}
6356

@@ -88,14 +81,8 @@ EvaluateRequestHandler::Run(const EvaluateArguments &arguments) const {
8881
if (value.GetError().Fail() && arguments.context != eEvaluateContextHover)
8982
value = frame.EvaluateExpression(expression.data());
9083

91-
if (value.GetError().Fail()) {
92-
// This error object must live until we're done with the pointer returned
93-
// by GetCString().
94-
lldb::SBError error = value.GetError();
95-
const char *error_cstr = error.GetCString();
96-
return make_error<DAPError>(
97-
error_cstr && error_cstr[0] ? error_cstr : "evaluate failed");
98-
}
84+
if (value.GetError().Fail())
85+
return ToError(value.GetError(), /*show_user=*/false);
9986

10087
VariableDescription desc(value,
10188
dap.configuration.enableAutoVariableSummaries);

lldb/tools/lldb-dap/LLDBUtils.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "LLDBUtils.h"
10+
#include "DAPError.h"
1011
#include "JSONUtils.h"
1112
#include "lldb/API/SBCommandInterpreter.h"
1213
#include "lldb/API/SBCommandReturnObject.h"
@@ -17,6 +18,7 @@
1718
#include "lldb/API/SBThread.h"
1819
#include "lldb/lldb-enumerations.h"
1920
#include "llvm/ADT/ArrayRef.h"
21+
#include "llvm/Support/Error.h"
2022
#include "llvm/Support/JSON.h"
2123
#include "llvm/Support/raw_ostream.h"
2224

@@ -214,13 +216,14 @@ GetStopDisassemblyDisplay(lldb::SBDebugger &debugger) {
214216
return result;
215217
}
216218

217-
llvm::Error ToError(const lldb::SBError &error) {
219+
llvm::Error ToError(const lldb::SBError &error, bool show_user) {
218220
if (error.Success())
219221
return llvm::Error::success();
220222

221-
return llvm::createStringError(
222-
std::error_code(error.GetError(), std::generic_category()),
223-
error.GetCString());
223+
return llvm::make_error<DAPError>(
224+
/*message=*/error.GetCString(),
225+
/*EC=*/std::error_code(error.GetError(), std::generic_category()),
226+
/*show_user=*/show_user);
224227
}
225228

226229
std::string GetStringValue(const lldb::SBStructuredData &data) {

lldb/tools/lldb-dap/LLDBUtils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ class ScopeSyncMode {
243243
lldb::StopDisassemblyType GetStopDisassemblyDisplay(lldb::SBDebugger &debugger);
244244

245245
/// Take ownership of the stored error.
246-
llvm::Error ToError(const lldb::SBError &error);
246+
llvm::Error ToError(const lldb::SBError &error, bool show_user = true);
247247

248248
/// Provides the string value if this data structure is a string type.
249249
std::string GetStringValue(const lldb::SBStructuredData &data);

0 commit comments

Comments
 (0)