GDB (API)
/home/stan/gdb/src/gdb/python/py-frame.c
Go to the documentation of this file.
00001 /* Python interface to stack frames
00002 
00003    Copyright (C) 2008-2013 Free Software Foundation, Inc.
00004 
00005    This file is part of GDB.
00006 
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; either version 3 of the License, or
00010    (at your option) any later version.
00011 
00012    This program is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016 
00017    You should have received a copy of the GNU General Public License
00018    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
00019 
00020 #include "defs.h"
00021 #include "charset.h"
00022 #include "block.h"
00023 #include "frame.h"
00024 #include "exceptions.h"
00025 #include "symtab.h"
00026 #include "stack.h"
00027 #include "value.h"
00028 #include "python-internal.h"
00029 #include "symfile.h"
00030 #include "objfiles.h"
00031 
00032 typedef struct {
00033   PyObject_HEAD
00034   struct frame_id frame_id;
00035   struct gdbarch *gdbarch;
00036 
00037   /* Marks that the FRAME_ID member actually holds the ID of the frame next
00038      to this, and not this frames' ID itself.  This is a hack to permit Python
00039      frame objects which represent invalid frames (i.e., the last frame_info
00040      in a corrupt stack).  The problem arises from the fact that this code
00041      relies on FRAME_ID to uniquely identify a frame, which is not always true
00042      for the last "frame" in a corrupt stack (it can have a null ID, or the same
00043      ID as the  previous frame).  Whenever get_prev_frame returns NULL, we
00044      record the frame_id of the next frame and set FRAME_ID_IS_NEXT to 1.  */
00045   int frame_id_is_next;
00046 } frame_object;
00047 
00048 /* Require a valid frame.  This must be called inside a TRY_CATCH, or
00049    another context in which a gdb exception is allowed.  */
00050 #define FRAPY_REQUIRE_VALID(frame_obj, frame)           \
00051     do {                                                \
00052       frame = frame_object_to_frame_info (frame_obj);   \
00053       if (frame == NULL)                                \
00054         error (_("Frame is invalid."));                 \
00055     } while (0)
00056 
00057 /* Returns the frame_info object corresponding to the given Python Frame
00058    object.  If the frame doesn't exist anymore (the frame id doesn't
00059    correspond to any frame in the inferior), returns NULL.  */
00060 
00061 struct frame_info *
00062 frame_object_to_frame_info (PyObject *obj)
00063 {
00064   frame_object *frame_obj = (frame_object *) obj;  
00065   struct frame_info *frame;
00066 
00067   frame = frame_find_by_id (frame_obj->frame_id);
00068   if (frame == NULL)
00069     return NULL;
00070 
00071   if (frame_obj->frame_id_is_next)
00072     frame = get_prev_frame (frame);
00073 
00074   return frame;
00075 }
00076 
00077 /* Called by the Python interpreter to obtain string representation
00078    of the object.  */
00079 
00080 static PyObject *
00081 frapy_str (PyObject *self)
00082 {
00083   char *s;
00084   PyObject *result;
00085   struct ui_file *strfile;
00086 
00087   strfile = mem_fileopen ();
00088   fprint_frame_id (strfile, ((frame_object *) self)->frame_id);
00089   s = ui_file_xstrdup (strfile, NULL);
00090   result = PyString_FromString (s);
00091   xfree (s);
00092 
00093   return result;
00094 }
00095 
00096 /* Implementation of gdb.Frame.is_valid (self) -> Boolean.
00097    Returns True if the frame corresponding to the frame_id of this
00098    object still exists in the inferior.  */
00099 
00100 static PyObject *
00101 frapy_is_valid (PyObject *self, PyObject *args)
00102 {
00103   struct frame_info *frame = NULL;
00104   volatile struct gdb_exception except;
00105 
00106   TRY_CATCH (except, RETURN_MASK_ALL)
00107     {
00108       frame = frame_object_to_frame_info (self);
00109     }
00110   GDB_PY_HANDLE_EXCEPTION (except);
00111 
00112   if (frame == NULL)
00113     Py_RETURN_FALSE;
00114 
00115   Py_RETURN_TRUE;
00116 }
00117 
00118 /* Implementation of gdb.Frame.name (self) -> String.
00119    Returns the name of the function corresponding to this frame.  */
00120 
00121 static PyObject *
00122 frapy_name (PyObject *self, PyObject *args)
00123 {
00124   struct frame_info *frame;
00125   char *name = NULL;
00126   enum language lang;
00127   PyObject *result;
00128   volatile struct gdb_exception except;
00129 
00130   TRY_CATCH (except, RETURN_MASK_ALL)
00131     {
00132       FRAPY_REQUIRE_VALID (self, frame);
00133 
00134       find_frame_funname (frame, &name, &lang, NULL);
00135     }
00136 
00137   if (except.reason < 0)
00138     xfree (name);
00139 
00140   GDB_PY_HANDLE_EXCEPTION (except);
00141 
00142   if (name)
00143     {
00144       result = PyUnicode_Decode (name, strlen (name), host_charset (), NULL);
00145       xfree (name);
00146     }
00147   else
00148     {
00149       result = Py_None;
00150       Py_INCREF (Py_None);
00151     }
00152 
00153   return result;
00154 }
00155 
00156 /* Implementation of gdb.Frame.type (self) -> Integer.
00157    Returns the frame type, namely one of the gdb.*_FRAME constants.  */
00158 
00159 static PyObject *
00160 frapy_type (PyObject *self, PyObject *args)
00161 {
00162   struct frame_info *frame;
00163   enum frame_type type = NORMAL_FRAME;/* Initialize to appease gcc warning.  */
00164   volatile struct gdb_exception except;
00165 
00166   TRY_CATCH (except, RETURN_MASK_ALL)
00167     {
00168       FRAPY_REQUIRE_VALID (self, frame);
00169 
00170       type = get_frame_type (frame);
00171     }
00172   GDB_PY_HANDLE_EXCEPTION (except);
00173 
00174   return PyInt_FromLong (type);
00175 }
00176 
00177 /* Implementation of gdb.Frame.architecture (self) -> gdb.Architecture.
00178    Returns the frame's architecture as a gdb.Architecture object.  */
00179 
00180 static PyObject *
00181 frapy_arch (PyObject *self, PyObject *args)
00182 {
00183   struct frame_info *frame = NULL;    /* Initialize to appease gcc warning.  */
00184   frame_object *obj = (frame_object *) self;
00185   volatile struct gdb_exception except;
00186 
00187   TRY_CATCH (except, RETURN_MASK_ALL)
00188     {
00189       FRAPY_REQUIRE_VALID (self, frame);
00190     }
00191   GDB_PY_HANDLE_EXCEPTION (except);
00192 
00193   return gdbarch_to_arch_object (obj->gdbarch);
00194 }
00195 
00196 /* Implementation of gdb.Frame.unwind_stop_reason (self) -> Integer.
00197    Returns one of the gdb.FRAME_UNWIND_* constants.  */
00198 
00199 static PyObject *
00200 frapy_unwind_stop_reason (PyObject *self, PyObject *args)
00201 {
00202   struct frame_info *frame = NULL;    /* Initialize to appease gcc warning.  */
00203   volatile struct gdb_exception except;
00204   enum unwind_stop_reason stop_reason;
00205 
00206   TRY_CATCH (except, RETURN_MASK_ALL)
00207     {
00208       FRAPY_REQUIRE_VALID (self, frame);
00209     }
00210   GDB_PY_HANDLE_EXCEPTION (except);
00211 
00212   stop_reason = get_frame_unwind_stop_reason (frame);
00213 
00214   return PyInt_FromLong (stop_reason);
00215 }
00216 
00217 /* Implementation of gdb.Frame.pc (self) -> Long.
00218    Returns the frame's resume address.  */
00219 
00220 static PyObject *
00221 frapy_pc (PyObject *self, PyObject *args)
00222 {
00223   CORE_ADDR pc = 0;           /* Initialize to appease gcc warning.  */
00224   struct frame_info *frame;
00225   volatile struct gdb_exception except;
00226 
00227   TRY_CATCH (except, RETURN_MASK_ALL)
00228     {
00229       FRAPY_REQUIRE_VALID (self, frame);
00230 
00231       pc = get_frame_pc (frame);
00232     }
00233   GDB_PY_HANDLE_EXCEPTION (except);
00234 
00235   return gdb_py_long_from_ulongest (pc);
00236 }
00237 
00238 /* Implementation of gdb.Frame.block (self) -> gdb.Block.
00239    Returns the frame's code block.  */
00240 
00241 static PyObject *
00242 frapy_block (PyObject *self, PyObject *args)
00243 {
00244   struct frame_info *frame;
00245   struct block *block = NULL, *fn_block;
00246   volatile struct gdb_exception except;
00247 
00248   TRY_CATCH (except, RETURN_MASK_ALL)
00249     {
00250       FRAPY_REQUIRE_VALID (self, frame);
00251       block = get_frame_block (frame, NULL);
00252     }
00253   GDB_PY_HANDLE_EXCEPTION (except);
00254 
00255   for (fn_block = block;
00256        fn_block != NULL && BLOCK_FUNCTION (fn_block) == NULL;
00257        fn_block = BLOCK_SUPERBLOCK (fn_block))
00258     ;
00259 
00260   if (block == NULL || fn_block == NULL || BLOCK_FUNCTION (fn_block) == NULL)
00261     {
00262       PyErr_SetString (PyExc_RuntimeError,
00263                        _("Cannot locate object file for block."));
00264       return NULL;
00265     }
00266 
00267   if (block)
00268     {
00269       struct symtab *symt;
00270 
00271       symt = SYMBOL_SYMTAB (BLOCK_FUNCTION (fn_block));
00272       return block_to_block_object (block, symt->objfile);
00273     }
00274 
00275   Py_RETURN_NONE;
00276 }
00277 
00278 
00279 /* Implementation of gdb.Frame.function (self) -> gdb.Symbol.
00280    Returns the symbol for the function corresponding to this frame.  */
00281 
00282 static PyObject *
00283 frapy_function (PyObject *self, PyObject *args)
00284 {
00285   struct symbol *sym = NULL;
00286   struct frame_info *frame;
00287   volatile struct gdb_exception except;
00288 
00289   TRY_CATCH (except, RETURN_MASK_ALL)
00290     {
00291       FRAPY_REQUIRE_VALID (self, frame);
00292 
00293       sym = find_pc_function (get_frame_address_in_block (frame));
00294     }
00295   GDB_PY_HANDLE_EXCEPTION (except);
00296 
00297   if (sym)
00298     return symbol_to_symbol_object (sym);
00299 
00300   Py_RETURN_NONE;
00301 }
00302 
00303 /* Convert a frame_info struct to a Python Frame object.
00304    Sets a Python exception and returns NULL on error.  */
00305 
00306 PyObject *
00307 frame_info_to_frame_object (struct frame_info *frame)
00308 {
00309   frame_object *frame_obj;
00310   volatile struct gdb_exception except;
00311 
00312   frame_obj = PyObject_New (frame_object, &frame_object_type);
00313   if (frame_obj == NULL)
00314     return NULL;
00315 
00316   TRY_CATCH (except, RETURN_MASK_ALL)
00317     {
00318 
00319       /* Try to get the previous frame, to determine if this is the last frame
00320          in a corrupt stack.  If so, we need to store the frame_id of the next
00321          frame and not of this one (which is possibly invalid).  */
00322       if (get_prev_frame (frame) == NULL
00323           && get_frame_unwind_stop_reason (frame) != UNWIND_NO_REASON
00324           && get_next_frame (frame) != NULL)
00325         {
00326           frame_obj->frame_id = get_frame_id (get_next_frame (frame));
00327           frame_obj->frame_id_is_next = 1;
00328         }
00329       else
00330         {
00331           frame_obj->frame_id = get_frame_id (frame);
00332           frame_obj->frame_id_is_next = 0;
00333         }
00334       frame_obj->gdbarch = get_frame_arch (frame);
00335     }
00336   if (except.reason < 0)
00337     {
00338       Py_DECREF (frame_obj);
00339       gdbpy_convert_exception (except);
00340       return NULL;
00341     }
00342   return (PyObject *) frame_obj;
00343 }
00344 
00345 /* Implementation of gdb.Frame.older (self) -> gdb.Frame.
00346    Returns the frame immediately older (outer) to this frame, or None if
00347    there isn't one.  */
00348 
00349 static PyObject *
00350 frapy_older (PyObject *self, PyObject *args)
00351 {
00352   struct frame_info *frame, *prev = NULL;
00353   volatile struct gdb_exception except;
00354   PyObject *prev_obj = NULL;   /* Initialize to appease gcc warning.  */
00355 
00356   TRY_CATCH (except, RETURN_MASK_ALL)
00357     {
00358       FRAPY_REQUIRE_VALID (self, frame);
00359 
00360       prev = get_prev_frame (frame);
00361     }
00362   GDB_PY_HANDLE_EXCEPTION (except);
00363 
00364   if (prev)
00365     prev_obj = (PyObject *) frame_info_to_frame_object (prev);
00366   else
00367     {
00368       Py_INCREF (Py_None);
00369       prev_obj = Py_None;
00370     }
00371 
00372   return prev_obj;
00373 }
00374 
00375 /* Implementation of gdb.Frame.newer (self) -> gdb.Frame.
00376    Returns the frame immediately newer (inner) to this frame, or None if
00377    there isn't one.  */
00378 
00379 static PyObject *
00380 frapy_newer (PyObject *self, PyObject *args)
00381 {
00382   struct frame_info *frame, *next = NULL;
00383   volatile struct gdb_exception except;
00384   PyObject *next_obj = NULL;   /* Initialize to appease gcc warning.  */
00385 
00386   TRY_CATCH (except, RETURN_MASK_ALL)
00387     {
00388       FRAPY_REQUIRE_VALID (self, frame);
00389 
00390       next = get_next_frame (frame);
00391     }
00392   GDB_PY_HANDLE_EXCEPTION (except);
00393 
00394   if (next)
00395     next_obj = (PyObject *) frame_info_to_frame_object (next);
00396   else
00397     {
00398       Py_INCREF (Py_None);
00399       next_obj = Py_None;
00400     }
00401 
00402   return next_obj;
00403 }
00404 
00405 /* Implementation of gdb.Frame.find_sal (self) -> gdb.Symtab_and_line.
00406    Returns the frame's symtab and line.  */
00407 
00408 static PyObject *
00409 frapy_find_sal (PyObject *self, PyObject *args)
00410 {
00411   struct frame_info *frame;
00412   struct symtab_and_line sal;
00413   volatile struct gdb_exception except;
00414   PyObject *sal_obj = NULL;   /* Initialize to appease gcc warning.  */
00415 
00416   TRY_CATCH (except, RETURN_MASK_ALL)
00417     {
00418       FRAPY_REQUIRE_VALID (self, frame);
00419 
00420       find_frame_sal (frame, &sal);
00421       sal_obj = symtab_and_line_to_sal_object (sal);
00422     }
00423   GDB_PY_HANDLE_EXCEPTION (except);
00424 
00425   return sal_obj;
00426 }
00427 
00428 /* Implementation of gdb.Frame.read_var_value (self, variable,
00429    [block]) -> gdb.Value.  If the optional block argument is provided
00430    start the search from that block, otherwise search from the frame's
00431    current block (determined by examining the resume address of the
00432    frame).  The variable argument must be a string or an instance of a
00433    gdb.Symbol.  The block argument must be an instance of gdb.Block.  Returns
00434    NULL on error, with a python exception set.  */
00435 static PyObject *
00436 frapy_read_var (PyObject *self, PyObject *args)
00437 {
00438   struct frame_info *frame;
00439   PyObject *sym_obj, *block_obj = NULL;
00440   struct symbol *var = NULL;    /* gcc-4.3.2 false warning.  */
00441   struct value *val = NULL;
00442   volatile struct gdb_exception except;
00443 
00444   if (!PyArg_ParseTuple (args, "O|O", &sym_obj, &block_obj))
00445     return NULL;
00446 
00447   if (PyObject_TypeCheck (sym_obj, &symbol_object_type))
00448     var = symbol_object_to_symbol (sym_obj);
00449   else if (gdbpy_is_string (sym_obj))
00450     {
00451       char *var_name;
00452       const struct block *block = NULL;
00453       struct cleanup *cleanup;
00454       volatile struct gdb_exception except;
00455 
00456       var_name = python_string_to_target_string (sym_obj);
00457       if (!var_name)
00458         return NULL;
00459       cleanup = make_cleanup (xfree, var_name);
00460 
00461       if (block_obj)
00462         {
00463           block = block_object_to_block (block_obj);
00464           if (!block)
00465             {
00466               PyErr_SetString (PyExc_RuntimeError,
00467                                _("Second argument must be block."));
00468               do_cleanups (cleanup);
00469               return NULL;
00470             }
00471         }
00472 
00473       TRY_CATCH (except, RETURN_MASK_ALL)
00474         {
00475           FRAPY_REQUIRE_VALID (self, frame);
00476 
00477           if (!block)
00478             block = get_frame_block (frame, NULL);
00479           var = lookup_symbol (var_name, block, VAR_DOMAIN, NULL);
00480         }
00481       if (except.reason < 0)
00482         {
00483           do_cleanups (cleanup);
00484           gdbpy_convert_exception (except);
00485           return NULL;
00486         }
00487 
00488       if (!var)
00489         {
00490           PyErr_Format (PyExc_ValueError,
00491                         _("Variable '%s' not found."), var_name);
00492           do_cleanups (cleanup);
00493 
00494           return NULL;
00495         }
00496 
00497       do_cleanups (cleanup);
00498     }
00499   else
00500     {
00501       PyErr_SetString (PyExc_TypeError,
00502                        _("Argument must be a symbol or string."));
00503       return NULL;
00504     }
00505 
00506   TRY_CATCH (except, RETURN_MASK_ALL)
00507     {
00508       FRAPY_REQUIRE_VALID (self, frame);
00509 
00510       val = read_var_value (var, frame);
00511     }
00512   GDB_PY_HANDLE_EXCEPTION (except);
00513 
00514   return value_to_value_object (val);
00515 }
00516 
00517 /* Select this frame.  */
00518 
00519 static PyObject *
00520 frapy_select (PyObject *self, PyObject *args)
00521 {
00522   struct frame_info *fi;
00523   volatile struct gdb_exception except;
00524 
00525   TRY_CATCH (except, RETURN_MASK_ALL)
00526     {
00527       FRAPY_REQUIRE_VALID (self, fi);
00528 
00529       select_frame (fi);
00530     }
00531   GDB_PY_HANDLE_EXCEPTION (except);
00532 
00533   Py_RETURN_NONE;
00534 }
00535 
00536 /* Implementation of gdb.newest_frame () -> gdb.Frame.
00537    Returns the newest frame object.  */
00538 
00539 PyObject *
00540 gdbpy_newest_frame (PyObject *self, PyObject *args)
00541 {
00542   struct frame_info *frame = NULL;
00543   volatile struct gdb_exception except;
00544 
00545   TRY_CATCH (except, RETURN_MASK_ALL)
00546     {
00547       frame = get_current_frame ();
00548     }
00549   GDB_PY_HANDLE_EXCEPTION (except);
00550 
00551   return frame_info_to_frame_object (frame);
00552 }
00553 
00554 /* Implementation of gdb.selected_frame () -> gdb.Frame.
00555    Returns the selected frame object.  */
00556 
00557 PyObject *
00558 gdbpy_selected_frame (PyObject *self, PyObject *args)
00559 {
00560   struct frame_info *frame = NULL;
00561   volatile struct gdb_exception except;
00562 
00563   TRY_CATCH (except, RETURN_MASK_ALL)
00564     {
00565       frame = get_selected_frame ("No frame is currently selected.");
00566     }
00567   GDB_PY_HANDLE_EXCEPTION (except);
00568 
00569   return frame_info_to_frame_object (frame);
00570 }
00571 
00572 /* Implementation of gdb.stop_reason_string (Integer) -> String.
00573    Return a string explaining the unwind stop reason.  */
00574 
00575 PyObject *
00576 gdbpy_frame_stop_reason_string (PyObject *self, PyObject *args)
00577 {
00578   int reason;
00579   const char *str;
00580 
00581   if (!PyArg_ParseTuple (args, "i", &reason))
00582     return NULL;
00583 
00584   if (reason < UNWIND_FIRST || reason > UNWIND_LAST)
00585     {
00586       PyErr_SetString (PyExc_ValueError, 
00587                        _("Invalid frame stop reason."));
00588       return NULL;
00589     }
00590 
00591   str = frame_stop_reason_string (reason);
00592   return PyUnicode_Decode (str, strlen (str), host_charset (), NULL);
00593 }
00594 
00595 /* Implements the equality comparison for Frame objects.
00596    All other comparison operators will throw a TypeError Python exception,
00597    as they aren't valid for frames.  */
00598 
00599 static PyObject *
00600 frapy_richcompare (PyObject *self, PyObject *other, int op)
00601 {
00602   int result;
00603 
00604   if (!PyObject_TypeCheck (other, &frame_object_type)
00605       || (op != Py_EQ && op != Py_NE))
00606     {
00607       Py_INCREF (Py_NotImplemented);
00608       return Py_NotImplemented;
00609     }
00610 
00611   if (frame_id_eq (((frame_object *) self)->frame_id,
00612                    ((frame_object *) other)->frame_id))
00613     result = Py_EQ;
00614   else
00615     result = Py_NE;
00616 
00617   if (op == result)
00618     Py_RETURN_TRUE;
00619   Py_RETURN_FALSE;
00620 }
00621 
00622 /* Sets up the Frame API in the gdb module.  */
00623 
00624 int
00625 gdbpy_initialize_frames (void)
00626 {
00627   frame_object_type.tp_new = PyType_GenericNew;
00628   if (PyType_Ready (&frame_object_type) < 0)
00629     return -1;
00630 
00631   /* Note: These would probably be best exposed as class attributes of
00632      Frame, but I don't know how to do it except by messing with the
00633      type's dictionary.  That seems too messy.  */
00634   if (PyModule_AddIntConstant (gdb_module, "NORMAL_FRAME", NORMAL_FRAME) < 0
00635       || PyModule_AddIntConstant (gdb_module, "DUMMY_FRAME", DUMMY_FRAME) < 0
00636       || PyModule_AddIntConstant (gdb_module, "INLINE_FRAME", INLINE_FRAME) < 0
00637       || PyModule_AddIntConstant (gdb_module, "TAILCALL_FRAME",
00638                                   TAILCALL_FRAME) < 0
00639       || PyModule_AddIntConstant (gdb_module, "SIGTRAMP_FRAME",
00640                                   SIGTRAMP_FRAME) < 0
00641       || PyModule_AddIntConstant (gdb_module, "ARCH_FRAME", ARCH_FRAME) < 0
00642       || PyModule_AddIntConstant (gdb_module, "SENTINEL_FRAME",
00643                                   SENTINEL_FRAME) < 0)
00644     return -1;
00645 
00646 #define SET(name, description) \
00647   if (PyModule_AddIntConstant (gdb_module, "FRAME_"#name, name) < 0) \
00648     return -1;
00649 #define FIRST_ERROR(name) \
00650   if (PyModule_AddIntConstant (gdb_module, "FRAME_"#name, name) < 0) \
00651     return -1;
00652 #include "unwind_stop_reasons.def"
00653 #undef SET
00654 #undef FIRST_ERROR
00655 
00656   return gdb_pymodule_addobject (gdb_module, "Frame",
00657                                  (PyObject *) &frame_object_type);
00658 }
00659 
00660 
00661 
00662 static PyMethodDef frame_object_methods[] = {
00663   { "is_valid", frapy_is_valid, METH_NOARGS,
00664     "is_valid () -> Boolean.\n\
00665 Return true if this frame is valid, false if not." },
00666   { "name", frapy_name, METH_NOARGS,
00667     "name () -> String.\n\
00668 Return the function name of the frame, or None if it can't be determined." },
00669   { "type", frapy_type, METH_NOARGS,
00670     "type () -> Integer.\n\
00671 Return the type of the frame." },
00672   { "architecture", frapy_arch, METH_NOARGS,
00673     "architecture () -> gdb.Architecture.\n\
00674 Return the architecture of the frame." },
00675   { "unwind_stop_reason", frapy_unwind_stop_reason, METH_NOARGS,
00676     "unwind_stop_reason () -> Integer.\n\
00677 Return the reason why it's not possible to find frames older than this." },
00678   { "pc", frapy_pc, METH_NOARGS,
00679     "pc () -> Long.\n\
00680 Return the frame's resume address." },
00681   { "block", frapy_block, METH_NOARGS,
00682     "block () -> gdb.Block.\n\
00683 Return the frame's code block." },
00684   { "function", frapy_function, METH_NOARGS,
00685     "function () -> gdb.Symbol.\n\
00686 Returns the symbol for the function corresponding to this frame." },
00687   { "older", frapy_older, METH_NOARGS,
00688     "older () -> gdb.Frame.\n\
00689 Return the frame that called this frame." },
00690   { "newer", frapy_newer, METH_NOARGS,
00691     "newer () -> gdb.Frame.\n\
00692 Return the frame called by this frame." },
00693   { "find_sal", frapy_find_sal, METH_NOARGS,
00694     "find_sal () -> gdb.Symtab_and_line.\n\
00695 Return the frame's symtab and line." },
00696   { "read_var", frapy_read_var, METH_VARARGS,
00697     "read_var (variable) -> gdb.Value.\n\
00698 Return the value of the variable in this frame." },
00699   { "select", frapy_select, METH_NOARGS,
00700     "Select this frame as the user's current frame." },
00701   {NULL}  /* Sentinel */
00702 };
00703 
00704 PyTypeObject frame_object_type = {
00705   PyVarObject_HEAD_INIT (NULL, 0)
00706   "gdb.Frame",                    /* tp_name */
00707   sizeof (frame_object),          /* tp_basicsize */
00708   0,                              /* tp_itemsize */
00709   0,                              /* tp_dealloc */
00710   0,                              /* tp_print */
00711   0,                              /* tp_getattr */
00712   0,                              /* tp_setattr */
00713   0,                              /* tp_compare */
00714   0,                              /* tp_repr */
00715   0,                              /* tp_as_number */
00716   0,                              /* tp_as_sequence */
00717   0,                              /* tp_as_mapping */
00718   0,                              /* tp_hash  */
00719   0,                              /* tp_call */
00720   frapy_str,                      /* tp_str */
00721   0,                              /* tp_getattro */
00722   0,                              /* tp_setattro */
00723   0,                              /* tp_as_buffer */
00724   Py_TPFLAGS_DEFAULT,             /* tp_flags */
00725   "GDB frame object",             /* tp_doc */
00726   0,                              /* tp_traverse */
00727   0,                              /* tp_clear */
00728   frapy_richcompare,              /* tp_richcompare */
00729   0,                              /* tp_weaklistoffset */
00730   0,                              /* tp_iter */
00731   0,                              /* tp_iternext */
00732   frame_object_methods,           /* tp_methods */
00733   0,                              /* tp_members */
00734   0,                              /* tp_getset */
00735   0,                              /* tp_base */
00736   0,                              /* tp_dict */
00737   0,                              /* tp_descr_get */
00738   0,                              /* tp_descr_set */
00739   0,                              /* tp_dictoffset */
00740   0,                              /* tp_init */
00741   0,                              /* tp_alloc */
00742 };
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines