public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
* [SCM]  master: Re-use modules when possible.
@ 2008-06-04 19:40 cagney
  0 siblings, 0 replies; only message in thread
From: cagney @ 2008-06-04 19:40 UTC (permalink / raw)
  To: frysk-cvs

The branch, master has been updated
       via  ee64fd4e4ff967bddfa2ffc7090ebe4b3d9e1e1f (commit)
      from  a725006dc73a5c978e3c461afc1f6d17fe9483c8 (commit)

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

- Log -----------------------------------------------------------------
commit ee64fd4e4ff967bddfa2ffc7090ebe4b3d9e1e1f
Author: Andrew Cagney <cagney@redhat.com>
Date:   Wed Jun 4 15:37:33 2008 -0400

    Re-use modules when possible.
    
    If a pre-existing module is refreshed, re-use that existing module's
    object.
    
    frysk-sys/frysk/rsl/ChangeLog
    2008-06-04  Andrew Cagney  <cagney@redhat.com>
    
    	* Log.java (finest(Class)): New.
    
    frysk-sys/lib/dwfl/ChangeLog
    2008-06-04  Andrew Cagney  <cagney@redhat.com>
    
    	* Dwfl.java (dwfl_addrmodule): Delete.
    	(reportModule): Try to re-use existing modules.
    	* TestDwfl.java (testModuleReuse()): New.

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

Summary of changes:
 frysk-sys/frysk/rsl/ChangeLog    |    4 ++++
 frysk-sys/frysk/rsl/Log.java     |    3 +++
 frysk-sys/lib/dwfl/ChangeLog     |    6 ++++++
 frysk-sys/lib/dwfl/Dwfl.java     |   36 +++++++++++++++++++++++++++---------
 frysk-sys/lib/dwfl/TestDwfl.java |   15 +++++++++++++++
 frysk-sys/lib/dwfl/cni/Dwfl.cxx  |    5 -----
 6 files changed, 55 insertions(+), 14 deletions(-)

First 500 lines of diff:
diff --git a/frysk-sys/frysk/rsl/ChangeLog b/frysk-sys/frysk/rsl/ChangeLog
index 37ad53b..f611e11 100644
--- a/frysk-sys/frysk/rsl/ChangeLog
+++ b/frysk-sys/frysk/rsl/ChangeLog
@@ -1,3 +1,7 @@
+2008-06-04  Andrew Cagney  <cagney@redhat.com>
+
+	* Log.java (finest(Class)): New.
+
 2008-05-24  Andrew Cagney  <cagney@redhat.com>
 
 	* Log.java (log(Object,String,long,String,long,String,long)): New.
