diff options
author | Phil Muldoon <pmuldoon@redhat.com> | 2010-04-29 15:45:57 +0000 |
---|---|---|
committer | Phil Muldoon <pmuldoon@redhat.com> | 2010-04-29 15:45:57 +0000 |
commit | d7b32ed3aba175979887a8e870c27a6a7aa687ec (patch) | |
tree | 3f5880c7f84b784ae395fe840d88ab9634b860d2 /gdb/python/python.c | |
parent | ce72ce41398df29a9e884768ed5bcf6bcbc20b2b (diff) | |
download | gdb-d7b32ed3aba175979887a8e870c27a6a7aa687ec.zip gdb-d7b32ed3aba175979887a8e870c27a6a7aa687ec.tar.gz gdb-d7b32ed3aba175979887a8e870c27a6a7aa687ec.tar.bz2 |
2010-04-29 Phil Muldoon <pmuldoon@redhat.com>
Tom Tromey <tromey@redhat.com>
Thiago Jung Bauermann <bauerman@br.ibm.com>
* Makefile.in (SUBDIR_PYTHON_OBS): Add py-parameter.
(SUBDIR_PYTHON_SRCS): Likewise.
(py-parameter.o): New rule.
* python/py-parameter.c: New file.
* python/python-internal.h (gdbpy_initialize_parameter)
(gdbpy_parameter, gdbpy_parameter_value)
(gdbpy_parse_command_name): Declare.
* python/py-cmd.c (parse_command_name): Rename to
gdbpy_parse_command_name.
(gdbpy_parse_command_name): Accept a starting list parameter and
use over cmdlist.
(cmdpy_init): Use gdbpy_parse_command_name.
* python/python.c (parameter_to_python): Rename to
gdbpy_parameter_to_python. Accept enum var_types and value.
(gdbpy_parameter): Use gdbpy_parameter_value.
(_initialize_python): Call gdbpy_initialize_parameters.
2010-04-29 Phil Muldoon <pmuldoon@redhat.com>
* gdb.python/py-param.exp: New File.
2010-04-29 Phil Muldoon <pmuldoon@redhat.com>
Tom Tromey <tromey@redhat.com>
Thiago Jung Bauermann <bauerman@br.ibm.com>
* gdb.texinfo (Parameters In Python): New Node.
Diffstat (limited to 'gdb/python/python.c')
-rw-r--r-- | gdb/python/python.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/gdb/python/python.c b/gdb/python/python.c index a1c1d8c..cf87b66 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -192,11 +192,10 @@ python_command (char *arg, int from_tty) /* Transform a gdb parameters's value into a Python value. May return NULL (and set a Python exception) on error. Helper function for get_parameter. */ - -static PyObject * -parameter_to_python (struct cmd_list_element *cmd) +PyObject * +gdbpy_parameter_value (enum var_types type, void *var) { - switch (cmd->var_type) + switch (type) { case var_string: case var_string_noescape: @@ -204,7 +203,7 @@ parameter_to_python (struct cmd_list_element *cmd) case var_filename: case var_enum: { - char *str = * (char **) cmd->var; + char *str = * (char **) var; if (! str) str = ""; return PyString_Decode (str, strlen (str), host_charset (), NULL); @@ -212,7 +211,7 @@ parameter_to_python (struct cmd_list_element *cmd) case var_boolean: { - if (* (int *) cmd->var) + if (* (int *) var) Py_RETURN_TRUE; else Py_RETURN_FALSE; @@ -220,7 +219,7 @@ parameter_to_python (struct cmd_list_element *cmd) case var_auto_boolean: { - enum auto_boolean ab = * (enum auto_boolean *) cmd->var; + enum auto_boolean ab = * (enum auto_boolean *) var; if (ab == AUTO_BOOLEAN_TRUE) Py_RETURN_TRUE; else if (ab == AUTO_BOOLEAN_FALSE) @@ -230,15 +229,15 @@ parameter_to_python (struct cmd_list_element *cmd) } case var_integer: - if ((* (int *) cmd->var) == INT_MAX) + if ((* (int *) var) == INT_MAX) Py_RETURN_NONE; /* Fall through. */ case var_zinteger: - return PyLong_FromLong (* (int *) cmd->var); + return PyLong_FromLong (* (int *) var); case var_uinteger: { - unsigned int val = * (unsigned int *) cmd->var; + unsigned int val = * (unsigned int *) var; if (val == UINT_MAX) Py_RETURN_NONE; return PyLong_FromUnsignedLong (val); @@ -252,7 +251,7 @@ parameter_to_python (struct cmd_list_element *cmd) /* A Python function which returns a gdb parameter's value as a Python value. */ -static PyObject * +PyObject * gdbpy_parameter (PyObject *self, PyObject *args) { struct cmd_list_element *alias, *prefix, *cmd; @@ -278,7 +277,7 @@ gdbpy_parameter (PyObject *self, PyObject *args) if (! cmd->var) return PyErr_Format (PyExc_RuntimeError, _("`%s' is not a parameter."), arg); - return parameter_to_python (cmd); + return gdbpy_parameter_value (cmd->var_type, cmd->var); } /* Wrapper for target_charset. */ @@ -645,6 +644,7 @@ Enables or disables printing of Python stack traces."), gdbpy_initialize_symtabs (); gdbpy_initialize_blocks (); gdbpy_initialize_functions (); + gdbpy_initialize_parameters (); gdbpy_initialize_types (); gdbpy_initialize_pspace (); gdbpy_initialize_objfile (); |