incubator-kato-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spo...@apache.org
Subject svn commit: r784411 [3/3] - in /incubator/kato/branches/experimental/PyJVMTI: ./ ibmtomcat.sh init.py kato.xml kato/BinDump.py kato/JStackFrame.py kato/XMLDump.py kato/console.py pyjvmti.c pyjvmti.h pyjvmti_convert.h tomcat.sh
Date Sat, 13 Jun 2009 15:56:55 GMT
Modified: incubator/kato/branches/experimental/PyJVMTI/kato/BinDump.py
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/PyJVMTI/kato/BinDump.py?rev=784411&r1=784410&r2=784411&view=diff
==============================================================================
--- incubator/kato/branches/experimental/PyJVMTI/kato/BinDump.py (original)
+++ incubator/kato/branches/experimental/PyJVMTI/kato/BinDump.py Sat Jun 13 15:56:55 2009
@@ -148,8 +148,11 @@
             
             
             javathis=self.getThis(thread.threadid,depth)
-            self.trace("javathis = %d " % javathis)
-            self.objectlist.add(javathis)
+            if javathis!=0 :
+                clazzid=jvmti.getObjectClass(javathis)
+                clazz=JClass.JClass(clazzid)
+                self.trace("javathis = %d %s" % (javathis,clazz.signature))
+                self.objectlist.add(javathis)
             
             header=struct.pack("!iiii",methodid,locationid,javathis,count)
             self.output.write(header)
@@ -576,7 +579,7 @@
         '''
         Save all remembered objects
         '''
-        self.objectlist.remove(0)
+        
         
         objectcount=len(self.objectlist)
         if objectcount==0 :  return  # nothing to do
@@ -643,6 +646,7 @@
                 self.output.write(header)
           elif signature=='[C' :
                  arraylen=0
+                 chararray=[]
                  if value != 0 :
                      chararray=jvmti.getCharArrayElements(value)
                      arraylen=len(chararray)

Added: incubator/kato/branches/experimental/PyJVMTI/kato/JStackFrame.py
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/PyJVMTI/kato/JStackFrame.py?rev=784411&view=auto
==============================================================================
--- incubator/kato/branches/experimental/PyJVMTI/kato/JStackFrame.py (added)
+++ incubator/kato/branches/experimental/PyJVMTI/kato/JStackFrame.py Sat Jun 13 15:56:55 2009
@@ -0,0 +1,51 @@
+#*******************************************************************************
+ #* Licensed under the Apache License, Version 2.0 (the "License");
+ #* you may not use this file except in compliance with the License.
+ #* You may obtain a copy of the License at
+ #* 
+ #*   http://www.apache.org/licenses/LICENSE-2.0
+ #* 
+ #* Unless required by applicable law or agreed to in writing, software
+ #* distributed under the License is distributed on an "AS IS" BASIS,
+ #* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ #* See the License for the specific language governing permissions and
+ #* limitations under the License.
+ #******************************************************************************"
+
+import kato.JMethod as JMethod
+import jvmti
+
+class JStackFrame(object):
+
+    thread=None
+    methodID=None
+    locationID=None
+    depth=0
+    
+    def __init__(self,t,frame,d):
+
+        self.thread=t;
+        self.methodID=frame[0]
+        self.locationID=frame[1]
+        self.depth=d
+        
+    @property
+    def location(self):
+        if self.locationID is None :
+            return -1
+        return self.locationID
+    
+    @property
+    def method(self):
+        return JMethod.JMethod(self.methodID)
+    
+    @property        
+    def this(self):
+        
+        try : 
+            javathis= jvmti.getLocalObject(self.thread.threadid,self.depth,0)
+            thisclass=jvmti.getObjectClass(javathis)
+            return javathis
+        except jvmti.error :
+            return 0
+        
\ No newline at end of file

Added: incubator/kato/branches/experimental/PyJVMTI/kato/XMLDump.py
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/PyJVMTI/kato/XMLDump.py?rev=784411&view=auto
==============================================================================
--- incubator/kato/branches/experimental/PyJVMTI/kato/XMLDump.py (added)
+++ incubator/kato/branches/experimental/PyJVMTI/kato/XMLDump.py Sat Jun 13 15:56:55 2009
@@ -0,0 +1,954 @@
+ #*******************************************************************************
+ #* Licensed under the Apache License, Version 2.0 (the "License");
+ #* you may not use this file except in compliance with the License.
+ #* You may obtain a copy of the License at
+ #* 
+ #*   http://www.apache.org/licenses/LICENSE-2.0
+ #* 
+ #* Unless required by applicable law or agreed to in writing, software
+ #* distributed under the License is distributed on an "AS IS" BASIS,
+ #* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ #* See the License for the specific language governing permissions and
+ #* limitations under the License.
+ #******************************************************************************"
+
+from kato.JField import *
+from kato.JClass import *
+from kato.JThreadGroup import *
+from kato.JThread import *
+from kato.JStackFrame import *
+from kato.JMethod import *
+
+import jvmti
+import base64
+import array
+
+methods=set()
+classes=set()
+
+def katodump(filename="kato.xml"):
+    '''
+    dump to provided file in XML format
+    '''
+    methods=set()
+    classes=set()
+    kml=open(filename,"w")
+    
+    # write xml header
+    writeHeader(kml)
+    
+    saveThreads(kml)
+    
+    saveThreadGroups(kml)
+        
+    writeTrailer(kml)
+    
+    kml.close()
+    
+    
+def saveThreadGroups(kml):
+    
+     groups=jvmti.getTopThreadGroups()
+     for group in groups :
+         g=JThreadGroup(group)
+         saveThreadGroup(kml,g)
+         
+def saveThreadGroup(kml,group):
+    '''
+    Saves a JThreadGroup to file
+    '''
+    parentgroup=group.parentThreadGroupID;
+    if parentgroup==None : parentgroup=0
+    kml.write('<threadgroup id="%d" parent="%d" maxpriority="%d" isdaemon="%d">\n' % (group.threadid ,parentgroup,group.maxpriority,group.isdaemon ) )    
+    kml.write("</threadgroup>\n")   
+                   
+def saveThreads(kml):
+    threads=jvmti.getAllThreads()
+    
+    for thread in threads :
+        t=JThread(thread)
+        saveThread(kml,t)
+    
+def saveClass(kml,classid):
+    '''
+    save class
+    '''
+    
+
+    if classid in classes :
+        return
+    
+
+    classes.add(classid)
+    clazz=JClass(classid)
+    
+    
+    print "saving  class %s (%d)" % (clazz.signature , classid )
+    
+    kml.write('<class id="%d" loader="%d" name="%s" > \n' % (clazz.classid,clazz.classloader, clazz.signature))
+    
+    for f in clazz.fields :
+        field=JField(clazz,f)
+        if field.isStatic : saveStaticField(kml,clazz,field)
+            
+    kml.write("</class>\n")
+    return clazz;
+
+    
+def saveInstance(kml,classid,objid):
+    '''
+    save instance
+    '''
+    clazz= saveClass(kml,classid)    
+    
+    
+    print "saving  instance "
+    
+    kml.write('<instance classid="%d" id="%d"> \n' % (classid,objid))
+    
+    for f in clazz.fields :
+        field=JField(clazz,f)
+        if field.isStatic is False  : saveInstanceField(kml,field,objid)
+            
+    kml.write("</class>\n")
+    
+ 
+
+def saveStaticField(kml,clazz,field):
+    
+        print "saving static field %s in clazz %s " % (field.name ,clazz.signature) 
+        kml.write('<field static="true" signature="%s" name="%s">\n'  % (field.signature, field.name) )
+        
+        signature=field.signature
+        
+        try :
+         
+            if signature=='Z' :
+                value=jvmti.getStaticBooleanField(clazz.classid,field.fieldid)
+                kml.write('<data value="%d"/>\n' % value)
+            
+            elif signature=='C' :
+                value=jvmti.getStaticCharField(clazz.classid,field.fieldid)
+                kml.write('<data value="%c"/>\n' % value)
+                
+            elif signature=='I' :
+                value=jvmti.getStaticIntField(clazz.classid,field.fieldid)
+                kml.write('<data value="%d"/>\n' % value)
+            
+            elif signature=='B' :
+                value=jvmti.getStaticByteField(clazz.classid,field.fieldid)
+                kml.write('<data value="%d"/>\n' % value)
+            
+            elif signature=='S' :
+                value=jvmti.getStaticShortField(clazz.classid,field.fieldid)
+                kml.write('<data value="%d"/>\n' % value)
+            
+            elif signature=='J' :
+                value=jvmti.getStaticLongField(clazz.classid,field.fieldid)
+                kml.write('<data value="%d"/>\n' % value)
+            
+            elif signature=='F' :
+                value=jvmti.getStaticFloatField(clazz.classid,field.fieldid)
+                kml.write('<data value="%f"/>\n' % value)
+            
+            elif signature=='D' :
+                value=jvmti.getStaticDoubleField(clazz.classid,field.fieldid)
+                kml.write('<data value="%d"/>\n' % value)
+            
+            elif signature=='Ljava/lang/String;' :
+                objvalue=jvmti.getStaticObjectField(clazz.classid,field.fieldid)
+                if objvalue == 0 :
+                    kml.write('<data nullvalue="true"/>\n')
+                else :
+                    string=jvmti.getStringUTFChars(objvalue)
+                    kml.write('<data value="%s"/>\n' % string)
+                
+                
+            elif signature=='[C' :
+                 
+                  
+                 objvalue=jvmti.getStaticObjectField(clazz.classid,field.fieldid)
+                 chararray=jvmti.getCharArrayElements(objvalue)
+                 arraylen=len(chararray)
+                 kml.write('<data ref="%d" length="%d">\n' % (objvalue,arraylen))
+                 
+                 data=array.array('c')
+                 
+                 for element in chararray :
+                     data.append(element)
+                 
+                 kml.write("<![CDATA[%s]]>\n" % base64.b64encode(data.tostring()))
+                     
+                 kml.write("</data>\n")
+                     
+             
+            elif signature=='[I' :
+                 objvalue=jvmti.getStaticObjectField(clazz.classid,field.fieldid)
+                 intarray=jvmti.getIntArrayElements(objvalue)
+                 arraylen=len(intarray)
+                 
+                 kml.write('<data ref="%d" length="%d">\n' % (objvalue,arraylen))
+                 
+                 data=array.array('i')
+                 
+                 for element in intarray :
+                     data.append(element)
+                 
+                 kml.write("<![CDATA[%s]]>\n" % base64.b64encode(data.tostring()))
+                     
+                 kml.write("</data>\n")
+                 
+            
+            elif signature=='[B' :
+                 objvalue=jvmti.getStaticObjectField(clazz.classid,field.fieldid)
+                 barray=jvmti.getByteArrayElements(objvalue)
+                 arraylen=len(barray)
+                 
+                 kml.write('<data ref="%d" length="%d">\n' % (objvalue,arraylen))
+                 
+                 data=array.array('b')
+                 
+                 for element in barray :
+                     data.append(element)
+                 
+                 kml.write("<![CDATA[%s]]>\n" % base64.b64encode(data.tostring()))
+                     
+                 kml.write("</data>\n")
+                 
+            elif signature=='[Z' :
+                 objvalue=jvmti.getStaticObjectField(clazz.classid,field.fieldid)
+                 barray=jvmti.getBooleanArrayElements(objvalue)
+                 arraylen=len(barray)
+                 
+                 kml.write('<data ref="%d" length="%d">\n' % (objvalue,arraylen))
+                 
+                 data=array.array('b')
+                 
+                 for element in barray :
+                     data.append(element)
+                 
+                 kml.write("<![CDATA[%s]]>\n" % base64.b64encode(data.tostring()))
+                     
+                 kml.write("</data>\n")     
+                
+            elif signature=='[S' :
+                 objvalue=jvmti.getStaticObjectField(clazz.classid,field.fieldid)
+                 sarray=jvmti.getShortArrayElements(objvalue)
+                 arraylen=len(sarray)
+                 kml.write('<data ref="%d" length="%d">\n' % (objvalue,arraylen))
+                 
+                 data=array.array('h')
+                 
+                 for element in sarray :
+                     data.append(element)
+                 
+                 kml.write("<![CDATA[%s]]>\n" % base64.b64encode(data.tostring()))
+                     
+                 kml.write("</data>\n")
+                 
+                 
+                 
+            elif signature=='[J' :
+                 objvalue=jvmti.getStaticObjectField(clazz.classid,field.fieldid)
+                 larray=jvmti.getLongArrayElements(objvalue)
+                 arraylen=len(larray)
+                 kml.write('<data ref="%d" length="%d">\n' % (objvalue,arraylen))
+                 
+                 data=array.array('l')
+                 
+                 for element in larray :
+                     data.append(element)
+                 
+                 kml.write("<![CDATA[%s]]>\n" % base64.b64encode(data.tostring()))
+                     
+                 kml.write("</data>\n")
+                 
+         
+            
+            elif signature=='[F' :
+                 objvalue=jvmti.getStaticObjectField(clazz.classid,field.fieldid)
+                 farray=jvmti.getFloatArrayElements(objvalue)
+                 arraylen=len(farray)
+                 kml.write('<data ref="%d" length="%d">\n' % (objvalue,arraylen))
+                 
+                 data=array.array('f')
+                 
+                 for element in farray :
+                     data.append(element)
+                 
+                 kml.write("<![CDATA[%s]]>\n" % base64.b64encode(data.tostring()))
+                     
+                 kml.write("</data>\n")
+                 
+                 
+            
+            elif signature=='[D' :
+                 objvalue=jvmti.getStaticObjectField(clazz.classid,field.fieldid)
+                 darray=jvmti.getDoubleArrayElements(objvalue)
+                 arraylen=len(darray)
+                 kml.write('<data ref="%d" length="%d">\n' % (objvalue,arraylen))
+                 
+                 data=array.array('d')
+                 
+                 for element in darray :
+                     data.append(element)
+                 
+                 kml.write("<![CDATA[%s]]>\n" % base64.b64encode(data.tostring()))
+                     
+                 kml.write("</data>\n")
+                 
+            elif signature=='[Ljava/lang/String;' :
+                
+                kml.write('<skipping sig="%s"/></field>\n' % signature)
+                return 
+                objvalue=jvmti.getStaticObjectField(clazz.classid,field.fieldid)
+                if objvalue==0 : 
+                    arraylen=0
+                   
+                else :
+                    arraylen=jvmti.getArrayLength(objvalue)
+                
+                kml.write('<data ref="%d" length="%d">\n' % (objvalue,arraylen))
+                
+                if arraylen > 0 :
+                    for i in range (0 ,arraylen)  :
+                        elementID=jvmti.getObjectArrayElement(objvalue,i)
+                        string=jvmti.getStringUTFChars(elementID)
+                        kml.write('<entry id="%d" value="%s"/>' % (elementID,string))
+                        
+                kml.write("</data>\n")
+                
+                
+            elif signature[0]=='[' :
+                kml.write('<skipping sig="%s"/></field>\n' % signature)
+                return 
+                objvalue=jvmti.getStaticObjectField(clazz.classid,field.fieldid)
+                if objvalue==0 : 
+                    arraylen=0
+                    
+                else :
+                    arraylen=jvmti.getArrayLength(objvalue)
+                
+                kml.write('<data ref="%d" length="%d">\n' % (objvalue,arraylen))
+                if arraylen > 0 :
+                    data=array.array('i')
+                    for i in range (0 ,arraylen)  :
+                        elementID=jvmti.getObjectArrayElement(objvalue,i)
+                        data.append(elementID)
+                    kml.write("<![CDATA[%s]]>\n" % base64.b64encode(data.tostring()))
+                        
+                kml.write("</data>\n")
+                
+            else :
+                kml.write('<skipping sig="%s"/></field>\n' % signature)
+                return 
+                objvalue=jvmti.getStaticObjectField(clazz.classid,field.fieldid)
+                
+                clazzid=0
+                if objvalue!=0 :
+                    clazzid=jvmti.getObjectClass(objvalue)
+                    saveClass(kml,clazzid)
+
+                kml.write('<data classid="%d" object="%d">\n' % (clazzid,objvalue))
+                kml.write("</data>\n")
+                
+        except jvmti.error :
+                
+               print "err..." , jvmti.error , signature
+          
+  
+        
+        kml.write('</field>\n')
+        
+def saveInstanceField(kml,field,objectid):
+    
+    print "saving instance field %s  " % (field.name) 
+    kml.write('<field  signature="%s" name="%s"/>\n' % (field.signature, field.name) )
+    signature=field.signature
+        
+    try :
+         
+            if signature=='Z' :
+                value=jvmti.getBooleanField(field.fieldid,objectid)
+                kml.write('<data value="%d"/>\n' % value)
+            
+            elif signature=='C' :
+                value=jvmti.getCharField(field.fieldid,objectid)
+                kml.write('<data value="%c"/>\n' % value)
+                
+            elif signature=='I' :
+                value=jvmti.getIntField(field.fieldid,objectid)
+                kml.write('<data value="%d"/>\n' % value)
+            
+            elif signature=='B' :
+                value=jvmti.getByteField(field.fieldid,objectid)
+                kml.write('<data value="%d"/>\n' % value)
+            
+            elif signature=='S' :
+                value=jvmti.getShortField(field.fieldid,objectid)
+                kml.write('<data value="%d"/>\n' % value)
+            
+            elif signature=='J' :
+                value=jvmti.getLongField(field.fieldid,objectid)
+                kml.write('<data value="%d"/>\n' % value)
+            
+            elif signature=='F' :
+                value=jvmti.getFloatField(field.fieldid,objectid)
+                kml.write('<data value="%f"/>\n' % value)
+            
+            elif signature=='D' :
+                value=jvmti.getDoubleField(field.fieldid,objectid)
+                kml.write('<data value="%d"/>\n' % value)
+            
+            elif signature=='Ljava/lang/String;' :
+                objvalue=jvmti.getObjectField(field.fieldid,objectid)
+                if objvalue == 0 :
+                    kml.write('<null/>\n')
+                else :
+                    string=jvmti.getStringUTFChars(objvalue)
+                    kml.write('<data value="%s"/>\n' % string)
+                
+                
+            elif signature=='[C' :
+                 
+                  
+                 objvalue=jvmti.getObjectField(field.fieldid,objectid)
+                 if objvalue == 0 :
+                     kml.write('<null/>\n')
+                 else :
+                 
+                     chararray=jvmti.getCharArrayElements(objvalue)
+                     arraylen=len(chararray)
+                     kml.write('<data ref="%d" length="%d">\n' % (objvalue,arraylen))
+                 
+                     data=array.array('c')
+                 
+                     for element in chararray :
+                         data.append(element)
+                 
+                     kml.write("<![CDATA[%s]]>\n" % base64.b64encode(data.tostring()))
+                     
+                 kml.write("</data>\n")
+                     
+             
+            elif signature=='[I' :
+                 objvalue=jvmti.getObjectField(field.fieldid,objectid)
+                 if objvalue == 0 :
+                     kml.write('<null/>\n')
+                 else :
+                     intarray=jvmti.getIntArrayElements(objvalue)
+                     arraylen=len(intarray)
+                 
+                     kml.write('<data ref="%d" length="%d">\n' % (objvalue,arraylen))
+                 
+                     data=array.array('i')
+                 
+                     for element in intarray :
+                         data.append(element)
+                 
+                     kml.write("<![CDATA[%s]]>\n" % base64.b64encode(data.tostring()))
+                     
+                 kml.write("</data>\n")
+                 
+            
+            elif signature=='[B' :
+                 objvalue=jvmti.getObjectField(field.fieldid,objectid)
+                 if objvalue == 0 :
+                     kml.write('<null/>\n')
+                 else :
+                     barray=jvmti.getByteArrayElements(objvalue)
+                     arraylen=len(barray)
+                 
+                     kml.write('<data ref="%d" length="%d">\n' % (objvalue,arraylen))
+                 
+                     data=array.array('b')
+                 
+                     for element in barray :
+                         data.append(element)
+                 
+                     kml.write("<![CDATA[%s]]>\n" % base64.b64encode(data.tostring()))
+                     
+                 kml.write("</data>\n")
+                 
+            elif signature=='[Z' :
+                 objvalue=jvmti.getObjectField(field.fieldid,objectid)
+                 if objvalue == 0 :
+                     kml.write('<null/>\n')
+                 else :
+                 
+                     barray=jvmti.getBooleanArrayElements(objvalue)
+                     arraylen=len(barray)
+                 
+                     kml.write('<data ref="%d" length="%d">\n' % (objvalue,arraylen))
+                 
+                     data=array.array('b')
+                 
+                     for element in barray :
+                         data.append(element)
+                 
+                     kml.write("<![CDATA[%s]]>\n" % base64.b64encode(data.tostring()))
+                     
+                 kml.write("</data>\n")     
+                
+            elif signature=='[S' :
+                 objvalue=jvmti.getObjectField(field.fieldid,objectid)
+                 if objvalue == 0 :
+                     kml.write('<null/>\n')
+                 else :
+                     sarray=jvmti.getShortArrayElements(objvalue)
+                     arraylen=len(sarray)
+                     kml.write('<data ref="%d" length="%d">\n' % (objvalue,arraylen))
+                 
+                     data=array.array('h')
+                 
+                     for element in sarray :
+                         data.append(element)
+                 
+                     kml.write("<![CDATA[%s]]>\n" % base64.b64encode(data.tostring()))
+                     
+                 kml.write("</data>\n")
+                 
+                 
+                 
+            elif signature=='[J' :
+                 objvalue=jvmti.getObjectField(field.fieldid,objectid)
+                 if objvalue == 0 :
+                     kml.write('<null/>\n')
+                 else :
+                     larray=jvmti.getLongArrayElements(objvalue)
+                     arraylen=len(larray)
+                     kml.write('<data ref="%d" length="%d">\n' % (objvalue,arraylen))
+                 
+                     data=array.array('l')
+                 
+                     for element in larray :
+                         data.append(element)
+                 
+                     kml.write("<![CDATA[%s]]>\n" % base64.b64encode(data.tostring()))
+                     
+                 kml.write("</data>\n")
+                 
+         
+            
+            elif signature=='[F' :
+                 objvalue=jvmti.getObjectField(field.fieldid,objectid)
+                 if objvalue == 0 :
+                     kml.write('<null/>\n')
+                 else :
+                 
+                     farray=jvmti.getFloatArrayElements(objvalue)
+                     arraylen=len(farray)
+                     kml.write('<data ref="%d" length="%d">\n' % (objvalue,arraylen))
+                 
+                     data=array.array('f')
+                 
+                     for element in farray :
+                         data.append(element)
+                 
+                         kml.write("<![CDATA[%s]]>\n" % base64.b64encode(data.tostring()))
+                     
+                 kml.write("</data>\n")
+                 
+                 
+            
+            elif signature=='[D' :
+                 objvalue=jvmti.getObjectField(field.fieldid,objectid)
+                 if objvalue == 0 :
+                     kml.write('<null/>\n')
+                 else :
+                 
+                     darray=jvmti.getDoubleArrayElements(objvalue)
+                     arraylen=len(darray)
+                     kml.write('<data ref="%d" length="%d">\n' % (objvalue,arraylen))
+                 
+                     data=array.array('d')
+                 
+                     for element in darray :
+                         data.append(element)
+                 
+                     kml.write("<![CDATA[%s]]>\n" % base64.b64encode(data.tostring()))
+                     
+                 kml.write("</data>\n")
+                 
+            elif signature=='[Ljava/lang/String;' :
+                
+                kml.write('<skipping sig="%s"/></field>\n' % signature)
+                return 
+                objvalue=jvmti.getObjectField(field.fieldid,objectid)
+                if objvalue==0 : 
+                    arraylen=0
+                   
+                else :
+                    arraylen=jvmti.getArrayLength(objvalue)
+                
+                kml.write('<data ref="%d" length="%d">\n' % (objvalue,arraylen))
+                
+                if arraylen > 0 :
+                    for i in range (0 ,arraylen)  :
+                        elementID=jvmti.getObjectArrayElement(objvalue,i)
+                        if elementID==0 :
+                                kml.write('<null/>\n')
+                        else :
+                            string=jvmti.getStringUTFChars(elementID)
+                            kml.write('<entry id="%d" value="%s"/>' % (elementID,string))
+                        
+                kml.write("</data>\n")
+                
+                
+            elif signature[0]=='[' :
+                kml.write('<skipping sig="%s"/></field>\n' % signature)
+                return 
+                objvalue=jvmti.getObjectField(field.fieldid,objectid)
+                if objvalue==0 : 
+                    arraylen=0
+                    
+                else :
+                    arraylen=jvmti.getArrayLength(objvalue)
+                
+                kml.write('<data ref="%d" length="%d">\n' % (objvalue,arraylen))
+                if arraylen > 0 :
+                    data=array.array('i')
+                    for i in range (0 ,arraylen)  :
+                        elementID=jvmti.getObjectArrayElement(objvalue,i)
+                        data.append(elementID)
+                    kml.write("<![CDATA[%s]]>\n" % base64.b64encode(data.tostring()))
+                        
+                kml.write("</data>\n")
+                
+            else :
+                kml.write('<skipping sig="%s"/></field>\n' % signature)
+                return 
+                objvalue=jvmti.getObjectField(field.fieldid,objectid)
+                
+                clazzid=0
+                if objvalue!=0 :
+                    clazzid=jvmti.getObjectClass(objvalue)
+                    saveClass(kml,clazzid)
+
+                kml.write('<data classid="%d" object="%d">\n' % (clazzid,objvalue))
+                kml.write("</data>\n")
+                
+    except jvmti.error :
+                
+               print "err..." , jvmti.error , signature
+  
+    kml.write('</field>\n')
+     
+def saveThread(kml,thread):
+    '''
+    Saves JThread to output file
+    '''
+    
+    kml.write('<thread id="%d" name="%s" priority="%d" isdaemon="%d" threadgroup="%d" contendedmonitor="%d">\n' % (thread.threadid,thread.name,thread.priority,thread.isDaemon,thread.threadGroupID,thread.contendedMonitor))
+    
+    saveMonitors(kml,thread)
+    
+    saveStackTrace(kml,thread)
+    
+    kml.write("</thread>\n")
+    
+def saveMonitors(kml,thread):
+    
+    
+    for monitor in thread.ownedMonitorIDs :
+        kml.write('<monitor id="%d"/>\n' % monitor )
+    
+def saveStackTrace(kml,thread):
+    
+    depth=0
+    
+    for frame in thread.stacktrace :
+            f=JStackFrame(thread,frame,depth)
+            saveStackFrame(kml,thread.threadid,f,depth)
+            depth=depth+1
+    
+def saveStackFrame(kml,threadid,frame,depth):
+    
+        this=frame.this
+      
+        writeMethod(kml,frame.method)
+        
+        
+        kml.write('<frame this="%d" methodid="%d" location="%d">\n' % (this,frame.methodID,frame.locationID))
+        method=frame.method
+        
+        
+        
+        localvars=method.localVariableTable
+        
+        for entry in localvars :
+            
+            if inRange(entry,frame.location) :
+                saveVariable(kml,entry,threadid,depth)
+                
+        kml.write("</frame>\n")
+        
+
+    
+def inRange(entry,loc): 
+    
+    if loc == -1 : return False
+    
+    start=entry.start   # where the variable starts
+    end=start+entry.length # where it ends
+    
+    if loc >= start and loc <= end : return True
+    
+    return False
+    
+def writeMethod(kml,method):
+    
+        if method.methodid  in methods :
+            return
+        
+        methods.add(method.methodid)
+        
+        
+        kml.write('<method id="%d" name="%s" sig="%s" maxlocals="%d">\n' % (method.methodid,method.name,method.signature,method.maxlocals))
+        
+        localvars=method.localVariableTable
+        
+        for var in localvars :
+             #LocalVariableTableEntry
+             kml.write('<var sig="%s" start="%d" length="%d" slot="%d"/>\n' % (var.signature,var.start,var.length,var.slot))
+        
+        
+        
+        kml.write("</method>\n")
+        
+def writeHeader(kml):
+    kml.write("<kato>\n")
+
+def writeTrailer(kml):
+    kml.write("</kato>")
+    
+def saveVariable(kml,entry,threadid,depth):
+     signature=entry.signature
+     print "saving var " , signature
+     
+     
+     try :
+         
+            if signature=='Z' :
+                boolvalue=jvmti.getLocalInt(threadid,depth,entry.slot)
+                kml.write('<localvar slot="%d" value="%d"/>\n' % (entry.slot,boolvalue))
+            
+            elif signature=='C' :
+                charvalue=jvmti.getLocalInt(threadid,depth,entry.slot)
+                kml.write('<localvar slot="%d" value="%c"/>\n' % (entry.slot,charvalue))
+                
+            elif signature=='I' :
+                intvalue=jvmti.getLocalInt(threadid,depth,entry.slot)
+                kml.write('<localvar slot="%d" value="%d"/>\n' % (entry.slot,intvalue))
+            
+            elif signature=='B' :
+                bytevalue=jvmti.getLocalInt(threadid,depth,entry.slot)
+                kml.write('<localvar slot="%d" value="%d"/>\n' % (entry.slot,bytevalue))
+            
+            elif signature=='S' :
+                shortvalue=jvmti.getLocalInt(threadid,depth,entry.slot)
+                kml.write('<localvar slot="%d" value="%d"/>\n' % (entry.slot,shortvalue))
+            
+            elif signature=='J' :
+                longvalue=jvmti.getLocalLong(threadid,depth,entry.slot)
+                kml.write('<localvar slot="%d" value="%d"/>\n' % (entry.slot,longvalue))
+            
+            elif signature=='Ljava/lang/String;' :
+                objvalue=jvmti.getLocalObject(threadid,depth,entry.slot)
+                if objvalue==0 :
+                    kml.write('<localvar slot="%d" nullvalue="true"/>\n' % entry.slot)
+                else :
+                    string=jvmti.getStringUTFChars(objvalue)
+                    kml.write('<localvar slot="%d" value="%s"/>\n' % (entry.slot,string))
+                
+            elif signature=='[C' :
+                 
+                  
+                 objvalue=jvmti.getLocalObject(threadid,depth,entry.slot)
+                 chararray=jvmti.getCharArrayElements(objvalue)
+                 arraylen=len(chararray)
+                 kml.write('<localvar slot="%d" ref="%d" length="%d">\n' % (entry.slot,objvalue,arraylen))
+                
+                 
+                 data=array.array('c')
+                 
+                 for element in chararray :
+                     data.append(element)
+                 
+                 kml.write("<![CDATA[%s]]>\n" % base64.b64encode(data.tostring()))
+                     
+                 kml.write("</localvar>\n")
+                     
+             
+            elif signature=='[I' :
+                 objvalue=jvmti.getLocalObject(threadid,depth,entry.slot)
+                 intarray=jvmti.getIntArrayElements(objvalue)
+                 arraylen=len(intarray)
+                 
+                 kml.write('<localvar slot="%d" ref="%d" length="%d">\n' % (entry.slot,objvalue,arraylen))
+                 
+                 data=array.array('i')
+                 
+                 for element in intarray :
+                     data.append(element)
+                 
+                 kml.write("<![CDATA[%s]]>\n" % base64.b64encode(data.tostring()))
+                     
+                 kml.write("</localvar>\n")
+                 
+            
+            elif signature=='[B' :
+                 objvalue=jvmti.getLocalObject(threadid,depth,entry.slot)
+                 barray=jvmti.getByteArrayElements(objvalue)
+                 arraylen=len(barray)
+                 
+                 kml.write('<localvar slot="%d" ref="%d" length="%d">\n' % (entry.slot,objvalue,arraylen))
+                 
+                 data=array.array('b')
+                 
+                 for element in barray :
+                     data.append(element)
+                 
+                 kml.write("<![CDATA[%s]]>\n" % base64.b64encode(data.tostring()))
+                     
+                 kml.write("</localvar>\n")
+                 
+            elif signature=='[Z' :
+                 objvalue=jvmti.getLocalObject(threadid,depth,entry.slot)
+                 barray=jvmti.getBooleanArrayElements(objvalue)
+                 arraylen=len(barray)
+                 
+                 kml.write('<localvar slot="%d" ref="%d" length="%d">\n' % (entry.slot,objvalue,arraylen))
+                 
+                 data=array.array('b')
+                 
+                 for element in barray :
+                     data.append(element)
+                 
+                 kml.write("<![CDATA[%s]]>\n" % base64.b64encode(data.tostring()))
+                     
+                 kml.write("</localvar>\n")     
+                
+            elif signature=='[S' :
+                 objvalue=jvmti.getLocalObject(threadid,depth,entry.slot)
+                 sarray=jvmti.getShortArrayElements(objvalue)
+                 arraylen=len(sarray)
+                 kml.write('<localvar slot="%d" ref="%d" length="%d">\n' % (entry.slot,objvalue,arraylen))
+                 
+                 data=array.array('h')
+                 
+                 for element in sarray :
+                     data.append(element)
+                 
+                 kml.write("<![CDATA[%s]]>\n" % base64.b64encode(data.tostring()))
+                     
+                 kml.write("</localvar>\n")
+                 
+                 
+                 
+            elif signature=='[J' :
+                 objvalue=jvmti.getLocalObject(threadid,depth,entry.slot)
+                 larray=jvmti.getLongArrayElements(objvalue)
+                 arraylen=len(larray)
+                 kml.write('<localvar slot="%d" ref="%d" length="%d">\n' % (entry.slot,objvalue,arraylen))
+                 
+                 data=array.array('l')
+                 
+                 for element in larray :
+                     data.append(element)
+                 
+                 kml.write("<![CDATA[%s]]>\n" % base64.b64encode(data.tostring()))
+                     
+                 kml.write("</localvar>\n")
+                 
+         
+            
+            elif signature=='[F' :
+                 objvalue=jvmti.getLocalObject(threadid,depth,entry.slot)
+                 farray=jvmti.getFloatArrayElements(objvalue)
+                 arraylen=len(farray)
+                 kml.write('<localvar slot="%d" ref="%d" length="%d">\n' % (entry.slot,objvalue,arraylen))
+                 
+                 data=array.array('f')
+                 
+                 for element in farray :
+                     data.append(element)
+                 
+                 kml.write("<![CDATA[%s]]>\n" % base64.b64encode(data.tostring()))
+                     
+                 kml.write("</localvar>\n")
+                 
+                 
+            
+            elif signature=='[D' :
+                 objvalue=jvmti.getLocalObject(threadid,depth,entry.slot)
+                 darray=jvmti.getDoubleArrayElements(objvalue)
+                 arraylen=len(darray)
+                 kml.write('<localvar slot="%d" ref="%d" length="%d">\n' % (entry.slot,objvalue,arraylen))
+                 
+                 data=array.array('d')
+                 
+                 for element in darray :
+                     data.append(element)
+                 
+                 kml.write("<![CDATA[%s]]>\n" % base64.b64encode(data.tostring()))
+                     
+                 kml.write("</localvar>\n")
+                 
+            elif signature=='[Ljava/lang/String;' :
+                
+                
+                objvalue=jvmti.getLocalObject(threadid,depth,entry.slot)
+                if objvalue==0 : 
+                    arraylen=0
+                    
+                else :
+                    arraylen=jvmti.getArrayLength(objvalue)
+                
+                kml.write('<localvar slot="%d" ref="%d" length="%d">\n' % (entry.slot,objvalue,arraylen))
+                
+                if arraylen > 0 :
+                    for i in range (0 ,arraylen)  :
+                        elementID=jvmti.getObjectArrayElement(objvalue,i)
+                        string=jvmti.getStringUTFChars(elementID)
+                        kml.write('<entry id="%d" value="%s"/>' % (elementID,string))
+                        
+                kml.write("</localvar>\n")
+                
+                
+            elif signature[0]=='[' :
+                objvalue=jvmti.getLocalObject(threadid,depth,entry.slot)
+                if objvalue==0 : 
+                    arraylen=0
+                    
+                else :
+                    arraylen=jvmti.getArrayLength(objvalue)
+                
+                kml.write('<localvar slot="%d" ref="%d" length="%d">\n' % (entry.slot,objvalue,arraylen))
+                if arraylen > 0 :
+                    data=array.array('i')
+                    for i in range (0 ,arraylen)  :
+                        elementID=jvmti.getObjectArrayElement(objvalue,i)
+                        data.append(elementID)
+                    kml.write("<![CDATA[%s]]>\n" % base64.b64encode(data.tostring()))
+                        
+                kml.write("</localvar>\n")
+                
+            else :
+                objvalue=jvmti.getLocalObject(threadid,depth,entry.slot)
+                
+                clazzid=0
+                if objvalue!=0 :
+                    clazzid=jvmti.getObjectClass(objvalue)
+                    saveInstance(kml,clazzid,objvalue)
+
+                kml.write('<localvar slot="%d" classid="%d" object="%d">\n' % (entry.slot,clazzid,objvalue))
+                kml.write("</localvar>\n")
+                
+     except jvmti.error :
+                
+            
+                print "err..." , jvmti.error , signature
+          
+  
+    

Modified: incubator/kato/branches/experimental/PyJVMTI/kato/console.py
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/PyJVMTI/kato/console.py?rev=784411&r1=784410&r2=784411&view=diff
==============================================================================
--- incubator/kato/branches/experimental/PyJVMTI/kato/console.py (original)
+++ incubator/kato/branches/experimental/PyJVMTI/kato/console.py Sat Jun 13 15:56:55 2009
@@ -15,8 +15,9 @@
 print "JVMTI Python Interactive Session started"
 
 import jvmti 
-#import kato.Dump as Dump
-from  kato.BinDump import BinDump
+
+from kato.XMLDump import *
+from kato.BinDump import BinDump
 from kato.JClass import JClass
 from kato.JField import JField
 
@@ -65,8 +66,8 @@
     print "saving..."
     print "save classes = ", saveclasses
     print "save Threads = ", saveThreads
-    d=BinDump()
-    d.save()
+    
+    katodump()
     
     print "saved"
 

Modified: incubator/kato/branches/experimental/PyJVMTI/pyjvmti.c
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/PyJVMTI/pyjvmti.c?rev=784411&r1=784410&r2=784411&view=diff
==============================================================================
--- incubator/kato/branches/experimental/PyJVMTI/pyjvmti.c (original)
+++ incubator/kato/branches/experimental/PyJVMTI/pyjvmti.c Sat Jun 13 15:56:55 2009
@@ -48,8 +48,8 @@
      jint rc = (*vmptr)->GetEnv(vmptr, (void **)&jniptr, JNI_VERSION_1_6);
 
      		  	if (rc != JNI_OK) {
-     		  		report("unable to load jni environment");
-     		  		
+     		  		printf("unable to load jni environment");
+
      		 	}
 
 
@@ -91,7 +91,7 @@
      jlong* tag_ptr,
      void* user_data) {
 	printf("called...");
-     	
+
 }
 
 static void JNICALL myVMInit(jvmtiEnv *jvmtiptr, JNIEnv *jni, jthread thread)
@@ -221,6 +221,24 @@
 \
    		 return Py_BuildValue(PTYPE, result);
 
+#define getStaticValue(FUNC,TYPE,PTYPE)  \
+	CHECK_VALID();         \
+                           \
+			int clazzID=0; \
+			int fieldID=0; \
+			PyArg_ParseTuple(args, "ii", &clazzID,&fieldID);\
+                                                            \
+            TRACE("clazzid=%d ",clazzID); \
+            TRACE("fieldID=%d\n",fieldID); \
+			jclass clazz=clazzID;\
+			jfieldID field=fieldID;\
+			                       \
+			TYPE result=(*jniptr)->FUNC(jniptr,clazz,field);\
+                                                            \
+            PyObject *pyresult=Py_BuildValue(PTYPE, result); \
+            TRACE_EXIT(); \
+            return pyresult;
+
 
 #define getList(FUNC,TYPE,DESC)  \
 	CHECK_VALID(); \
@@ -325,15 +343,56 @@
 		return result;
 }
 
-static PyObject *  jvmti_getArrayLength(PyObject *self, PyObject *args) {
+static PyObject *  jvmti_getStaticBooleanField(PyObject *self, PyObject *args) {
+		TRACE_ENTER();
+		getStaticValue(GetStaticBooleanField,jboolean,"i")
+		TRACE_EXIT();
+}
+static PyObject *  jvmti_getStaticByteField(PyObject *self, PyObject *args) {
+		TRACE_ENTER();
+		getStaticValue(GetStaticByteField,jbyte,"h")
+		TRACE_EXIT();
+}
+static PyObject *  jvmti_getStaticCharField(PyObject *self, PyObject *args) {
+	TRACE_ENTER();
+		getStaticValue(GetStaticCharField,jchar,"c")
+}
+static PyObject *  jvmti_getStaticShortField(PyObject *self, PyObject *args) {
+	TRACE_ENTER();
+		getStaticValue(GetStaticShortField,jshort,"h")
+}
+static PyObject *  jvmti_getStaticIntField(PyObject *self, PyObject *args) {
+	TRACE_ENTER();
+		getStaticValue(GetStaticIntField,jshort,"i")
+}
+static PyObject *  jvmti_getStaticLongField(PyObject *self, PyObject *args) {
+	TRACE_ENTER();
+		getStaticValue(GetStaticLongField,jlong,"l")
+}
+static PyObject *  jvmti_getStaticFloatField(PyObject *self, PyObject *args) {
+	TRACE_ENTER();
+		getStaticValue(GetStaticFloatField,jfloat,"f")
+}
+static PyObject *  jvmti_getStaticDoubleField(PyObject *self, PyObject *args) {
+	TRACE_ENTER();
+		getStaticValue(GetStaticDoubleField,jdouble,"f")
+}
+static PyObject *  jvmti_getStaticObjectField(PyObject *self, PyObject *args) {
+	TRACE_ENTER();
+		getStaticValue(GetStaticObjectField,jobject,"i")
+	TRACE_EXIT();
+}
 
+static PyObject *  jvmti_getArrayLength(PyObject *self, PyObject *args) {
+	TRACE_ENTER();
 	CHECK_VALID();
 
 	int arrayid=0;
 
 	PyArg_ParseTuple(args, "i", &arrayid);
+	TRACE("arrayid=%d\n",arrayid);
 
-	jarray array=(jarray)arrayid;
+	jarray array=INT2JARRAY(arrayid);
 
 	jsize result=(*jniptr)->GetArrayLength(jniptr,array);
 
@@ -341,84 +400,132 @@
 
 }
 
+static PyObject *  jvmti_getStringUTFChars(PyObject *self, PyObject *args) {
+	TRACE_ENTER();
+	CHECK_VALID();
 
+	int objid=0;
+	const char *utf;
+	jboolean iscopy;
 
-static PyObject *  jvmti_getObjectField(PyObject *self, PyObject *args) {
+	PyArg_ParseTuple(args, "i", &objid);
+
+	jstring string=(jstring)objid;
+
+	utf=(*jniptr)->GetStringUTFChars(jniptr,string,&iscopy);
+
+	PyObject *result=Py_BuildValue("s",utf);
+
+	if(iscopy==JNI_TRUE) {
+
+		(*jniptr)->ReleaseStringUTFChars(jniptr,string,utf);
+	}
+
+	return result;
+
+}
+
+
+static PyObject *  jvmti_getObjectArrayElement(PyObject *self, PyObject *args) {
+	TRACE_ENTER();
+	CHECK_VALID();
+
+	int arrayid=0;
+	int index=0;
+
+	PyArg_ParseTuple(args, "ii", &arrayid,&index);
+
+	jarray array=(jarray)arrayid;
+	jsize  element=(jsize)index;
+
+	jobject result=(*jniptr)->GetObjectArrayElement(jniptr,array, element);
 
+
+    return Py_BuildValue("i", result);
+
+}
+
+
+static PyObject *  jvmti_getObjectField(PyObject *self, PyObject *args) {
+	TRACE_ENTER();
 	getFieldValue(GetObjectField,jobject,"i","get obj field")
 }
 static PyObject *  jvmti_getBooleanField(PyObject *self, PyObject *args) {
-
+	TRACE_ENTER();
 	getFieldValue(GetBooleanField,jboolean,"i","get boolean field")
 }
 static PyObject *  jvmti_getByteField(PyObject *self, PyObject *args) {
-
+	TRACE_ENTER();
 	getFieldValue(GetByteField,jbyte,"i","get byte field")
 }
 
 static PyObject *  jvmti_getCharField(PyObject *self, PyObject *args) {
-
+	TRACE_ENTER();
 	getFieldValue(GetCharField,jchar,"i","get char field")
 }
 
 static PyObject *  jvmti_getShortField(PyObject *self, PyObject *args) {
-
+	TRACE_ENTER();
 	getFieldValue(GetShortField,jshort,"i","get short field")
 }
 
 static PyObject *  jvmti_getIntField(PyObject *self, PyObject *args) {
-
+	TRACE_ENTER();
 
 	getFieldValue(GetIntField,jint,"i","get int field")
 }
 
 static PyObject *  jvmti_getLongField(PyObject *self, PyObject *args) {
-
+	TRACE_ENTER();
 	getFieldValue(GetLongField,jlong,"l","get long field")
 
 }
 static PyObject *  jvmti_getFloatField(PyObject *self, PyObject *args) {
-
+	TRACE_ENTER();
 	getFieldValue(GetFloatField,jfloat,"f","get float field")
 
 }
 static PyObject *  jvmti_getDoubleField(PyObject *self, PyObject *args) {
-
+	TRACE_ENTER();
 	getFieldValue(GetDoubleField,jlong,"f","get double field")
 
 }
 
 static PyObject *  jvmti_getIntArrayElements(PyObject *self, PyObject *args) {
-
+	TRACE_ENTER();
 	getArray(Int,jint,int,"i")
 }
 static PyObject *  jvmti_getByteArrayElements(PyObject *self, PyObject *args) {
-
+	TRACE_ENTER();
 	getArray(Byte,jbyte,int,"i")
 }
+static PyObject *  jvmti_getBooleanArrayElements(PyObject *self, PyObject *args) {
+	TRACE_ENTER();
+	getArray(Boolean,jboolean,int,"i")
+}
 static PyObject *  jvmti_getCharArrayElements(PyObject *self, PyObject *args) {
-
+	TRACE_ENTER();
 	getArray(Char,jchar,char,"c")
 }
 static PyObject *  jvmti_getShortArrayElements(PyObject *self, PyObject *args) {
-
+	TRACE_ENTER();
 	getArray(Short,jshort,short,"h")
 }
 static PyObject *  jvmti_getLongArrayElements(PyObject *self, PyObject *args) {
-
+	TRACE_ENTER();
 	getArray(Long,jlong,long,"l")
 }
 static PyObject *  jvmti_getFloatArrayElements(PyObject *self, PyObject *args) {
-
+	TRACE_ENTER();
 	getArray(Float,jfloat,float,"f")
 }
 static PyObject *  jvmti_getDoubleArrayElements(PyObject *self, PyObject *args) {
-
+	TRACE_ENTER();
 	getArray(Double,jdouble,double,"d")
 }
 
 static PyObject *  jvmti_registerExceptionFilter(PyObject *self, PyObject *args) {
-
+	TRACE_ENTER();
 	CHECK_VALID();
 	PyObject *temp=NULL;
     PyObject *result = NULL;
@@ -445,7 +552,7 @@
 }
 
 static PyObject *  jvmti_iterateOverReachableObjects(PyObject *self, PyObject *args) {
-
+	TRACE_ENTER();
 	CHECK_VALID();
 	objectcounter=0;
     PyObject *temp=NULL;
@@ -475,7 +582,7 @@
 
 }
 static PyObject *  jvmti_getStackTrace(PyObject *self, PyObject *args) {
-
+	TRACE_ENTER();
 
 			int threadID=0;
 			int start_depth=0;
@@ -512,8 +619,30 @@
 
 }
 
-static PyObject *  jvmti_getFrameCount(PyObject *self, PyObject *args) {
 
+
+static PyObject *  jvmti_deleteLocalRef(PyObject *self, PyObject *args) {
+	TRACE_ENTER();
+	CHECK_VALID();
+
+		// get required ref
+		int ref=0;
+
+		PyArg_ParseTuple(args, "i", &ref);
+
+		jobject refj=INT2JOBJECT(ref);
+		(*jniptr)->DeleteLocalRef(jniptr,refj);
+
+		 PyObject *result= Py_BuildValue("i", ref);
+		 TRACE_EXIT();
+		 return result;
+
+
+
+
+}
+static PyObject *  jvmti_getFrameCount(PyObject *self, PyObject *args) {
+	TRACE_ENTER();
 	CHECK_VALID();
 
 		// get required thread...
@@ -537,7 +666,7 @@
  * Takes threadid and returns a python list of object ids
  */
 static PyObject *  jvmti_getCurrentContendedMonitor(PyObject *self, PyObject *args) {
-
+	TRACE_ENTER();
 
 			CHECK_VALID();
 
@@ -561,7 +690,7 @@
  * Takes threadid and returns a python list of object ids
  */
 static PyObject *  jvmti_getOwnedMonitorInfo(PyObject *self, PyObject *args) {
-
+	TRACE_ENTER();
 	CHECK_VALID();
 
 		// get required thread...
@@ -591,7 +720,7 @@
 }
 
 static PyObject *  jvmti_getThreadGroupInfo(PyObject *self, PyObject *args) {
-
+	TRACE_ENTER();
 	CHECK_VALID();
 
 		// get required threadgroup
@@ -614,7 +743,7 @@
 		return result;
 }
 static PyObject *  jvmti_getTopThreadGroups(PyObject *self, PyObject *args) {
-
+	TRACE_ENTER();
 	CHECK_VALID();
 
 
@@ -645,7 +774,7 @@
  */
 
 static PyObject *  jvmti_getcapabilities(PyObject *self, PyObject *args) {
-
+	TRACE_ENTER();
 
 	CHECK_VALID();
 
@@ -663,7 +792,7 @@
 
  static PyObject *
 jvmti_getThread(PyObject *self, PyObject *args)
-{
+{TRACE_ENTER();
 	CHECK_VALID();
 	// get required thread...
 	int threadID=0;
@@ -687,7 +816,7 @@
 
  static PyObject *
 jvmti_getCurrentThread(PyObject *self, PyObject *args)
-{
+{TRACE_ENTER();
 	CHECK_VALID();
 	jthread threadj=0;
 
@@ -707,7 +836,7 @@
  static PyObject *
  jvmti_getLoadedClasses(PyObject *self, PyObject *args)
  {
-
+	 TRACE_ENTER();
  	CHECK_VALID();
 
  	jint count=0;
@@ -738,7 +867,7 @@
  static PyObject *
 jvmti_getAllThreads(PyObject *self, PyObject *args)
 {
-
+	 TRACE_ENTER();
 	CHECK_VALID();
 
 
@@ -771,6 +900,7 @@
 static PyObject *
 jvmti_getsystemproperties(PyObject *self, PyObject *args)
 {
+	TRACE_ENTER();
 	CHECK_VALID();
 
 	jint countj=0;
@@ -819,7 +949,7 @@
 jvmti_getSuperClass(PyObject *self, PyObject *args)
 {
 
-
+	TRACE_ENTER();
 CHECK_VALID();
 
 	int classid=0;
@@ -835,7 +965,7 @@
 jvmti_getObjectClass(PyObject *self, PyObject *args)
 {
 
-
+	TRACE_ENTER();
 CHECK_VALID();
 
 	int objid=0;
@@ -853,7 +983,7 @@
 jvmti_gettime(PyObject *self, PyObject *args)
 {
 
-
+	TRACE_ENTER();
 CHECK_VALID();
 
 	jlong result=0;
@@ -869,6 +999,7 @@
 static PyObject *
 jvmti_getLocalValue(PyObject *self, PyObject *args)
 {
+	TRACE_ENTER();
 	int threadID=0;
 	int depth=0;
 	int slot=0;
@@ -894,6 +1025,39 @@
 	CHECK_OK("Get Local Value");
 	return Py_BuildValue("i", 0);
 }
+
+
+
+static PyObject *
+jvmti_getFrameLocation(PyObject *self, PyObject *args)
+{
+	TRACE_ENTER();
+
+CHECK_VALID();
+
+	int threadID=0;
+	int depth=0;
+	int methodID=0;
+
+	PyArg_ParseTuple(args, "iii", &threadID,&depth);
+
+	TRACE("thread id=%d ",threadID);
+	TRACE("depth=%d ",depth);
+
+
+	jthread threadj=INT2JTHREAD(threadID);
+	jint    depthj=depth;
+	jmethodID methodj=0;
+	jlocation result=0;
+
+	jvmtiError err=(*jvmtiptr)->GetFrameLocation(jvmtiptr,threadj,depthj,&methodj,&result);
+
+	CHECK_OK("GetFrameLocation");
+
+	PyObject *pyresult=Py_BuildValue("ii", methodj,result);
+	TRACE_EXIT();
+	return pyresult;
+}
 /**
  * Get Local Variable that is an Object
  */
@@ -901,7 +1065,7 @@
 static PyObject *
 jvmti_getLocalObject(PyObject *self, PyObject *args)
 {
-
+	TRACE_ENTER();
 
 CHECK_VALID();
 
@@ -911,17 +1075,22 @@
 
 	PyArg_ParseTuple(args, "iii", &threadID,&depth,&slot);
 
-	
+	TRACE("thread id=%d ",threadID);
+	TRACE("depth=%d ",depth);
+	TRACE("slot=%d\n",slot);
+
 	jthread threadj=INT2JTHREAD(threadID);
 	jint    depthj=depth;
 	jint    slotj=slot;
-	jobject result;
+	jobject result=0;
 
 	jvmtiError err=(*jvmtiptr)->GetLocalObject(jvmtiptr,threadj,depthj,slotj,&result);
 
 	CHECK_OK("GetLocalObject");
 
-	return Py_BuildValue("i", result);
+	PyObject *pyresult=Py_BuildValue("i", result);
+	TRACE_EXIT();
+	return pyresult;
 }
 
 /**
@@ -931,7 +1100,7 @@
 static PyObject *
 jvmti_getLocalInt(PyObject *self, PyObject *args)
 {
-
+	TRACE_ENTER();
 
 CHECK_VALID();
 
@@ -941,7 +1110,7 @@
 
 	PyArg_ParseTuple(args, "iii", &threadID,&depth,&slot);
 
-	
+
 	jthread threadj=INT2JTHREAD(threadID);
 	jint    depthj=depth;
 	jint    slotj=slot;
@@ -961,7 +1130,7 @@
 jvmti_getLocalLong(PyObject *self, PyObject *args)
 {
 
-
+	TRACE_ENTER();
 CHECK_VALID();
 
 	int threadID=0;
@@ -989,6 +1158,7 @@
 static PyObject *
 jvmti_getBytecodes(PyObject *self, PyObject *args)
 {
+	TRACE_ENTER();
 	CHECK_VALID();
 
 			int methodID=0;
@@ -1020,7 +1190,7 @@
 static PyObject *
 jvmti_getMethodName(PyObject *self, PyObject *args)
 {
-
+	TRACE_ENTER();
 
 
 	CHECK_VALID();
@@ -1054,7 +1224,7 @@
 static PyObject *
 jvmti_getClassSignature(PyObject *self, PyObject *args)
 {
-
+	TRACE_ENTER();
 
 
 	CHECK_VALID();
@@ -1086,6 +1256,7 @@
 static PyObject *
 jvmti_getFieldModifiers(PyObject *self, PyObject *args)
 {
+	TRACE_ENTER();
 	CHECK_VALID();
 	int class=0;
     int field=0;
@@ -1114,7 +1285,7 @@
 {
 
 
-
+	TRACE_ENTER();
 	CHECK_VALID();
 
 		int classID=0;
@@ -1151,7 +1322,7 @@
 {
 
 
-
+	TRACE_ENTER();
 	CHECK_VALID();
 
 		int methodID=0;
@@ -1200,6 +1371,8 @@
 
 		DEALLOC(entries);
 
+		TRACE_EXIT();
+
 		return list;
 }
 
@@ -1207,53 +1380,66 @@
  * Returns the size of the object
  */
 static PyObject *  jvmti_getObjectSize(PyObject *self, PyObject *args) {
+	TRACE_ENTER();
 		getValue(GetObjectSize,jobject,jlong,"i","Get Object Size")
 }
 static PyObject *  jvmti_getClassLoaderClasses(PyObject *self, PyObject *args) {
+	TRACE_ENTER();
 	getList(GetClassLoaderClasses,jclass,"Get ClassLoader classes")
 }
 static PyObject *  jvmti_getSourceFileName(PyObject *self, PyObject *args) {
+	TRACE_ENTER();
 	getStringValue(GetSourceFileName,"Get Source File Name")
 }
 static PyObject *  jvmti_getClassStatus(PyObject *self, PyObject *args) {
+	TRACE_ENTER();
 	getValue(GetClassStatus,jobject,jint,"i","Get Class Status")
 }
 static PyObject *  jvmti_getClassModifiers(PyObject *self, PyObject *args) {
+	TRACE_ENTER();
 	getValue(GetClassModifiers,jobject,jint,"i","Get Class Modifiers")
 }
 static PyObject *  jvmti_getClassMethods(PyObject *self, PyObject *args) {
+	TRACE_ENTER();
 	getList(GetClassMethods,jmethodID,"Get Class Methods")
 }
 static PyObject *  jvmti_getClassFields(PyObject *self, PyObject *args) {
+	TRACE_ENTER();
 	getList(GetClassFields,jfieldID,"Get Class Fields")
 }
 
 static PyObject *  jvmti_getClassLoader(PyObject *self, PyObject *args) {
+	TRACE_ENTER();
 	getValue(GetClassLoader,jobject,jclass,"i","Get Class Loader")
 }
 
 static PyObject *  jvmti_getMethodModifiers(PyObject *self, PyObject *args) {
+	TRACE_ENTER();
 		getValue(GetMethodModifiers,jmethodID,jint,"i","Get Method Modifiers")
 }
 
 static PyObject *  jvmti_getMaxLocals(PyObject *self, PyObject *args) {
+	TRACE_ENTER();
 		getValue(GetMaxLocals,jmethodID,jint,"i","Get Max Locals")
 }
 
 static PyObject *  jvmti_getArgumentsSize(PyObject *self, PyObject *args) {
+	TRACE_ENTER();
 		getValue(GetArgumentsSize,jmethodID,jint,"i","Get Arguments Size")
 }
 
 static PyObject *  jvmti_isMethodNative(PyObject *self, PyObject *args) {
+	TRACE_ENTER();
 		getValue(IsMethodNative,jmethodID,jboolean,"i","Is method native")
 }
 static PyObject *  jvmti_getImplementedInterfaces(PyObject *self, PyObject *args) {
+	TRACE_ENTER();
 	getList(GetImplementedInterfaces,jclass,"Get Implemented Interfaces")
 }
 
 static PyObject *  jvmti_iterateOverInstancesOfClass(PyObject *self, PyObject *args) {
 
-
+	TRACE_ENTER();
 	CHECK_VALID();
 			// get required class
 			int classID=0;
@@ -1310,8 +1496,11 @@
      {"getSuperClass",        jvmti_getSuperClass, METH_VARARGS,   "Get Superclass."},
      {"getObjectClass",       jvmti_getObjectClass, METH_VARARGS,   "Get Object Class."},
      {"getClassLoader",       jvmti_getClassLoader, METH_VARARGS,   "Get Class Loader."},
+     {"deleteLocalRef",       jvmti_deleteLocalRef, METH_VARARGS,   "Get Class Loader."},
 
 
+
+     {"getFrameLocation",     jvmti_getFrameLocation, METH_VARARGS,   "Get Frame Location."},
      {"getFieldName",         jvmti_getFieldName, METH_VARARGS,   "Get Field Name."},
      {"getFieldModifiers",    jvmti_getFieldModifiers, METH_VARARGS,   "Get Field Name."},
      {"getMethodModifiers",   jvmti_getMethodModifiers, METH_VARARGS,   "Get Method Modifiers."},
@@ -1322,6 +1511,7 @@
      {"getIntArrayElements",  jvmti_getIntArrayElements, METH_VARARGS,   "Get Int Array Elements"},
      {"getCharArrayElements", jvmti_getCharArrayElements, METH_VARARGS,   "Get Char Array Elements"},
      {"getByteArrayElements", jvmti_getByteArrayElements, METH_VARARGS,   "Get Byte Array Elements"},
+     {"getBooleanArrayElements", jvmti_getBooleanArrayElements, METH_VARARGS,   "Get Boolean Array Elements"},
      {"getShortArrayElements",jvmti_getShortArrayElements, METH_VARARGS,   "Get Short Array Elements"},
      {"getLongArrayElements", jvmti_getLongArrayElements, METH_VARARGS,   "Get Long Array Elements"},
      {"getFloatArrayElements",jvmti_getFloatArrayElements, METH_VARARGS,   "Get Float Array Elements"},
@@ -1331,8 +1521,15 @@
      {"getCurrentThread",      jvmti_getCurrentThread, METH_VARARGS,   "Get Current Thread ID"},
      {"iterateOverReachableObjects",       jvmti_iterateOverReachableObjects, METH_VARARGS,   "Iterate over reachable objects"},
 
-
-
+     {"getStaticBooleanField",jvmti_getStaticBooleanField, METH_VARARGS,   "Iterate over reachable objects"},
+     {"getStaticByteField",   jvmti_getStaticByteField, METH_VARARGS,   "Iterate over reachable objects"},
+     {"getStaticCharField",   jvmti_getStaticCharField, METH_VARARGS,   "Iterate over reachable objects"},
+     {"getStaticShortField",  jvmti_getStaticShortField, METH_VARARGS,   "Iterate over reachable objects"},
+     {"getStaticIntField",    jvmti_getStaticIntField, METH_VARARGS,   "Iterate over reachable objects"},
+     {"getStaticLongField",   jvmti_getStaticLongField, METH_VARARGS,   "Iterate over reachable objects"},
+     {"getStaticFloatField",  jvmti_getStaticFloatField, METH_VARARGS,   "Iterate over reachable objects"},
+     {"getStaticDoubleField", jvmti_getStaticDoubleField, METH_VARARGS,   "Iterate over reachable objects"},
+     {"getStaticObjectField", jvmti_getStaticObjectField, METH_VARARGS,   "Iterate over reachable objects"},
 
      {"getObjectField",  jvmti_getObjectField, METH_VARARGS,   "Iterate over reachable objects"},
     {"getBooleanField",  jvmti_getBooleanField, METH_VARARGS,   "Iterate over reachable objects"},
@@ -1343,6 +1540,8 @@
      {"getLongField",  jvmti_getLongField, METH_VARARGS,   "Iterate over reachable objects"},
      {"getFloatField",  jvmti_getFloatField, METH_VARARGS,   "Iterate over reachable objects"},
      {"getDoubleField",  jvmti_getDoubleField, METH_VARARGS,   "Iterate over reachable objects"},
+     {"getObjectArrayElement",  jvmti_getObjectArrayElement, METH_VARARGS,   "Get object array element"},
+     {"getStringUTFChars",  jvmti_getStringUTFChars, METH_VARARGS,   "Get String UTF8 Chars"},
 
      {NULL, NULL, 0, NULL}        /* Sentinel */
 };
@@ -1351,7 +1550,7 @@
 PyMODINIT_FUNC
 initjvmti(void)
 {
-
+	TRACE_ENTER();
 
     PyObject *m;
 
@@ -1374,7 +1573,7 @@
 jclass threadClass;
 jmethodID constructor;
 
-
+TRACE_ENTER();
 printf("\ncreating thread");
 
 threadClass = (*env)->FindClass(env, "test/MyDump");
@@ -1390,7 +1589,7 @@
 
 void exec_interactive_interpreter(int argc, char** argv)
   {
-
+	TRACE_ENTER();
 
 
 		 Py_Main(argc, argv);
@@ -1402,7 +1601,7 @@
 
 
 void runScript(char *script) {
-
+	TRACE_ENTER();
 		printf("\nrunning script %s\n",script);
 
 		 // Python code in separate environments
@@ -1418,16 +1617,17 @@
 
 
 JNIEXPORT void JNICALL Agent_OnUnload(JavaVM *vm) {
+	TRACE_ENTER();
 
-		report("unloaded");
 }
 
 JNIEXPORT void JNICALL Java_test_MyDump_doit
   (JNIEnv *env, jobject obj) {
-
+	TRACE_ENTER();
 	startPython();
 }
 void startPython() {
+	TRACE_ENTER();
 	char *names[]={scriptname,scriptname};
 
 		 exec_interactive_interpreter(1,names);
@@ -1437,6 +1637,7 @@
 static void JNICALL
 dataDumpRequest(jvmtiEnv *jvmti)
 {
+	TRACE_ENTER();
 	jvmtiptr=jvmti;
 
 	 jint rc = (*vmptr)->GetEnv(vmptr, (void **)&jniptr, JNI_VERSION_1_6);
@@ -1455,7 +1656,7 @@
 JNIEXPORT jint JNICALL
 Agent_OnLoad(JavaVM *vm, char *options, void *reserved)
 {
-
+	TRACE_ENTER();
 	report(" jvmti is active");
 
 	vmptr=vm;

Modified: incubator/kato/branches/experimental/PyJVMTI/pyjvmti.h
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/PyJVMTI/pyjvmti.h?rev=784411&r1=784410&r2=784411&view=diff
==============================================================================
--- incubator/kato/branches/experimental/PyJVMTI/pyjvmti.h (original)
+++ incubator/kato/branches/experimental/PyJVMTI/pyjvmti.h Sat Jun 13 15:56:55 2009
@@ -50,13 +50,19 @@
             return NULL; \
 		} \
 	}
-#define report(s)  printf("\nkato: %s",s)
 
+#define TRACE_ENTER()   printf(">%s\n",__FUNCTION__)
+#define TRACE(s,v)      printf(s,v)
+#define TRACE_EXIT()   printf("<%s\n",__FUNCTION__)
 
+#define report(s) printf("kato:%s\n",s);
 
 PyMODINIT_FUNC initjvmti(void);
 
+static PyObject *jvmti_getFrameLocation(PyObject *self, PyObject *args);
+static PyObject *jvmti_deleteLocalRef(PyObject *self, PyObject *args);
 static PyObject *jvmti_getIntArrayElements(PyObject *self, PyObject *args);
+static PyObject *jvmti_getBooleanArrayElements(PyObject *self, PyObject *args);
 static PyObject *jvmti_getByteArrayElements(PyObject *self, PyObject *args);
 static PyObject *jvmti_getCharArrayElements(PyObject *self, PyObject *args);
 static PyObject *jvmti_getShortArrayElements(PyObject *self, PyObject *args);
@@ -106,6 +112,19 @@
 static PyObject *  jvmti_getLongField(PyObject *self, PyObject *args);
 static PyObject *  jvmti_getFloatField(PyObject *self, PyObject *args);
 static PyObject *  jvmti_getDoubleField(PyObject *self, PyObject *args);
+static PyObject *  jvmti_getObjectArrayElement(PyObject *self, PyObject *args);
+static PyObject *  jvmti_getStringUTFChars(PyObject *self, PyObject *args);
+static PyObject *  jvmti_getStaticBooleanField(PyObject *self, PyObject *args);
+static PyObject *  jvmti_getStaticByteField(PyObject *self, PyObject *args);
+static PyObject *  jvmti_getStaticCharField(PyObject *self, PyObject *args);
+static PyObject *  jvmti_getStaticShortField(PyObject *self, PyObject *args);
+static PyObject *  jvmti_getStaticIntField(PyObject *self, PyObject *args);
+static PyObject *  jvmti_getStaticLongField(PyObject *self, PyObject *args);
+static PyObject *  jvmti_getStaticFloatField(PyObject *self, PyObject *args);
+static PyObject *  jvmti_getStaticDoubleField(PyObject *self, PyObject *args);
+static PyObject *  jvmti_getStaticObjectField(PyObject *self, PyObject *args);
+
+
 
 void runScript(char *);
 void startPython(void);

Modified: incubator/kato/branches/experimental/PyJVMTI/pyjvmti_convert.h
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/PyJVMTI/pyjvmti_convert.h?rev=784411&r1=784410&r2=784411&view=diff
==============================================================================
--- incubator/kato/branches/experimental/PyJVMTI/pyjvmti_convert.h (original)
+++ incubator/kato/branches/experimental/PyJVMTI/pyjvmti_convert.h Sat Jun 13 15:56:55 2009
@@ -33,5 +33,7 @@
 #define JCLASS2INT(t)   (int)t
 #define INT2JCLASS(i)   (jclass)i
 
+#define JARRAY2INT(t)   (int)t
+#define INT2JARRAY(i)   (jarray)i
 
 #endif

Modified: incubator/kato/branches/experimental/PyJVMTI/tomcat.sh
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/PyJVMTI/tomcat.sh?rev=784411&r1=784410&r2=784411&view=diff
==============================================================================
--- incubator/kato/branches/experimental/PyJVMTI/tomcat.sh (original)
+++ incubator/kato/branches/experimental/PyJVMTI/tomcat.sh Sat Jun 13 15:56:55 2009
@@ -2,4 +2,4 @@
 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./build/lib.linux-i686-2.6:/usr/lib/python2.6:/usr/lib/python2.6/config
 export PYTHONSTARTUP=./build/lib.linux-i686-2.6/kato/console.py
 export PYTHONPATH=$PYTHONPATH:.
-/home/spoole/javasdks/sun/jdk1.6.0_12/bin/java -Dcatalina.base=/home/spoole/workspace-maven/.metadata/.plugins/org.eclipse.wst.server.core/tmp0 -Dcatalina.home=/usr/share/tomcat5.5 -Dwtp.deploy=/home/spoole/workspace-maven/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps -Djava.endorsed.dirs=/usr/share/tomcat5.5/common/endorsed  -Dfile.encoding=UTF-8 -Xcheck:jni -agentlib:pyjvmti=init.py -classpath /usr/share/tomcat5.5/bin/bootstrap.jar:/home/spoole/javasdks/sun/jdk1.6.0_12/lib/tools.jar org.apache.catalina.startup.Bootstrap start
+/home/spoole/javasdks/sun/jdk1.6.0_12/bin/java -Dcatalina.base=/home/spoole/workspace-maven/.metadata/.plugins/org.eclipse.wst.server.core/tmp0 -Dcatalina.home=/usr/share/tomcat5.5 -Dwtp.deploy=/home/spoole/workspace-maven/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps -Djava.endorsed.dirs=/usr/share/tomcat5.5/common/endorsed  -Dfile.encoding=UTF-8 -verbose:gc -verbose:jni -Xcheck:jni -agentlib:pyjvmti=init.py -classpath /usr/share/tomcat5.5/bin/bootstrap.jar:/home/spoole/javasdks/sun/jdk1.6.0_12/lib/tools.jar org.apache.catalina.startup.Bootstrap start



Mime
View raw message