From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14456 invoked by alias); 22 Aug 2007 12:26:42 -0000 Received: (qmail 14377 invoked by uid 22791); 22 Aug 2007 12:26:41 -0000 X-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,DK_POLICY_SIGNSOME,FORGED_RCVD_HELO X-Spam-Check-By: sourceware.org Received: from wildebeest.demon.nl (HELO gnu.wildebeest.org) (83.160.170.119) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 22 Aug 2007 12:26:38 +0000 Received: from dijkstra.wildebeest.org ([192.168.1.29]) by gnu.wildebeest.org with esmtp (Exim 4.63) (envelope-from ) id 1INpI6-0007lb-0O for frysk@sourceware.org; Wed, 22 Aug 2007 14:26:35 +0200 Subject: Disassembly source buffer and libopcodes From: Mark Wielaard To: frysk@sourceware.org Content-Type: multipart/mixed; boundary="=-kH7HufTPnAYUXJ8f7n+I" Date: Wed, 22 Aug 2007 12:26:00 -0000 Message-Id: <1187785589.3759.10.camel@dijkstra.wildebeest.org> Mime-Version: 1.0 X-Mailer: Evolution 2.8.3 (2.8.3-2.fc6) X-Spam-Score: -4.2 (----) 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/msg00318.txt.bz2 --=-kH7HufTPnAYUXJ8f7n+I Content-Type: text/plain Content-Transfer-Encoding: 7bit Content-length: 1134 Hi, Since Fedora did a license audit and found we were linking in libopcodes from binutils which is under GPL, but we distribute Frysk under GPL + Exception, automatic libopcode usage has been disabled (you need to configure --with-libopcodes to get it). But this exposed a bug in SourceBuffer which didn't handle not getting any disassembly. This patch fixes that (and makes the method slightly more efficient by using only one StringBuilder and appending the chars individually, not as String objects). And it fixes a typo in Disassembler.cxx which prevented disassembly even when --with-libopcodes was given. frysk-gui/frysk/gui/srcwin/ChangeLog 2007-08-22 Mark Wielaard * SourceBuffer.java (disassembleFrame): Use one StringBuffer, only call Iterator.next() when hasNext() returns true, append chars individually, not as String objects. frysk-sys/lib/opcodes/ChangeLog 2007-08-22 Mark Wielaard * cni/Disassembler.cxx (disassemble): Use WITH_LIBOPCODES, not HAVE_LIPOPCODES. This fixes bug #4948. Tested with and without --with-libopcodes. Cheers, Mark --=-kH7HufTPnAYUXJ8f7n+I Content-Disposition: inline; filename=Disassembler.patch Content-Type: text/x-patch; name=Disassembler.patch; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-length: 2230 Index: frysk-gui/frysk/gui/srcwin/SourceBuffer.java =================================================================== RCS file: /cvs/frysk/frysk-gui/frysk/gui/srcwin/SourceBuffer.java,v retrieving revision 1.137 diff -u -r1.137 SourceBuffer.java --- frysk-gui/frysk/gui/srcwin/SourceBuffer.java 13 Aug 2007 13:06:46 -0000 1.137 +++ frysk-gui/frysk/gui/srcwin/SourceBuffer.java 22 Aug 2007 11:44:14 -0000 @@ -870,7 +870,7 @@ this.firstLoad = false; - StringBuffer buffer = new StringBuffer(); + StringBuilder buf = new StringBuilder(); Disassembler diss = new Disassembler(task.getMemory()); long address = frame.getAddress(); @@ -879,27 +879,23 @@ List instructionsList = diss.disassembleInstructions(address, 40); Iterator iter = instructionsList.iterator(); - Instruction ins = (Instruction) iter.next(); while (iter.hasNext()) { - StringBuffer buf = new StringBuffer(); - buf.append("<"); + Instruction ins = (Instruction) iter.next(); + buf.append('<'); buf.append(frame.getSymbol().getDemangledName()); buf.append(" pc"); - buf.append("+"); + buf.append('+'); buf.append(ins.address - address); buf.append(">: "); buf.append("0x"); buf.append(Long.toHexString(ins.address)); - buf.append(" "); + buf.append(' '); buf.append(ins.instruction); - buf.append("\n"); - - buffer.append(buf.toString()); - ins = (Instruction) iter.next(); + buf.append('\n'); } - this.insertText(buffer.toString()); + this.insertText(buf.toString()); } /** Index: frysk-sys/lib/opcodes/cni/Disassembler.cxx =================================================================== RCS file: /cvs/frysk/frysk-sys/lib/opcodes/cni/Disassembler.cxx,v retrieving revision 1.3 diff -u -r1.3 Disassembler.cxx --- frysk-sys/lib/opcodes/cni/Disassembler.cxx 16 Aug 2007 19:22:34 -0000 1.3 +++ frysk-sys/lib/opcodes/cni/Disassembler.cxx 22 Aug 2007 12:22:19 -0000 @@ -195,7 +195,7 @@ void lib::opcodes::Disassembler::disassemble (jlong address, jlong instructions) { -#ifdef HAVE_LIPOPCODES +#ifdef WITH_LIBOPCODES disassemble_info disasm_info; int instr_length = 0; int (*disasm_func) (bfd_vma, disassemble_info*) = NULL; --=-kH7HufTPnAYUXJ8f7n+I--