public inbox for frysk@sourceware.org
 help / color / mirror / Atom feed
From: Zhao Shujing <pearly.zhao@oracle.com>
To: Frysk Mailing List <frysk@sourceware.org>
Cc: Kris Van Hees <kris.van.hees@oracle.com>,
	        Andrew Cagney <cagney@redhat.com>
Subject: [patch] Fix bugs of memory window
Date: Thu, 30 Aug 2007 03:51:00 -0000	[thread overview]
Message-ID: <1188446167.7327.22.camel@linux-pzhao.site> (raw)

[-- Attachment #1: Type: text/plain, Size: 380 bytes --]

Hi,

This patch is to fix bug #4617 and other bugs of memory window.
- Fixed bug converting to bin and hex when memory value is negative
number.
- Fixed bug to get octal number by convert from hex.
- Setting the font to fixed-width font "monospace 10"
- Adding leading zero for all of bin, oct and hex.
- Adding prefix zero to octal number.

Any suggestions are welcomed

Pearly


[-- Attachment #2: Type: text/x-patch, Size: 3322 bytes --]

Index: MemoryWindow.java
===================================================================
RCS file: /cvs/frysk/frysk-gui/frysk/gui/memory/MemoryWindow.java,v
retrieving revision 1.44
diff -u -r1.44 MemoryWindow.java
--- MemoryWindow.java	28 Aug 2007 06:05:19 -0000	1.44
+++ MemoryWindow.java	30 Aug 2007 03:35:59 -0000
@@ -53,6 +53,7 @@
 import org.gnu.gtk.Button;
 import org.gnu.gtk.CellRenderer;
 import org.gnu.gtk.CellRendererText;
+import org.gnu.pango.FontDescription;
 import org.gnu.gtk.DataColumn;
 import org.gnu.gtk.DataColumnDouble;
 import org.gnu.gtk.DataColumnObject;
@@ -325,6 +326,8 @@
     this.bitsCombo.setActive(currentFormat + 1);
 
     this.memoryView = (TreeView) this.glade.getWidget("memoryView");
+    FontDescription fontDesc = new FontDescription("monospace 10");
+    memoryView.setFont(fontDesc);
 
     this.bitsCombo.showAll();
     this.diss = new Disassembler(myTask.getMemory());
@@ -652,10 +655,16 @@
           {
             for (int i = 0; i < b.length; i++)
               {
-                bin = bin + Integer.toBinaryString(b[i] & 0xff);
-                oct = oct + Integer.toOctalString(b[i] & 0xff);
+                String str = Integer.toBinaryString(b[i] & 0xff);
+                while (str.length() < 8)
+                    str = "0"+str;
+                bin = bin + str;
                 hex = hex + Integer.toHexString(b[i] & 0xff);
+                if ((b[i] & 0xff)==0)
+                    hex = hex + "0";
               }
+            BigInteger bihex = new BigInteger(hex, 16);
+            oct = bihex.toString(8);
           }
         else
           {
@@ -668,10 +677,24 @@
         int diff = bin.length() % BYTE_BITS;
         if (diff != 0)
           bin = padBytes(bin, false, diff);
+        int length = (int)Math.pow(2, currentFormat + 3);
+            
+        while (bin.length() < length)
+        {
+            bin = "0" + bin;            
+        }
+        while (oct.length() < (length/3 + 1))
+        {
+            oct = "0" + oct;
+        }      
+        while (hex.length() < length/4 )
+        {
+            hex = "0" + hex;
+        }            
 
         /* Little endian first */
         this.model.setValue(iter, (DataColumnString) cols[1], bin);
-        this.model.setValue(iter, (DataColumnString) cols[3], oct);
+        this.model.setValue(iter, (DataColumnString) cols[3], "0"+oct);
         this.model.setValue(iter, (DataColumnString) cols[5], dec);
         this.model.setValue(iter, (DataColumnString) cols[7], "0x" + hex);
 
@@ -687,9 +710,21 @@
           dec = bi.toString(10);
         else
           dec = bii.toString(10);
-
+        
+        while (bin2.length() < length)
+        {
+            bin2 = "0" + bin2;            
+        }
+        while (oct.length() < (length/3 + 1))
+        {
+            oct = "0" + oct;
+        }      
+        while (hex.length() < length/4 )
+        {
+            hex = "0" + hex;
+        }
         this.model.setValue(iter, (DataColumnString) cols[2], bin2);
-        this.model.setValue(iter, (DataColumnString) cols[4], oct);
+        this.model.setValue(iter, (DataColumnString) cols[4], "0"+oct);
         this.model.setValue(iter, (DataColumnString) cols[6], dec);
         this.model.setValue(iter, (DataColumnString) cols[8], "0x" + hex);
 

             reply	other threads:[~2007-08-30  3:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-30  3:51 Zhao Shujing [this message]
2007-08-30 13:59 ` Andrew Cagney
2007-08-31  6:30   ` Zhao Shujing
  -- strict thread matches above, loose matches on Subject: below --
2007-08-10  9:26 [patch] fix " Zhao Shujing

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1188446167.7327.22.camel@linux-pzhao.site \
    --to=pearly.zhao@oracle.com \
    --cc=cagney@redhat.com \
    --cc=frysk@sourceware.org \
    --cc=kris.van.hees@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).