case TYPE_CODE_ARRAY:
return check_typedef (realtype->target_type ());
default:
- /* This is done to preserve existing behavior. PR 20769.
- E.g., gdb.parse_and_eval("my_int_variable").lazy_string().type. */
- return realtype;
+ gdb_assert_not_reached ("invalid lazy string");
}
}
If LENGTH is provided then the length parameter is set to LENGTH.
Otherwise if the value is an array of known length then the array's length
is used. Otherwise the length will be set to -1 (meaning first null of
- appropriate with).
-
- Note: In order to not break any existing uses this allows creating
- lazy strings from anything. PR 20769. E.g.,
- gdb.parse_and_eval("my_int_variable").lazy_string().
- "It's easier to relax restrictions than it is to impose them after the
- fact." So we should be flagging any unintended uses as errors, but it's
- perhaps too late for that. */
+ appropriate with). */
static PyObject *
valpy_lazy_string (PyObject *self, PyObject *args, PyObject *kw)
addr = value_as_address (value);
break;
default:
- /* Should flag an error here. PR 20769. */
- addr = value->address ();
- break;
+ error (_("Cannot make lazy string from this object"));
}
str_obj = gdbpy_create_lazy_string_object (addr, length, user_encoding,
#gdb_test "python print ($var.lazy_string(length=0).value())" "\"\"" "empty lazy string value"
}
}
+
+gdb_py_test_silent_cmd "python nas = gdb.parse_and_eval('not_a_string')" \
+ "get not_a_string" 1
+gdb_test "python print(nas.lazy_string())" \
+ "Cannot make lazy string from this object"