This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

TUI's asm window, vertical scrolling


Hi,

TUI's assembly layout window's vertical scroll quite broken, in usability terms.

- there's no way to scroll a line (instruction) at a time.  It scrolls by some
  weird amount.  Hitting UP, and DOWN doesn't bring you to the same place.

- related to that, up / down behaves the same as page_up / page_down, which
  is kind of a waste.  In contrast, the source window behaves
  naturally (up/down scrolls one line, page_up/page_down scroll, a page), as
  one would expect.

- If the inferior isn't running yet, there's no way to scroll in the assembly
  view, as you get an error claiming:

  >gdb file
  ...
  (gdb) layout asm
  <hit up, down, left, or right, and you get>
  (gdb) No registers.

This patch, that I'm about to check in, fixes these issues.  Now, up/down behaves as
expected, and page up/down too.  You can now scroll in asm view, even if the inferior
isn't running yet.

Based on IRC sampling, there aren't many gdb developers using the TUI (only two
that I know of, and I'm one of those).  If you're a TUI user,
please test this out, and let me know if something isn't right for you.

One thing to note about the patch: tui_update_source_window_as_is only cares about the
symtab in SRC_WIN type windows.  Switching on the type is ugly, but that's how
things are done throughout the codebase --- the tui sourcebase is screaming for
better OO, but that'll be for a rainier day...  I couldn't find a case where we
could reach the get_selected_frame calls with window type SRC_WIN, and target_has_stack
false, so this looked better, than checking against target_has_stack.

-- 
Pedro Alves
2009-01-18  Pedro Alves  <pedro@codesourcery.com>

	* tui/tui-disasm.c (tui_vertical_disassem_scroll): Scroll one line
	at a time, times NUM_TO_SCROLL.
	* tui/tui-winsource.c (tui_horizontal_source_scroll): Don't try to
	fetch the selected frame if there is no stack.

---
 gdb/tui/tui-disasm.c    |   15 ++++-----------
 gdb/tui/tui-winsource.c |   15 +++++++++------
 2 files changed, 13 insertions(+), 17 deletions(-)

Index: src/gdb/tui/tui-disasm.c
===================================================================
--- src.orig/gdb/tui/tui-disasm.c	2009-01-18 20:53:04.000000000 +0000
+++ src/gdb/tui/tui-disasm.c	2009-01-18 20:56:32.000000000 +0000
@@ -379,24 +379,17 @@ tui_vertical_disassem_scroll (enum tui_s
     {
       CORE_ADDR pc;
       tui_win_content content;
-      struct symtab *s;
       struct tui_line_or_address val;
-      int max_lines, dir;
-      struct symtab_and_line cursal = get_current_source_symtab_and_line ();
+      int dir;
 
       content = (tui_win_content) TUI_DISASM_WIN->generic.content;
-      if (cursal.symtab == (struct symtab *) NULL)
-	s = find_pc_symtab (get_frame_pc (get_selected_frame (NULL)));
-      else
-	s = cursal.symtab;
 
-      /* Account for hilite.  */
-      max_lines = TUI_DISASM_WIN->generic.height - 2;
       pc = content[0]->which_element.source.line_or_addr.u.addr;
-      dir = (scroll_direction == FORWARD_SCROLL) ? max_lines : - max_lines;
+      num_to_scroll++;
+      dir = (scroll_direction == FORWARD_SCROLL) ? num_to_scroll : -num_to_scroll;
 
       val.loa = LOA_ADDRESS;
       val.u.addr = tui_find_disassembly_address (pc, dir);
-      tui_update_source_window_as_is (TUI_DISASM_WIN, s, val, FALSE);
+      tui_update_source_window_as_is (TUI_DISASM_WIN, NULL, val, FALSE);
     }
 }
Index: src/gdb/tui/tui-winsource.c
===================================================================
--- src.orig/gdb/tui/tui-winsource.c	2009-01-18 20:53:04.000000000 +0000
+++ src/gdb/tui/tui-winsource.c	2009-01-18 21:02:44.000000000 +0000
@@ -312,13 +312,16 @@ tui_horizontal_source_scroll (struct tui
   if (win_info->generic.content != NULL)
     {
       int offset;
-      struct symtab *s;
-      struct symtab_and_line cursal = get_current_source_symtab_and_line ();
+      struct symtab *s = NULL;
 
-      if (cursal.symtab == (struct symtab *) NULL)
-	s = find_pc_symtab (get_frame_pc (get_selected_frame (NULL)));
-      else
-	s = cursal.symtab;
+      if (win_info->generic.type == SRC_WIN)
+	{
+	  struct symtab_and_line cursal = get_current_source_symtab_and_line ();
+	  if (cursal.symtab == NULL)
+	    s = find_pc_symtab (get_frame_pc (get_selected_frame (NULL)));
+	  else
+	    s = cursal.symtab;
+	}
 
       if (direction == LEFT_SCROLL)
 	offset = win_info->detail.source_info.horizontal_offset + num_to_scroll;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]