]> Git Repo - binutils.git/blob - gdb/python/py-unwind.c
Use ui_file_as_string in execute_command_to_string
[binutils.git] / gdb / python / py-unwind.c
1 /* Python frame unwinder interface.
2
3    Copyright (C) 2015-2016 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 "frame-unwind.h"
23 #include "gdb_obstack.h"
24 #include "gdbcmd.h"
25 #include "language.h"
26 #include "observer.h"
27 #include "python-internal.h"
28 #include "regcache.h"
29 #include "valprint.h"
30 #include "user-regs.h"
31
32 #define TRACE_PY_UNWIND(level, args...) if (pyuw_debug >= level)  \
33   { fprintf_unfiltered (gdb_stdlog, args); }
34
35 typedef struct
36 {
37   PyObject_HEAD
38
39   /* Frame we are unwinding.  */
40   struct frame_info *frame_info;
41
42   /* Its architecture, passed by the sniffer caller.  */
43   struct gdbarch *gdbarch;
44 } pending_frame_object;
45
46 /* Saved registers array item.  */
47
48 typedef struct
49 {
50   int number;
51   PyObject *value;
52 } saved_reg;
53 DEF_VEC_O (saved_reg);
54
55 /* The data we keep for the PyUnwindInfo: pending_frame, saved registers
56    and frame ID.  */
57
58 typedef struct
59 {
60   PyObject_HEAD
61
62   /* gdb.PendingFrame for the frame we are unwinding.  */
63   PyObject *pending_frame;
64
65   /* Its ID.  */
66   struct frame_id frame_id;
67
68   /* Saved registers array.  */
69   VEC (saved_reg) *saved_regs;
70 } unwind_info_object;
71
72 /* The data we keep for a frame we can unwind: frame ID and an array of
73    (register_number, register_value) pairs.  */
74
75 struct reg_info
76 {
77   /* Register number.  */
78   int number;
79
80   /* Register data bytes pointer.  */
81   gdb_byte data[MAX_REGISTER_SIZE];
82 };
83
84 typedef struct
85 {
86   /* Frame ID.  */
87   struct frame_id frame_id;
88
89   /* GDB Architecture.  */
90   struct gdbarch *gdbarch;
91
92   /* Length of the `reg' array below.  */
93   int reg_count;
94
95   struct reg_info reg[];
96 } cached_frame_info;
97
98 extern PyTypeObject pending_frame_object_type
99     CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("pending_frame_object");
100
101 extern PyTypeObject unwind_info_object_type
102     CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("unwind_info_object");
103
104 static unsigned int pyuw_debug = 0;
105
106 static struct gdbarch_data *pyuw_gdbarch_data;
107
108 /* Parses register id, which can be either a number or a name.
109    Returns 1 on success, 0 otherwise.  */
110
111 static int
112 pyuw_parse_register_id (struct gdbarch *gdbarch, PyObject *pyo_reg_id,
113                         int *reg_num)
114 {
115   if (pyo_reg_id == NULL)
116     return 0;
117   if (gdbpy_is_string (pyo_reg_id))
118     {
119       const char *reg_name = gdbpy_obj_to_string (pyo_reg_id);
120
121       if (reg_name == NULL)
122         return 0;
123       *reg_num = user_reg_map_name_to_regnum (gdbarch, reg_name,
124                                               strlen (reg_name));
125       return *reg_num >= 0;
126     }
127   else if (PyInt_Check (pyo_reg_id))
128     {
129       long value;
130       if (gdb_py_int_as_long (pyo_reg_id, &value) && (int) value == value)
131         {
132           *reg_num = (int) value;
133           return user_reg_map_regnum_to_name (gdbarch, *reg_num) != NULL;
134         }
135     }
136   return 0;
137 }
138
139 /* Convert gdb.Value instance to inferior's pointer.  Return 1 on success,
140    0 on failure.  */
141
142 static int
143 pyuw_value_obj_to_pointer (PyObject *pyo_value, CORE_ADDR *addr)
144 {
145   int rc = 0;
146   struct value *value;
147
148   TRY
149     {
150       if ((value = value_object_to_value (pyo_value)) != NULL)
151         {
152           *addr = unpack_pointer (value_type (value),
153                                   value_contents (value));
154           rc = 1;
155         }
156     }
157   CATCH (except, RETURN_MASK_ALL)
158     {
159       gdbpy_convert_exception (except);
160     }
161   END_CATCH
162   return rc;
163 }
164
165 /* Get attribute from an object and convert it to the inferior's
166    pointer value.  Return 1 if attribute exists and its value can be
167    converted.  Otherwise, if attribute does not exist or its value is
168    None, return 0.  In all other cases set Python error and return
169    0.  */
170
171 static int
172 pyuw_object_attribute_to_pointer (PyObject *pyo, const char *attr_name,
173                                   CORE_ADDR *addr)
174 {
175   int rc = 0;
176
177   if (PyObject_HasAttrString (pyo, attr_name))
178     {
179       PyObject *pyo_value = PyObject_GetAttrString (pyo, attr_name);
180
181       if (pyo_value != NULL && pyo_value != Py_None)
182         {
183           rc = pyuw_value_obj_to_pointer (pyo_value, addr);
184           if (!rc)
185             PyErr_Format (
186                 PyExc_ValueError,
187                 _("The value of the '%s' attribute is not a pointer."),
188                 attr_name);
189         }
190       Py_XDECREF (pyo_value);
191     }
192   return rc;
193 }
194
195 /* Called by the Python interpreter to obtain string representation
196    of the UnwindInfo object.  */
197
198 static PyObject *
199 unwind_infopy_str (PyObject *self)
200 {
201   struct ui_file *strfile = mem_fileopen ();
202   unwind_info_object *unwind_info = (unwind_info_object *) self;
203   PyObject *result;
204
205   fprintf_unfiltered (strfile, "Frame ID: ");
206   fprint_frame_id (strfile, unwind_info->frame_id);
207   {
208     char *sep = "";
209     int i;
210     struct value_print_options opts;
211     saved_reg *reg;
212
213     get_user_print_options (&opts);
214     fprintf_unfiltered (strfile, "\nSaved registers: (");
215     for (i = 0; VEC_iterate (saved_reg, unwind_info->saved_regs, i, reg); i++)
216       {
217         struct value *value = value_object_to_value (reg->value);
218
219         fprintf_unfiltered (strfile, "%s(%d, ", sep, reg->number);
220         if (value != NULL)
221           {
222             TRY
223               {
224                 value_print (value, strfile, &opts);
225                 fprintf_unfiltered (strfile, ")");
226               }
227             CATCH (except, RETURN_MASK_ALL)
228               {
229                 GDB_PY_HANDLE_EXCEPTION (except);
230               }
231             END_CATCH
232           }
233         else
234           fprintf_unfiltered (strfile, "<BAD>)");
235         sep = ", ";
236       }
237     fprintf_unfiltered (strfile, ")");
238   }
239   {
240     char *s = ui_file_xstrdup (strfile, NULL);
241
242     result = PyString_FromString (s);
243     xfree (s);
244   }
245   ui_file_delete (strfile);
246   return result;
247 }
248
249 /* Create UnwindInfo instance for given PendingFrame and frame ID.
250    Sets Python error and returns NULL on error.  */
251
252 static PyObject *
253 pyuw_create_unwind_info (PyObject *pyo_pending_frame,
254                          struct frame_id frame_id)
255 {
256   unwind_info_object *unwind_info
257       = PyObject_New (unwind_info_object, &unwind_info_object_type);
258
259   if (((pending_frame_object *) pyo_pending_frame)->frame_info == NULL)
260     {
261       PyErr_SetString (PyExc_ValueError,
262                        "Attempting to use stale PendingFrame");
263       return NULL;
264     }
265   unwind_info->frame_id = frame_id;
266   Py_INCREF (pyo_pending_frame);
267   unwind_info->pending_frame = pyo_pending_frame;
268   unwind_info->saved_regs = VEC_alloc (saved_reg, 4);
269   return (PyObject *) unwind_info;
270 }
271
272 /* The implementation of
273    gdb.UnwindInfo.add_saved_register (REG, VALUE) -> None.  */
274
275 static PyObject *
276 unwind_infopy_add_saved_register (PyObject *self, PyObject *args)
277 {
278   unwind_info_object *unwind_info = (unwind_info_object *) self;
279   pending_frame_object *pending_frame
280       = (pending_frame_object *) (unwind_info->pending_frame);
281   PyObject *pyo_reg_id;
282   PyObject *pyo_reg_value;
283   int regnum;
284
285   if (pending_frame->frame_info == NULL)
286     {
287       PyErr_SetString (PyExc_ValueError,
288                        "UnwindInfo instance refers to a stale PendingFrame");
289       return NULL;
290     }
291   if (!PyArg_UnpackTuple (args, "previous_frame_register", 2, 2,
292                           &pyo_reg_id, &pyo_reg_value))
293     return NULL;
294   if (!pyuw_parse_register_id (pending_frame->gdbarch, pyo_reg_id, &regnum))
295     {
296       PyErr_SetString (PyExc_ValueError, "Bad register");
297       return NULL;
298     }
299   {
300     struct value *value;
301     size_t data_size;
302
303     if (pyo_reg_value == NULL
304       || (value = value_object_to_value (pyo_reg_value)) == NULL)
305       {
306         PyErr_SetString (PyExc_ValueError, "Bad register value");
307         return NULL;
308       }
309     data_size = register_size (pending_frame->gdbarch, regnum);
310     if (data_size != TYPE_LENGTH (value_type (value)))
311       {
312         PyErr_Format (
313             PyExc_ValueError,
314             "The value of the register returned by the Python "
315             "sniffer has unexpected size: %u instead of %u.",
316             (unsigned) TYPE_LENGTH (value_type (value)),
317             (unsigned) data_size);
318         return NULL;
319       }
320   }
321   {
322     int i;
323     saved_reg *reg;
324
325     for (i = 0; VEC_iterate (saved_reg, unwind_info->saved_regs, i, reg); i++)
326       {
327         if (regnum == reg->number)
328           {
329             Py_DECREF (reg->value);
330             break;
331           }
332       }
333     if (reg == NULL)
334       {
335         reg = VEC_safe_push (saved_reg, unwind_info->saved_regs, NULL);
336         reg->number = regnum;
337       }
338     Py_INCREF (pyo_reg_value);
339     reg->value = pyo_reg_value;
340   }
341   Py_RETURN_NONE;
342 }
343
344 /* UnwindInfo cleanup.  */
345
346 static void
347 unwind_infopy_dealloc (PyObject *self)
348 {
349   unwind_info_object *unwind_info = (unwind_info_object *) self;
350   int i;
351   saved_reg *reg;
352
353   Py_XDECREF (unwind_info->pending_frame);
354   for (i = 0; VEC_iterate (saved_reg, unwind_info->saved_regs, i, reg); i++)
355       Py_DECREF (reg->value);
356   VEC_free (saved_reg, unwind_info->saved_regs);
357   Py_TYPE (self)->tp_free (self);
358 }
359
360 /* Called by the Python interpreter to obtain string representation
361    of the PendingFrame object.  */
362
363 static PyObject *
364 pending_framepy_str (PyObject *self)
365 {
366   struct frame_info *frame = ((pending_frame_object *) self)->frame_info;
367   const char *sp_str = NULL;
368   const char *pc_str = NULL;
369
370   if (frame == NULL)
371     return PyString_FromString ("Stale PendingFrame instance");
372   TRY
373     {
374       sp_str = core_addr_to_string_nz (get_frame_sp (frame));
375       pc_str = core_addr_to_string_nz (get_frame_pc (frame));
376     }
377   CATCH (except, RETURN_MASK_ALL)
378     {
379       GDB_PY_HANDLE_EXCEPTION (except);
380     }
381   END_CATCH
382
383   return PyString_FromFormat ("SP=%s,PC=%s", sp_str, pc_str);
384 }
385
386 /* Implementation of gdb.PendingFrame.read_register (self, reg) -> gdb.Value.
387    Returns the value of register REG as gdb.Value instance.  */
388
389 static PyObject *
390 pending_framepy_read_register (PyObject *self, PyObject *args)
391 {
392   pending_frame_object *pending_frame = (pending_frame_object *) self;
393   struct value *val = NULL;
394   int regnum;
395   PyObject *pyo_reg_id;
396
397   if (pending_frame->frame_info == NULL)
398     {
399       PyErr_SetString (PyExc_ValueError,
400                        "Attempting to read register from stale PendingFrame");
401       return NULL;
402     }
403   if (!PyArg_UnpackTuple (args, "read_register", 1, 1, &pyo_reg_id))
404     return NULL;
405   if (!pyuw_parse_register_id (pending_frame->gdbarch, pyo_reg_id, &regnum))
406     {
407       PyErr_SetString (PyExc_ValueError, "Bad register");
408       return NULL;
409     }
410
411   TRY
412     {
413       val = get_frame_register_value (pending_frame->frame_info, regnum);
414       if (val == NULL)
415         PyErr_Format (PyExc_ValueError,
416                       "Cannot read register %d from frame.",
417                       regnum);
418     }
419   CATCH (except, RETURN_MASK_ALL)
420     {
421       GDB_PY_HANDLE_EXCEPTION (except);
422     }
423   END_CATCH
424
425   return val == NULL ? NULL : value_to_value_object (val);
426 }
427
428 /* Implementation of
429    PendingFrame.create_unwind_info (self, frameId) -> UnwindInfo.  */
430
431 static PyObject *
432 pending_framepy_create_unwind_info (PyObject *self, PyObject *args)
433 {
434   PyObject *pyo_frame_id;
435   CORE_ADDR sp;
436   CORE_ADDR pc;
437   CORE_ADDR special;
438
439   if (!PyArg_ParseTuple (args, "O:create_unwind_info", &pyo_frame_id))
440       return NULL;
441   if (!pyuw_object_attribute_to_pointer (pyo_frame_id, "sp", &sp))
442     {
443       PyErr_SetString (PyExc_ValueError,
444                        _("frame_id should have 'sp' attribute."));
445       return NULL;
446     }
447
448   /* The logic of building frame_id depending on the attributes of
449      the frame_id object:
450      Has     Has    Has           Function to call
451      'sp'?   'pc'?  'special'?
452      ------|------|--------------|-------------------------
453      Y       N      *             frame_id_build_wild (sp)
454      Y       Y      N             frame_id_build (sp, pc)
455      Y       Y      Y             frame_id_build_special (sp, pc, special)
456   */
457   if (!pyuw_object_attribute_to_pointer (pyo_frame_id, "pc", &pc))
458     return pyuw_create_unwind_info (self, frame_id_build_wild (sp));
459   if (!pyuw_object_attribute_to_pointer (pyo_frame_id, "special", &special))
460     return pyuw_create_unwind_info (self, frame_id_build (sp, pc));
461   else
462     return pyuw_create_unwind_info (self,
463                                     frame_id_build_special (sp, pc, special));
464 }
465
466 /* Invalidate PendingFrame instance.  */
467
468 static void
469 pending_frame_invalidate (void *pyo_pending_frame)
470 {
471   if (pyo_pending_frame != NULL)
472     ((pending_frame_object *) pyo_pending_frame)->frame_info = NULL;
473 }
474
475 /* frame_unwind.this_id method.  */
476
477 static void
478 pyuw_this_id (struct frame_info *this_frame, void **cache_ptr,
479               struct frame_id *this_id)
480 {
481   *this_id = ((cached_frame_info *) *cache_ptr)->frame_id;
482   if (pyuw_debug >= 1)
483     {
484       fprintf_unfiltered (gdb_stdlog, "%s: frame_id: ", __FUNCTION__);
485       fprint_frame_id (gdb_stdlog, *this_id);
486       fprintf_unfiltered (gdb_stdlog, "\n");
487     }
488 }
489
490 /* frame_unwind.prev_register.  */
491
492 static struct value *
493 pyuw_prev_register (struct frame_info *this_frame, void **cache_ptr,
494                     int regnum)
495 {
496   cached_frame_info *cached_frame = (cached_frame_info *) *cache_ptr;
497   struct reg_info *reg_info = cached_frame->reg;
498   struct reg_info *reg_info_end = reg_info + cached_frame->reg_count;
499
500   TRACE_PY_UNWIND (1, "%s (frame=%p,...,reg=%d)\n", __FUNCTION__, this_frame,
501                    regnum);
502   for (; reg_info < reg_info_end; ++reg_info)
503     {
504       if (regnum == reg_info->number)
505         return frame_unwind_got_bytes (this_frame, regnum, reg_info->data);
506     }
507
508   return frame_unwind_got_optimized (this_frame, regnum);
509 }
510
511 /* Frame sniffer dispatch.  */
512
513 static int
514 pyuw_sniffer (const struct frame_unwind *self, struct frame_info *this_frame,
515               void **cache_ptr)
516 {
517   struct gdbarch *gdbarch = (struct gdbarch *) (self->unwind_data);
518   struct cleanup *cleanups = ensure_python_env (gdbarch, current_language);
519   PyObject *pyo_execute;
520   PyObject *pyo_pending_frame;
521   PyObject *pyo_unwind_info;
522   cached_frame_info *cached_frame;
523
524   TRACE_PY_UNWIND (3, "%s (SP=%s, PC=%s)\n", __FUNCTION__,
525                    paddress (gdbarch, get_frame_sp (this_frame)),
526                    paddress (gdbarch, get_frame_pc (this_frame)));
527
528   /* Create PendingFrame instance to pass to sniffers.  */
529   pyo_pending_frame  = (PyObject *) PyObject_New (pending_frame_object,
530                                                   &pending_frame_object_type);
531   if (pyo_pending_frame == NULL)
532     goto error;
533   ((pending_frame_object *) pyo_pending_frame)->gdbarch = gdbarch;
534   ((pending_frame_object *) pyo_pending_frame)->frame_info = this_frame;
535   make_cleanup_py_decref (pyo_pending_frame);
536   make_cleanup (pending_frame_invalidate, (void *) pyo_pending_frame);
537
538   /* Run unwinders.  */
539   if (gdb_python_module == NULL
540       || ! PyObject_HasAttrString (gdb_python_module, "execute_unwinders"))
541     {
542       PyErr_SetString (PyExc_NameError,
543                        "Installation error: gdb.execute_unwinders function "
544                        "is missing");
545       goto error;
546     }
547   pyo_execute = PyObject_GetAttrString (gdb_python_module, "execute_unwinders");
548   if (pyo_execute == NULL)
549     goto error;
550   make_cleanup_py_decref (pyo_execute);
551   pyo_unwind_info
552       = PyObject_CallFunctionObjArgs (pyo_execute, pyo_pending_frame, NULL);
553   if (pyo_unwind_info == NULL)
554     goto error;
555   make_cleanup_py_decref (pyo_unwind_info);
556   if (pyo_unwind_info == Py_None)
557     goto cannot_unwind;
558
559   /* Received UnwindInfo, cache data.  */
560   if (PyObject_IsInstance (pyo_unwind_info,
561                            (PyObject *) &unwind_info_object_type) <= 0)
562     error (_("A Unwinder should return gdb.UnwindInfo instance."));
563
564   {
565     unwind_info_object *unwind_info = (unwind_info_object *) pyo_unwind_info;
566     int reg_count = VEC_length (saved_reg, unwind_info->saved_regs);
567     saved_reg *reg;
568     int i;
569
570     cached_frame
571       = ((cached_frame_info *)
572          xmalloc (sizeof (*cached_frame)
573                   + reg_count * sizeof (cached_frame->reg[0])));
574     cached_frame->gdbarch = gdbarch;
575     cached_frame->frame_id = unwind_info->frame_id;
576     cached_frame->reg_count = reg_count;
577
578     /* Populate registers array.  */
579     for (i = 0; VEC_iterate (saved_reg, unwind_info->saved_regs, i, reg); i++)
580       {
581         struct value *value = value_object_to_value (reg->value);
582         size_t data_size = register_size (gdbarch, reg->number);
583
584         cached_frame->reg[i].number = reg->number;
585
586         /* `value' validation was done before, just assert.  */
587         gdb_assert (value != NULL);
588         gdb_assert (data_size == TYPE_LENGTH (value_type (value)));
589         gdb_assert (data_size <= MAX_REGISTER_SIZE);
590
591         memcpy (cached_frame->reg[i].data, value_contents (value), data_size);
592       }
593   }
594
595   *cache_ptr = cached_frame;
596   do_cleanups (cleanups);
597   return 1;
598
599  error:
600   gdbpy_print_stack ();
601   /* Fallthrough.  */
602  cannot_unwind:
603   do_cleanups (cleanups);
604   return 0;
605 }
606
607 /* Frame cache release shim.  */
608
609 static void
610 pyuw_dealloc_cache (struct frame_info *this_frame, void *cache)
611 {
612   TRACE_PY_UNWIND (3, "%s: enter", __FUNCTION__);
613   xfree (cache);
614 }
615
616 struct pyuw_gdbarch_data_type
617 {
618   /* Has the unwinder shim been prepended? */
619   int unwinder_registered;
620 };
621
622 static void *
623 pyuw_gdbarch_data_init (struct gdbarch *gdbarch)
624 {
625   return GDBARCH_OBSTACK_ZALLOC (gdbarch, struct pyuw_gdbarch_data_type);
626 }
627
628 /* New inferior architecture callback: register the Python unwinders
629    intermediary.  */
630
631 static void
632 pyuw_on_new_gdbarch (struct gdbarch *newarch)
633 {
634   struct pyuw_gdbarch_data_type *data
635     = (struct pyuw_gdbarch_data_type *) gdbarch_data (newarch,
636                                                       pyuw_gdbarch_data);
637
638   if (!data->unwinder_registered)
639     {
640       struct frame_unwind *unwinder
641           = GDBARCH_OBSTACK_ZALLOC (newarch, struct frame_unwind);
642
643       unwinder->type = NORMAL_FRAME;
644       unwinder->stop_reason = default_frame_unwind_stop_reason;
645       unwinder->this_id = pyuw_this_id;
646       unwinder->prev_register = pyuw_prev_register;
647       unwinder->unwind_data = (const struct frame_data *) newarch;
648       unwinder->sniffer = pyuw_sniffer;
649       unwinder->dealloc_cache = pyuw_dealloc_cache;
650       frame_unwind_prepend_unwinder (newarch, unwinder);
651       data->unwinder_registered = 1;
652     }
653 }
654
655 /* Initialize unwind machinery.  */
656
657 int
658 gdbpy_initialize_unwind (void)
659 {
660   int rc;
661   add_setshow_zuinteger_cmd
662       ("py-unwind", class_maintenance, &pyuw_debug,
663         _("Set Python unwinder debugging."),
664         _("Show Python unwinder debugging."),
665         _("When non-zero, Python unwinder debugging is enabled."),
666         NULL,
667         NULL,
668         &setdebuglist, &showdebuglist);
669   pyuw_gdbarch_data
670       = gdbarch_data_register_post_init (pyuw_gdbarch_data_init);
671   observer_attach_architecture_changed (pyuw_on_new_gdbarch);
672
673   if (PyType_Ready (&pending_frame_object_type) < 0)
674     return -1;
675   rc = gdb_pymodule_addobject (gdb_module, "PendingFrame",
676       (PyObject *) &pending_frame_object_type);
677   if (rc)
678     return rc;
679
680   if (PyType_Ready (&unwind_info_object_type) < 0)
681     return -1;
682   return gdb_pymodule_addobject (gdb_module, "UnwindInfo",
683       (PyObject *) &unwind_info_object_type);
684 }
685
686 static PyMethodDef pending_frame_object_methods[] =
687 {
688   { "read_register", pending_framepy_read_register, METH_VARARGS,
689     "read_register (REG) -> gdb.Value\n"
690     "Return the value of the REG in the frame." },
691   { "create_unwind_info",
692     pending_framepy_create_unwind_info, METH_VARARGS,
693     "create_unwind_info (FRAME_ID) -> gdb.UnwindInfo\n"
694     "Construct UnwindInfo for this PendingFrame, using FRAME_ID\n"
695     "to identify it." },
696   {NULL}  /* Sentinel */
697 };
698
699 PyTypeObject pending_frame_object_type =
700 {
701   PyVarObject_HEAD_INIT (NULL, 0)
702   "gdb.PendingFrame",             /* tp_name */
703   sizeof (pending_frame_object),  /* tp_basicsize */
704   0,                              /* tp_itemsize */
705   0,                              /* tp_dealloc */
706   0,                              /* tp_print */
707   0,                              /* tp_getattr */
708   0,                              /* tp_setattr */
709   0,                              /* tp_compare */
710   0,                              /* tp_repr */
711   0,                              /* tp_as_number */
712   0,                              /* tp_as_sequence */
713   0,                              /* tp_as_mapping */
714   0,                              /* tp_hash  */
715   0,                              /* tp_call */
716   pending_framepy_str,            /* tp_str */
717   0,                              /* tp_getattro */
718   0,                              /* tp_setattro */
719   0,                              /* tp_as_buffer */
720   Py_TPFLAGS_DEFAULT,             /* tp_flags */
721   "GDB PendingFrame object",      /* tp_doc */
722   0,                              /* tp_traverse */
723   0,                              /* tp_clear */
724   0,                              /* tp_richcompare */
725   0,                              /* tp_weaklistoffset */
726   0,                              /* tp_iter */
727   0,                              /* tp_iternext */
728   pending_frame_object_methods,   /* tp_methods */
729   0,                              /* tp_members */
730   0,                              /* tp_getset */
731   0,                              /* tp_base */
732   0,                              /* tp_dict */
733   0,                              /* tp_descr_get */
734   0,                              /* tp_descr_set */
735   0,                              /* tp_dictoffset */
736   0,                              /* tp_init */
737   0,                              /* tp_alloc */
738 };
739
740 static PyMethodDef unwind_info_object_methods[] =
741 {
742   { "add_saved_register",
743     unwind_infopy_add_saved_register, METH_VARARGS,
744     "add_saved_register (REG, VALUE) -> None\n"
745     "Set the value of the REG in the previous frame to VALUE." },
746   { NULL }  /* Sentinel */
747 };
748
749 PyTypeObject unwind_info_object_type =
750 {
751   PyVarObject_HEAD_INIT (NULL, 0)
752   "gdb.UnwindInfo",               /* tp_name */
753   sizeof (unwind_info_object),    /* tp_basicsize */
754   0,                              /* tp_itemsize */
755   unwind_infopy_dealloc,          /* tp_dealloc */
756   0,                              /* tp_print */
757   0,                              /* tp_getattr */
758   0,                              /* tp_setattr */
759   0,                              /* tp_compare */
760   0,                              /* tp_repr */
761   0,                              /* tp_as_number */
762   0,                              /* tp_as_sequence */
763   0,                              /* tp_as_mapping */
764   0,                              /* tp_hash  */
765   0,                              /* tp_call */
766   unwind_infopy_str,              /* tp_str */
767   0,                              /* tp_getattro */
768   0,                              /* tp_setattro */
769   0,                              /* tp_as_buffer */
770   Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,  /* tp_flags */
771   "GDB UnwindInfo object",        /* tp_doc */
772   0,                              /* tp_traverse */
773   0,                              /* tp_clear */
774   0,                              /* tp_richcompare */
775   0,                              /* tp_weaklistoffset */
776   0,                              /* tp_iter */
777   0,                              /* tp_iternext */
778   unwind_info_object_methods,     /* tp_methods */
779   0,                              /* tp_members */
780   0,                              /* tp_getset */
781   0,                              /* tp_base */
782   0,                              /* tp_dict */
783   0,                              /* tp_descr_get */
784   0,                              /* tp_descr_set */
785   0,                              /* tp_dictoffset */
786   0,                              /* tp_init */
787   0,                              /* tp_alloc */
788 };
This page took 0.070155 seconds and 4 git commands to generate.