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

📄 breakpoint.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 5 页
字号:
voidbreakpoint_auto_delete (bs)     bpstat bs;{  for (; bs; bs = bs->next)    if (bs->breakpoint_at && bs->breakpoint_at->disposition == delete)      delete_breakpoint (bs->breakpoint_at);}/* Delete a breakpoint and clean up all traces of it in the data structures. */voiddelete_breakpoint (bpt)     struct breakpoint *bpt;{  register struct breakpoint *b;  register bpstat bs;  if (bpt->inserted)      target_remove_breakpoint(bpt->address, bpt->shadow_contents);  if (breakpoint_chain == bpt)    breakpoint_chain = bpt->next;  ALL_BREAKPOINTS (b)    if (b->next == bpt)      {	b->next = bpt->next;	break;      }  check_duplicates (bpt->address);  free_command_lines (bpt->commands);  if (bpt->cond)    free ((PTR)bpt->cond);  if (bpt->cond_string != NULL)    free ((PTR)bpt->cond_string);  if (bpt->addr_string != NULL)    free ((PTR)bpt->addr_string);  if (xgdb_verbose && bpt->type == bp_breakpoint)    printf ("breakpoint #%d deleted\n", bpt->number);  /* Be sure no bpstat's are pointing at it after it's been freed.  */  /* FIXME, how can we find all bpstat's?  We just check stop_bpstat for now. */  for (bs = stop_bpstat; bs; bs = bs->next)    if (bs->breakpoint_at == bpt)      bs->breakpoint_at = NULL;  free ((PTR)bpt);}static voiddelete_command (arg, from_tty)     char *arg;     int from_tty;{  if (arg == 0)    {      /* Ask user only if there are some breakpoints to delete.  */      if (!from_tty	  || (breakpoint_chain && query ("Delete all breakpoints? ", 0, 0)))	{	  /* No arg; clear all breakpoints.  */	  while (breakpoint_chain)	    delete_breakpoint (breakpoint_chain);	}    }  else    map_breakpoint_numbers (arg, delete_breakpoint);}/* Reset a breakpoint given it's struct breakpoint * BINT.   The value we return ends up being the return value from catch_errors.   Unused in this case.  */static intbreakpoint_re_set_one (bint)     char *bint;{  struct breakpoint *b = (struct breakpoint *)bint;  /* get past catch_errs */  int i;  struct symtabs_and_lines sals;  char *s;  enum enable save_enable;  switch (b->type)    {    case bp_breakpoint:      if (b->addr_string == NULL)	{	  /* Anything without a string can't be re-set. */	  delete_breakpoint (b);	  return 0;	}      /* In case we have a problem, disable this breakpoint.  We'll restore	 its status if we succeed.  */      save_enable = b->enable;      b->enable = disabled;      s = b->addr_string;      sals = decode_line_1 (&s, 1, (struct symtab *)NULL, 0);      for (i = 0; i < sals.nelts; i++)	{	  resolve_sal_pc (&sals.sals[i]);	  if (b->symtab != sals.sals[i].symtab	      || b->line_number != sals.sals[i].line	      || b->address != sals.sals[i].pc)	    {	      b->symtab = sals.sals[i].symtab;	      b->line_number = sals.sals[i].line;	      b->address = sals.sals[i].pc;	      if (b->cond_string != NULL)		{		  s = b->cond_string;		  b->cond = parse_exp_1 (&s, block_for_pc (sals.sals[i].pc), 0);		}	  	      check_duplicates (b->address);	      mention (b);	    }	  b->enable = save_enable;	/* Restore it, this worked. */	}      free ((PTR)sals.sals);      break;    case bp_watchpoint:      break;    default:      printf_filtered ("Deleting unknown breakpoint type %d\n", b->type);    case bp_until:    case bp_finish:    case bp_longjmp:    case bp_longjmp_resume:      delete_breakpoint (b);      break;    }  return 0;}/* Re-set all breakpoints after symbols have been re-loaded.  */voidbreakpoint_re_set (){  struct breakpoint *b, *temp;  static char message1[] = "Error in re-setting breakpoint %d:\n";  char message[sizeof (message1) + 30 /* slop */];    /* If we have no current source symtab, and we have any breakpoints,     go through the work of making a source context.  */  if (current_source_symtab == NULL && breakpoint_chain != 0)    {      select_source_symtab (NULL);    }  ALL_BREAKPOINTS_SAFE (b, temp)    {      sprintf (message, message1, b->number);	/* Format possible error msg */      catch_errors (breakpoint_re_set_one, (char *) b, message);    }  create_longjmp_breakpoint("longjmp");  create_longjmp_breakpoint("_longjmp");  create_longjmp_breakpoint("siglongjmp");  create_longjmp_breakpoint(NULL);#if 0  /* Took this out (temporaliy at least), since it produces an extra      blank line at startup. This messes up the gdbtests. -PB */  /* Blank line to finish off all those mention() messages we just printed.  */  printf_filtered ("\n");#endif}/* Set ignore-count of breakpoint number BPTNUM to COUNT.   If from_tty is nonzero, it prints a message to that effect,   which ends with a period (no newline).  */voidset_ignore_count (bptnum, count, from_tty)     int bptnum, count, from_tty;{  register struct breakpoint *b;  if (count < 0)    count = 0;  ALL_BREAKPOINTS (b)    if (b->number == bptnum)      {	b->ignore_count = count;	if (!from_tty)	  return;	else if (count == 0)	  printf_filtered ("Will stop next time breakpoint %d is reached.",			   bptnum);	else if (count == 1)	  printf_filtered ("Will ignore next crossing of breakpoint %d.",			   bptnum);	else	  printf_filtered ("Will ignore next %d crossings of breakpoint %d.",		  count, bptnum);	return;      }  error ("No breakpoint number %d.", bptnum);}/* Clear the ignore counts of all breakpoints.  */voidbreakpoint_clear_ignore_counts (){  struct breakpoint *b;  ALL_BREAKPOINTS (b)    b->ignore_count = 0;}/* Command to set ignore-count of breakpoint N to COUNT.  */static voidignore_command (args, from_tty)     char *args;     int from_tty;{  char *p = args;  register int num;  if (p == 0)    error_no_arg ("a breakpoint number");    num = get_number (&p);  if (*p == 0)    error ("Second argument (specified ignore-count) is missing.");  set_ignore_count (num,		    longest_to_int (value_as_long (parse_and_eval (p))),		    from_tty);  printf_filtered ("\n");}/* Call FUNCTION on each of the breakpoints   whose numbers are given in ARGS.  */static voidmap_breakpoint_numbers (args, function)     char *args;     void (*function) PARAMS ((struct breakpoint *));{  register char *p = args;  char *p1;  register int num;  register struct breakpoint *b;  if (p == 0)    error_no_arg ("one or more breakpoint numbers");  while (*p)    {      p1 = p;            num = get_number (&p1);      ALL_BREAKPOINTS (b)	if (b->number == num)	  {	    function (b);	    goto win;	  }      printf ("No breakpoint number %d.\n", num);    win:      p = p1;    }}static voidenable_breakpoint (bpt)     struct breakpoint *bpt;{  bpt->enable = enabled;  if (xgdb_verbose && bpt->type == bp_breakpoint)    printf ("breakpoint #%d enabled\n", bpt->number);  check_duplicates (bpt->address);  if (bpt->type == bp_watchpoint)    {      if (bpt->exp_valid_block != NULL       && !contained_in (get_selected_block (), bpt->exp_valid_block))	{	  printf_filtered ("\Cannot enable watchpoint %d because the block in which its expression\n\is valid is not currently in scope.\n", bpt->number);	  return;	}      value_free (bpt->val);      bpt->val = evaluate_expression (bpt->exp);      release_value (bpt->val);    }}/* ARGSUSED */static voidenable_command (args, from_tty)     char *args;     int from_tty;{  struct breakpoint *bpt;  if (args == 0)    ALL_BREAKPOINTS (bpt)      switch (bpt->type)	{	case bp_breakpoint:	case bp_watchpoint:	  enable_breakpoint (bpt);	default:	  continue;	}  else    map_breakpoint_numbers (args, enable_breakpoint);}static voiddisable_breakpoint (bpt)     struct breakpoint *bpt;{  bpt->enable = disabled;  if (xgdb_verbose && bpt->type == bp_breakpoint)    printf_filtered ("breakpoint #%d disabled\n", bpt->number);  check_duplicates (bpt->address);}/* ARGSUSED */static voiddisable_command (args, from_tty)     char *args;     int from_tty;{  register struct breakpoint *bpt;  if (args == 0)    ALL_BREAKPOINTS (bpt)      switch (bpt->type)	{	case bp_breakpoint:	case bp_watchpoint:	  disable_breakpoint (bpt);	default:	  continue;	}  else    map_breakpoint_numbers (args, disable_breakpoint);}static voidenable_once_breakpoint (bpt)     struct breakpoint *bpt;{  bpt->enable = enabled;  bpt->disposition = disable;  check_duplicates (bpt->address);}/* ARGSUSED */static voidenable_once_command (args, from_tty)     char *args;     int from_tty;{  map_breakpoint_numbers (args, enable_once_breakpoint);}static voidenable_delete_breakpoint (bpt)     struct breakpoint *bpt;{  bpt->enable = enabled;  bpt->disposition = delete;  check_duplicates (bpt->address);}/* ARGSUSED */static voidenable_delete_command (args, from_tty)     char *args;     int from_tty;{  map_breakpoint_numbers (args, enable_delete_breakpoint);}voidclear_breakpoints(){	delete_command(0, 0);}/* * Use default_breakpoint_'s, or nothing if they aren't valid. */struct symtabs_and_linesdecode_line_spec_1 (string, funfirstline)     char *string;     int funfirstline;{  struct symtabs_and_lines sals;  if (string == 0)    error ("Empty line specification.");  if (default_breakpoint_valid)    sals = decode_line_1 (&string, funfirstline,			  default_breakpoint_symtab, default_breakpoint_line);  else    sals = decode_line_1 (&string, funfirstline, (struct symtab *)NULL, 0);  if (*string)    error ("Junk at end of line specification: %s", string);  return sals;}void_initialize_breakpoint (){  extern char **make_function_completion_list();  breakpoint_chain = 0;  /* Don't bother to call set_breakpoint_count.  $bpnum isn't useful     before a breakpoint is set.  */  breakpoint_count = 0;  add_com ("ignore", class_breakpoint, ignore_command,	   "Set ignore-count of breakpoint number N to COUNT.");  add_com ("commands", class_breakpoint, commands_command,	   "Set commands to be executed when a breakpoint is hit.\n\Give breakpoint number as argument after \"commands\".\n\With no argument, the targeted breakpoint is the last one set.\n\The commands themselves follow starting on the next line.\n\Type a line containing \"end\" to indicate the end of them.\n\Give \"silent\" as the first line to make the breakpoint silent;\n\then no output is printed when it is hit, except what the commands print.");  add_com ("condition", class_breakpoint, condition_command,	   "Specify breakpoint number N to break only if COND is true.\n\N is an integer; COND is an expression to be evaluated whenever\n\breakpoint N is reached.  ");  add_cmd ("tbreak", class_breakpoint, tbreak_command,	   "Set a temporary breakpoint.  Args like \"break\" command.\n\Like \"break\" except the breakpoint is only enabled temporarily,\n\so it will be disabled when hit.  Equivalent to \"break\" followed\n\by using \"enable once\" on the breakpoint number.",	&cmdlist)->completer = make_function_completion_list;  add_prefix_cmd ("enable", class_breakpoint, enable_command,		  "Enable some breakpoints.\n\Give breakpoint numbers (separated by spaces) as arguments.\n\With no subcommand, breakpoints are enabled until you command otherwise.\n\This is used to cancel the effect of the \"disable\" command.\n\With a subcommand you can enable temporarily.",		  &enablelist, "enable ", 1, &cmdlist);  add_abbrev_prefix_cmd ("breakpoints", class_breakpoint, enable_command,		  "Enable some breakpoints.\n\Give breakpoint numbers (separated by spaces) as arguments.\n\This is used to cancel the effect of the \"disable\" command.\n\May be abbreviated to simply \"enable\".\n",		  &enablebreaklist, "enable breakpoints ", 1, &enablelist);  add_cmd ("once", no_class, enable_once_command,	   "Enable breakpoints for one hit.  Give breakpoint numbers.\n\If a breakpoint is hit while enabled in this fashion, it becomes disabled.\n\See the \"tbreak\" command which sets a breakpoint and enables it once.",	   &enablebreaklist);  add_cmd ("delete", no_class, enable_delete_command,	   "Enable breakpoints and delete when hit.  Give breakpoint numbers.\n\If a breakpoint is hit while enabled in this fashion, it is deleted.",	   &enablebreaklist);  add_cmd ("delete", no_class, enable_delete_command,	   "Enable breakpoints and delete when hit.  Give breakpoint numbers.\n\If a breakpoint is hit while enabled in this fashion, it is deleted.",	   &enablelist);  add_cmd ("once", no_class, enable_once_command,	   "Enable breakpoints for one hit.  Give breakpoint numbers.\n\If a breakpoint is hit while enabled in this fashion, it becomes disabled.\n\See the \"tbreak\" command which sets a breakpoint and enables it once.",	   &enablelist);  add_prefix_cmd ("disable", class_breakpoint, disable_command,	   "Disable some breakpoints.\n\Arguments are breakpoint numbers with spaces in between.\n\To disable all breakpoints, give no argument.\n\A disabled breakpoint is not forgotten, but has no effect until reenabled.",		  &disablelist, "disable ", 1, &cmdlist);  add_com_alias ("dis", "disable", class_breakpoint, 1);  add_com_alias ("disa", "disable", class_breakpoint, 1);  add_cmd ("breakpoints", class_alias, disable_command,	   "Disable some breakpoints.\n\Arguments are breakpoint numbers with spaces in between.\n\To disable all breakpoints, give no argument.\n\A disabled breakpoint is not forgotten, but has no effect until reenabled.\n\This command may be abbreviated \"disable\".",	   &disablelist);  add_prefix_cmd ("delete", class_breakpoint, delete_command,	   "Delete some breakpoints or auto-display expressions.\n\Arguments are breakpoint numbers with spaces in between.\n\To delete all breakpoints, give no argument.\n\\n\Also a prefix command for deletion of other GDB objects.\n\The \"unset\" command is also an alias for \"delete\".",		  &deletelist, "delete ", 1, &cmdlist);  add_com_alias ("d", "delete", class_breakpoint, 1);  add_cmd ("breakpoints", class_alias, delete_command,	   "Delete some breakpoints or auto-display expre

⌨️ 快捷键说明

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