Add support for writing unwinders in Python.
[deliverable/binutils-gdb.git] / gdb / python / py-unwind.c
1 /* Python frame unwinder interface.
2
3 Copyright (C) 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 "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 typedef struct
76 {
77 /* Frame ID. */
78 struct frame_id frame_id;
79
80 /* GDB Architecture. */
81 struct gdbarch *gdbarch;
82
83 /* Length of the `reg' array below. */
84 int reg_count;
85
86 struct reg_info
87 {
88 /* Register number. */
89 int number;
90
91 /* Register data bytes pointer. */
92 gdb_byte data[MAX_REGISTER_SIZE];
93 } reg[];
94 } cached_frame_info;
95
96 static PyTypeObject pending_frame_object_type
97 CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("pending_frame_object");
98
99 static PyTypeObject unwind_info_object_type
100 CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("unwind_info_object");
101
102 static unsigned int pyuw_debug = 0;
103
104 static struct gdbarch_data *pyuw_gdbarch_data;
105
106 /* Parses register id, which can be either a number or a name.
107 Returns 1 on success, 0 otherwise. */
108
109 static int
110 pyuw_parse_register_id (struct gdbarch *gdbarch, PyObject *pyo_reg_id,
111 int *reg_num)
112 {
113 if (pyo_reg_id == NULL)
114 return 0;
115 if (gdbpy_is_string (pyo_reg_id))
116 {
117 const char *reg_name = gdbpy_obj_to_string (pyo_reg_id);
118
119 if (reg_name == NULL)
120 return 0;
121 *reg_num = user_reg_map_name_to_regnum (gdbarch, reg_name,
122 strlen (reg_name));
123 return *reg_num >= 0;
124 }
125 else if (PyInt_Check (pyo_reg_id))
126 {
127 long value;
128 if (gdb_py_int_as_long (pyo_reg_id, &value) && (int) value == value)
129 {
130 *reg_num = (int) value;
131 return user_reg_map_regnum_to_name (gdbarch, *reg_num) != NULL;
132 }
133 }
134 return 0;
135 }
136
137 /* Convert gdb.Value instance to inferior's pointer. Return 1 on success,
138 0 on failure. */
139
140 static int
141 pyuw_value_obj_to_pointer (PyObject *pyo_value, CORE_ADDR *addr)
142 {
143 int rc = 0;
144 struct value *value;
145
146 TRY
147 {
148 if ((value = value_object_to_value (pyo_value)) != NULL)
149 {
150 *addr = unpack_pointer (value_type (value),
151 value_contents (value));
152 rc = 1;
153 }
154 }
155 CATCH (except, RETURN_MASK_ALL)
156 {
157 gdbpy_convert_exception (except);
158 }
159 END_CATCH
160 return rc;
161 }
162
163 /* Get attribute from an object and convert it to the inferior's
164 pointer value. Return 1 if attribute exists and its value can be
165 converted. Otherwise, if attribute does not exist or its value is
166 None, return 0. In all other cases set Python error and return
167 0. */
168
169 static int
170 pyuw_object_attribute_to_pointer (PyObject *pyo, const char *attr_name,
171 CORE_ADDR *addr)
172 {
173 int rc = 0;
174
175 if (PyObject_HasAttrString (pyo, attr_name))
176 {
177 PyObject *pyo_value = PyObject_GetAttrString (pyo, attr_name);
178 struct value *value;
179
180 if (pyo_value != NULL && pyo_value != Py_None)
181 {
182 rc = pyuw_value_obj_to_pointer (pyo_value, addr);
183 if (!rc)
184 PyErr_Format (
185 PyExc_ValueError,
186 _("The value of the '%s' attribute is not a pointer."),
187 attr_name);
188 }
189 Py_XDECREF (pyo_value);
190 }
191 return rc;
192 }
193
194 /* Called by the Python interpreter to obtain string representation
195 of the UnwindInfo object. */
196
197 static PyObject *
198 unwind_infopy_str (PyObject *self)
199 {
200 struct ui_file *strfile = mem_fileopen ();
201 unwind_info_object *unwind_info = (unwind_info_object *) self;
202 pending_frame_object *pending_frame
203 = (pending_frame_object *) (unwind_info->pending_frame);
204 PyObject *result;
205
206 fprintf_unfiltered (strfile, "Frame ID: ");
207 fprint_frame_id (strfile, unwind_info->frame_id);
208 {
209 char *sep = "";
210 int i;
211 struct value_print_options opts;
212 saved_reg *reg;
213
214 get_user_print_options (&opts);
215 fprintf_unfiltered (strfile, "\nSaved registers: (");
216 for (i = 0;
217 i < VEC_iterate (saved_reg, unwind_info->saved_regs, i, reg);
218 i++)
219 {
220 struct value *value = value_object_to_value (reg->value);
221
222 fprintf_unfiltered (strfile, "%s(%d, ", sep, reg->number);
223 if (value != NULL)
224 {
225 TRY
226 {
227 value_print (value, strfile, &opts);
228 fprintf_unfiltered (strfile, ")");
229 }
230 CATCH (except, RETURN_MASK_ALL)
231 {
232 GDB_PY_HANDLE_EXCEPTION (except);
233 }
234 END_CATCH
235 }
236 else
237 fprintf_unfiltered (strfile, "<BAD>)");
238 sep = ", ";
239 }
240 fprintf_unfiltered (strfile, ")");
241 }
242 {
243 char *s = ui_file_xstrdup (strfile, NULL);
244
245 result = PyString_FromString (s);
246 xfree (s);
247 }
248 ui_file_delete (strfile);
249 return result;
250 }
251
252 /* Create UnwindInfo instance for given PendingFrame and frame ID.
253 Sets Python error and returns NULL on error. */
254
255 static PyObject *
256 pyuw_create_unwind_info (PyObject *pyo_pending_frame,
257 struct frame_id frame_id)
258 {
259 unwind_info_object *unwind_info
260 = PyObject_New (unwind_info_object, &unwind_info_object_type);
261
262 if (((pending_frame_object *) pyo_pending_frame)->frame_info == NULL)
263 {
264 PyErr_SetString (PyExc_ValueError,
265 "Attempting to use stale PendingFrame");
266 return NULL;
267 }
268 unwind_info->frame_id = frame_id;
269 Py_INCREF (pyo_pending_frame);
270 unwind_info->pending_frame = pyo_pending_frame;
271 unwind_info->saved_regs = VEC_alloc (saved_reg, 4);
272 return (PyObject *) unwind_info;
273 }
274
275 /* The implementation of
276 gdb.UnwindInfo.add_saved_register (REG, VALUE) -> None. */
277
278 static PyObject *
279 unwind_infopy_add_saved_register (PyObject *self, PyObject *args)
280 {
281 unwind_info_object *unwind_info = (unwind_info_object *) self;
282 pending_frame_object *pending_frame
283 = (pending_frame_object *) (unwind_info->pending_frame);
284 PyObject *pyo_reg_id;
285 PyObject *pyo_reg_value;
286 int regnum;
287
288 if (pending_frame->frame_info == NULL)
289 {
290 PyErr_SetString (PyExc_ValueError,
291 "UnwindInfo instance refers to a stale PendingFrame");
292 return NULL;
293 }
294 if (!PyArg_UnpackTuple (args, "previous_frame_register", 2, 2,
295 &pyo_reg_id, &pyo_reg_value))
296 return NULL;
297 if (!pyuw_parse_register_id (pending_frame->gdbarch, pyo_reg_id, &regnum))
298 {
299 PyErr_SetString (PyExc_ValueError, "Bad register");
300 return NULL;
301 }
302 {
303 struct value *value;
304 size_t data_size;
305
306 if (pyo_reg_value == NULL
307 || (value = value_object_to_value (pyo_reg_value)) == NULL)
308 {
309 PyErr_SetString (PyExc_ValueError, "Bad register value");
310 return NULL;
311 }
312 data_size = register_size (pending_frame->gdbarch, regnum);
313 if (data_size != TYPE_LENGTH (value_type (value)))
314 {
315 PyErr_Format (
316 PyExc_ValueError,
317 "The value of the register returned by the Python "
318 "sniffer has unexpected size: %u instead of %u.",
319 (unsigned) TYPE_LENGTH (value_type (value)),
320 (unsigned) data_size);
321 return NULL;
322 }
323 }
324 {
325 int i;
326 saved_reg *reg;
327
328 for (i = 0; VEC_iterate (saved_reg, unwind_info->saved_regs, i, reg); i++)
329 {
330 if (regnum == reg->number)
331 {
332 Py_DECREF (reg->value);
333 break;
334 }
335 }
336 if (reg == NULL)
337 {
338 reg = VEC_safe_push (saved_reg, unwind_info->saved_regs, NULL);
339 reg->number = regnum;
340 }
341 Py_INCREF (pyo_reg_value);
342 reg->value = pyo_reg_value;
343 }
344 Py_RETURN_NONE;
345 }
346
347 /* UnwindInfo cleanup. */
348
349 static void
350 unwind_infopy_dealloc (PyObject *self)
351 {
352 unwind_info_object *unwind_info = (unwind_info_object *) self;
353 int i;
354 saved_reg *reg;
355
356 Py_XDECREF (unwind_info->pending_frame);
357 for (i = 0; VEC_iterate (saved_reg, unwind_info->saved_regs, i, reg); i++)
358 Py_DECREF (reg->value);
359 VEC_free (saved_reg, unwind_info->saved_regs);
360 Py_TYPE (self)->tp_free (self);
361 }
362
363 /* Called by the Python interpreter to obtain string representation
364 of the PendingFrame object. */
365
366 static PyObject *
367 pending_framepy_str (PyObject *self)
368 {
369 struct frame_info *frame = ((pending_frame_object *) self)->frame_info;
370 const char *sp_str = NULL;
371 const char *pc_str = NULL;
372
373 if (frame == NULL)
374 return PyString_FromString ("Stale PendingFrame instance");
375 TRY
376 {
377 sp_str = core_addr_to_string_nz (get_frame_sp (frame));
378 pc_str = core_addr_to_string_nz (get_frame_pc (frame));
379 }
380 CATCH (except, RETURN_MASK_ALL)
381 {
382 GDB_PY_HANDLE_EXCEPTION (except);
383 }
384 END_CATCH
385
386 return PyString_FromFormat ("SP=%s,PC=%s", sp_str, pc_str);
387 }
388
389 /* Implementation of gdb.PendingFrame.read_register (self, reg) -> gdb.Value.
390 Returns the value of register REG as gdb.Value instance. */
391
392 static PyObject *
393 pending_framepy_read_register (PyObject *self, PyObject *args)
394 {
395 pending_frame_object *pending_frame = (pending_frame_object *) self;
396 struct value *val = NULL;
397 int regnum;
398 PyObject *pyo_reg_id;
399
400 if (pending_frame->frame_info == NULL)
401 {
402 PyErr_SetString (PyExc_ValueError,
403 "Attempting to read register from stale PendingFrame");
404 return NULL;
405 }
406 if (!PyArg_UnpackTuple (args, "read_register", 1, 1, &pyo_reg_id))
407 return NULL;
408 if (!pyuw_parse_register_id (pending_frame->gdbarch, pyo_reg_id, &regnum))
409 {
410 PyErr_SetString (PyExc_ValueError, "Bad register");
411 return NULL;
412 }
413
414 TRY
415 {
416 val = get_frame_register_value (pending_frame->frame_info, regnum);
417 if (val == NULL)
418 PyErr_Format (PyExc_ValueError,
419 "Cannot read register %d from frame.",
420 regnum);
421 }
422 CATCH (except, RETURN_MASK_ALL)
423 {
424 GDB_PY_HANDLE_EXCEPTION (except);
425 }
426 END_CATCH
427
428 return val == NULL ? NULL : value_to_value_object (val);
429 }
430
431 /* Implementation of
432 PendingFrame.create_unwind_info (self, frameId) -> UnwindInfo. */
433
434 static PyObject *
435 pending_framepy_create_unwind_info (PyObject *self, PyObject *args)
436 {
437 PyObject *pyo_frame_id;
438 CORE_ADDR sp;
439 CORE_ADDR pc;
440 CORE_ADDR special;
441
442 if (!PyArg_ParseTuple (args, "O:create_unwind_info", &pyo_frame_id))
443 return NULL;
444 if (!pyuw_object_attribute_to_pointer (pyo_frame_id, "sp", &sp))
445 {
446 PyErr_SetString (PyExc_ValueError,
447 _("frame_id should have 'sp' attribute."));
448 return NULL;
449 }
450
451 /* The logic of building frame_id depending on the attributes of
452 the frame_id object:
453 Has Has Has Function to call
454 'sp'? 'pc'? 'special'?
455 ------|------|--------------|-------------------------
456 Y N * frame_id_build_wild (sp)
457 Y Y N frame_id_build (sp, pc)
458 Y Y Y frame_id_build_special (sp, pc, special)
459 */
460 if (!pyuw_object_attribute_to_pointer (pyo_frame_id, "pc", &pc))
461 return pyuw_create_unwind_info (self, frame_id_build_wild (sp));
462 if (!pyuw_object_attribute_to_pointer (pyo_frame_id, "special", &special))
463 return pyuw_create_unwind_info (self, frame_id_build (sp, pc));
464 else
465 return pyuw_create_unwind_info (self,
466 frame_id_build_special (sp, pc, special));
467 }
468
469 /* Invalidate PendingFrame instance. */
470
471 static void
472 pending_frame_invalidate (void *pyo_pending_frame)
473 {
474 if (pyo_pending_frame != NULL)
475 ((pending_frame_object *) pyo_pending_frame)->frame_info = NULL;
476 }
477
478 /* frame_unwind.this_id method. */
479
480 static void
481 pyuw_this_id (struct frame_info *this_frame, void **cache_ptr,
482 struct frame_id *this_id)
483 {
484 *this_id = ((cached_frame_info *) *cache_ptr)->frame_id;
485 if (pyuw_debug >= 1)
486 {
487 fprintf_unfiltered (gdb_stdlog, "%s: frame_id: ", __FUNCTION__);
488 fprint_frame_id (gdb_stdlog, *this_id);
489 fprintf_unfiltered (gdb_stdlog, "\n");
490 }
491 }
492
493 /* frame_unwind.prev_register. */
494
495 static struct value *
496 pyuw_prev_register (struct frame_info *this_frame, void **cache_ptr,
497 int regnum)
498 {
499 cached_frame_info *cached_frame = *cache_ptr;
500 struct reg_info *reg_info = cached_frame->reg;
501 struct reg_info *reg_info_end = reg_info + cached_frame->reg_count;
502
503 TRACE_PY_UNWIND (1, "%s (frame=%p,...,reg=%d)\n", __FUNCTION__, this_frame,
504 regnum);
505 for (; reg_info < reg_info_end; ++reg_info)
506 {
507 if (regnum == reg_info->number)
508 return frame_unwind_got_bytes (this_frame, regnum, reg_info->data);
509 }
510
511 return frame_unwind_got_optimized (this_frame, regnum);
512 }
513
514 /* Frame sniffer dispatch. */
515
516 static int
517 pyuw_sniffer (const struct frame_unwind *self, struct frame_info *this_frame,
518 void **cache_ptr)
519 {
520 struct gdbarch *gdbarch = (struct gdbarch *) (self->unwind_data);
521 struct cleanup *cleanups = ensure_python_env (gdbarch, current_language);
522 PyObject *pyo_execute;
523 PyObject *pyo_pending_frame;
524 PyObject *pyo_unwind_info;
525 cached_frame_info *cached_frame;
526
527 TRACE_PY_UNWIND (3, "%s (SP=%s, PC=%s)\n", __FUNCTION__,
528 paddress (gdbarch, get_frame_sp (this_frame)),
529 paddress (gdbarch, get_frame_pc (this_frame)));
530
531 /* Create PendingFrame instance to pass to sniffers. */
532 pyo_pending_frame = (PyObject *) PyObject_New (pending_frame_object,
533 &pending_frame_object_type);
534 if (pyo_pending_frame == NULL)
535 goto error;
536 ((pending_frame_object *) pyo_pending_frame)->gdbarch = gdbarch;
537 ((pending_frame_object *) pyo_pending_frame)->frame_info = this_frame;
538 make_cleanup (pending_frame_invalidate, (void *) pyo_pending_frame);
539 make_cleanup_py_decref (pyo_pending_frame);
540
541 /* Run unwinders. */
542 if (gdb_python_module == NULL
543 || ! PyObject_HasAttrString (gdb_python_module, "execute_unwinders"))
544 {
545 PyErr_SetString (PyExc_NameError,
546 "Installation error: gdb.execute_unwinders function "
547 "is missing");
548 goto error;
549 }
550 pyo_execute = PyObject_GetAttrString (gdb_python_module, "execute_unwinders");
551 if (pyo_execute == NULL)
552 goto error;
553 make_cleanup_py_decref (pyo_execute);
554 pyo_unwind_info
555 = PyObject_CallFunctionObjArgs (pyo_execute, pyo_pending_frame, NULL);
556 if (pyo_unwind_info == NULL)
557 goto error;
558 make_cleanup_py_decref (pyo_unwind_info);
559 if (pyo_unwind_info == Py_None)
560 goto cannot_unwind;
561
562 /* Received UnwindInfo, cache data. */
563 if (PyObject_IsInstance (pyo_unwind_info,
564 (PyObject *) &unwind_info_object_type) <= 0)
565 error (_("A Unwinder should return gdb.UnwindInfo instance."));
566
567 {
568 unwind_info_object *unwind_info = (unwind_info_object *) pyo_unwind_info;
569 int reg_count = VEC_length (saved_reg, unwind_info->saved_regs);
570 saved_reg *reg;
571 int i;
572
573 cached_frame = xmalloc (sizeof (*cached_frame) +
574 reg_count * sizeof (cached_frame->reg[0]));
575 cached_frame->gdbarch = gdbarch;
576 cached_frame->frame_id = unwind_info->frame_id;
577 cached_frame->reg_count = reg_count;
578
579 /* Populate registers array. */
580 for (i = 0; VEC_iterate (saved_reg, unwind_info->saved_regs, i, reg); i++)
581 {
582 struct value *value = value_object_to_value (reg->value);
583 size_t data_size = register_size (gdbarch, reg->number);
584
585 cached_frame->reg[i].number = reg->number;
586
587 /* `value' validation was done before, just assert. */
588 gdb_assert (value != NULL);
589 gdb_assert (data_size == TYPE_LENGTH (value_type (value)));
590 gdb_assert (data_size <= MAX_REGISTER_SIZE);
591
592 memcpy (cached_frame->reg[i].data, value_contents (value), data_size);
593 }
594 }
595
596 *cache_ptr = cached_frame;
597 do_cleanups (cleanups);
598 return 1;
599
600 error:
601 gdbpy_print_stack ();
602 /* Fallthrough. */
603 cannot_unwind:
604 do_cleanups (cleanups);
605 return 0;
606 }
607
608 /* Frame cache release shim. */
609
610 static void
611 pyuw_dealloc_cache (struct frame_info *this_frame, void *cache)
612 {
613 TRACE_PY_UNWIND (3, "%s: enter", __FUNCTION__);
614 xfree (cache);
615 }
616
617 struct pyuw_gdbarch_data_type
618 {
619 /* Has the unwinder shim been prepended? */
620 int unwinder_registered;
621 };
622
623 static void *
624 pyuw_gdbarch_data_init (struct gdbarch *gdbarch)
625 {
626 return GDBARCH_OBSTACK_ZALLOC (gdbarch, struct pyuw_gdbarch_data_type);
627 }
628
629 /* New inferior architecture callback: register the Python unwinders
630 intermediary. */
631
632 static void
633 pyuw_on_new_gdbarch (struct gdbarch *newarch)
634 {
635 struct pyuw_gdbarch_data_type *data =
636 gdbarch_data (newarch, 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 = (void *) 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 static 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 static 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.065066 seconds and 4 git commands to generate.