* [patch] Fix bugs of memory window
@ 2007-08-30 3:51 Zhao Shujing
2007-08-30 13:59 ` Andrew Cagney
0 siblings, 1 reply; 4+ messages in thread
From: Zhao Shujing @ 2007-08-30 3:51 UTC (permalink / raw)
To: Frysk Mailing List; +Cc: Kris Van Hees, Andrew Cagney
[-- 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);
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch] Fix bugs of memory window
2007-08-30 3:51 [patch] Fix bugs of memory window Zhao Shujing
@ 2007-08-30 13:59 ` Andrew Cagney
2007-08-31 6:30 ` Zhao Shujing
0 siblings, 1 reply; 4+ messages in thread
From: Andrew Cagney @ 2007-08-30 13:59 UTC (permalink / raw)
To: pearly.zhao; +Cc: Frysk Mailing List
Zhao Shujing wrote:
> 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, perhaps check the constructor <<new BigInteger(int,byte[])>> as
in <<new BigInteger(1,b)>> it will convert the big-endian byte array
directly into an unsigned BigInteger letting you use more of:
> + oct = bihex.toString(8);
and, beyond needing to zero-pad, may make things even simpler.
Andrew
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch] Fix bugs of memory window
2007-08-30 13:59 ` Andrew Cagney
@ 2007-08-31 6:30 ` Zhao Shujing
0 siblings, 0 replies; 4+ messages in thread
From: Zhao Shujing @ 2007-08-31 6:30 UTC (permalink / raw)
To: Andrew Cagney; +Cc: Frysk Mailing List
[-- Attachment #1: Type: text/plain, Size: 875 bytes --]
Thanks Andrew.
The patch is updated.
On Thu, 2007-08-30 at 09:59 -0400, Andrew Cagney wrote:
> Zhao Shujing wrote:
> > 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, perhaps check the constructor <<new BigInteger(int,byte[])>> as
> in <<new BigInteger(1,b)>> it will convert the big-endian byte array
> directly into an unsigned BigInteger letting you use more of:
>
> > + oct = bihex.toString(8);
> and, beyond needing to zero-pad, may make things even simpler.
>
> Andrew
>
[-- Attachment #2: memwin0830.patch --]
[-- Type: text/x-patch, Size: 3294 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 31 Aug 2007 06:25:25 -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());
@@ -649,29 +652,33 @@
String dec = "";
if (bi.signum() < 0)
- {
- for (int i = 0; i < b.length; i++)
- {
- bin = bin + Integer.toBinaryString(b[i] & 0xff);
- oct = oct + Integer.toOctalString(b[i] & 0xff);
- hex = hex + Integer.toHexString(b[i] & 0xff);
- }
- }
- else
- {
- bin = bi.toString(2);
- oct = bi.toString(8);
- hex = bi.toString(16);
- }
+ bi = new BigInteger(1, b);
+ bin = bi.toString(2);
+ oct = bi.toString(8);
+ hex = bi.toString(16);
dec = bi.toString(10);
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 +694,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);
^ permalink raw reply [flat|nested] 4+ messages in thread
* [patch] fix bugs of memory window
@ 2007-08-10 9:26 Zhao Shujing
0 siblings, 0 replies; 4+ messages in thread
From: Zhao Shujing @ 2007-08-10 9:26 UTC (permalink / raw)
To: Frysk Mailing List
[-- Attachment #1: Type: text/plain, Size: 1055 bytes --]
Hi,
Can anyone help me to review the attached patch? Thanks. I have tested
at x86_64/FC7.
The patch is mainly to fix the following bugs of memory window:
- fromSpin.setValue would invoke the fromSpin entryEvent again, so the
handleFromSpin is called twice. It happens at toSpin too.
- Prepend row by order from low to high when decrease fromBox.
- removeRow would make iter to set to the next valid row,
iter.getNextIter is not needed after removeRow.
The above-mentioned are happened at disassembly window too. But only
fixing these bugs can not make the window display correctly yet. So
there is no patch for disassembly window this time.
BTW: I'm touching GUI test and the disassembly window and memory window
refactoring. Any suggestions are welcomed.
2007-08-10 Zhao Shujing <pearly.zhao@oracle.com>
*memory/MemoryWindow.java (fromBox.entryEvent): Use
fromSpin.setValue to invoke fromSpin entryEvent.
(toBox.entryEvent): Ditto.
(handleToSpin): Ditto.
(handleFromSpin): Prepend row by the order from high to low.
Thanks
Pearly
[-- Attachment #2: Type: text/x-patch, Size: 2596 bytes --]
Index: frysk-gui/frysk/gui/memory/MemoryWindow.java
===================================================================
RCS file: /cvs/frysk/frysk-gui/frysk/gui/memory/MemoryWindow.java,v
retrieving revision 1.42
diff -u -r1.42 MemoryWindow.java
--- frysk-gui/frysk/gui/memory/MemoryWindow.java 27 Jul 2007 21:07:22 -0000 1.42
+++ frysk-gui/frysk/gui/memory/MemoryWindow.java 10 Aug 2007 08:07:48 -0000
@@ -484,8 +484,15 @@
try
{
double d = (double) Long.parseLong(str, 16);
- //fromSpin.setValue(d);
- handleFromSpin(d);
+ if (d > lastKnownTo)
+ {
+ if (lastKnownTo == lastKnownFrom)
+ handleFromSpin(lastKnownTo);
+ else
+ fromSpin.setValue(lastKnownTo);
+ }
+ else
+ fromSpin.setValue(d);
}
catch (NumberFormatException nfe)
{
@@ -508,8 +515,15 @@
try
{
double d = (double) Long.parseLong(str, 16);
- //toSpin.setValue(d);
- handleToSpin(d);
+ if (d < lastKnownFrom)
+ {
+ if (lastKnownFrom == lastKnownTo)
+ handleToSpin(lastKnownFrom);
+ else
+ toSpin.setValue(lastKnownFrom);
+ }
+ else
+ toSpin.setValue(d);
}
catch (NumberFormatException nfe)
{
@@ -877,12 +891,11 @@
for (long i = (long) lastKnownFrom; i < (long) val; i++)
{
model.removeRow(iter);
- iter = iter.getNextIter();
}
}
else
{
- for (long i = (long) val; i < lastKnownFrom; i++)
+ for (long i = (long) lastKnownFrom - 1; i >= (long) val; i--)
{
TreeIter newRow = model.prependRow();
rowAppend(i, newRow);
@@ -903,7 +916,7 @@
public void handleToSpin (double val)
{
- if (this.model.getFirstIter() == null || val == this.lastKnownTo)
+ if (this.model.getFirstIter() == null)
return;
if (val < this.lastKnownFrom)
@@ -918,8 +931,6 @@
{
for (long i = (long) lastKnownTo + 1; i < val + 1; i++)
rowAppend(i, null);
-
- this.lastKnownTo = val;
}
else
{
@@ -931,7 +942,7 @@
}
this.toBox.setText(Long.toHexString((long) val));
- this.toSpin.setValue(val);
+ this.lastKnownTo = val;
refreshList();
}
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-08-31 6:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-30 3:51 [patch] Fix bugs of memory window Zhao Shujing
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
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).