From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21738 invoked by alias); 28 Aug 2007 11:01:01 -0000 Received: (qmail 21599 invoked by uid 22791); 28 Aug 2007 11:01:00 -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; Tue, 28 Aug 2007 11:00:56 +0000 Received: from dijkstra.wildebeest.org ([192.168.1.29]) by gnu.wildebeest.org with esmtp (Exim 4.63) (envelope-from ) id 1IPyoY-00013W-BF for frysk@sourceware.org; Tue, 28 Aug 2007 13:00:55 +0200 Subject: DummyDisassembler for fstep From: Mark Wielaard To: frysk@sourceware.org Content-Type: multipart/mixed; boundary="=-WK+jLgkSYZ/HJC3EChRc" Date: Tue, 28 Aug 2007 11:01:00 -0000 Message-Id: <1188298851.3817.7.camel@dijkstra.wildebeest.org> Mime-Version: 1.0 X-Mailer: Evolution 2.8.3 (2.8.3-2.fc6) X-Spam-Score: -4.4 (----) 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/msg00357.txt.bz2 --=-WK+jLgkSYZ/HJC3EChRc Content-Type: text/plain Content-Transfer-Encoding: 7bit Content-length: 921 Hi, In the last test reports I saw that FStep.testFirstStep was disabled because we don't have a disassembler anymore. This made me a little nervous since the test isn't actually testing the disassembler at all and the test is a good indicator of subtle observer issues with stepping and breakpoints. So I added a quick and dirty DummyDisassembler to fstep that is used when no full blown Disassembler is available. 2007-08-28 Mark Wielaard * fstep.java (DummyDisassembler): New static helper class. (updateAttached): Create DummyDisassembler when needed. (updateHit): Add new observers first before removing Code observer. * TestFStep.java: Always supported. With this the test passes again and now fstep even gives some useful output even without the full disassembler. Maybe someone wants to make this more generic for other consumers of the disassembler? Cheers, Mark --=-WK+jLgkSYZ/HJC3EChRc Content-Disposition: inline; filename=fstep-dummy-dis.patch Content-Type: text/x-patch; name=fstep-dummy-dis.patch; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-length: 2996 Index: frysk-core/frysk/bindir/TestFStep.java =================================================================== RCS file: /cvs/frysk/frysk-core/frysk/bindir/TestFStep.java,v retrieving revision 1.5 diff -u -r1.5 TestFStep.java --- frysk-core/frysk/bindir/TestFStep.java 16 Aug 2007 20:15:11 -0000 1.5 +++ frysk-core/frysk/bindir/TestFStep.java 28 Aug 2007 10:58:46 -0000 @@ -54,8 +54,6 @@ // stepped program. public void testFirstStep() throws Exception { - if (unsupported("disassembler", !lib.opcodes.Disassembler.available())) - return; Elf e = new Elf("/bin/true", ElfCommand.ELF_C_READ); try { Index: frysk-core/frysk/bindir/fstep.java =================================================================== RCS file: /cvs/frysk/frysk-core/frysk/bindir/fstep.java,v retrieving revision 1.10 diff -u -r1.10 fstep.java --- frysk-core/frysk/bindir/fstep.java 9 Jul 2007 16:31:29 -0000 1.10 +++ frysk-core/frysk/bindir/fstep.java 28 Aug 2007 10:58:46 -0000 @@ -42,6 +42,7 @@ import frysk.proc.*; import frysk.util.CommandlineParser; import lib.opcodes.*; +import inua.eio.ByteBuffer; import gnu.classpath.tools.getopt.*; import java.util.*; @@ -186,12 +187,49 @@ Manager.eventLoop.run(); } + /** + * Disassembler to use when real disassembler isn't available. + * Only implements disassembleInstructions and just + * returns address and four bytes in raw hex form. + */ + static class DummyDisassembler extends Disassembler + { + private final ByteBuffer memory; + DummyDisassembler(ByteBuffer memory) + { + super(memory); + this.memory = memory; + } + + public List disassembleInstructions(long address, long count) + { + ArrayList list = new ArrayList(); + memory.position(address); + while (count > 0) + { + list.add("0x" + Long.toHexString(address) + + "\t0x" + Integer.toHexString(memory.getByte() & 0xff) + + " 0x" + Integer.toHexString(memory.getByte() & 0xff) + + " 0x" + Integer.toHexString(memory.getByte() & 0xff) + + " 0x" + Integer.toHexString(memory.getByte() & 0xff)); + address++; + count--; + } + return list; + } + } + // TaskObserver.Attached interface public Action updateAttached(Task task) { // We only need one disassembler since all Tasks share their memory. if (disassembler == null) - disassembler = new Disassembler(task.getMemory()); + { + if (Disassembler.available()) + disassembler = new Disassembler(task.getMemory()); + else + disassembler = new DummyDisassembler(task.getMemory()); + } tasks.put(task, Long.valueOf(0)); @@ -226,9 +264,9 @@ // TaskObserver.Code interface public Action updateHit(Task task, long address) { - task.requestDeleteCodeObserver(this, address); task.requestAddInstructionObserver(this); task.requestAddTerminatedObserver(this); + task.requestDeleteCodeObserver(this, address); return Action.BLOCK; } --=-WK+jLgkSYZ/HJC3EChRc--