Skip to content

Commit 5aa5994

Browse files
committed
data breakpoint
1 parent 525652b commit 5aa5994

File tree

5 files changed

+14
-13
lines changed

5 files changed

+14
-13
lines changed

lldb/tools/lldb-dap/Breakpoint.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ class Breakpoint : public BreakpointBase {
2626

2727
void SetCondition() override;
2828
void SetHitCondition() override;
29-
3029
protocol::Breakpoint ToProtocolBreakpoint() override;
3130

3231
bool MatchesName(const char *name);

lldb/tools/lldb-dap/DAP.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,8 +525,9 @@ lldb::SBFrame DAP::GetLLDBFrame(uint64_t frame_id) {
525525
}
526526

527527
lldb::SBFrame DAP::GetLLDBFrame(const llvm::json::Object &arguments) {
528-
const auto frame_id = GetInteger<uint64_t>(arguments, "frameId");
529-
return GetLLDBFrame(frame_id.value_or(0));
528+
const auto frame_id =
529+
GetInteger<uint64_t>(arguments, "frameId").value_or(UINT64_MAX);
530+
return GetLLDBFrame(frame_id);
530531
}
531532

532533
llvm::json::Value DAP::CreateTopLevelScopes() {

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,21 @@ llvm::Expected<protocol::DataBreakpointInfoResponseBody>
2323
DataBreakpointInfoRequestHandler::Run(
2424
const protocol::DataBreakpointInfoArguments &args) const {
2525
protocol::DataBreakpointInfoResponseBody response;
26-
lldb::SBFrame frame = dap.GetLLDBFrame(args.frameId.value_or(0));
26+
lldb::SBFrame frame = dap.GetLLDBFrame(args.frameId.value_or(UINT64_MAX));
2727
lldb::SBValue variable = dap.variables.FindVariable(
2828
args.variablesReference.value_or(0), args.name);
2929
std::string addr, size;
3030

31+
bool is_data_ok = true;
3132
if (variable.IsValid()) {
3233
lldb::addr_t load_addr = variable.GetLoadAddress();
3334
size_t byte_size = variable.GetByteSize();
3435
if (load_addr == LLDB_INVALID_ADDRESS) {
35-
response.dataId = std::nullopt;
36+
is_data_ok = false;
3637
response.description = "does not exist in memory, its location is " +
3738
std::string(variable.GetLocation());
3839
} else if (byte_size == 0) {
39-
response.dataId = std::nullopt;
40+
is_data_ok = false;
4041
response.description = "variable size is 0";
4142
} else {
4243
addr = llvm::utohexstr(load_addr);
@@ -47,7 +48,7 @@ DataBreakpointInfoRequestHandler::Run(
4748
if (value.GetError().Fail()) {
4849
lldb::SBError error = value.GetError();
4950
const char *error_cstr = error.GetCString();
50-
response.dataId = std::nullopt;
51+
is_data_ok = false;
5152
response.description = error_cstr && error_cstr[0]
5253
? std::string(error_cstr)
5354
: "evaluation failed";
@@ -64,23 +65,23 @@ DataBreakpointInfoRequestHandler::Run(
6465
// request if SBProcess::GetMemoryRegionInfo returns error.
6566
if (err.Success()) {
6667
if (!(region.IsReadable() || region.IsWritable())) {
67-
response.dataId = std::nullopt;
68+
is_data_ok = false;
6869
response.description = "memory region for address " + addr +
6970
" has no read or write permissions";
7071
}
7172
}
7273
} else {
73-
response.dataId = std::nullopt;
74+
is_data_ok = false;
7475
response.description =
7576
"unable to get byte size for expression: " + args.name;
7677
}
7778
}
7879
} else {
79-
response.dataId = std::nullopt;
80+
is_data_ok = false;
8081
response.description = "variable not found: " + args.name;
8182
}
8283

83-
if (!response.dataId.has_value()) {
84+
if (is_data_ok) {
8485
response.dataId = addr + "/" + size;
8586
response.accessTypes = {protocol::eDataBreakpointAccessTypeRead,
8687
protocol::eDataBreakpointAccessTypeWrite,

lldb/tools/lldb-dap/Protocol/ProtocolRequests.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ struct DataBreakpointInfoResponseBody {
517517
/// for details. Breakpoints set using the `dataId` in the
518518
/// `setDataBreakpoints` request may outlive the lifetime of the associated
519519
/// `dataId`.
520-
std::optional<std::optional<std::string>> dataId;
520+
std::optional<std::string> dataId;
521521

522522
/// UI string that describes on what data the breakpoint is set on or why a
523523
/// data breakpoint is not available.

llvm/include/llvm/Support/JSON.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ inline bool fromJSON(const Value &E, unsigned int &Out, Path P) {
781781
Out = *S;
782782
return true;
783783
}
784-
P.report("expected integer");
784+
P.report("expected unsigned integer");
785785
return false;
786786
}
787787
inline bool fromJSON(const Value &E, uint64_t &Out, Path P) {

0 commit comments

Comments
 (0)