From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14751 invoked by alias); 6 Oct 2011 12:49:52 -0000 Received: (qmail 14653 invoked by uid 22791); 6 Oct 2011 12:49:49 -0000 X-SWARE-Spam-Status: No, hits=-6.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 06 Oct 2011 12:49:27 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p96CnRiM010698 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 6 Oct 2011 08:49:27 -0400 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p96CnQHi007760 for ; Thu, 6 Oct 2011 08:49:26 -0400 From: Phil Muldoon To: gdb-patches@sourceware.org Subject: [python] [patch] PR 13624 Reply-to: pmuldoon@redhat.com X-URL: http://www.redhat.com Date: Thu, 06 Oct 2011 12:49:00 -0000 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-10/txt/msg00152.txt.bz2 The patch address PR 13624 which noted that in some instances we were not catching GDB exceptions. I checked every function and I found two GDB cases, and one Python case. OK? Cheers, Phil -- 2011-10-06 Phil Muldoon * python/py-value.c (valpy_call): Check that arguments are a tuple. (valpy_nonzero): Catch GDB exceptions. (valpy_absolute): Ditto. -- diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c index 252d9b9..48bbb0a 100644 --- a/gdb/python/py-value.c +++ b/gdb/python/py-value.c @@ -519,6 +519,13 @@ valpy_call (PyObject *self, PyObject *args, PyObject *keywords) return NULL; } + if (! PyTuple_Check (args)) + { + PyErr_SetString (PyExc_RuntimeError, + _("Inferior arguments must be provided in a tuple.")); + return NULL; + } + args_count = PyTuple_Size (args); if (args_count > 0) { @@ -792,33 +799,53 @@ static PyObject * valpy_absolute (PyObject *self) { struct value *value = ((value_object *) self)->value; + volatile struct gdb_exception except; + int isabs = 1; - if (value_less (value, value_zero (value_type (value), not_lval))) - return valpy_negative (self); - else + TRY_CATCH (except, RETURN_MASK_ALL) + { + if (value_less (value, value_zero (value_type (value), not_lval))) + isabs = 0; + } + GDB_PY_HANDLE_EXCEPTION (except); + + if (isabs) return valpy_positive (self); + else + return valpy_negative (self); } /* Implements boolean evaluation of gdb.Value. */ static int valpy_nonzero (PyObject *self) { + volatile struct gdb_exception except; value_object *self_value = (value_object *) self; struct type *type; + int nonzero = 0; /* Appease GCC warning. */ type = check_typedef (value_type (self_value->value)); - if (is_integral_type (type) || TYPE_CODE (type) == TYPE_CODE_PTR) - return !!value_as_long (self_value->value); - else if (TYPE_CODE (type) == TYPE_CODE_FLT) - return value_as_double (self_value->value) != 0; - else if (TYPE_CODE (type) == TYPE_CODE_DECFLOAT) - return !decimal_is_zero (value_contents (self_value->value), - TYPE_LENGTH (type), - gdbarch_byte_order (get_type_arch (type))); - else - /* All other values are True. */ - return 1; + TRY_CATCH (except, RETURN_MASK_ALL) + { + if (is_integral_type (type) || TYPE_CODE (type) == TYPE_CODE_PTR) + nonzero = !!value_as_long (self_value->value); + else if (TYPE_CODE (type) == TYPE_CODE_FLT) + nonzero = value_as_double (self_value->value) != 0; + else if (TYPE_CODE (type) == TYPE_CODE_DECFLOAT) + nonzero = !decimal_is_zero (value_contents (self_value->value), + TYPE_LENGTH (type), + gdbarch_byte_order (get_type_arch (type))); + else + /* All other values are True. */ + nonzero = 1; + } + /* This is not documented in the Python documentation, but if this + function fails, return -1 as slot_nb_nonzero does (the default + Python nonzero function). */ + GDB_PY_SET_HANDLE_EXCEPTION (except); + + return nonzero; } /* Implements ~ for value objects. */