* python/py-arch.c (gdbpy_initialize_arch): Return 'int'.
[platform/upstream/binutils.git] / gdb / python / py-frame.c
1 /* Python interface to stack frames
2
3    Copyright (C) 2008-2013 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 "charset.h"
22 #include "block.h"
23 #include "frame.h"
24 #include "exceptions.h"
25 #include "symtab.h"
26 #include "stack.h"
27 #include "value.h"
28 #include "python-internal.h"
29 #include "symfile.h"
30 #include "objfiles.h"
31
32 typedef struct {
33   PyObject_HEAD
34   struct frame_id frame_id;
35   struct gdbarch *gdbarch;
36
37   /* Marks that the FRAME_ID member actually holds the ID of the frame next
38      to this, and not this frames' ID itself.  This is a hack to permit Python
39      frame objects which represent invalid frames (i.e., the last frame_info
40      in a corrupt stack).  The problem arises from the fact that this code
41      relies on FRAME_ID to uniquely identify a frame, which is not always true
42      for the last "frame" in a corrupt stack (it can have a null ID, or the same
43      ID as the  previous frame).  Whenever get_prev_frame returns NULL, we
44      record the frame_id of the next frame and set FRAME_ID_IS_NEXT to 1.  */
45   int frame_id_is_next;
46 } frame_object;
47
48 /* Require a valid frame.  This must be called inside a TRY_CATCH, or
49    another context in which a gdb exception is allowed.  */
50 #define FRAPY_REQUIRE_VALID(frame_obj, frame)           \
51     do {                                                \
52       frame = frame_object_to_frame_info (frame_obj);   \
53       if (frame == NULL)                                \
54         error (_("Frame is invalid."));                 \
55     } while (0)
56
57 /* Returns the frame_info object corresponding to the given Python Frame
58    object.  If the frame doesn't exist anymore (the frame id doesn't
59    correspond to any frame in the inferior), returns NULL.  */
60
61 struct frame_info *
62 frame_object_to_frame_info (PyObject *obj)
63 {
64   frame_object *frame_obj = (frame_object *) obj;  
65   struct frame_info *frame;
66
67   frame = frame_find_by_id (frame_obj->frame_id);
68   if (frame == NULL)
69     return NULL;
70
71   if (frame_obj->frame_id_is_next)
72     frame = get_prev_frame (frame);
73
74   return frame;
75 }
76
77 /* Called by the Python interpreter to obtain string representation
78    of the object.  */
79
80 static PyObject *
81 frapy_str (PyObject *self)
82 {
83   char *s;
84   PyObject *result;
85   struct ui_file *strfile;
86
87   strfile = mem_fileopen ();
88   fprint_frame_id (strfile, ((frame_object *) self)->frame_id);
89   s = ui_file_xstrdup (strfile, NULL);
90   result = PyString_FromString (s);
91   xfree (s);
92
93   return result;
94 }
95
96 /* Implementation of gdb.Frame.is_valid (self) -> Boolean.
97    Returns True if the frame corresponding to the frame_id of this
98    object still exists in the inferior.  */
99
100 static PyObject *
101 frapy_is_valid (PyObject *self, PyObject *args)
102 {
103   struct frame_info *frame = NULL;
104   volatile struct gdb_exception except;
105
106   TRY_CATCH (except, RETURN_MASK_ALL)
107     {
108       frame = frame_object_to_frame_info (self);
109     }
110   GDB_PY_HANDLE_EXCEPTION (except);
111
112   if (frame == NULL)
113     Py_RETURN_FALSE;
114
115   Py_RETURN_TRUE;
116 }
117
118 /* Implementation of gdb.Frame.name (self) -> String.
119    Returns the name of the function corresponding to this frame.  */
120
121 static PyObject *
122 frapy_name (PyObject *self, PyObject *args)
123 {
124   struct frame_info *frame;
125   const char *name;
126   enum language lang;
127   PyObject *result;
128   volatile struct gdb_exception except;
129
130   TRY_CATCH (except, RETURN_MASK_ALL)
131     {
132       FRAPY_REQUIRE_VALID (self, frame);
133
134       find_frame_funname (frame, &name, &lang, NULL);
135     }
136   GDB_PY_HANDLE_EXCEPTION (except);
137
138   if (name)
139     result = PyUnicode_Decode (name, strlen (name), host_charset (), NULL);
140   else
141     {
142       result = Py_None;
143       Py_INCREF (Py_None);
144     }
145
146   return result;
147 }
148
149 /* Implementation of gdb.Frame.type (self) -> Integer.
150    Returns the frame type, namely one of the gdb.*_FRAME constants.  */
151
152 static PyObject *
153 frapy_type (PyObject *self, PyObject *args)
154 {
155   struct frame_info *frame;
156   enum frame_type type = NORMAL_FRAME;/* Initialize to appease gcc warning.  */
157   volatile struct gdb_exception except;
158
159   TRY_CATCH (except, RETURN_MASK_ALL)
160     {
161       FRAPY_REQUIRE_VALID (self, frame);
162
163       type = get_frame_type (frame);
164     }
165   GDB_PY_HANDLE_EXCEPTION (except);
166
167   return PyInt_FromLong (type);
168 }
169
170 /* Implementation of gdb.Frame.architecture (self) -> gdb.Architecture.
171    Returns the frame's architecture as a gdb.Architecture object.  */
172
173 static PyObject *
174 frapy_arch (PyObject *self, PyObject *args)
175 {
176   struct frame_info *frame = NULL;    /* Initialize to appease gcc warning.  */
177   frame_object *obj = (frame_object *) self;
178   volatile struct gdb_exception except;
179
180   TRY_CATCH (except, RETURN_MASK_ALL)
181     {
182       FRAPY_REQUIRE_VALID (self, frame);
183     }
184   GDB_PY_HANDLE_EXCEPTION (except);
185
186   return gdbarch_to_arch_object (obj->gdbarch);
187 }
188
189 /* Implementation of gdb.Frame.unwind_stop_reason (self) -> Integer.
190    Returns one of the gdb.FRAME_UNWIND_* constants.  */
191
192 static PyObject *
193 frapy_unwind_stop_reason (PyObject *self, PyObject *args)
194 {
195   struct frame_info *frame = NULL;    /* Initialize to appease gcc warning.  */
196   volatile struct gdb_exception except;
197   enum unwind_stop_reason stop_reason;
198
199   TRY_CATCH (except, RETURN_MASK_ALL)
200     {
201       FRAPY_REQUIRE_VALID (self, frame);
202     }
203   GDB_PY_HANDLE_EXCEPTION (except);
204
205   stop_reason = get_frame_unwind_stop_reason (frame);
206
207   return PyInt_FromLong (stop_reason);
208 }
209
210 /* Implementation of gdb.Frame.pc (self) -> Long.
211    Returns the frame's resume address.  */
212
213 static PyObject *
214 frapy_pc (PyObject *self, PyObject *args)
215 {
216   CORE_ADDR pc = 0;           /* Initialize to appease gcc warning.  */
217   struct frame_info *frame;
218   volatile struct gdb_exception except;
219
220   TRY_CATCH (except, RETURN_MASK_ALL)
221     {
222       FRAPY_REQUIRE_VALID (self, frame);
223
224       pc = get_frame_pc (frame);
225     }
226   GDB_PY_HANDLE_EXCEPTION (except);
227
228   return gdb_py_long_from_ulongest (pc);
229 }
230
231 /* Implementation of gdb.Frame.block (self) -> gdb.Block.
232    Returns the frame's code block.  */
233
234 static PyObject *
235 frapy_block (PyObject *self, PyObject *args)
236 {
237   struct frame_info *frame;
238   struct block *block = NULL, *fn_block;
239   volatile struct gdb_exception except;
240
241   TRY_CATCH (except, RETURN_MASK_ALL)
242     {
243       FRAPY_REQUIRE_VALID (self, frame);
244       block = get_frame_block (frame, NULL);
245     }
246   GDB_PY_HANDLE_EXCEPTION (except);
247
248   for (fn_block = block;
249        fn_block != NULL && BLOCK_FUNCTION (fn_block) == NULL;
250        fn_block = BLOCK_SUPERBLOCK (fn_block))
251     ;
252
253   if (block == NULL || fn_block == NULL || BLOCK_FUNCTION (fn_block) == NULL)
254     {
255       PyErr_SetString (PyExc_RuntimeError,
256                        _("Cannot locate object file for block."));
257       return NULL;
258     }
259
260   if (block)
261     {
262       struct symtab *symt;
263
264       symt = SYMBOL_SYMTAB (BLOCK_FUNCTION (fn_block));
265       return block_to_block_object (block, symt->objfile);
266     }
267
268   Py_RETURN_NONE;
269 }
270
271
272 /* Implementation of gdb.Frame.function (self) -> gdb.Symbol.
273    Returns the symbol for the function corresponding to this frame.  */
274
275 static PyObject *
276 frapy_function (PyObject *self, PyObject *args)
277 {
278   struct symbol *sym = NULL;
279   struct frame_info *frame;
280   volatile struct gdb_exception except;
281
282   TRY_CATCH (except, RETURN_MASK_ALL)
283     {
284       FRAPY_REQUIRE_VALID (self, frame);
285
286       sym = find_pc_function (get_frame_address_in_block (frame));
287     }
288   GDB_PY_HANDLE_EXCEPTION (except);
289
290   if (sym)
291     return symbol_to_symbol_object (sym);
292
293   Py_RETURN_NONE;
294 }
295
296 /* Convert a frame_info struct to a Python Frame object.
297    Sets a Python exception and returns NULL on error.  */
298
299 PyObject *
300 frame_info_to_frame_object (struct frame_info *frame)
301 {
302   frame_object *frame_obj;
303   volatile struct gdb_exception except;
304
305   frame_obj = PyObject_New (frame_object, &frame_object_type);
306   if (frame_obj == NULL)
307     return NULL;
308
309   TRY_CATCH (except, RETURN_MASK_ALL)
310     {
311
312       /* Try to get the previous frame, to determine if this is the last frame
313          in a corrupt stack.  If so, we need to store the frame_id of the next
314          frame and not of this one (which is possibly invalid).  */
315       if (get_prev_frame (frame) == NULL
316           && get_frame_unwind_stop_reason (frame) != UNWIND_NO_REASON
317           && get_next_frame (frame) != NULL)
318         {
319           frame_obj->frame_id = get_frame_id (get_next_frame (frame));
320           frame_obj->frame_id_is_next = 1;
321         }
322       else
323         {
324           frame_obj->frame_id = get_frame_id (frame);
325           frame_obj->frame_id_is_next = 0;
326         }
327       frame_obj->gdbarch = get_frame_arch (frame);
328     }
329   GDB_PY_HANDLE_EXCEPTION (except);
330
331   return (PyObject *) frame_obj;
332 }
333
334 /* Implementation of gdb.Frame.older (self) -> gdb.Frame.
335    Returns the frame immediately older (outer) to this frame, or None if
336    there isn't one.  */
337
338 static PyObject *
339 frapy_older (PyObject *self, PyObject *args)
340 {
341   struct frame_info *frame, *prev;
342   volatile struct gdb_exception except;
343   PyObject *prev_obj = NULL;   /* Initialize to appease gcc warning.  */
344
345   TRY_CATCH (except, RETURN_MASK_ALL)
346     {
347       FRAPY_REQUIRE_VALID (self, frame);
348
349       prev = get_prev_frame (frame);
350       if (prev)
351         prev_obj = (PyObject *) frame_info_to_frame_object (prev);
352       else
353         {
354           Py_INCREF (Py_None);
355           prev_obj = Py_None;
356         }
357     }
358   GDB_PY_HANDLE_EXCEPTION (except);
359
360   return prev_obj;
361 }
362
363 /* Implementation of gdb.Frame.newer (self) -> gdb.Frame.
364    Returns the frame immediately newer (inner) to this frame, or None if
365    there isn't one.  */
366
367 static PyObject *
368 frapy_newer (PyObject *self, PyObject *args)
369 {
370   struct frame_info *frame, *next;
371   volatile struct gdb_exception except;
372   PyObject *next_obj = NULL;   /* Initialize to appease gcc warning.  */
373
374   TRY_CATCH (except, RETURN_MASK_ALL)
375     {
376       FRAPY_REQUIRE_VALID (self, frame);
377
378       next = get_next_frame (frame);
379       if (next)
380         next_obj = (PyObject *) frame_info_to_frame_object (next);
381       else
382         {
383           Py_INCREF (Py_None);
384           next_obj = Py_None;
385         }
386     }
387   GDB_PY_HANDLE_EXCEPTION (except);
388
389   return next_obj;
390 }
391
392 /* Implementation of gdb.Frame.find_sal (self) -> gdb.Symtab_and_line.
393    Returns the frame's symtab and line.  */
394
395 static PyObject *
396 frapy_find_sal (PyObject *self, PyObject *args)
397 {
398   struct frame_info *frame;
399   struct symtab_and_line sal;
400   volatile struct gdb_exception except;
401   PyObject *sal_obj = NULL;   /* Initialize to appease gcc warning.  */
402
403   TRY_CATCH (except, RETURN_MASK_ALL)
404     {
405       FRAPY_REQUIRE_VALID (self, frame);
406
407       find_frame_sal (frame, &sal);
408       sal_obj = symtab_and_line_to_sal_object (sal);
409     }
410   GDB_PY_HANDLE_EXCEPTION (except);
411
412   return sal_obj;
413 }
414
415 /* Implementation of gdb.Frame.read_var_value (self, variable,
416    [block]) -> gdb.Value.  If the optional block argument is provided
417    start the search from that block, otherwise search from the frame's
418    current block (determined by examining the resume address of the
419    frame).  The variable argument must be a string or an instance of a
420    gdb.Symbol.  The block argument must be an instance of gdb.Block.  Returns
421    NULL on error, with a python exception set.  */
422 static PyObject *
423 frapy_read_var (PyObject *self, PyObject *args)
424 {
425   struct frame_info *frame;
426   PyObject *sym_obj, *block_obj = NULL;
427   struct symbol *var = NULL;    /* gcc-4.3.2 false warning.  */
428   struct value *val = NULL;
429   volatile struct gdb_exception except;
430
431   if (!PyArg_ParseTuple (args, "O|O", &sym_obj, &block_obj))
432     return NULL;
433
434   if (PyObject_TypeCheck (sym_obj, &symbol_object_type))
435     var = symbol_object_to_symbol (sym_obj);
436   else if (gdbpy_is_string (sym_obj))
437     {
438       char *var_name;
439       const struct block *block = NULL;
440       struct cleanup *cleanup;
441       volatile struct gdb_exception except;
442
443       var_name = python_string_to_target_string (sym_obj);
444       if (!var_name)
445         return NULL;
446       cleanup = make_cleanup (xfree, var_name);
447
448       if (block_obj)
449         {
450           block = block_object_to_block (block_obj);
451           if (!block)
452             {
453               PyErr_SetString (PyExc_RuntimeError,
454                                _("Second argument must be block."));
455               return NULL;
456             }
457         }
458
459       TRY_CATCH (except, RETURN_MASK_ALL)
460         {
461           FRAPY_REQUIRE_VALID (self, frame);
462
463           if (!block)
464             block = get_frame_block (frame, NULL);
465           var = lookup_symbol (var_name, block, VAR_DOMAIN, NULL);
466         }
467       GDB_PY_HANDLE_EXCEPTION (except);
468
469       if (!var)
470         {
471           PyErr_Format (PyExc_ValueError,
472                         _("Variable '%s' not found."), var_name);
473           do_cleanups (cleanup);
474
475           return NULL;
476         }
477
478       do_cleanups (cleanup);
479     }
480   else
481     {
482       PyErr_SetString (PyExc_TypeError,
483                        _("Argument must be a symbol or string."));
484       return NULL;
485     }
486
487   TRY_CATCH (except, RETURN_MASK_ALL)
488     {
489       FRAPY_REQUIRE_VALID (self, frame);
490
491       val = read_var_value (var, frame);
492     }
493   GDB_PY_HANDLE_EXCEPTION (except);
494
495   return value_to_value_object (val);
496 }
497
498 /* Select this frame.  */
499
500 static PyObject *
501 frapy_select (PyObject *self, PyObject *args)
502 {
503   struct frame_info *fi;
504   volatile struct gdb_exception except;
505
506   TRY_CATCH (except, RETURN_MASK_ALL)
507     {
508       FRAPY_REQUIRE_VALID (self, fi);
509
510       select_frame (fi);
511     }
512   GDB_PY_HANDLE_EXCEPTION (except);
513
514   Py_RETURN_NONE;
515 }
516
517 /* Implementation of gdb.newest_frame () -> gdb.Frame.
518    Returns the newest frame object.  */
519
520 PyObject *
521 gdbpy_newest_frame (PyObject *self, PyObject *args)
522 {
523   struct frame_info *frame;
524   PyObject *frame_obj = NULL;   /* Initialize to appease gcc warning.  */
525   volatile struct gdb_exception except;
526
527   TRY_CATCH (except, RETURN_MASK_ALL)
528     {
529       frame = get_current_frame ();
530       frame_obj = frame_info_to_frame_object (frame);
531     }
532   GDB_PY_HANDLE_EXCEPTION (except);
533
534   return frame_obj;
535 }
536
537 /* Implementation of gdb.selected_frame () -> gdb.Frame.
538    Returns the selected frame object.  */
539
540 PyObject *
541 gdbpy_selected_frame (PyObject *self, PyObject *args)
542 {
543   struct frame_info *frame;
544   PyObject *frame_obj = NULL;   /* Initialize to appease gcc warning.  */
545   volatile struct gdb_exception except;
546
547   TRY_CATCH (except, RETURN_MASK_ALL)
548     {
549       frame = get_selected_frame ("No frame is currently selected.");
550       frame_obj = frame_info_to_frame_object (frame);
551     }
552   GDB_PY_HANDLE_EXCEPTION (except);
553
554   return frame_obj;
555 }
556
557 /* Implementation of gdb.stop_reason_string (Integer) -> String.
558    Return a string explaining the unwind stop reason.  */
559
560 PyObject *
561 gdbpy_frame_stop_reason_string (PyObject *self, PyObject *args)
562 {
563   int reason;
564   const char *str;
565
566   if (!PyArg_ParseTuple (args, "i", &reason))
567     return NULL;
568
569   if (reason < UNWIND_FIRST || reason > UNWIND_LAST)
570     {
571       PyErr_SetString (PyExc_ValueError, 
572                        _("Invalid frame stop reason."));
573       return NULL;
574     }
575
576   str = frame_stop_reason_string (reason);
577   return PyUnicode_Decode (str, strlen (str), host_charset (), NULL);
578 }
579
580 /* Implements the equality comparison for Frame objects.
581    All other comparison operators will throw a TypeError Python exception,
582    as they aren't valid for frames.  */
583
584 static PyObject *
585 frapy_richcompare (PyObject *self, PyObject *other, int op)
586 {
587   int result;
588
589   if (!PyObject_TypeCheck (other, &frame_object_type)
590       || (op != Py_EQ && op != Py_NE))
591     {
592       Py_INCREF (Py_NotImplemented);
593       return Py_NotImplemented;
594     }
595
596   if (frame_id_eq (((frame_object *) self)->frame_id,
597                    ((frame_object *) other)->frame_id))
598     result = Py_EQ;
599   else
600     result = Py_NE;
601
602   if (op == result)
603     Py_RETURN_TRUE;
604   Py_RETURN_FALSE;
605 }
606
607 /* Sets up the Frame API in the gdb module.  */
608
609 int
610 gdbpy_initialize_frames (void)
611 {
612   frame_object_type.tp_new = PyType_GenericNew;
613   if (PyType_Ready (&frame_object_type) < 0)
614     return -1;
615
616   /* Note: These would probably be best exposed as class attributes of
617      Frame, but I don't know how to do it except by messing with the
618      type's dictionary.  That seems too messy.  */
619   if (PyModule_AddIntConstant (gdb_module, "NORMAL_FRAME", NORMAL_FRAME) < 0
620       || PyModule_AddIntConstant (gdb_module, "DUMMY_FRAME", DUMMY_FRAME) < 0
621       || PyModule_AddIntConstant (gdb_module, "INLINE_FRAME", INLINE_FRAME) < 0
622       || PyModule_AddIntConstant (gdb_module, "TAILCALL_FRAME",
623                                   TAILCALL_FRAME) < 0
624       || PyModule_AddIntConstant (gdb_module, "SIGTRAMP_FRAME",
625                                   SIGTRAMP_FRAME) < 0
626       || PyModule_AddIntConstant (gdb_module, "ARCH_FRAME", ARCH_FRAME) < 0
627       || PyModule_AddIntConstant (gdb_module, "SENTINEL_FRAME",
628                                   SENTINEL_FRAME) < 0)
629     return -1;
630
631 #define SET(name, description) \
632   if (PyModule_AddIntConstant (gdb_module, "FRAME_"#name, name) < 0) \
633     return -1;
634 #define FIRST_ERROR(name) \
635   if (PyModule_AddIntConstant (gdb_module, "FRAME_"#name, name) < 0) \
636     return -1;
637 #include "unwind_stop_reasons.def"
638 #undef SET
639 #undef FIRST_ERROR
640
641   Py_INCREF (&frame_object_type);
642   return PyModule_AddObject (gdb_module, "Frame",
643                              (PyObject *) &frame_object_type);
644 }
645
646 \f
647
648 static PyMethodDef frame_object_methods[] = {
649   { "is_valid", frapy_is_valid, METH_NOARGS,
650     "is_valid () -> Boolean.\n\
651 Return true if this frame is valid, false if not." },
652   { "name", frapy_name, METH_NOARGS,
653     "name () -> String.\n\
654 Return the function name of the frame, or None if it can't be determined." },
655   { "type", frapy_type, METH_NOARGS,
656     "type () -> Integer.\n\
657 Return the type of the frame." },
658   { "architecture", frapy_arch, METH_NOARGS,
659     "architecture () -> gdb.Architecture.\n\
660 Return the architecture of the frame." },
661   { "unwind_stop_reason", frapy_unwind_stop_reason, METH_NOARGS,
662     "unwind_stop_reason () -> Integer.\n\
663 Return the reason why it's not possible to find frames older than this." },
664   { "pc", frapy_pc, METH_NOARGS,
665     "pc () -> Long.\n\
666 Return the frame's resume address." },
667   { "block", frapy_block, METH_NOARGS,
668     "block () -> gdb.Block.\n\
669 Return the frame's code block." },
670   { "function", frapy_function, METH_NOARGS,
671     "function () -> gdb.Symbol.\n\
672 Returns the symbol for the function corresponding to this frame." },
673   { "older", frapy_older, METH_NOARGS,
674     "older () -> gdb.Frame.\n\
675 Return the frame that called this frame." },
676   { "newer", frapy_newer, METH_NOARGS,
677     "newer () -> gdb.Frame.\n\
678 Return the frame called by this frame." },
679   { "find_sal", frapy_find_sal, METH_NOARGS,
680     "find_sal () -> gdb.Symtab_and_line.\n\
681 Return the frame's symtab and line." },
682   { "read_var", frapy_read_var, METH_VARARGS,
683     "read_var (variable) -> gdb.Value.\n\
684 Return the value of the variable in this frame." },
685   { "select", frapy_select, METH_NOARGS,
686     "Select this frame as the user's current frame." },
687   {NULL}  /* Sentinel */
688 };
689
690 PyTypeObject frame_object_type = {
691   PyVarObject_HEAD_INIT (NULL, 0)
692   "gdb.Frame",                    /* tp_name */
693   sizeof (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   frapy_str,                      /* tp_str */
707   0,                              /* tp_getattro */
708   0,                              /* tp_setattro */
709   0,                              /* tp_as_buffer */
710   Py_TPFLAGS_DEFAULT,             /* tp_flags */
711   "GDB frame object",             /* tp_doc */
712   0,                              /* tp_traverse */
713   0,                              /* tp_clear */
714   frapy_richcompare,              /* tp_richcompare */
715   0,                              /* tp_weaklistoffset */
716   0,                              /* tp_iter */
717   0,                              /* tp_iternext */
718   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 };