Beispiel #1
0
static void
tui_handle_xdb_layout (struct tui_layout_def *layout_def)
{
  if (layout_def->split)
    {
      tui_set_layout (SRC_DISASSEM_COMMAND, TUI_UNDEFINED_REGS);
      tui_set_win_focus_to (tui_win_list[layout_def->display_mode]);
    }
  else
    {
      if (layout_def->display_mode == SRC_WIN)
	tui_set_layout (SRC_COMMAND, TUI_UNDEFINED_REGS);
      else
	tui_set_layout (DISASSEM_DATA_COMMAND, layout_def->regs_display_type);
    }
}
Beispiel #2
0
/* Function to display source in the source/asm window.  This function
   shows the source as specified by the horizontal offset.  */
void
tui_update_source_window_as_is (struct tui_win_info *win_info, 
				struct gdbarch *gdbarch,
				struct symtab *s,
				struct tui_line_or_address line_or_addr, 
				int noerror)
{
  enum tui_status ret;

  if (win_info->generic.type == SRC_WIN)
    ret = tui_set_source_content (s, line_or_addr.u.line_no, noerror);
  else
    ret = tui_set_disassem_content (gdbarch, line_or_addr.u.addr);

  if (ret == TUI_FAILURE)
    {
      tui_clear_source_content (win_info, EMPTY_SOURCE_PROMPT);
      tui_clear_exec_info_content (win_info);
    }
  else
    {
      tui_update_breakpoint_info (win_info, 0);
      tui_show_source_content (win_info);
      tui_update_exec_info (win_info);
      if (win_info->generic.type == SRC_WIN)
	{
	  struct symtab_and_line sal;
	  
	  init_sal (&sal);
	  sal.line = line_or_addr.u.line_no +
	    (win_info->generic.content_size - 2);
	  sal.symtab = s;
	  sal.pspace = SYMTAB_PSPACE (s);
	  set_current_source_symtab_and_line (&sal);
	  /* If the focus was in the asm win, put it in the src win if
	     we don't have a split layout.  */
	  if (tui_win_with_focus () == TUI_DISASM_WIN
	      && tui_current_layout () != SRC_DISASSEM_COMMAND)
	    tui_set_win_focus_to (TUI_SRC_WIN);
	}
    }


  return;
}
Beispiel #3
0
Datei: tui.c Projekt: 0mp/freebsd
/* TUI readline command.
   Switch the active window to give the focus to a next window.  */
static int
tui_rl_other_window (int count, int key)
{
  struct tui_win_info * win_info;

  if (!tui_active)
    tui_rl_switch_mode (0/*notused*/, 0/*notused*/);

  win_info = tui_next_win (tui_win_with_focus ());
  if (win_info)
    {
      tui_set_win_focus_to (win_info);
      if (TUI_DATA_WIN && TUI_DATA_WIN->generic.is_visible)
        tui_refresh_data_win ();
      keypad (TUI_CMD_WIN->generic.handle, (win_info != TUI_CMD_WIN));
    }
  return 0;
}
Beispiel #4
0
/* Function to display the disassembly window with disassembled code.   */
void
tui_show_disassem (CORE_ADDR start_addr)
{
  struct symtab *s = find_pc_symtab (start_addr);
  struct tui_win_info * win_with_focus = tui_win_with_focus ();
  union tui_line_or_address val;

  val.addr = start_addr;
  tui_add_win_to_layout (DISASSEM_WIN);
  tui_update_source_window (TUI_DISASM_WIN, s, val, FALSE);
  /*
     ** if the focus was in the src win, put it in the asm win, if the
     ** source view isn't split
   */
  if (tui_current_layout () != SRC_DISASSEM_COMMAND && win_with_focus == TUI_SRC_WIN)
    tui_set_win_focus_to (TUI_DISASM_WIN);

  return;
}
Beispiel #5
0
Datei: tui.c Projekt: 0mp/freebsd
/* Enter in the tui mode (curses).
   When in normal mode, it installs the tui hooks in gdb, redirects
   the gdb output, configures the readline to work in tui mode.
   When in curses mode, it does nothing.  */
void
tui_enable (void)
{
  if (tui_active)
    return;

  /* To avoid to initialize curses when gdb starts, there is a defered
     curses initialization.  This initialization is made only once
     and the first time the curses mode is entered.  */
  if (tui_finish_init)
    {
      WINDOW *w;

      w = initscr ();
  
      cbreak ();
      noecho ();
      /*timeout (1);*/
      nodelay(w, FALSE);
      nl();
      keypad (w, TRUE);
      rl_initialize ();
      tui_set_term_height_to (LINES);
      tui_set_term_width_to (COLS);
      def_prog_mode ();

      tui_show_frame_info (0);
      tui_set_layout (SRC_COMMAND, TUI_UNDEFINED_REGS);
      tui_set_win_focus_to (TUI_SRC_WIN);
      keypad (TUI_CMD_WIN->generic.handle, TRUE);
      wrefresh (TUI_CMD_WIN->generic.handle);
      tui_finish_init = 0;
    }
  else
    {
     /* Save the current gdb setting of the terminal.
        Curses will restore this state when endwin() is called.  */
     def_shell_mode ();
     clearok (stdscr, TRUE);
   }

  /* Install the TUI specific hooks.  */
  tui_install_hooks ();
  rl_startup_hook = tui_rl_startup_hook;

  tui_update_variables ();
  
  tui_setup_io (1);

  tui_active = 1;
  if (deprecated_selected_frame)
     tui_show_frame_info (deprecated_selected_frame);

  /* Restore TUI keymap.  */
  tui_set_key_mode (tui_current_key_mode);
  tui_refresh_all_win ();

  /* Update gdb's knowledge of its terminal.  */
  target_terminal_save_ours ();
  tui_update_gdb_sizes ();
}
Beispiel #6
0
/* Function to set the layout to SRC_COMMAND, DISASSEM_COMMAND,
   SRC_DISASSEM_COMMAND, SRC_DATA_COMMAND, or DISASSEM_DATA_COMMAND.
   If the layout is SRC_DATA_COMMAND, DISASSEM_DATA_COMMAND, or
   UNDEFINED_LAYOUT, then the data window is populated according to
   regs_display_type.  */
