public inbox for frysk@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: frysk@sourceware.org
Subject: Disassembly source buffer and libopcodes
Date: Wed, 22 Aug 2007 12:26:00 -0000	[thread overview]
Message-ID: <1187785589.3759.10.camel@dijkstra.wildebeest.org> (raw)

[-- 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;

             reply	other threads:[~2007-08-22 12:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-22 12:26 Mark Wielaard [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1187785589.3759.10.camel@dijkstra.wildebeest.org \
    --to=mark@klomp.org \
    --cc=frysk@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).