public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
* [SCM]  master: Allow for LocalMemory being part of a separate shared library.
@ 2008-06-06  2:12 cagney
  0 siblings, 0 replies; only message in thread
From: cagney @ 2008-06-06  2:12 UTC (permalink / raw)
  To: frysk-cvs

The branch, master has been updated
       via  320da5218a7124bc55ab876d80f49b38a256ca9b (commit)
      from  4c1f1d27185537bb1a43f8aac8e723ba0deab3a8 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit 320da5218a7124bc55ab876d80f49b38a256ca9b
Author: Andrew Cagney <cagney@redhat.com>
Date:   Thu Jun 5 22:08:17 2008 -0400

    Allow for LocalMemory being part of a separate shared library.
    
    frysk-sys/frysk/testbed/ChangeLog
    2008-06-05  Andrew Cagney  <cagney@redhat.com>
    
    	* LocalMemory.java (getCodeName()): New.
    	* jni/LocalMemory.cxx: Update.
    	* cni/LocalMemory.cxx: Synchronise with JNI version.
    
    frysk-sys/lib/dwfl/ChangeLog
    2008-06-05  Andrew Cagney  <cagney@redhat.com>
    
    	* TestDwfl.java (testGetModules()): Allow for JNI.
    	(testGetDie()): Use LocalMemory.getCodeName.

-----------------------------------------------------------------------

Summary of changes:
 frysk-sys/frysk/testbed/ChangeLog           |    6 +
 frysk-sys/frysk/testbed/LocalMemory.java    |    5 +
 frysk-sys/frysk/testbed/cni/LocalMemory.cxx |   21 +++-
 frysk-sys/frysk/testbed/jni/LocalMemory.cxx |   10 ++-
 frysk-sys/lib/dwfl/ChangeLog                |    3 +
 frysk-sys/lib/dwfl/TestDwfl.java            |  173 ++++++++++++++-------------
 6 files changed, 129 insertions(+), 89 deletions(-)

First 500 lines of diff:
diff --git a/frysk-sys/frysk/testbed/ChangeLog b/frysk-sys/frysk/testbed/ChangeLog
index 1cf45e6..6d16666 100644
--- a/frysk-sys/frysk/testbed/ChangeLog
+++ b/frysk-sys/frysk/testbed/ChangeLog
@@ -1,3 +1,9 @@
+2008-06-05  Andrew Cagney  <cagney@redhat.com>
+
+	* LocalMemory.java (getCodeName()): New.
+	* jni/LocalMemory.cxx: Update.
+	* cni/LocalMemory.cxx: Synchronise with JNI version.
+
 2008-05-24  Andrew Cagney  <cagney@redhat.com>
 
 	* jni/LocalMemory.cxx: Update; byteArray -> jbyteArray.
