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