From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14991 invoked by alias); 21 Sep 2007 08:19:39 -0000 Received: (qmail 14968 invoked by uid 22791); 21 Sep 2007 08:19:38 -0000 X-Spam-Status: No, hits=-1.3 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; Fri, 21 Sep 2007 08:19:34 +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 l8L8JAM1015701; Fri, 21 Sep 2007 02:19:10 -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 l8L8J6vV019464; Fri, 21 Sep 2007 02:19:07 -0600 Subject: [patch] Memory Window: Change the location increment by eight. Fix bug 4674 From: Zhao Shujing Reply-To: pearly.zhao@oracle.com To: Frysk Mailing List Cc: cagney@redhat.com Content-Type: multipart/mixed; boundary="=-TOd7U3masZ4jGdH1N3wI" Organization: Oracle Date: Fri, 21 Sep 2007 08:19:00 -0000 Message-Id: <1190363168.3820.7.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/msg00398.txt.bz2 --=-TOd7U3masZ4jGdH1N3wI Content-Type: text/plain Content-Transfer-Encoding: 7bit Content-length: 204 Hi After investigate gdb, gtk/insight and other debugger of Linux, the location increment of memory window is change to eight, that is, it display 64bit every row. Any suggestions are welcomed. Pearly --=-TOd7U3masZ4jGdH1N3wI Content-Description: Content-Disposition: inline; filename=4674.patch Content-Type: text/x-patch; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-length: 13534 Index: gladedir/memorywindow.glade =================================================================== RCS file: /cvs/frysk/frysk-gui/frysk/gui/gladedir/memorywindow.glade,v retrieving revision 1.3 diff -u -r1.3 memorywindow.glade --- gladedir/memorywindow.glade 15 Jun 2007 12:28:11 -0000 1.3 +++ gladedir/memorywindow.glade 21 Sep 2007 08:17:36 -0000 @@ -569,7 +569,7 @@ GTK_UPDATE_ALWAYS False False - 1 0 10000000000 1 10 10 + 1 0 10000000000 8 10 10 6 @@ -589,7 +589,7 @@ GTK_UPDATE_ALWAYS False False - 1 0 10000000000 1 10 10 + 1 0 10000000000 8 10 10 6 Index: memory/MemoryWindow.java =================================================================== RCS file: /cvs/frysk/frysk-gui/frysk/gui/memory/MemoryWindow.java,v retrieving revision 1.47 diff -u -r1.47 MemoryWindow.java --- memory/MemoryWindow.java 21 Sep 2007 07:00:44 -0000 1.47 +++ memory/MemoryWindow.java 21 Sep 2007 08:17:36 -0000 @@ -314,7 +314,7 @@ this.diss = new Disassembler(myTask.getMemory()); pc_inc = myTask.getIsa().pc(myTask); - long end = pc_inc + 50; + long end = pc_inc + 20*8; this.setTitle(this.getTitle() + " - " + this.myTask.getProc().getCommand() + " " + this.myTask.getName()); @@ -666,8 +666,8 @@ memoryView.setModel(model); - for (long i = start; i < end + 1; i++) - rowAppend(i, null); + for (int i = 0; i <= end - start; i = i + 8) + rowAppend((long)(start + i), null); this.refreshList(); } @@ -689,8 +689,8 @@ this.toSpin.setValue(this.lastKnownTo); this.model.clear(); - for (long i = (long) lastKnownFrom; i < this.lastKnownTo + 1; i++) - rowAppend(i, null); + for (int i = 0; i <= this.lastKnownTo - this.lastKnownFrom; i = i + 8) + rowAppend((long)(this.lastKnownFrom + i), null); refreshList(); this.refreshLock = false; @@ -728,70 +728,178 @@ byte[] b = bi.toByteArray(); String bin = ""; - String oct = ""; + //String oct = ""; String hex = ""; - String dec = ""; + //String dec = ""; if (bi.signum() < 0) bi = new BigInteger(1, b); bin = bi.toString(2); - oct = bi.toString(8); + //oct = bi.toString(8); hex = bi.toString(16); - dec = bi.toString(10); + //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) + while (bin.length() < Long.SIZE) { bin = "0" + bin; } - while (oct.length() < (length/3 + 1)) - { - oct = "0" + oct; - } - while (hex.length() < length/4 ) + + while (hex.length() < Long.SIZE/4 ) { hex = "0" + hex; } /* Little endian first */ - this.model.setValue(iter, (DataColumnString) cols[1], bin); - 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); + String newbin = ""; + String newoct = ""; + String newdec = ""; + String newhex = ""; + int bit = (int) Math.pow(2, currentFormat + 3); + long len = Math.round((double)bin.length()/bit); + String[] binArray = new String[(int)len]; + String[] octArray = new String[(int)len]; + String[] hexArray = new String[(int)len]; + for (int i=0; i< len; i++) + { + if (bit*(i+1) < bin.length()) + { + binArray[i] = bin.substring(bit*i, bit*(i+1)); + hexArray[i] = hex.substring(bit/4*i, bit/4*(i+1)); + } + else + { + binArray[i] = bin.substring(bit*i); + hexArray[i] = hex.substring(bit/4*i, bit/4*(i+1)); + } + if (currentFormat == EIGHT_BIT) + { + byte bb = (byte)Integer.parseInt(binArray[i], 2); + newdec = newdec + bb + " "; + octArray[i]= Integer.toOctalString( bb & 0xff); + + } + if (currentFormat == SIXTEEN_BIT) + { + short s = (short)Integer.parseInt(binArray[i], 2); + newdec = newdec + s + " "; + + octArray[i] = Integer.toOctalString(s & 0xffff); + } + if (currentFormat == THIRTYTWO_BIT) + { + int in = (int)Long.parseLong(binArray[i], 2); + newdec = newdec + in + " "; + octArray[i] = Integer.toOctalString(in); + } + if (currentFormat == SIXTYFOUR_BIT) + { + long l; + if( binArray[i].length() == bit && + binArray[i].startsWith("1")) + { + l = (long)Long.parseLong(binArray[i].substring(1), 2); + l = (long)(l-(long)Math.pow(2, bit-1)); + + } + else + l = (long)Long.parseLong(binArray[i], 2); + newdec = newdec + l + " "; + octArray[i] = Long.toOctalString((long)l); + } + + newbin += binArray[i] + " "; + newoct += "0"+octArray[i] + " "; + newhex += "0x"+hexArray[i]+ " "; + } + this.model.setValue(iter, (DataColumnString) cols[1], newbin); + this.model.setValue(iter, (DataColumnString) cols[3], newoct); + this.model.setValue(iter, (DataColumnString) cols[5], newdec); + this.model.setValue(iter, (DataColumnString) cols[7], newhex); /* Big endian second */ String bin2 = switchEndianness(bin, true); BigInteger bii = new BigInteger(bin2, 2); - oct = bii.toString(8); - hex = bii.toString(16); - + hex = bii.toString(16); + newbin = ""; + newoct = ""; + newdec = ""; + newhex = ""; /* Bad hack to get around weird BigInteger endian bug */ - if (bin2.equals(bin)) + /*if (bin2.equals(bin)) dec = bi.toString(10); else - dec = bii.toString(10); + dec = bii.toString(10);*/ - while (bin2.length() < length) + while (bin2.length() < Long.SIZE) { bin2 = "0" + bin2; - } - while (oct.length() < (length/3 + 1)) - { - oct = "0" + oct; } - while (hex.length() < length/4 ) + while (hex.length() < Long.SIZE/4 ) { hex = "0" + hex; } - this.model.setValue(iter, (DataColumnString) cols[2], bin2); - 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); + + for (int i=0; i< len; i++) + { + if (bit*(i+1) < bin2.length()) + { + binArray[i] = bin2.substring(bit*i, bit*(i+1)); + hexArray[i] = hex.substring(bit/4*i, bit/4*(i+1)); + } + else + { + binArray[i] = bin2.substring(bit*i); + hexArray[i] = hex.substring(bit/4*i, bit/4*(i+1)); + } + if (currentFormat == EIGHT_BIT) + { + byte bb = (byte)Integer.parseInt(binArray[i], 2); + newdec = newdec + bb + " "; + octArray[i]= Integer.toOctalString( bb & 0xff); + + } + if (currentFormat == SIXTEEN_BIT) + { + short s = (short)Integer.parseInt(binArray[i], 2); + newdec = newdec + s + " "; + + octArray[i] = Integer.toOctalString(s & 0xffff); + } + if (currentFormat == THIRTYTWO_BIT) + { + int in = (int)Long.parseLong(binArray[i], 2); + newdec = newdec + in + " "; + octArray[i] = Integer.toOctalString(in); + } + if (currentFormat == SIXTYFOUR_BIT) + { + long l; + if( binArray[i].length() == bit && + binArray[i].startsWith("1")) + { + l = (long)Long.parseLong(binArray[i].substring(1), 2); + l = (long)(l-(long)Math.pow(2, bit-1)); + + } + else + l = (long)Long.parseLong(binArray[i], 2); + newdec = newdec + l + " "; + octArray[i] = Long.toOctalString((long)l); + } + + newbin += binArray[i] + " "; + newoct += "0"+octArray[i] + " "; + newhex += "0x"+hexArray[i]+ " "; + } + this.model.setValue(iter, (DataColumnString) cols[2], newbin); + this.model.setValue(iter, (DataColumnString) cols[4], newoct); + this.model.setValue(iter, (DataColumnString) cols[6], newdec); + this.model.setValue(iter, (DataColumnString) cols[8], newhex); if (ins != null && Long.toHexString(ins.address).equals(addr)) { @@ -837,58 +945,16 @@ model.setValue(iter, (DataColumnString) cols[LOC], "0x" + Long.toHexString(i)); model.setValue(iter, (DataColumnDouble) cols[11], 1.0); - - switch (currentFormat) - { - case EIGHT_BIT: - try - { - model.setValue(iter, (DataColumnObject) cols[OBJ], - "" + myTask.getMemory().getByte(i)); - } - catch (Exception e) - { - return; - } - break; - - case SIXTEEN_BIT: - try - { - model.setValue(iter, (DataColumnObject) cols[OBJ], - "" + myTask.getMemory().getShort(i)); - } - catch (Exception e) - { - return; - } - break; - - case THIRTYTWO_BIT: - try - { - model.setValue(iter, (DataColumnObject) cols[OBJ], - "" + myTask.getMemory().getInt(i)); - } - catch (Exception e) - { - return; - } - break; - - case SIXTYFOUR_BIT: - try - { - model.setValue(iter, (DataColumnObject) cols[OBJ], - "" + myTask.getMemory().getLong(i)); - } - catch (Exception e) - { - return; - } - break; - } - + + try + { + model.setValue(iter, (DataColumnObject) cols[OBJ], + "" + myTask.getMemory().getLong(i)); + } + catch (Exception e) + { + return; + } } private void desensitize () @@ -990,17 +1056,17 @@ { TreeIter iter = model.getFirstIter(); - for (long i = (long) lastKnownFrom; i < (long) val; i++) + for (long i = (long) lastKnownFrom; i < (long) val; i = i+8) { model.removeRow(iter); } } else { - for (long i = (long) lastKnownFrom - 1; i >= (long) val; i--) + for (long i = (long) lastKnownFrom - 8; i >= (long) val; i = i-8) { TreeIter newRow = model.prependRow(); - rowAppend(i, newRow); + rowAppend((long)(i- 8*(lastKnownFrom-i -8)), newRow); } } @@ -1031,12 +1097,12 @@ if (val > this.lastKnownTo) { - for (long i = (long) lastKnownTo + 1; i < val + 1; i++) - rowAppend(i, null); + for (long i = (long) lastKnownTo + 8; i < val + 1; i = i+8) + rowAppend((long)(i+8*(i-lastKnownTo-8)), null); } else { - for (; this.lastKnownTo > val; this.lastKnownTo--) + for (; this.lastKnownTo > val; this.lastKnownTo = this.lastKnownTo-8) { this.model.removeRow(this.model.getIter(this.lastPath)); this.lastPath.previous(); @@ -1058,8 +1124,8 @@ long startAddress = ((Long)addressList.getFirst()).longValue(); Symbol symbol = SymbolFactory.getSymbol(this.myTask, startAddress); long endAddress = symbol.getAddress() + symbol.getSize(); - long size = endAddress - startAddress + 1; - long modelSize = (long)lastKnownTo - (long)lastKnownFrom + 1; + long size = (endAddress - startAddress)/8 + 1; + long modelSize = ((long)lastKnownTo - (long)lastKnownFrom)/8 + 1; TreeIter iter = this.model.getFirstIter(); while (size < modelSize) { @@ -1074,12 +1140,12 @@ modelSize++; } this.lastKnownFrom = (double)startAddress; - this.lastKnownTo = (double)endAddress; + this.lastKnownTo = (double)(double)(startAddress+(long)(endAddress-startAddress)/8*8); iter = this.model.getFirstIter(); this.lastPath = iter.getPath(); - for(long i= startAddress; i < endAddress+1; i++) + for(int i = 0; i <= lastKnownTo-lastKnownFrom; i=i+8) { - rowAppend(i, iter); + rowAppend((long)(i+startAddress), iter); iter = iter.getNextIter(); } refreshList(); --=-TOd7U3masZ4jGdH1N3wI--