This is the mail archive of the
frysk@sources.redhat.com
mailing list for the frysk project.
Re: New method to get real length of register
- From: Mark Wielaard <mark at klomp dot org>
- To: Yao Qi <qiyaoltc at cn dot ibm dot com>
- Cc: frysk <frysk at sourceware dot org>, Tim Moore <timoore at redhat dot com>
- Date: Wed, 23 Aug 2006 14:39:30 +0200
- Subject: Re: New method to get real length of register
- References: <20060823100418.GA18719@GreenHouse.cn.ibm.com>
Hi,
On Wed, 2006-08-23 at 18:04 +0800, Yao Qi wrote:
> A new method getRealLength is added in Register, and mostly it is the
> same as getLength, and getRealLength is overridden if they are
> different.
It might be easier if you define an additional constructor for Register
that takes the realLenght and stores it in an instance field. That way
you don't have to define all these methods for each individual register,
which makes the code less readable imho. See attached for an example.
Cheers,
Mark
Index: frysk-core/frysk/proc/Register.java
===================================================================
RCS file: /cvs/frysk/frysk-core/frysk/proc/Register.java,v
retrieving revision 1.9
diff -u -r1.9 Register.java
--- frysk-core/frysk/proc/Register.java 16 Aug 2006 10:58:50 -0000 1.9
+++ frysk-core/frysk/proc/Register.java 23 Aug 2006 12:37:41 -0000
@@ -50,6 +50,7 @@
final int bank;
final int offset;
final int length;
+ final int realLength;
final String name;
// Does this really not exist somewhere else?
@@ -65,9 +66,15 @@
Register(int bank, int offset, int length, String name)
{
+ this(bank, offset, length, length, name);
+ }
+
+ Register(int bank, int offset, int length, int realLength, String name)
+ {
this.bank = bank;
this.offset = offset;
this.length = length;
+ this.realLength = realLength;
this.name = name;
}
@@ -197,6 +204,11 @@
return length;
}
+ public int getRealLength()
+ {
+ return realLength;
+ }
+
// void get(proc.Task task, byte[] bytes, int off, int len);
// void get(Task task, byte[] array);
}
Index: frysk-core/frysk/proc/IsaIA32.java
===================================================================
RCS file: /cvs/frysk/frysk-core/frysk/proc/IsaIA32.java,v
retrieving revision 1.3
diff -u -r1.3 IsaIA32.java
--- frysk-core/frysk/proc/IsaIA32.java 23 Aug 2006 04:04:19 -0000 1.3
+++ frysk-core/frysk/proc/IsaIA32.java 23 Aug 2006 12:37:41 -0000
@@ -56,6 +56,11 @@
{
super(0, wordOffset * 4, 4, name);
}
+
+ IA32Register(String name, int wordOffset, int realLength)
+ {
+ super(0, wordOffset * 4, 4, realLength, name);
+ }
}
private static final IA32Register[]
regDefs = { new IA32Register("eax", 6),
@@ -65,12 +70,12 @@
new IA32Register("esi", 3),
new IA32Register("edi", 4),
new IA32Register("ebp", 5),
- new IA32Register("cs", 13),
- new IA32Register("ds", 7),
- new IA32Register("es", 8),
- new IA32Register("fs", 9),
- new IA32Register("gs", 10),
- new IA32Register("ss", 16),
+ new IA32Register("cs", 13, 2),
+ new IA32Register("ds", 7, 2),
+ new IA32Register("es", 8, 2),
+ new IA32Register("fs", 9, 2),
+ new IA32Register("gs", 10, 2),
+ new IA32Register("ss", 16, 2),
new IA32Register("orig_eax", 11),
new IA32Register("eip", 12),
new IA32Register("efl", 14),