diff --git a/frysk-sys/frysk/testbed/LocalMemory.java b/frysk-sys/frysk/testbed/LocalMemory.java
index 633a151..5a171dd 100644
--- a/frysk-sys/frysk/testbed/LocalMemory.java
+++ b/frysk-sys/frysk/testbed/LocalMemory.java
@@ -58,6 +58,11 @@ public class LocalMemory {
     public static native byte[] getDataBytes();
 
     /**
+     * Returns the name of the code function.
+     */
+    public static native String getCodeName();
+
+    /**
      * Returns the address of a function.
      */
     public static native long getCodeAddr();
diff --git a/frysk-sys/frysk/testbed/cni/LocalMemory.cxx b/frysk-sys/frysk/testbed/cni/LocalMemory.cxx
index 6eef06c..5730980 100644
--- a/frysk-sys/frysk/testbed/cni/LocalMemory.cxx
+++ b/frysk-sys/frysk/testbed/cni/LocalMemory.cxx
@@ -1,6 +1,6 @@
 // This file is part of the program FRYSK.
 //
-// Copyright 2005, 2006, 2007 Red Hat Inc.
+// Copyright 2005, 2006, 2007, 2008 Red Hat Inc.
 //
 // FRYSK is free software; you can redistribute it and/or modify it
 // under the terms of the GNU General Public License as published by
@@ -74,7 +74,19 @@ frysk::testbed::LocalMemory::getDataBytes() {
  * Function used by getCode*(), must be on a single line for __LINE__
  * to work correctly.
  */
-jint frysk::testbed::LocalMemory::getCodeLine () { return __LINE__; }
+extern "C" {
+  static jint codeLine() { return __LINE__; }
+}
+
+jstring
+frysk::testbed::LocalMemory::getCodeName() {
+  return JvNewStringUTF("codeLine");
+}
+
+jint
+frysk::testbed::LocalMemory::getCodeLine() {
+  return codeLine();
+}
 
 jstring
 frysk::testbed::LocalMemory::getCodeFile() {
@@ -84,11 +96,12 @@ frysk::testbed::LocalMemory::getCodeFile() {
 static void*
 codeAddr() {
 #ifdef __powerpc64__
-  return *((void**) frysk::testbed::LocalMemory::getCodeLine);
+  return *((void**) codeLine);
 #else
-  return (void*)&frysk::testbed::LocalMemory::getCodeLine;
+  return (void*)&codeLine;
 #endif
 }
+
 jlong
 frysk::testbed::LocalMemory::getCodeAddr() {
   return (jlong)codeAddr();
diff --git a/frysk-sys/frysk/testbed/jni/LocalMemory.cxx b/frysk-sys/frysk/testbed/jni/LocalMemory.cxx
index f3d9e02..02c7c6f 100644
--- a/frysk-sys/frysk/testbed/jni/LocalMemory.cxx
+++ b/frysk-sys/frysk/testbed/jni/LocalMemory.cxx
@@ -74,7 +74,14 @@ frysk::testbed::LocalMemory::getDataBytes(::jnixx::env env) {
  * Function used by getCode*(), must be on a single line for __LINE__
  * to work correctly.
  */
-static jint codeLine() { return __LINE__; }
+extern "C" {
+  static jint codeLine() { return __LINE__; }
+}
+
+String
+frysk::testbed::LocalMemory::getCodeName(jnixx::env env) {
+  return String::NewStringUTF(env, "codeLine");
+}
 
 jint
 frysk::testbed::LocalMemory::getCodeLine(::jnixx::env) {
@@ -94,6 +101,7 @@ codeAddr() {
   return (void*)&codeLine;
 #endif
 }
+
 jlong
 frysk::testbed::LocalMemory::getCodeAddr(::jnixx::env) {
   return (jlong)codeAddr();
diff --git a/frysk-sys/lib/dwfl/ChangeLog b/frysk-sys/lib/dwfl/ChangeLog
index d162897..bb39b95 100644
--- a/frysk-sys/lib/dwfl/ChangeLog
+++ b/frysk-sys/lib/dwfl/ChangeLog
@@ -1,5 +1,8 @@
 2008-06-05  Andrew Cagney  <cagney@redhat.com>
 
+	* TestDwfl.java (testGetModules()): Allow for JNI.
+	(testGetDie()): Use LocalMemory.getCodeName.
+
 	* cni/Dwfl.cxx: Fix includes.
 	
 	* DwflLine.java: Pass pointer to native methods.
diff --git a/frysk-sys/lib/dwfl/TestDwfl.java b/frysk-sys/lib/dwfl/TestDwfl.java
index d04e0e6..1e3392b 100644
--- a/frysk-sys/lib/dwfl/TestDwfl.java
+++ b/frysk-sys/lib/dwfl/TestDwfl.java
@@ -42,14 +42,15 @@ package lib.dwfl;
 import java.io.File;
 import java.util.Iterator;
 import java.util.List;
-
+import frysk.rsl.Log;
 import frysk.junit.Runner;
 import frysk.junit.TestCase;
 import frysk.testbed.LocalMemory;
+import frysk.config.Runtime;
+
+public class TestDwfl extends TestCase {
+    public static final Log finest = Log.finest(TestDwfl.class);
 
-public class TestDwfl
-    extends TestCase
-{
   public void testDwfl()
   {
     Dwfl dwfl = new Dwfl("");
@@ -143,88 +144,92 @@ public class TestDwfl
     assertEquals("column", 0, line.getColumn());
   }
 
-  public void testGetDie ()
-  {
-    Dwfl dwfl = DwflTestbed.createFromSelf();
-    assertNotNull(dwfl);
-    
-    DwflDie die = dwfl.getCompilationUnit(LocalMemory.getCodeAddr());
-    assertNotNull("die", die);
-    assertEquals("bias", 0, die.getBias());
+    public void testGetDie() {
+	Dwfl dwfl = DwflTestbed.createFromSelf();
+	assertNotNull("dwfl", dwfl);
     
-    assertEquals("file",
-		 new File(LocalMemory.getCodeFile()).getName(),
-		 new File(die.getName()).getName());
-
-    DwarfDie[] allDies = die.getScopes(LocalMemory.getCodeAddr() - die.getBias());
-    assertNotNull(allDies);
+	DwflDie die = dwfl.getCompilationUnit(LocalMemory.getCodeAddr());
+	assertNotNull("die", die);
+	// assertEquals("bias", 0, die.getBias());
+	assertEquals("file",
+		     new File(LocalMemory.getCodeFile()).getName(),
+		     new File(die.getName()).getName());
 
-    String[] names = {
-	"getCodeLine",
-	new File(LocalMemory.getCodeFile()).getName()
-    };
-
-    for (int i = 0; i < allDies.length; i++)
-      {
-	  assertNotNull("allDies[i]", allDies[i]);
-	  // Enable this line if you think that checking for inlined
-	  // code in a test suite is ok
-//        assertEquals(false, allDies[i].isInlinedFunction());        
-	  if (i == 1)
-	      assertEquals("names[i]", names[i],
-			   new File(allDies[i].getName()).getName());
-	  else
-	      assertEquals(names[i], allDies[i].getName());
-      }
-  }
+	DwarfDie[] allDies
+	    = die.getScopes(LocalMemory.getCodeAddr() - die.getBias());
+	assertNotNull("allDies", allDies);
+	String[] names = {
+	    LocalMemory.getCodeName(),
+	    new File(LocalMemory.getCodeFile()).getName()
+	};
+	for (int i = 0; i < allDies.length; i++) {
+	    assertNotNull("allDies[i]", allDies[i]);
+	    // Enable this line if you think that checking for inlined
+	    // code in a test suite is ok
+	    //        assertEquals(false, allDies[i].isInlinedFunction());        
+	    if (i == 1)
+		assertEquals("names " + i, names[i],
+			     new File(allDies[i].getName()).getName());
+	    else
+		assertEquals("names " + i, names[i], allDies[i].getName());
+	}
+    }
 
-  // Get all the modules of the test application; look for some that
-  // should be there. 
-  public void testGetModules() 
-  {
-    Dwfl dwfl = DwflTestbed.createFromSelf();
-    DwflModule[] modules = dwfl.getModules();
-    assertNotNull(modules);
-    // Look for some modules that should be there.
-    boolean foundTestRunner = false;
-    boolean foundlibc = false;
-    boolean foundlibgcj = false;
-    for (int i = 0; i < modules.length; i++) 
-      {
-	String modName = modules[i].getName();
-	if (modName.lastIndexOf (Runner.getProgramBasename ()) >= 0)
-	  foundTestRunner = true;
-	else if (modName.lastIndexOf("libc") >= 0)
-	  foundlibc = true;
-	else if (modName.lastIndexOf("libgcj") >= 0)
-	  foundlibgcj = true;
-      }
-    assertTrue(foundTestRunner && foundlibc && foundlibgcj);
-  }
+    /**
+     * Get all the modules of the test application; look for some that
+     * should be there.
+     */
+    public void testGetModules() {
+	Dwfl dwfl = DwflTestbed.createFromSelf();
+	DwflModule[] modules = dwfl.getModules();
+	assertNotNull("modules", modules);
+	// Look for some modules that should be there.
+	boolean foundSelf = false;
+	boolean foundlibc = false;
+	for (int i = 0; i < modules.length; i++) {
+	    String modName = modules[i].getName();
+	    if (modName.lastIndexOf("libc") >= 0) {
+		foundlibc = true;
+		continue;
+	    }
+	    if (Runtime.get() == Runtime.JAVA_NATIVE_INTERFACE) {
+		if (modName.lastIndexOf("libfrysk-sys-jni.so") >= 0) {
+		    foundSelf = true;
+		}
+	    }
+	    if (Runtime.get() == Runtime.COMPILER_NATIVE_INTERFACE) {
+		if (modName.lastIndexOf (Runner.getProgramBasename ()) >= 0) {
+		    foundSelf = true;
+		}
+	    }
+	}
+	assertTrue("found libc", foundlibc);
+	assertTrue("found self", foundSelf);
+    }
 
-  // Get a line from an address, then see that the address is included
-  // in the DwflLine records returned for a line.
-  public void testGetAddresses() 
-  {
-    Dwfl dwfl = DwflTestbed.createFromSelf();
-    assertNotNull(dwfl);
-    long addr = LocalMemory.getCodeAddr();
-    DwflLine line = dwfl.getSourceLine(addr);
-    assertNotNull(line);
-    List lines = dwfl.getLineAddresses(line.getSourceFile(), 
-					 line.getLineNum(),
-					 0);
-    Iterator linesIterator = lines.iterator();
-    boolean foundAddress = false;
-    while (linesIterator.hasNext()) 
-      {
-	DwflLine addrLine = (DwflLine)linesIterator.next();
-	if (addrLine.getAddress() == addr) 
-	  {
-	    foundAddress = true;
-	    break;
-	  }
-      }
-    assertTrue(foundAddress);
-  }
+    /**
+     * Get a line from an address, then see that the address is
+     * included in the DwflLine records returned for a line.
+     */
+    public void testGetAddresses() {
+	Dwfl dwfl = DwflTestbed.createFromSelf();
+	assertNotNull("dwfl", dwfl);
+	long addr = LocalMemory.getCodeAddr();
+	finest.log("addr", addr);
+	DwflLine line = dwfl.getSourceLine(addr);
+	assertNotNull("line", line);
+	List lines = dwfl.getLineAddresses(line.getSourceFile(), 
+					   line.getLineNum(),
+					   0);
+	Iterator linesIterator = lines.iterator();
+	boolean foundAddress = false;
+	while (linesIterator.hasNext()) {
+	    DwflLine addrLine = (DwflLine)linesIterator.next();
+	    if (addrLine.getAddress() == addr) {
+		foundAddress = true;
+		break;
+	    }
+	}
+	assertTrue(foundAddress);
+    }
 }


hooks/post-receive
--
frysk system monitor/debugger


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-06-06  2:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-06  2:12 [SCM] master: Allow for LocalMemory being part of a separate shared library cagney

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