enum tui_status
tui_set_layout (enum tui_layout_type layout_type,
		enum tui_register_display_type regs_display_type)
{
  enum tui_status status = TUI_SUCCESS;

  if (layout_type != UNDEFINED_LAYOUT 
      || regs_display_type != TUI_UNDEFINED_REGS)
    {
      enum tui_layout_type cur_layout = tui_current_layout (),
	new_layout = UNDEFINED_LAYOUT;
      int regs_populate = FALSE;
      struct gdbarch *gdbarch;
      CORE_ADDR addr;
      struct tui_win_info *win_with_focus = tui_win_with_focus ();
      struct tui_layout_def *layout_def = tui_layout_def ();

      extract_display_start_addr (&gdbarch, &addr);

      if (layout_type == UNDEFINED_LAYOUT
	  && regs_display_type != TUI_UNDEFINED_REGS)
	{
	  if (cur_layout == SRC_DISASSEM_COMMAND)
	    new_layout = DISASSEM_DATA_COMMAND;
	  else if (cur_layout == SRC_COMMAND 
		   || cur_layout == SRC_DATA_COMMAND)
	    new_layout = SRC_DATA_COMMAND;
	  else if (cur_layout == DISASSEM_COMMAND 
		   || cur_layout == DISASSEM_DATA_COMMAND)
	    new_layout = DISASSEM_DATA_COMMAND;
	}
      else
	new_layout = layout_type;

      regs_populate = (new_layout == SRC_DATA_COMMAND 
		       || new_layout == DISASSEM_DATA_COMMAND 
		       || regs_display_type != TUI_UNDEFINED_REGS);
      if (new_layout != cur_layout
	  || regs_display_type != TUI_UNDEFINED_REGS)
	{
	  if (new_layout != cur_layout)
	    {
	      show_layout (new_layout);

	      /* Now determine where focus should be.  */
	      if (win_with_focus != TUI_CMD_WIN)
		{
		  switch (new_layout)
		    {
		    case SRC_COMMAND:
		      tui_set_win_focus_to (TUI_SRC_WIN);
		      layout_def->display_mode = SRC_WIN;
		      layout_def->split = FALSE;
		      break;
		    case DISASSEM_COMMAND:
		      /* The previous layout was not showing code.
		         This can happen if there is no source
		         available:

		         1. if the source file is in another dir OR
		         2. if target was compiled without -g
		         We still want to show the assembly though!  */

		      tui_get_begin_asm_address (&gdbarch, &addr);
		      tui_set_win_focus_to (TUI_DISASM_WIN);
		      layout_def->display_mode = DISASSEM_WIN;
		      layout_def->split = FALSE;
		      break;
		    case SRC_DISASSEM_COMMAND:
		      /* The previous layout was not showing code.
		         This can happen if there is no source
		         available:

		         1. if the source file is in another dir OR
		         2. if target was compiled without -g
		         We still want to show the assembly though!  */

		      tui_get_begin_asm_address (&gdbarch, &addr);
		      if (win_with_focus == TUI_SRC_WIN)
			tui_set_win_focus_to (TUI_SRC_WIN);
		      else
			tui_set_win_focus_to (TUI_DISASM_WIN);
		      layout_def->split = TRUE;
		      break;
		    case SRC_DATA_COMMAND:
		      if (win_with_focus != TUI_DATA_WIN)
			tui_set_win_focus_to (TUI_SRC_WIN);
		      else
			tui_set_win_focus_to (TUI_DATA_WIN);
		      layout_def->display_mode = SRC_WIN;
		      layout_def->split = FALSE;
		      break;
		    case DISASSEM_DATA_COMMAND:
		      /* The previous layout was not showing code.
		         This can happen if there is no source
		         available:

			 1. if the source file is in another dir OR
		         2. if target was compiled without -g
		         We still want to show the assembly though!  */

		      tui_get_begin_asm_address (&gdbarch, &addr);
		      if (win_with_focus != TUI_DATA_WIN)
			tui_set_win_focus_to (TUI_DISASM_WIN);
		      else
			tui_set_win_focus_to (TUI_DATA_WIN);
		      layout_def->display_mode = DISASSEM_WIN;
		      layout_def->split = FALSE;
		      break;
		    default:
		      break;
		    }
		}
	      /*
	       * Now update the window content.
	       */
	      if (!regs_populate 
		  && (new_layout == SRC_DATA_COMMAND 
		      || new_layout == DISASSEM_DATA_COMMAND))
		tui_display_all_data ();

	      tui_update_source_windows_with_addr (gdbarch, addr);
	    }
	  if (regs_populate)
	    {
              tui_show_registers (TUI_DATA_WIN->detail.data_display_info.current_group);
	    }
	}
    }
  else
    status = TUI_FAILURE;

  return status;
}