public inbox for frysk@sourceware.org
 help / color / mirror / Atom feed
* [patch] Make source compile with older gcj
@ 2008-01-16 12:49 Mark Wielaard
  2008-01-16 13:41 ` Chris Moller
  2008-01-16 13:49 ` Petr Machata
  0 siblings, 2 replies; 3+ messages in thread
From: Mark Wielaard @ 2008-01-16 12:49 UTC (permalink / raw)
  To: frysk; +Cc: Petr Machata

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

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

[-- Attachment #2: patch --]
[-- Type: text/x-patch, Size: 8329 bytes --]

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();

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

* Re: [patch] Make source compile with older gcj
  2008-01-16 12:49 [patch] Make source compile with older gcj Mark Wielaard
@ 2008-01-16 13:41 ` Chris Moller
  2008-01-16 13:49 ` Petr Machata
  1 sibling, 0 replies; 3+ messages in thread
From: Chris Moller @ 2008-01-16 13:41 UTC (permalink / raw)
  To: Mark Wielaard; +Cc: frysk, Petr Machata

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



Mark Wielaard wrote:
> 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
>   

Aha!  /That's/ why I'm getting gcj internal compiler errors!  But it was 
time to upgrade my old FC6 machine anyway...

> calling inner class methods defined in the outer method they were

-- 
Chris Moller

  Java: the blunt scissors of programming languages.
      -- Dave Thomas



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 251 bytes --]

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

* Re: [patch] Make source compile with older gcj
  2008-01-16 12:49 [patch] Make source compile with older gcj Mark Wielaard
  2008-01-16 13:41 ` Chris Moller
@ 2008-01-16 13:49 ` Petr Machata
  1 sibling, 0 replies; 3+ messages in thread
From: Petr Machata @ 2008-01-16 13:49 UTC (permalink / raw)
  To: Mark Wielaard; +Cc: frysk

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

Mark Wielaard wrote:
> 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.

Huh, you lost me at "outer methods".  But in general, since gcj seems to
have all sorts of problems with classes defined in methods, it's
probably for the best simply to avoid them...

> The patch isn't very nice (sorry Petr), but since this is a test class
> anyway I thought I could get away with it.

Absolutely.

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

Very cool, especially the Centos 5.1 part; F 8 is my main devel
platform, so I'm not all that surprised that works :)

> Mark

PM


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

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

end of thread, other threads:[~2008-01-16 13:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-16 12:49 [patch] Make source compile with older gcj Mark Wielaard
2008-01-16 13:41 ` Chris Moller
2008-01-16 13:49 ` Petr Machata

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