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