Ejemplo n.º 1
0
static void
mi_solib_loaded (struct so_list *solib)
{
  struct mi_interp *mi = top_level_interpreter_data ();
  struct ui_out *uiout = interp_ui_out (top_level_interpreter ());

  target_terminal_ours ();

  fprintf_unfiltered (mi->event_channel, "library-loaded");

  ui_out_redirect (uiout, mi->event_channel);

  ui_out_field_string (uiout, "id", solib->so_original_name);
  ui_out_field_string (uiout, "target-name", solib->so_original_name);
  ui_out_field_string (uiout, "host-name", solib->so_name);
  ui_out_field_int (uiout, "symbols-loaded", solib->symbols_loaded);
  if (!gdbarch_has_global_solist (target_gdbarch ()))
    {
      ui_out_field_fmt (uiout, "thread-group", "i%d", current_inferior ()->num);
    }

  ui_out_redirect (uiout, NULL);

  gdb_flush (mi->event_channel);
}
Ejemplo n.º 2
0
static void
mi_memory_changed (struct inferior *inferior, CORE_ADDR memaddr,
		   ssize_t len, const bfd_byte *myaddr)
{
  struct mi_interp *mi = top_level_interpreter_data ();
  struct ui_out *mi_uiout = interp_ui_out (top_level_interpreter ());
  struct obj_section *sec;

  if (mi_suppress_notification.memory)
    return;

  target_terminal_ours ();

  fprintf_unfiltered (mi->event_channel,
		      "memory-changed");

  ui_out_redirect (mi_uiout, mi->event_channel);

  ui_out_field_fmt (mi_uiout, "thread-group", "i%d", inferior->num);
  ui_out_field_core_addr (mi_uiout, "addr", target_gdbarch (), memaddr);
  ui_out_field_fmt (mi_uiout, "len", "%s", hex_string (len));

  /* Append 'type=code' into notification if MEMADDR falls in the range of
     sections contain code.  */
  sec = find_pc_section (memaddr);
  if (sec != NULL && sec->objfile != NULL)
    {
      flagword flags = bfd_get_section_flags (sec->objfile->obfd,
					      sec->the_bfd_section);

      if (flags & SEC_CODE)
	ui_out_field_string (mi_uiout, "type", "code");
    }

  ui_out_redirect (mi_uiout, NULL);

  gdb_flush (mi->event_channel);
}
Ejemplo n.º 3
0
static void
ui_out_field_uint (struct ui_out *uiout, const char *fld, unsigned int val)
{
  ui_out_field_fmt (uiout, fld, "%u", val);
}
Ejemplo n.º 4
0
void
print_command_lines (struct ui_out *uiout, struct command_line *cmd,
		     unsigned int depth)
{
  struct command_line *list;

  list = cmd;
  while (list)
    {
      if (depth)
	ui_out_spaces (uiout, 2 * depth);

      /* A simple command, print it and continue.  */
      if (list->control_type == simple_control)
	{
	  ui_out_field_string (uiout, NULL, list->line);
	  ui_out_text (uiout, "\n");
	  list = list->next;
	  continue;
	}

      /* loop_continue to jump to the start of a while loop, print it
         and continue. */
      if (list->control_type == continue_control)
	{
	  ui_out_field_string (uiout, NULL, "loop_continue");
	  ui_out_text (uiout, "\n");
	  list = list->next;
	  continue;
	}

      /* loop_break to break out of a while loop, print it and
	 continue.  */
      if (list->control_type == break_control)
	{
	  ui_out_field_string (uiout, NULL, "loop_break");
	  ui_out_text (uiout, "\n");
	  list = list->next;
	  continue;
	}

      /* A while command.  Recursively print its subcommands and
	 continue.  */
      if (list->control_type == while_control
	  || list->control_type == while_stepping_control)
	{
	  /* For while-stepping, the line includes the 'while-stepping'
	     token.  See comment in process_next_line for explanation.
	     Here, take care not print 'while-stepping' twice.  */
	  if (list->control_type == while_control)
	    ui_out_field_fmt (uiout, NULL, "while %s", list->line);
	  else
	    ui_out_field_string (uiout, NULL, list->line);
	  ui_out_text (uiout, "\n");
	  print_command_lines (uiout, *list->body_list, depth + 1);
	  if (depth)
	    ui_out_spaces (uiout, 2 * depth);
	  ui_out_field_string (uiout, NULL, "end");
	  ui_out_text (uiout, "\n");
	  list = list->next;
	  continue;
	}

      /* An if command.  Recursively print both arms before
	 continueing.  */
      if (list->control_type == if_control)
	{
	  ui_out_field_fmt (uiout, NULL, "if %s", list->line);
	  ui_out_text (uiout, "\n");
	  /* The true arm.  */
	  print_command_lines (uiout, list->body_list[0], depth + 1);

	  /* Show the false arm if it exists.  */
	  if (list->body_count == 2)
	    {
	      if (depth)
		ui_out_spaces (uiout, 2 * depth);
	      ui_out_field_string (uiout, NULL, "else");
	      ui_out_text (uiout, "\n");
	      print_command_lines (uiout, list->body_list[1], depth + 1);
	    }

	  if (depth)
	    ui_out_spaces (uiout, 2 * depth);
	  ui_out_field_string (uiout, NULL, "end");
	  ui_out_text (uiout, "\n");
	  list = list->next;
	  continue;
	}

      /* A commands command.  Print the breakpoint commands and
	 continue.  */
      if (list->control_type == commands_control)
	{
	  if (*(list->line))
	    ui_out_field_fmt (uiout, NULL, "commands %s", list->line);
	  else
	    ui_out_field_string (uiout, NULL, "commands");
	  ui_out_text (uiout, "\n");
	  print_command_lines (uiout, *list->body_list, depth + 1);
	  if (depth)
	    ui_out_spaces (uiout, 2 * depth);
	  ui_out_field_string (uiout, NULL, "end");
	  ui_out_text (uiout, "\n");
	  list = list->next;
	  continue;
	}

      if (list->control_type == python_control)
	{
	  ui_out_field_string (uiout, NULL, "python");
	  ui_out_text (uiout, "\n");
	  /* Don't indent python code at all.  */
	  print_command_lines (uiout, *list->body_list, 0);
	  if (depth)
	    ui_out_spaces (uiout, 2 * depth);
	  ui_out_field_string (uiout, NULL, "end");
	  ui_out_text (uiout, "\n");
	  list = list->next;
	  continue;
	}

      /* Ignore illegal command type and try next.  */
      list = list->next;
    }				/* while (list) */
}