You are viewing a plain text version of this content. The canonical link for it is here.
Posted to kato-commits@incubator.apache.org by sp...@apache.org on 2009/06/18 12:37:15 UTC

svn commit: r786037 - in /incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.jvmti/src/main/java/org/apache/kato/jvmti: javaruntime/model/ process/ reader/

Author: spoole
Date: Thu Jun 18 12:37:14 2009
New Revision: 786037

URL: http://svn.apache.org/viewvc?rev=786037&view=rev
Log:
updated jvmti module to use new xml format

Modified:
    incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.jvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JLocalVariable.java
    incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.jvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JLocalVariableTableEntry.java
    incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.jvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JMethod.java
    incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.jvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JStackFrame.java
    incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.jvmti/src/main/java/org/apache/kato/jvmti/process/ImageImpl.java
    incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.jvmti/src/main/java/org/apache/kato/jvmti/reader/BinReader.java
    incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.jvmti/src/main/java/org/apache/kato/jvmti/reader/XMLReader.java

Modified: incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.jvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JLocalVariable.java
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.jvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JLocalVariable.java?rev=786037&r1=786036&r2=786037&view=diff
==============================================================================
--- incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.jvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JLocalVariable.java (original)
+++ incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.jvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JLocalVariable.java Thu Jun 18 12:37:14 2009
@@ -1,14 +1,66 @@
 package org.apache.kato.jvmti.javaruntime.model;
 
-public class JLocalVariable implements JValueHolder{
+import org.apache.kato.image.DataUnavailable;
+import org.apache.kato.java.JavaVariable;
+
+public class JLocalVariable implements JValueHolder,JavaVariable{
 
 	public Object value=null;
 	public int slot=0;
+	private JLocation location;
+	
 	
+	public JLocalVariable() {
+		
+	}
 	@Override
 	public void setValue(Object o) {
 		value=o;
 		
 	}
 
+	@Override
+	public int getLength() {
+		JLocalVariableTableEntry entry=location.method.getEntry(slot);
+		if(entry==null) return 0;
+		return entry.length;
+	}
+
+	@Override
+	public String getName() throws DataUnavailable {
+		
+		JLocalVariableTableEntry entry=location.method.getEntry(slot);
+		if(entry==null) return null;
+		return entry.getName();
+	}
+
+	@Override
+	public String getSignature() {
+		JLocalVariableTableEntry entry=location.method.getEntry(slot);
+		if(entry==null) return null;
+		return entry.sig;
+	}
+
+	@Override
+	public int getSlot() {
+		
+		return slot;
+	}
+
+	@Override
+	public int getStart() {
+		JLocalVariableTableEntry entry=location.method.getEntry(slot);
+		if(entry==null) return 0;
+		return entry.start;
+	}
+
+	@Override
+	public Object getValue() {
+		return value;
+	}
+	public void setLocation(JLocation loc) {
+		this.location=loc;
+		
+	}
+
 }

Modified: incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.jvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JLocalVariableTableEntry.java
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.jvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JLocalVariableTableEntry.java?rev=786037&r1=786036&r2=786037&view=diff
==============================================================================
--- incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.jvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JLocalVariableTableEntry.java (original)
+++ incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.jvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JLocalVariableTableEntry.java Thu Jun 18 12:37:14 2009
@@ -6,31 +6,35 @@
 import org.apache.kato.image.DataUnavailable;
 import org.apache.kato.java.JavaVariable;
 
-public class JLocalVariableTableEntry implements JavaVariable {
+public class JLocalVariableTableEntry  {
 
 	public String gensig;
 	public String sig;
-	public String name;
+	private String name;
 	public int slot;
 	public int length;
 	public int start;
-	@Override
+	
 	public int getLength() {
 		return length;
 	}
-	@Override
+	
+	public void setName(String n) {
+		this.name=n;
+	}
 	public String getName() throws DataUnavailable {
+		if(name==null) return "slot:"+slot;
 		return name;
 	}
-	@Override
+	
 	public String getSignature() {
 		return sig;
 	}
-	@Override
+	
 	public int getSlot() {
 		return slot;
 	}
-	@Override
+	
 	public int getStart() {
 		return start;
 	}

Modified: incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.jvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JMethod.java
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.jvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JMethod.java?rev=786037&r1=786036&r2=786037&view=diff
==============================================================================
--- incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.jvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JMethod.java (original)
+++ incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.jvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JMethod.java Thu Jun 18 12:37:14 2009
@@ -6,6 +6,7 @@
 import java.util.LinkedList;
 import java.util.List;
 
+import org.apache.kato.ObjectMapList;
 import org.apache.kato.image.CorruptDataException;
 import org.apache.kato.image.DataUnavailable;
 import org.apache.kato.java.JavaClass;
@@ -23,7 +24,7 @@
 	public int mods=0;
 	public JClass parent=null;
 	
-	private List<JLocalVariableTableEntry> localVars=null;
+	private ObjectMapList<Integer,JLocalVariableTableEntry> localVars=null;
 	public JMethod() {
 		
 	}
@@ -35,10 +36,10 @@
 
 	public void addLocalVariableTableEntry(JLocalVariableTableEntry entry) {
 		if(localVars==null) {
-			localVars=new LinkedList<JLocalVariableTableEntry>();
+			localVars=new ObjectMapList<Integer, JLocalVariableTableEntry>();
 		}
 		
-		localVars.add(entry);
+		localVars.put(entry.slot,entry);
 	}
 
 	@Override
@@ -78,9 +79,17 @@
 	@Override
 	public List getVariables() throws DataUnavailable {
 		if(localVars==null) {
-			localVars=new LinkedList<JLocalVariableTableEntry>();
+			localVars=new ObjectMapList<Integer, JLocalVariableTableEntry>();
 		}
-		return localVars;
+		return localVars.values();
+	}
+
+	public JLocalVariableTableEntry getEntry(int slot) {
+		if(localVars==null) {
+			localVars=new ObjectMapList<Integer, JLocalVariableTableEntry>();
+		}
+		return localVars.get(slot);
+			
 	}
 	
 }
\ No newline at end of file

Modified: incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.jvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JStackFrame.java
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.jvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JStackFrame.java?rev=786037&r1=786036&r2=786037&view=diff
==============================================================================
--- incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.jvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JStackFrame.java (original)
+++ incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.jvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JStackFrame.java Thu Jun 18 12:37:14 2009
@@ -12,17 +12,21 @@
 import org.apache.kato.image.ImagePointer;
 import org.apache.kato.java.JavaLocation;
 import org.apache.kato.java.JavaStackFrame;
+import org.apache.kato.java.JavaVariable;
 
 public class JStackFrame implements JavaStackFrame {
 
-	public JLocation location=null;
-	private ObjectMapList<Integer,Object> vars=new ObjectMapList<Integer, Object>();
+	private JLocation location=null;
+	private ObjectMapList<Integer,JavaVariable> vars=new ObjectMapList<Integer, JavaVariable>();
 	@Override
 	public ImagePointer getBasePointer() throws CorruptDataException {
 		
 		return new SimpleImagePointer(0);
 	}
 
+	public void setLocation(JLocation loc) {
+		this.location=loc;
+	}
 	@Override
 	public List getHeapRoots() {
 		return new LinkedList();
@@ -43,13 +47,22 @@
 		
 	}
 	
-	public void addVariable(int slot,Object value) {
-		vars.put(slot, value);
+	public void addVariable(JLocalVariable value) {
+		value.setLocation(location);
+		vars.put(value.slot, (JavaVariable) value);
 	}
 
 	@Override
-	public List getVariables() {
+	public List<JavaVariable> getVariables() {
 		
 		return vars.values();
 	}
+
+	public void addVariable(int slot, Object data) {
+		JLocalVariable var=new JLocalVariable();
+		var.slot=slot;
+		var.value=data;
+		addVariable(var);
+		
+	}
 }
\ No newline at end of file

Modified: incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.jvmti/src/main/java/org/apache/kato/jvmti/process/ImageImpl.java
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.jvmti/src/main/java/org/apache/kato/jvmti/process/ImageImpl.java?rev=786037&r1=786036&r2=786037&view=diff
==============================================================================
--- incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.jvmti/src/main/java/org/apache/kato/jvmti/process/ImageImpl.java (original)
+++ incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.jvmti/src/main/java/org/apache/kato/jvmti/process/ImageImpl.java Thu Jun 18 12:37:14 2009
@@ -21,6 +21,8 @@
 import java.util.List;
 import java.util.Properties;
 
+import javax.xml.parsers.ParserConfigurationException;
+
 import org.apache.kato.image.CorruptDataException;
 import org.apache.kato.image.DataUnavailable;
 import org.apache.kato.image.Image;
@@ -31,7 +33,9 @@
 import org.apache.kato.image.ImageThread;
 import org.apache.kato.jvmti.javaruntime.JavaRuntimeImpl;
 import org.apache.kato.jvmti.reader.BinReader;
+import org.apache.kato.jvmti.reader.XMLReader;
 import org.apache.kato.runtime.ManagedRuntime;
+import org.xml.sax.SAXException;
 
 public class ImageImpl implements Image{
 
@@ -92,7 +96,17 @@
 				if(runtimes==null) {
 					runtimes=new LinkedList<ManagedRuntime>();
 					try {
-						BinReader br=new BinReader(file);
+						//BinReader br=new BinReader(file);
+						XMLReader br=null;
+						try {
+							br = new XMLReader(file);
+						} catch (ParserConfigurationException e) {
+							// TODO Auto-generated catch block
+							e.printStackTrace();
+						} catch (SAXException e) {
+							// TODO Auto-generated catch block
+							e.printStackTrace();
+						}
 						runtimes.add(new JavaRuntimeImpl(br.getModel()));
 					} catch (IOException e) {
 						e.printStackTrace();

Modified: incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.jvmti/src/main/java/org/apache/kato/jvmti/reader/BinReader.java
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.jvmti/src/main/java/org/apache/kato/jvmti/reader/BinReader.java?rev=786037&r1=786036&r2=786037&view=diff
==============================================================================
--- incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.jvmti/src/main/java/org/apache/kato/jvmti/reader/BinReader.java (original)
+++ incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.jvmti/src/main/java/org/apache/kato/jvmti/reader/BinReader.java Thu Jun 18 12:37:14 2009
@@ -357,7 +357,7 @@
 				 entry.start=in.readInt();
 				 entry.length=in.readInt();
 				 entry.slot=in.readInt();
-				 entry.name=readName();
+				 entry.setName(readName());
 				 entry.sig=readName();
 				 entry.gensig=readName();
 				 
@@ -486,7 +486,7 @@
 		loc.linenumber=location;
 		
 		JStackFrame frame=new JStackFrame();
-		frame.location=loc;
+		frame.setLocation(loc);
 		t.addStackFrame(frame);
 		
 		if(javathis!=0) {

Modified: incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.jvmti/src/main/java/org/apache/kato/jvmti/reader/XMLReader.java
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.jvmti/src/main/java/org/apache/kato/jvmti/reader/XMLReader.java?rev=786037&r1=786036&r2=786037&view=diff
==============================================================================
--- incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.jvmti/src/main/java/org/apache/kato/jvmti/reader/XMLReader.java (original)
+++ incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.jvmti/src/main/java/org/apache/kato/jvmti/reader/XMLReader.java Thu Jun 18 12:37:14 2009
@@ -11,10 +11,12 @@
 
 import org.apache.commons.codec.binary.Base64;
 import org.apache.kato.image.CorruptDataException;
+import org.apache.kato.java.JavaVariable;
 import org.apache.kato.jvmti.javaruntime.model.JClass;
 import org.apache.kato.jvmti.javaruntime.model.JClassLoader;
 import org.apache.kato.jvmti.javaruntime.model.JField;
 import org.apache.kato.jvmti.javaruntime.model.JLocalVariable;
+import org.apache.kato.jvmti.javaruntime.model.JLocalVariableTableEntry;
 import org.apache.kato.jvmti.javaruntime.model.JLocation;
 import org.apache.kato.jvmti.javaruntime.model.JMethod;
 import org.apache.kato.jvmti.javaruntime.model.JMonitor;
@@ -116,7 +118,7 @@
 				else if(name.equals("var")) {
 					JLocalVariable var=(JLocalVariable) stack.pop(); 
 					JStackFrame parent=(JStackFrame) stack.peek();
-					parent.addVariable(var.slot,var.value);
+					parent.addVariable( var);
 					
 				}
 				else if(name.equals("instance")) {
@@ -232,6 +234,11 @@
 				loadLocalVariable(attributes);
 				
 			}
+			else if(name.equals("vardef")) {
+				loadLocalVariableDefinition(attributes);
+				
+			}
+			
 			else if(name.equals("threadgroup")) {
 				loadThreadGroup(attributes);
 				
@@ -239,6 +246,18 @@
 			
 			
 		}
+		private void loadLocalVariableDefinition(Attributes attributes) {
+			// <vardef sig="Ljava/lang/InterruptedException;" start="27" length="0" slot="3"/>
+			JLocalVariableTableEntry entry=new JLocalVariableTableEntry();
+			entry.sig=getString(attributes, "sig");
+			entry.start=getInteger(attributes, "start");
+			entry.length=getInteger(attributes, "length");
+			entry.setName(getString(attributes, "name"));
+			
+			JMethod parent=(JMethod) stack.peek();
+			parent.addLocalVariableTableEntry(entry);
+			
+		}
 		private void loadInstanceField(Attributes attributes) {
 			
 			// parent should be JObject
@@ -508,7 +527,7 @@
 			JLocation location=new JLocation();
 			location.method=model.getMethod(mid);
 			location.linenumber=loc;
-			frame.location=location;
+			frame.setLocation(location);
 			
 			parent.addStackFrame(frame);
 			
@@ -641,6 +660,10 @@
 
 	}
 
+	public Model getModel() {
+		return model;
+	}
+
 	
 	
 }