Example #1
0
void
mi_cmd_break_watch (char *command, char **argv, int argc)
{
  char *expr = NULL;
  enum wp_type type = REG_WP;
  enum opt
    {
      READ_OPT, ACCESS_OPT
    };
  static const struct mi_opt opts[] =
  {
    {"r", READ_OPT, 0},
    {"a", ACCESS_OPT, 0},
    { 0, 0, 0 }
  };

  /* Parse arguments. */
  int oind = 0;
  char *oarg;

  while (1)
    {
      int opt = mi_getopt ("-break-watch", argc, argv,
			   opts, &oind, &oarg);

      if (opt < 0)
	break;
      switch ((enum opt) opt)
	{
	case READ_OPT:
	  type = READ_WP;
	  break;
	case ACCESS_OPT:
	  type = ACCESS_WP;
	  break;
	}
    }
  if (oind >= argc)
    error (_("-break-watch: Missing <expression>"));
  if (oind < argc - 1)
    error (_("-break-watch: Garbage following <expression>"));
  expr = argv[oind];

  /* Now we have what we need, let's insert the watchpoint!  */
  switch (type)
    {
    case REG_WP:
      watch_command_wrapper (expr, FROM_TTY, 0);
      break;
    case READ_WP:
      rwatch_command_wrapper (expr, FROM_TTY, 0);
      break;
    case ACCESS_WP:
      awatch_command_wrapper (expr, FROM_TTY, 0);
      break;
    default:
      error (_("-break-watch: Unknown watchpoint type."));
    }
}
Example #2
0
static SCM
gdbscm_register_breakpoint_x (SCM self)
{
    breakpoint_smob *bp_smob
        = bpscm_get_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
    volatile struct gdb_exception except;

    /* We only support registering breakpoints created with make-breakpoint.  */
    if (!bp_smob->is_scheme_bkpt)
        scm_misc_error (FUNC_NAME, _("not a Scheme breakpoint"), SCM_EOL);

    if (bpscm_is_valid (bp_smob))
        scm_misc_error (FUNC_NAME, _("breakpoint is already registered"), SCM_EOL);

    pending_breakpoint_scm = self;

    TRY_CATCH (except, RETURN_MASK_ALL)
    {
        char *location = bp_smob->spec.location;
        int internal = bp_smob->spec.is_internal;

        switch (bp_smob->spec.type)
        {
        case bp_breakpoint:
        {
            create_breakpoint (get_current_arch (),
                               location, NULL, -1, NULL,
                               0,
                               0, bp_breakpoint,
                               0,
                               AUTO_BOOLEAN_TRUE,
                               &bkpt_breakpoint_ops,
                               0, 1, internal, 0);
            break;
        }
        case bp_watchpoint:
        {
            enum target_hw_bp_type access_type = bp_smob->spec.access_type;

            if (access_type == hw_write)
                watch_command_wrapper (location, 0, internal);
            else if (access_type == hw_access)
                awatch_command_wrapper (location, 0, internal);
            else if (access_type == hw_read)
                rwatch_command_wrapper (location, 0, internal);
            else
                gdb_assert_not_reached ("invalid access type");
            break;
        }
        default:
            gdb_assert_not_reached ("invalid breakpoint type");
        }
    }
static SCM
gdbscm_register_breakpoint_x (SCM self)
{
  breakpoint_smob *bp_smob
    = bpscm_get_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
  struct gdb_exception except = exception_none;
  char *location, *copy;
  struct event_location *eloc;
  struct cleanup *cleanup;

  /* We only support registering breakpoints created with make-breakpoint.  */
  if (!bp_smob->is_scheme_bkpt)
    scm_misc_error (FUNC_NAME, _("not a Scheme breakpoint"), SCM_EOL);

  if (bpscm_is_valid (bp_smob))
    scm_misc_error (FUNC_NAME, _("breakpoint is already registered"), SCM_EOL);

  pending_breakpoint_scm = self;
  location = bp_smob->spec.location;
  copy = location;
  eloc = new_linespec_location (&copy);
  cleanup = make_cleanup_delete_event_location (eloc);

  TRY
    {
      int internal = bp_smob->spec.is_internal;

      switch (bp_smob->spec.type)
	{
	case bp_breakpoint:
	  {
	    create_breakpoint (get_current_arch (),
			       eloc, NULL, -1, NULL,
			       0,
			       0, bp_breakpoint,
			       0,
			       AUTO_BOOLEAN_TRUE,
			       &bkpt_breakpoint_ops,
			       0, 1, internal, 0);
	    break;
	  }
	case bp_watchpoint:
	  {
	    enum target_hw_bp_type access_type = bp_smob->spec.access_type;

	    if (access_type == hw_write)
	      watch_command_wrapper (location, 0, internal);
	    else if (access_type == hw_access)
	      awatch_command_wrapper (location, 0, internal);
	    else if (access_type == hw_read)
	      rwatch_command_wrapper (location, 0, internal);
	    else
	      gdb_assert_not_reached ("invalid access type");
	    break;
	  }
	default:
	  gdb_assert_not_reached ("invalid breakpoint type");
	}
    }
  CATCH (ex, RETURN_MASK_ALL)
    {
      except = ex;
    }
  END_CATCH

  /* Ensure this gets reset, even if there's an error.  */
  pending_breakpoint_scm = SCM_BOOL_F;
  GDBSCM_HANDLE_GDB_EXCEPTION (except);
  do_cleanups (cleanup);

  return SCM_UNSPECIFIED;
}