Skip to content

Commit 3b81f76

Browse files
committed
Address comments (2)
1 parent 344965b commit 3b81f76

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
@@ -1625,7 +1625,7 @@ void request_evaluate(const llvm::json::Object &request) {
16251625
EmplaceSafeString(body, "result", desc.GetResult(context));
16261626
EmplaceSafeString(body, "type", desc.display_type_name);
16271627
int64_t var_ref = 0;
1628-
if (value.MightHaveChildren() || HasValueLocation(value))
1628+
if (value.MightHaveChildren() || ValuePointsToCode(value))
16291629
var_ref = g_dap.variables.InsertVariable(
16301630
value, /*is_permanent=*/context == "repl");
16311631
if (value.MightHaveChildren())
@@ -1635,7 +1635,7 @@ void request_evaluate(const llvm::json::Object &request) {
16351635
if (lldb::addr_t addr = value.GetLoadAddress();
16361636
addr != LLDB_INVALID_ADDRESS)
16371637
body.try_emplace("memoryReference", EncodeMemoryReference(addr));
1638-
if (HasValueLocation(value))
1638+
if (ValuePointsToCode(value))
16391639
body.try_emplace("valueLocationReference", var_ref);
16401640
}
16411641
}
@@ -3824,7 +3824,7 @@ void request_setVariable(const llvm::json::Object &request) {
38243824
if (lldb::addr_t addr = variable.GetLoadAddress();
38253825
addr != LLDB_INVALID_ADDRESS)
38263826
body.try_emplace("memoryReference", EncodeMemoryReference(addr));
3827-
if (HasValueLocation(variable))
3827+
if (ValuePointsToCode(variable))
38283828
body.try_emplace("valueLocationReference", new_var_ref);
38293829
} else {
38303830
EmplaceSafeString(body, "message", std::string(error.GetCString()));

0 commit comments

Comments
 (0)