From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25534 invoked by alias); 2 Mar 2009 20:46:16 -0000 Mailing-List: contact archer-commits-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: Received: (qmail 25452 invoked by uid 9674); 2 Mar 2009 20:46:15 -0000 Date: Mon, 02 Mar 2009 20:46:00 -0000 Message-ID: <20090302204615.25405.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: 49f350efd1b7ea38798e77eb8951440160fd7c81 X-Git-Newrev: 2fac9534dc2dc85f7c999b94574cf0acf1767dd6 X-SW-Source: 2009-q1/txt/msg00233.txt.bz2 List-Id: The branch, archer-jankratochvil-python has been updated via 2fac9534dc2dc85f7c999b94574cf0acf1767dd6 (commit) via d1078c2fa27154160e390b04f9c89a41103d80ed (commit) via 1453f41cc1b2703b905f769de4b48a4db44a21d2 (commit) from 49f350efd1b7ea38798e77eb8951440160fd7c81 (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 | 20 ++++++++++++++++++-- gdb/python/python-frame.c | 24 ++++++++++++++++++------ gdb/testsuite/gdb.python/python-frame.exp | 9 +++++++++ 3 files changed, 45 insertions(+), 8 deletions(-) First 500 lines of diff: diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index be22f07..8e259f8 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -18350,6 +18350,11 @@ which is typically four bytes. @var{max_count} is the highest number of matches to search for. @end defun +@findex gdb.solib_address +@defun solib_address @var{address} +Return the name of the shared library holding the given address, or None. +@end defun + @node Exception Handling @subsubsection Exception Handling @cindex python exceptions @@ -19559,10 +19564,20 @@ Returns the type of the frame. The value can be one of or @code{gdb.SENTINEL_FRAME}. @end defmethod +@defmethod Frame unwind_stop_reason +Return an integer representing the reason why it's not possible to find +frames older than this. Use @code{gdb.frame_stop_reason_string} to convert +the value returned by this function to a string. +@end defmethod + @defmethod Frame pc Returns the frame's resume address. @end defmethod +@defmethod Frame block +Returns the frame's code block. @c (see @xref{Block,,Code Blocks and Scopes}). +@end defmethod + @defmethod Frame address_in_block Returns an address which falls within the frame's code block. @end defmethod @@ -19579,8 +19594,9 @@ Return the frame immediately newer (inner) to this frame. Return the frame's symtab and line object. @c (see @xref{Symtab_and_line,, Symtab and line}). @end defmethod -@defmethod Frame read_var_value @var{symbol} -Return the value of the variable corresponding to the given symbol in this frame. +@defmethod Frame read_var_value @var{variable} +Return the value of the given variable in this frame. @code{variable} can be +either a string or a @code{gdb.Symbol} object. @c (@pxref{Symbols In Python}). @end defmethod @end table diff --git a/gdb/python/python-frame.c b/gdb/python/python-frame.c index 1f152b8..7305199 100644 --- a/gdb/python/python-frame.c +++ b/gdb/python/python-frame.c @@ -413,20 +413,32 @@ frapy_read_var_value (PyObject *self, PyObject *args) else if (gdbpy_is_string (sym_obj)) { char *var_name; - struct block *block; + struct block *block = NULL; + struct cleanup *cleanup; volatile struct gdb_exception except; + var_name = python_string_to_target_string (sym_obj); + cleanup = make_cleanup (xfree, var_name); + TRY_CATCH (except, RETURN_MASK_ALL) { - struct block *block; - FRAPY_REQUIRE_VALID ((frame_object *) self, frame); block = block_for_pc (get_frame_address_in_block (frame)); - var = lookup_symbol (python_string_to_target_string (sym_obj), block, - VAR_DOMAIN, NULL); + var = lookup_symbol (var_name, block, VAR_DOMAIN, NULL); } GDB_PY_HANDLE_EXCEPTION (except); + + if (!var) + { + PyErr_Format (PyExc_ValueError, + _("variable '%s' not found"), var_name); + do_cleanups (cleanup); + + return NULL; + } + + do_cleanups (cleanup); } else { @@ -573,7 +585,7 @@ gdbpy_initialize_frames (void) if (PyType_Ready (&frame_object_type) < 0) return; - /* FIXME: These would probably be best exposed as class attributes of Frame, + /* Note: These would probably be best exposed as class attributes of Frame, but I don't know how to do it except by messing with the type's dictionary. That seems too messy. */ PyModule_AddIntConstant (gdb_module, "NORMAL_FRAME", NORMAL_FRAME); diff --git a/gdb/testsuite/gdb.python/python-frame.exp b/gdb/testsuite/gdb.python/python-frame.exp index cfa2226..f62f63d 100644 --- a/gdb/testsuite/gdb.python/python-frame.exp +++ b/gdb/testsuite/gdb.python/python-frame.exp @@ -63,6 +63,7 @@ if ![runto_main] then { gdb_breakpoint "f2" gdb_continue_to_breakpoint "breakpoint at f2" +gdb_test "up" "" "" gdb_py_test_silent_cmd "python frames = gdb.frames ()" "get frames list" 1 gdb_test "python print frames" "\\(, , \\)" "verify frames list" @@ -75,9 +76,17 @@ gdb_test "python print 'result =', f0.is_valid ()" " = True" "test Frame.is_vali gdb_test "python print 'result =', f0.name ()" " = f2" "test Frame.name" gdb_test "python print 'result =', f0.type () == gdb.NORMAL_FRAME" " = True" "test Frame.type" 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.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_value ('b')" \ + "ValueError: variable 'b' not found.*Error while executing Python code." \ + "test Frame.read_var_value - error" +gdb_test "python print 'result =', f0.read_var_value ('a')" " = 1" "test Frame.read_var_value - success" + +gdb_test "python print 'result =', gdb.newest_frame ().equals (f0)" " = True" "test gdb.newest_frame" +gdb_test "python print 'result =', gdb.selected_frame ().equals (f1)" " = True" "test gdb.selected_frame" gdb_test "python print 'result =', f0.block ()" "" "test Frame.block" hooks/post-receive -- Repository for Project Archer.