Esempio n. 1
0
/* Function to initialize the content of the execution info window,
   based upon the input window which is either the source or
   disassembly window.  */
enum tui_status
tui_set_exec_info_content (struct tui_win_info *win_info)
{
  enum tui_status ret = TUI_SUCCESS;

  if (win_info->detail.source_info.execution_info
      != (struct tui_gen_win_info *) NULL)
    {
      struct tui_gen_win_info *exec_info_ptr
	= win_info->detail.source_info.execution_info;

      if (exec_info_ptr->content == NULL)
	exec_info_ptr->content =
	  (void **) tui_alloc_content (win_info->generic.height,
					 exec_info_ptr->type);
      if (exec_info_ptr->content != NULL)
	{
	  int i;

          tui_update_breakpoint_info (win_info, 1);
	  for (i = 0; i < win_info->generic.content_size; i++)
	    {
	      struct tui_win_element *element;
	      struct tui_win_element *src_element;
              int mode;

	      element = (struct tui_win_element *) exec_info_ptr->content[i];
	      src_element = (struct tui_win_element *)
		win_info->generic.content[i];

              memset(element->which_element.simple_string, ' ',
                     sizeof(element->which_element.simple_string));
              element->which_element.simple_string[TUI_EXECINFO_SIZE - 1] = 0;

	      /* Now update the exec info content based upon the state
                 of each line as indicated by the source content.  */
              mode = src_element->which_element.source.has_break;
              if (mode & TUI_BP_HIT)
                element->which_element.simple_string[TUI_BP_HIT_POS] =
                  (mode & TUI_BP_HARDWARE) ? 'H' : 'B';
              else if (mode & (TUI_BP_ENABLED | TUI_BP_DISABLED))
                element->which_element.simple_string[TUI_BP_HIT_POS] =
                  (mode & TUI_BP_HARDWARE) ? 'h' : 'b';

              if (mode & TUI_BP_ENABLED)
                element->which_element.simple_string[TUI_BP_BREAK_POS] = '+';
              else if (mode & TUI_BP_DISABLED)
                element->which_element.simple_string[TUI_BP_BREAK_POS] = '-';

              if (src_element->which_element.source.is_exec_point)
                element->which_element.simple_string[TUI_EXEC_POS] = '>';
	    }
	  exec_info_ptr->content_size = win_info->generic.content_size;
	}
      else
	ret = TUI_FAILURE;
    }

  return ret;
}
Esempio n. 2
0
/* Adds the input number of elements to the windows's content.  If no
   content has been allocated yet, alloc_content() is called to do
   this.  The index of the first element added is returned, unless
   there is a memory allocation error, in which case, (-1) is
   returned.  */
int
tui_add_content_elements (struct tui_gen_win_info *win_info, 
			  int num_elements)
{
  struct tui_win_element *element_ptr;
  int i, index_start;

  if (win_info->content == NULL)
    {
      win_info->content = tui_alloc_content (num_elements, win_info->type);
      index_start = 0;
    }
  else
    index_start = win_info->content_size;
  if (win_info->content != NULL)
    {
      for (i = index_start; (i < num_elements + index_start); i++)
	{
	  element_ptr = XNEW (struct tui_win_element);
	  if (element_ptr != NULL)
	    {
	      win_info->content[i] = element_ptr;
	      init_content_element (element_ptr, win_info->type);
	      win_info->content_size++;
	    }
	  else	/* Things must be really hosed now!  We ran out of
		   memory!?  */
	    return (-1);
	}
    }

  return index_start;
}
Esempio n. 3
0
/* Update the locator, with the provided arguments.  */
static void
tui_set_locator_info (struct gdbarch *gdbarch,
		      const char *fullname,
		      const char *procname, 
		      int lineno,
                      CORE_ADDR addr)
{
  struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
  struct tui_locator_element *element;

  /* Allocate the locator content if necessary.  */
  if (locator->content_size <= 0)
    {
      locator->content = (void **) tui_alloc_content (1, locator->type);
      locator->content_size = 1;
    }

  element = &((struct tui_win_element *)
	      locator->content[0])->which_element.locator;
  element->proc_name[0] = (char) 0;
  strcat_to_buf (element->proc_name, MAX_LOCATOR_ELEMENT_LEN, procname);
  element->line_no = lineno;
  element->addr = addr;
  element->gdbarch = gdbarch;
  tui_set_locator_fullname (fullname);
}
Esempio n. 4
0
/* init_content_element().
 */
