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