2014-05-20 15:53:04 +02:00
|
|
|
/* Support for debug methods in Python.
|
|
|
|
|
2017-01-01 07:50:51 +01:00
|
|
|
Copyright (C) 2013-2017 Free Software Foundation, Inc.
|
2014-05-20 15:53:04 +02:00
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
#include "arch-utils.h"
|
|
|
|
#include "extension-priv.h"
|
|
|
|
#include "objfiles.h"
|
|
|
|
#include "value.h"
|
|
|
|
#include "language.h"
|
|
|
|
|
|
|
|
#include "python.h"
|
|
|
|
#include "python-internal.h"
|
2016-11-08 23:34:55 +01:00
|
|
|
#include "py-ref.h"
|
2014-05-20 15:53:04 +02:00
|
|
|
|
|
|
|
static const char enabled_field_name[] = "enabled";
|
|
|
|
static const char match_method_name[] = "match";
|
|
|
|
static const char get_arg_types_method_name[] = "get_arg_types";
|
2015-04-29 22:24:21 +02:00
|
|
|
static const char get_result_type_method_name[] = "get_result_type";
|
2014-05-20 15:53:04 +02:00
|
|
|
static const char matchers_attr_str[] = "xmethods";
|
|
|
|
|
|
|
|
static PyObject *py_match_method_name = NULL;
|
|
|
|
static PyObject *py_get_arg_types_method_name = NULL;
|
|
|
|
|
|
|
|
struct gdbpy_worker_data
|
|
|
|
{
|
|
|
|
PyObject *worker;
|
|
|
|
PyObject *this_type;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct xmethod_worker *new_python_xmethod_worker (PyObject *item,
|
|
|
|
PyObject *py_obj_type);
|
|
|
|
|
|
|
|
/* Implementation of free_xmethod_worker_data for Python. */
|
|
|
|
|
|
|
|
void
|
|
|
|
gdbpy_free_xmethod_worker_data (const struct extension_language_defn *extlang,
|
|
|
|
void *data)
|
|
|
|
{
|
2015-09-25 20:08:07 +02:00
|
|
|
struct gdbpy_worker_data *worker_data = (struct gdbpy_worker_data *) data;
|
2014-05-20 15:53:04 +02:00
|
|
|
|
|
|
|
gdb_assert (worker_data->worker != NULL && worker_data->this_type != NULL);
|
|
|
|
|
|
|
|
/* We don't do much here, but we still need the GIL. */
|
2016-11-08 00:13:40 +01:00
|
|
|
gdbpy_enter enter_py (get_current_arch (), current_language);
|
2014-05-20 15:53:04 +02:00
|
|
|
|
|
|
|
Py_DECREF (worker_data->worker);
|
|
|
|
Py_DECREF (worker_data->this_type);
|
|
|
|
xfree (worker_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Implementation of clone_xmethod_worker_data for Python. */
|
|
|
|
|
|
|
|
void *
|
|
|
|
gdbpy_clone_xmethod_worker_data (const struct extension_language_defn *extlang,
|
|
|
|
void *data)
|
|
|
|
{
|
2015-09-25 20:08:07 +02:00
|
|
|
struct gdbpy_worker_data *worker_data
|
|
|
|
= (struct gdbpy_worker_data *) data, *new_data;
|
2014-05-20 15:53:04 +02:00
|
|
|
|
|
|
|
gdb_assert (worker_data->worker != NULL && worker_data->this_type != NULL);
|
|
|
|
|
|
|
|
/* We don't do much here, but we still need the GIL. */
|
2016-11-08 00:13:40 +01:00
|
|
|
gdbpy_enter enter_py (get_current_arch (), current_language);
|
2014-05-20 15:53:04 +02:00
|
|
|
|
|
|
|
new_data = XCNEW (struct gdbpy_worker_data);
|
|
|
|
new_data->worker = worker_data->worker;
|
|
|
|
new_data->this_type = worker_data->this_type;
|
|
|
|
Py_INCREF (new_data->worker);
|
|
|
|
Py_INCREF (new_data->this_type);
|
|
|
|
|
|
|
|
return new_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Invoke the "match" method of the MATCHER and return a new reference
|
|
|
|
to the result. Returns NULL on error. */
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
invoke_match_method (PyObject *matcher, PyObject *py_obj_type,
|
|
|
|
const char *xmethod_name)
|
|
|
|
{
|
|
|
|
int enabled;
|
|
|
|
|
Turn gdbpy_ref into a template
This turns gdbpy_ref into a template class, so that it can be used to
wrap subclasses of PyObject. The default argument remains PyObject;
and this necessitated renaming uses of "gdbpy_ref" to "gdbpy_ref<>".
gdb/ChangeLog
2017-02-10 Tom Tromey <tom@tromey.com>
* python/py-ref.h (gdbpy_ref_policy): Now a template.
(gdbpy_ref): Now a template; allow subclasses of PyObject to be
used.
* python/py-arch.c, python/py-bpevent.c, python/py-breakpoint.c,
python/py-cmd.c, python/py-continueevent.c, python/py-event.c,
python/py-exitedevent.c, python/py-finishbreakpoint.c,
python/py-framefilter.c, python/py-function.c,
python/py-inferior.c, python/py-infevents.c,
python/py-linetable.c, python/py-newobjfileevent.c,
python/py-param.c, python/py-prettyprint.c, python/py-ref.h,
python/py-signalevent.c, python/py-stopevent.c,
python/py-symbol.c, python/py-threadevent.c, python/py-type.c,
python/py-unwind.c, python/py-utils.c, python/py-value.c,
python/py-varobj.c, python/py-xmethods.c, python/python.c,
varobj.c: Change gdbpy_ref to gdbpy_ref<>.
2017-02-09 21:16:36 +01:00
|
|
|
gdbpy_ref<> enabled_field (PyObject_GetAttrString (matcher,
|
|
|
|
enabled_field_name));
|
2014-05-20 15:53:04 +02:00
|
|
|
if (enabled_field == NULL)
|
2016-11-08 23:35:24 +01:00
|
|
|
return NULL;
|
2014-05-20 15:53:04 +02:00
|
|
|
|
2016-11-08 23:35:24 +01:00
|
|
|
enabled = PyObject_IsTrue (enabled_field.get ());
|
2014-05-20 15:53:04 +02:00
|
|
|
if (enabled == -1)
|
2016-11-08 23:35:24 +01:00
|
|
|
return NULL;
|
2014-05-20 15:53:04 +02:00
|
|
|
if (enabled == 0)
|
|
|
|
{
|
|
|
|
/* Return 'None' if the matcher is not enabled. */
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
}
|
|
|
|
|
Turn gdbpy_ref into a template
This turns gdbpy_ref into a template class, so that it can be used to
wrap subclasses of PyObject. The default argument remains PyObject;
and this necessitated renaming uses of "gdbpy_ref" to "gdbpy_ref<>".
gdb/ChangeLog
2017-02-10 Tom Tromey <tom@tromey.com>
* python/py-ref.h (gdbpy_ref_policy): Now a template.
(gdbpy_ref): Now a template; allow subclasses of PyObject to be
used.
* python/py-arch.c, python/py-bpevent.c, python/py-breakpoint.c,
python/py-cmd.c, python/py-continueevent.c, python/py-event.c,
python/py-exitedevent.c, python/py-finishbreakpoint.c,
python/py-framefilter.c, python/py-function.c,
python/py-inferior.c, python/py-infevents.c,
python/py-linetable.c, python/py-newobjfileevent.c,
python/py-param.c, python/py-prettyprint.c, python/py-ref.h,
python/py-signalevent.c, python/py-stopevent.c,
python/py-symbol.c, python/py-threadevent.c, python/py-type.c,
python/py-unwind.c, python/py-utils.c, python/py-value.c,
python/py-varobj.c, python/py-xmethods.c, python/python.c,
varobj.c: Change gdbpy_ref to gdbpy_ref<>.
2017-02-09 21:16:36 +01:00
|
|
|
gdbpy_ref<> match_method (PyObject_GetAttrString (matcher,
|
|
|
|
match_method_name));
|
2014-05-20 15:53:04 +02:00
|
|
|
if (match_method == NULL)
|
2016-11-08 23:35:24 +01:00
|
|
|
return NULL;
|
2014-05-20 15:53:04 +02:00
|
|
|
|
Turn gdbpy_ref into a template
This turns gdbpy_ref into a template class, so that it can be used to
wrap subclasses of PyObject. The default argument remains PyObject;
and this necessitated renaming uses of "gdbpy_ref" to "gdbpy_ref<>".
gdb/ChangeLog
2017-02-10 Tom Tromey <tom@tromey.com>
* python/py-ref.h (gdbpy_ref_policy): Now a template.
(gdbpy_ref): Now a template; allow subclasses of PyObject to be
used.
* python/py-arch.c, python/py-bpevent.c, python/py-breakpoint.c,
python/py-cmd.c, python/py-continueevent.c, python/py-event.c,
python/py-exitedevent.c, python/py-finishbreakpoint.c,
python/py-framefilter.c, python/py-function.c,
python/py-inferior.c, python/py-infevents.c,
python/py-linetable.c, python/py-newobjfileevent.c,
python/py-param.c, python/py-prettyprint.c, python/py-ref.h,
python/py-signalevent.c, python/py-stopevent.c,
python/py-symbol.c, python/py-threadevent.c, python/py-type.c,
python/py-unwind.c, python/py-utils.c, python/py-value.c,
python/py-varobj.c, python/py-xmethods.c, python/python.c,
varobj.c: Change gdbpy_ref to gdbpy_ref<>.
2017-02-09 21:16:36 +01:00
|
|
|
gdbpy_ref<> py_xmethod_name (PyString_FromString (xmethod_name));
|
2014-05-20 15:53:04 +02:00
|
|
|
if (py_xmethod_name == NULL)
|
2016-11-08 23:35:24 +01:00
|
|
|
return NULL;
|
2014-05-20 15:53:04 +02:00
|
|
|
|
2016-11-08 23:35:24 +01:00
|
|
|
return PyObject_CallMethodObjArgs (matcher, py_match_method_name,
|
|
|
|
py_obj_type, py_xmethod_name.get (),
|
|
|
|
NULL);
|
2014-05-20 15:53:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Implementation of get_matching_xmethod_workers for Python. */
|
|
|
|
|
|
|
|
enum ext_lang_rc
|
|
|
|
gdbpy_get_matching_xmethod_workers
|
|
|
|
(const struct extension_language_defn *extlang,
|
|
|
|
struct type *obj_type, const char *method_name,
|
|
|
|
xmethod_worker_vec **dm_vec)
|
|
|
|
{
|
|
|
|
struct objfile *objfile;
|
|
|
|
VEC (xmethod_worker_ptr) *worker_vec = NULL;
|
2016-11-08 23:34:55 +01:00
|
|
|
PyObject *py_progspace;
|
2014-05-20 15:53:04 +02:00
|
|
|
|
|
|
|
gdb_assert (obj_type != NULL && method_name != NULL);
|
|
|
|
|
2016-11-08 23:34:55 +01:00
|
|
|
gdbpy_enter enter_py (get_current_arch (), current_language);
|
2014-05-20 15:53:04 +02:00
|
|
|
|
Turn gdbpy_ref into a template
This turns gdbpy_ref into a template class, so that it can be used to
wrap subclasses of PyObject. The default argument remains PyObject;
and this necessitated renaming uses of "gdbpy_ref" to "gdbpy_ref<>".
gdb/ChangeLog
2017-02-10 Tom Tromey <tom@tromey.com>
* python/py-ref.h (gdbpy_ref_policy): Now a template.
(gdbpy_ref): Now a template; allow subclasses of PyObject to be
used.
* python/py-arch.c, python/py-bpevent.c, python/py-breakpoint.c,
python/py-cmd.c, python/py-continueevent.c, python/py-event.c,
python/py-exitedevent.c, python/py-finishbreakpoint.c,
python/py-framefilter.c, python/py-function.c,
python/py-inferior.c, python/py-infevents.c,
python/py-linetable.c, python/py-newobjfileevent.c,
python/py-param.c, python/py-prettyprint.c, python/py-ref.h,
python/py-signalevent.c, python/py-stopevent.c,
python/py-symbol.c, python/py-threadevent.c, python/py-type.c,
python/py-unwind.c, python/py-utils.c, python/py-value.c,
python/py-varobj.c, python/py-xmethods.c, python/python.c,
varobj.c: Change gdbpy_ref to gdbpy_ref<>.
2017-02-09 21:16:36 +01:00
|
|
|
gdbpy_ref<> py_type (type_to_type_object (obj_type));
|
2014-05-20 15:53:04 +02:00
|
|
|
if (py_type == NULL)
|
|
|
|
{
|
|
|
|
gdbpy_print_stack ();
|
|
|
|
return EXT_LANG_RC_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create an empty list of debug methods. */
|
Turn gdbpy_ref into a template
This turns gdbpy_ref into a template class, so that it can be used to
wrap subclasses of PyObject. The default argument remains PyObject;
and this necessitated renaming uses of "gdbpy_ref" to "gdbpy_ref<>".
gdb/ChangeLog
2017-02-10 Tom Tromey <tom@tromey.com>
* python/py-ref.h (gdbpy_ref_policy): Now a template.
(gdbpy_ref): Now a template; allow subclasses of PyObject to be
used.
* python/py-arch.c, python/py-bpevent.c, python/py-breakpoint.c,
python/py-cmd.c, python/py-continueevent.c, python/py-event.c,
python/py-exitedevent.c, python/py-finishbreakpoint.c,
python/py-framefilter.c, python/py-function.c,
python/py-inferior.c, python/py-infevents.c,
python/py-linetable.c, python/py-newobjfileevent.c,
python/py-param.c, python/py-prettyprint.c, python/py-ref.h,
python/py-signalevent.c, python/py-stopevent.c,
python/py-symbol.c, python/py-threadevent.c, python/py-type.c,
python/py-unwind.c, python/py-utils.c, python/py-value.c,
python/py-varobj.c, python/py-xmethods.c, python/python.c,
varobj.c: Change gdbpy_ref to gdbpy_ref<>.
2017-02-09 21:16:36 +01:00
|
|
|
gdbpy_ref<> py_xmethod_matcher_list (PyList_New (0));
|
2014-05-20 15:53:04 +02:00
|
|
|
if (py_xmethod_matcher_list == NULL)
|
|
|
|
{
|
|
|
|
gdbpy_print_stack ();
|
|
|
|
return EXT_LANG_RC_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Gather debug method matchers registered with the object files.
|
|
|
|
This could be done differently by iterating over each objfile's matcher
|
|
|
|
list individually, but there's no data yet to show it's needed. */
|
|
|
|
ALL_OBJFILES (objfile)
|
|
|
|
{
|
|
|
|
PyObject *py_objfile = objfile_to_objfile_object (objfile);
|
|
|
|
|
|
|
|
if (py_objfile == NULL)
|
|
|
|
{
|
|
|
|
gdbpy_print_stack ();
|
|
|
|
return EXT_LANG_RC_ERROR;
|
|
|
|
}
|
|
|
|
|
Turn gdbpy_ref into a template
This turns gdbpy_ref into a template class, so that it can be used to
wrap subclasses of PyObject. The default argument remains PyObject;
and this necessitated renaming uses of "gdbpy_ref" to "gdbpy_ref<>".
gdb/ChangeLog
2017-02-10 Tom Tromey <tom@tromey.com>
* python/py-ref.h (gdbpy_ref_policy): Now a template.
(gdbpy_ref): Now a template; allow subclasses of PyObject to be
used.
* python/py-arch.c, python/py-bpevent.c, python/py-breakpoint.c,
python/py-cmd.c, python/py-continueevent.c, python/py-event.c,
python/py-exitedevent.c, python/py-finishbreakpoint.c,
python/py-framefilter.c, python/py-function.c,
python/py-inferior.c, python/py-infevents.c,
python/py-linetable.c, python/py-newobjfileevent.c,
python/py-param.c, python/py-prettyprint.c, python/py-ref.h,
python/py-signalevent.c, python/py-stopevent.c,
python/py-symbol.c, python/py-threadevent.c, python/py-type.c,
python/py-unwind.c, python/py-utils.c, python/py-value.c,
python/py-varobj.c, python/py-xmethods.c, python/python.c,
varobj.c: Change gdbpy_ref to gdbpy_ref<>.
2017-02-09 21:16:36 +01:00
|
|
|
gdbpy_ref<> objfile_matchers (objfpy_get_xmethods (py_objfile, NULL));
|
|
|
|
gdbpy_ref<> temp (PySequence_Concat (py_xmethod_matcher_list.get (),
|
|
|
|
objfile_matchers.get ()));
|
2016-11-08 23:34:55 +01:00
|
|
|
if (temp == NULL)
|
2014-05-20 15:53:04 +02:00
|
|
|
{
|
|
|
|
gdbpy_print_stack ();
|
|
|
|
return EXT_LANG_RC_ERROR;
|
|
|
|
}
|
2016-11-08 23:34:55 +01:00
|
|
|
|
|
|
|
py_xmethod_matcher_list = std::move (temp);
|
2014-05-20 15:53:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Gather debug methods matchers registered with the current program
|
|
|
|
space. */
|
|
|
|
py_progspace = pspace_to_pspace_object (current_program_space);
|
|
|
|
if (py_progspace != NULL)
|
|
|
|
{
|
Turn gdbpy_ref into a template
This turns gdbpy_ref into a template class, so that it can be used to
wrap subclasses of PyObject. The default argument remains PyObject;
and this necessitated renaming uses of "gdbpy_ref" to "gdbpy_ref<>".
gdb/ChangeLog
2017-02-10 Tom Tromey <tom@tromey.com>
* python/py-ref.h (gdbpy_ref_policy): Now a template.
(gdbpy_ref): Now a template; allow subclasses of PyObject to be
used.
* python/py-arch.c, python/py-bpevent.c, python/py-breakpoint.c,
python/py-cmd.c, python/py-continueevent.c, python/py-event.c,
python/py-exitedevent.c, python/py-finishbreakpoint.c,
python/py-framefilter.c, python/py-function.c,
python/py-inferior.c, python/py-infevents.c,
python/py-linetable.c, python/py-newobjfileevent.c,
python/py-param.c, python/py-prettyprint.c, python/py-ref.h,
python/py-signalevent.c, python/py-stopevent.c,
python/py-symbol.c, python/py-threadevent.c, python/py-type.c,
python/py-unwind.c, python/py-utils.c, python/py-value.c,
python/py-varobj.c, python/py-xmethods.c, python/python.c,
varobj.c: Change gdbpy_ref to gdbpy_ref<>.
2017-02-09 21:16:36 +01:00
|
|
|
gdbpy_ref<> pspace_matchers (pspy_get_xmethods (py_progspace, NULL));
|
2014-05-20 15:53:04 +02:00
|
|
|
|
Turn gdbpy_ref into a template
This turns gdbpy_ref into a template class, so that it can be used to
wrap subclasses of PyObject. The default argument remains PyObject;
and this necessitated renaming uses of "gdbpy_ref" to "gdbpy_ref<>".
gdb/ChangeLog
2017-02-10 Tom Tromey <tom@tromey.com>
* python/py-ref.h (gdbpy_ref_policy): Now a template.
(gdbpy_ref): Now a template; allow subclasses of PyObject to be
used.
* python/py-arch.c, python/py-bpevent.c, python/py-breakpoint.c,
python/py-cmd.c, python/py-continueevent.c, python/py-event.c,
python/py-exitedevent.c, python/py-finishbreakpoint.c,
python/py-framefilter.c, python/py-function.c,
python/py-inferior.c, python/py-infevents.c,
python/py-linetable.c, python/py-newobjfileevent.c,
python/py-param.c, python/py-prettyprint.c, python/py-ref.h,
python/py-signalevent.c, python/py-stopevent.c,
python/py-symbol.c, python/py-threadevent.c, python/py-type.c,
python/py-unwind.c, python/py-utils.c, python/py-value.c,
python/py-varobj.c, python/py-xmethods.c, python/python.c,
varobj.c: Change gdbpy_ref to gdbpy_ref<>.
2017-02-09 21:16:36 +01:00
|
|
|
gdbpy_ref<> temp (PySequence_Concat (py_xmethod_matcher_list.get (),
|
|
|
|
pspace_matchers.get ()));
|
2016-11-08 23:34:55 +01:00
|
|
|
if (temp == NULL)
|
2014-05-20 15:53:04 +02:00
|
|
|
{
|
|
|
|
gdbpy_print_stack ();
|
|
|
|
return EXT_LANG_RC_ERROR;
|
|
|
|
}
|
2016-11-08 23:34:55 +01:00
|
|
|
|
|
|
|
py_xmethod_matcher_list = std::move (temp);
|
2014-05-20 15:53:04 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gdbpy_print_stack ();
|
|
|
|
return EXT_LANG_RC_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Gather debug method matchers registered globally. */
|
|
|
|
if (gdb_python_module != NULL
|
|
|
|
&& PyObject_HasAttrString (gdb_python_module, matchers_attr_str))
|
|
|
|
{
|
Turn gdbpy_ref into a template
This turns gdbpy_ref into a template class, so that it can be used to
wrap subclasses of PyObject. The default argument remains PyObject;
and this necessitated renaming uses of "gdbpy_ref" to "gdbpy_ref<>".
gdb/ChangeLog
2017-02-10 Tom Tromey <tom@tromey.com>
* python/py-ref.h (gdbpy_ref_policy): Now a template.
(gdbpy_ref): Now a template; allow subclasses of PyObject to be
used.
* python/py-arch.c, python/py-bpevent.c, python/py-breakpoint.c,
python/py-cmd.c, python/py-continueevent.c, python/py-event.c,
python/py-exitedevent.c, python/py-finishbreakpoint.c,
python/py-framefilter.c, python/py-function.c,
python/py-inferior.c, python/py-infevents.c,
python/py-linetable.c, python/py-newobjfileevent.c,
python/py-param.c, python/py-prettyprint.c, python/py-ref.h,
python/py-signalevent.c, python/py-stopevent.c,
python/py-symbol.c, python/py-threadevent.c, python/py-type.c,
python/py-unwind.c, python/py-utils.c, python/py-value.c,
python/py-varobj.c, python/py-xmethods.c, python/python.c,
varobj.c: Change gdbpy_ref to gdbpy_ref<>.
2017-02-09 21:16:36 +01:00
|
|
|
gdbpy_ref<> gdb_matchers (PyObject_GetAttrString (gdb_python_module,
|
|
|
|
matchers_attr_str));
|
2014-05-20 15:53:04 +02:00
|
|
|
if (gdb_matchers != NULL)
|
|
|
|
{
|
Turn gdbpy_ref into a template
This turns gdbpy_ref into a template class, so that it can be used to
wrap subclasses of PyObject. The default argument remains PyObject;
and this necessitated renaming uses of "gdbpy_ref" to "gdbpy_ref<>".
gdb/ChangeLog
2017-02-10 Tom Tromey <tom@tromey.com>
* python/py-ref.h (gdbpy_ref_policy): Now a template.
(gdbpy_ref): Now a template; allow subclasses of PyObject to be
used.
* python/py-arch.c, python/py-bpevent.c, python/py-breakpoint.c,
python/py-cmd.c, python/py-continueevent.c, python/py-event.c,
python/py-exitedevent.c, python/py-finishbreakpoint.c,
python/py-framefilter.c, python/py-function.c,
python/py-inferior.c, python/py-infevents.c,
python/py-linetable.c, python/py-newobjfileevent.c,
python/py-param.c, python/py-prettyprint.c, python/py-ref.h,
python/py-signalevent.c, python/py-stopevent.c,
python/py-symbol.c, python/py-threadevent.c, python/py-type.c,
python/py-unwind.c, python/py-utils.c, python/py-value.c,
python/py-varobj.c, python/py-xmethods.c, python/python.c,
varobj.c: Change gdbpy_ref to gdbpy_ref<>.
2017-02-09 21:16:36 +01:00
|
|
|
gdbpy_ref<> temp (PySequence_Concat (py_xmethod_matcher_list.get (),
|
|
|
|
gdb_matchers.get ()));
|
2016-11-08 23:34:55 +01:00
|
|
|
if (temp == NULL)
|
2014-05-20 15:53:04 +02:00
|
|
|
{
|
|
|
|
gdbpy_print_stack ();
|
|
|
|
return EXT_LANG_RC_ERROR;
|
|
|
|
}
|
2016-11-08 23:34:55 +01:00
|
|
|
|
|
|
|
py_xmethod_matcher_list = std::move (temp);
|
2014-05-20 15:53:04 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gdbpy_print_stack ();
|
|
|
|
return EXT_LANG_RC_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Turn gdbpy_ref into a template
This turns gdbpy_ref into a template class, so that it can be used to
wrap subclasses of PyObject. The default argument remains PyObject;
and this necessitated renaming uses of "gdbpy_ref" to "gdbpy_ref<>".
gdb/ChangeLog
2017-02-10 Tom Tromey <tom@tromey.com>
* python/py-ref.h (gdbpy_ref_policy): Now a template.
(gdbpy_ref): Now a template; allow subclasses of PyObject to be
used.
* python/py-arch.c, python/py-bpevent.c, python/py-breakpoint.c,
python/py-cmd.c, python/py-continueevent.c, python/py-event.c,
python/py-exitedevent.c, python/py-finishbreakpoint.c,
python/py-framefilter.c, python/py-function.c,
python/py-inferior.c, python/py-infevents.c,
python/py-linetable.c, python/py-newobjfileevent.c,
python/py-param.c, python/py-prettyprint.c, python/py-ref.h,
python/py-signalevent.c, python/py-stopevent.c,
python/py-symbol.c, python/py-threadevent.c, python/py-type.c,
python/py-unwind.c, python/py-utils.c, python/py-value.c,
python/py-varobj.c, python/py-xmethods.c, python/python.c,
varobj.c: Change gdbpy_ref to gdbpy_ref<>.
2017-02-09 21:16:36 +01:00
|
|
|
gdbpy_ref<> list_iter (PyObject_GetIter (py_xmethod_matcher_list.get ()));
|
2014-05-20 15:53:04 +02:00
|
|
|
if (list_iter == NULL)
|
|
|
|
{
|
|
|
|
gdbpy_print_stack ();
|
|
|
|
return EXT_LANG_RC_ERROR;
|
|
|
|
}
|
2016-11-08 23:34:55 +01:00
|
|
|
while (true)
|
2014-05-20 15:53:04 +02:00
|
|
|
{
|
Turn gdbpy_ref into a template
This turns gdbpy_ref into a template class, so that it can be used to
wrap subclasses of PyObject. The default argument remains PyObject;
and this necessitated renaming uses of "gdbpy_ref" to "gdbpy_ref<>".
gdb/ChangeLog
2017-02-10 Tom Tromey <tom@tromey.com>
* python/py-ref.h (gdbpy_ref_policy): Now a template.
(gdbpy_ref): Now a template; allow subclasses of PyObject to be
used.
* python/py-arch.c, python/py-bpevent.c, python/py-breakpoint.c,
python/py-cmd.c, python/py-continueevent.c, python/py-event.c,
python/py-exitedevent.c, python/py-finishbreakpoint.c,
python/py-framefilter.c, python/py-function.c,
python/py-inferior.c, python/py-infevents.c,
python/py-linetable.c, python/py-newobjfileevent.c,
python/py-param.c, python/py-prettyprint.c, python/py-ref.h,
python/py-signalevent.c, python/py-stopevent.c,
python/py-symbol.c, python/py-threadevent.c, python/py-type.c,
python/py-unwind.c, python/py-utils.c, python/py-value.c,
python/py-varobj.c, python/py-xmethods.c, python/python.c,
varobj.c: Change gdbpy_ref to gdbpy_ref<>.
2017-02-09 21:16:36 +01:00
|
|
|
gdbpy_ref<> matcher (PyIter_Next (list_iter.get ()));
|
2016-11-08 23:34:55 +01:00
|
|
|
if (matcher == NULL)
|
|
|
|
{
|
|
|
|
if (PyErr_Occurred ())
|
|
|
|
{
|
|
|
|
gdbpy_print_stack ();
|
|
|
|
return EXT_LANG_RC_ERROR;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
Turn gdbpy_ref into a template
This turns gdbpy_ref into a template class, so that it can be used to
wrap subclasses of PyObject. The default argument remains PyObject;
and this necessitated renaming uses of "gdbpy_ref" to "gdbpy_ref<>".
gdb/ChangeLog
2017-02-10 Tom Tromey <tom@tromey.com>
* python/py-ref.h (gdbpy_ref_policy): Now a template.
(gdbpy_ref): Now a template; allow subclasses of PyObject to be
used.
* python/py-arch.c, python/py-bpevent.c, python/py-breakpoint.c,
python/py-cmd.c, python/py-continueevent.c, python/py-event.c,
python/py-exitedevent.c, python/py-finishbreakpoint.c,
python/py-framefilter.c, python/py-function.c,
python/py-inferior.c, python/py-infevents.c,
python/py-linetable.c, python/py-newobjfileevent.c,
python/py-param.c, python/py-prettyprint.c, python/py-ref.h,
python/py-signalevent.c, python/py-stopevent.c,
python/py-symbol.c, python/py-threadevent.c, python/py-type.c,
python/py-unwind.c, python/py-utils.c, python/py-value.c,
python/py-varobj.c, python/py-xmethods.c, python/python.c,
varobj.c: Change gdbpy_ref to gdbpy_ref<>.
2017-02-09 21:16:36 +01:00
|
|
|
gdbpy_ref<> match_result (invoke_match_method (matcher.get (),
|
|
|
|
py_type.get (),
|
|
|
|
method_name));
|
2014-05-20 15:53:04 +02:00
|
|
|
|
|
|
|
if (match_result == NULL)
|
|
|
|
{
|
|
|
|
gdbpy_print_stack ();
|
|
|
|
return EXT_LANG_RC_ERROR;
|
|
|
|
}
|
|
|
|
if (match_result == Py_None)
|
|
|
|
; /* This means there was no match. */
|
2016-11-08 23:34:55 +01:00
|
|
|
else if (PySequence_Check (match_result.get ()))
|
2014-05-20 15:53:04 +02:00
|
|
|
{
|
Turn gdbpy_ref into a template
This turns gdbpy_ref into a template class, so that it can be used to
wrap subclasses of PyObject. The default argument remains PyObject;
and this necessitated renaming uses of "gdbpy_ref" to "gdbpy_ref<>".
gdb/ChangeLog
2017-02-10 Tom Tromey <tom@tromey.com>
* python/py-ref.h (gdbpy_ref_policy): Now a template.
(gdbpy_ref): Now a template; allow subclasses of PyObject to be
used.
* python/py-arch.c, python/py-bpevent.c, python/py-breakpoint.c,
python/py-cmd.c, python/py-continueevent.c, python/py-event.c,
python/py-exitedevent.c, python/py-finishbreakpoint.c,
python/py-framefilter.c, python/py-function.c,
python/py-inferior.c, python/py-infevents.c,
python/py-linetable.c, python/py-newobjfileevent.c,
python/py-param.c, python/py-prettyprint.c, python/py-ref.h,
python/py-signalevent.c, python/py-stopevent.c,
python/py-symbol.c, python/py-threadevent.c, python/py-type.c,
python/py-unwind.c, python/py-utils.c, python/py-value.c,
python/py-varobj.c, python/py-xmethods.c, python/python.c,
varobj.c: Change gdbpy_ref to gdbpy_ref<>.
2017-02-09 21:16:36 +01:00
|
|
|
gdbpy_ref<> iter (PyObject_GetIter (match_result.get ()));
|
2014-05-20 15:53:04 +02:00
|
|
|
|
|
|
|
if (iter == NULL)
|
|
|
|
{
|
|
|
|
gdbpy_print_stack ();
|
|
|
|
return EXT_LANG_RC_ERROR;
|
|
|
|
}
|
2016-11-08 23:34:55 +01:00
|
|
|
while (true)
|
2014-05-20 15:53:04 +02:00
|
|
|
{
|
|
|
|
struct xmethod_worker *worker;
|
|
|
|
|
Turn gdbpy_ref into a template
This turns gdbpy_ref into a template class, so that it can be used to
wrap subclasses of PyObject. The default argument remains PyObject;
and this necessitated renaming uses of "gdbpy_ref" to "gdbpy_ref<>".
gdb/ChangeLog
2017-02-10 Tom Tromey <tom@tromey.com>
* python/py-ref.h (gdbpy_ref_policy): Now a template.
(gdbpy_ref): Now a template; allow subclasses of PyObject to be
used.
* python/py-arch.c, python/py-bpevent.c, python/py-breakpoint.c,
python/py-cmd.c, python/py-continueevent.c, python/py-event.c,
python/py-exitedevent.c, python/py-finishbreakpoint.c,
python/py-framefilter.c, python/py-function.c,
python/py-inferior.c, python/py-infevents.c,
python/py-linetable.c, python/py-newobjfileevent.c,
python/py-param.c, python/py-prettyprint.c, python/py-ref.h,
python/py-signalevent.c, python/py-stopevent.c,
python/py-symbol.c, python/py-threadevent.c, python/py-type.c,
python/py-unwind.c, python/py-utils.c, python/py-value.c,
python/py-varobj.c, python/py-xmethods.c, python/python.c,
varobj.c: Change gdbpy_ref to gdbpy_ref<>.
2017-02-09 21:16:36 +01:00
|
|
|
gdbpy_ref<> py_worker (PyIter_Next (iter.get ()));
|
2016-11-08 23:34:55 +01:00
|
|
|
if (py_worker == NULL)
|
|
|
|
{
|
|
|
|
if (PyErr_Occurred ())
|
|
|
|
{
|
|
|
|
gdbpy_print_stack ();
|
|
|
|
return EXT_LANG_RC_ERROR;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
worker = new_python_xmethod_worker (py_worker.get (),
|
|
|
|
py_type.get ());
|
2014-05-20 15:53:04 +02:00
|
|
|
VEC_safe_push (xmethod_worker_ptr, worker_vec, worker);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
struct xmethod_worker *worker;
|
|
|
|
|
2016-11-08 23:34:55 +01:00
|
|
|
worker = new_python_xmethod_worker (match_result.get (),
|
|
|
|
py_type.get ());
|
2014-05-20 15:53:04 +02:00
|
|
|
VEC_safe_push (xmethod_worker_ptr, worker_vec, worker);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*dm_vec = worker_vec;
|
|
|
|
|
|
|
|
return EXT_LANG_RC_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Implementation of get_xmethod_arg_types for Python. */
|
|
|
|
|
|
|
|
enum ext_lang_rc
|
|
|
|
gdbpy_get_xmethod_arg_types (const struct extension_language_defn *extlang,
|
|
|
|
struct xmethod_worker *worker,
|
|
|
|
int *nargs, struct type ***arg_types)
|
|
|
|
{
|
Fix Py_DECREF being executed without holding the GIL
When the gdbpy_ref objects get destroyed, they call Py_DECREF to
decrement the reference counter of the python object they hold a
reference to. Any time we call into the Python API, we should be
holding the GIL. The gdbpy_enter object does that for us in an
RAII-fashion.
However, if gdbpy_enter is declared after a gdbpy_ref object in a
function, gdbpy_enter's destructor will be called (and the GIL will be
released) before gdbpy_ref's destructor is called. Therefore, we will
end up calling Py_DECREF without holding the GIL.
This became obvious with Python 3.6, where memory management functions
have asserts to make sure that the GIL is held. This was exposed by
tests py-as-string.exp, py-function.exp and py-xmethods. For example:
(gdb) p $_as_string(enum_valid)
Fatal Python error: Python memory allocator called without holding the GIL
Current thread 0x00007f7f7b21c780 (most recent call first):
[1] 18678 abort (core dumped) ./gdb -nx testsuite/outputs/gdb.python/py-as-string/py-as-string
#0 0x00007ffff618bc37 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x00007ffff618f028 in abort () from /lib/x86_64-linux-gnu/libc.so.6
#2 0x00007ffff6b104d6 in Py_FatalError (msg=msg@entry=0x7ffff6ba15b8 "Python memory allocator called without holding the GIL") at Python/pylifecycle.c:1457
#3 0x00007ffff6a37a68 in _PyMem_DebugCheckGIL () at Objects/obmalloc.c:1972
#4 0x00007ffff6a3804e in _PyMem_DebugFree (ctx=0x7ffff6e65290 <_PyMem_Debug+48>, ptr=0x24f8830) at Objects/obmalloc.c:1994
#5 0x00007ffff6a38e1d in PyMem_Free (ptr=<optimized out>) at Objects/obmalloc.c:442
#6 0x00007ffff6b866c6 in _PyFaulthandler_Fini () at ./Modules/faulthandler.c:1369
#7 0x00007ffff6b104bd in Py_FatalError (msg=msg@entry=0x7ffff6ba15b8 "Python memory allocator called without holding the GIL") at Python/pylifecycle.c:1431
#8 0x00007ffff6a37a68 in _PyMem_DebugCheckGIL () at Objects/obmalloc.c:1972
#9 0x00007ffff6a3804e in _PyMem_DebugFree (ctx=0x7ffff6e652c0 <_PyMem_Debug+96>, ptr=0x7ffff46b6040) at Objects/obmalloc.c:1994
#10 0x00007ffff6a38f55 in PyObject_Free (ptr=<optimized out>) at Objects/obmalloc.c:503
#11 0x00007ffff6a5f27e in unicode_dealloc (unicode=unicode@entry=0x7ffff46b6040) at Objects/unicodeobject.c:1794
#12 0x00007ffff6a352a9 in _Py_Dealloc (op=0x7ffff46b6040) at Objects/object.c:1786
#13 0x000000000063f28b in gdb_Py_DECREF (op=0x7ffff46b6040) at /home/emaisin/src/binutils-gdb/gdb/python/python-internal.h:192
#14 0x000000000063fa33 in gdbpy_ref_policy::decref (ptr=0x7ffff46b6040) at /home/emaisin/src/binutils-gdb/gdb/python/py-ref.h:35
#15 0x000000000063fa77 in gdb::ref_ptr<_object, gdbpy_ref_policy>::~ref_ptr (this=0x7fffffffcdf0, __in_chrg=<optimized out>) at /home/emaisin/src/binutils-gdb/gdb/common/gdb_ref_ptr.h:91
#16 0x000000000064d8b8 in fnpy_call (gdbarch=0x2b50010, language=0x115d2c0 <c_language_defn>, cookie=0x7ffff46b7468, argc=1, argv=0x7fffffffcf48)
at /home/emaisin/src/binutils-gdb/gdb/python/py-function.c:145
The fix is to place the gdbpy_enter first in the function. I also
cleaned up the comments a bit and removed the unnecessary initialization
of the value variable.
gdb/ChangeLog:
* python/py-function.c (fnpy_call): Reorder declarations to have
the gdbpy_enter object declared first.
* python/py-xmethods.c (gdbpy_get_xmethod_arg_types): Likewise.
2017-01-21 03:02:05 +01:00
|
|
|
/* The gdbpy_enter object needs to be placed first, so that it's the last to
|
|
|
|
be destroyed. */
|
|
|
|
gdbpy_enter enter_py (get_current_arch (), current_language);
|
2015-09-25 20:08:07 +02:00
|
|
|
struct gdbpy_worker_data *worker_data
|
|
|
|
= (struct gdbpy_worker_data *) worker->data;
|
2014-05-20 15:53:04 +02:00
|
|
|
PyObject *py_worker = worker_data->worker;
|
2016-11-08 23:47:39 +01:00
|
|
|
struct type *obj_type;
|
2014-05-20 15:53:04 +02:00
|
|
|
int i = 1, arg_count;
|
Turn gdbpy_ref into a template
This turns gdbpy_ref into a template class, so that it can be used to
wrap subclasses of PyObject. The default argument remains PyObject;
and this necessitated renaming uses of "gdbpy_ref" to "gdbpy_ref<>".
gdb/ChangeLog
2017-02-10 Tom Tromey <tom@tromey.com>
* python/py-ref.h (gdbpy_ref_policy): Now a template.
(gdbpy_ref): Now a template; allow subclasses of PyObject to be
used.
* python/py-arch.c, python/py-bpevent.c, python/py-breakpoint.c,
python/py-cmd.c, python/py-continueevent.c, python/py-event.c,
python/py-exitedevent.c, python/py-finishbreakpoint.c,
python/py-framefilter.c, python/py-function.c,
python/py-inferior.c, python/py-infevents.c,
python/py-linetable.c, python/py-newobjfileevent.c,
python/py-param.c, python/py-prettyprint.c, python/py-ref.h,
python/py-signalevent.c, python/py-stopevent.c,
python/py-symbol.c, python/py-threadevent.c, python/py-type.c,
python/py-unwind.c, python/py-utils.c, python/py-value.c,
python/py-varobj.c, python/py-xmethods.c, python/python.c,
varobj.c: Change gdbpy_ref to gdbpy_ref<>.
2017-02-09 21:16:36 +01:00
|
|
|
gdbpy_ref<> list_iter;
|
2014-05-20 15:53:04 +02:00
|
|
|
|
|
|
|
/* Set nargs to -1 so that any premature return from this function returns
|
|
|
|
an invalid/unusable number of arg types. */
|
|
|
|
*nargs = -1;
|
|
|
|
|
Turn gdbpy_ref into a template
This turns gdbpy_ref into a template class, so that it can be used to
wrap subclasses of PyObject. The default argument remains PyObject;
and this necessitated renaming uses of "gdbpy_ref" to "gdbpy_ref<>".
gdb/ChangeLog
2017-02-10 Tom Tromey <tom@tromey.com>
* python/py-ref.h (gdbpy_ref_policy): Now a template.
(gdbpy_ref): Now a template; allow subclasses of PyObject to be
used.
* python/py-arch.c, python/py-bpevent.c, python/py-breakpoint.c,
python/py-cmd.c, python/py-continueevent.c, python/py-event.c,
python/py-exitedevent.c, python/py-finishbreakpoint.c,
python/py-framefilter.c, python/py-function.c,
python/py-inferior.c, python/py-infevents.c,
python/py-linetable.c, python/py-newobjfileevent.c,
python/py-param.c, python/py-prettyprint.c, python/py-ref.h,
python/py-signalevent.c, python/py-stopevent.c,
python/py-symbol.c, python/py-threadevent.c, python/py-type.c,
python/py-unwind.c, python/py-utils.c, python/py-value.c,
python/py-varobj.c, python/py-xmethods.c, python/python.c,
varobj.c: Change gdbpy_ref to gdbpy_ref<>.
2017-02-09 21:16:36 +01:00
|
|
|
gdbpy_ref<> get_arg_types_method
|
2016-11-08 23:47:39 +01:00
|
|
|
(PyObject_GetAttrString (py_worker, get_arg_types_method_name));
|
2014-05-20 15:53:04 +02:00
|
|
|
if (get_arg_types_method == NULL)
|
|
|
|
{
|
|
|
|
gdbpy_print_stack ();
|
|
|
|
return EXT_LANG_RC_ERROR;
|
|
|
|
}
|
|
|
|
|
Turn gdbpy_ref into a template
This turns gdbpy_ref into a template class, so that it can be used to
wrap subclasses of PyObject. The default argument remains PyObject;
and this necessitated renaming uses of "gdbpy_ref" to "gdbpy_ref<>".
gdb/ChangeLog
2017-02-10 Tom Tromey <tom@tromey.com>
* python/py-ref.h (gdbpy_ref_policy): Now a template.
(gdbpy_ref): Now a template; allow subclasses of PyObject to be
used.
* python/py-arch.c, python/py-bpevent.c, python/py-breakpoint.c,
python/py-cmd.c, python/py-continueevent.c, python/py-event.c,
python/py-exitedevent.c, python/py-finishbreakpoint.c,
python/py-framefilter.c, python/py-function.c,
python/py-inferior.c, python/py-infevents.c,
python/py-linetable.c, python/py-newobjfileevent.c,
python/py-param.c, python/py-prettyprint.c, python/py-ref.h,
python/py-signalevent.c, python/py-stopevent.c,
python/py-symbol.c, python/py-threadevent.c, python/py-type.c,
python/py-unwind.c, python/py-utils.c, python/py-value.c,
python/py-varobj.c, python/py-xmethods.c, python/python.c,
varobj.c: Change gdbpy_ref to gdbpy_ref<>.
2017-02-09 21:16:36 +01:00
|
|
|
gdbpy_ref<> py_argtype_list
|
2016-11-08 23:47:39 +01:00
|
|
|
(PyObject_CallMethodObjArgs (py_worker, py_get_arg_types_method_name,
|
|
|
|
NULL));
|
2014-05-20 15:53:04 +02:00
|
|
|
if (py_argtype_list == NULL)
|
|
|
|
{
|
|
|
|
gdbpy_print_stack ();
|
|
|
|
return EXT_LANG_RC_ERROR;
|
|
|
|
}
|
2016-11-08 23:47:39 +01:00
|
|
|
|
2014-05-20 15:53:04 +02:00
|
|
|
if (py_argtype_list == Py_None)
|
|
|
|
arg_count = 0;
|
2016-11-08 23:47:39 +01:00
|
|
|
else if (PySequence_Check (py_argtype_list.get ()))
|
2014-05-20 15:53:04 +02:00
|
|
|
{
|
2016-11-08 23:47:39 +01:00
|
|
|
arg_count = PySequence_Size (py_argtype_list.get ());
|
2014-05-20 15:53:04 +02:00
|
|
|
if (arg_count == -1)
|
|
|
|
{
|
|
|
|
gdbpy_print_stack ();
|
|
|
|
return EXT_LANG_RC_ERROR;
|
|
|
|
}
|
|
|
|
|
2016-11-08 23:47:39 +01:00
|
|
|
list_iter.reset (PyObject_GetIter (py_argtype_list.get ()));
|
2014-05-20 15:53:04 +02:00
|
|
|
if (list_iter == NULL)
|
|
|
|
{
|
|
|
|
gdbpy_print_stack ();
|
|
|
|
return EXT_LANG_RC_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
arg_count = 1;
|
|
|
|
|
|
|
|
/* Include the 'this' argument in the size. */
|
2016-11-08 23:47:39 +01:00
|
|
|
gdb::unique_xmalloc_ptr<struct type *> type_array
|
|
|
|
(XCNEWVEC (struct type *, arg_count + 1));
|
2014-05-20 15:53:04 +02:00
|
|
|
i = 1;
|
|
|
|
if (list_iter != NULL)
|
|
|
|
{
|
2016-11-08 23:47:39 +01:00
|
|
|
while (true)
|
2014-05-20 15:53:04 +02:00
|
|
|
{
|
Turn gdbpy_ref into a template
This turns gdbpy_ref into a template class, so that it can be used to
wrap subclasses of PyObject. The default argument remains PyObject;
and this necessitated renaming uses of "gdbpy_ref" to "gdbpy_ref<>".
gdb/ChangeLog
2017-02-10 Tom Tromey <tom@tromey.com>
* python/py-ref.h (gdbpy_ref_policy): Now a template.
(gdbpy_ref): Now a template; allow subclasses of PyObject to be
used.
* python/py-arch.c, python/py-bpevent.c, python/py-breakpoint.c,
python/py-cmd.c, python/py-continueevent.c, python/py-event.c,
python/py-exitedevent.c, python/py-finishbreakpoint.c,
python/py-framefilter.c, python/py-function.c,
python/py-inferior.c, python/py-infevents.c,
python/py-linetable.c, python/py-newobjfileevent.c,
python/py-param.c, python/py-prettyprint.c, python/py-ref.h,
python/py-signalevent.c, python/py-stopevent.c,
python/py-symbol.c, python/py-threadevent.c, python/py-type.c,
python/py-unwind.c, python/py-utils.c, python/py-value.c,
python/py-varobj.c, python/py-xmethods.c, python/python.c,
varobj.c: Change gdbpy_ref to gdbpy_ref<>.
2017-02-09 21:16:36 +01:00
|
|
|
gdbpy_ref<> item (PyIter_Next (list_iter.get ()));
|
2016-11-08 23:47:39 +01:00
|
|
|
if (item == NULL)
|
|
|
|
{
|
|
|
|
if (PyErr_Occurred ())
|
|
|
|
{
|
|
|
|
gdbpy_print_stack ();
|
|
|
|
return EXT_LANG_RC_ERROR;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2014-05-20 15:53:04 +02:00
|
|
|
|
2016-11-08 23:47:39 +01:00
|
|
|
struct type *arg_type = type_object_to_type (item.get ());
|
2014-05-20 15:53:04 +02:00
|
|
|
if (arg_type == NULL)
|
|
|
|
{
|
|
|
|
PyErr_SetString (PyExc_TypeError,
|
|
|
|
_("Arg type returned by the get_arg_types "
|
|
|
|
"method of a debug method worker object is "
|
|
|
|
"not a gdb.Type object."));
|
2016-11-08 23:47:39 +01:00
|
|
|
return EXT_LANG_RC_ERROR;
|
2014-05-20 15:53:04 +02:00
|
|
|
}
|
|
|
|
|
2016-11-08 23:47:39 +01:00
|
|
|
(type_array.get ())[i] = arg_type;
|
2014-05-20 15:53:04 +02:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (arg_count == 1)
|
|
|
|
{
|
|
|
|
/* py_argtype_list is not actually a list but a single gdb.Type
|
|
|
|
object. */
|
2016-11-08 23:47:39 +01:00
|
|
|
struct type *arg_type = type_object_to_type (py_argtype_list.get ());
|
2014-05-20 15:53:04 +02:00
|
|
|
|
|
|
|
if (arg_type == NULL)
|
|
|
|
{
|
|
|
|
PyErr_SetString (PyExc_TypeError,
|
|
|
|
_("Arg type returned by the get_arg_types method "
|
|
|
|
"of an xmethod worker object is not a gdb.Type "
|
|
|
|
"object."));
|
2016-11-08 23:47:39 +01:00
|
|
|
return EXT_LANG_RC_ERROR;
|
2014-05-20 15:53:04 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-11-08 23:47:39 +01:00
|
|
|
(type_array.get ())[i] = arg_type;
|
2014-05-20 15:53:04 +02:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add the type of 'this' as the first argument. The 'this' pointer should
|
|
|
|
be a 'const' value. Hence, create a 'const' variant of the 'this' pointer
|
|
|
|
type. */
|
|
|
|
obj_type = type_object_to_type (worker_data->this_type);
|
2016-11-08 23:47:39 +01:00
|
|
|
(type_array.get ())[0] = make_cv_type (1, 0, lookup_pointer_type (obj_type),
|
|
|
|
NULL);
|
2014-05-20 15:53:04 +02:00
|
|
|
*nargs = i;
|
2016-11-08 23:47:39 +01:00
|
|
|
*arg_types = type_array.release ();
|
2014-05-20 15:53:04 +02:00
|
|
|
|
|
|
|
return EXT_LANG_RC_OK;
|
|
|
|
}
|
|
|
|
|
2015-04-29 22:24:21 +02:00
|
|
|
/* Implementation of get_xmethod_result_type for Python. */
|
|
|
|
|
|
|
|
enum ext_lang_rc
|
|
|
|
gdbpy_get_xmethod_result_type (const struct extension_language_defn *extlang,
|
|
|
|
struct xmethod_worker *worker,
|
|
|
|
struct value *obj,
|
|
|
|
struct value **args, int nargs,
|
|
|
|
struct type **result_type_ptr)
|
|
|
|
{
|
2015-09-25 20:08:07 +02:00
|
|
|
struct gdbpy_worker_data *worker_data
|
|
|
|
= (struct gdbpy_worker_data *) worker->data;
|
2015-04-29 22:24:21 +02:00
|
|
|
PyObject *py_worker = worker_data->worker;
|
|
|
|
struct type *obj_type, *this_type;
|
|
|
|
int i;
|
|
|
|
|
2016-11-08 23:47:39 +01:00
|
|
|
gdbpy_enter enter_py (get_current_arch (), current_language);
|
2015-04-29 22:24:21 +02:00
|
|
|
|
|
|
|
/* First see if there is a get_result_type method.
|
|
|
|
If not this could be an old xmethod (pre 7.9.1). */
|
Turn gdbpy_ref into a template
This turns gdbpy_ref into a template class, so that it can be used to
wrap subclasses of PyObject. The default argument remains PyObject;
and this necessitated renaming uses of "gdbpy_ref" to "gdbpy_ref<>".
gdb/ChangeLog
2017-02-10 Tom Tromey <tom@tromey.com>
* python/py-ref.h (gdbpy_ref_policy): Now a template.
(gdbpy_ref): Now a template; allow subclasses of PyObject to be
used.
* python/py-arch.c, python/py-bpevent.c, python/py-breakpoint.c,
python/py-cmd.c, python/py-continueevent.c, python/py-event.c,
python/py-exitedevent.c, python/py-finishbreakpoint.c,
python/py-framefilter.c, python/py-function.c,
python/py-inferior.c, python/py-infevents.c,
python/py-linetable.c, python/py-newobjfileevent.c,
python/py-param.c, python/py-prettyprint.c, python/py-ref.h,
python/py-signalevent.c, python/py-stopevent.c,
python/py-symbol.c, python/py-threadevent.c, python/py-type.c,
python/py-unwind.c, python/py-utils.c, python/py-value.c,
python/py-varobj.c, python/py-xmethods.c, python/python.c,
varobj.c: Change gdbpy_ref to gdbpy_ref<>.
2017-02-09 21:16:36 +01:00
|
|
|
gdbpy_ref<> get_result_type_method
|
2016-11-08 23:47:39 +01:00
|
|
|
(PyObject_GetAttrString (py_worker, get_result_type_method_name));
|
2015-04-29 22:24:21 +02:00
|
|
|
if (get_result_type_method == NULL)
|
|
|
|
{
|
|
|
|
PyErr_Clear ();
|
|
|
|
*result_type_ptr = NULL;
|
|
|
|
return EXT_LANG_RC_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
obj_type = check_typedef (value_type (obj));
|
|
|
|
this_type = check_typedef (type_object_to_type (worker_data->this_type));
|
|
|
|
if (TYPE_CODE (obj_type) == TYPE_CODE_PTR)
|
|
|
|
{
|
|
|
|
struct type *this_ptr = lookup_pointer_type (this_type);
|
|
|
|
|
|
|
|
if (!types_equal (obj_type, this_ptr))
|
|
|
|
obj = value_cast (this_ptr, obj);
|
|
|
|
}
|
|
|
|
else if (TYPE_CODE (obj_type) == TYPE_CODE_REF)
|
|
|
|
{
|
|
|
|
struct type *this_ref = lookup_reference_type (this_type);
|
|
|
|
|
|
|
|
if (!types_equal (obj_type, this_ref))
|
|
|
|
obj = value_cast (this_ref, obj);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!types_equal (obj_type, this_type))
|
|
|
|
obj = value_cast (this_type, obj);
|
|
|
|
}
|
Turn gdbpy_ref into a template
This turns gdbpy_ref into a template class, so that it can be used to
wrap subclasses of PyObject. The default argument remains PyObject;
and this necessitated renaming uses of "gdbpy_ref" to "gdbpy_ref<>".
gdb/ChangeLog
2017-02-10 Tom Tromey <tom@tromey.com>
* python/py-ref.h (gdbpy_ref_policy): Now a template.
(gdbpy_ref): Now a template; allow subclasses of PyObject to be
used.
* python/py-arch.c, python/py-bpevent.c, python/py-breakpoint.c,
python/py-cmd.c, python/py-continueevent.c, python/py-event.c,
python/py-exitedevent.c, python/py-finishbreakpoint.c,
python/py-framefilter.c, python/py-function.c,
python/py-inferior.c, python/py-infevents.c,
python/py-linetable.c, python/py-newobjfileevent.c,
python/py-param.c, python/py-prettyprint.c, python/py-ref.h,
python/py-signalevent.c, python/py-stopevent.c,
python/py-symbol.c, python/py-threadevent.c, python/py-type.c,
python/py-unwind.c, python/py-utils.c, python/py-value.c,
python/py-varobj.c, python/py-xmethods.c, python/python.c,
varobj.c: Change gdbpy_ref to gdbpy_ref<>.
2017-02-09 21:16:36 +01:00
|
|
|
gdbpy_ref<> py_value_obj (value_to_value_object (obj));
|
2015-04-29 22:24:21 +02:00
|
|
|
if (py_value_obj == NULL)
|
2016-11-08 23:47:39 +01:00
|
|
|
{
|
|
|
|
gdbpy_print_stack ();
|
|
|
|
return EXT_LANG_RC_ERROR;
|
|
|
|
}
|
2015-04-29 22:24:21 +02:00
|
|
|
|
Turn gdbpy_ref into a template
This turns gdbpy_ref into a template class, so that it can be used to
wrap subclasses of PyObject. The default argument remains PyObject;
and this necessitated renaming uses of "gdbpy_ref" to "gdbpy_ref<>".
gdb/ChangeLog
2017-02-10 Tom Tromey <tom@tromey.com>
* python/py-ref.h (gdbpy_ref_policy): Now a template.
(gdbpy_ref): Now a template; allow subclasses of PyObject to be
used.
* python/py-arch.c, python/py-bpevent.c, python/py-breakpoint.c,
python/py-cmd.c, python/py-continueevent.c, python/py-event.c,
python/py-exitedevent.c, python/py-finishbreakpoint.c,
python/py-framefilter.c, python/py-function.c,
python/py-inferior.c, python/py-infevents.c,
python/py-linetable.c, python/py-newobjfileevent.c,
python/py-param.c, python/py-prettyprint.c, python/py-ref.h,
python/py-signalevent.c, python/py-stopevent.c,
python/py-symbol.c, python/py-threadevent.c, python/py-type.c,
python/py-unwind.c, python/py-utils.c, python/py-value.c,
python/py-varobj.c, python/py-xmethods.c, python/python.c,
varobj.c: Change gdbpy_ref to gdbpy_ref<>.
2017-02-09 21:16:36 +01:00
|
|
|
gdbpy_ref<> py_arg_tuple (PyTuple_New (nargs + 1));
|
2015-04-29 22:24:21 +02:00
|
|
|
if (py_arg_tuple == NULL)
|
2016-11-08 23:47:39 +01:00
|
|
|
{
|
|
|
|
gdbpy_print_stack ();
|
|
|
|
return EXT_LANG_RC_ERROR;
|
|
|
|
}
|
2015-04-29 22:24:21 +02:00
|
|
|
|
2016-11-08 23:47:39 +01:00
|
|
|
/* PyTuple_SET_ITEM steals the reference of the element, hence the
|
|
|
|
release. */
|
|
|
|
PyTuple_SET_ITEM (py_arg_tuple.get (), 0, py_value_obj.release ());
|
2015-04-29 22:24:21 +02:00
|
|
|
|
|
|
|
for (i = 0; i < nargs; i++)
|
|
|
|
{
|
|
|
|
PyObject *py_value_arg = value_to_value_object (args[i]);
|
|
|
|
|
|
|
|
if (py_value_arg == NULL)
|
2016-11-08 23:47:39 +01:00
|
|
|
{
|
|
|
|
gdbpy_print_stack ();
|
|
|
|
return EXT_LANG_RC_ERROR;
|
|
|
|
}
|
|
|
|
PyTuple_SET_ITEM (py_arg_tuple.get (), i + 1, py_value_arg);
|
2015-04-29 22:24:21 +02:00
|
|
|
}
|
|
|
|
|
Turn gdbpy_ref into a template
This turns gdbpy_ref into a template class, so that it can be used to
wrap subclasses of PyObject. The default argument remains PyObject;
and this necessitated renaming uses of "gdbpy_ref" to "gdbpy_ref<>".
gdb/ChangeLog
2017-02-10 Tom Tromey <tom@tromey.com>
* python/py-ref.h (gdbpy_ref_policy): Now a template.
(gdbpy_ref): Now a template; allow subclasses of PyObject to be
used.
* python/py-arch.c, python/py-bpevent.c, python/py-breakpoint.c,
python/py-cmd.c, python/py-continueevent.c, python/py-event.c,
python/py-exitedevent.c, python/py-finishbreakpoint.c,
python/py-framefilter.c, python/py-function.c,
python/py-inferior.c, python/py-infevents.c,
python/py-linetable.c, python/py-newobjfileevent.c,
python/py-param.c, python/py-prettyprint.c, python/py-ref.h,
python/py-signalevent.c, python/py-stopevent.c,
python/py-symbol.c, python/py-threadevent.c, python/py-type.c,
python/py-unwind.c, python/py-utils.c, python/py-value.c,
python/py-varobj.c, python/py-xmethods.c, python/python.c,
varobj.c: Change gdbpy_ref to gdbpy_ref<>.
2017-02-09 21:16:36 +01:00
|
|
|
gdbpy_ref<> py_result_type
|
2016-11-08 23:47:39 +01:00
|
|
|
(PyObject_CallObject (get_result_type_method.get (), py_arg_tuple.get ()));
|
2015-04-29 22:24:21 +02:00
|
|
|
if (py_result_type == NULL)
|
2016-11-08 23:47:39 +01:00
|
|
|
{
|
|
|
|
gdbpy_print_stack ();
|
|
|
|
return EXT_LANG_RC_ERROR;
|
|
|
|
}
|
2015-04-29 22:24:21 +02:00
|
|
|
|
2016-11-08 23:47:39 +01:00
|
|
|
*result_type_ptr = type_object_to_type (py_result_type.get ());
|
2015-04-29 22:24:21 +02:00
|
|
|
if (*result_type_ptr == NULL)
|
|
|
|
{
|
|
|
|
PyErr_SetString (PyExc_TypeError,
|
|
|
|
_("Type returned by the get_result_type method of an"
|
|
|
|
" xmethod worker object is not a gdb.Type object."));
|
2016-11-08 23:47:39 +01:00
|
|
|
gdbpy_print_stack ();
|
|
|
|
return EXT_LANG_RC_ERROR;
|
2015-04-29 22:24:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return EXT_LANG_RC_OK;
|
|
|
|
}
|
|
|
|
|
2014-05-20 15:53:04 +02:00
|
|
|
/* Implementation of invoke_xmethod for Python. */
|
|
|
|
|
|
|
|
struct value *
|
|
|
|
gdbpy_invoke_xmethod (const struct extension_language_defn *extlang,
|
|
|
|
struct xmethod_worker *worker,
|
|
|
|
struct value *obj, struct value **args, int nargs)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
struct type *obj_type, *this_type;
|
|
|
|
struct value *res = NULL;
|
2015-09-25 20:08:07 +02:00
|
|
|
struct gdbpy_worker_data *worker_data
|
|
|
|
= (struct gdbpy_worker_data *) worker->data;
|
2014-05-20 15:53:04 +02:00
|
|
|
PyObject *xmethod_worker = worker_data->worker;
|
|
|
|
|
2016-11-08 23:47:39 +01:00
|
|
|
gdbpy_enter enter_py (get_current_arch (), current_language);
|
2014-05-20 15:53:04 +02:00
|
|
|
|
|
|
|
obj_type = check_typedef (value_type (obj));
|
|
|
|
this_type = check_typedef (type_object_to_type (worker_data->this_type));
|
|
|
|
if (TYPE_CODE (obj_type) == TYPE_CODE_PTR)
|
|
|
|
{
|
|
|
|
struct type *this_ptr = lookup_pointer_type (this_type);
|
|
|
|
|
|
|
|
if (!types_equal (obj_type, this_ptr))
|
|
|
|
obj = value_cast (this_ptr, obj);
|
|
|
|
}
|
|
|
|
else if (TYPE_CODE (obj_type) == TYPE_CODE_REF)
|
|
|
|
{
|
|
|
|
struct type *this_ref = lookup_reference_type (this_type);
|
|
|
|
|
|
|
|
if (!types_equal (obj_type, this_ref))
|
|
|
|
obj = value_cast (this_ref, obj);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!types_equal (obj_type, this_type))
|
|
|
|
obj = value_cast (this_type, obj);
|
|
|
|
}
|
Turn gdbpy_ref into a template
This turns gdbpy_ref into a template class, so that it can be used to
wrap subclasses of PyObject. The default argument remains PyObject;
and this necessitated renaming uses of "gdbpy_ref" to "gdbpy_ref<>".
gdb/ChangeLog
2017-02-10 Tom Tromey <tom@tromey.com>
* python/py-ref.h (gdbpy_ref_policy): Now a template.
(gdbpy_ref): Now a template; allow subclasses of PyObject to be
used.
* python/py-arch.c, python/py-bpevent.c, python/py-breakpoint.c,
python/py-cmd.c, python/py-continueevent.c, python/py-event.c,
python/py-exitedevent.c, python/py-finishbreakpoint.c,
python/py-framefilter.c, python/py-function.c,
python/py-inferior.c, python/py-infevents.c,
python/py-linetable.c, python/py-newobjfileevent.c,
python/py-param.c, python/py-prettyprint.c, python/py-ref.h,
python/py-signalevent.c, python/py-stopevent.c,
python/py-symbol.c, python/py-threadevent.c, python/py-type.c,
python/py-unwind.c, python/py-utils.c, python/py-value.c,
python/py-varobj.c, python/py-xmethods.c, python/python.c,
varobj.c: Change gdbpy_ref to gdbpy_ref<>.
2017-02-09 21:16:36 +01:00
|
|
|
gdbpy_ref<> py_value_obj (value_to_value_object (obj));
|
2014-05-20 15:53:04 +02:00
|
|
|
if (py_value_obj == NULL)
|
|
|
|
{
|
|
|
|
gdbpy_print_stack ();
|
|
|
|
error (_("Error while executing Python code."));
|
|
|
|
}
|
|
|
|
|
Turn gdbpy_ref into a template
This turns gdbpy_ref into a template class, so that it can be used to
wrap subclasses of PyObject. The default argument remains PyObject;
and this necessitated renaming uses of "gdbpy_ref" to "gdbpy_ref<>".
gdb/ChangeLog
2017-02-10 Tom Tromey <tom@tromey.com>
* python/py-ref.h (gdbpy_ref_policy): Now a template.
(gdbpy_ref): Now a template; allow subclasses of PyObject to be
used.
* python/py-arch.c, python/py-bpevent.c, python/py-breakpoint.c,
python/py-cmd.c, python/py-continueevent.c, python/py-event.c,
python/py-exitedevent.c, python/py-finishbreakpoint.c,
python/py-framefilter.c, python/py-function.c,
python/py-inferior.c, python/py-infevents.c,
python/py-linetable.c, python/py-newobjfileevent.c,
python/py-param.c, python/py-prettyprint.c, python/py-ref.h,
python/py-signalevent.c, python/py-stopevent.c,
python/py-symbol.c, python/py-threadevent.c, python/py-type.c,
python/py-unwind.c, python/py-utils.c, python/py-value.c,
python/py-varobj.c, python/py-xmethods.c, python/python.c,
varobj.c: Change gdbpy_ref to gdbpy_ref<>.
2017-02-09 21:16:36 +01:00
|
|
|
gdbpy_ref<> py_arg_tuple (PyTuple_New (nargs + 1));
|
2014-05-20 15:53:04 +02:00
|
|
|
if (py_arg_tuple == NULL)
|
|
|
|
{
|
|
|
|
gdbpy_print_stack ();
|
|
|
|
error (_("Error while executing Python code."));
|
|
|
|
}
|
|
|
|
|
2016-11-08 23:47:39 +01:00
|
|
|
/* PyTuple_SET_ITEM steals the reference of the element, hence the
|
|
|
|
release. */
|
|
|
|
PyTuple_SET_ITEM (py_arg_tuple.get (), 0, py_value_obj.release ());
|
2014-05-20 15:53:04 +02:00
|
|
|
|
|
|
|
for (i = 0; i < nargs; i++)
|
|
|
|
{
|
|
|
|
PyObject *py_value_arg = value_to_value_object (args[i]);
|
|
|
|
|
|
|
|
if (py_value_arg == NULL)
|
|
|
|
{
|
|
|
|
gdbpy_print_stack ();
|
|
|
|
error (_("Error while executing Python code."));
|
|
|
|
}
|
|
|
|
|
2016-11-08 23:47:39 +01:00
|
|
|
PyTuple_SET_ITEM (py_arg_tuple.get (), i + 1, py_value_arg);
|
2014-05-20 15:53:04 +02:00
|
|
|
}
|
|
|
|
|
Turn gdbpy_ref into a template
This turns gdbpy_ref into a template class, so that it can be used to
wrap subclasses of PyObject. The default argument remains PyObject;
and this necessitated renaming uses of "gdbpy_ref" to "gdbpy_ref<>".
gdb/ChangeLog
2017-02-10 Tom Tromey <tom@tromey.com>
* python/py-ref.h (gdbpy_ref_policy): Now a template.
(gdbpy_ref): Now a template; allow subclasses of PyObject to be
used.
* python/py-arch.c, python/py-bpevent.c, python/py-breakpoint.c,
python/py-cmd.c, python/py-continueevent.c, python/py-event.c,
python/py-exitedevent.c, python/py-finishbreakpoint.c,
python/py-framefilter.c, python/py-function.c,
python/py-inferior.c, python/py-infevents.c,
python/py-linetable.c, python/py-newobjfileevent.c,
python/py-param.c, python/py-prettyprint.c, python/py-ref.h,
python/py-signalevent.c, python/py-stopevent.c,
python/py-symbol.c, python/py-threadevent.c, python/py-type.c,
python/py-unwind.c, python/py-utils.c, python/py-value.c,
python/py-varobj.c, python/py-xmethods.c, python/python.c,
varobj.c: Change gdbpy_ref to gdbpy_ref<>.
2017-02-09 21:16:36 +01:00
|
|
|
gdbpy_ref<> py_result (PyObject_CallObject (xmethod_worker,
|
|
|
|
py_arg_tuple.get ()));
|
2014-05-20 15:53:04 +02:00
|
|
|
if (py_result == NULL)
|
|
|
|
{
|
|
|
|
gdbpy_print_stack ();
|
|
|
|
error (_("Error while executing Python code."));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (py_result != Py_None)
|
|
|
|
{
|
2016-11-08 23:47:39 +01:00
|
|
|
res = convert_value_from_python (py_result.get ());
|
2014-05-20 15:53:04 +02:00
|
|
|
if (res == NULL)
|
|
|
|
{
|
|
|
|
gdbpy_print_stack ();
|
|
|
|
error (_("Error while executing Python code."));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
res = allocate_value (lookup_typename (python_language, python_gdbarch,
|
|
|
|
"void", NULL, 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Creates a new Python xmethod_worker object.
|
|
|
|
The new object has data of type 'struct gdbpy_worker_data' composed
|
|
|
|
with the components PY_WORKER and THIS_TYPE. */
|
|
|
|
|
|
|
|
static struct xmethod_worker *
|
|
|
|
new_python_xmethod_worker (PyObject *py_worker, PyObject *this_type)
|
|
|
|
{
|
|
|
|
struct gdbpy_worker_data *data;
|
|
|
|
|
|
|
|
gdb_assert (py_worker != NULL && this_type != NULL);
|
|
|
|
|
|
|
|
data = XCNEW (struct gdbpy_worker_data);
|
|
|
|
data->worker = py_worker;
|
|
|
|
data->this_type = this_type;
|
|
|
|
Py_INCREF (py_worker);
|
|
|
|
Py_INCREF (this_type);
|
|
|
|
|
|
|
|
return new_xmethod_worker (&extension_language_python, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
gdbpy_initialize_xmethods (void)
|
|
|
|
{
|
|
|
|
py_match_method_name = PyString_FromString (match_method_name);
|
|
|
|
if (py_match_method_name == NULL)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
py_get_arg_types_method_name
|
|
|
|
= PyString_FromString (get_arg_types_method_name);
|
|
|
|
if (py_get_arg_types_method_name == NULL)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|