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