diff --git a/frysk-sys/frysk/rsl/Log.java b/frysk-sys/frysk/rsl/Log.java
index 0356ab1..1557332 100644
--- a/frysk-sys/frysk/rsl/Log.java
+++ b/frysk-sys/frysk/rsl/Log.java
@@ -106,6 +106,9 @@ public final class Log {
     public static Log fine(Class klass) {
 	return LogFactory.fine(klass);
     }
+    public static Log finest(Class klass) {
+	return LogFactory.finest(klass);
+    }
 
     // Static?
     private static Printer out = new Printer(new PrintWriter(System.out));
diff --git a/frysk-sys/lib/dwfl/ChangeLog b/frysk-sys/lib/dwfl/ChangeLog
index 4d4442b..e7bd08d 100644
--- a/frysk-sys/lib/dwfl/ChangeLog
+++ b/frysk-sys/lib/dwfl/ChangeLog
@@ -1,3 +1,9 @@
+2008-06-04  Andrew Cagney  <cagney@redhat.com>
+
+	* Dwfl.java (dwfl_addrmodule): Delete.
+	(reportModule): Try to re-use existing modules.
+	* TestDwfl.java (testModuleReuse()): New.
+
 2008-06-03  Andrew Cagney  <cagney@redhat.com>
 
 	* Dwfl.java (modules, modulesArray, reportBegin, reportModule):
diff --git a/frysk-sys/lib/dwfl/Dwfl.java b/frysk-sys/lib/dwfl/Dwfl.java
index 676caa6..1e8d52a 100644
--- a/frysk-sys/lib/dwfl/Dwfl.java
+++ b/frysk-sys/lib/dwfl/Dwfl.java
@@ -46,6 +46,7 @@ import inua.eio.ULong;
 
 public class Dwfl {
     private static final Log fine = Log.fine(Dwfl.class);
+    private static final Log finest = Log.finest(Dwfl.class);
 
     private long pointer;
     private long callbacks;
@@ -166,29 +167,48 @@ public class Dwfl {
     public void reportBegin() {
 	fine.log(this, "reportBegin");
 	reportBegin(pointer);
+	// fill modulesArray with the current modules and then clear
+	// the set.  Will iterate over the old modules so that they
+	// are re-used.
+	getModules();
 	modules.clear();
-	modulesArray = null;
     }
     private static native void reportBegin(long pointer);
+
     /**
      * Finish a refresh of the address map.
      */
     public void reportEnd() {
 	fine.log(this, "reportEnd");
 	reportEnd(pointer);
+	// Finished; scrub references to old modules.
+	modulesArray = null;
     }
     private static native void reportEnd(long pointer);
+
     /**
      * Report a mapped component.
      */
     public void reportModule(String moduleName, long low, long high) {
 	fine.log(this, "reportModule", moduleName, "low", low, "high", high);
-	// XXX: Can elfutils be trusted to return identical module
-	// addresss across map rebuilds; and not recycle addresses?
-	// For moment assume not.
-	long module = reportModule(pointer, moduleName, low, high);
-	modules.put(new Long(module), new DwflModule(module, this,
-						     moduleName, low, high));
+	long modulePointer = reportModule(pointer, moduleName, low, high);
+	for (int i = 0; i < modulesArray.length; i++) {
+	    DwflModule module = modulesArray[i];
+	    if (module.getName().equals(moduleName)
+		&& module.lowAddress() == low
+		&& module.highAddress() == high
+		&& module.getPointer() == modulePointer) {
+		// Could the pointer be changed; will the pointer
+		// change?
+		finest.log(this, "reportModule reusing", module);
+		modules.put(new Long(modulePointer), module);
+		return;
+	    }
+	}
+	DwflModule module = new DwflModule(modulePointer, this, moduleName,
+					   low, high);
+	finest.log(this, "reportModule creating", module);
+	modules.put(new Long(modulePointer), module);
     }
     private static native long reportModule(long pointer, String moduleName,
 					    long low, long high);
@@ -293,6 +313,4 @@ public class Dwfl {
     protected native long dwfl_getsrc (long addr);
   
     protected native DwflDieBias dwfl_addrdie (long addr);
-  
-    protected native long dwfl_addrmodule (long addr);
 }
diff --git a/frysk-sys/lib/dwfl/TestDwfl.java b/frysk-sys/lib/dwfl/TestDwfl.java
index dbc881f..04bf421 100644
--- a/frysk-sys/lib/dwfl/TestDwfl.java
+++ b/frysk-sys/lib/dwfl/TestDwfl.java
@@ -83,6 +83,21 @@ public class TestDwfl
                module.getName().equals(moduleName));
   }
   
+    public void testModuleReuse() {
+	Dwfl dwfl = new Dwfl("");
+	assertNotNull("dwfl", dwfl);
+	dwfl.reportBegin();
+	dwfl.reportModule("module", 0, 1);
+	dwfl.reportEnd();
+	DwflModule module = dwfl.getModule(0);
+	assertEquals("module name", "module", module.getName());
+	// now refresh the info; should get the _same_ module.
+	dwfl.reportBegin();
+	dwfl.reportModule("module", 0, 1);
+	dwfl.reportEnd();
+	assertSame("refreshed module", module, dwfl.getModule(0));
+    }
+
   public void testDwflGetModule2()
   {
     Dwfl dwfl = new Dwfl("");
diff --git a/frysk-sys/lib/dwfl/cni/Dwfl.cxx b/frysk-sys/lib/dwfl/cni/Dwfl.cxx
index ae6358a..6fa85e6 100644
--- a/frysk-sys/lib/dwfl/cni/Dwfl.cxx
+++ b/frysk-sys/lib/dwfl/cni/Dwfl.cxx
@@ -223,11 +223,6 @@ lib::dwfl::Dwfl::dwfl_addrdie(jlong addr){
 }
 
 jlong
-lib::dwfl::Dwfl::dwfl_addrmodule(jlong addr){
-  return (jlong) ::dwfl_addrmodule(DWFL_POINTER, (Dwarf_Addr) addr);	
-}
-
-jlong
 lib::dwfl::Dwfl::dwfl_cumodule(jlong cudie)
 {
   Dwfl_Module* module = ::dwfl_cumodule((Dwarf_Die*)cudie);


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


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

only message in thread, other threads:[~2008-06-04 19:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-04 19:40 [SCM] master: Re-use modules when possible 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).