From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29205 invoked by alias); 24 Mar 2009 17:33:23 -0000 Mailing-List: contact archer-commits-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: Received: (qmail 29104 invoked by uid 9674); 24 Mar 2009 17:33:22 -0000 Date: Tue, 24 Mar 2009 17:33:00 -0000 Message-ID: <20090324173322.29083.qmail@sourceware.org> From: jkratoch@sourceware.org To: archer-commits@sourceware.org Subject: [SCM] archer-jankratochvil-python: Merge commit 'origin/archer-tromey-python' into archer-jankratochvil-python X-Git-Refname: refs/heads/archer-jankratochvil-python X-Git-Reftype: branch X-Git-Oldrev: 9640dcec5549aabe60d6e0bb71264195d243990f X-Git-Newrev: 57ef0cba8a93024e781a32a323884f8a7ff1d557 X-SW-Source: 2009-q1/txt/msg00367.txt.bz2 List-Id: The branch, archer-jankratochvil-python has been updated via 57ef0cba8a93024e781a32a323884f8a7ff1d557 (commit) via cb7eaa7343fa9fa04f8deee2471b85be2b44fe13 (commit) via cb27ee6e1ada4fd6992dd51da402baef10ad88e3 (commit) via e107fb9687bb1e7f74170aa3d19c4a8f6edbb10f (commit) via 6e85bcb66b4c94185c527f475c14711b621d0fdf (commit) from 9640dcec5549aabe60d6e0bb71264195d243990f (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- ----------------------------------------------------------------------- Summary of changes: gdb/doc/gdb.texinfo | 12 +++++++++++- gdb/python/lib/gdb/libstdcxx/v6/printers.py | 23 ++++++++++++++++------- gdb/python/python-frame.c | 2 +- gdb/python/python-type.c | 9 ++++++++- gdb/python/python-value.c | 21 ++++++++++++++++++++- gdb/testsuite/gdb.python/python-value.exp | 3 +++ 6 files changed, 59 insertions(+), 11 deletions(-) First 500 lines of diff: diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 7a13a7f..b82be72 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -18514,6 +18514,15 @@ bar = some_val['foo'] Again, @code{bar} will also be a @code{gdb.Value} object. +The following attribute is provided: + +@table @code +@defmethod Value is_optimized_out +This read-only boolean attribute is true if the compiler optimized out +this value, thus it is not available for fetching from the inferior. +@end defmethod +@end table + The following methods are provided: @table @code @@ -18637,7 +18646,8 @@ non-zero value, which is the size of the field in bits. Otherwise, this will be zero; in this case the field's size is given by its type. @item type -The type of the field. +The type of the field. This is usually an instance of @code{Type}, +but it can be @code{None} in some situations. @end table @end defmethod diff --git a/gdb/python/lib/gdb/libstdcxx/v6/printers.py b/gdb/python/lib/gdb/libstdcxx/v6/printers.py index c0dc987..bbe4475 100644 --- a/gdb/python/lib/gdb/libstdcxx/v6/printers.py +++ b/gdb/python/lib/gdb/libstdcxx/v6/printers.py @@ -27,6 +27,8 @@ class StdPointerPrinter: self.val = val def to_string (self): + if self.val['_M_refcount']['_M_pi'] == 0: + return '%s (empty) %s' % (self.typename, self.val['_M_ptr']) return '%s (count %d) %s' % (self.typename, self.val['_M_refcount']['_M_pi']['_M_use_count'], self.val['_M_ptr']) @@ -617,14 +619,21 @@ def build_libstdcxx_dictionary (): pretty_printers_dict[re.compile('^std::vector<.*>$')] = StdVectorPrinter # vector - # These are the C++0x printers. They also exist in the standard namespace. + # These are the TR1 and C++0x printers. # For array - the default GDB pretty-printer seems reasonable. - pretty_printers_dict[re.compile('^std::(tr1::)?shared_ptr<.*>$')] = lambda val: StdPointerPrinter ('std::shared_ptr', val) - pretty_printers_dict[re.compile('^std::(tr1::)?weak_ptr<.*>$')] = lambda val: StdPointerPrinter ('std::weak_ptr', val) - pretty_printers_dict[re.compile('^std::(tr1::)?unordered_map<.*>$')] = lambda val: Tr1UnorderedMapPrinter ('std::tr1::unordered_map', val) - pretty_printers_dict[re.compile('^std::(tr1::)?unordered_set<.*>$')] = lambda val: Tr1UnorderedSetPrinter ('std::tr1::unordered_set', val) - pretty_printers_dict[re.compile('^std::(tr1::)?unordered_multimap<.*>$')] = lambda val: Tr1UnorderedMapPrinter ('std::tr1::unordered_multimap', val) - pretty_printers_dict[re.compile('^std::(tr1::)?unordered_multiset<.*>$')] = lambda val: Tr1UnorderedSetPrinter ('std::tr1::unordered_multiset', val) + pretty_printers_dict[re.compile('^std::shared_ptr<.*>$')] = lambda val: StdPointerPrinter ('std::shared_ptr', val) + pretty_printers_dict[re.compile('^std::weak_ptr<.*>$')] = lambda val: StdPointerPrinter ('std::weak_ptr', val) + pretty_printers_dict[re.compile('^std::unordered_map<.*>$')] = lambda val: Tr1UnorderedMapPrinter ('std::unordered_map', val) + pretty_printers_dict[re.compile('^std::unordered_set<.*>$')] = lambda val: Tr1UnorderedSetPrinter ('std::unordered_set', val) + pretty_printers_dict[re.compile('^std::unordered_multimap<.*>$')] = lambda val: Tr1UnorderedMapPrinter ('std::unordered_multimap', val) + pretty_printers_dict[re.compile('^std::unordered_multiset<.*>$')] = lambda val: Tr1UnorderedSetPrinter ('std::unordered_multiset', val) + + pretty_printers_dict[re.compile('^std::tr1::shared_ptr<.*>$')] = lambda val: StdPointerPrinter ('std::tr1::shared_ptr', val) + pretty_printers_dict[re.compile('^std::tr1::weak_ptr<.*>$')] = lambda val: StdPointerPrinter ('std::tr1::weak_ptr', val) + pretty_printers_dict[re.compile('^std::tr1::unordered_map<.*>$')] = lambda val: Tr1UnorderedMapPrinter ('std::tr1::unordered_map', val) + pretty_printers_dict[re.compile('^std::tr1::unordered_set<.*>$')] = lambda val: Tr1UnorderedSetPrinter ('std::tr1::unordered_set', val) + pretty_printers_dict[re.compile('^std::tr1::unordered_multimap<.*>$')] = lambda val: Tr1UnorderedMapPrinter ('std::tr1::unordered_multimap', val) + pretty_printers_dict[re.compile('^std::tr1::unordered_multiset<.*>$')] = lambda val: Tr1UnorderedSetPrinter ('std::tr1::unordered_multiset', val) # Extensions. diff --git a/gdb/python/python-frame.c b/gdb/python/python-frame.c index dc3f45e..1fc553b 100644 --- a/gdb/python/python-frame.c +++ b/gdb/python/python-frame.c @@ -419,7 +419,7 @@ frapy_read_var (PyObject *self, PyObject *args) var_name = python_string_to_target_string (sym_obj); if (!var_name) - return NULL; + return NULL; cleanup = make_cleanup (xfree, var_name); TRY_CATCH (except, RETURN_MASK_ALL) diff --git a/gdb/python/python-type.c b/gdb/python/python-type.c index 772a011..c851cdb 100644 --- a/gdb/python/python-type.c +++ b/gdb/python/python-type.c @@ -176,7 +176,14 @@ convert_field (struct type *type, int field) if (PyObject_SetAttrString (result, "bitsize", arg) < 0) goto failarg; - arg = type_to_type_object (TYPE_FIELD_TYPE (type, field)); + /* A field can have a NULL type in some situations. */ + if (TYPE_FIELD_TYPE (type, field) == NULL) + { + arg = Py_None; + Py_INCREF (arg); + } + else + arg = type_to_type_object (TYPE_FIELD_TYPE (type, field)); if (!arg) goto fail; if (PyObject_SetAttrString (result, "type", arg) < 0) diff --git a/gdb/python/python-value.c b/gdb/python/python-value.c index 2507fcd..5d4f596 100644 --- a/gdb/python/python-value.c +++ b/gdb/python/python-value.c @@ -312,6 +312,18 @@ valpy_str (PyObject *self) return result; } +/* Implements gdb.Value.is_optimized_out. */ +static PyObject * +valpy_get_is_optimized_out (PyObject *self, void *closure) +{ + struct value *value = ((value_object *) self)->value; + + if (value_optimized_out (value)) + Py_RETURN_TRUE; + + Py_RETURN_FALSE; +} + enum valpy_opcode { VALPY_ADD, @@ -913,6 +925,13 @@ gdbpy_initialize_values (void) +static PyGetSetDef value_object_getset[] = { + { "is_optimized_out", valpy_get_is_optimized_out, NULL, + "Boolean telling whether the value is optimized out (i.e., not available).", + NULL }, + {NULL} /* Sentinel */ +}; + static PyMethodDef value_object_methods[] = { { "address", valpy_address, METH_NOARGS, "Return the address of the value." }, { "cast", valpy_cast, METH_VARARGS, "Cast the value to the supplied type." }, @@ -987,7 +1006,7 @@ PyTypeObject value_object_type = { 0, /* tp_iternext */ value_object_methods, /* tp_methods */ 0, /* tp_members */ - 0, /* tp_getset */ + value_object_getset, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ diff --git a/gdb/testsuite/gdb.python/python-value.exp b/gdb/testsuite/gdb.python/python-value.exp index 9ca9593..bd54b2f 100644 --- a/gdb/testsuite/gdb.python/python-value.exp +++ b/gdb/testsuite/gdb.python/python-value.exp @@ -225,6 +225,9 @@ proc test_value_in_inferior {} { # Check that the dereferenced value is sane gdb_test "python print arg0" "0x.*$testfile\"" "verify dereferenced value" + + # Smoke-test is_optimized_out attribute + gdb_test "python print 'result =', arg0.is_optimized_out" "= False" "Test is_optimized_out attribute" } proc test_value_after_death {} { hooks/post-receive -- Repository for Project Archer.