From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9236 invoked by alias); 20 Aug 2007 09:07:19 -0000 Received: (qmail 8758 invoked by uid 22791); 20 Aug 2007 09:07:12 -0000 X-Spam-Status: No, hits=-0.8 required=5.0 tests=AWL,BAYES_00,DK_POLICY_SIGNSOME X-Spam-Check-By: sourceware.org Received: from rgminet01.oracle.com (HELO rgminet01.oracle.com) (148.87.113.118) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 20 Aug 2007 09:07:07 +0000 Received: from rgmgw2.us.oracle.com (rgmgw2.us.oracle.com [138.1.186.111]) by rgminet01.oracle.com (Switch-3.2.4/Switch-3.1.6) with ESMTP id l7K973mV002050 for ; Mon, 20 Aug 2007 03:07:04 -0600 Received: from dhcp-beijing-cdc-10-182-121-20.cn.oracle.com (dhcp-beijing-cdc-10-182-121-20.cn.oracle.com [10.182.121.20]) by rgmgw2.us.oracle.com (Switch-3.2.4/Switch-3.2.4) with ESMTP id l7K971eQ021550 for ; Mon, 20 Aug 2007 03:07:02 -0600 Subject: Re: [patch] disassembly window From: Zhao Shujing Reply-To: pearly.zhao@oracle.com To: frysk@sourceware.org In-Reply-To: <1187340639.3861.47.camel@linux-pzhao.site> References: <1187340639.3861.47.camel@linux-pzhao.site> Content-Type: multipart/mixed; boundary="=-VTDxcWnfhUgbTiqrVpj5" Organization: Oracle Date: Mon, 20 Aug 2007 09:07:00 -0000 Message-Id: <1187601068.25862.16.camel@linux-pzhao.site> Mime-Version: 1.0 X-Mailer: Evolution 2.6.0 X-Brightmail-Tracker: AAAAAQAAAAI= X-Brightmail-Tracker: AAAAAA== X-Whitelist: TRUE X-Whitelist: TRUE X-Virus-Checked: Checked by ClamAV on sourceware.org X-IsSubscribed: yes Mailing-List: contact frysk-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: frysk-owner@sourceware.org X-SW-Source: 2007-q3/txt/msg00308.txt.bz2 --=-VTDxcWnfhUgbTiqrVpj5 Content-Type: text/plain Content-Transfer-Encoding: 7bit Content-length: 1205 Sorry, I make a mistake with fromBox.entryEvent to use the same code with toBox.entryEvent at the last patch. It is fixed at this one. On Fri, 2007-08-17 at 16:50 +0800, Zhao Shujing wrote: > Hi > > This patch is to fix bug #4932 and other bugs of disassembly window. > rowPrepend is added to prepend rows by calculating memory information > like rowAppend. Because the methods that are provided by class > Disassembler, disassembleInstructions and > disassembleInstructionsStartEnd, can only read the instructions that are > following some address, rowPrepend have to use two while execution > control to read the instructions that are preceding some address. > Any suggestions are welcomed. > > --ChangeLog-- > 2007-08-17 Zhao Shujing > > *disassembler/DisassemblyWindow.java: fix bug #4932 > (fromBox.entryEvent): Use fromSpin.setValue to invoke fromSpin > entryEvent. > (toBox.entryEvent): Ditto. > (refreshList): Change to get next instruction after finishing model > setValue. > (rowPrepend): Added. > (handleFromSpin): Prepend rows provided by rowPrepend and remove > redundant instructions according to the change of memory address. > > > Cheers > Pearly --=-VTDxcWnfhUgbTiqrVpj5 Content-Description: Content-Disposition: inline; filename=disassemblewin.patch Content-Type: text/x-patch; charset=utf-8 Content-Transfer-Encoding: 7bit Content-length: 6920 Index: frysk/gui/disassembler/DisassemblyWindow.java =================================================================== RCS file: /cvs/frysk/frysk-gui/frysk/gui/disassembler/DisassemblyWindow.java,v retrieving revision 1.29 diff -u -r1.29 DisassemblyWindow.java --- frysk/gui/disassembler/DisassemblyWindow.java 27 Jul 2007 21:07:22 -0000 1.29 +++ frysk/gui/disassembler/DisassemblyWindow.java 20 Aug 2007 08:56:51 -0000 @@ -44,6 +44,7 @@ import java.util.prefs.Preferences; import java.util.List; import java.util.Iterator; +import java.util.ListIterator; import java.util.Observable; import java.util.Observer; @@ -354,7 +355,15 @@ try { double d = (double) Long.parseLong(str, 16); - handleFromSpin(d); + if (d > lastKnownTo) + { + if (lastKnownTo == lastKnownFrom) + handleFromSpin(lastKnownTo); + else + fromSpin.setValue(lastKnownTo); + } + else + fromSpin.setValue(d); } catch (NumberFormatException nfe) { @@ -377,7 +386,15 @@ try { double d = (double) Long.parseLong(str, 16); - handleToSpin(d); + if (d < lastKnownFrom) + { + if (lastKnownFrom == lastKnownTo) + handleToSpin(lastKnownFrom); + else + toSpin.setValue(lastKnownFrom); + } + else + toSpin.setValue(d); } catch (NumberFormatException nfe) { @@ -537,22 +554,23 @@ this.model.setValue(iter, (DataColumnString) cols[2], ins.instruction); this.pcOffset += ins.address; - - if (li.hasNext()) - ins = (Instruction) li.next(); - else - { - this.toSpin.setValue((double) ins.address); - this.toBox.setText(Long.toHexString(ins.address)); - this.lastKnownTo = ins.address; - ins = null; - } } else this.model.setValue(iter, (DataColumnString) cols[1], ""); this.model.setValue(iter, (DataColumnObject) cols[OBJ], ins); + + if (li.hasNext()) + ins = (Instruction) li.next(); + else + { + this.toSpin.setValue((double) ins.address); + this.toBox.setText(Long.toHexString(ins.address)); + this.lastKnownTo = ins.address; + ins = null; + } + iter = iter.getNextIter(); } @@ -568,7 +586,7 @@ /** * Helper function for calculating memory information and putting it into rows * to be displayed. - * By default append rows to the end; occasionally prepend rows to the front. + * By default append rows to the end. * * @param i The address to be displayed * @param iter The TreeIter representing the row to be added. @@ -617,6 +635,70 @@ this.lastKnownTo = ins.address; } + /** + * Helper function for calculating memory information and putting it into rows + * to be displayed. + * By default prepend rows to the front. + * + * @param val The address to be displayed + * @param nums The numbers of rows to be prepend. + */ + private synchronized void rowPrepend(long val, int addressAdded) + { + TreeIter iter = model.getFirstIter(); + TreePath path = iter.getPath(); + List instructionsList = diss.disassembleInstructions((long)(val-20), addressAdded+20); + ListIterator li = instructionsList.listIterator(0); + Instruction ins = (Instruction) li.next(); + while (li.hasNext() && ins.address < lastKnownFrom) + { + ins = (Instruction) li.next(); + if (ins.address == lastKnownFrom) + break; + + } + while (li.hasPrevious()) + { + if (ins.address < (long) val) { + ins = (Instruction) li.next(); + break; + } + ins = (Instruction) li.previous(); + } + if (addressAdded > 1) // if num==1, it should fetch the previous instruction + ins = (Instruction) li.next(); + + long newlastFrom = ins.address; + + while (ins != null && ins.address < lastKnownFrom) { + iter = model.insertRowBefore(model.getIter(path)); + this.lastPath.next(); + if (ins != null) { + model.setValue(iter, (DataColumnString) cols[1], ": "); + model.setValue(iter, (DataColumnString) cols[LOC], "0x" + + Long.toHexString(ins.address)); + model.setValue(iter, (DataColumnString) cols[2], + ins.instruction); + model.setValue(iter, (DataColumnObject) cols[3], ins); + this.numInstructions++; + if (li.hasNext()) { + ins = (Instruction) li.next(); + path.next(); + } + else + ins = null; + } + else + model.setValue(iter, (DataColumnString) cols[1], ""); + + } + + this.lastKnownFrom = newlastFrom; + this.fromSpin.setValue((double) newlastFrom); + this.fromBox.setText(Long.toHexString(newlastFrom)); + } + private void desensitize () { this.disassemblerView.setSensitive(false); @@ -661,28 +743,38 @@ if (val > this.lastKnownFrom) { - TreeIter iter = model.getFirstIter(); - - for (int i = (int) lastKnownFrom; i < (int) val; i++) - { - this.numInstructions--; - model.removeRow(iter); - iter = iter.getNextIter(); - } + if (this.numInstructions < 1) + return; + + TreeIter iter = model.getFirstIter(); + Instruction ins = (Instruction) this.model.getValue(iter, (DataColumnObject) cols[OBJ]); + //--this.numInstructions; + + while (ins != null && ins.address < val) + { + this.model.removeRow(iter); + this.lastPath.previous(); + ins = (Instruction) this.model.getValue(iter,(DataColumnObject) cols[OBJ]); + --this.numInstructions; + } + if (ins == null) + return; + + this.lastKnownFrom = ins.address; + this.fromBox.setText(Long.toHexString(ins.address)); + this.fromSpin.setValue((double)ins.address); + refreshList(); + return; } else { - for (long i = (long) val; i < lastKnownFrom; i++) - { - this.numInstructions++; - model.prependRow(); - } + int addressAdded = 0; + for (long i = (long)lastKnownFrom; i > (long)val; i--) + addressAdded++; + if (addressAdded == 0) + return; + rowPrepend((long)val, addressAdded); } - - this.fromSpin.setValue(val); - this.lastKnownFrom = val; - this.fromBox.setText(Long.toHexString((long) val)); - refreshList(); } boolean toToggle = false; --=-VTDxcWnfhUgbTiqrVpj5--