home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / D / GDB / GDB-4.13 / GDB-4 / gdb-4.13 / gdb / frame.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-13  |  8.3 KB  |  241 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. /* A FRAME identifies a specific stack frame.  It is not constant over
  24.    calls to the inferior (frame addresses are, see below).
  25.  
  26.    This is implemented as a "struct frame_info *".  This file and
  27.    blockframe.c are the only places which are allowed to use the
  28.    equivalence between FRAME and struct frame_info *.  Exception:
  29.    Prototypes in other files use "struct frame_info *" because this
  30.    file might not be included.
  31.  
  32.    The distinction between a FRAME and a "struct frame_info *" is made
  33.    with the idea of maybe someday changing a FRAME to be something else,
  34.    but seems to me that a "struct frame_info *" is fully general (since
  35.    any necessarily fields can be added; changing the meaning of existing
  36.    fields is not helped by the FRAME distinction), and this distinction
  37.    merely creates unnecessary hair.  -kingdon, 18 May 93.  */
  38. typedef struct frame_info *FRAME;
  39.  
  40. /* Convert from a "struct frame_info *" into a FRAME.  */
  41. #define FRAME_INFO_ID(f)    (f)
  42.  
  43. /* Convert from a FRAME into a "struct frame_info *".  */
  44. extern struct frame_info *
  45. get_frame_info PARAMS ((FRAME));
  46.  
  47. /* Type of the address of a frame.  It is widely assumed (at least in
  48.    prototypes in headers which might not include this header) that
  49.    this is the same as CORE_ADDR, and no one can think of a case in
  50.    which it wouldn't be, so it might be best to remove this typedef.  */
  51. typedef CORE_ADDR    FRAME_ADDR;
  52.  
  53. /* Convert from a FRAME into a frame address.  Except in the
  54.    machine-dependent *FRAME* macros, a frame address has no defined
  55.    meaning other than as a magic cookie which identifies a frame over
  56.    calls to the inferior.  The only known exception is inferior.h
  57.    (PC_IN_CALL_DUMMY) [ON_STACK]; see comments there.  You cannot
  58.    assume that a frame address contains enough information to
  59.    reconstruct the frame; if you want more than just to identify the
  60.    frame (e.g. be able to fetch variables relative to that frame),
  61.    then save the whole struct frame_info (and the next struct
  62.    frame_info, since the latter is used for fetching variables on some
  63.    machines).  */
  64.  
  65. #define FRAME_FP(fr)    ((fr)->frame)
  66.  
  67. /* We keep a cache of stack frames, each of which is a "struct
  68.    frame_info".  The innermost one gets allocated (in
  69.    wait_for_inferior) each time the inferior stops; current_frame
  70.    points to it.  Additional frames get allocated (in
  71.    get_prev_frame_info) as needed, and are chained through the next
  72.    and prev fields.  Any time that the frame cache becomes invalid
  73.    (most notably when we execute something, but also if we change how
  74.    we interpret the frames (e.g. "set heuristic-fence-post" in
  75.    mips-tdep.c, or anything which reads new symbols)), we should call
  76.    reinit_frame_cache.  */
  77.  
  78. struct frame_info
  79.   {
  80.     /* Nominal address of the frame described.  See comments at FRAME_FP
  81.        about what this means outside the *FRAME* macros; in the *FRAME*
  82.        macros, it can mean whatever makes most sense for this machine.  */
  83.     FRAME_ADDR frame;
  84.  
  85.     /* Address at which execution is occurring in this frame.
  86.        For the innermost frame, it's the current pc.
  87.        For other frames, it is a pc saved in the next frame.  */
  88.     CORE_ADDR pc;
  89.  
  90.     /* Nonzero if this is a frame associated with calling a signal handler.
  91.  
  92.        Set by machine-dependent code.  On some machines, if
  93.        the machine-dependent code fails to check for this, the backtrace
  94.        will look relatively normal.  For example, on the i386
  95.          #3  0x158728 in sighold ()
  96.        On other machines (e.g. rs6000), the machine-dependent code better
  97.        set this to prevent us from trying to print it like a normal frame.  */
  98.     int signal_handler_caller;
  99.  
  100.     /* Anything extra for this structure that may have been defined
  101.        in the machine dependent files. */
  102. #ifdef EXTRA_FRAME_INFO
  103.     EXTRA_FRAME_INFO
  104. #endif
  105.  
  106.     /* We should probably also store a "struct frame_saved_regs" here.
  107.        This is already done by some machines (e.g. config/m88k/tm-m88k.h)
  108.        but there is no reason it couldn't be general.  */
  109.  
  110.     /* Pointers to the next and previous frame_info's in the frame cache.  */
  111.     FRAME next, prev;
  112.   };
  113.  
  114. /* Describe the saved registers of a frame.  */
  115.  
  116. struct frame_saved_regs
  117.   {
  118.  
  119.     /* For each register, address of where it was saved on entry to
  120.        the frame, or zero if it was not saved on entry to this frame.
  121.        This includes special registers such as pc and fp saved in
  122.        special ways in the stack frame.  The SP_REGNUM is even more
  123.        special, the address here is the sp for the next frame, not the
  124.        address where the sp was saved.  */
  125.  
  126.     CORE_ADDR regs[NUM_REGS];
  127.   };
  128.  
  129. /* Define a default FRAME_CHAIN_VALID, in the form that is suitable for most
  130.    targets.  If FRAME_CHAIN_VALID returns zero it means that the given frame
  131.    is the outermost one and has no caller.
  132.  
  133.    If a particular target needs a different definition, then it can override
  134.    the definition here by providing one in the tm file. */
  135.  
  136. #if !defined (FRAME_CHAIN_VALID)
  137.  
  138. #if defined (FRAME_CHAIN_VALID_ALTERNATE)
  139.  
  140. /* Use the alternate method of avoiding running up off the end of the frame
  141.    chain or following frames back into the startup code.  See the comments
  142.    in objfiles.h. */
  143.    
  144. #define FRAME_CHAIN_VALID(chain, thisframe)    \
  145.   ((chain) != 0                    \
  146.    && !inside_main_func ((thisframe) -> pc)    \
  147.    && !inside_entry_func ((thisframe) -> pc))
  148.  
  149. #else
  150.  
  151. #define FRAME_CHAIN_VALID(chain, thisframe)    \
  152.   ((chain) != 0                    \
  153.    && !inside_entry_file (FRAME_SAVED_PC (thisframe)))
  154.  
  155. #endif    /* FRAME_CHAIN_VALID_ALTERNATE */
  156.  
  157. #endif    /* FRAME_CHAIN_VALID */
  158.  
  159. /* The stack frame that the user has specified for commands to act on.
  160.    Note that one cannot assume this is the address of valid data.  */
  161.  
  162. extern FRAME selected_frame;
  163.  
  164. /* Level of the selected frame:
  165.    0 for innermost, 1 for its caller, ...
  166.    or -1 for frame specified by address with no defined level.  */
  167.  
  168. extern int selected_frame_level;
  169.  
  170. extern struct frame_info *
  171. get_prev_frame_info PARAMS ((FRAME));
  172.  
  173. extern FRAME
  174. create_new_frame PARAMS ((FRAME_ADDR, CORE_ADDR));
  175.  
  176. extern void
  177. flush_cached_frames PARAMS ((void));
  178.  
  179. extern void
  180. reinit_frame_cache PARAMS ((void));
  181.  
  182. extern void
  183. get_frame_saved_regs PARAMS ((struct frame_info *, struct frame_saved_regs *));
  184.  
  185. extern void
  186. set_current_frame PARAMS ((FRAME));
  187.  
  188. extern FRAME
  189. get_prev_frame PARAMS ((FRAME));
  190.  
  191. extern FRAME
  192. get_current_frame PARAMS ((void));
  193.  
  194. extern FRAME
  195. get_next_frame PARAMS ((FRAME));
  196.  
  197. extern struct block *
  198. get_frame_block PARAMS ((FRAME));
  199.  
  200. extern struct block *
  201. get_current_block PARAMS ((void));
  202.  
  203. extern struct block *
  204. get_selected_block PARAMS ((void));
  205.  
  206. extern struct symbol *
  207. get_frame_function PARAMS ((FRAME));
  208.  
  209. extern CORE_ADDR
  210. get_frame_pc PARAMS ((FRAME));
  211.  
  212. extern CORE_ADDR
  213. get_pc_function_start PARAMS ((CORE_ADDR));
  214.  
  215. extern struct block * block_for_pc PARAMS ((CORE_ADDR));
  216.  
  217. extern int frameless_look_for_prologue PARAMS ((FRAME));
  218.  
  219. extern void print_frame_args PARAMS ((struct symbol *, struct frame_info *,
  220.                       int, GDB_FILE *));
  221.  
  222. extern FRAME find_relative_frame PARAMS ((FRAME, int*));
  223.  
  224. extern void print_stack_frame PARAMS ((FRAME, int, int));
  225.  
  226. extern void select_frame PARAMS ((FRAME, int));
  227.  
  228. extern void record_selected_frame PARAMS ((FRAME_ADDR *, int *));
  229.  
  230. extern void print_frame_info PARAMS ((struct frame_info *, int, int, int));
  231.  
  232. extern CORE_ADDR find_saved_register PARAMS ((FRAME, int));
  233.  
  234. extern FRAME block_innermost_frame PARAMS ((struct block *));
  235.  
  236. extern FRAME find_frame_addr_in_frame_chain PARAMS ((FRAME_ADDR));
  237.  
  238. extern CORE_ADDR sigtramp_saved_pc PARAMS ((FRAME));
  239.  
  240. #endif /* !defined (FRAME_H)  */
  241.