From bc3b79fd1ac12e5432ef017d81064427d04a2d71 Mon Sep 17 00:00:00 2001 From: Thiago Jung Bauermann Date: Sat, 21 Mar 2009 03:03:56 +0000 Subject: gdb/ 2009-03-05 Tom Tromey Add support for convenience functions in Python. * Makefile.in (SUBDIR_PYTHON_OBS): Add python-function.o. (SUBDIR_PYTHON_SRCS): Add python-function.c. (python-function.o): New target. * eval.c: Include "python/python.h" and . (evaluate_subexp_standard): Handle values of type TYPE_CODE_INTERNAL_FUNCTION. * gdbtypes.h (type_code): Add TYPE_CODE_INTERNAL_FUNCTION. * parse.c (write_exp_string): Remove duplicate word in comment. * python/python-function.c: New file. * python/python-internal.h (gdbpy_initialize_functions): Add prototype. * python/python.c (_initialize_python): Call gdbpy_initialize_functions. * valprint.c (value_check_printable): Handle values of type TYPE_CODE_INTERNAL_FUNCTION. * value.c: Include "cli/cli-decode.h". (internal_function): New struct. (functionlist, internal_fn_type): New static variables. (lookup_only_internalvar, lookup_internalvar): Add const qualifier to name argument. (create_internalvar): Likewise. Initialize new field. (set_internal_var): Fix typo in comment. Don't allow assignment to canonical variable. (value_create_internal_function, value_internal_function_name, call_internal_function, function_command, function_destroyer, add_internal_function): New functions. (_initialize_values): Create `function' placeholder command. Initialize internal_fn_type. * value.h (lookup_only_internalvar, create_internalvar, lookup_internalvar): Add const qualifier to name argument. (internal_function_fn, add_internal_function, call_internal_function, value_internal_function_name): Add prototypes. (struct internalvar) : New field. gdb/doc/ 2008-03-05 Tom Tromey * gdb.texinfo (Convenience Vars): Document convenience functions. (Functions In Python): New node. (Python API): Update. gdb/testsuite/ 2009-03-05 Thiago Jung Bauermann * gdb.python/python-function.exp: New file. --- gdb/eval.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gdb/eval.c') diff --git a/gdb/eval.c b/gdb/eval.c index cc92ebe..8dda837 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -40,9 +40,12 @@ #include "regcache.h" #include "user-regs.h" #include "valprint.h" +#include "python/python.h" #include "gdb_assert.h" +#include + /* This is defined in valops.c */ extern int overload_resolution; @@ -1512,6 +1515,9 @@ evaluate_subexp_standard (struct type *expect_type, else error (_("Expression of type other than \"Function returning ...\" used as function")); } + if (TYPE_CODE (value_type (argvec[0])) == TYPE_CODE_INTERNAL_FUNCTION) + return call_internal_function (argvec[0], nargs, argvec + 1); + return call_function_by_hand (argvec[0], nargs, argvec + 1); /* pai: FIXME save value from call_function_by_hand, then adjust pc by adjust_fn_pc if +ve */ -- cgit v1.1