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

📄 stack.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 3 页
字号:
  if (funname)    {      printf_filtered (" in ");      fputs_demangled (funname, stdout, DMGL_ANSI | DMGL_PARAMS);    }  wrap_here ("   ");  if (sal.symtab)    printf_filtered (" (%s:%d)", sal.symtab->filename, sal.line);  puts_filtered ("; ");  wrap_here ("    ");  printf_filtered ("saved %s %s\n", reg_names[PC_REGNUM],		   local_hex_string(FRAME_SAVED_PC (frame)));  {    int frameless = 0;#ifdef FRAMELESS_FUNCTION_INVOCATION    FRAMELESS_FUNCTION_INVOCATION (fi, frameless);#endif    if (frameless)      printf_filtered (" (FRAMELESS),");  }  if (calling_frame)    printf_filtered (" called by frame at %s", 		     local_hex_string(FRAME_FP (calling_frame)));  if (fi->next_frame && calling_frame)    puts_filtered (",");  wrap_here ("   ");  if (fi->next_frame)    printf_filtered (" caller of frame at %s", local_hex_string(fi->next_frame));  if (fi->next_frame || calling_frame)    puts_filtered ("\n");  if (s)     printf_filtered(" source language %s.\n", language_str(s->language));#ifdef PRINT_EXTRA_FRAME_INFO  PRINT_EXTRA_FRAME_INFO (fi);#endif  {    /* Address of the argument list for this frame, or 0.  */    CORE_ADDR arg_list = FRAME_ARGS_ADDRESS_CORRECT (fi);    /* Number of args for this frame, or -1 if unknown.  */    int numargs;    if (arg_list == 0)	printf_filtered (" Arglist at unknown address.\n");    else      {	printf_filtered (" Arglist at %s,", local_hex_string(arg_list));	FRAME_NUM_ARGS (numargs, fi);	if (numargs < 0)	  puts_filtered (" args: ");	else if (numargs == 0)	  puts_filtered (" no args.");	else if (numargs == 1)	  puts_filtered (" 1 arg: ");	else	  printf_filtered (" %d args: ", numargs);	print_frame_args (func, fi, numargs, stdout);	puts_filtered ("\n");      }  }  {    /* Address of the local variables for this frame, or 0.  */    CORE_ADDR arg_list = FRAME_LOCALS_ADDRESS (fi);    if (arg_list == 0)	printf_filtered (" Locals at unknown address,");    else	printf_filtered (" Locals at %s,", local_hex_string(arg_list));  }#if defined (FRAME_FIND_SAVED_REGS)    get_frame_saved_regs (fi, &fsr);  /* The sp is special; what's returned isn't the save address, but     actually the value of the previous frame's sp.  */  printf_filtered (" Previous frame's sp is %s\n", 		   local_hex_string(fsr.regs[SP_REGNUM]));  count = 0;  for (i = 0; i < NUM_REGS; i++)    if (fsr.regs[i] && i != SP_REGNUM)      {	if (count == 0)	  puts_filtered (" Saved registers:\n ");	else	  puts_filtered (",");	wrap_here (" ");	printf_filtered (" %s at %s", reg_names[i], 			 local_hex_string(fsr.regs[i]));	count++;      }  if (count)    puts_filtered ("\n");#endif /* Have FRAME_FIND_SAVED_REGS.  */}#if 0/* Set a limit on the number of frames printed by default in a   backtrace.  */static int backtrace_limit;static voidset_backtrace_limit_command (count_exp, from_tty)     char *count_exp;     int from_tty;{  int count = parse_and_eval_address (count_exp);  if (count < 0)    error ("Negative argument not meaningful as backtrace limit.");  backtrace_limit = count;}static voidbacktrace_limit_info (arg, from_tty)     char *arg;     int from_tty;{  if (arg)    error ("\"Info backtrace-limit\" takes no arguments.");  printf ("Backtrace limit: %d.\n", backtrace_limit);}#endif/* Print briefly all stack frames or just the innermost COUNT frames.  */static voidbacktrace_command (count_exp, from_tty)     char *count_exp;     int from_tty;{  struct frame_info *fi;  register int count;  register FRAME frame;  register int i;  register FRAME trailing;  register int trailing_level;  if (!target_has_stack)    error ("No stack.");  /* The following code must do two things.  First, it must     set the variable TRAILING to the frame from which we should start     printing.  Second, it must set the variable count to the number     of frames which we should print, or -1 if all of them.  */  trailing = get_current_frame ();  trailing_level = 0;  if (count_exp)    {      count = parse_and_eval_address (count_exp);      if (count < 0)	{	  FRAME current;	  count = -count;	  current = trailing;	  while (current && count--)	    {	      QUIT;	      current = get_prev_frame (current);	    }	  	  /* Will stop when CURRENT reaches the top of the stack.  TRAILING	     will be COUNT below it.  */	  while (current)	    {	      QUIT;	      trailing = get_prev_frame (trailing);	      current = get_prev_frame (current);	      trailing_level++;	    }	  	  count = -1;	}    }  else    count = -1;  if (info_verbose)    {      struct partial_symtab *ps;            /* Read in symbols for all of the frames.  Need to do this in	 a separate pass so that "Reading in symbols for xxx" messages	 don't screw up the appearance of the backtrace.  Also	 if people have strong opinions against reading symbols for	 backtrace this may have to be an option.  */      i = count;      for (frame = trailing;	   frame != NULL && i--;	   frame = get_prev_frame (frame))	{	  QUIT;	  fi = get_frame_info (frame);	  ps = find_pc_psymtab (fi->pc);	  if (ps)	    PSYMTAB_TO_SYMTAB (ps);	/* Force syms to come in */	}    }  for (i = 0, frame = trailing;       frame && count--;       i++, frame = get_prev_frame (frame))    {      QUIT;      fi = get_frame_info (frame);      print_frame_info (fi, trailing_level + i, 0, 1);    }  /* If we've stopped before the end, mention that.  */  if (frame && from_tty)    printf_filtered ("(More stack frames follow...)\n");}/* Print the local variables of a block B active in FRAME.   Return 1 if any variables were printed; 0 otherwise.  */static intprint_block_frame_locals (b, frame, stream)     struct block *b;     register FRAME frame;     register FILE *stream;{  int nsyms;  register int i;  register struct symbol *sym;  register int values_printed = 0;  nsyms = BLOCK_NSYMS (b);  for (i = 0; i < nsyms; i++)    {      sym = BLOCK_SYM (b, i);      if (SYMBOL_CLASS (sym) == LOC_LOCAL	  || SYMBOL_CLASS (sym) == LOC_REGISTER	  || SYMBOL_CLASS (sym) == LOC_STATIC)	{	  values_printed = 1;	  fprint_symbol (stream, SYMBOL_NAME (sym));	  fputs_filtered (" = ", stream);	  print_variable_value (sym, frame, stream);	  fprintf_filtered (stream, "\n");	}    }  return values_printed;}/* Same, but print labels.  */static intprint_block_frame_labels (b, have_default, stream)     struct block *b;     int *have_default;     register FILE *stream;{  int nsyms;  register int i;  register struct symbol *sym;  register int values_printed = 0;  nsyms = BLOCK_NSYMS (b);  for (i = 0; i < nsyms; i++)    {      sym = BLOCK_SYM (b, i);      if (! strcmp (SYMBOL_NAME (sym), "default"))	{	  if (*have_default)	    continue;	  *have_default = 1;	}      if (SYMBOL_CLASS (sym) == LOC_LABEL)	{	  struct symtab_and_line sal;	  sal = find_pc_line (SYMBOL_VALUE_ADDRESS (sym), 0);	  values_printed = 1;	  fputs_demangled (SYMBOL_NAME (sym), stream, DMGL_ANSI | DMGL_PARAMS);	  if (addressprint)	    fprintf_filtered (stream, " %s", 			      local_hex_string(SYMBOL_VALUE_ADDRESS (sym)));	  fprintf_filtered (stream, " in file %s, line %d\n",			    sal.symtab->filename, sal.line);	}    }  return values_printed;}/* Print on STREAM all the local variables in frame FRAME,   including all the blocks active in that frame   at its current pc.   Returns 1 if the job was done,   or 0 if nothing was printed because we have no info   on the function running in FRAME.  */static voidprint_frame_local_vars (frame, stream)     register FRAME frame;     register FILE *stream;{  register struct block *block = get_frame_block (frame);  register int values_printed = 0;  if (block == 0)    {      fprintf_filtered (stream, "No symbol table info available.\n");      return;    }    while (block != 0)    {      if (print_block_frame_locals (block, frame, stream))	values_printed = 1;      /* After handling the function's top-level block, stop.	 Don't continue to its superblock, the block of	 per-file symbols.  */      if (BLOCK_FUNCTION (block))	break;      block = BLOCK_SUPERBLOCK (block);    }  if (!values_printed)    {      fprintf_filtered (stream, "No locals.\n");    }}/* Same, but print labels.  */static voidprint_frame_label_vars (frame, this_level_only, stream)     register FRAME frame;     int this_level_only;     register FILE *stream;{  register struct blockvector *bl;  register struct block *block = get_frame_block (frame);  register int values_printed = 0;  int index, have_default = 0;  char *blocks_printed;  struct frame_info *fi = get_frame_info (frame);  CORE_ADDR pc = fi->pc;  if (block == 0)    {      fprintf_filtered (stream, "No symbol table info available.\n");      return;    }  bl = blockvector_for_pc (BLOCK_END (block) - 4, &index);  blocks_printed = (char *) alloca (BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));  memset (blocks_printed, 0, BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));  while (block != 0)    {      CORE_ADDR end = BLOCK_END (block) - 4;      int last_index;      if (bl != blockvector_for_pc (end, &index))	error ("blockvector blotch");      if (BLOCKVECTOR_BLOCK (bl, index) != block)	error ("blockvector botch");      last_index = BLOCKVECTOR_NBLOCKS (bl);      index += 1;      /* Don't print out blocks that have gone by.  */      while (index < last_index	     && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < pc)	index++;      while (index < last_index	     && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < end)	{	  if (blocks_printed[index] == 0)	    {	      if (print_block_frame_labels (BLOCKVECTOR_BLOCK (bl, index), &have_default, stream))		values_printed = 1;	      blocks_printed[index] = 1;	    }	  index++;	}      if (have_default)	return;      if (values_printed && this_level_only)	return;      /* After handling the function's top-level block, stop.	 Don't continue to its superblock, the block of	 per-file symbols.  */      if (BLOCK_FUNCTION (block))	break;      block = BLOCK_SUPERBLOCK (block);    }  if (!values_printed && !this_level_only)    {      fprintf_filtered (stream, "No catches.\n");    }}/* ARGSUSED */static voidlocals_info (args, from_tty)     char *args;     int from_tty;{  if (!selected_frame)    error ("No frame selected.");  print_frame_local_vars (selected_frame, stdout);}static voidcatch_info (ignore, from_tty)     char *ignore;     int from_tty;{  if (!selected_frame)    error ("No frame selected.");  print_frame_label_vars (selected_frame, 0, stdout);}static voidprint_frame_arg_vars (frame, stream)     register FRAME frame;     register FILE *stream;{  struct symbol *func = get_frame_function (frame);  register struct block *b;  int nsyms;  register int i;  register struct symbol *sym, *sym2;  register int values_printed = 0;  if (func == 0)    {

⌨️ 快捷键说明

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