Пример #1
0
void
_initialize_annotate (void)
{
  observer_attach_breakpoint_created (breakpoint_changed);
  observer_attach_breakpoint_deleted (breakpoint_changed);
  observer_attach_breakpoint_modified (breakpoint_changed);
}
Пример #2
0
/* Install the TUI specific hooks.  */
void
tui_install_hooks (void)
{
  /* If this hook is not set to something then print_frame_info will
     assume that the CLI, not the TUI, is active, and will print the frame info
     for us in such a way that we are not prepared to handle.  This hook is
     otherwise effectively obsolete.  */
  deprecated_print_frame_info_listing_hook
    = tui_dummy_print_frame_info_listing_hook;

  /* Install the event hooks.  */
  tui_bp_created_observer
    = observer_attach_breakpoint_created (tui_event_create_breakpoint);
  tui_bp_deleted_observer
    = observer_attach_breakpoint_deleted (tui_event_delete_breakpoint);
  tui_bp_modified_observer
    = observer_attach_breakpoint_modified (tui_event_modify_breakpoint);
  tui_inferior_exit_observer
    = observer_attach_inferior_exit (tui_inferior_exit);
  tui_before_prompt_observer
    = observer_attach_before_prompt (tui_before_prompt);
  tui_normal_stop_observer
    = observer_attach_normal_stop (tui_normal_stop);
  tui_register_changed_observer
    = observer_attach_register_changed (tui_register_changed);
}
Пример #3
0
void
_initialize_annotate (void)
{
    if (annotation_level == 2)
    {
        observer_attach_breakpoint_deleted (breakpoint_changed);
        observer_attach_breakpoint_modified (breakpoint_changed);
    }
}
Пример #4
0
/* Install the TUI specific hooks.  */
void
tui_install_hooks (void)
{
  deprecated_target_wait_hook = tui_target_wait_hook;
  deprecated_selected_frame_level_changed_hook = tui_selected_frame_level_changed_hook;
  deprecated_print_frame_info_listing_hook = tui_print_frame_info_listing_hook;

  deprecated_query_hook = tui_query_hook;

  /* Install the event hooks.  */
  tui_bp_created_observer
    = observer_attach_breakpoint_created (tui_event_create_breakpoint);
  tui_bp_deleted_observer
    = observer_attach_breakpoint_deleted (tui_event_delete_breakpoint);
  tui_bp_modified_observer
    = observer_attach_breakpoint_modified (tui_event_modify_breakpoint);

  deprecated_register_changed_hook = tui_register_changed_hook;
  deprecated_detach_hook = tui_detach_hook;
}
Пример #5
0
/* Install the TUI specific hooks.  */
void
tui_install_hooks (void)
{
  deprecated_selected_frame_level_changed_hook
    = tui_selected_frame_level_changed_hook;
  deprecated_print_frame_info_listing_hook
    = tui_print_frame_info_listing_hook;

  /* Install the event hooks.  */
  tui_bp_created_observer
    = observer_attach_breakpoint_created (tui_event_create_breakpoint);
  tui_bp_deleted_observer
    = observer_attach_breakpoint_deleted (tui_event_delete_breakpoint);
  tui_bp_modified_observer
    = observer_attach_breakpoint_modified (tui_event_modify_breakpoint);
  tui_inferior_exit_observer
    = observer_attach_inferior_exit (tui_inferior_exit);
  tui_about_to_proceed_observer
    = observer_attach_about_to_proceed (tui_about_to_proceed);

  deprecated_register_changed_hook = tui_register_changed_hook;
}
Пример #6
0
static void *
mi_interpreter_init (struct interp *interp, int top_level)
{
  struct mi_interp *mi = XNEW (struct mi_interp);
  const char *name;
  int mi_version;

  /* Assign the output channel created at startup to its own global,
     so that we can create a console channel that encapsulates and
     prefixes all gdb_output-type bits coming from the rest of the
     debugger.  */

  raw_stdout = gdb_stdout;

  /* Create MI console channels, each with a different prefix so they
     can be distinguished.  */
  mi->out = mi_console_file_new (raw_stdout, "~", '"');
  mi->err = mi_console_file_new (raw_stdout, "&", '"');
  mi->log = mi->err;
  mi->targ = mi_console_file_new (raw_stdout, "@", '"');
  mi->event_channel = mi_console_file_new (raw_stdout, "=", 0);

  name = interp_name (interp);
  /* INTERP_MI selects the most recent released version.  "mi2" was
     released as part of GDB 6.0.  */
  if (strcmp (name, INTERP_MI) == 0)
    mi_version = 2;
  else if (strcmp (name, INTERP_MI1) == 0)
    mi_version = 1;
  else if (strcmp (name, INTERP_MI2) == 0)
    mi_version = 2;
  else if (strcmp (name, INTERP_MI3) == 0)
    mi_version = 3;
  else
    gdb_assert_not_reached ("unhandled MI version");

  mi->mi_uiout = mi_out_new (mi_version);
  mi->cli_uiout = cli_out_new (mi->out);

  /* There are installed even if MI is not the top level interpreter.
     The callbacks themselves decide whether to be skipped.  */
  observer_attach_signal_received (mi_on_signal_received);
  observer_attach_end_stepping_range (mi_on_end_stepping_range);
  observer_attach_signal_exited (mi_on_signal_exited);
  observer_attach_exited (mi_on_exited);
  observer_attach_no_history (mi_on_no_history);

  if (top_level)
    {
      observer_attach_new_thread (mi_new_thread);
      observer_attach_thread_exit (mi_thread_exit);
      observer_attach_inferior_added (mi_inferior_added);
      observer_attach_inferior_appeared (mi_inferior_appeared);
      observer_attach_inferior_exit (mi_inferior_exit);
      observer_attach_inferior_removed (mi_inferior_removed);
      observer_attach_record_changed (mi_record_changed);
      observer_attach_normal_stop (mi_on_normal_stop);
      observer_attach_target_resumed (mi_on_resume);
      observer_attach_solib_loaded (mi_solib_loaded);
      observer_attach_solib_unloaded (mi_solib_unloaded);
      observer_attach_about_to_proceed (mi_about_to_proceed);
      observer_attach_traceframe_changed (mi_traceframe_changed);
      observer_attach_tsv_created (mi_tsv_created);
      observer_attach_tsv_deleted (mi_tsv_deleted);
      observer_attach_tsv_modified (mi_tsv_modified);
      observer_attach_breakpoint_created (mi_breakpoint_created);
      observer_attach_breakpoint_deleted (mi_breakpoint_deleted);
      observer_attach_breakpoint_modified (mi_breakpoint_modified);
      observer_attach_command_param_changed (mi_command_param_changed);
      observer_attach_memory_changed (mi_memory_changed);
      observer_attach_sync_execution_done (mi_on_sync_execution_done);

      /* The initial inferior is created before this function is
	 called, so we need to report it explicitly.  Use iteration in
	 case future version of GDB creates more than one inferior
	 up-front.  */
      iterate_over_inferiors (report_initial_inferior, mi);
    }

  return mi;
}
Пример #7
0
void
mi_cmd_break_insert (char *command, char **argv, int argc)
{
  char *address = NULL;
  int hardware = 0;
  int temp_p = 0;
  int thread = -1;
  int ignore_count = 0;
  char *condition = NULL;
  int pending = 0;
  int enabled = 1;
  int tracepoint = 0;
  struct cleanup *back_to;
  enum bptype type_wanted;

  enum opt
    {
      HARDWARE_OPT, TEMP_OPT, CONDITION_OPT,
      IGNORE_COUNT_OPT, THREAD_OPT, PENDING_OPT, DISABLE_OPT,
      TRACEPOINT_OPT,
    };
  static struct mi_opt opts[] =
  {
    {"h", HARDWARE_OPT, 0},
    {"t", TEMP_OPT, 0},
    {"c", CONDITION_OPT, 1},
    {"i", IGNORE_COUNT_OPT, 1},
    {"p", THREAD_OPT, 1},
    {"f", PENDING_OPT, 0},
    {"d", DISABLE_OPT, 0},
    {"a", TRACEPOINT_OPT, 0},
    { 0, 0, 0 }
  };

  /* Parse arguments. It could be -r or -h or -t, <location> or ``--''
     to denote the end of the option list. */
  int optind = 0;
  char *optarg;

  while (1)
    {
      int opt = mi_getopt ("-break-insert", argc, argv,
			   opts, &optind, &optarg);
      if (opt < 0)
	break;
      switch ((enum opt) opt)
	{
	case TEMP_OPT:
	  temp_p = 1;
	  break;
	case HARDWARE_OPT:
	  hardware = 1;
	  break;
	case CONDITION_OPT:
	  condition = optarg;
	  break;
	case IGNORE_COUNT_OPT:
	  ignore_count = atol (optarg);
	  break;
	case THREAD_OPT:
	  thread = atol (optarg);
	  break;
	case PENDING_OPT:
	  pending = 1;
	  break;
	case DISABLE_OPT:
	  enabled = 0;
	  break;
	case TRACEPOINT_OPT:
	  tracepoint = 1;
	  break;
	}
    }

  if (optind >= argc)
    error (_("-break-insert: Missing <location>"));
  if (optind < argc - 1)
    error (_("-break-insert: Garbage following <location>"));
  address = argv[optind];

  /* Now we have what we need, let's insert the breakpoint! */
  if (! mi_breakpoint_observers_installed)
    {
      observer_attach_breakpoint_created (breakpoint_notify);
      observer_attach_breakpoint_modified (breakpoint_notify);
      observer_attach_breakpoint_deleted (breakpoint_notify);
      mi_breakpoint_observers_installed = 1;
    }

  back_to = make_cleanup_restore_integer (&mi_can_breakpoint_notify);
  mi_can_breakpoint_notify = 1;

  /* Note that to request a fast tracepoint, the client uses the
     "hardware" flag, although there's nothing of hardware related to
     fast tracepoints -- one can implement slow tracepoints with
     hardware breakpoints, but fast tracepoints are always software.
     "fast" is a misnomer, actually, "jump" would be more appropriate.
     A simulator or an emulator could conceivably implement fast
     regular non-jump based tracepoints.  */
  type_wanted = (tracepoint
		 ? (hardware ? bp_fast_tracepoint : bp_tracepoint)
		 : (hardware ? bp_hardware_breakpoint : bp_breakpoint));

  create_breakpoint (get_current_arch (), address, condition, thread,
		     0 /* condition and thread are valid.  */,
		     temp_p, type_wanted,
		     ignore_count,
		     pending ? AUTO_BOOLEAN_TRUE : AUTO_BOOLEAN_FALSE,
		     NULL, 0, enabled, 0);
  do_cleanups (back_to);

}
enum mix_cmd_result
mix_cmd_break_insert (char *command, char **argv, int argc)
{
  char *address = NULL;
  enum bp_type type = REG_BP;
  int temp_p = 0;
  int thread = -1;
  int ignore_count = 0;
  char *condition = NULL;
  char *requested_shlib = NULL;
  char realpath_buf[PATH_MAX];
  enum gdb_rc rc;
  int *indices = NULL;
  int pending = 0;
  struct gdb_exception e;
  struct gdb_events *old_hooks;
  enum opt
    {
      HARDWARE_OPT, TEMP_OPT /*, REGEXP_OPT */ , CONDITION_OPT,
      IGNORE_COUNT_OPT, THREAD_OPT, PENDING_OPT, SHLIB_OPT, LIST_OPT
    };
  static struct mix_opt opts[] =
  {
    {"h", HARDWARE_OPT, 0},
    {"t", TEMP_OPT, 0},
    {"c", CONDITION_OPT, 1},
    {"i", IGNORE_COUNT_OPT, 1},
    {"p", THREAD_OPT, 1},
    {"f", PENDING_OPT, 0},
    {"s", SHLIB_OPT, 1},
    {"l", LIST_OPT, 1},
    { 0, 0, 0 }
  };

  /* Parse arguments. It could be -r or -h or -t, <location> or ``--''
     to denote the end of the option list. */
  int optind = 0;
  char *optarg;
  struct cleanup *indices_cleanup = NULL;
  while (1)
    {
      int opt = mix_getopt ("mix_cmd_break_insert", argc, argv, opts, &optind, &optarg);
      if (opt < 0)
        break;
      switch ((enum opt) opt)
        {
        case TEMP_OPT:
          temp_p = 1;
          break;
        case HARDWARE_OPT:
          type = HW_BP;
          break;
#if 0
        case REGEXP_OPT:
          type = REGEXP_BP;
          break;
#endif
        case CONDITION_OPT:
          condition = optarg;
          break;
        case IGNORE_COUNT_OPT:
          ignore_count = atol (optarg);
          /* APPLE LOCAL: Same behavior as set_ignore_count().  */
          if (ignore_count < 0)
            ignore_count = 0;
          break;
        case THREAD_OPT:
          thread = atol (optarg);
          break;
        case PENDING_OPT:
          pending = 1;
          break;
        case SHLIB_OPT:
          requested_shlib = optarg;
          break;
        case LIST_OPT:
          {
            char *numptr;
            int nelem = 0, i;
            /* First count the number of elements, which is the
               number of spaces plus one.  */
            numptr = optarg;
            while (*numptr)
              {
                if (*numptr != ' ')
                  {
                    nelem++;
                    while (*numptr != ' ' && *numptr != '\0')
                      numptr++;
                  }
                else
                  numptr++;
              }

            if (nelem == 0)
              error ("mix_cmd_break_insert: Got index with no elements");

            indices = (int *) xmalloc ((nelem + 1) * sizeof (int *));
            indices_cleanup = make_cleanup (xfree, indices);

            /* Now extract the elements.  */

            numptr = optarg;
            i = 0;
            errno = 0;
            while (*numptr != '\0')
              {
                indices[i++] = strtol (numptr, &numptr, 10);
                if (errno == EINVAL)
                    error ("mix_cmd_break_insert: bad index at \"%s\"", numptr);
              }

            /* Since we aren't passing a number of elements, we terminate the
               indices by putting in a -1 element.  */
            
            indices[i] = -1;

            break;
          }
        }
    }

  if (optind >= argc)
    error (_("mix_cmd_break_insert: Missing <location>"));
  if (optind < argc - 1)
    error (_("mix_cmd_break_insert: Garbage following <location>"));
  address = argv[optind];

  /* APPLE LOCAL: realpath() the incoming shlib name, as we do with all
     objfile/dylib/executable names.  NB this condition is incorrect if
     we're passed something like "./foo.dylib", "../foo.dylib", or
     "~/bin/foo.dylib", but that shouldn't happen....  */
  if (requested_shlib && IS_ABSOLUTE_PATH (requested_shlib))
    {
      realpath (requested_shlib, realpath_buf);
      /* It'll be xstrdup()'ed down in the breakpoint command, so just point
         to the stack array until then. */
      requested_shlib = realpath_buf; 
    }

  /* Now we have what we need, let's insert the breakpoint! */
  if (! mi_breakpoint_observers_installed)
    {
      observer_attach_breakpoint_created (breakpoint_notify);
      observer_attach_breakpoint_modified (breakpoint_notify);
      observer_attach_breakpoint_deleted (breakpoint_notify);
      mi_breakpoint_observers_installed = 1;
    }

  mi_can_breakpoint_notify = 1;
  /* Make sure we restore hooks even if exception is thrown.  */
  TRY_CATCH (e, RETURN_MASK_ALL)
    {
      switch (type)
        {
        case REG_BP:
          set_breakpoint (address, condition,
                          0 /*hardwareflag */, temp_p,
                          thread, ignore_count,
                          pending);
          break;
        case HW_BP:
          set_breakpoint (address, condition,
                          1 /*hardwareflag */, temp_p,
                          thread, ignore_count,
                          pending);
          break;
#if 0
        case REGEXP_BP:
          if (temp_p)
            error (_("mix_cmd_break_insert: Unsupported tempoary regexp breakpoint"));
          else
            rbreak_command_wrapper (address, FROM_TTY);
          return MIX_CMD_DONE;
          break;
#endif
        default:
          internal_error (__FILE__, __LINE__,
                          _("mix_cmd_break_insert: Bad switch."));
        }
    }
  mi_can_breakpoint_notify = 0;
  if (e.reason < 0)
    throw_exception (e);

  return MIX_CMD_DONE;
}