From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30716 invoked by alias); 29 Mar 2009 22:42:32 -0000 Mailing-List: contact archer-commits-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: Received: (qmail 30370 invoked by uid 9674); 29 Mar 2009 22:42:29 -0000 Date: Sun, 29 Mar 2009 22:42:00 -0000 Message-ID: <20090329224227.30354.qmail@sourceware.org> From: jkratoch@sourceware.org To: archer-commits@sourceware.org Subject: [SCM] archer: Merge commit 'origin/archer-jankratochvil-python' into archer X-Git-Refname: refs/heads/archer X-Git-Reftype: branch X-Git-Oldrev: 446b0b4faf66026411834eda53dfa76947ce00b7 X-Git-Newrev: 0bd30605d0f86a62c7dfa2f127b242bcbbe0e818 X-SW-Source: 2009-q1/txt/msg00392.txt.bz2 List-Id: The branch, archer has been updated via 0bd30605d0f86a62c7dfa2f127b242bcbbe0e818 (commit) via a99d5b6c1c3f8667b833b186eefe5f94dc1f6c22 (commit) via 7946cfed05838e9cd6475fca65f9a48662929959 (commit) via 51431bcab78f52fd56bd639e9572a1f075282c3d (commit) via 74b9d22a011e9f8c6b286647ee0a751063f9ed9f (commit) via 1948198702b51b31d79793fc49434b529b4e245f (commit) via 4d8ab8c4efc5939b06dee212d3883cf3b8c2c153 (commit) from 446b0b4faf66026411834eda53dfa76947ce00b7 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 0bd30605d0f86a62c7dfa2f127b242bcbbe0e818 Merge: 446b0b4faf66026411834eda53dfa76947ce00b7 a99d5b6c1c3f8667b833b186eefe5f94dc1f6c22 Author: Jan Kratochvil Date: Mon Mar 30 00:42:00 2009 +0200 Merge commit 'origin/archer-jankratochvil-python' into archer ----------------------------------------------------------------------- Summary of changes: gdb/doc/gdb.texinfo | 18 +++++----- gdb/python/lib/gdb/command/backtrace.py | 2 +- gdb/python/lib/gdb/libstdcxx/v6/printers.py | 4 +- gdb/python/python-frame.c | 21 +++++++----- gdb/python/python-value.c | 41 +++++++++++++++++------ gdb/python/python.c | 20 ----------- gdb/testsuite/gdb.ada/lang_switch.exp | 2 + gdb/testsuite/gdb.ada/ref_param.exp | 2 + gdb/testsuite/gdb.base/call-ar-st.exp | 1 + gdb/testsuite/gdb.base/funcargs.exp | 2 + gdb/testsuite/gdb.python/find.exp | 10 +++--- gdb/testsuite/gdb.python/python-frame.exp | 2 +- gdb/testsuite/gdb.python/python-prettyprint.py | 4 +- gdb/testsuite/gdb.python/python-value.exp | 6 +++ 14 files changed, 75 insertions(+), 60 deletions(-) First 500 lines of diff: diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 083546b..c711d3d 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -18602,9 +18602,15 @@ bar = some_val['foo'] Again, @code{bar} will also be a @code{gdb.Value} object. -The following attribute is provided: +The following attributes are provided: @table @code +@defmethod Value address +If this object is addressable, this read-only attribute holds a +@code{gdb.Value} object representing the address. Otherwise, +this attribute holds @code{None}. +@end defmethod + @cindex optimized out value in Python @defmethod Value is_optimized_out This read-only boolean attribute is true if the compiler optimized out @@ -18615,12 +18621,6 @@ this value, thus it is not available for fetching from the inferior. The following methods are provided: @table @code -@defmethod Value address -If the @code{gdb.Value} object is addressable, this will return a new -@code{gdb.Value} object representing the address. Otherwise, this -will throw an exception. -@end defmethod - @defmethod Value cast type Cast the @code{gdb.Value} to the type represented by @var{type}, and return a new @code{gdb.Value}. @var{type} must be a @code{gdb.Type} @@ -19760,8 +19760,8 @@ Returns the frame's resume address. Returns the frame's code block. @c (@pxref{Block,,Code Blocks and Scopes}). @end defmethod -@defmethod Frame address_in_block -Returns an address which falls within the frame's code block. +@defmethod Frame function +Returns the symbol for the function corresponding to this frame. @c (@pxref{Symbols In Python}). @end defmethod @defmethod Frame older diff --git a/gdb/python/lib/gdb/command/backtrace.py b/gdb/python/lib/gdb/command/backtrace.py index f07696e..17b1c18 100644 --- a/gdb/python/lib/gdb/command/backtrace.py +++ b/gdb/python/lib/gdb/command/backtrace.py @@ -92,7 +92,7 @@ class FrameWrapper: stream.write (" 0x%08x in" % pc) stream.write (" " + name + " (") - func = gdb.find_pc_function (self.frame.addr_in_block ()) + func = self.frame.function () self.print_frame_args (stream, func) stream.write (")") diff --git a/gdb/python/lib/gdb/libstdcxx/v6/printers.py b/gdb/python/lib/gdb/libstdcxx/v6/printers.py index bcc5b28..58e7fa7 100644 --- a/gdb/python/lib/gdb/libstdcxx/v6/printers.py +++ b/gdb/python/lib/gdb/libstdcxx/v6/printers.py @@ -49,7 +49,7 @@ class StdListPrinter: def __init__(self, nodetype, head): self.nodetype = nodetype self.base = head['_M_next'] - self.head = head.address() + self.head = head.address self.count = 0 def __iter__(self): @@ -73,7 +73,7 @@ class StdListPrinter: return self._iterator(nodetype, self.val['_M_impl']['_M_node']) def to_string(self): - if self.val['_M_impl']['_M_node'].address() == self.val['_M_impl']['_M_node']['_M_next']: + if self.val['_M_impl']['_M_node'].address == self.val['_M_impl']['_M_node']['_M_next']: return 'empty std::list' return 'std::list' diff --git a/gdb/python/python-frame.c b/gdb/python/python-frame.c index 1fc553b..4b76709 100644 --- a/gdb/python/python-frame.c +++ b/gdb/python/python-frame.c @@ -253,13 +253,13 @@ frapy_block (PyObject *self, PyObject *args) } -/* Implementation of gdb.Frame.addr_in_block (self) -> Long. - Returns an address which falls within the frame's code block. */ +/* Implementation of gdb.Frame.function (self) -> gdb.Symbol. + Returns the symbol for the function corresponding to this frame. */ static PyObject * -frapy_addr_in_block (PyObject *self, PyObject *args) +frapy_function (PyObject *self, PyObject *args) { - CORE_ADDR pc = 0; /* Initialize to appease gcc warning. */ + struct symbol *sym = NULL; struct frame_info *frame; volatile struct gdb_exception except; @@ -267,11 +267,14 @@ frapy_addr_in_block (PyObject *self, PyObject *args) { FRAPY_REQUIRE_VALID ((frame_object *) self, frame); - pc = get_frame_address_in_block (frame); + sym = find_pc_function (get_frame_address_in_block (frame)); } GDB_PY_HANDLE_EXCEPTION (except); - return PyLong_FromUnsignedLongLong (pc); + if (sym) + return symbol_to_symbol_object (sym); + + Py_RETURN_NONE; } /* Convert a frame_info struct to a Python Frame object. @@ -634,9 +637,9 @@ Return the frame's resume address." }, { "block", frapy_block, METH_NOARGS, "block () -> gdb.Block.\n\ Return the frame's code block." }, - { "addr_in_block", frapy_addr_in_block, METH_NOARGS, - "addr_in_block () -> Long.\n\ -Return an address which falls within the frame's code block." }, + { "function", frapy_function, METH_NOARGS, + "function () -> gdb.Symbol.\n\ +Returns the symbol for the function corresponding to this frame." }, { "older", frapy_older, METH_NOARGS, "older () -> gdb.Frame.\n\ Return the frame immediately older (outer) to this frame." }, diff --git a/gdb/python/python-value.c b/gdb/python/python-value.c index 5d4f596..b55463c 100644 --- a/gdb/python/python-value.c +++ b/gdb/python/python-value.c @@ -62,7 +62,7 @@ struct value *values_in_python = NULL; typedef struct { PyObject_HEAD struct value *value; - int owned_by_gdb; + PyObject *address; } value_object; /* Called by the Python interpreter when deallocating a value object. */ @@ -73,8 +73,14 @@ valpy_dealloc (PyObject *obj) value_remove_from_list (&values_in_python, self->value); - if (!self->owned_by_gdb) - value_free (self->value); + value_free (self->value); + + if (self->address) + /* Use braces to appease gcc warning. *sigh* */ + { + Py_DECREF (self->address); + } + self->ob_type->tp_free (self); } @@ -108,7 +114,7 @@ valpy_new (PyTypeObject *subtype, PyObject *args, PyObject *keywords) } value_obj->value = value; - value_obj->owned_by_gdb = 0; + value_obj->address = NULL; release_value (value); value_prepend_to_list (&values_in_python, value); @@ -133,18 +139,30 @@ valpy_dereference (PyObject *self, PyObject *args) /* Return "&value". */ static PyObject * -valpy_address (PyObject *self, PyObject *args) +valpy_get_address (PyObject *self, void *closure) { struct value *res_val = NULL; /* Initialize to appease gcc warning. */ + value_object *val_obj = (value_object *) self; volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + if (!val_obj->address) { - res_val = value_addr (((value_object *) self)->value); + TRY_CATCH (except, RETURN_MASK_ALL) + { + res_val = value_addr (val_obj->value); + } + if (except.reason < 0) + { + val_obj->address = Py_None; + Py_INCREF (Py_None); + } + else + val_obj->address = value_to_value_object (res_val); } - GDB_PY_HANDLE_EXCEPTION (except); - return value_to_value_object (res_val); + Py_INCREF (val_obj->address); + + return val_obj->address; } /* Return type of the value. */ @@ -765,7 +783,7 @@ value_to_value_object (struct value *val) if (val_obj != NULL) { val_obj->value = val; - val_obj->owned_by_gdb = 0; + val_obj->address = NULL; release_value (val); value_prepend_to_list (&values_in_python, val); } @@ -926,6 +944,8 @@ gdbpy_initialize_values (void) static PyGetSetDef value_object_getset[] = { + { "address", valpy_get_address, NULL, "The address of the value.", + NULL }, { "is_optimized_out", valpy_get_is_optimized_out, NULL, "Boolean telling whether the value is optimized out (i.e., not available).", NULL }, @@ -933,7 +953,6 @@ static PyGetSetDef value_object_getset[] = { }; 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." }, { "dereference", valpy_dereference, METH_NOARGS, "Dereferences the value." }, { "type", valpy_type, METH_NOARGS, "Return type of the value." }, diff --git a/gdb/python/python.c b/gdb/python/python.c index 0bc25b1..f5c20d4 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -313,23 +313,6 @@ gdbpy_solib_address (PyObject *self, PyObject *args) return str_obj; } -static PyObject * -gdbpy_find_pc_function (PyObject *self, PyObject *args) -{ - unsigned long long pc; - struct symbol *sym; - PyObject *sym_obj; - - if (!PyArg_ParseTuple (args, "K", &pc)) - return NULL; - - sym = find_pc_function (pc); - if (sym) - return symbol_to_symbol_object (sym); - - Py_RETURN_NONE; -} - /* Adds GDB value V to the pattern buffer in *PATTERN_BUF. If SIZE is not zero, it specifies the number of bytes from V to copy to *PATTERN_BUF. The function increases the size of *PATTERN_BUF as necessary, adjusting @@ -1907,9 +1890,6 @@ a boolean indicating if name is a field of the current implied argument\n\ "solib_address (Long) -> String.\n\ Return the name of the shared library holding a given address, or None." }, - { "find_pc_function", gdbpy_find_pc_function, METH_VARARGS, - "Return the function containing the given pc value, or None." }, - { "block_for_pc", gdbpy_block_for_pc, METH_VARARGS, "Return the block containing the given pc value, or None." }, diff --git a/gdb/testsuite/gdb.ada/lang_switch.exp b/gdb/testsuite/gdb.ada/lang_switch.exp index 45a4e53..3fc3584 100644 --- a/gdb/testsuite/gdb.ada/lang_switch.exp +++ b/gdb/testsuite/gdb.ada/lang_switch.exp @@ -41,6 +41,8 @@ gdb_load ${binfile} set bp_location [gdb_get_line_number "STOP" ${testdir}/foo.c] runto "foo.c:$bp_location" +gdb_test "set print frame-arguments all" "" + # Make sure that the language is switched to Ada for the second frame # by checking the string parameter. gdb_test "bt" \ diff --git a/gdb/testsuite/gdb.ada/ref_param.exp b/gdb/testsuite/gdb.ada/ref_param.exp index 5325dd2..4d49296 100644 --- a/gdb/testsuite/gdb.ada/ref_param.exp +++ b/gdb/testsuite/gdb.ada/ref_param.exp @@ -39,6 +39,8 @@ if ![runto call_me] then { return } +gdb_test "set print frame-arguments all" "" + set expected_d "\\(one => 1, two => 2, three => 3, four => 4, five => 5, six => 6\\)" gdb_test "frame" \ "#0\[ \t\]*pck\\.call_me \\(d=${expected_d}\\).*" \ diff --git a/gdb/testsuite/gdb.base/call-ar-st.exp b/gdb/testsuite/gdb.base/call-ar-st.exp index b88ff02..a058f67 100644 --- a/gdb/testsuite/gdb.base/call-ar-st.exp +++ b/gdb/testsuite/gdb.base/call-ar-st.exp @@ -332,6 +332,7 @@ gdb_expect { gdb_test "break sum_array_print" \ ".*Breakpoint ${decimal}: file .*call-ar-st.c, line.*" \ "set breakpoint in sum_array_print" +gdb_test "set print frame-arguments all" "" gdb_test "continue" \ ".*Breakpoint ${decimal}, sum_array_print \\(seed=10, linked_list1=.next_index = .1, 2, 3, 4, 5, 6, 7, 8, 9, 10., values = .4, 6, 8, 10, 12, 14, 16, 18, 20, 22., head = 0., linked_list2=.next_index = .1, 2, 3, 4, 5, 6, 7, 8, 9, 10., values = .8, 10, 12, 14, 16, 18, 20, 22, 24, 26., head = 0., linked_list3=.next_index = .1, 2, 3, 4, 5, 6, 7, 8, 9, 10., values = .10, 12, 14, 16, 18, 20, 22, 24, 26, 28., head = 0., linked_list4=.next_index = .1, 2, 3, 4, 5, 6, 7, 8, 9, 10., values = .20, 22, 24, 26, 28, 30, 32, 34, 36, 38., head = 0.\\) at .*call-ar-st.c:1105\[ \t\n\r\]+1105.*printf\\(.Sum of 4 arrays, by element \\(add in seed as well\\).*\\);.*" \ "check args of sum_array_print" diff --git a/gdb/testsuite/gdb.base/funcargs.exp b/gdb/testsuite/gdb.base/funcargs.exp index 1cf3e9d..037f0a0 100644 --- a/gdb/testsuite/gdb.base/funcargs.exp +++ b/gdb/testsuite/gdb.base/funcargs.exp @@ -1194,6 +1194,8 @@ gdb_expect { # Perform tests +gdb_test "set print frame-arguments all" "" + integral_args funcargs_reload unsigned_integral_args diff --git a/gdb/testsuite/gdb.python/find.exp b/gdb/testsuite/gdb.python/find.exp index dd9aabc..d63ea84 100644 --- a/gdb/testsuite/gdb.python/find.exp +++ b/gdb/testsuite/gdb.python/find.exp @@ -91,7 +91,7 @@ set two_patterns_found "${newline}.${dec_number}L, ${dec_number}L]" gdb_test "set *(int32_t*) &int8_search_buf\[10\] = 0x61616161" "" "" gdb_test "py search_buf = gdb.selected_frame ().read_var ('int8_search_buf')" "" "" -gdb_test "py start_addr = search_buf.address ()" "" "" +gdb_test "py start_addr = search_buf.address" "" "" gdb_test "py length = search_buf.type ().sizeof ()" "" "" gdb_test "py print gdb.search_memory (start_addr, length, 'aaa')" \ @@ -129,7 +129,7 @@ gdb_test "py print gdb.search_memory (start_addr, length, \['a', 'a'\], max_coun gdb_test "set int16_search_buf\[10\] = 0x1234" "" "" gdb_test "py search_buf = gdb.selected_frame ().read_var ('int16_search_buf')" "" "" -gdb_test "py start_addr = search_buf.address ()" "" "" +gdb_test "py start_addr = search_buf.address" "" "" gdb_test "py length = search_buf.type ().sizeof ()" "" "" gdb_test "py pattern = gdb.parse_and_eval ('(int16_t) 0x1234')" "" "" @@ -143,7 +143,7 @@ gdb_test "py print gdb.search_memory (start_addr, length, pattern)" \ gdb_test "set int32_search_buf\[10\] = 0x12345678" "" "" gdb_test "py search_buf = gdb.selected_frame ().read_var ('int32_search_buf')" "" "" -gdb_test "py start_addr = search_buf.address ()" "" "" +gdb_test "py start_addr = search_buf.address" "" "" gdb_test "py length = search_buf.type ().sizeof ()" "" "" gdb_test "py pattern = gdb.parse_and_eval ('(int32_t) 0x12345678')" "" "" @@ -156,7 +156,7 @@ gdb_test "py print gdb.search_memory (start_addr, length, pattern)" \ gdb_test "set int64_search_buf\[10\] = 0xfedcba9876543210LL" "" "" gdb_test "py search_buf = gdb.selected_frame ().read_var ('int64_search_buf')" "" "" -gdb_test "py start_addr = search_buf.address ()" "" "" +gdb_test "py start_addr = search_buf.address" "" "" gdb_test "py length = search_buf.type ().sizeof ()" "" "" gdb_test "py pattern = gdb.parse_and_eval ('(int64_t) 0xfedcba9876543210LL')" "" "" @@ -171,7 +171,7 @@ gdb_test "set *(int8_t*) &search_buf\[10\] = 0x62" "" "" gdb_test "set *(int16_t*) &search_buf\[11\] = 0x6363" "" "" gdb_test "set *(int32_t*) &search_buf\[13\] = 0x64646464" "" "" gdb_test "py search_buf = gdb.selected_frame ().read_var ('search_buf')" "" "" -gdb_test "py start_addr = search_buf\[0\].address ()" "" "" +gdb_test "py start_addr = search_buf\[0\].address" "" "" gdb_test "py pattern1 = gdb.parse_and_eval ('(int8_t) 0x62')" "" "" gdb_test "py pattern2 = gdb.parse_and_eval ('(int16_t) 0x6363')" "" "" gdb_test "py pattern3 = gdb.parse_and_eval ('(int32_t) 0x64646464')" "" "" diff --git a/gdb/testsuite/gdb.python/python-frame.exp b/gdb/testsuite/gdb.python/python-frame.exp index 674c25e..93a3d21 100644 --- a/gdb/testsuite/gdb.python/python-frame.exp +++ b/gdb/testsuite/gdb.python/python-frame.exp @@ -78,7 +78,7 @@ gdb_test "python print 'result =', f0.type () == gdb.NORMAL_FRAME" " = True" "te gdb_test "python print 'result =', f0.unwind_stop_reason () == gdb.FRAME_UNWIND_NO_REASON" " = True" "test Frame.type" gdb_test "python print 'result =', gdb.frame_stop_reason_string (gdb.FRAME_UNWIND_INNER_ID)" " = previous frame inner to this frame \\(corrupt stack\\?\\)" "test gdb.frame_stop_reason_string" gdb_test "python print 'result =', f0.pc ()" " = \[0-9\]+" "test Frame.pc" -gdb_test "python print 'result =', f0.addr_in_block ()" " = \[0-9\]+" "test Frame.addr_in_block" +gdb_test "python print 'result =', f0.function ()" " = symbol for f2" "test Frame.function" gdb_test "python print 'result =', f0.older ().equals (f1)" " = True" "test Frame.older" gdb_test "python print 'result =', f1.newer ().equals (f0)" " = True" "test Frame.newer" gdb_test "python print 'result =', f0.read_var ('variable_which_surely_doesnt_exist')" \ diff --git a/gdb/testsuite/gdb.python/python-prettyprint.py b/gdb/testsuite/gdb.python/python-prettyprint.py index 0d9cb87..e032303 100644 --- a/gdb/testsuite/gdb.python/python-prettyprint.py +++ b/gdb/testsuite/gdb.python/python-prettyprint.py @@ -60,8 +60,8 @@ class pp_s: def to_string(self): a = self.val["a"] b = self.val["b"] - if a.address() != b: - raise Exception("&a(%s) != b(%s)" % (str(a.address()), str(b))) + if a.address != b: + raise Exception("&a(%s) != b(%s)" % (str(a.address), str(b))) return " a=<" + str(self.val["a"]) + "> b=<" + str(self.val["b"]) + ">" class pp_ss: diff --git a/gdb/testsuite/gdb.python/python-value.exp b/gdb/testsuite/gdb.python/python-value.exp index bd54b2f..6825f03 100644 --- a/gdb/testsuite/gdb.python/python-value.exp +++ b/gdb/testsuite/gdb.python/python-value.exp @@ -70,6 +70,9 @@ proc test_value_creation {} { gdb_py_test_silent_cmd "python a = gdb.Value (u'unicode test')" "create unicode value" 1 gdb_test "python print a" "\"unicode test\"" "print Unicode string" gdb_test "python print a.__class__" "" "verify type of unicode string" + + # Test address attribute is None in a non-addressable value + gdb_test "python print 'result =', i.address" "= None" "Test address attribute in non-addressable value" } proc test_value_numeric_ops {} { @@ -228,6 +231,9 @@ proc test_value_in_inferior {} { # Smoke-test is_optimized_out attribute gdb_test "python print 'result =', arg0.is_optimized_out" "= False" "Test is_optimized_out attribute" + + # Test address attribute + gdb_test "python print 'result =', arg0.address" "= 0x\[\[:xdigit:\]\]+" "Test address attribute" } proc test_value_after_death {} { hooks/post-receive -- Repository for Project Archer.