* [python][patch] And range method to type
@ 2009-12-04 15:25 Phil Muldoon
2009-12-04 15:32 ` Eli Zaretskii
` (2 more replies)
0 siblings, 3 replies; 16+ messages in thread
From: Phil Muldoon @ 2009-12-04 15:25 UTC (permalink / raw)
To: gdb-patches ml
This patch adds a "range" method for GDB.Types. It only supports types
that support a range, or the range type itself.
Ok?
Cheers,
Phil
--
ChangeLog
2009-12-04 Phil Muldoon <pmuldoon@redhat.com>
* python/py-type.c (typy_range): New method.
Testsuite ChangeLog
2009-12-04 Phil Muldoon <pmuldoon@redhat.com>
* gdb.python/py-type.exp (test_range): New method. Test type range
method.
Doc ChangeLog
2009-12-04 Phil Muldoon <pmuldoon@redhat.com>
* gdb.texinfo (Types In Python): Document range method.
--
Index: doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.647
diff -u -r1.647 gdb.texinfo
--- doc/gdb.texinfo 3 Dec 2009 21:19:48 -0000 1.647
+++ doc/gdb.texinfo 4 Dec 2009 15:15:21 -0000
@@ -19654,6 +19654,13 @@
@code{volatile}.
@end defmethod
+@defmethod Type range
+Return a Python @code{Tuple} object that contains two elements. The
+first element of the @code{Tuple} contains the low bound of the type; the
+second element contains the high bound of the type. If the type does
+not have a range, @value{GDBN} will throw a @code{RuntimeError}
+@end defmethod
+
@defmethod Type reference
Return a new @code{gdb.Type} object which represents a reference to this
type.
Index: python/py-type.c
===================================================================
RCS file: /cvs/src/src/gdb/python/py-type.c,v
retrieving revision 1.3
diff -u -r1.3 py-type.c
--- python/py-type.c 3 Dec 2009 21:19:49 -0000 1.3
+++ python/py-type.c 4 Dec 2009 15:15:22 -0000
@@ -273,6 +273,44 @@
return type_to_type_object (type);
}
+/* Return the range of a type represented by SELF. The return type is
+ a tuple. The first element of the tuple contains the low bound,
+ while the second element of the tuple contains the high bound. */
+static PyObject *
+typy_range (PyObject *self, PyObject *args)
+{
+ struct type *type = ((type_object *) self)->type;
+ PyObject *result, *low, *high;
+
+ if (TYPE_CODE (type) != TYPE_CODE_ARRAY &&
+ TYPE_CODE (type) != TYPE_CODE_STRING &&
+ TYPE_CODE (type) != TYPE_CODE_RANGE)
+ {
+ PyErr_SetString (PyExc_RuntimeError,
+ "This type does not have a range.");
+ return NULL;
+ }
+
+ switch (TYPE_CODE (type))
+ {
+ case TYPE_CODE_ARRAY:
+ case TYPE_CODE_STRING:
+ low = PyLong_FromLong (TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type)));
+ high = PyLong_FromLong (TYPE_HIGH_BOUND (TYPE_INDEX_TYPE (type)));
+ break;
+ case TYPE_CODE_RANGE:
+ low = PyLong_FromLong (TYPE_LOW_BOUND (type));
+ high = PyLong_FromLong (TYPE_HIGH_BOUND (type));
+ break;
+ }
+
+ result = PyTuple_New (2);
+ PyTuple_SetItem (result, 0, low);
+ PyTuple_SetItem (result, 1, high);
+
+ return result;
+}
+
/* Return a Type object which represents a reference to SELF. */
static PyObject *
typy_reference (PyObject *self, PyObject *args)
@@ -699,6 +737,9 @@
{ "pointer", typy_pointer, METH_NOARGS,
"pointer () -> Type\n\
Return a type of pointer to this type." },
+ { "range", typy_range, METH_NOARGS,
+ "range () -> Tuple\n\
+Return a Tuple containing the lower and upper range for this type."},
{ "reference", typy_reference, METH_NOARGS,
"reference () -> Type\n\
Return a type of reference to this type." },
Index: testsuite/gdb.python/py-type.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-type.exp,v
retrieving revision 1.1
diff -u -r1.1 py-type.exp
--- testsuite/gdb.python/py-type.exp 3 Dec 2009 21:19:49 -0000 1.1
+++ testsuite/gdb.python/py-type.exp 4 Dec 2009 15:15:24 -0000
@@ -102,6 +102,28 @@
gdb_test "python print fields\[1\].is_base_class" "False" "Check base class"
}
+proc test_range {} {
+
+ # Test a valid range request.
+ gdb_py_test_silent_cmd "print ar" "print value" 1
+ gdb_py_test_silent_cmd "python ar = gdb.history (0)" "get value from history" 1
+ gdb_test "python print len(ar.type.range())" "2" "Check correct tuple length"
+ gdb_test "python print ar.type.range()\[0\]" "0" "Check low range"
+ gdb_test "python print ar.type.range()\[1\]" "1" "Check high range"
+
+ # Test a range request on a ranged type.
+ gdb_py_test_silent_cmd "print ar" "print value" 1
+ gdb_py_test_silent_cmd "python ar = gdb.history (0)" "get value from history" 1
+ gdb_py_test_silent_cmd "python fields = ar.type.fields()" "get fields" 1
+ gdb_test "python print fields\[0\].type.range()\[0\]" "0" "Check range type low bound"
+ gdb_test "python print fields\[0\].type.range()\[1\]" "1" "Check range type high bound"
+
+ # Test where a range does not exist.
+ gdb_py_test_silent_cmd "print st" "print value" 1
+ gdb_py_test_silent_cmd "python st = gdb.history (0)" "get value from history" 1
+ gdb_test "python print st.type.range()" "RuntimeError: This type does not have a range.*" "Check range for non ranged type."
+}
+
# Perform C Tests.
build_inferior "c"
restart_gdb "break to inspect struct and array."
@@ -112,3 +134,4 @@
restart_gdb "break to inspect struct and array."
test_fields "c++"
test_base_class
+test_range
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [python][patch] And range method to type
2009-12-04 15:25 [python][patch] And range method to type Phil Muldoon
@ 2009-12-04 15:32 ` Eli Zaretskii
2009-12-04 17:10 ` Phil Muldoon
2009-12-04 17:19 ` Joel Brobecker
2009-12-04 18:13 ` Tom Tromey
2 siblings, 1 reply; 16+ messages in thread
From: Eli Zaretskii @ 2009-12-04 15:32 UTC (permalink / raw)
To: Phil Muldoon; +Cc: gdb-patches
> Date: Fri, 04 Dec 2009 15:25:16 +0000
> From: Phil Muldoon <pmuldoon@redhat.com>
>
> This patch adds a "range" method for GDB.Types. It only supports types
> that support a range, or the range type itself.
>
> Ok?
A couple of comments to the doco part:
> +@defmethod Type range
> +Return a Python @code{Tuple} object that contains two elements. The
> +first element of the @code{Tuple} contains the low bound of the type; the
> +second element contains the high bound of the type.
This could be made a bit more concise:
Return a Python @code{Tuple} object that contains two elements: the
low bound of the argument type and the high bound of that type.
> If the type does
> +not have a range, @value{GDBN} will throw a @code{RuntimeError}
> +@end defmethod
The last sentence is incomplete.
Thanks.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [python][patch] And range method to type
2009-12-04 15:32 ` Eli Zaretskii
@ 2009-12-04 17:10 ` Phil Muldoon
2009-12-04 19:30 ` Eli Zaretskii
0 siblings, 1 reply; 16+ messages in thread
From: Phil Muldoon @ 2009-12-04 17:10 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: gdb-patches
On 12/04/2009 03:32 PM, Eli Zaretskii wrote:
>> Date: Fri, 04 Dec 2009 15:25:16 +0000
>> From: Phil Muldoon <pmuldoon@redhat.com>
>>
>> This patch adds a "range" method for GDB.Types. It only supports types
>> that support a range, or the range type itself.
>>
>> Ok?
>
> A couple of comments to the doco part:
>
>> +@defmethod Type range
>> +Return a Python @code{Tuple} object that contains two elements. The
>> +first element of the @code{Tuple} contains the low bound of the type; the
>> +second element contains the high bound of the type.
+@defmethod Type range
+Return a Python @code{Tuple} object that contains two elements: the
+low bound of the argument type and the high bound of that type. If the
+type does not have a range, @value{GDBN} will raise a @code{RuntimeError}.
+@end defmethod
With your suggestions, adding the missing full-stop and changing "throw" to "raise"
in the exception case, is this ok?
Cheers,
Phil
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [python][patch] And range method to type
2009-12-04 15:25 [python][patch] And range method to type Phil Muldoon
2009-12-04 15:32 ` Eli Zaretskii
@ 2009-12-04 17:19 ` Joel Brobecker
2009-12-04 18:13 ` Tom Tromey
2 siblings, 0 replies; 16+ messages in thread
From: Joel Brobecker @ 2009-12-04 17:19 UTC (permalink / raw)
To: Phil Muldoon; +Cc: gdb-patches ml
This is not an official review, as I don't have much experience
exporting to Python, but it seems right to me. Just one minor
cosmetic comment:
> + if (TYPE_CODE (type) != TYPE_CODE_ARRAY &&
> + TYPE_CODE (type) != TYPE_CODE_STRING &&
> + TYPE_CODE (type) != TYPE_CODE_RANGE)
The && operators should be at the beginning of the line (GNU Coding
Standards):
if (TYPE_CODE (type) != TYPE_CODE_ARRAY
&& TYPE_CODE (type) != TYPE_CODE_STRING
&& TYPE_CODE (type) != TYPE_CODE_RANGE)
--
Joel
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [python][patch] And range method to type
2009-12-04 15:25 [python][patch] And range method to type Phil Muldoon
2009-12-04 15:32 ` Eli Zaretskii
2009-12-04 17:19 ` Joel Brobecker
@ 2009-12-04 18:13 ` Tom Tromey
2009-12-05 9:19 ` Phil Muldoon
2 siblings, 1 reply; 16+ messages in thread
From: Tom Tromey @ 2009-12-04 18:13 UTC (permalink / raw)
To: Phil Muldoon; +Cc: gdb-patches ml
>>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> writes:
Phil> This patch adds a "range" method for GDB.Types. It only supports types
Phil> that support a range, or the range type itself.
Phil> + if (TYPE_CODE (type) != TYPE_CODE_ARRAY &&
Phil> + TYPE_CODE (type) != TYPE_CODE_STRING &&
Phil> + TYPE_CODE (type) != TYPE_CODE_RANGE)
In the GNU style, the "&&"s go at the start of the line.
I think this code should check for failures from PyLong_FromLong and
PyTuple_SetItem. I realize that is a pain, but if one of those does
fail, a failure to check will yield weird problems.
Phil> Return a type of pointer to this type." },
Phil> + { "range", typy_range, METH_NOARGS,
Phil> + "range () -> Tuple\n\
It should be "tuple", as that is the name of the returned type.
Tom
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [python][patch] And range method to type
2009-12-04 17:10 ` Phil Muldoon
@ 2009-12-04 19:30 ` Eli Zaretskii
0 siblings, 0 replies; 16+ messages in thread
From: Eli Zaretskii @ 2009-12-04 19:30 UTC (permalink / raw)
To: Phil Muldoon; +Cc: gdb-patches
> Date: Fri, 04 Dec 2009 17:10:09 +0000
> From: Phil Muldoon <pmuldoon@redhat.com>
> CC: gdb-patches@sourceware.org
>
> +@defmethod Type range
> +Return a Python @code{Tuple} object that contains two elements: the
> +low bound of the argument type and the high bound of that type. If the
> +type does not have a range, @value{GDBN} will raise a @code{RuntimeError}.
> +@end defmethod
>
> With your suggestions, adding the missing full-stop and changing "throw" to "raise"
> in the exception case, is this ok?
Fine with me, although I thought you'd want to say "raise a
RuntimeError exception". But if your wording is accepted in Python
context, I'm fine with that.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [python][patch] And range method to type
2009-12-04 18:13 ` Tom Tromey
@ 2009-12-05 9:19 ` Phil Muldoon
2009-12-05 9:22 ` Eli Zaretskii
2009-12-07 19:54 ` Tom Tromey
0 siblings, 2 replies; 16+ messages in thread
From: Phil Muldoon @ 2009-12-05 9:19 UTC (permalink / raw)
To: tromey; +Cc: gdb-patches ml
On 12/04/2009 06:13 PM, Tom Tromey wrote:
>>>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> writes:
>
> Phil> This patch adds a "range" method for GDB.Types. It only supports types
> Phil> that support a range, or the range type itself.
>
> Phil> + if (TYPE_CODE (type) != TYPE_CODE_ARRAY &&
> Phil> + TYPE_CODE (type) != TYPE_CODE_STRING &&
> Phil> + TYPE_CODE (type) != TYPE_CODE_RANGE)
>
> In the GNU style, the "&&"s go at the start of the line.
OK.
>
> I think this code should check for failures from PyLong_FromLong and
> PyTuple_SetItem. I realize that is a pain, but if one of those does
> fail, a failure to check will yield weird problems.
OK, the new code has more robust error checking.
> Phil> Return a type of pointer to this type." },
> Phil> + { "range", typy_range, METH_NOARGS,
> Phil> + "range () -> Tuple\n\
>
> It should be "tuple", as that is the name of the returned type.
OK.
I've regenerated the patch. Thanks for the review! What do you think?
Cheers,
Phil
--
Index: doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.647
diff -u -r1.647 gdb.texinfo
--- doc/gdb.texinfo 3 Dec 2009 21:19:48 -0000 1.647
+++ doc/gdb.texinfo 5 Dec 2009 09:11:25 -0000
@@ -19654,6 +19654,13 @@
@code{volatile}.
@end defmethod
+@defmethod Type range
+Return a Python @code{Tuple} object that contains two elements: the
+low bound of the argument type and the high bound of that type. If
+the type does not have a range, @value{GDBN} will raise a
+@code{RuntimeError} exception.
+@end defmethod
+
@defmethod Type reference
Return a new @code{gdb.Type} object which represents a reference to this
type.
Index: python/py-type.c
===================================================================
RCS file: /cvs/src/src/gdb/python/py-type.c,v
retrieving revision 1.3
diff -u -r1.3 py-type.c
--- python/py-type.c 3 Dec 2009 21:19:49 -0000 1.3
+++ python/py-type.c 5 Dec 2009 09:11:25 -0000
@@ -273,6 +273,70 @@
return type_to_type_object (type);
}
+/* Return the range of a type represented by SELF. The return type is
+ a tuple. The first element of the tuple contains the low bound,
+ while the second element of the tuple contains the high bound. */
+static PyObject *
+typy_range (PyObject *self, PyObject *args)
+{
+ struct type *type = ((type_object *) self)->type;
+ PyObject *result;
+ PyObject *low_bound = NULL, *high_bound = NULL;
+ LONGEST low, high;
+
+ if (TYPE_CODE (type) != TYPE_CODE_ARRAY
+ && TYPE_CODE (type) != TYPE_CODE_STRING
+ && TYPE_CODE (type) != TYPE_CODE_RANGE)
+ {
+ PyErr_SetString (PyExc_RuntimeError,
+ "This type does not have a range.");
+ return NULL;
+ }
+
+ switch (TYPE_CODE (type))
+ {
+ case TYPE_CODE_ARRAY:
+ case TYPE_CODE_STRING:
+ low = TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type));
+ high = TYPE_HIGH_BOUND (TYPE_INDEX_TYPE (type));
+ break;
+ case TYPE_CODE_RANGE:
+ low = TYPE_LOW_BOUND (type);
+ high = TYPE_HIGH_BOUND (type);
+ break;
+ }
+
+ low_bound = PyLong_FromLong (low);
+ if (!low_bound)
+ goto failarg;
+
+ high_bound = PyLong_FromLong (high);
+ if (!high_bound)
+ goto failarg;
+
+ result = PyTuple_New (2);
+ if (!result)
+ goto failarg;
+
+ if (PyTuple_SetItem (result, 0, low_bound) != 0)
+ {
+ Py_DECREF (result);
+ goto failarg;
+ }
+ if (PyTuple_SetItem (result, 1, high_bound) != 0)
+ {
+ Py_DECREF (high_bound);
+ Py_DECREF (result);
+ return NULL;
+ }
+ return result;
+
+ failarg:
+ Py_XDECREF (high_bound);
+ Py_XDECREF (low_bound);
+ return NULL;
+}
+
/* Return a Type object which represents a reference to SELF. */
static PyObject *
typy_reference (PyObject *self, PyObject *args)
@@ -699,6 +763,9 @@
{ "pointer", typy_pointer, METH_NOARGS,
"pointer () -> Type\n\
Return a type of pointer to this type." },
+ { "range", typy_range, METH_NOARGS,
+ "range () -> tuple\n\
+Return a tuple containing the lower and upper range for this type."},
{ "reference", typy_reference, METH_NOARGS,
"reference () -> Type\n\
Return a type of reference to this type." },
Index: testsuite/gdb.python/py-type.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-type.exp,v
retrieving revision 1.1
diff -u -r1.1 py-type.exp
--- testsuite/gdb.python/py-type.exp 3 Dec 2009 21:19:49 -0000 1.1
+++ testsuite/gdb.python/py-type.exp 5 Dec 2009 09:11:26 -0000
@@ -102,6 +102,28 @@
gdb_test "python print fields\[1\].is_base_class" "False" "Check base class"
}
+proc test_range {} {
+
+ # Test a valid range request.
+ gdb_py_test_silent_cmd "print ar" "print value" 1
+ gdb_py_test_silent_cmd "python ar = gdb.history (0)" "get value from history" 1
+ gdb_test "python print len(ar.type.range())" "2" "Check correct tuple length"
+ gdb_test "python print ar.type.range()\[0\]" "0" "Check low range"
+ gdb_test "python print ar.type.range()\[1\]" "1" "Check high range"
+
+ # Test a range request on a ranged type.
+ gdb_py_test_silent_cmd "print ar" "print value" 1
+ gdb_py_test_silent_cmd "python ar = gdb.history (0)" "get value from history" 1
+ gdb_py_test_silent_cmd "python fields = ar.type.fields()" "get fields" 1
+ gdb_test "python print fields\[0\].type.range()\[0\]" "0" "Check range type low bound"
+ gdb_test "python print fields\[0\].type.range()\[1\]" "1" "Check range type high bound"
+
+ # Test where a range does not exist.
+ gdb_py_test_silent_cmd "print st" "print value" 1
+ gdb_py_test_silent_cmd "python st = gdb.history (0)" "get value from history" 1
+ gdb_test "python print st.type.range()" "RuntimeError: This type does not have a range.*" "Check range for non ranged type."
+}
+
# Perform C Tests.
build_inferior "c"
restart_gdb "break to inspect struct and array."
@@ -112,3 +134,4 @@
restart_gdb "break to inspect struct and array."
test_fields "c++"
test_base_class
+test_range
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [python][patch] And range method to type
2009-12-05 9:19 ` Phil Muldoon
@ 2009-12-05 9:22 ` Eli Zaretskii
2009-12-07 19:54 ` Tom Tromey
1 sibling, 0 replies; 16+ messages in thread
From: Eli Zaretskii @ 2009-12-05 9:22 UTC (permalink / raw)
To: Phil Muldoon; +Cc: tromey, gdb-patches
> Date: Sat, 05 Dec 2009 09:19:44 +0000
> From: Phil Muldoon <pmuldoon@redhat.com>
> CC: gdb-patches ml <gdb-patches@sourceware.org>
>
> I've regenerated the patch. Thanks for the review! What do you think?
The gdb.texinfo part is OK with me.
Thanks.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [python][patch] And range method to type
2009-12-05 9:19 ` Phil Muldoon
2009-12-05 9:22 ` Eli Zaretskii
@ 2009-12-07 19:54 ` Tom Tromey
2009-12-08 14:14 ` Phil Muldoon
1 sibling, 1 reply; 16+ messages in thread
From: Tom Tromey @ 2009-12-07 19:54 UTC (permalink / raw)
To: Phil Muldoon; +Cc: gdb-patches ml
>>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> writes:
Phil> I've regenerated the patch. Thanks for the review! What do you think?
Ok.
Tom
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [python][patch] And range method to type
2009-12-07 19:54 ` Tom Tromey
@ 2009-12-08 14:14 ` Phil Muldoon
2009-12-09 3:00 ` Hui Zhu
0 siblings, 1 reply; 16+ messages in thread
From: Phil Muldoon @ 2009-12-08 14:14 UTC (permalink / raw)
To: gdb-patches ml; +Cc: Tom Tromey, Eli Zaretskii
> Phil> I've regenerated the patch. Thanks for the review! What do you think?
>>>>>> On 12/07/2009 07:54 PM, Tom Tromey wrote:
> Ok.
>>>>>> On 12/04/2009 03:32 PM, Eli Zaretskii wrote:
> The gdb.texinfo part is OK with me.
Committed, thanks.
Cheers,
Phil
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [python][patch] And range method to type
2009-12-08 14:14 ` Phil Muldoon
@ 2009-12-09 3:00 ` Hui Zhu
2009-12-09 7:47 ` Phil Muldoon
2009-12-09 7:52 ` Phil Muldoon
0 siblings, 2 replies; 16+ messages in thread
From: Hui Zhu @ 2009-12-09 3:00 UTC (permalink / raw)
To: Phil Muldoon; +Cc: gdb-patches ml, Tom Tromey, Eli Zaretskii
Hi,
I make the cvs-head get:
gcc -g -O2 -I. -I../../src/gdb -I../../src/gdb/common
-I../../src/gdb/config -DLOCALEDIR="\"/usr/local/share/locale\""
-DHAVE_CONFIG_H -I../../src/gdb/../include/opcode
-I../../src/gdb/../readline/.. -I../bfd -I../../src/gdb/../bfd
-I../../src/gdb/../include -I../libdecnumber
-I../../src/gdb/../libdecnumber -I../../src/gdb/gnulib -Ignulib
-DMI_OUT=1 -DTUI=1 -DGDBTK -Wall -Wdeclaration-after-statement
-Wpointer-arith -Wformat-nonliteral -Wno-pointer-sign -Wno-unused
-Wunused-value -Wno-switch -Wno-char-subscripts -Werror -c -o
py-type.o -MT py-type.o -MMD -MP -MF .deps/py-type.Tpo
-fno-strict-aliasing -DNDEBUG -fwrapv ../../src/gdb/python/py-type.c
cc1: warnings being treated as errors
../../src/gdb/python/py-type.c: In function 'typy_range':
../../src/gdb/python/py-type.c:285: warning: 'high' may be used
uninitialized in this function
../../src/gdb/python/py-type.c:285: warning: 'low' may be used
uninitialized in this function
make[2]: *** [py-type.o] Error 1
make[2]: Leaving directory `/home/teawater/gdb/cvs/bgdb/gdb'
make[1]: *** [all-gdb] Error 2
make[1]: Leaving directory `/home/teawater/gdb/cvs/bgdb'
make: *** [all] Error 2
Thanks,
Hui
On Tue, Dec 8, 2009 at 22:13, Phil Muldoon <pmuldoon@redhat.com> wrote:
>
>> Phil> I've regenerated the patch. Thanks for the review! What do you think?
>
>>>>>>> On 12/07/2009 07:54 PM, Tom Tromey wrote:
>
>> Ok.
>
>>>>>>> On 12/04/2009 03:32 PM, Eli Zaretskii wrote:
>
>> The gdb.texinfo part is OK with me.
>
> Committed, thanks.
>
> Cheers,
>
> Phil
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [python][patch] And range method to type
2009-12-09 3:00 ` Hui Zhu
@ 2009-12-09 7:47 ` Phil Muldoon
2009-12-09 11:27 ` Eli Zaretskii
2009-12-09 7:52 ` Phil Muldoon
1 sibling, 1 reply; 16+ messages in thread
From: Phil Muldoon @ 2009-12-09 7:47 UTC (permalink / raw)
To: Hui Zhu; +Cc: gdb-patches ml, Tom Tromey, Eli Zaretskii
> I make the cvs-head get:
> cc1: warnings being treated as errors
> ../../src/gdb/python/py-type.c: In function 'typy_range':
> ../../src/gdb/python/py-type.c:285: warning: 'high' may be used
> uninitialized in this function
> ../../src/gdb/python/py-type.c:285: warning: 'low' may be used
> uninitialized in this function
I do not see this on my build at all. I just did a clean build from a
new checkout with CVS and the build completes successfully. What is
your version of GCC?
For reference, mine is:
gcc version 4.4.2 20091027 (Red Hat 4.4.2-7) (GCC)
I'll initialize the values to appease the differing versions of GCC,
and send the patch (as obvious) to the list
Cheers,
Phil
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [python][patch] And range method to type
2009-12-09 3:00 ` Hui Zhu
2009-12-09 7:47 ` Phil Muldoon
@ 2009-12-09 7:52 ` Phil Muldoon
2009-12-09 7:56 ` Hui Zhu
1 sibling, 1 reply; 16+ messages in thread
From: Phil Muldoon @ 2009-12-09 7:52 UTC (permalink / raw)
To: Hui Zhu; +Cc: gdb-patches ml, Tom Tromey, Eli Zaretskii
On 12/09/2009 03:00 AM, Hui Zhu wrote:
> cc1: warnings being treated as errors
> ../../src/gdb/python/py-type.c: In function 'typy_range':
> ../../src/gdb/python/py-type.c:285: warning: 'high' may be used
> uninitialized in this function
> ../../src/gdb/python/py-type.c:285: warning: 'low' may be used
> uninitialized in this function
> make[2]: *** [py-type.o] Error 1
> make[2]: Leaving directory `/home/teawater/gdb/cvs/bgdb/gdb'
> make[1]: *** [all-gdb] Error 2
> make[1]: Leaving directory `/home/teawater/gdb/cvs/bgdb'
> make: *** [all] Error 2
I've checked in the following patch under the obvious rule to appease
these warnings. I do not see them on my compiler, but it looks like
some versions might trigger the (bogus, imo ;) warning:
--
Index: python/py-type.c
===================================================================
RCS file: /cvs/src/src/gdb/python/py-type.c,v
retrieving revision 1.4
diff -u -r1.4 py-type.c
--- python/py-type.c 8 Dec 2009 14:06:02 -0000 1.4
+++ python/py-type.c 9 Dec 2009 07:47:34 -0000
@@ -282,7 +282,8 @@
struct type *type = ((type_object *) self)->type;
PyObject *result;
PyObject *low_bound = NULL, *high_bound = NULL;
- LONGEST low, high;
+ /* Initialize these to appease GCC warnings. */
+ LONGEST low = 0, high = 0;
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [python][patch] And range method to type
2009-12-09 7:52 ` Phil Muldoon
@ 2009-12-09 7:56 ` Hui Zhu
0 siblings, 0 replies; 16+ messages in thread
From: Hui Zhu @ 2009-12-09 7:56 UTC (permalink / raw)
To: Phil Muldoon; +Cc: gdb-patches ml, Tom Tromey, Eli Zaretskii
It's OK now. Thanks.
My gcc is:
gcc -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--with-gxx-include-dir=/usr/include/c++/4.2 --program-suffix=-4.2
--enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc
--enable-mpfr --enable-targets=all --enable-checking=release
--build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.2.4 (Ubuntu 4.2.4-1ubuntu4)
Hui
On Wed, Dec 9, 2009 at 15:52, Phil Muldoon <pmuldoon@redhat.com> wrote:
> On 12/09/2009 03:00 AM, Hui Zhu wrote:
>> cc1: warnings being treated as errors
>> ../../src/gdb/python/py-type.c: In function 'typy_range':
>> ../../src/gdb/python/py-type.c:285: warning: 'high' may be used
>> uninitialized in this function
>> ../../src/gdb/python/py-type.c:285: warning: 'low' may be used
>> uninitialized in this function
>> make[2]: *** [py-type.o] Error 1
>> make[2]: Leaving directory `/home/teawater/gdb/cvs/bgdb/gdb'
>> make[1]: *** [all-gdb] Error 2
>> make[1]: Leaving directory `/home/teawater/gdb/cvs/bgdb'
>> make: *** [all] Error 2
>
>
> I've checked in the following patch under the obvious rule to appease
> these warnings. I do not see them on my compiler, but it looks like
> some versions might trigger the (bogus, imo ;) warning:
>
>
> --
>
> Index: python/py-type.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/python/py-type.c,v
> retrieving revision 1.4
> diff -u -r1.4 py-type.c
> --- python/py-type.c 8 Dec 2009 14:06:02 -0000 1.4
> +++ python/py-type.c 9 Dec 2009 07:47:34 -0000
> @@ -282,7 +282,8 @@
> struct type *type = ((type_object *) self)->type;
> PyObject *result;
> PyObject *low_bound = NULL, *high_bound = NULL;
> - LONGEST low, high;
> + /* Initialize these to appease GCC warnings. */
> + LONGEST low = 0, high = 0;
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [python][patch] And range method to type
2009-12-09 7:47 ` Phil Muldoon
@ 2009-12-09 11:27 ` Eli Zaretskii
2009-12-09 11:41 ` Andreas Schwab
0 siblings, 1 reply; 16+ messages in thread
From: Eli Zaretskii @ 2009-12-09 11:27 UTC (permalink / raw)
To: Phil Muldoon; +Cc: teawater, gdb-patches, tromey
> Date: Wed, 09 Dec 2009 07:46:54 +0000
> From: Phil Muldoon <pmuldoon@redhat.com>
> CC: gdb-patches ml <gdb-patches@sourceware.org>, Tom Tromey <tromey@redhat.com>, Eli Zaretskii <eliz@gnu.org>
>
>
> > I make the cvs-head get:
>
> > cc1: warnings being treated as errors
> > ../../src/gdb/python/py-type.c: In function 'typy_range':
> > ../../src/gdb/python/py-type.c:285: warning: 'high' may be used
> > uninitialized in this function
> > ../../src/gdb/python/py-type.c:285: warning: 'low' may be used
> > uninitialized in this function
>
> I do not see this on my build at all.
Are you compiling without optimizations, per chance? AFAIK, this
warning is only produced in optimized compilations.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [python][patch] And range method to type
2009-12-09 11:27 ` Eli Zaretskii
@ 2009-12-09 11:41 ` Andreas Schwab
0 siblings, 0 replies; 16+ messages in thread
From: Andreas Schwab @ 2009-12-09 11:41 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Phil Muldoon, teawater, gdb-patches, tromey
Eli Zaretskii <eliz@gnu.org> writes:
>> > I make the cvs-head get:
>>
>> > cc1: warnings being treated as errors
>> > ../../src/gdb/python/py-type.c: In function 'typy_range':
>> > ../../src/gdb/python/py-type.c:285: warning: 'high' may be used
>> > uninitialized in this function
>> > ../../src/gdb/python/py-type.c:285: warning: 'low' may be used
>> > uninitialized in this function
>>
>> I do not see this on my build at all.
>
> Are you compiling without optimizations, per chance? AFAIK, this
> warning is only produced in optimized compilations.
Recent gcc versions are also much better at tracking values.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2009-12-09 11:41 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-04 15:25 [python][patch] And range method to type Phil Muldoon
2009-12-04 15:32 ` Eli Zaretskii
2009-12-04 17:10 ` Phil Muldoon
2009-12-04 19:30 ` Eli Zaretskii
2009-12-04 17:19 ` Joel Brobecker
2009-12-04 18:13 ` Tom Tromey
2009-12-05 9:19 ` Phil Muldoon
2009-12-05 9:22 ` Eli Zaretskii
2009-12-07 19:54 ` Tom Tromey
2009-12-08 14:14 ` Phil Muldoon
2009-12-09 3:00 ` Hui Zhu
2009-12-09 7:47 ` Phil Muldoon
2009-12-09 11:27 ` Eli Zaretskii
2009-12-09 11:41 ` Andreas Schwab
2009-12-09 7:52 ` Phil Muldoon
2009-12-09 7:56 ` Hui Zhu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox