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/05/28 11:38:55 UTC
svn commit: r779573 - in /incubator/kato/branches/experimental/PyJVMTI: ./
build.sh kato/BinDump.py kato/Dump.py kato/console.py tomcat.sh
Author: spoole
Date: Thu May 28 11:38:55 2009
New Revision: 779573
URL: http://svn.apache.org/viewvc?rev=779573&view=rev
Log:
changes to jvmti to work with tomcat
Added:
incubator/kato/branches/experimental/PyJVMTI/tomcat.sh (with props)
Modified:
incubator/kato/branches/experimental/PyJVMTI/ (props changed)
incubator/kato/branches/experimental/PyJVMTI/build.sh
incubator/kato/branches/experimental/PyJVMTI/kato/BinDump.py
incubator/kato/branches/experimental/PyJVMTI/kato/Dump.py
incubator/kato/branches/experimental/PyJVMTI/kato/console.py
Propchange: incubator/kato/branches/experimental/PyJVMTI/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Thu May 28 11:38:55 2009
@@ -1,3 +1,3 @@
build
-
kato.dump
+dump.kato
Modified: incubator/kato/branches/experimental/PyJVMTI/build.sh
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/PyJVMTI/build.sh?rev=779573&r1=779572&r2=779573&view=diff
==============================================================================
--- incubator/kato/branches/experimental/PyJVMTI/build.sh (original)
+++ incubator/kato/branches/experimental/PyJVMTI/build.sh Thu May 28 11:38:55 2009
@@ -1,4 +1,4 @@
-DIRS=$JAVA_HOME/include:$JAVA_HOME/include/linux
+export DIRS=$JAVA_HOME/include:$JAVA_HOME/include/linux
javac -g ./kato/PauseJVM.java
python -u ./setup.py build
Modified: incubator/kato/branches/experimental/PyJVMTI/kato/BinDump.py
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/PyJVMTI/kato/BinDump.py?rev=779573&r1=779572&r2=779573&view=diff
==============================================================================
--- incubator/kato/branches/experimental/PyJVMTI/kato/BinDump.py (original)
+++ incubator/kato/branches/experimental/PyJVMTI/kato/BinDump.py Thu May 28 11:38:55 2009
@@ -22,13 +22,18 @@
class BinDump(Dump.Dump):
output=None
-
+ reporttrace=True
+ tracedepth=1
+ missingobjects=0
+
def open(self):
+ self.traceEntry("open")
self.output=open("dump.kato","wb")
self.output.write("KATOJVMTI")
header=struct.pack("!hhh",0,0,1)
self.output.write(header)
+
def close(self):
'''
Called at end of save process
@@ -36,17 +41,20 @@
do clean up processing
'''
self.output.close()
-
+ self.traceExit("close (missing objects = %d)" % self.missingobjects)
def startThreadSave(self,count):
# write a threads meta record
+ self.traceEntry("save threads")
recordType=struct.pack("!hi",100,count)
self.output.write(recordType)
def startThreadGroupSave(self,count):
# write a thread group meta record
+ self.traceEntry("save thread groups")
+
recordType=struct.pack("!hi",300,count)
self.output.write(recordType)
@@ -54,6 +62,8 @@
'''
Save a thread group
'''
+ self.traceEntry("save thread group")
+
parentgroup=group.parentThreadGroupID;
if parentgroup==None : parentgroup=0
@@ -63,11 +73,13 @@
# now write its kids...
+ self.traceExit("save thread group")
def saveThread(self,thread):
'''
Save a single Jthread
'''
+ self.traceEntry("save thread")
monitors=thread.ownedMonitorIDs
monlength=len(monitors)
@@ -87,11 +99,13 @@
if tracelen > 0 :
self.saveStackTrace(tracelen,thread,stacktrace)
- print "saved " , thread.name
+
+ self.traceExit("save thread %s" % thread.name);
def saveMonitors(self,count,list):
- print "monitors=",count
+ self.traceEntry("saving %d monitors" % count)
+
header=struct.pack("!hi",102,count)
self.output.write(header)
@@ -99,10 +113,12 @@
header=struct.pack("!i",monitor)
self.output.write(header)
+ self.traceExit("saved monitors")
def saveStackTrace(self,count,thread,list):
- print "stacktrace=",count
+ self.traceEntry("saving %d stack traces" % count)
+
header=struct.pack("!hi",103,count)
self.output.write(header)
@@ -125,11 +141,12 @@
self.output.write(header)
if count > 0 :
- print "saving ",count," vars"
+ self.trace("saving %d variables" % count)
self.saveVariables(thread.threadid,localvars,depth)
depth=depth+1
-
+
+ self.traceExit("saved stack traces")
def getVariables(self,threadid,method,depth):
'''
@@ -220,7 +237,7 @@
except jvmti.error :
print "err..." , jvmti.error
- print results
+
return results
def saveVariables(self,threadid,localvars,depth):
@@ -228,14 +245,16 @@
Saves all the local variables of slot...
'''
-
+ self.traceEntry("saving variables")
for entry in localvars :
header=struct.pack("!hi",501,entry.slot)
self.output.write(header)
signature=entry.signature
- print "saving ",signature,entry.slot
+
+ self.trace("saving %s variable at %d " % (signature,entry.slot))
+
try :
@@ -274,7 +293,7 @@
elif signature=='J' :
longvalue=jvmti.getLocalLong(threadid,depth,entry.slot)
header=struct.pack("!q",longvalue)
- print "length of len=",len(header)
+
self.writeName(signature)
self.output.write(header)
@@ -287,7 +306,7 @@
self.writeName(signature)
self.output.write(header)
- print chararray
+
for element in chararray :
header=struct.pack("!c",element)
self.output.write(header)
@@ -300,7 +319,7 @@
header=struct.pack("!i",arraylen)
self.writeName(signature)
self.output.write(header)
- print intarray
+
for element in intarray :
header=struct.pack("!i",element)
self.output.write(header)
@@ -316,7 +335,7 @@
for element in array :
header=struct.pack("!h",element)
self.output.write(header)
- print array
+
elif signature=='[S' :
objvalue=jvmti.getLocalObject(threadid,depth,entry.slot)
@@ -328,7 +347,7 @@
for element in array :
header=struct.pack("!h",element)
self.output.write(header)
- print array
+
elif signature=='[J' :
objvalue=jvmti.getLocalObject(threadid,depth,entry.slot)
@@ -340,7 +359,7 @@
for element in array :
header=struct.pack("!q",element)
self.output.write(header)
- print array
+
elif signature=='[F' :
@@ -353,7 +372,7 @@
for element in array :
header=struct.pack("!f",element)
self.output.write(header)
- print array
+
elif signature=='[D' :
objvalue=jvmti.getLocalObject(threadid,depth,entry.slot)
@@ -364,19 +383,25 @@
self.output.write(header)
for element in array :
header=struct.pack("!d",element)
- print "len of d=",len(header)
self.output.write(header)
- print array
+
elif signature[0]=='[' :
objvalue=jvmti.getLocalObject(threadid,depth,entry.slot)
- arrayLength=jvmti.getArrayLength(objvalue)
+ if objvalue==0 :
+ arrayLength=0
+ self.missingobjects+=1
+ else :
+ arrayLength=jvmti.getArrayLength(objvalue)
+
+ self.trace("Array length %d" % arrayLength)
header=struct.pack("!i",arrayLength)
self.writeName(signature)
self.output.write(header)
+
else :
objvalue=jvmti.getLocalObject(threadid,depth,entry.slot)
header=struct.pack("!i",objvalue)
@@ -388,7 +413,8 @@
#self.output.write(header)
print "err..." , jvmti.error
-
+
+ self.traceExit("saving variables")
def startClassSave(self,count):
@@ -409,11 +435,14 @@
self.writeName(field.genericsignature)
+ self.trace("save field name=%s signature=%s" % (field.name,field.genericsignature))
def saveClass(self,clazz):
'''
Save a single JClass
'''
+ self.traceEntry("save class %s" % clazz.signature)
+
interfaceCount=len(clazz.interfaces)
methodCount=len(clazz.methods)
@@ -423,6 +452,7 @@
self.output.write(namelength)
self.output.write(clazz.signature)
+
# write fields...
for fieldid in clazz.fields :
@@ -448,16 +478,19 @@
self.saveMethods(clazz)
-
+ self.traceExit("saved class")
def saveMethods(self,clazz):
+ self.traceEntry("save methods")
for methodid in clazz.methods :
m=JMethod.JMethod(methodid)
vartable=m.localVariableTable
tablesize=len(vartable)
+ self.trace("save method %s" % m.name);
+
header=struct.pack("!hiiiiii",204,methodid,m.modifiers,m.maxlocals,m.argumentsize,m.isnative,tablesize)
self.output.write(header)
self. writeName(m.name)
@@ -471,6 +504,8 @@
self. writeName(entry.name) # name
self. writeName(entry.signature) #sig
self. writeName(entry.genericsignature) # generi sig
+
+ self.traceExit("saved methods")
def writeName(self,name):
length=0
@@ -478,5 +513,18 @@
namelength=struct.pack("!i",length)
self.output.write(namelength)
if length>0 : self.output.write(name)
-
+
+ def traceEntry(self,msg):
+ if self.reporttrace :
+ self.tracedepth+=1
+ print "."*self.tracedepth , msg
+
+ def traceExit(self,msg):
+ if self.reporttrace :
+ print "."*self.tracedepth , msg
+ self.tracedepth-=1
+
+ def trace(self,msg):
+ if self.reporttrace :
+ print "."*self.tracedepth , msg
\ No newline at end of file
Modified: incubator/kato/branches/experimental/PyJVMTI/kato/Dump.py
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/PyJVMTI/kato/Dump.py?rev=779573&r1=779572&r2=779573&view=diff
==============================================================================
--- incubator/kato/branches/experimental/PyJVMTI/kato/Dump.py (original)
+++ incubator/kato/branches/experimental/PyJVMTI/kato/Dump.py Thu May 28 11:38:55 2009
@@ -37,7 +37,8 @@
includeThreads=True
includeClasses=True
includeTopThreadGroups=True
-
+ opencalled=False
+
'''
Abstract class that walks the required data and calls dump methods
@@ -102,7 +103,11 @@
will call saveThreadGroup repeatedly with a newly constructed
JThreadGroup instance
'''
- self.startThreadGroupSave(len(groups))
+
+ count=len(groups)
+ self.trace("start saving %d thread groups" % count)
+
+ self.startThreadGroupSave(count)
for g in groups :
q=JThreadGroup.JThreadGroup(g)
@@ -145,7 +150,9 @@
will call saveThread repeatedly with a newly constructed
JThread instance
'''
- self.startThreadSave(len(threads))
+ threadcount=len(threads)
+
+ self.startThreadSave(threadcount)
for t in threads :
q=JThread.JThread(t)
@@ -161,23 +168,27 @@
calls the saveAll* methods in turn depending
on configuration
'''
- self.open()
+ self.checkOpen()
+
saved=self.saveAllThreads()
- print "saved",saved,"threads"
+
saved=self.saveAllClasses()
- print "saved",saved,"classes"
+
saved=self.saveAllThreadGroups()
- print "saved",saved,"thread groups"
+
+ self.trace("Close")
self.close()
def saveAllThreads(self):
'''
Save threads to dump if includeThreads is true
'''
+
if self.includeThreads==False : return 0
+ self.checkOpen()
threads=jvmti.getAllThreads()
self.saveThreads(threads);
@@ -187,9 +198,11 @@
'''
Save class to dump if includeClasses is true
'''
-
+
if self.includeClasses==False : return 0
+ self.checkOpen()
+
classes=jvmti.getLoadedClasses()
self.saveClasses(classes);
@@ -199,11 +212,22 @@
'''
Save thredgroups to dump if includeTopThreadGroups is true
'''
-
+ self.checkOpen()
if self.includeTopThreadGroups==False : return 0
groups=jvmti.getTopThreadGroups()
self.saveThreadGroups(groups);
return len(groups)
-
\ No newline at end of file
+
+ def checkOpen(self):
+ '''
+ Checks if open has been called and if not calls
+ it
+ '''
+ if self.opencalled==False :
+
+ self.open()
+ self.opencalled=True
+
+
\ No newline at end of file
Modified: incubator/kato/branches/experimental/PyJVMTI/kato/console.py
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/PyJVMTI/kato/console.py?rev=779573&r1=779572&r2=779573&view=diff
==============================================================================
--- incubator/kato/branches/experimental/PyJVMTI/kato/console.py (original)
+++ incubator/kato/branches/experimental/PyJVMTI/kato/console.py Thu May 28 11:38:55 2009
@@ -17,6 +17,9 @@
import jvmti
#import kato.Dump as Dump
from kato.BinDump import BinDump
+from kato.JClass import JClass
+from kato.JField import JField
+
saveclasses=False
saveThreads=False
Added: incubator/kato/branches/experimental/PyJVMTI/tomcat.sh
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/PyJVMTI/tomcat.sh?rev=779573&view=auto
==============================================================================
--- incubator/kato/branches/experimental/PyJVMTI/tomcat.sh (added)
+++ incubator/kato/branches/experimental/PyJVMTI/tomcat.sh Thu May 28 11:38:55 2009
@@ -0,0 +1,5 @@
+export LD_PRELOAD=/usr/lib/python2.6/config/libpython2.6.so
+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 -agentlib:pyjvmti -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
Propchange: incubator/kato/branches/experimental/PyJVMTI/tomcat.sh
------------------------------------------------------------------------------
svn:executable = *