service/dap: do not try to access value of unreadable string variables (#4055)

Fixes #4053
This commit is contained in:
Alessandro Arzilli
2025-07-14 18:12:48 +02:00
committed by GitHub
parent 4a2a6e1aeb
commit 8a7650b013

View File

@ -2437,10 +2437,12 @@ func (s *Session) childrenToDAPVariables(v *fullyQualifiedVariable) []dap.Variab
reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
valexpr = fmt.Sprintf("%s[%s]", v.fullyQualifiedNameOrExpr, api.VariableValueAsString(keyv))
case reflect.String:
if keyv.Unreadable == nil {
if key := constant.StringVal(keyv.Value); keyv.Len == int64(len(key)) { // fully loaded
valexpr = fmt.Sprintf("%s[%q]", v.fullyQualifiedNameOrExpr, key)
}
}
}
key, keyref := s.convertVariable(keyv, keyexpr)
val, valref := s.convertVariable(valv, valexpr)
keyType := s.getTypeIfSupported(keyv)