public inbox for frysk@sourceware.org
 help / color / mirror / Atom feed
* Disassembly source buffer and libopcodes
@ 2007-08-22 12:26 Mark Wielaard
  2007-08-22 14:27 ` Elena Zannoni
  0 siblings, 1 reply; 5+ messages in thread
From: Mark Wielaard @ 2007-08-22 12:26 UTC (permalink / raw)
  To: frysk

[-- Attachment #1: Type: text/plain, Size: 1134 bytes --]

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  <mwielaard@redhat.com>

    * 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  <mwielaard@redhat.com>

    * cni/Disassembler.cxx (disassemble): Use WITH_LIBOPCODES, not
    HAVE_LIPOPCODES.

This fixes bug #4948. Tested with and without --with-libopcodes.

Cheers,

Mark

[-- Attachment #2: Disassembler.patch --]
[-- Type: text/x-patch, Size: 2230 bytes --]

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;

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-08-22 18:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-22 12:26 Disassembly source buffer and libopcodes Mark Wielaard
2007-08-22 14:27 ` Elena Zannoni
2007-08-22 14:51   ` Mark Wielaard
2007-08-22 16:02     ` Elena Zannoni
2007-08-22 18:13       ` Mark Wielaard

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).