From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20979 invoked by alias); 16 Oct 2008 03:56:41 -0000 Mailing-List: contact archer-commits-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: Received: (qmail 20916 invoked by uid 9723); 16 Oct 2008 03:56:40 -0000 Date: Thu, 16 Oct 2008 03:56:00 -0000 Message-ID: <20081016035640.20899.qmail@sourceware.org> From: bauermann@sourceware.org To: archer-commits@sourceware.org Subject: [SCM] archer-bauermann-python-patches: gdb X-Git-Refname: refs/heads/archer-bauermann-python-patches X-Git-Reftype: branch X-Git-Oldrev: 83d0eb61b536657bc94733a021a0210dd712b534 X-Git-Newrev: 6269ec87240e9afcac220b6372f61836cdc3ff02 X-SW-Source: 2008-q4/txt/msg00004.txt.bz2 List-Id: The branch, archer-bauermann-python-patches has been updated discards 83d0eb61b536657bc94733a021a0210dd712b534 (commit) discards 15cbff8911750ac4e16df921a3bc6f9321b4fa06 (commit) discards 9d1c927d4e89c43cc349e7c5302953dcd278b443 (commit) discards dda8d658696a3c78e8464edcd9cf5a68b432ff97 (commit) discards 5bfaec17e39a9e631a6d2a60a595c55fe989804b (commit) discards d4d50ac1b38d6c76f42d8ca99bee498d63e573b9 (commit) discards f1234c817437aa38b0ce637998b0e0d8710722cf (commit) discards 4d8bc5ae9103b46d89dbf56865a7566b26a4b929 (commit) discards d4895ded0acdb700e5ae3d2d699ed98ce46bc8ea (commit) discards a3123a8e1f2851106c73aba5bc85680ebba3619f (commit) discards 1d09b87190c0537e36c63824afcc5fa94df67f2c (commit) discards 8fa31caa2156e7eb2ffb4b9ae0204b4f0a655104 (commit) discards 59139bcb7593a02c0221f2bec8ae2f9430e80994 (commit) discards 874448321f3f2acff6edb0a6d2b35e178237a3b8 (commit) discards b1e67b395a388bb4b28aff17908dcee0bdec311b (commit) discards 473a90e44cf72a4d3250b5adec871a3814ccc13f (commit) discards 1fd6d18362668d7949894def09c854e501d5622b (commit) discards a5c1364aa2611d55f492384aee44b0e92d39f5cc (commit) discards 0f350d79eb71696f276c97b681bfb330925815a7 (commit) via 6269ec87240e9afcac220b6372f61836cdc3ff02 (commit) via ad76d5184f5a976f66db99d62a20512b696dafe1 (commit) via 39be93153d22b79f7a470b0d433295b22deba16f (commit) via 3f0cc9d65edae1604c1d6512d37afe7001c13996 (commit) via 088d96d60d04a70da4374e3712ef2cee476b55ad (commit) via af912e7ea14a1bf748b41d6526df444a1ae53473 (commit) via 64aa3a2ed1bd09a670cd3d6991d6e914b6f9b337 (commit) via 6be292baa84b7da96e59203c1f84f353242c56e2 (commit) via b4e534a09f11ac1410f1439b3e3e5c77b1917a0e (commit) via d4a3947fc1df2f122b4ce6760102fc7826db70c9 (commit) via e0add0bcedfb32911881ee8ade64f4f722f2ae41 (commit) via 3836c5ab21411695939a26a2bb3b23e6dca92a23 (commit) via 4e2c2b9d46335715b85d5aa4b441ff5b539ac6e8 (commit) via 00220d62f5c04ffeda6af90e753a0a93de060ca4 (commit) via 78007a7ca8a0d110603a4d6829114fa987bd89a6 (commit) via 0c8b691676ed2c293ce225459772c67ba318da9c (commit) via 1b769c3c3a07fed7c18699b6c782b9ac6e72d228 (commit) via d3985fcb4a769f6db4714abc692ccc5193768a7d (commit) via dfd2c2bca27df46376ac0ab67fa67c912df2c618 (commit) from 83d0eb61b536657bc94733a021a0210dd712b534 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 6269ec87240e9afcac220b6372f61836cdc3ff02 Author: Tom Tromey Date: Sun Oct 12 13:32:45 2008 -0600 gdb * python/python.c (gdbpy_parameter_value): Rename. No longer static. Change arguments. (_initialize_python): Call gdbpy_initialize_parameters. (get_parameter): Change 'variable' to 'parameter'. * python/python-param.c: New file. * Makefile.in (SUBDIR_PYTHON_OBS): Add python-param.o. (SUBDIR_PYTHON_SRCS): Add python-param.c. (python-param.o): New target. * python/python-internal.h (gdbpy_parse_command_name): Declare. (gdbpy_initialize_parameters): Declare. * python/python-cmd.c (gdbpy_parse_command_name): Rename. Add 'start_list' argument. No longer static. (cmdpy_init): Update. gdb/doc * gdb.texinfo (Parameters In Python): New node. (Python API): Update. commit ad76d5184f5a976f66db99d62a20512b696dafe1 Author: Tom Tromey Date: Fri Oct 10 17:31:51 2008 -0600 * varobj.c (install_visualizer): New function. (install_default_visualizer): Use it. (varobj_set_visualizer): New function. * varobj.h (varobj_set_visualizer): Restore. * python/python.c (gdbpy_get_default_visualizer): New function. (GdbMethods) : New entry. * mi/mi-cmds.h (mi_cmd_var_set_visualizer): Restore. * mi/mi-cmds.c (mi_cmds) : Restore. * mi/mi-cmd-var.c (mi_cmd_var_set_visualizer): Restore. * varobj.c (value_get_print_value): Handle replacement value return. Don't pretty-print if printer fails or returns replacement. * python/python-internal.h (apply_varobj_pretty_printer): Update. * python/python.c (apply_varobj_pretty_printer): Add 'replacement' argument. Don't print replacement value. * valprint.h (raw_printing): Declare. * valprint.c (raw_printing): No longer static. * varobj.c (update_dynamic_varobj_children): Set num_children on varobj. (varobj_get_num_children): Move later. Call update_dynamic_varobj_children. commit 39be93153d22b79f7a470b0d433295b22deba16f Author: Tom Tromey Date: Thu Oct 9 16:23:21 2008 -0600 * python/python.c (_initialize_python): Define _format_children. (pretty_print_one_value): Add 'children' argument. Call _format_children. (apply_pretty_printer): Update. (apply_val_pretty_printer): Update. (apply_varobj_pretty_printer): Update. commit 3f0cc9d65edae1604c1d6512d37afe7001c13996 Author: Tom Tromey Date: Thu Oct 9 15:15:45 2008 -0600 gdb * mi/mi-cmds.c (mi_cmds) : Remove. : Remove. : Remove. * mi/mi-cmds.h (mi_cmd_var_set_visualizer): Remove. (mi_cmd_var_clear_type_visualizers): Remove. (mi_cmd_var_set_visualizer): Remove. * mi/mi-cmd-var.c (mi_cmd_var_set_visualizer): Remove. (mi_cmd_var_clear_type_visualizers): Remove. (mi_cmd_var_set_type_visualizer): Remove. * varobj.h (varobj_clear_type_visualizers, varobj_set_type_visualizer, varobj_set_visualizer): Remove. * varobj.c (value_get_print_value): Use apply_varobj_pretty_printer. (varobj_clear_type_visualizers): Remove. (type_visualizer): Remove. (type_visualizers): Remove. (varobj_set_type_visualizer): Remove. (install_default_visualizer): Rewrote. (varobj_set_visualizer): Remove. * python/python-internal.h (apply_varobj_pretty_printer): Declare. (gdbpy_children_cst, gdbpy_to_string_cst): Declare. * python/python.c (gdbpy_to_static_cst, gdbpy_children_cst): commit 088d96d60d04a70da4374e3712ef2cee476b55ad Author: Thiago Jung Bauermann Date: Mon Oct 13 22:43:44 2008 -0200 Value conversion additions and fixes. commit af912e7ea14a1bf748b41d6526df444a1ae53473 Author: Tom Tromey Date: Thu Sep 25 12:56:13 2008 -0600 initial Type support commit 64aa3a2ed1bd09a670cd3d6991d6e914b6f9b337 Author: Tom Tromey Date: Tue Sep 23 12:11:40 2008 -0600 initial pretty-printing support and add extra argument to value_print add /r format commit 6be292baa84b7da96e59203c1f84f353242c56e2 Author: Tom Tromey Date: Sat Sep 13 16:27:40 2008 -0600 add auto-loading based on objfile name commit b4e534a09f11ac1410f1439b3e3e5c77b1917a0e Author: Tom Tromey Date: Fri Aug 1 08:57:27 2008 -0600 initial python script support commit d4a3947fc1df2f122b4ce6760102fc7826db70c9 Author: Thiago Jung Bauermann Date: Tue Jul 15 03:43:38 2008 -0300 Implement Python-based computation of varobj children. * mi/mi-cmd-var.c (mi_cmd_var_set_type_visualizer) (mi_cmd_var_clear_type_visualizers, mi_cmd_var_set_visualizer): New. (varobj_update_one): List children, if they have changed. * mi-cmds.c (mi_cmds): Register var-set-type-visualizer, var-clear-type-visualizers and var-set-visualizer. * mi-cmds.h (mi_cmd_var_set_type_visualizer) (mi_cmd_var_clear_type_visualizers, mi_cmd_var_set_visualizer): New. * python/python-internal.h (make_cleanup_py_decref): Declare. * python/python.c (py_decref, make_cleanup_py_decref): New. * varobj.c (struct varobj): New fields children_requested, value_formatter and children_lister. (struct type_visualizer): New. (create_child_with_value, install_default_visualizer): New. (value_get_print_value): New parameter value_formatter. (varobj_add_child): New. (type_visualizers): New variable. (varobj_create): Call install_default_visualizer (varobj_set_display_format): Adjust call to value_get_print_value. (varobj_set_visualizer, varobj_set_type_visualizer) (varobj_clear_type_visualizers, update_dynamic_varobj_children) (varobj_list_children): Set children_requested. Call update_dynamic_varobj_children if necessary. Call install_default_visualizer on children. (install_new_value): Always fetch dynamic varobjs. (varobj_update): Rework not to try to get value of children for which Python code has already computed the value. (create_child): Use create_child_with_value. (new_variable): Zero new fields. (free_variable): Free Python objects. (value_get_print_value): Call Python visualizer, is necessary. (c_value_of_variable): Directly return Python-produced string value. * varobj.h (struct varobj_update_result_t): New field value_installed. (varobj_set_type_visualizer, varobj_clear_type_visualizers) (varobj_set_visualizer): New. * Makefile.in: Update dependencies. commit e0add0bcedfb32911881ee8ade64f4f722f2ae41 Author: Thiago Jung Bauermann Date: Mon Apr 28 16:28:10 2008 -0300 Expose threads to Python. commit 3836c5ab21411695939a26a2bb3b23e6dca92a23 Author: Thiago Jung Bauermann Date: Mon Apr 28 14:50:41 2008 -0300 Expose symtab to Python. commit 4e2c2b9d46335715b85d5aa4b441ff5b539ac6e8 Author: Thiago Jung Bauermann Date: Sun Jun 8 18:38:30 2008 -0300 Expose block and symbol to Python. commit 00220d62f5c04ffeda6af90e753a0a93de060ca4 Author: Thiago Jung Bauermann Date: Mon Apr 28 13:28:48 2008 -0300 Expose frames to Python. commit 78007a7ca8a0d110603a4d6829114fa987bd89a6 Author: Thiago Jung Bauermann Date: Mon Apr 28 05:33:07 2008 -0300 Add mechanism to define commands in Python. commit 0c8b691676ed2c293ce225459772c67ba318da9c Author: Thiago Jung Bauermann Date: Mon Apr 28 05:16:05 2008 -0300 Expose breakpoints to Python. commit 1b769c3c3a07fed7c18699b6c782b9ac6e72d228 Author: Thiago Jung Bauermann Date: Mon Jun 9 01:13:18 2008 -0300 Implement Python function objects. commit d3985fcb4a769f6db4714abc692ccc5193768a7d Author: Thiago Jung Bauermann Date: Mon Apr 28 05:05:34 2008 -0300 Export hooks to Python. commit dfd2c2bca27df46376ac0ab67fa67c912df2c618 Author: Thiago Jung Bauermann Date: Tue Jul 15 03:36:41 2008 -0300 Export values to Python. ----------------------------------------------------------------------- Summary of changes: gdb/doc/gdb.texinfo | 2 +- gdb/python/python-value.c | 89 +++++++++-------------------- gdb/testsuite/gdb.python/python-value.exp | 8 +- 3 files changed, 33 insertions(+), 66 deletions(-) First 500 lines of diff: diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index f881b0a..d01f4e7 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -17815,7 +17815,7 @@ for its internal bookkeeping of the inferior's values, and for fetching values when necessary. Inferior values that are simple scalars can be used directly in -Python expressions that are valid for the value's data type Here's +Python expressions that are valid for the value's data type. Here's an example for an integer or floating-point value @code{some_val}: @smallexample diff --git a/gdb/python/python-value.c b/gdb/python/python-value.c index 02c3fec..e78a4b6 100644 --- a/gdb/python/python-value.c +++ b/gdb/python/python-value.c @@ -369,113 +369,80 @@ enum valpy_opcode #define STRIP_REFERENCE(TYPE) \ ((TYPE_CODE (TYPE) == TYPE_CODE_REF) ? (TYPE_TARGET_TYPE (TYPE)) : (TYPE)) -/* Returns a value object which is the sum of this value with the given - integer argument. */ +/* Returns a value object which is the result of applying the operation + specified by OPCODE to the given arguments. */ static PyObject * valpy_binop (enum valpy_opcode opcode, PyObject *self, PyObject *other) { - long l; - double d; struct value *res_val = NULL; /* Initialize to appease gcc warning. */ - struct value *other_val; - value_object *self_value; volatile struct gdb_exception except; - /* If the gdb.Value object is the second operand, then it will be passed - to us as the OTHER argument, and SELF will be an entirely different - kind of object, altogether. Swap them to avoid surprises. */ - if (!PyObject_TypeCheck (self, &value_object_type)) - { - PyObject *tmp; - - tmp = self; - self = other; - other = tmp; - } - - self_value = (value_object *) self; - - if (PyObject_TypeCheck (other, &value_object_type)) - other_val = ((value_object *) other)->value; - else if (PyInt_Check (other)) - { - l = PyInt_AsLong (other); - if (PyErr_Occurred ()) - return Py_NotImplemented; - - other_val = value_from_longest (builtin_type_pyint, l); - } - else if (PyFloat_Check (other)) + TRY_CATCH (except, RETURN_MASK_ALL) { - d = PyFloat_AsDouble (other); - if (PyErr_Occurred ()) - return Py_NotImplemented; + struct value *arg1, *arg2; - other_val = value_from_double (builtin_type_pyfloat, d); - } - else - /* If the types cannot be added, Python documentation says to return - NotImplemented (http://docs.python.org/ref/numeric-types.html). */ - return Py_NotImplemented; + /* If the gdb.Value object is the second operand, then it will be passed + to us as the OTHER argument, and SELF will be an entirely different + kind of object, altogether. Because of this, we can't assume self is + a gdb.Value object and need to convert it from python as well. */ + arg1 = convert_value_from_python (self); + arg2 = convert_value_from_python (other); - TRY_CATCH (except, RETURN_MASK_ALL) - { switch (opcode) { case VALPY_ADD: { - struct type *ltype = value_type (self_value->value); - struct type *rtype = value_type (other_val); + struct type *ltype = value_type (arg1); + struct type *rtype = value_type (arg2); + CHECK_TYPEDEF (ltype); ltype = STRIP_REFERENCE (ltype); CHECK_TYPEDEF (rtype); rtype = STRIP_REFERENCE (rtype); if (TYPE_CODE (ltype) == TYPE_CODE_PTR) - res_val = value_ptradd (self_value->value, other_val); + res_val = value_ptradd (arg1, arg2); else if (TYPE_CODE (rtype) == TYPE_CODE_PTR) - res_val = value_ptradd (other_val, self_value->value); + res_val = value_ptradd (arg2, arg1); else - res_val = value_binop (self_value->value, other_val, BINOP_ADD); + res_val = value_binop (arg1, arg2, BINOP_ADD); } break; case VALPY_SUB: { - struct type *ltype = value_type (self_value->value); - struct type *rtype = value_type (other_val); + struct type *ltype = value_type (arg1); + struct type *rtype = value_type (arg2); + CHECK_TYPEDEF (ltype); ltype = STRIP_REFERENCE (ltype); CHECK_TYPEDEF (rtype); rtype = STRIP_REFERENCE (rtype); + if (TYPE_CODE (ltype) == TYPE_CODE_PTR) { if (TYPE_CODE (rtype) == TYPE_CODE_PTR) - { /* A ptrdiff_t for the target would be preferable here. */ - res_val - = value_from_longest (builtin_type_pyint, - value_ptrdiff (self_value->value, - other_val)); - } + res_val = value_from_longest (builtin_type_pyint, + value_ptrdiff (arg1, arg2)); else - res_val = value_ptrsub (self_value->value, other_val); + res_val = value_ptrsub (arg1, arg2); } else - res_val = value_binop (self_value->value, other_val, BINOP_SUB); + res_val = value_binop (arg1, arg2, BINOP_SUB); } break; case VALPY_MUL: - res_val = value_binop (self_value->value, other_val, BINOP_MUL); + res_val = value_binop (arg1, arg2, BINOP_MUL); break; case VALPY_DIV: - res_val = value_binop (self_value->value, other_val, BINOP_DIV); + res_val = value_binop (arg1, arg2, BINOP_DIV); break; case VALPY_REM: - res_val = value_binop (self_value->value, other_val, BINOP_REM); + res_val = value_binop (arg1, arg2, BINOP_REM); break; case VALPY_POW: - res_val = value_binop (self_value->value, other_val, BINOP_EXP); + res_val = value_binop (arg1, arg2, BINOP_EXP); break; } } diff --git a/gdb/testsuite/gdb.python/python-value.exp b/gdb/testsuite/gdb.python/python-value.exp index b723b9d..7515ab7 100644 --- a/gdb/testsuite/gdb.python/python-value.exp +++ b/gdb/testsuite/gdb.python/python-value.exp @@ -104,11 +104,11 @@ proc test_value_numeric_ops {} { # Test gdb.Value mixed with Python types. - gdb_test "python print 'result = ' + str(i+1)" " = 6" "add integer value with python integer" - gdb_test "python print (i+1).__class__" "" "verify type of mixed integer add result" + gdb_test "python print 'result = ' + str(i-1)" " = 4" "subtract integer value from python integer" + gdb_test "python print (i-1).__class__" "" "verify type of mixed integer subtraction result" gdb_test "python print 'result = ' + str(f+1.5)" " = 2.75" "add double value with python float" - gdb_test "python print 'result = ' + str(1+i)" " = 6" "add python integer with integer value" + gdb_test "python print 'result = ' + str(1-i)" " = -4" "subtract python integer from integer value" gdb_test "python print 'result = ' + str(1.5+f)" " = 2.75" "add python float with double value" # Test pointer arithmethic @@ -126,7 +126,7 @@ proc test_value_numeric_ops {} { # Test some invalid operations. gdb_test_multiple "python print 'result = ' + str(i+'foo')" "catch error in python type conversion" { - -re "unsupported operand type.*$gdb_prompt $" {pass "catch error in python type conversion"} + -re "Argument to arithmetic operation not a number or boolean.*$gdb_prompt $" {pass "catch error in python type conversion"} -re "result = .*$gdb_prompt $" {fail "catch error in python type conversion"} -re "$gdb_prompt $" {fail "catch error in python type conversion"} } hooks/post-receive -- Repository for Project Archer.