⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 blockframe.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 2 页
字号:
#ifdef INIT_EXTRA_FRAME_INFO  INIT_EXTRA_FRAME_INFO(fromleaf, prev);#endif  /* This entry is in the frame queue now, which is good since     FRAME_SAVED_PC may use that queue to figure out it's value     (see tm-sparc.h).  We want the pc saved in the inferior frame. */  INIT_FRAME_PC(fromleaf, prev);  return prev;}CORE_ADDRget_frame_pc (frame)     FRAME frame;{  struct frame_info *fi;  fi = get_frame_info (frame);  return fi->pc;}#if defined (FRAME_FIND_SAVED_REGS)/* Find the addresses in which registers are saved in FRAME.  */voidget_frame_saved_regs (frame_info_addr, saved_regs_addr)     struct frame_info *frame_info_addr;     struct frame_saved_regs *saved_regs_addr;{  FRAME_FIND_SAVED_REGS (frame_info_addr, *saved_regs_addr);}#endif/* Return the innermost lexical block in execution   in a specified stack frame.  The frame address is assumed valid.  */struct block *get_frame_block (frame)     FRAME frame;{  struct frame_info *fi;  CORE_ADDR pc;  fi = get_frame_info (frame);  pc = fi->pc;  if (fi->next_frame != 0)    /* We are not in the innermost frame.  We need to subtract one to       get the correct block, in case the call instruction was the       last instruction of the block.  If there are any machines on       which the saved pc does not point to after the call insn, we       probably want to make fi->pc point after the call insn anyway.  */    --pc;  return block_for_pc (pc);}struct block *get_current_block (){  return block_for_pc (read_pc ());}CORE_ADDRget_pc_function_start (pc)     CORE_ADDR pc;{  register struct block *bl;  register struct symbol *symbol;  register struct minimal_symbol *msymbol;  CORE_ADDR fstart;  if ((bl = block_for_pc (pc)) != NULL &&      (symbol = block_function (bl)) != NULL)    {      bl = SYMBOL_BLOCK_VALUE (symbol);      fstart = BLOCK_START (bl);    }  else if ((msymbol = lookup_minimal_symbol_by_pc (pc)) != NULL)    {      fstart = msymbol -> address;    }  else    {      fstart = 0;    }  return (fstart);}/* Return the symbol for the function executing in frame FRAME.  */struct symbol *get_frame_function (frame)     FRAME frame;{  register struct block *bl = get_frame_block (frame);  if (bl == 0)    return 0;  return block_function (bl);}/* Return the blockvector immediately containing the innermost lexical block   containing the specified pc value, or 0 if there is none.   PINDEX is a pointer to the index value of the block.  If PINDEX   is NULL, we don't pass this information back to the caller.  */struct blockvector *blockvector_for_pc (pc, pindex)     register CORE_ADDR pc;     int *pindex;{  register struct block *b;  register int bot, top, half;  register struct symtab *s;  struct blockvector *bl;  /* First search all symtabs for one whose file contains our pc */  s = find_pc_symtab (pc);  if (s == 0)    return 0;  bl = BLOCKVECTOR (s);  b = BLOCKVECTOR_BLOCK (bl, 0);  /* Then search that symtab for the smallest block that wins.  */  /* Use binary search to find the last block that starts before PC.  */  bot = 0;  top = BLOCKVECTOR_NBLOCKS (bl);  while (top - bot > 1)    {      half = (top - bot + 1) >> 1;      b = BLOCKVECTOR_BLOCK (bl, bot + half);      if (BLOCK_START (b) <= pc)	bot += half;      else	top = bot + half;    }  /* Now search backward for a block that ends after PC.  */  while (bot >= 0)    {      b = BLOCKVECTOR_BLOCK (bl, bot);      if (BLOCK_END (b) >= pc)	{	  if (pindex)	    *pindex = bot;	  return bl;	}      bot--;    }  return 0;}/* Return the innermost lexical block containing the specified pc value,   or 0 if there is none.  */struct block *block_for_pc (pc)     register CORE_ADDR pc;{  register struct blockvector *bl;  int index;  bl = blockvector_for_pc (pc, &index);  if (bl)    return BLOCKVECTOR_BLOCK (bl, index);  return 0;}/* Return the function containing pc value PC.   Returns 0 if function is not known.  */struct symbol *find_pc_function (pc)     CORE_ADDR pc;{  register struct block *b = block_for_pc (pc);  if (b == 0)    return 0;  return block_function (b);}/* These variables are used to cache the most recent result * of find_pc_partial_function. */static CORE_ADDR cache_pc_function_low = 0;static CORE_ADDR cache_pc_function_high = 0;static char *cache_pc_function_name = 0;/* Clear cache, e.g. when symbol table is discarded. */voidclear_pc_function_cache(){  cache_pc_function_low = 0;  cache_pc_function_high = 0;  cache_pc_function_name = (char *)0;}/* Finds the "function" (text symbol) that is smaller than PC   but greatest of all of the potential text symbols.  Sets   *NAME and/or *ADDRESS conditionally if that pointer is non-zero.   Returns 0 if it couldn't find anything, 1 if it did.  On a zero   return, *NAME and *ADDRESS are always set to zero.  On a 1 return,   *NAME and *ADDRESS contain real information.  */intfind_pc_partial_function (pc, name, address)     CORE_ADDR pc;     char **name;     CORE_ADDR *address;{  struct partial_symtab *pst;  struct symbol *f;  struct minimal_symbol *msymbol;  struct partial_symbol *psb;  if (pc >= cache_pc_function_low && pc < cache_pc_function_high)    {	if (address)	    *address = cache_pc_function_low;	if (name)	    *name = cache_pc_function_name;	return 1;    }  pst = find_pc_psymtab (pc);  if (pst)    {      if (pst->readin)	{	  /* The information we want has already been read in.	     We can go to the already readin symbols and we'll get	     the best possible answer.  */	  f = find_pc_function (pc);	  if (!f)	    {	    return_error:	      /* No available symbol.  */	      if (name != 0)		*name = 0;	      if (address != 0)		*address = 0;	      return 0;	    }	  cache_pc_function_low = BLOCK_START (SYMBOL_BLOCK_VALUE (f));	  cache_pc_function_high = BLOCK_END (SYMBOL_BLOCK_VALUE (f));	  cache_pc_function_name = SYMBOL_NAME (f);	  if (name)	    *name = cache_pc_function_name;	  if (address)	    *address = cache_pc_function_low;	  return 1;	}      /* Get the information from a combination of the pst	 (static symbols), and the minimal symbol table (extern	 symbols).  */      msymbol = lookup_minimal_symbol_by_pc (pc);      psb = find_pc_psymbol (pst, pc);      if (!psb && (msymbol == NULL))	{	  goto return_error;	}      if (psb	  && (msymbol == NULL	      || (SYMBOL_VALUE_ADDRESS (psb)		  >= msymbol -> address)))	{	  /* This case isn't being cached currently. */	  if (address)	    *address = SYMBOL_VALUE_ADDRESS (psb);	  if (name)	    *name = SYMBOL_NAME (psb);	  return 1;	}    }  else    /* Must be in the minimal symbol table.  */    {      msymbol = lookup_minimal_symbol_by_pc (pc);      if (msymbol == NULL)	goto return_error;    }  {    if (msymbol -> type == mst_text)      cache_pc_function_low = msymbol -> address;    else      /* It is a transfer table for Sun shared libraries.  */      cache_pc_function_low = pc - FUNCTION_START_OFFSET;  }  cache_pc_function_name = msymbol -> name;  /* FIXME:  Deal with bumping into end of minimal symbols for a given     objfile, and what about testing for mst_text again? */  if ((msymbol + 1) -> name != NULL)    cache_pc_function_high = (msymbol + 1) -> address;  else    cache_pc_function_high = cache_pc_function_low + 1;  if (address)    *address = cache_pc_function_low;  if (name)    *name = cache_pc_function_name;  return 1;}/* Return the innermost stack frame executing inside of the specified block,   or zero if there is no such frame.  */#if 0	/* Currently unused */FRAMEblock_innermost_frame (block)     struct block *block;{  struct frame_info *fi;  register FRAME frame;  register CORE_ADDR start = BLOCK_START (block);  register CORE_ADDR end = BLOCK_END (block);  frame = 0;  while (1)    {      frame = get_prev_frame (frame);      if (frame == 0)	return 0;      fi = get_frame_info (frame);      if (fi->pc >= start && fi->pc < end)	return frame;    }}#endif	/* 0 */void_initialize_blockframe (){  obstack_init (&frame_cache_obstack);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -