home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / gdb-4.9 / gdb / frame.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-12  |  7.3 KB  |  232 lines

  1. /* Definitions for dealing with stack frames, for GDB, the GNU debugger.
  2.    Copyright 1986, 1989, 1991, 1992 Free Software Foundation, Inc.
  3.  
  4. This file is part of GDB.
  5.  
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10.  
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with this program; if not, write to the Free Software
  18. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. #if !defined (FRAME_H)
  21. #define FRAME_H 1
  22.  
  23. /* FRAME is the type of the identifier of a specific stack frame.  It
  24.    is a pointer to the frame cache item corresponding to this frame.
  25.    Please note that frame id's are *not* constant over calls to the
  26.    inferior.  Use frame addresses, which are.
  27.   
  28.    FRAME_ADDR is the type of the address of a specific frame.  I
  29.    cannot imagine a case in which this would not be CORE_ADDR, so
  30.    maybe it's silly to give it it's own type.  Life's rough.
  31.   
  32.    FRAME_FP is a macro which converts from a frame identifier into a
  33.    frame_address.
  34.   
  35.    FRAME_INFO_ID is a macro which "converts" from a frame info pointer
  36.    to a frame id.  This is here in case I or someone else decides to
  37.    change the FRAME type again.
  38.   
  39.    This file and blockframe.c are the only places which are allowed to
  40.    use the equivalence between FRAME and struct frame_info *.  EXCEPTION:
  41.    value.h uses CORE_ADDR instead of FRAME_ADDR because the compiler
  42.    will accept that in the absence of this file.
  43.    FIXME:  Prototypes in other files make use of the equivalence between
  44.            "FRAME" and "struct frame_info *" and the equivalence between
  45.        CORE_ADDR and FRAME_ADDR.  */
  46.  
  47. typedef struct frame_info *FRAME;
  48. typedef CORE_ADDR    FRAME_ADDR;
  49. #define FRAME_FP(fr)    ((fr)->frame)
  50. #define FRAME_INFO_ID(f)    (f)
  51.  
  52. /* Caching structure for stack frames.  This is also the structure
  53.    used for extended info about stack frames.  May add more to this
  54.    structure as it becomes necessary.
  55.   
  56.    Note that the first entry in the cache will always refer to the
  57.    innermost executing frame.  This value is set in wait_for_inferior.  */
  58.  
  59. struct frame_info
  60.   {
  61.     /* Nominal address of the frame described.  */
  62.     FRAME_ADDR frame;
  63.     /* Address at which execution is occurring in this frame.
  64.        For the innermost frame, it's the current pc.
  65.        For other frames, it is a pc saved in the next frame.  */
  66.     CORE_ADDR pc;
  67.  
  68.     /* Nonzero if this is a frame associated with calling a signal handler.
  69.  
  70.        Set by machine-dependent code.  On some machines, if
  71.        the machine-dependent code fails to check for this, the backtrace
  72.        will look relatively normal.  For example, on the i386
  73.          #3  0x158728 in sighold ()
  74.        On other machines (e.g. rs6000), the machine-dependent code better
  75.        set this to prevent us from trying to print it like a normal frame.  */
  76.     int signal_handler_caller;
  77.  
  78.     /* The frame called by the frame we are describing, or 0.  On the
  79.        innermost frame it is (FRAME_ADDR)0 and various parts of GDB
  80.        check for this.  Is this any different from checking ->next ==
  81.        0 (framelessness?).  It's possible it would make more sense to
  82.        change this to mean the bottom of this frame (read_register
  83.        (SP_REGNUM) in the innermost frame).  */
  84.     FRAME_ADDR next_frame;
  85.  
  86.     /* Anything extra for this structure that may have been defined
  87.        in the machine depedent files. */
  88. #ifdef EXTRA_FRAME_INFO
  89.     EXTRA_FRAME_INFO
  90. #endif
  91.     /* Pointers to the next and previous frame_info's in this stack.  */
  92.     FRAME next, prev;
  93.   };
  94.  
  95. /* Describe the saved registers of a frame.  */
  96.  
  97. struct frame_saved_regs
  98.   {
  99.     /* For each register, address of where it was saved on entry to the frame,
  100.        or zero if it was not saved on entry to this frame.  */
  101.     CORE_ADDR regs[NUM_REGS];
  102.   };
  103.  
  104. /* Define a default FRAME_CHAIN_VALID, in the form that is suitable for most
  105.    targets.  If FRAME_CHAIN_VALID returns zero it means that the given frame
  106.    is the outermost one and has no caller.
  107.  
  108.    If a particular target needs a different definition, then it can override
  109.    the definition here by providing one in the tm file. */
  110.  
  111. #if !defined (FRAME_CHAIN_VALID)
  112.  
  113. #if defined (FRAME_CHAIN_VALID_ALTERNATE)
  114.  
  115. /* Use the alternate method of avoiding running up off the end of the frame
  116.    chain or following frames back into the startup code.  See the comments
  117.    in objfiles.h. */
  118.    
  119. #define FRAME_CHAIN_VALID(chain, thisframe)    \
  120.   ((chain) != 0                    \
  121.    && !inside_main_func ((thisframe) -> pc)    \
  122.    && !inside_entry_func ((thisframe) -> pc))
  123.  
  124. #else
  125.  
  126. #define FRAME_CHAIN_VALID(chain, thisframe)    \
  127.   ((chain) != 0                    \
  128.    && !inside_entry_file (FRAME_SAVED_PC (thisframe)))
  129.  
  130. #endif    /* FRAME_CHAIN_VALID_ALTERNATE */
  131.  
  132. #endif    /* FRAME_CHAIN_VALID */
  133.  
  134. /* If we encounter a request to use base register addressing of variables
  135.    on a machine for which gdb has not been configured to support such
  136.    access, report the failure to support this access mode. */
  137.  
  138. #if !defined (FRAME_GET_BASEREG_VALUE)
  139.  
  140. #define FRAME_GET_BASEREG_VALUE(frame, regno) \
  141.   (error ("Missing valid method for finding contents of base register."),0)
  142.  
  143. #endif
  144.  
  145. /* The stack frame that the user has specified for commands to act on.
  146.    Note that one cannot assume this is the address of valid data.  */
  147.  
  148. extern FRAME selected_frame;
  149.  
  150. /* Level of the selected frame:
  151.    0 for innermost, 1 for its caller, ...
  152.    or -1 for frame specified by address with no defined level.  */
  153.  
  154. extern int selected_frame_level;
  155.  
  156. extern struct frame_info *
  157. get_frame_info PARAMS ((FRAME));
  158.  
  159. extern struct frame_info *
  160. get_prev_frame_info PARAMS ((FRAME));
  161.  
  162. extern FRAME
  163. create_new_frame PARAMS ((FRAME_ADDR, CORE_ADDR));
  164.  
  165. extern void
  166. flush_cached_frames PARAMS ((void));
  167.  
  168. extern void
  169. reinit_frame_cache PARAMS ((void));
  170.  
  171. extern void
  172. get_frame_saved_regs PARAMS ((struct frame_info *, struct frame_saved_regs *));
  173.  
  174. extern void
  175. set_current_frame PARAMS ((FRAME));
  176.  
  177. extern FRAME
  178. get_prev_frame PARAMS ((FRAME));
  179.  
  180. extern FRAME
  181. get_current_frame PARAMS ((void));
  182.  
  183. extern FRAME
  184. get_next_frame PARAMS ((FRAME));
  185.  
  186. extern struct block *
  187. get_frame_block PARAMS ((FRAME));
  188.  
  189. extern struct block *
  190. get_current_block PARAMS ((void));
  191.  
  192. extern struct block *
  193. get_selected_block PARAMS ((void));
  194.  
  195. extern struct symbol *
  196. get_frame_function PARAMS ((FRAME));
  197.  
  198. extern CORE_ADDR
  199. get_frame_pc PARAMS ((FRAME));
  200.  
  201. extern CORE_ADDR
  202. get_pc_function_start PARAMS ((CORE_ADDR));
  203.  
  204. extern struct block *
  205. block_for_pc PARAMS ((CORE_ADDR));
  206.  
  207. extern int
  208. frameless_look_for_prologue PARAMS ((FRAME));
  209.  
  210. extern void
  211. print_frame_args PARAMS ((struct symbol *, struct frame_info *, int, FILE *));
  212.  
  213. extern FRAME
  214. find_relative_frame PARAMS ((FRAME, int*));
  215.  
  216. extern void
  217. print_stack_frame PARAMS ((FRAME, int, int));
  218.  
  219. extern void
  220. select_frame PARAMS ((FRAME, int));
  221.  
  222. extern void
  223. record_selected_frame PARAMS ((FRAME_ADDR *, int *));
  224.  
  225. extern void
  226. print_frame_info PARAMS ((struct frame_info *, int, int, int));
  227.  
  228. extern CORE_ADDR
  229. find_saved_register PARAMS ((FRAME, int));
  230.  
  231. #endif /* !defined (FRAME_H)  */
  232.