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

  1. /* Get info from stack frames;
  2.    convert between frames, blocks, functions and pc values.
  3.    Copyright 1986, 1987, 1988, 1989, 1991 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 2 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, write to the Free Software
  19. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  20.  
  21. #include "defs.h"
  22. #include "symtab.h"
  23. #include "bfd.h"
  24. #include "symfile.h"
  25. #include "objfiles.h"
  26. #include "frame.h"
  27. #include "gdbcore.h"
  28. #include "value.h"        /* for read_register */
  29. #include "target.h"        /* for target_has_stack */
  30. #include "inferior.h"        /* for read_pc */
  31.  
  32. /* Is ADDR inside the startup file?  Note that if your machine
  33.    has a way to detect the bottom of the stack, there is no need
  34.    to call this function from FRAME_CHAIN_VALID; the reason for
  35.    doing so is that some machines have no way of detecting bottom
  36.    of stack. 
  37.  
  38.    A PC of zero is always considered to be the bottom of the stack. */
  39.  
  40. int
  41. inside_entry_file (addr)
  42.      CORE_ADDR addr;
  43. {
  44.   if (addr == 0)
  45.     return 1;
  46.   if (symfile_objfile == 0)
  47.     return 0;
  48.   return (addr >= symfile_objfile -> ei.entry_file_lowpc &&
  49.       addr <  symfile_objfile -> ei.entry_file_highpc);
  50. }
  51.  
  52. /* Test a specified PC value to see if it is in the range of addresses
  53.    that correspond to the main() function.  See comments above for why
  54.    we might want to do this.
  55.  
  56.    Typically called from FRAME_CHAIN_VALID.
  57.  
  58.    A PC of zero is always considered to be the bottom of the stack. */
  59.  
  60. int
  61. inside_main_func (pc)
  62. CORE_ADDR pc;
  63. {
  64.   if (pc == 0)
  65.     return 1;
  66.   if (symfile_objfile == 0)
  67.     return 0;
  68.   return (symfile_objfile -> ei.main_func_lowpc  <= pc &&
  69.       symfile_objfile -> ei.main_func_highpc > pc);
  70. }
  71.  
  72. /* Test a specified PC value to see if it is in the range of addresses
  73.    that correspond to the process entry point function.  See comments
  74.    in objfiles.h for why we might want to do this.
  75.  
  76.    Typically called from FRAME_CHAIN_VALID.
  77.  
  78.    A PC of zero is always considered to be the bottom of the stack. */
  79.  
  80. int
  81. inside_entry_func (pc)
  82. CORE_ADDR pc;
  83. {
  84.   if (pc == 0)
  85.     return 1;
  86.   if (symfile_objfile == 0)
  87.     return 0;
  88.   return (symfile_objfile -> ei.entry_func_lowpc  <= pc &&
  89.       symfile_objfile -> ei.entry_func_highpc > pc);
  90. }
  91.  
  92. /* Address of innermost stack frame (contents of FP register) */
  93.  
  94. static FRAME current_frame;
  95.  
  96. /*
  97.  * Cache for frame addresses already read by gdb.  Valid only while
  98.  * inferior is stopped.  Control variables for the frame cache should
  99.  * be local to this module.
  100.  */
  101. struct obstack frame_cache_obstack;
  102.  
  103. /* Return the innermost (currently executing) stack frame.  */
  104.  
  105. FRAME
  106. get_current_frame ()
  107. {
  108.   /* We assume its address is kept in a general register;
  109.      param.h says which register.  */
  110.  
  111.   return current_frame;
  112. }
  113.  
  114. void
  115. set_current_frame (frame)
  116.      FRAME frame;
  117. {
  118.   current_frame = frame;
  119. }
  120.  
  121. FRAME
  122. create_new_frame (addr, pc)
  123.      FRAME_ADDR addr;
  124.      CORE_ADDR pc;
  125. {
  126.   struct frame_info *fci;    /* Same type as FRAME */
  127.  
  128.   fci = (struct frame_info *)
  129.     obstack_alloc (&frame_cache_obstack,
  130.            sizeof (struct frame_info));
  131.  
  132.   /* Arbitrary frame */
  133.   fci->next = (struct frame_info *) 0;
  134.   fci->prev = (struct frame_info *) 0;
  135.   fci->frame = addr;
  136.   fci->next_frame = 0;        /* Since arbitrary */
  137.   fci->pc = pc;
  138.   fci->signal_handler_caller = 0;
  139.  
  140. #ifdef INIT_EXTRA_FRAME_INFO
  141.   INIT_EXTRA_FRAME_INFO (0, fci);
  142. #endif
  143.  
  144.   return fci;
  145. }
  146.  
  147. /* Return the frame that called FRAME.
  148.    If FRAME is the original frame (it has no caller), return 0.  */
  149.  
  150. FRAME
  151. get_prev_frame (frame)
  152.      FRAME frame;
  153. {
  154.   /* We're allowed to know that FRAME and "struct frame_info *" are
  155.      the same */
  156.   return get_prev_frame_info (frame);
  157. }
  158.  
  159. /* Return the frame that FRAME calls (0 if FRAME is the innermost
  160.    frame).  */
  161.  
  162. FRAME
  163. get_next_frame (frame)
  164.      FRAME frame;
  165. {
  166.   /* We're allowed to know that FRAME and "struct frame_info *" are
  167.      the same */
  168.   return frame->next;
  169. }
  170.  
  171. /*
  172.  * Flush the entire frame cache.
  173.  */
  174. void
  175. flush_cached_frames ()
  176. {
  177.   /* Since we can't really be sure what the first object allocated was */
  178.   obstack_free (&frame_cache_obstack, 0);
  179.   obstack_init (&frame_cache_obstack);
  180.  
  181.   current_frame = (struct frame_info *) 0; /* Invalidate cache */
  182. }
  183.  
  184. /* Flush the frame cache, and start a new one if necessary.  */
  185. void
  186. reinit_frame_cache ()
  187. {
  188.   FRAME fr = current_frame;
  189.   flush_cached_frames ();
  190.   if (fr)
  191.     set_current_frame ( create_new_frame (read_register (FP_REGNUM),
  192.                       read_pc ()));
  193. }
  194.  
  195. /* Return a structure containing various interesting information
  196.    about a specified stack frame.  */
  197. /* How do I justify including this function?  Well, the FRAME
  198.    identifier format has gone through several changes recently, and
  199.    it's not completely inconceivable that it could happen again.  If
  200.    it does, have this routine around will help */
  201.  
  202. struct frame_info *
  203. get_frame_info (frame)
  204.      FRAME frame;
  205. {
  206.   return frame;
  207. }
  208.  
  209. /* If a machine allows frameless functions, it should define a macro
  210.    FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) in param.h.  FI is the struct
  211.    frame_info for the frame, and FRAMELESS should be set to nonzero
  212.    if it represents a frameless function invocation.  */
  213.  
  214. /* Return nonzero if the function for this frame lacks a prologue.  Many
  215.    machines can define FRAMELESS_FUNCTION_INVOCATION to just call this
  216.    function.  */
  217.  
  218. int
  219. frameless_look_for_prologue (frame)
  220.      FRAME frame;
  221. {
  222.   CORE_ADDR func_start, after_prologue;
  223.   func_start = (get_pc_function_start (frame->pc) +
  224.         FUNCTION_START_OFFSET);
  225.   if (func_start)
  226.     {
  227.       after_prologue = func_start;
  228. #ifdef SKIP_PROLOGUE_FRAMELESS_P
  229.       /* This is faster, since only care whether there *is* a prologue,
  230.      not how long it is.  */
  231.       SKIP_PROLOGUE_FRAMELESS_P (after_prologue);
  232. #else
  233.       SKIP_PROLOGUE (after_prologue);
  234. #endif
  235.       return after_prologue == func_start;
  236.     }
  237.   else
  238.     /* If we can't find the start of the function, we don't really
  239.        know whether the function is frameless, but we should be able
  240.        to get a reasonable (i.e. best we can do under the
  241.        circumstances) backtrace by saying that it isn't.  */
  242.     return 0;
  243. }
  244.  
  245. /* Default a few macros that people seldom redefine.  */
  246.  
  247. #if !defined (INIT_FRAME_PC)
  248. #define INIT_FRAME_PC(fromleaf, prev) \
  249.   prev->pc = (fromleaf ? SAVED_PC_AFTER_CALL (prev->next) : \
  250.           prev->next ? FRAME_SAVED_PC (prev->next) : read_pc ());
  251. #endif
  252.  
  253. #ifndef FRAME_CHAIN_COMBINE
  254. #define    FRAME_CHAIN_COMBINE(chain, thisframe) (chain)
  255. #endif
  256.  
  257. /* Return a structure containing various interesting information
  258.    about the frame that called NEXT_FRAME.  Returns NULL
  259.    if there is no such frame.  */
  260.  
  261. struct frame_info *
  262. get_prev_frame_info (next_frame)
  263.      FRAME next_frame;
  264. {
  265.   FRAME_ADDR address;
  266.   struct frame_info *prev;
  267.   int fromleaf = 0;
  268.  
  269.   /* If the requested entry is in the cache, return it.
  270.      Otherwise, figure out what the address should be for the entry
  271.      we're about to add to the cache. */
  272.  
  273.   if (!next_frame)
  274.     {
  275.       if (!current_frame)
  276.     {
  277.       error ("You haven't set up a process's stack to examine.");
  278.     }
  279.  
  280.       return current_frame;
  281.     }
  282.  
  283.   /* If we have the prev one, return it */
  284.   if (next_frame->prev)
  285.     return next_frame->prev;
  286.  
  287.   /* On some machines it is possible to call a function without
  288.      setting up a stack frame for it.  On these machines, we
  289.      define this macro to take two args; a frameinfo pointer
  290.      identifying a frame and a variable to set or clear if it is
  291.      or isn't leafless.  */
  292. #ifdef FRAMELESS_FUNCTION_INVOCATION
  293.   /* Still don't want to worry about this except on the innermost
  294.      frame.  This macro will set FROMLEAF if NEXT_FRAME is a
  295.      frameless function invocation.  */
  296.   if (!(next_frame->next))
  297.     {
  298.       FRAMELESS_FUNCTION_INVOCATION (next_frame, fromleaf);
  299.       if (fromleaf)
  300.     address = next_frame->frame;
  301.     }
  302. #endif
  303.  
  304.   if (!fromleaf)
  305.     {
  306.       /* Two macros defined in tm.h specify the machine-dependent
  307.      actions to be performed here.
  308.      First, get the frame's chain-pointer.
  309.      If that is zero, the frame is the outermost frame or a leaf
  310.      called by the outermost frame.  This means that if start
  311.      calls main without a frame, we'll return 0 (which is fine
  312.      anyway).
  313.  
  314.      Nope; there's a problem.  This also returns when the current
  315.      routine is a leaf of main.  This is unacceptable.  We move
  316.      this to after the ffi test; I'd rather have backtraces from
  317.      start go curfluy than have an abort called from main not show
  318.      main.  */
  319.       address = FRAME_CHAIN (next_frame);
  320.       if (!FRAME_CHAIN_VALID (address, next_frame))
  321.     return 0;
  322.       address = FRAME_CHAIN_COMBINE (address, next_frame);
  323.     }
  324.   if (address == 0)
  325.     return 0;
  326.  
  327.   prev = (struct frame_info *)
  328.     obstack_alloc (&frame_cache_obstack,
  329.            sizeof (struct frame_info));
  330.  
  331.   if (next_frame)
  332.     next_frame->prev = prev;
  333.   prev->next = next_frame;
  334.   prev->prev = (struct frame_info *) 0;
  335.   prev->frame = address;
  336.   prev->next_frame = prev->next ? prev->next->frame : 0;
  337.   prev->signal_handler_caller = 0;
  338.  
  339. /* This change should not be needed, FIXME!  We should
  340.    determine whether any targets *need* INIT_FRAME_PC to happen
  341.    after INIT_EXTRA_FRAME_INFO and come up with a simple way to
  342.    express what goes on here.
  343.  
  344.       INIT_EXTRA_FRAME_INFO is called from two places: create_new_frame
  345.               (where the PC is already set up) and here (where it isn't).
  346.       INIT_FRAME_PC is only called from here, always after
  347.               INIT_EXTRA_FRAME_INFO.
  348.    
  349.    The catch is the MIPS, where INIT_EXTRA_FRAME_INFO requires the PC
  350.    value (which hasn't been set yet).  Some other machines appear to
  351.    require INIT_EXTRA_FRAME_INFO before they can do INIT_FRAME_PC.  Phoo.
  352.  
  353.    We shouldn't need INIT_FRAME_PC_FIRST to add more complication to
  354.    an already overcomplicated part of GDB.   gnu@cygnus.com, 15Sep92.
  355.  
  356.    To answer the question, yes the sparc needs INIT_FRAME_PC after
  357.    INIT_EXTRA_FRAME_INFO.  Suggested scheme:
  358.  
  359.    SETUP_INNERMOST_FRAME()
  360.      Default version is just create_new_frame (read_register (FP_REGNUM),
  361.      read_pc ()).  Machines with extra frame info would do that (or the
  362.      local equivalent) and then set the extra fields.
  363.    SETUP_ARBITRARY_FRAME(argc, argv)
  364.      Only change here is that create_new_frame would no longer init extra
  365.      frame info; SETUP_ARBITRARY_FRAME would have to do that.
  366.    INIT_PREV_FRAME(fromleaf, prev)
  367.      Replace INIT_EXTRA_FRAME_INFO and INIT_FRAME_PC.
  368.    std_frame_pc(fromleaf, prev)
  369.      This is the default setting for INIT_PREV_FRAME.  It just does what
  370.      the default INIT_FRAME_PC does.  Some machines will call it from
  371.      INIT_PREV_FRAME (either at the beginning, the end, or in the middle).
  372.      Some machines won't use it.
  373.    kingdon@cygnus.com, 13Apr93.  */
  374.  
  375. #ifdef INIT_FRAME_PC_FIRST
  376.   INIT_FRAME_PC_FIRST (fromleaf, prev);
  377. #endif
  378.  
  379. #ifdef INIT_EXTRA_FRAME_INFO
  380.   INIT_EXTRA_FRAME_INFO(fromleaf, prev);
  381. #endif
  382.  
  383.   /* This entry is in the frame queue now, which is good since
  384.      FRAME_SAVED_PC may use that queue to figure out it's value
  385.      (see tm-sparc.h).  We want the pc saved in the inferior frame. */
  386.   INIT_FRAME_PC(fromleaf, prev);
  387.  
  388.   return prev;
  389. }
  390.  
  391. CORE_ADDR
  392. get_frame_pc (frame)
  393.      FRAME frame;
  394. {
  395.   struct frame_info *fi;
  396.   fi = get_frame_info (frame);
  397.   return fi->pc;
  398. }
  399.  
  400. #if defined (FRAME_FIND_SAVED_REGS)
  401. /* Find the addresses in which registers are saved in FRAME.  */
  402.  
  403. void
  404. get_frame_saved_regs (frame_info_addr, saved_regs_addr)
  405.      struct frame_info *frame_info_addr;
  406.      struct frame_saved_regs *saved_regs_addr;
  407. {
  408.   FRAME_FIND_SAVED_REGS (frame_info_addr, *saved_regs_addr);
  409. }
  410. #endif
  411.  
  412. /* Return the innermost lexical block in execution
  413.    in a specified stack frame.  The frame address is assumed valid.  */
  414.  
  415. struct block *
  416. get_frame_block (frame)
  417.      FRAME frame;
  418. {
  419.   struct frame_info *fi;
  420.   CORE_ADDR pc;
  421.  
  422.   fi = get_frame_info (frame);
  423.  
  424.   pc = fi->pc;
  425.   if (fi->next_frame != 0)
  426.     /* We are not in the innermost frame.  We need to subtract one to
  427.        get the correct block, in case the call instruction was the
  428.        last instruction of the block.  If there are any machines on
  429.        which the saved pc does not point to after the call insn, we
  430.        probably want to make fi->pc point after the call insn anyway.  */
  431.     --pc;
  432.   return block_for_pc (pc);
  433. }
  434.  
  435. struct block *
  436. get_current_block ()
  437. {
  438.   return block_for_pc (read_pc ());
  439. }
  440.  
  441. CORE_ADDR
  442. get_pc_function_start (pc)
  443.      CORE_ADDR pc;
  444. {
  445.   register struct block *bl;
  446.   register struct symbol *symbol;
  447.   register struct minimal_symbol *msymbol;
  448.   CORE_ADDR fstart;
  449.  
  450.   if ((bl = block_for_pc (pc)) != NULL &&
  451.       (symbol = block_function (bl)) != NULL)
  452.     {
  453.       bl = SYMBOL_BLOCK_VALUE (symbol);
  454.       fstart = BLOCK_START (bl);
  455.     }
  456.   else if ((msymbol = lookup_minimal_symbol_by_pc (pc)) != NULL)
  457.     {
  458.       fstart = SYMBOL_VALUE_ADDRESS (msymbol);
  459.     }
  460.   else
  461.     {
  462.       fstart = 0;
  463.     }
  464.   return (fstart);
  465. }
  466.  
  467. /* Return the symbol for the function executing in frame FRAME.  */
  468.  
  469. struct symbol *
  470. get_frame_function (frame)
  471.      FRAME frame;
  472. {
  473.   register struct block *bl = get_frame_block (frame);
  474.   if (bl == 0)
  475.     return 0;
  476.   return block_function (bl);
  477. }
  478.  
  479. /* Return the blockvector immediately containing the innermost lexical block
  480.    containing the specified pc value, or 0 if there is none.
  481.    PINDEX is a pointer to the index value of the block.  If PINDEX
  482.    is NULL, we don't pass this information back to the caller.  */
  483.  
  484. struct blockvector *
  485. blockvector_for_pc (pc, pindex)
  486.      register CORE_ADDR pc;
  487.      int *pindex;
  488. {
  489.   register struct block *b;
  490.   register int bot, top, half;
  491.   register struct symtab *s;
  492.   struct blockvector *bl;
  493.  
  494.   /* First search all symtabs for one whose file contains our pc */
  495.   s = find_pc_symtab (pc);
  496.   if (s == 0)
  497.     return 0;
  498.  
  499.   bl = BLOCKVECTOR (s);
  500.   b = BLOCKVECTOR_BLOCK (bl, 0);
  501.  
  502.   /* Then search that symtab for the smallest block that wins.  */
  503.   /* Use binary search to find the last block that starts before PC.  */
  504.  
  505.   bot = 0;
  506.   top = BLOCKVECTOR_NBLOCKS (bl);
  507.  
  508.   while (top - bot > 1)
  509.     {
  510.       half = (top - bot + 1) >> 1;
  511.       b = BLOCKVECTOR_BLOCK (bl, bot + half);
  512.       if (BLOCK_START (b) <= pc)
  513.     bot += half;
  514.       else
  515.     top = bot + half;
  516.     }
  517.  
  518.   /* Now search backward for a block that ends after PC.  */
  519.  
  520.   while (bot >= 0)
  521.     {
  522.       b = BLOCKVECTOR_BLOCK (bl, bot);
  523.       if (BLOCK_END (b) > pc)
  524.     {
  525.       if (pindex)
  526.         *pindex = bot;
  527.       return bl;
  528.     }
  529.       bot--;
  530.     }
  531.  
  532.   return 0;
  533. }
  534.  
  535. /* Return the innermost lexical block containing the specified pc value,
  536.    or 0 if there is none.  */
  537.  
  538. struct block *
  539. block_for_pc (pc)
  540.      register CORE_ADDR pc;
  541. {
  542.   register struct blockvector *bl;
  543.   int index;
  544.  
  545.   bl = blockvector_for_pc (pc, &index);
  546.   if (bl)
  547.     return BLOCKVECTOR_BLOCK (bl, index);
  548.   return 0;
  549. }
  550.  
  551. /* Return the function containing pc value PC.
  552.    Returns 0 if function is not known.  */
  553.  
  554. struct symbol *
  555. find_pc_function (pc)
  556.      CORE_ADDR pc;
  557. {
  558.   register struct block *b = block_for_pc (pc);
  559.   if (b == 0)
  560.     return 0;
  561.   return block_function (b);
  562. }
  563.  
  564. /* These variables are used to cache the most recent result
  565.  * of find_pc_partial_function. */
  566.  
  567. static CORE_ADDR cache_pc_function_low = 0;
  568. static CORE_ADDR cache_pc_function_high = 0;
  569. static char *cache_pc_function_name = 0;
  570.  
  571. /* Clear cache, e.g. when symbol table is discarded. */
  572.  
  573. void
  574. clear_pc_function_cache()
  575. {
  576.   cache_pc_function_low = 0;
  577.   cache_pc_function_high = 0;
  578.   cache_pc_function_name = (char *)0;
  579. }
  580.  
  581. /* Finds the "function" (text symbol) that is smaller than PC
  582.    but greatest of all of the potential text symbols.  Sets
  583.    *NAME and/or *ADDRESS conditionally if that pointer is non-zero.
  584.    Returns 0 if it couldn't find anything, 1 if it did.  On a zero
  585.    return, *NAME and *ADDRESS are always set to zero.  On a 1 return,
  586.    *NAME and *ADDRESS contain real information.  */
  587.  
  588. int
  589. find_pc_partial_function (pc, name, address)
  590.      CORE_ADDR pc;
  591.      char **name;
  592.      CORE_ADDR *address;
  593. {
  594.   struct partial_symtab *pst;
  595.   struct symbol *f;
  596.   struct minimal_symbol *msymbol;
  597.   struct partial_symbol *psb;
  598.  
  599.   if (pc >= cache_pc_function_low && pc < cache_pc_function_high)
  600.     {
  601.     if (address)
  602.         *address = cache_pc_function_low;
  603.     if (name)
  604.         *name = cache_pc_function_name;
  605.     return 1;
  606.     }
  607.  
  608.   pst = find_pc_psymtab (pc);
  609.   if (pst)
  610.     {
  611.       if (pst->readin)
  612.     {
  613.       /* The information we want has already been read in.
  614.          We can go to the already readin symbols and we'll get
  615.          the best possible answer.  */
  616.       f = find_pc_function (pc);
  617.       if (!f)
  618.         {
  619.         return_error:
  620.           /* No available symbol.  */
  621.           if (name != 0)
  622.         *name = 0;
  623.           if (address != 0)
  624.         *address = 0;
  625.           return 0;
  626.         }
  627.  
  628.       cache_pc_function_low = BLOCK_START (SYMBOL_BLOCK_VALUE (f));
  629.       cache_pc_function_high = BLOCK_END (SYMBOL_BLOCK_VALUE (f));
  630.       cache_pc_function_name = SYMBOL_NAME (f);
  631.       if (name)
  632.         *name = cache_pc_function_name;
  633.       if (address)
  634.         *address = cache_pc_function_low;
  635.       return 1;
  636.     }
  637.  
  638.       /* Get the information from a combination of the pst
  639.      (static symbols), and the minimal symbol table (extern
  640.      symbols).  */
  641.       msymbol = lookup_minimal_symbol_by_pc (pc);
  642.       psb = find_pc_psymbol (pst, pc);
  643.  
  644.       if (!psb && (msymbol == NULL))
  645.     {
  646.       goto return_error;
  647.     }
  648.       if (psb
  649.       && (msymbol == NULL ||
  650.           (SYMBOL_VALUE_ADDRESS (psb) >= SYMBOL_VALUE_ADDRESS (msymbol))))
  651.     {
  652.       /* This case isn't being cached currently. */
  653.       if (address)
  654.         *address = SYMBOL_VALUE_ADDRESS (psb);
  655.       if (name)
  656.         *name = SYMBOL_NAME (psb);
  657.       return 1;
  658.     }
  659.     }
  660.   else
  661.     /* Must be in the minimal symbol table.  */
  662.     {
  663.       msymbol = lookup_minimal_symbol_by_pc (pc);
  664.       if (msymbol == NULL)
  665.     goto return_error;
  666.     }
  667.  
  668.   {
  669.     if (msymbol -> type == mst_text)
  670.       cache_pc_function_low = SYMBOL_VALUE_ADDRESS (msymbol);
  671.     else
  672.       /* It is a transfer table for Sun shared libraries.  */
  673.       cache_pc_function_low = pc - FUNCTION_START_OFFSET;
  674.   }
  675.   cache_pc_function_name = SYMBOL_NAME (msymbol);
  676.   /* FIXME:  Deal with bumping into end of minimal symbols for a given
  677.      objfile, and what about testing for mst_text again? */
  678.   if (SYMBOL_NAME (msymbol + 1) != NULL)
  679.     cache_pc_function_high = SYMBOL_VALUE_ADDRESS (msymbol + 1);
  680.   else
  681.     cache_pc_function_high = cache_pc_function_low + 1;
  682.   if (address)
  683.     *address = cache_pc_function_low;
  684.   if (name)
  685.     *name = cache_pc_function_name;
  686.   return 1;
  687. }
  688.  
  689. /* Return the innermost stack frame executing inside of the specified block,
  690.    or zero if there is no such frame.  */
  691.  
  692. #if 0    /* Currently unused */
  693.  
  694. FRAME
  695. block_innermost_frame (block)
  696.      struct block *block;
  697. {
  698.   struct frame_info *fi;
  699.   register FRAME frame;
  700.   register CORE_ADDR start = BLOCK_START (block);
  701.   register CORE_ADDR end = BLOCK_END (block);
  702.  
  703.   frame = 0;
  704.   while (1)
  705.     {
  706.       frame = get_prev_frame (frame);
  707.       if (frame == 0)
  708.     return 0;
  709.       fi = get_frame_info (frame);
  710.       if (fi->pc >= start && fi->pc < end)
  711.     return frame;
  712.     }
  713. }
  714.  
  715. #endif    /* 0 */
  716.  
  717. void
  718. _initialize_blockframe ()
  719. {
  720.   obstack_init (&frame_cache_obstack);
  721. }
  722.