static void
init_content_element (struct tui_win_element *element, 
		      enum tui_win_type type)
{
  element->highlight = FALSE;
  switch (type)
    {
    case SRC_WIN:
    case DISASSEM_WIN:
      element->which_element.source.line = NULL;
      element->which_element.source.line_or_addr.loa = LOA_LINE;
      element->which_element.source.line_or_addr.u.line_no = 0;
      element->which_element.source.is_exec_point = FALSE;
      element->which_element.source.has_break = FALSE;
      break;
    case DATA_WIN:
      tui_init_generic_part (&element->which_element.data_window);
      element->which_element.data_window.type = DATA_ITEM_WIN;
      element->which_element.data_window.content =
	tui_alloc_content (1, DATA_ITEM_WIN);
      element->which_element.data_window.content_size = 1;
      break;
    case CMD_WIN:
      element->which_element.command.line = NULL;
      break;
    case DATA_ITEM_WIN:
      element->which_element.data.name = NULL;
      element->which_element.data.type = TUI_REGISTER;
      element->which_element.data.item_no = UNDEFINED_ITEM;
      element->which_element.data.value = NULL;
      element->which_element.data.highlight = FALSE;
      element->which_element.data.content = NULL;
      break;
    case LOCATOR_WIN:
      element->which_element.locator.full_name[0] =
	element->which_element.locator.proc_name[0] = (char) 0;
      element->which_element.locator.line_no = 0;
      element->which_element.locator.addr = 0;
      break;
    case EXEC_INFO_WIN:
      memset(element->which_element.simple_string, ' ',
             sizeof(element->which_element.simple_string));
      break;
    default:
      break;
    }
}
enum tui_status
tui_alloc_source_buffer (struct tui_win_info *win_info)
{
  char *src_line_buf;
  int i, line_width, max_lines;
  enum tui_status ret = TUI_FAILURE;

  max_lines = win_info->generic.height;	/* less the highlight box */
  line_width = win_info->generic.width - 1;
  /*
     ** Allocate the buffer for the source lines.  Do this only once since they
     ** will be re-used for all source displays.  The only other time this will
     ** be done is when a window's size changes.
   */
  if (win_info->generic.content == NULL)
    {
      src_line_buf = (char *) xmalloc ((max_lines * line_width) * sizeof (char));
      if (src_line_buf == (char *) NULL)
	fputs_unfiltered (
	   "Unable to Allocate Memory for Source or Disassembly Display.\n",
			   gdb_stderr);
      else
	{
	  /* allocate the content list */
	  if ((win_info->generic.content =
	  (void **) tui_alloc_content (max_lines, SRC_WIN)) == NULL)
	    {
	      xfree (src_line_buf);
	      src_line_buf = (char *) NULL;
	      fputs_unfiltered (
				 "Unable to Allocate Memory for Source or Disassembly Display.\n",
				 gdb_stderr);
	    }
	}
      for (i = 0; i < max_lines; i++)
	((struct tui_win_element *)
	 win_info->generic.content[i])->which_element.source.line =
	  src_line_buf + (line_width * i);
      ret = TUI_SUCCESS;
    }
  else
    ret = TUI_SUCCESS;

  return ret;
}
Esempio n. 6
0
static int
tui_set_locator_info (struct gdbarch *gdbarch,
		      const char *fullname,
		      const char *procname, 
		      int lineno,
                      CORE_ADDR addr)
{
  struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
  struct tui_locator_element *element;
  int locator_changed_p = 0;

  /* Allocate the locator content if necessary.  */
  if (locator->content_size <= 0)
    {
      locator->content = tui_alloc_content (1, LOCATOR_WIN);
      locator->content_size = 1;
      locator_changed_p = 1;
    }

  if (procname == NULL)
    procname = "";

  if (fullname == NULL)
    fullname = "";

  element = &locator->content[0]->which_element.locator;

  locator_changed_p |= strncmp (element->proc_name, procname,
				MAX_LOCATOR_ELEMENT_LEN) != 0;
  locator_changed_p |= lineno != element->line_no;
  locator_changed_p |= addr != element->addr;
  locator_changed_p |= gdbarch != element->gdbarch;
  locator_changed_p |= strncmp (element->full_name, fullname,
				MAX_LOCATOR_ELEMENT_LEN) != 0;

  element->proc_name[0] = (char) 0;
  strcat_to_buf (element->proc_name, MAX_LOCATOR_ELEMENT_LEN, procname);
  element->line_no = lineno;
  element->addr = addr;
  element->gdbarch = gdbarch;
  tui_set_locator_fullname (fullname);

  return locator_changed_p;
}
Esempio n. 7
0
enum tui_status
tui_alloc_source_buffer (struct tui_win_info *win_info)
{
  char *src_line_buf;
  int i, line_width, max_lines;

  max_lines = win_info->generic.height;	/* Less the highlight box.  */
  line_width = win_info->generic.width - 1;
  /*
   * Allocate the buffer for the source lines.  Do this only once
   * since they will be re-used for all source displays.  The only
   * other time this will be done is when a window's size changes.
   */
  if (win_info->generic.content == NULL)
    {
      src_line_buf = (char *) 
	xmalloc ((max_lines * line_width) * sizeof (char));
      if (src_line_buf == (char *) NULL)
	{
	  fputs_unfiltered ("Unable to Allocate Memory for "
			    "Source or Disassembly Display.\n",
			    gdb_stderr);
	  return TUI_FAILURE;
	}
      /* Allocate the content list.  */
      win_info->generic.content = tui_alloc_content (max_lines, SRC_WIN);
      if (win_info->generic.content == NULL)
	{
	  xfree (src_line_buf);
	  fputs_unfiltered ("Unable to Allocate Memory for "
			    "Source or Disassembly Display.\n",
			    gdb_stderr);
	  return TUI_FAILURE;
	}
      for (i = 0; i < max_lines; i++)
	win_info->generic.content[i]->which_element.source.line
	  = src_line_buf + (line_width * i);
    }

  return TUI_SUCCESS;
}
Esempio n. 8
0
static enum tui_status
tui_show_register_group (struct reggroup *group,
                         struct frame_info *frame,
                         int refresh_values_only)
{
    struct gdbarch *gdbarch = get_frame_arch (frame);
    enum tui_status ret = TUI_FAILURE;
    int nr_regs;
    int allocated_here = FALSE;
    int regnum, pos;
    char title[80];
    struct tui_data_info *display_info = &TUI_DATA_WIN->detail.data_display_info;

    /* Make a new title showing which group we display.  */
    snprintf (title, sizeof (title) - 1, "Register group: %s",
    reggroup_name (group));
    xfree (TUI_DATA_WIN->generic.title);
    TUI_DATA_WIN->generic.title = xstrdup (title);

    /* See how many registers must be displayed.  */
    nr_regs = 0;
    for (regnum = 0;
    regnum < gdbarch_num_regs (gdbarch)
    + gdbarch_num_pseudo_regs (gdbarch);
    regnum++)
    {
        const char *name;

        /* Must be in the group.  */
        if (!gdbarch_register_reggroup_p (gdbarch, regnum, group))
            continue;

        /* If the register name is empty, it is undefined for this
        processor, so don't display anything.  */
        name = gdbarch_register_name (gdbarch, regnum);
        if (name == 0 || *name == '\0')
            continue;

        nr_regs++;
    }

    if (display_info->regs_content_count > 0 && !refresh_values_only)
    {
        tui_free_data_content (display_info->regs_content,
        display_info->regs_content_count);
        display_info->regs_content_count = 0;
    }

    if (display_info->regs_content_count <= 0)
    {
        display_info->regs_content = tui_alloc_content (nr_regs, DATA_WIN);
        allocated_here = TRUE;
        refresh_values_only = FALSE;
    }

    if (display_info->regs_content != (tui_win_content) NULL)
    {
        if (!refresh_values_only || allocated_here)
        {
            TUI_DATA_WIN->generic.content = (void*) NULL;
            TUI_DATA_WIN->generic.content_size = 0;
            tui_add_content_elements (&TUI_DATA_WIN->generic, nr_regs);
            display_info->regs_content
            = (tui_win_content) TUI_DATA_WIN->generic.content;
            display_info->regs_content_count = nr_regs;
        }

        /* Now set the register names and values.  */
        pos = 0;
        for (regnum = 0;
                regnum < gdbarch_num_regs (gdbarch)
                + gdbarch_num_pseudo_regs (gdbarch);
                regnum++)
        {
            struct tui_gen_win_info *data_item_win;
            struct tui_data_element *data;
            const char *name;

            /* Must be in the group.  */
            if (!gdbarch_register_reggroup_p (gdbarch, regnum, group))
                continue;

            /* If the register name is empty, it is undefined for this
               processor, so don't display anything.  */
            name = gdbarch_register_name (gdbarch, regnum);
            if (name == 0 || *name == '\0')
                continue;

            data_item_win =
                &display_info->regs_content[pos]->which_element.data_window;
            data = &((struct tui_win_element *)
                     data_item_win->content[0])->which_element.data;
            if (data)
            {
                if (!refresh_values_only)
                {
                    data->item_no = regnum;
                    data->name = name;
                    data->highlight = FALSE;
                }
                tui_get_register (frame, data, regnum, 0);
            }
            pos++;
        }

        TUI_DATA_WIN->generic.content_size =
            display_info->regs_content_count + display_info->data_content_count;
        ret = TUI_SUCCESS;
    }

    return ret;
}
Esempio n. 9
0
static enum tui_status
tui_show_register_group (struct gdbarch *gdbarch, struct reggroup *group,
                         struct frame_info *frame, int refresh_values_only)
{
    enum tui_status ret = TUI_FAILURE;
    int nr_regs;
    int allocated_here = FALSE;
    int regnum, pos;
    char title[80];
    struct tui_data_info *display_info = &TUI_DATA_WIN->detail.data_display_info;

