From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2732 invoked by alias); 16 Jan 2008 12:49:42 -0000 Received: (qmail 2721 invoked by uid 22791); 16 Jan 2008 12:49:41 -0000 X-Spam-Status: No, hits=-0.8 required=5.0 tests=AWL,BAYES_05,J_CHICKENPOX_46,J_CHICKENPOX_47 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, 16 Jan 2008 12:49:17 +0000 Received: from dijkstra.wildebeest.org ([192.168.1.29]) by gnu.wildebeest.org with esmtp (Exim 4.63) (envelope-from ) id 1JF7he-0003PQ-SA; Wed, 16 Jan 2008 13:49:13 +0100 Subject: [patch] Make source compile with older gcj From: Mark Wielaard To: frysk Cc: Petr Machata Content-Type: multipart/mixed; boundary="=-pjCreSBTNCAgHTxysGvU" Date: Wed, 16 Jan 2008 12:49:00 -0000 Message-Id: <1200487750.6395.11.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.12.2 (2.12.2-3.fc8) 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: 2008-q1/txt/msg00028.txt.bz2 --=-pjCreSBTNCAgHTxysGvU Content-Type: text/plain Content-Transfer-Encoding: 7bit Content-length: 1611 Hi, Some older versions of gcj (GCC) 4.1.2 20070626 (Red Hat 4.1.2-14) fell over the creative usage of anonymous inner classes inside methods calling inner class methods defined in the outer method they were defined in. This is probably one of the old parser bugs listed at: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18131 But since gcj switched the java source frontend parser since then they have all been closed (upgrading to a later gcj which uses ecj does indeed just compile things fine). The patch isn't very nice (sorry Petr), but since this is a test class anyway I thought I could get away with it. And it does make frysk compile again on older distros. Basically it lifts all affected inner classes up so they are class members, makes them static and adds the needed fields to the constructor. It also removes the unresolved bug #5053 since I couldn't reproduce that on any setup. It PASSes fine for me (fedora 8, centos 5.1). frysk-core/frysk/ftrace/ChangeLog 2008-01-16 Mark Wielaard * TestLtrace.java (DummyFunctionObserver): Made static. (ObserverCreator): Likewise. (GenericController): Likewise. (MyFunctionObserver1): Made class member and static. Add events as field. (MyFunctionObserver2): Likewise. Add expectedEvents and expectedReturns as fields. (MyFunctionObserver3): Likewiese. Add enterAliases and leaveAliases as fields. (testMultipleObservers): Removed unresolvedOffUtrace bug #5053. (testMultipleControlers): Likewise. (testRecursive): Likewise. Cheers, Mark --=-pjCreSBTNCAgHTxysGvU Content-Disposition: inline; filename=patch Content-Type: text/x-patch; name=patch; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-length: 8329 diff --git a/frysk-core/frysk/ftrace/TestLtrace.java b/frysk-core/frysk/ftrace/TestLtrace.java index 9ee4353..395eb93 100644 --- a/frysk-core/frysk/ftrace/TestLtrace.java +++ b/frysk-core/frysk/ftrace/TestLtrace.java @@ -54,7 +54,7 @@ import java.util.regex.*; public class TestLtrace extends TestLib { - class DummyFunctionObserver + static class DummyFunctionObserver implements FunctionObserver { public Action funcallEnter(Task task, Symbol symbol, Object[] args) { @@ -68,7 +68,7 @@ public class TestLtrace public void addFailed (Object observable, Throwable w) {} } - abstract class ObserverCreator { + static abstract class ObserverCreator { abstract FunctionObserver createObserver(); public boolean shouldAcceptMapping(Task task, String name) { return task.getProc().getExe().equals(name); @@ -137,7 +137,7 @@ public class TestLtrace } } - abstract class GenericController + static abstract class GenericController extends ObserverCreator { final String name; @@ -216,16 +216,15 @@ public class TestLtrace } } - public void testCallRecorded() - { - if(unresolvedOffUtrace(5053)) - return; - - final ArrayList events = new ArrayList(); - - class MyFunctionObserver1 + static class MyFunctionObserver1 extends DummyFunctionObserver { + final ArrayList events; + + MyFunctionObserver1(ArrayList events) + { + this.events = events; + } public Action funcallEnter(Task task, Symbol symbol, Object[] args) { events.add("enter " + symbol.name); return Action.CONTINUE; @@ -236,10 +235,14 @@ public class TestLtrace } } + public void testCallRecorded() + { + final ArrayList events = new ArrayList(); + GenericMappingObserver mappingObserver = new GenericMappingObserver(new ObserverCreator() { public FunctionObserver createObserver() { - return new MyFunctionObserver1(); + return new MyFunctionObserver1(events); } }); @@ -273,35 +276,19 @@ public class TestLtrace assertEquals("number of recorded events", expectedEvents.length, events.size()); } - public void testArgumentsCorrect1() - { - if(unresolvedOffUtrace(5053)) - return; - - final Set registeredSymbols = new HashSet(); - final LinkedList expectedEvents = new LinkedList(); - final LinkedList expectedReturns = new LinkedList(); - - class ExpectedEvent { - String name; - long[] arguments; - long retval; - - ExpectedEvent(String name, long[] arguments, long retval) { - this.name = name; - this.retval = retval; - this.arguments = arguments; - registeredSymbols.add(name); - expectedEvents.addLast(this); - } - } - - new ExpectedEvent("trace_me_1", new long[]{3, 5, 7, 11, 13, 17}, 56); - new ExpectedEvent("trace_me_2", new long[]{3, 5, 7, 11, 13, 17}, 56); - - class MyFunctionObserver2 + static class MyFunctionObserver2 extends DummyFunctionObserver { + final LinkedList expectedEvents; + final LinkedList expectedReturns; + + MyFunctionObserver2(LinkedList expectedEvents, + LinkedList expectedReturns) + { + this.expectedEvents = expectedEvents; + this.expectedReturns = expectedReturns; + } + public Action funcallEnter(Task task, Symbol symbol, Object[] args) { ExpectedEvent ee = (ExpectedEvent)expectedEvents.removeFirst(); assertEquals("enter function name", ee.name, symbol.name); @@ -330,6 +317,32 @@ public class TestLtrace } } + static class ExpectedEvent { + String name; + long[] arguments; + long retval; + + ExpectedEvent(String name, long[] arguments, long retval, + Set registeredSymbols, LinkedList expectedEvents) { + this.name = name; + this.retval = retval; + this.arguments = arguments; + registeredSymbols.add(name); + expectedEvents.addLast(this); + } + } + + public void testArgumentsCorrect1() + { + final Set registeredSymbols = new HashSet(); + final LinkedList expectedEvents = new LinkedList(); + final LinkedList expectedReturns = new LinkedList(); + + new ExpectedEvent("trace_me_1", new long[]{3, 5, 7, 11, 13, 17}, 56, + registeredSymbols, expectedEvents); + new ExpectedEvent("trace_me_2", new long[]{3, 5, 7, 11, 13, 17}, 56, + registeredSymbols, expectedEvents); + String[] cmd = {Config.getPkgLibFile("funit-calls").getPath()}; DaemonBlockedAtEntry child = new DaemonBlockedAtEntry(cmd); Task task = child.getMainTask(); @@ -339,7 +352,8 @@ public class TestLtrace GenericMappingObserver mappingObserver = new GenericMappingObserver(new ObserverCreator() { public FunctionObserver createObserver() { - return new MyFunctionObserver2(); + return new MyFunctionObserver2(expectedEvents, + expectedReturns); } public boolean acceptTracepoint(Task task, TracePoint tp) { return registeredSymbols.contains(tp.symbol.name); @@ -357,21 +371,21 @@ public class TestLtrace assertEquals("number of unprocessed returns", 0, expectedReturns.size()); } - public void testTracingAlias() - { - if(unresolvedOffUtrace(5053)) - return; - final HashSet enterAliases = new HashSet(); - final HashSet leaveAliases = new HashSet(); - class MyFunctionObserver3 + static class MyFunctionObserver3 extends DummyFunctionObserver { String name; + final HashSet enterAliases; + final HashSet leaveAliases; - public MyFunctionObserver3 (String name) { + public MyFunctionObserver3 (String name, + HashSet enterAliases, + HashSet leaveAliases) { this.name = name; + this.enterAliases = enterAliases; + this.leaveAliases = leaveAliases; } private void addAliases(Symbol symbol, HashSet aliases) { @@ -395,21 +409,33 @@ public class TestLtrace } } - class MyObserverCreator3 + static class MyObserverCreator3 extends GenericController { final String ownName; + final HashSet enterAliases; + final HashSet leaveAliases; - public MyObserverCreator3(String aliasName, String ownName) { + public MyObserverCreator3(String aliasName, String ownName, + HashSet enterAliases, + HashSet leaveAliases) { super(aliasName); this.ownName = ownName; + this.enterAliases = enterAliases; + this.leaveAliases = leaveAliases; } public FunctionObserver createObserver() { - return new MyFunctionObserver3(ownName); + return new MyFunctionObserver3(ownName, + enterAliases, leaveAliases); } } + public void testTracingAlias() + { + final HashSet enterAliases = new HashSet(); + final HashSet leaveAliases = new HashSet(); + String[] cmd = {Config.getPkgLibFile("funit-calls").getPath()}; DaemonBlockedAtEntry child = new DaemonBlockedAtEntry(cmd); Task task = child.getMainTask(); @@ -417,7 +443,7 @@ public class TestLtrace int pid = proc.getPid(); String symbols[] = {"fun1", "alias1", "alias2"}; - MyObserverCreator3 observerCreator = new MyObserverCreator3("alias2", "fun1"); + MyObserverCreator3 observerCreator = new MyObserverCreator3("alias2", "fun1", enterAliases, leaveAliases); MappingGuard.requestAddMappingObserver(task, new GenericMappingObserver(observerCreator)); assertRunUntilStop("add mapping observer"); @@ -436,9 +462,6 @@ public class TestLtrace public void testMultipleObservers() { - if(unresolvedOffUtrace(5053)) - return; - final int N = 10; String[] cmd = {Config.getPkgLibFile("funit-calls").getPath()}; @@ -469,9 +492,6 @@ public class TestLtrace public void testMultipleControlers() { - if(unresolvedOffUtrace(5053)) - return; - String[] cmd = {Config.getPkgLibFile("funit-calls").getPath()}; DaemonBlockedAtEntry child = new DaemonBlockedAtEntry(cmd); Task task = child.getMainTask(); @@ -507,9 +527,6 @@ public class TestLtrace public void testRecursive() { - if(unresolvedOffUtrace(5053)) - return; - String[] cmd = {Config.getPkgLibFile("funit-calls").getPath()}; DaemonBlockedAtEntry child = new DaemonBlockedAtEntry(cmd); Task task = child.getMainTask(); --=-pjCreSBTNCAgHTxysGvU--