aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.python
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2024-11-18 13:47:22 -0700
committerTom Tromey <tromey@adacore.com>2024-12-09 14:17:21 -0700
commit2134b0b4a5ff493878386183dfd8a735b5334ad7 (patch)
treee9b318cc897c5b3fdffbe6f37f97c8d8b29504e6 /gdb/testsuite/gdb.python
parent523a46ee9795bbec2d1d5cf7e434adc2a3044f94 (diff)
downloadgdb-2134b0b4a5ff493878386183dfd8a735b5334ad7.zip
gdb-2134b0b4a5ff493878386183dfd8a735b5334ad7.tar.gz
gdb-2134b0b4a5ff493878386183dfd8a735b5334ad7.tar.bz2
Reject non-string types in gdb.Value.lazy_string
Currently, gdb.Value.lazy_string will allow the conversion of any object to a "lazy string". However, this was never the intent and is weird besides. This patch changes this code to correctly throw an exception in the non-matching cases. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=20769
Diffstat (limited to 'gdb/testsuite/gdb.python')
-rw-r--r--gdb/testsuite/gdb.python/py-lazy-string.c1
-rw-r--r--gdb/testsuite/gdb.python/py-lazy-string.exp5
2 files changed, 6 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.python/py-lazy-string.c b/gdb/testsuite/gdb.python/py-lazy-string.c
index 326523d..805ba92 100644
--- a/gdb/testsuite/gdb.python/py-lazy-string.c
+++ b/gdb/testsuite/gdb.python/py-lazy-string.c
@@ -24,6 +24,7 @@ main ()
const char array[] = "array";
pointer typedef_ptr = "typedef pointer";
const char *null = 0;
+ int not_a_string = 23;
return 0; /* break here */
}
diff --git a/gdb/testsuite/gdb.python/py-lazy-string.exp b/gdb/testsuite/gdb.python/py-lazy-string.exp
index a00f47b..0650c67 100644
--- a/gdb/testsuite/gdb.python/py-lazy-string.exp
+++ b/gdb/testsuite/gdb.python/py-lazy-string.exp
@@ -73,3 +73,8 @@ foreach var_spec { { "ptr" "pointer" "const char \\*" -1 } \
#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"