    /* Make a new title showing which group we display.  */
    snprintf (title, sizeof (title) - 1, "Register group: %s",
    reggroup_name (group));
    xfree (TUI_DATA_WIN->generic.title);
    TUI_DATA_WIN->generic.title = xstrdup (title);

    /* See how many registers must be displayed.  */
    nr_regs = 0;
    for (regnum = 0; regnum < NUM_REGS + NUM_PSEUDO_REGS; regnum++)
    {
        /* Must be in the group and have a name.  */
        if (gdbarch_register_reggroup_p (gdbarch, regnum, group)
        && gdbarch_register_name (gdbarch, regnum) != 0)
            nr_regs++;
    }

    if (display_info->regs_content_count > 0 && !refresh_values_only)
    {
        tui_free_data_content (display_info->regs_content,
        display_info->regs_content_count);
        display_info->regs_content_count = 0;
    }

    if (display_info->regs_content_count <= 0)
    {
        display_info->regs_content = tui_alloc_content (nr_regs, DATA_WIN);
        allocated_here = TRUE;
        refresh_values_only = FALSE;
    }

    if (display_info->regs_content != (tui_win_content) NULL)
    {
        if (!refresh_values_only || allocated_here)
        {
            TUI_DATA_WIN->generic.content = (void*) NULL;
            TUI_DATA_WIN->generic.content_size = 0;
            tui_add_content_elements (&TUI_DATA_WIN->generic, nr_regs);
            display_info->regs_content
            = (tui_win_content) TUI_DATA_WIN->generic.content;
            display_info->regs_content_count = nr_regs;
        }

        /* Now set the register names and values */
        pos = 0;
        for (regnum = 0; regnum < NUM_REGS + NUM_PSEUDO_REGS; regnum++)
        {
            struct tui_gen_win_info *data_item_win;
            struct tui_data_element *data;
            const char *name;

            if (!gdbarch_register_reggroup_p (gdbarch, regnum, group))
                continue;

            name = gdbarch_register_name (gdbarch, regnum);
            if (name == 0)
                continue;

            data_item_win =
                &display_info->regs_content[pos]->which_element.data_window;
            data =
                &((struct tui_win_element *) data_item_win->content[0])->which_element.data;
            if (data)
            {
                if (!refresh_values_only)
                {
                    data->item_no = regnum;
                    data->name = name;
                    data->highlight = FALSE;
                }
                if (data->value == (void*) NULL)
                    data->value = (void*) xmalloc (MAX_REGISTER_SIZE);

                tui_get_register (gdbarch, frame, data, regnum, 0);
            }
            pos++;
        }

        TUI_DATA_WIN->generic.content_size =
            display_info->regs_content_count + display_info->data_content_count;
        ret = TUI_SUCCESS;
    }

    return ret;
}