aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2024-11-19 07:34:26 -0700
committerTom Tromey <tromey@adacore.com>2024-12-09 14:17:23 -0700
commitc286bfe1e5c252689126cb2f45677bd36a2fdd56 (patch)
treee74594d70e93b7a457b0b0b1708fb7af968bb414 /gdb/testsuite
parent2134b0b4a5ff493878386183dfd8a735b5334ad7 (diff)
downloadbinutils-c286bfe1e5c252689126cb2f45677bd36a2fdd56.zip
binutils-c286bfe1e5c252689126cb2f45677bd36a2fdd56.tar.gz
binutils-c286bfe1e5c252689126cb2f45677bd36a2fdd56.tar.bz2
Clean up 0-length handling in gdbpy_create_lazy_string_object
gdbpy_create_lazy_string_object will throw an exception if you pass it a NULL pointer without also setting length=0 -- the default, length==-1, will fail. This seems bizarre. Furthermore, it doesn't make sense to do this check for array types, as an array can have a zero length. This patch cleans up the check and makes it specific to TYPE_CODE_PTR.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/gdb.python/py-lazy-string.exp2
1 files changed, 2 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.python/py-lazy-string.exp b/gdb/testsuite/gdb.python/py-lazy-string.exp
index 0650c67..d212e61 100644
--- a/gdb/testsuite/gdb.python/py-lazy-string.exp
+++ b/gdb/testsuite/gdb.python/py-lazy-string.exp
@@ -48,6 +48,8 @@ gdb_test "python print(null.lazy_string(length=3).value())" \
gdb_test "python print(null.lazy_string(length=-2))" \
"ValueError.*: Invalid length.*Error occurred in Python.*" \
"bad length"
+gdb_py_test_silent_cmd "python nullstr = null.lazy_string()" \
+ "create null lazy string with default length" 1
foreach var_spec { { "ptr" "pointer" "const char \\*" -1 } \
{ "array" "array" "const char \\[6\\]" 6 } \