This is the mail archive of the gdb-patches@sources.redhat.com 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]

[PATCH]: Fix tuiGetLowDisassemblyAddress


Hi!

The tuiGetLowDisassemblyAddress function computes the starting address
of the disassembly window to center the window arround the current pc.
It was assuming (like the scrolling stuff) that each instruction is 4-bytes wide.

This patch fixes that by using the same mechanism as the backward scroll.

Committed on mainline.

	Stephane

2002-08-29  Stephane Carrez  <stcarrez@nerim.fr>

	* tui.c (tuiGetLowDisassemblyAddress): Moved from here.
	* tuiDisassem.c (tuiGetLowDisassemblyAddress): To here, and use
	tui_find_disassembly_address to find the starting address of
	disassemble window.
Index: tui.c
===================================================================
RCS file: /cvs/src/src/gdb/tui/tui.c,v
retrieving revision 1.22
diff -u -p -r1.22 tui.c
--- tui.c	26 Aug 2002 19:35:37 -0000	1.22
+++ tui.c	28 Aug 2002 20:22:13 -0000
@@ -311,31 +311,6 @@ tuiFree (char *ptr)
     }
 }
 
-/* Determine what the low address will be to display in the TUI's
-   disassembly window.  This may or may not be the same as the
-   low address input.  */
-CORE_ADDR
-tuiGetLowDisassemblyAddress (CORE_ADDR low, CORE_ADDR pc)
-{
-  int line;
-  CORE_ADDR newLow;
-
-  /* Determine where to start the disassembly so that the pc is about in the
-     middle of the viewport.  */
-  for (line = 0, newLow = pc;
-       (newLow > low &&
-	line < (tuiDefaultWinViewportHeight (DISASSEM_WIN,
-					     DISASSEM_COMMAND) / 2));)
-    {
-      bfd_byte buffer[4];
-
-      newLow -= sizeof (bfd_getb32 (buffer));
-      line++;
-    }
-
-  return newLow;
-}
-
 void
 strcat_to_buf (char *buf, int buflen, const char *itemToAdd)
 {
Index: tuiDisassem.c
===================================================================
RCS file: /cvs/src/src/gdb/tui/tuiDisassem.c,v
retrieving revision 1.15
diff -u -p -r1.15 tuiDisassem.c
--- tuiDisassem.c	27 Aug 2002 21:59:49 -0000	1.15
+++ tuiDisassem.c	28 Aug 2002 20:22:13 -0000
@@ -382,6 +382,24 @@ tuiGetBeginAsmAddress (void)
   return addr;
 }				/* tuiGetBeginAsmAddress */
 
+/* Determine what the low address will be to display in the TUI's
+   disassembly window.  This may or may not be the same as the
+   low address input.  */
+CORE_ADDR
+tuiGetLowDisassemblyAddress (CORE_ADDR low, CORE_ADDR pc)
+{
+  int pos;
+
+  /* Determine where to start the disassembly so that the pc is about in the
+     middle of the viewport.  */
+  pos = tuiDefaultWinViewportHeight (DISASSEM_WIN, DISASSEM_COMMAND) / 2;
+  pc = tui_find_disassembly_address (pc, -pos);
+
+  if (pc < low)
+    pc = low;
+  return pc;
+}
+
 /*
    ** tuiVerticalDisassemScroll().
    **      Scroll the disassembly forward or backward vertically

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