-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[lldb-dap] Followup fixs for data breakpoints #81680
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
|
||
#include "DAP.h" | ||
#include "Watchpoint.h" | ||
#include "lldb/API/SBMemoryRegionInfo.h" | ||
|
||
#include <cassert> | ||
#include <climits> | ||
|
@@ -2741,8 +2742,20 @@ void request_dataBreakpointInfo(const llvm::json::Object &request) { | |
std::string addr, size; | ||
|
||
if (variable.IsValid()) { | ||
addr = llvm::utohexstr(variable.GetLoadAddress()); | ||
size = llvm::utostr(variable.GetByteSize()); | ||
lldb::addr_t load_addr = variable.GetLoadAddress(); | ||
size_t byte_size = variable.GetByteSize(); | ||
if (load_addr == LLDB_INVALID_ADDRESS) { | ||
body.try_emplace("dataId", nullptr); | ||
body.try_emplace("description", | ||
"does not exist in memory, its location is " + | ||
std::string(variable.GetLocation())); | ||
} else if (byte_size == 0) { | ||
body.try_emplace("dataId", nullptr); | ||
body.try_emplace("description", "variable size is 0"); | ||
} else { | ||
addr = llvm::utohexstr(load_addr); | ||
size = llvm::utostr(byte_size); | ||
} | ||
} else if (variablesReference == 0 && frame.IsValid()) { | ||
// Name might be an expression. In this case we assume that name is composed | ||
// of the number of bytes to watch and expression, separated by '@': | ||
|
@@ -2757,13 +2770,29 @@ void request_dataBreakpointInfo(const llvm::json::Object &request) { | |
body.try_emplace("description", error_cstr && error_cstr[0] | ||
? std::string(error_cstr) | ||
: "evaluation failed"); | ||
} else | ||
addr = llvm::utohexstr(value.GetValueAsUnsigned()); | ||
} else { | ||
uint64_t load_addr = value.GetValueAsUnsigned(); | ||
addr = llvm::utohexstr(load_addr); | ||
lldb::SBMemoryRegionInfo region; | ||
lldb::SBError err = | ||
g_dap.target.GetProcess().GetMemoryRegionInfo(load_addr, region); | ||
if (err.Success()) { | ||
if (!(region.IsReadable() || region.IsWritable())) { | ||
body.try_emplace("dataId", nullptr); | ||
body.try_emplace("description", | ||
"memory region for address " + addr + | ||
" has no read or write permissions"); | ||
} | ||
} else { | ||
body.try_emplace("dataId", nullptr); | ||
body.try_emplace("description", | ||
"unable to get memory region info for address " + | ||
addr); | ||
} | ||
} | ||
} else { | ||
auto state = g_dap.target.GetProcess().GetState(); | ||
body.try_emplace("dataId", nullptr); | ||
body.try_emplace("description", | ||
"variable not found: " + llvm::utostr(state)); | ||
body.try_emplace("description", "variable not found"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want more info shown here like the variable name that we tried to lookup? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we have a way to get the complete name? |
||
} | ||
|
||
if (!body.getObject("dataId")) { | ||
|
Uh oh!
There was an error while loading. Please reload this page.