Skip to content

Commit ae6e7d2

Browse files
committed
Address comments (2)
1 parent fe2a773 commit ae6e7d2

File tree

4 files changed

+8
-10
lines changed

4 files changed

+8
-10
lines changed

lldb/test/API/tools/lldb-dap/locations/main.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@ int main(void) {
66
int var1 = 1;
77
void (*func_ptr)() = &greet;
88
void (&func_ref)() = greet;
9-
__builtin_printf("break here");
10-
return 0;
9+
return 0; // break here
1110
}

lldb/tools/lldb-dap/JSONUtils.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,10 +1198,9 @@ std::string VariableDescription::GetResult(llvm::StringRef context) {
11981198
return description.trim().str();
11991199
}
12001200

1201-
bool HasValueLocation(lldb::SBValue v) {
1202-
if (!v.GetType().IsPointerType() && !v.GetType().IsReferenceType()) {
1201+
bool ValuePointsToCode(lldb::SBValue v) {
1202+
if (!v.GetType().GetPointeeType().IsFunctionType())
12031203
return false;
1204-
}
12051204

12061205
lldb::addr_t addr = v.GetValueAsAddress();
12071206
lldb::SBLineEntry line_entry =
@@ -1424,7 +1423,7 @@ llvm::json::Value CreateVariable(lldb::SBValue v, int64_t var_ref,
14241423
if (v.GetDeclaration().IsValid())
14251424
object.try_emplace("declarationLocationReference", PackLocation(var_ref, false));
14261425

1427-
if (HasValueLocation(v))
1426+
if (ValuePointsToCode(v))
14281427
object.try_emplace("valueLocationReference", PackLocation(var_ref, true));
14291428

14301429
if (lldb::addr_t addr = v.GetLoadAddress(); addr != LLDB_INVALID_ADDRESS)

lldb/tools/lldb-dap/JSONUtils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ struct VariableDescription {
459459
};
460460

461461
/// Does the given variable have an associated value location?
462-
bool HasValueLocation(lldb::SBValue v);
462+
bool ValuePointsToCode(lldb::SBValue v);
463463

464464
/// Pack a location into a single integer which we can send via
465465
/// the debug adapter protocol.

lldb/tools/lldb-dap/lldb-dap.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,7 +1642,7 @@ void request_evaluate(const llvm::json::Object &request) {
16421642
EmplaceSafeString(body, "result", desc.GetResult(context));
16431643
EmplaceSafeString(body, "type", desc.display_type_name);
16441644
int64_t var_ref = 0;
1645-
if (value.MightHaveChildren() || HasValueLocation(value))
1645+
if (value.MightHaveChildren() || ValuePointsToCode(value))
16461646
var_ref = g_dap.variables.InsertVariable(
16471647
value, /*is_permanent=*/context == "repl");
16481648
if (value.MightHaveChildren())
@@ -1652,7 +1652,7 @@ void request_evaluate(const llvm::json::Object &request) {
16521652
if (lldb::addr_t addr = value.GetLoadAddress();
16531653
addr != LLDB_INVALID_ADDRESS)
16541654
body.try_emplace("memoryReference", EncodeMemoryReference(addr));
1655-
if (HasValueLocation(value))
1655+
if (ValuePointsToCode(value))
16561656
body.try_emplace("valueLocationReference", var_ref);
16571657
}
16581658
}
@@ -3841,7 +3841,7 @@ void request_setVariable(const llvm::json::Object &request) {
38413841
if (lldb::addr_t addr = variable.GetLoadAddress();
38423842
addr != LLDB_INVALID_ADDRESS)
38433843
body.try_emplace("memoryReference", EncodeMemoryReference(addr));
3844-
if (HasValueLocation(variable))
3844+
if (ValuePointsToCode(variable))
38453845
body.try_emplace("valueLocationReference", new_var_ref);
38463846
} else {
38473847
EmplaceSafeString(body, "message", std::string(error.GetCString()));

0 commit comments

Comments
 (0)