GDB (xrefs)
py-xmethods.c
Go to the documentation of this file.
1 /* Support for debug methods in Python.
2 
3  Copyright (C) 2013-2015 Free Software Foundation, Inc.
4 
5  This file is part of GDB.
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 3 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 
20 #include "defs.h"
21 #include "arch-utils.h"
22 #include "extension-priv.h"
23 #include "objfiles.h"
24 #include "value.h"
25 #include "language.h"
26 
27 #include "python.h"
28 #include "python-internal.h"
29 
30 static const char enabled_field_name[] = "enabled";
31 static const char match_method_name[] = "match";
32 static const char get_arg_types_method_name[] = "get_arg_types";
33 static const char get_result_type_method_name[] = "get_result_type";
34 static const char invoke_method_name[] = "invoke";
35 static const char matchers_attr_str[] = "xmethods";
36 
37 static PyObject *py_match_method_name = NULL;
38 static PyObject *py_get_arg_types_method_name = NULL;
39 static PyObject *py_get_result_type_method_name = NULL;
40 static PyObject *py_invoke_method_name = NULL;
41 
43 {
44  PyObject *worker;
45  PyObject *this_type;
46 };
47 
48 static struct xmethod_worker *new_python_xmethod_worker (PyObject *item,
49  PyObject *py_obj_type);
50 
51 /* Implementation of free_xmethod_worker_data for Python. */
52 
53 void
55  void *data)
56 {
57  struct gdbpy_worker_data *worker_data = data;
58  struct cleanup *cleanups;
59 
60  gdb_assert (worker_data->worker != NULL && worker_data->this_type != NULL);
61 
62  /* We don't do much here, but we still need the GIL. */
64 
65  Py_DECREF (worker_data->worker);
66  Py_DECREF (worker_data->this_type);
67  xfree (worker_data);
68 
69  do_cleanups (cleanups);
70 }
71 
72 /* Implementation of clone_xmethod_worker_data for Python. */
73 
74 void *
76  void *data)
77 {
78  struct gdbpy_worker_data *worker_data = data, *new_data;
79  struct cleanup *cleanups;
80 
81  gdb_assert (worker_data->worker != NULL && worker_data->this_type != NULL);
82 
83  /* We don't do much here, but we still need the GIL. */
85 
86  new_data = XCNEW (struct gdbpy_worker_data);
87  new_data->worker = worker_data->worker;
88  new_data->this_type = worker_data->this_type;
89  Py_INCREF (new_data->worker);
90  Py_INCREF (new_data->this_type);
91 
92  do_cleanups (cleanups);
93 
94  return new_data;
95 }
96 
97 /* Invoke the "match" method of the MATCHER and return a new reference
98  to the result. Returns NULL on error. */
99 
100 static PyObject *
101 invoke_match_method (PyObject *matcher, PyObject *py_obj_type,
102  const char *xmethod_name)
103 {
104  PyObject *py_xmethod_name;
105  PyObject *match_method, *enabled_field, *match_result;
106  struct cleanup *cleanups;
107  int enabled;
108 
109  cleanups = make_cleanup (null_cleanup, NULL);
110 
111  enabled_field = PyObject_GetAttrString (matcher, enabled_field_name);
112  if (enabled_field == NULL)
113  {
114  do_cleanups (cleanups);
115  return NULL;
116  }
117  make_cleanup_py_decref (enabled_field);
118 
119  enabled = PyObject_IsTrue (enabled_field);
120  if (enabled == -1)
121  {
122  do_cleanups (cleanups);
123  return NULL;
124  }
125  if (enabled == 0)
126  {
127  /* Return 'None' if the matcher is not enabled. */
128  do_cleanups (cleanups);
129  Py_RETURN_NONE;
130  }
131 
132  match_method = PyObject_GetAttrString (matcher, match_method_name);
133  if (match_method == NULL)
134  {
135  do_cleanups (cleanups);
136  return NULL;
137  }
138  make_cleanup_py_decref (match_method);
139 
140  py_xmethod_name = PyString_FromString (xmethod_name);
141  if (py_xmethod_name == NULL)
142  {
143  do_cleanups (cleanups);
144  return NULL;
145  }
146  make_cleanup_py_decref (py_xmethod_name);
147 
148  match_result = PyObject_CallMethodObjArgs (matcher,
149  py_match_method_name,
150  py_obj_type,
151  py_xmethod_name,
152  NULL);
153 
154  do_cleanups (cleanups);
155 
156  return match_result;
157 }
158 
159 /* Implementation of get_matching_xmethod_workers for Python. */
160 
161 enum ext_lang_rc
163  (const struct extension_language_defn *extlang,
164  struct type *obj_type, const char *method_name,
165  xmethod_worker_vec **dm_vec)
166 {
167  struct cleanup *cleanups;
168  struct objfile *objfile;
169  VEC (xmethod_worker_ptr) *worker_vec = NULL;
170  PyObject *py_type, *py_progspace;
171  PyObject *py_xmethod_matcher_list = NULL, *list_iter, *matcher;
172 
173  gdb_assert (obj_type != NULL && method_name != NULL);
174 
176 
177  py_type = type_to_type_object (obj_type);
178  if (py_type == NULL)
179  {
181  do_cleanups (cleanups);
182 
183  return EXT_LANG_RC_ERROR;
184  }
185  make_cleanup_py_decref (py_type);
186 
187  /* Create an empty list of debug methods. */
188  py_xmethod_matcher_list = PyList_New (0);
189  if (py_xmethod_matcher_list == NULL)
190  {
192  do_cleanups (cleanups);
193 
194  return EXT_LANG_RC_ERROR;
195  }
196 
197  /* Gather debug method matchers registered with the object files.
198  This could be done differently by iterating over each objfile's matcher
199  list individually, but there's no data yet to show it's needed. */
200  ALL_OBJFILES (objfile)
201  {
202  PyObject *py_objfile = objfile_to_objfile_object (objfile);
203  PyObject *objfile_matchers, *temp = py_xmethod_matcher_list;
204 
205  if (py_objfile == NULL)
206  {
208  Py_DECREF (py_xmethod_matcher_list);
209  do_cleanups (cleanups);
210 
211  return EXT_LANG_RC_ERROR;
212  }
213 
214  objfile_matchers = objfpy_get_xmethods (py_objfile, NULL);
215  py_xmethod_matcher_list = PySequence_Concat (temp, objfile_matchers);
216  Py_DECREF (temp);
217  Py_DECREF (objfile_matchers);
218  if (py_xmethod_matcher_list == NULL)
219  {
221  do_cleanups (cleanups);
222 
223  return EXT_LANG_RC_ERROR;
224  }
225  }
226 
227  /* Gather debug methods matchers registered with the current program
228  space. */
230  if (py_progspace != NULL)
231  {
232  PyObject *temp = py_xmethod_matcher_list;
233  PyObject *pspace_matchers = pspy_get_xmethods (py_progspace, NULL);
234 
235  py_xmethod_matcher_list = PySequence_Concat (temp, pspace_matchers);
236  Py_DECREF (temp);
237  Py_DECREF (pspace_matchers);
238  if (py_xmethod_matcher_list == NULL)
239  {
241  do_cleanups (cleanups);
242 
243  return EXT_LANG_RC_ERROR;
244  }
245  }
246  else
247  {
249  Py_DECREF (py_xmethod_matcher_list);
250  do_cleanups (cleanups);
251 
252  return EXT_LANG_RC_ERROR;
253  }
254 
255  /* Gather debug method matchers registered globally. */
256  if (gdb_python_module != NULL
257  && PyObject_HasAttrString (gdb_python_module, matchers_attr_str))
258  {
259  PyObject *gdb_matchers;
260  PyObject *temp = py_xmethod_matcher_list;
261 
263  matchers_attr_str);
264  if (gdb_matchers != NULL)
265  {
266  py_xmethod_matcher_list = PySequence_Concat (temp, gdb_matchers);
267  Py_DECREF (temp);
268  Py_DECREF (gdb_matchers);
269  if (py_xmethod_matcher_list == NULL)
270  {
272  do_cleanups (cleanups);
273 
274  return EXT_LANG_RC_ERROR;
275  }
276  }
277  else
278  {
280  Py_DECREF (py_xmethod_matcher_list);
281  do_cleanups (cleanups);
282 
283  return EXT_LANG_RC_ERROR;
284  }
285  }
286 
287  /* Safe to make a cleanup for py_xmethod_matcher_list now as it
288  will not change any more. */
289  make_cleanup_py_decref (py_xmethod_matcher_list);
290 
291  list_iter = PyObject_GetIter (py_xmethod_matcher_list);
292  if (list_iter == NULL)
293  {
295  do_cleanups (cleanups);
296 
297  return EXT_LANG_RC_ERROR;
298  }
299  while ((matcher = PyIter_Next (list_iter)) != NULL)
300  {
301  PyObject *match_result = invoke_match_method (matcher, py_type,
302  method_name);
303 
304  if (match_result == NULL)
305  {
307  Py_DECREF (matcher);
308  do_cleanups (cleanups);
309 
310  return EXT_LANG_RC_ERROR;
311  }
312  if (match_result == Py_None)
313  ; /* This means there was no match. */
314  else if (PySequence_Check (match_result))
315  {
316  PyObject *iter = PyObject_GetIter (match_result);
317  PyObject *py_worker;
318 
319  if (iter == NULL)
320  {
322  Py_DECREF (matcher);
323  Py_DECREF (match_result);
324  do_cleanups (cleanups);
325 
326  return EXT_LANG_RC_ERROR;
327  }
328  while ((py_worker = PyIter_Next (iter)) != NULL)
329  {
330  struct xmethod_worker *worker;
331 
332  worker = new_python_xmethod_worker (py_worker, py_type);
333  VEC_safe_push (xmethod_worker_ptr, worker_vec, worker);
334  Py_DECREF (py_worker);
335  }
336  Py_DECREF (iter);
337  /* Report any error that could have occurred while iterating. */
338  if (PyErr_Occurred ())
339  {
341  Py_DECREF (matcher);
342  Py_DECREF (match_result);
343  do_cleanups (cleanups);
344 
345  return EXT_LANG_RC_ERROR;
346  }
347  }
348  else
349  {
350  struct xmethod_worker *worker;
351 
352  worker = new_python_xmethod_worker (match_result, py_type);
353  VEC_safe_push (xmethod_worker_ptr, worker_vec, worker);
354  }
355 
356  Py_DECREF (match_result);
357  Py_DECREF (matcher);
358  }
359  Py_DECREF (list_iter);
360  /* Report any error that could have occurred while iterating. */
361  if (PyErr_Occurred ())
362  {
364  do_cleanups (cleanups);
365 
366  return EXT_LANG_RC_ERROR;
367  }
368 
369  do_cleanups (cleanups);
370  *dm_vec = worker_vec;
371 
372  return EXT_LANG_RC_OK;
373 }
374 
375 /* Implementation of get_xmethod_arg_types for Python. */
376 
377 enum ext_lang_rc
379  struct xmethod_worker *worker,
380  int *nargs, struct type ***arg_types)
381 {
382  struct gdbpy_worker_data *worker_data = worker->data;
383  PyObject *py_worker = worker_data->worker;
384  PyObject *get_arg_types_method;
385  PyObject *py_argtype_list, *list_iter = NULL, *item;
386  struct cleanup *cleanups;
387  struct type **type_array, *obj_type;
388  int i = 1, arg_count;
389 
390  /* Set nargs to -1 so that any premature return from this function returns
391  an invalid/unusable number of arg types. */
392  *nargs = -1;
393 
395 
396  get_arg_types_method = PyObject_GetAttrString (py_worker,
397  get_arg_types_method_name);
398  if (get_arg_types_method == NULL)
399  {
401  do_cleanups (cleanups);
402 
403  return EXT_LANG_RC_ERROR;
404  }
405  make_cleanup_py_decref (get_arg_types_method);
406 
407  py_argtype_list = PyObject_CallMethodObjArgs (py_worker,
408  py_get_arg_types_method_name,
409  NULL);
410  if (py_argtype_list == NULL)
411  {
413  do_cleanups (cleanups);
414 
415  return EXT_LANG_RC_ERROR;
416  }
417  make_cleanup_py_decref (py_argtype_list);
418  if (py_argtype_list == Py_None)
419  arg_count = 0;
420  else if (PySequence_Check (py_argtype_list))
421  {
422  arg_count = PySequence_Size (py_argtype_list);
423  if (arg_count == -1)
424  {
426  do_cleanups (cleanups);
427 
428  return EXT_LANG_RC_ERROR;
429  }
430 
431  list_iter = PyObject_GetIter (py_argtype_list);
432  if (list_iter == NULL)
433  {
435  do_cleanups (cleanups);
436 
437  return EXT_LANG_RC_ERROR;
438  }
439  make_cleanup_py_decref (list_iter);
440  }
441  else
442  arg_count = 1;
443 
444  /* Include the 'this' argument in the size. */
445  type_array = XCNEWVEC (struct type *, arg_count + 1);
446  i = 1;
447  if (list_iter != NULL)
448  {
449  while ((item = PyIter_Next (list_iter)) != NULL)
450  {
451  struct type *arg_type = type_object_to_type (item);
452 
453  Py_DECREF (item);
454  if (arg_type == NULL)
455  {
456  PyErr_SetString (PyExc_TypeError,
457  _("Arg type returned by the get_arg_types "
458  "method of a debug method worker object is "
459  "not a gdb.Type object."));
460  break;
461  }
462 
463  type_array[i] = arg_type;
464  i++;
465  }
466  }
467  else if (arg_count == 1)
468  {
469  /* py_argtype_list is not actually a list but a single gdb.Type
470  object. */
471  struct type *arg_type = type_object_to_type (py_argtype_list);
472 
473  if (arg_type == NULL)
474  {
475  PyErr_SetString (PyExc_TypeError,
476  _("Arg type returned by the get_arg_types method "
477  "of an xmethod worker object is not a gdb.Type "
478  "object."));
479  }
480  else
481  {
482  type_array[i] = arg_type;
483  i++;
484  }
485  }
486  if (PyErr_Occurred ())
487  {
489  do_cleanups (cleanups);
490  xfree (type_array);
491 
492  return EXT_LANG_RC_ERROR;
493  }
494 
495  /* Add the type of 'this' as the first argument. The 'this' pointer should
496  be a 'const' value. Hence, create a 'const' variant of the 'this' pointer
497  type. */
498  obj_type = type_object_to_type (worker_data->this_type);
499  type_array[0] = make_cv_type (1, 0, lookup_pointer_type (obj_type), NULL);
500  *nargs = i;
501  *arg_types = type_array;
502  do_cleanups (cleanups);
503 
504  return EXT_LANG_RC_OK;
505 }
506 
507 /* Implementation of get_xmethod_result_type for Python. */
508 
509 enum ext_lang_rc
511  struct xmethod_worker *worker,
512  struct value *obj,
513  struct value **args, int nargs,
514  struct type **result_type_ptr)
515 {
516  struct gdbpy_worker_data *worker_data = worker->data;
517  PyObject *py_worker = worker_data->worker;
518  PyObject *py_value_obj, *py_arg_tuple, *py_result_type;
519  PyObject *get_result_type_method;
520  struct type *obj_type, *this_type;
521  struct cleanup *cleanups;
522  int i;
523 
525 
526  /* First see if there is a get_result_type method.
527  If not this could be an old xmethod (pre 7.9.1). */
528  get_result_type_method
529  = PyObject_GetAttrString (py_worker, get_result_type_method_name);
530  if (get_result_type_method == NULL)
531  {
532  PyErr_Clear ();
533  do_cleanups (cleanups);
534  *result_type_ptr = NULL;
535  return EXT_LANG_RC_OK;
536  }
537  make_cleanup_py_decref (get_result_type_method);
538 
539  obj_type = check_typedef (value_type (obj));
540  this_type = check_typedef (type_object_to_type (worker_data->this_type));
541  if (TYPE_CODE (obj_type) == TYPE_CODE_PTR)
542  {
543  struct type *this_ptr = lookup_pointer_type (this_type);
544 
545  if (!types_equal (obj_type, this_ptr))
546  obj = value_cast (this_ptr, obj);
547  }
548  else if (TYPE_CODE (obj_type) == TYPE_CODE_REF)
549  {
550  struct type *this_ref = lookup_reference_type (this_type);
551 
552  if (!types_equal (obj_type, this_ref))
553  obj = value_cast (this_ref, obj);
554  }
555  else
556  {
557  if (!types_equal (obj_type, this_type))
558  obj = value_cast (this_type, obj);
559  }
560  py_value_obj = value_to_value_object (obj);
561  if (py_value_obj == NULL)
562  goto Fail;
563  make_cleanup_py_decref (py_value_obj);
564 
565  py_arg_tuple = PyTuple_New (nargs + 1);
566  if (py_arg_tuple == NULL)
567  goto Fail;
568  make_cleanup_py_decref (py_arg_tuple);
569 
570  /* PyTuple_SET_ITEM steals the reference of the element. Hence INCREF the
571  reference to the 'this' object as we have a cleanup to DECREF it. */
572  Py_INCREF (py_value_obj);
573  PyTuple_SET_ITEM (py_arg_tuple, 0, py_value_obj);
574 
575  for (i = 0; i < nargs; i++)
576  {
577  PyObject *py_value_arg = value_to_value_object (args[i]);
578 
579  if (py_value_arg == NULL)
580  goto Fail;
581  PyTuple_SET_ITEM (py_arg_tuple, i + 1, py_value_arg);
582  }
583 
584  py_result_type = PyObject_CallObject (get_result_type_method, py_arg_tuple);
585  if (py_result_type == NULL)
586  goto Fail;
587  make_cleanup_py_decref (py_result_type);
588 
589  *result_type_ptr = type_object_to_type (py_result_type);
590  if (*result_type_ptr == NULL)
591  {
592  PyErr_SetString (PyExc_TypeError,
593  _("Type returned by the get_result_type method of an"
594  " xmethod worker object is not a gdb.Type object."));
595  goto Fail;
596  }
597 
598  do_cleanups (cleanups);
599  return EXT_LANG_RC_OK;
600 
601  Fail:
603  do_cleanups (cleanups);
604  return EXT_LANG_RC_ERROR;
605 }
606 
607 /* Implementation of invoke_xmethod for Python. */
608 
609 struct value *
611  struct xmethod_worker *worker,
612  struct value *obj, struct value **args, int nargs)
613 {
614  int i;
615  struct cleanup *cleanups;
616  PyObject *py_value_obj, *py_arg_tuple, *py_result;
617  struct type *obj_type, *this_type;
618  struct value *res = NULL;
619  struct gdbpy_worker_data *worker_data = worker->data;
620  PyObject *xmethod_worker = worker_data->worker;
621 
623 
624  obj_type = check_typedef (value_type (obj));
625  this_type = check_typedef (type_object_to_type (worker_data->this_type));
626  if (TYPE_CODE (obj_type) == TYPE_CODE_PTR)
627  {
628  struct type *this_ptr = lookup_pointer_type (this_type);
629 
630  if (!types_equal (obj_type, this_ptr))
631  obj = value_cast (this_ptr, obj);
632  }
633  else if (TYPE_CODE (obj_type) == TYPE_CODE_REF)
634  {
635  struct type *this_ref = lookup_reference_type (this_type);
636 
637  if (!types_equal (obj_type, this_ref))
638  obj = value_cast (this_ref, obj);
639  }
640  else
641  {
642  if (!types_equal (obj_type, this_type))
643  obj = value_cast (this_type, obj);
644  }
645  py_value_obj = value_to_value_object (obj);
646  if (py_value_obj == NULL)
647  {
649  error (_("Error while executing Python code."));
650  }
651  make_cleanup_py_decref (py_value_obj);
652 
653  py_arg_tuple = PyTuple_New (nargs + 1);
654  if (py_arg_tuple == NULL)
655  {
657  error (_("Error while executing Python code."));
658  }
659  make_cleanup_py_decref (py_arg_tuple);
660 
661  /* PyTuple_SET_ITEM steals the reference of the element. Hence INCREF the
662  reference to the 'this' object as we have a cleanup to DECREF it. */
663  Py_INCREF (py_value_obj);
664  PyTuple_SET_ITEM (py_arg_tuple, 0, py_value_obj);
665 
666  for (i = 0; i < nargs; i++)
667  {
668  PyObject *py_value_arg = value_to_value_object (args[i]);
669 
670  if (py_value_arg == NULL)
671  {
673  error (_("Error while executing Python code."));
674  }
675 
676  PyTuple_SET_ITEM (py_arg_tuple, i + 1, py_value_arg);
677  }
678 
679  py_result = PyObject_CallObject (xmethod_worker, py_arg_tuple);
680  if (py_result == NULL)
681  {
683  error (_("Error while executing Python code."));
684  }
685  make_cleanup_py_decref (py_result);
686 
687  if (py_result != Py_None)
688  {
689  res = convert_value_from_python (py_result);
690  if (res == NULL)
691  {
693  error (_("Error while executing Python code."));
694  }
695  }
696  else
697  {
699  "void", NULL, 0));
700  }
701 
702  do_cleanups (cleanups);
703 
704  return res;
705 }
706 
707 /* Creates a new Python xmethod_worker object.
708  The new object has data of type 'struct gdbpy_worker_data' composed
709  with the components PY_WORKER and THIS_TYPE. */
710 
711 static struct xmethod_worker *
712 new_python_xmethod_worker (PyObject *py_worker, PyObject *this_type)
713 {
714  struct gdbpy_worker_data *data;
715 
716  gdb_assert (py_worker != NULL && this_type != NULL);
717 
718  data = XCNEW (struct gdbpy_worker_data);
719  data->worker = py_worker;
720  data->this_type = this_type;
721  Py_INCREF (py_worker);
722  Py_INCREF (this_type);
723 
725 }
726 
727 int
729 {
730  py_match_method_name = PyString_FromString (match_method_name);
731  if (py_match_method_name == NULL)
732  return -1;
733 
734  py_invoke_method_name = PyString_FromString (invoke_method_name);
735  if (py_invoke_method_name == NULL)
736  return -1;
737 
738  py_get_arg_types_method_name
739  = PyString_FromString (get_arg_types_method_name);
740  if (py_get_arg_types_method_name == NULL)
741  return -1;
742 
743  py_get_result_type_method_name
744  = PyString_FromString (get_result_type_method_name);
745  if (py_get_result_type_method_name == NULL)
746  return -1;
747 
748  return 1;
749 }
int gdbpy_initialize_xmethods(void)
Definition: py-xmethods.c:728
void * gdbpy_clone_xmethod_worker_data(const struct extension_language_defn *extlang, void *data)
Definition: py-xmethods.c:75
#define Py_DECREF(op)
#define PyObject_GetAttrString(obj, attr)
PyObject * gdb_python_module
Definition: python.c:113
void xfree(void *)
Definition: common-utils.c:97
ext_lang_rc
struct type * type_object_to_type(PyObject *obj)
Definition: py-type.c:1394
PyObject * pspy_get_xmethods(PyObject *o, void *ignore)
Definition: py-progspace.c:279
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)
Definition: py-xmethods.c:378
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)
Definition: py-xmethods.c:163
PyObject * this_type
Definition: py-xmethods.c:45
static const char enabled_field_name[]
Definition: py-xmethods.c:30
#define VEC_safe_push(T, V, O)
Definition: vec.h:260
static PyObject * py_match_method_name
Definition: py-xmethods.c:37
#define VEC(T)
Definition: vec.h:398
#define _(String)
Definition: gdb_locale.h:40
const struct extension_language_defn extension_language_python
Definition: python.c:66
struct value * gdbpy_invoke_xmethod(const struct extension_language_defn *extlang, struct xmethod_worker *worker, struct value *obj, struct value **args, int nargs)
Definition: py-xmethods.c:610
struct value * allocate_value(struct type *type)
Definition: value.c:962
void null_cleanup(void *arg)
Definition: cleanups.c:295
struct type * lookup_typename(const struct language_defn *language, struct gdbarch *gdbarch, const char *name, const struct block *block, int noerr)
Definition: gdbtypes.c:1404
#define ALL_OBJFILES(obj)
Definition: objfiles.h:579
struct type * check_typedef(struct type *type)
Definition: gdbtypes.c:2217
static PyObject * py_get_arg_types_method_name
Definition: py-xmethods.c:38
PyObject * worker
Definition: py-xmethods.c:44
struct cleanup * make_cleanup(make_cleanup_ftype *function, void *arg)
Definition: cleanups.c:117
Definition: gdbtypes.h:749
PyObject * objfile_to_objfile_object(struct objfile *objfile)
Definition: py-objfile.c:632
static const char invoke_method_name[]
Definition: py-xmethods.c:34
static const char get_arg_types_method_name[]
Definition: py-xmethods.c:32
struct gdbarch * get_current_arch(void)
Definition: arch-utils.c:781
struct gdbarch * python_gdbarch
Definition: python.c:201
struct cleanup * ensure_python_env(struct gdbarch *gdbarch, const struct language_defn *language)
Definition: python.c:247
#define gdb_assert(expr)
Definition: gdb_assert.h:33
PyObject * objfpy_get_xmethods(PyObject *o, void *ignore)
Definition: py-objfile.c:380
PyObject * value_to_value_object(struct value *val)
Definition: py-value.c:1523
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)
Definition: py-xmethods.c:510
struct xmethod_worker * new_xmethod_worker(const struct extension_language_defn *extlang, void *data)
Definition: extension.c:864
struct value * value_cast(struct type *type, struct value *arg2)
Definition: valops.c:351
static struct xmethod_worker * new_python_xmethod_worker(PyObject *item, PyObject *py_obj_type)
Definition: py-xmethods.c:712
Definition: value.c:172
static PyObject * invoke_match_method(PyObject *matcher, PyObject *py_obj_type, const char *xmethod_name)
Definition: py-xmethods.c:101
int types_equal(struct type *a, struct type *b)
Definition: gdbtypes.c:3085
struct type * make_cv_type(int cnst, int voltl, struct type *type, struct type **typeptr)
Definition: gdbtypes.c:651
const struct language_defn * current_language
Definition: language.c:85
#define TYPE_CODE(thistype)
Definition: gdbtypes.h:1240
void gdbpy_print_stack(void)
Definition: python.c:1199
static const char matchers_attr_str[]
Definition: py-xmethods.c:35
static const char match_method_name[]
Definition: py-xmethods.c:31
struct value * convert_value_from_python(PyObject *obj)
Definition: py-value.c:1559
static PyObject * py_get_result_type_method_name
Definition: py-xmethods.c:39
void gdbpy_free_xmethod_worker_data(const struct extension_language_defn *extlang, void *data)
Definition: py-xmethods.c:54
struct program_space * current_program_space
Definition: progspace.c:35
static const char get_result_type_method_name[]
Definition: py-xmethods.c:33
static PyObject * py_invoke_method_name
Definition: py-xmethods.c:40
struct type * value_type(const struct value *value)
Definition: value.c:1021
struct type * lookup_reference_type(struct type *type)
Definition: gdbtypes.c:441
const struct language_defn * python_language
Definition: python.c:202
struct cleanup * make_cleanup_py_decref(PyObject *py)
Definition: py-utils.c:41
void error(const char *fmt,...)
Definition: errors.c:38
struct type * lookup_pointer_type(struct type *type)
Definition: gdbtypes.c:368
PyObject * pspace_to_pspace_object(struct program_space *pspace)
Definition: py-progspace.c:350
#define PyObject_HasAttrString(obj, attr)
void do_cleanups(struct cleanup *old_chain)
Definition: cleanups.c:175
PyObject * type_to_type_object(struct type *type)
Definition: py-type.c:1382