• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

Revisión8503d6e1e564cb5ac61bc6e3f16c0b384c76661e (tree)
Tiempo2015-01-07 00:07:12
AutorJoel Brobecker <brobecker@adac...>
CommiterJoel Brobecker

Log Message

gdb/python: exception trying to create empty array

The following python command fails:

(gdb) python print gdb.lookup_type('char').array(1, 0)
Traceback (most recent call last):
File "<string>", line 1, in <module>
ValueError: Array length must not be negative
Error while executing Python code.

The above is trying to create an empty array, which is fairly command
in Ada.

gdb/ChangeLog:

        • python/py-type.c (typy_array_1): Do not raise negative-length
          exception if N2 is equal to N1 - 1.

gdb/testsuite/ChangeLog:

        • gdb.python/py-type.exp: Add a couple test about empty
          array creation, and negative-length array creation.

Cambiar Resumen

Diferencia incremental

--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
1+2015-01-06 Joel Brobecker <brobecker@adacore.com>
2+
3+ * python/py-type.c (typy_array_1): Do not raise negative-length
4+ exception if N2 is equal to N1 - 1.
5+
16 2015-01-03 Doug Evans <xdje42@gmail.com>
27
38 * c-exp.y: Whitespace cleanup.
--- a/gdb/python/py-type.c
+++ b/gdb/python/py-type.c
@@ -528,7 +528,7 @@ typy_array_1 (PyObject *self, PyObject *args, int is_vector)
528528 n1 = 0;
529529 }
530530
531- if (n2 < n1)
531+ if (n2 < n1 - 1)
532532 {
533533 PyErr_SetString (PyExc_ValueError,
534534 _("Array length must not be negative"));
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
1+2015-01-06 Joel Brobecker <brobecker@adacore.com>
2+
3+ * gdb.python/py-type.exp: Add a couple test about empty
4+ array creation, and negative-length array creation.
5+
16 2015-01-02 Doug Evans <xdje42@gmail.com>
27
38 * gdb.cp/nsalias.exp: Fix output of external/declaration flags.
--- a/gdb/testsuite/gdb.python/py-type.exp
+++ b/gdb/testsuite/gdb.python/py-type.exp
@@ -247,6 +247,12 @@ restart_gdb "${binfile}"
247247 # Skip all tests if Python scripting is not enabled.
248248 if { [skip_python_tests] } { continue }
249249
250+gdb_test "python print gdb.lookup_type('char').array(1, 0)" \
251+ "char \\\[0\\\]"
252+
253+gdb_test "python print gdb.lookup_type('char').array(1, -1)" \
254+ "Array length must not be negative.*"
255+
250256 with_test_prefix "lang_c" {
251257 runto_bp "break to inspect struct and array."
252258 test_fields "c"