public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
From: cagney@sourceware.org
To: frysk-cvs@sourceware.org
Subject: [SCM]  master: Update the DwflModule list during the report phase.
Date: Tue, 03 Jun 2008 22:23:00 -0000	[thread overview]
Message-ID: <20080603222352.4635.qmail@sourceware.org> (raw)

The branch, master has been updated
       via  b4b0e9bf226bc91db7cf802735d8791630504d0c (commit)
       via  160578cd1f2acd44727faeb05661627b2364f3a5 (commit)
      from  4c5506710d57fe3e149e199bdf7faa6cacb7654f (commit)

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

- Log -----------------------------------------------------------------
commit b4b0e9bf226bc91db7cf802735d8791630504d0c
Author: Andrew Cagney <cagney@redhat.com>
Date:   Tue Jun 3 18:21:03 2008 -0400

    Update the DwflModule list during the report phase.
    
    ::dwfl_report_module returns the handle for each module as it is
    [re]inserted.  Make use of this by updating the DwflModule list during
    the report phase.
    
    frysk-core/frysk/ftrace/ChangeLog
    2008-06-03  Andrew Cagney  <cagney@redhat.com>
    
    	* Ftrace.java: Use DwflModule.getModules() and not
    	.getModulesForce.
    
    frysk-core/frysk/stack/ChangeLog
    2008-06-03  Andrew Cagney  <cagney@redhat.com>
    
    	* TestFrame.java: Use DwflModule.getModules() and not
    	.getModulesForce().
    
    frysk-sys/lib/dwfl/ChangeLog
    2008-06-03  Andrew Cagney  <cagney@redhat.com>
    
    	* Dwfl.java (modules, modulesArray, reportBegin, reportModule):
    	Maintain a list of modules.
    	(getModules()): Re-implement.
    	(getModule(long)): Re-implement.
    	(getModulesForce()): Delete.
    	(dwfl_getmodules()): Delete.
    	(dwfl_addr_module(long)): Delete.
    	* DwflModule.java (DwflModule(long,Dwfl)): Delete.
    	(getName()): Re-implement.
    	(lowAddress(), highAddress()): New.
    	* cni/DwflModule.cxx: Update.
    	* jni/DwflModule.cxx: Update.

commit 160578cd1f2acd44727faeb05661627b2364f3a5
Author: Andrew Cagney <cagney@redhat.com>
Date:   Tue Jun 3 16:51:42 2008 -0400

    Delete unused bias variable.
    
    frysk-sys/lib/dwfl/ChangeLog
    2008-06-03  Andrew Cagney  <cagney@redhat.com>
    
    	* DwflModule.java (bias): Delete.

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

Summary of changes:
 frysk-core/frysk/ftrace/ChangeLog     |    5 ++
 frysk-core/frysk/ftrace/Ftrace.java   |    2 +-
 frysk-core/frysk/stack/ChangeLog      |    5 ++
 frysk-core/frysk/stack/TestFrame.java |    2 +-
 frysk-sys/lib/dwfl/ChangeLog          |   15 +++++
 frysk-sys/lib/dwfl/Dwfl.java          |   94 ++++++++++++++++++---------------
 frysk-sys/lib/dwfl/DwflModule.java    |   53 ++++++++++--------
 frysk-sys/lib/dwfl/cni/Dwfl.cxx       |   54 ++-----------------
 frysk-sys/lib/dwfl/cni/DwflModule.cxx |   19 ++-----
 frysk-sys/lib/dwfl/jni/Dwfl.cxx       |   71 ++-----------------------
 frysk-sys/lib/dwfl/jni/DwflModule.cxx |   11 ----
 11 files changed, 122 insertions(+), 209 deletions(-)

First 500 lines of diff:
diff --git a/frysk-core/frysk/ftrace/ChangeLog b/frysk-core/frysk/ftrace/ChangeLog
index 2d2ec7c..4e989ef 100644
--- a/frysk-core/frysk/ftrace/ChangeLog
+++ b/frysk-core/frysk/ftrace/ChangeLog
@@ -1,3 +1,8 @@
+2008-06-03  Andrew Cagney  <cagney@redhat.com>
+
+	* Ftrace.java: Use DwflModule.getModules() and not
+	.getModulesForce.
+
 2008-06-02  Petr Machata  <pmachata@redhat.com>
 
 	* Ftrace.java, FtraceController.java, TaskTracer.java: Retract
diff --git a/frysk-core/frysk/ftrace/Ftrace.java b/frysk-core/frysk/ftrace/Ftrace.java
index d0f9dd4..adfa35a 100644
--- a/frysk-core/frysk/ftrace/Ftrace.java
+++ b/frysk-core/frysk/ftrace/Ftrace.java
@@ -607,7 +607,7 @@ public class Ftrace {
 
 	private DwflModule getModuleForFile(Task task, String path) {
 	    Dwfl dwfl = frysk.dwfl.DwflCache.getDwfl(task);
-	    DwflModule[] modules = dwfl.getModulesForce();
+	    DwflModule[] modules = dwfl.getModules();
 	    for (int i = 0; i < modules.length; ++i) {
 		String name = modules[i].getName();
 		if (name.equals(path))
diff --git a/frysk-core/frysk/stack/ChangeLog b/frysk-core/frysk/stack/ChangeLog
index 5d32375..4f95b4b 100644
--- a/frysk-core/frysk/stack/ChangeLog
+++ b/frysk-core/frysk/stack/ChangeLog
@@ -1,3 +1,8 @@
+2008-06-03  Andrew Cagney  <cagney@redhat.com>
+
+	* TestFrame.java: Use DwflModule.getModules() and not
+	.getModulesForce().
+
 2008-05-24  Andrew Cagney  <cagney@redhat.com>
 
 	* LibunwindAddressSpace.java (findProcInfo): Return
diff --git a/frysk-core/frysk/stack/TestFrame.java b/frysk-core/frysk/stack/TestFrame.java
index ee356f9..9f33b7e 100644
--- a/frysk-core/frysk/stack/TestFrame.java
+++ b/frysk-core/frysk/stack/TestFrame.java
@@ -149,7 +149,7 @@ public class TestFrame extends TestLib {
 
 	private DwflModule getModuleForFile(String path) {
 	    Dwfl dwfl = frysk.dwfl.DwflCache.getDwfl(task);
-	    DwflModule[] modules = dwfl.getModulesForce();
+	    DwflModule[] modules = dwfl.getModules();
 	    for (int i = 0; i < modules.length; ++i) {
 		String name = modules[i].getName();
 		if (name.equals(path))
diff --git a/frysk-sys/lib/dwfl/ChangeLog b/frysk-sys/lib/dwfl/ChangeLog
index 527f68b..4d4442b 100644
--- a/frysk-sys/lib/dwfl/ChangeLog
+++ b/frysk-sys/lib/dwfl/ChangeLog
@@ -1,5 +1,20 @@
 2008-06-03  Andrew Cagney  <cagney@redhat.com>
 
+	* Dwfl.java (modules, modulesArray, reportBegin, reportModule):
+	Maintain a list of modules.
+	(getModules()): Re-implement.
+	(getModule(long)): Re-implement.
+	(getModulesForce()): Delete.
+	(dwfl_getmodules()): Delete.
+	(dwfl_addr_module(long)): Delete.
+	* DwflModule.java (DwflModule(long,Dwfl)): Delete.
+	(getName()): Re-implement.
+	(lowAddress(), highAddress()): New.
+	* cni/DwflModule.cxx: Update.
+	* jni/DwflModule.cxx: Update.
+	
+	* DwflModule.java (bias): Delete.
+
 	* Dwfl.java (callbackBegin, callbackEnd): New.
 	(Dwfl(String), close()): Use.
 	* cni/Dwfl.cxx: Update.
diff --git a/frysk-sys/lib/dwfl/Dwfl.java b/frysk-sys/lib/dwfl/Dwfl.java
index 7dff8a1..676caa6 100644
--- a/frysk-sys/lib/dwfl/Dwfl.java
+++ b/frysk-sys/lib/dwfl/Dwfl.java
@@ -39,8 +39,10 @@
 
 package lib.dwfl;
 
+import java.util.LinkedHashMap;
 import java.util.LinkedList;
 import frysk.rsl.Log;
+import inua.eio.ULong;
 
 public class Dwfl {
     private static final Log fine = Log.fine(Dwfl.class);
@@ -48,8 +50,6 @@ public class Dwfl {
     private long pointer;
     private long callbacks;
 
-    private DwflModule[] modules;
-
     protected final DwarfDieFactory factory = DwarfDieFactory.getFactory();
   
     /**
@@ -79,41 +79,9 @@ public class Dwfl {
     private static native void dwflEnd(long pointer);
     private static native void callbacksEnd(long callbacks);
 
-
-    /**
-     * Get all the DwflModule objects associated with this Dwfl. Use a
-     * cached array if possible.
-     *
-     * @return an array of DwflModule.
-     */
-    public DwflModule[] getModules() {
-	if (modules == null) {
-	    dwfl_getmodules();
-	}
-	return modules;
-    }
-
-    /**
-     * Get new all the DwflModule objects associated with this
-     * Dwfl. This requests a new array from libdwfl and stores it as
-     * the cached list for return by getModules.
-     *
-     * @return an array of DwflModule.
-     */
-    public DwflModule[] getModulesForce()    {
-	dwfl_getmodules();
-	return modules;
-    }
-  
-    /**
-     * Get the DwflModule associated with an address.
-     *
-     * @return The module
-     */
-    public native DwflModule getModule(long addr);
-    
-    public DwflModule getCompliationUnitModule(DwarfDie cuDie){
-	return new DwflModule(dwfl_cumodule(cuDie.getPointer()), this);
+    public DwflModule getCompliationUnitModule(DwarfDie cuDie) {
+	long key = dwfl_cumodule(cuDie.getPointer());
+	return (DwflModule) modules.get(new Long(key));
     }
     
     private native long dwfl_cumodule(long cuDie);
@@ -186,11 +154,20 @@ public class Dwfl {
     }
   
     /**
+     * Maintain a set of known modules, it is rebuilt each time
+     * there's a report begin/end.
+     */
+    private final LinkedHashMap modules = new LinkedHashMap();
+    private DwflModule[] modulesArray;
+
+    /**
      * Start a refresh of the address map.
      */
     public void reportBegin() {
 	fine.log(this, "reportBegin");
 	reportBegin(pointer);
+	modules.clear();
+	modulesArray = null;
     }
     private static native void reportBegin(long pointer);
     /**
@@ -206,12 +183,16 @@ public class Dwfl {
      */
     public void reportModule(String moduleName, long low, long high) {
 	fine.log(this, "reportModule", moduleName, "low", low, "high", high);
-	reportModule(pointer, moduleName, low, 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));
     }
-    private static native void reportModule(long pointer, String moduleName,
+    private static native long reportModule(long pointer, String moduleName,
 					    long low, long high);
 
-
     private String name;
     private long low;
     private long high;
@@ -276,6 +257,37 @@ public class Dwfl {
 	reportEnd();
     }
 
+    /**
+     * Return all the DwflModule objects associated with this
+     * Dwfl. Use a the cached array if possible.
+     *
+     * @return an array of DwflModule.
+     */
+    public DwflModule[] getModules() {
+	if (modulesArray == null) {
+	    modulesArray = new DwflModule[modules.size()];
+	    modules.values().toArray(modulesArray);
+	}
+	return modulesArray;
+    }
+
+    /**
+     * Get the DwflModule associated with an address.
+     *
+     * @return The module
+     */
+    public DwflModule getModule(long addr) {
+	getModules();
+	for (int i = 0; i < modulesArray.length; i++) {
+	    DwflModule module = modulesArray[i];
+	    if (ULong.GE(addr, module.lowAddress())
+		&& ULong.LT(addr, module.highAddress())) {
+		return module;
+	    }
+	}
+	return null;
+    }
+
     // protected native long[] dwfl_get_modules();
     // protected native long[] dwfl_getdwarf();
     protected native long dwfl_getsrc (long addr);
@@ -283,6 +295,4 @@ public class Dwfl {
     protected native DwflDieBias dwfl_addrdie (long addr);
   
     protected native long dwfl_addrmodule (long addr);
-
-    protected native void dwfl_getmodules();
 }
diff --git a/frysk-sys/lib/dwfl/DwflModule.java b/frysk-sys/lib/dwfl/DwflModule.java
index 4e1ab2f..aca5a9d 100644
--- a/frysk-sys/lib/dwfl/DwflModule.java
+++ b/frysk-sys/lib/dwfl/DwflModule.java
@@ -1,6 +1,6 @@
 // This file is part of the program FRYSK.
 //
-// Copyright 2005, Red Hat Inc.
+// Copyright 2005, 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
@@ -44,39 +44,51 @@ import java.util.LinkedList;
 /**
  * A wrapper object around the libdwfl Dwfl_Module structure.
  */
-public class DwflModule
-{
+public class DwflModule {
 
     protected LinkedList pubNames;
     protected LinkedList symbolTable;
     
-    protected long bias;
-  
-    private long pointer;
+    private final long pointer;
+    private final Dwfl parent;
+    private final String name;
+    private final long low;
+    private final long high;
 
-    protected final Dwfl parent;
+    DwflModule(long val, Dwfl parent, String name, long low, long high) {
+	this.pointer = val;
+	this.parent = parent;
+	this.name = name;
+	this.low = low;
+	this.high = high;
+    }
 
-    protected String name;
   
     public String toString() {
 	return name + " pointer: 0x" + Long.toHexString(pointer);
     }
-    public DwflModule(long val, Dwfl parent) {
-	this(val, parent, null);
-    }
-  
-    DwflModule (long val, Dwfl parent, String name) {
-	this.pointer = val;
-	this.parent = parent;
-	this.bias = 0;
-	this.name = name;
+
+    public long lowAddress() {
+	return low;
     }
 
+    public long highAddress() {
+	return high;
+    }
 
     protected long getPointer () {
 	return pointer;
     }
 
+    /**
+     * Get the name of the module.
+     *
+     * @return the name
+     */
+    public String getName() {
+	return name;
+    }
+  
     protected Dwfl getParent () {
 	return this.parent;
     }
@@ -104,13 +116,6 @@ public class DwflModule
     private native DwarfDie offdie(long die, long offset);
 
     
-    /**
-     * Get the name of the module.
-     *
-     * @return the name
-     */
-    public native String getName();
-  
     public native void getSymbol(long address, SymbolBuilder symbolBuilder);
   
     private native ModuleElfBias module_getelf();
diff --git a/frysk-sys/lib/dwfl/cni/Dwfl.cxx b/frysk-sys/lib/dwfl/cni/Dwfl.cxx
index 006dfb9..ae6358a 100644
--- a/frysk-sys/lib/dwfl/cni/Dwfl.cxx
+++ b/frysk-sys/lib/dwfl/cni/Dwfl.cxx
@@ -173,7 +173,7 @@ lib::dwfl::Dwfl::reportEnd(jlong pointer) {
 }
 
 
-void
+jlong
 lib::dwfl::Dwfl::reportModule(jlong pointer, jstring moduleName,
 			      jlong low, jlong high) {
   jsize len = JvGetStringUTFLength(moduleName);
@@ -182,8 +182,9 @@ lib::dwfl::Dwfl::reportModule(jlong pointer, jstring moduleName,
   JvGetStringUTFRegion(moduleName, 0, len, modName);
   modName[len] = '\0';
 	
-  ::dwfl_report_module(DWFL_POINTER, modName, (::Dwarf_Addr) low, 
-		       (::Dwarf_Addr) high);  
+  return (jlong) ::dwfl_report_module(DWFL_POINTER, modName,
+				      (::Dwarf_Addr) low, 
+				      (::Dwarf_Addr) high);  
 }
 
 extern "C" int moduleCounter(Dwfl_Module *, void **, const char *,
@@ -202,43 +203,6 @@ struct ModuleAdderData
   int index;
 };
 
-extern "C" int moduleAdder(Dwfl_Module *module, void **, const char *name,
-			   Dwarf_Addr, void *arg)
-{
-  ModuleAdderData *adderData = (ModuleAdderData *)arg;
-  
-  elements(adderData->moduleArray)[adderData->index++]
-    = new lib::dwfl::DwflModule((jlong)module, adderData->dwfl, JvNewStringUTF(name));
-  return DWARF_CB_OK;
-}
-
-typedef JArray<lib::dwfl::DwflModule *> DwflModuleArray;
-void
-lib::dwfl::Dwfl::dwfl_getmodules()
-{
-  int numModules = 0;
-  
-  ::dwfl_getmodules(DWFL_POINTER, moduleCounter, &numModules, 0);
-  ModuleAdderData adderData
-    = {this,
-       (DwflModuleArray *)JvNewObjectArray(numModules,
-					   &lib::dwfl::DwflModule::class$,
-					   0),
-       0};
-  ::dwfl_getmodules(DWFL_POINTER, moduleAdder, &adderData, 0);
-  this->modules = adderData.moduleArray;
-}
-
-//jlong[]
-//lib::dwfl::Dwfl::dwfl_get_modules(){
-//	
-//}
-
-//jlong[]
-//lib::dwfl::Dwfl::dwfl_getdwarf(){
-//	
-//}
-
 jlong
 lib::dwfl::Dwfl::dwfl_getsrc(jlong addr){
   return (jlong) ::dwfl_getsrc(DWFL_POINTER, (::Dwarf_Addr) addr);
@@ -263,16 +227,6 @@ lib::dwfl::Dwfl::dwfl_addrmodule(jlong addr){
   return (jlong) ::dwfl_addrmodule(DWFL_POINTER, (Dwarf_Addr) addr);	
 }
 
-lib::dwfl::DwflModule*
-lib::dwfl::Dwfl::getModule(jlong addr)
-{
-  Dwfl_Module *module = ::dwfl_addrmodule(DWFL_POINTER, (Dwarf_Addr) addr);
-
-  if (!module)
-    return 0;
-  return new lib::dwfl::DwflModule((jlong)module, this);
-}
-
 jlong
 lib::dwfl::Dwfl::dwfl_cumodule(jlong cudie)
 {
diff --git a/frysk-sys/lib/dwfl/cni/DwflModule.cxx b/frysk-sys/lib/dwfl/cni/DwflModule.cxx
index 5a67e59..66dfc30 100644
--- a/frysk-sys/lib/dwfl/cni/DwflModule.cxx
+++ b/frysk-sys/lib/dwfl/cni/DwflModule.cxx
@@ -64,15 +64,6 @@
 
 #define DWFL_MODULE_POINTER (Dwfl_Module *) this->pointer
 
-jstring
-lib::dwfl::DwflModule::getName()
-{
-  if (!name)
-    name = JvNewStringUTF(dwfl_module_info(DWFL_MODULE_POINTER,
-					   0, 0, 0, 0, 0, 0, 0));
-  return name;
-}
-
 lib::dwfl::ModuleElfBias*
 lib::dwfl::DwflModule::module_getelf()
 {
@@ -393,10 +384,12 @@ lib::dwfl::DwflModule::getDebuginfo()
 namespace {
   struct each_pubname_context {
     lib::dwfl::DwflModule* const dwflModule;
+    lib::dwfl::Dwfl* parent;
     Dwarf_Addr const bias;
 
-    each_pubname_context(lib::dwfl::DwflModule* m, Dwarf_Addr b)
-      : dwflModule(m), bias(b)
+    each_pubname_context(lib::dwfl::DwflModule* m, lib::dwfl::Dwfl* p,
+			 Dwarf_Addr b)
+      : dwflModule(m), parent(p), bias(b)
     {}
   };
 
@@ -404,7 +397,7 @@ namespace {
   each_pubname (Dwarf *dwarf, Dwarf_Global *gl, void* data)
   {
     each_pubname_context const* context = static_cast<each_pubname_context*>(data);
-    lib::dwfl::Dwfl* dwfl = context->dwflModule->parent;
+    lib::dwfl::Dwfl* dwfl = context->parent;
 
     Dwarf_Die* die = (Dwarf_Die*)JvMalloc(sizeof(Dwarf_Die));
 
@@ -428,7 +421,7 @@ lib::dwfl::DwflModule::get_pubnames()
 
   if (dwarf != NULL)
     {
-      ::each_pubname_context ctx(this, bias);
+      ::each_pubname_context ctx(this, parent, bias);
       ::dwarf_getpubnames(dwarf, each_pubname, &ctx, 0);
     }
 }
diff --git a/frysk-sys/lib/dwfl/jni/Dwfl.cxx b/frysk-sys/lib/dwfl/jni/Dwfl.cxx
index 7cb3472..7d062b2 100644
--- a/frysk-sys/lib/dwfl/jni/Dwfl.cxx
+++ b/frysk-sys/lib/dwfl/jni/Dwfl.cxx
@@ -177,61 +177,13 @@ lib::dwfl::Dwfl::reportEnd(jnixx::env env, jlong pointer) {
 }
 
 
-void
+jlong
 lib::dwfl::Dwfl::reportModule(jnixx::env env, jlong pointer,
 			      String jmoduleName, jlong low, jlong high) {
   jstringUTFChars moduleName = jstringUTFChars(env, jmoduleName);
-  ::dwfl_report_module(DWFL_POINTER, moduleName.elements(),
-		       (::Dwarf_Addr) low, (::Dwarf_Addr) high);  
-}
-
-static int
-moduleCounter(Dwfl_Module *, void **, const char *,
-	      Dwarf_Addr, void *arg) {
-  int *iarg = (int *)arg;
-  (*iarg)++;
-  return DWARF_CB_OK;
-}
-
-typedef jnixx::array<lib::dwfl::DwflModule> DwflModuleArray;
-struct module_adder_context {
-  jnixx::env env;
-  lib::dwfl::Dwfl dwfl;
-  DwflModuleArray moduleArray;
-  int index;
-  module_adder_context(jnixx::env env, lib::dwfl::Dwfl dwfl,
-		       DwflModuleArray moduleArray) {
-    this->env = env;
-    this->dwfl = dwfl;


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


                 reply	other threads:[~2008-06-03 22:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080603222352.4635.qmail@sourceware.org \
    --to=cagney@sourceware.org \
    --cc=frysk-cvs@sourceware.org \
    --cc=frysk@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).