java - Byteman - trace all classes and methods in a given package -


when using byteman, have specify class , method in rule syntax. if want trace program execution using byteman?

example: not know methods being executed when executing feature of program. want identify called methods during feature execution.

does mean i've add rule each method of each class in given package? or there other way achieve this?

yes, need rule every method want trace (although there easy way -- see below).

byteman deliberately avoids use of wildcard patterns class , method injecting into. that's because using these sort of rules slow jvm down enormously.

why? well, every time class loaded byteman gets asked "do want transform class injecting code it?". currently, byteman indexes loaded rules classname. so, answering question involves hash table lookup (well, actually, 2 -- 1 bare name , package qualified name). means no answers (which right answer) super-quick. if byteman allow patterns classname not rely on simple hash lookup.

if, example had pattern class org..foo , 2 classes org.my.app.foobar , org.my.app.bletch how decide first 1 matches , second 1 not? have try pattern match each pattern rule every class name. single pattern match lot more expensive hash table lookup. if used multiple pattern-based rules cost multiply according number of rules.

ok, how can work round limitation of byteman? if want instrument lot of classes + methods suggest use program generate rule script containing rule each class+method interested in. write program reads file containing entries like

class_name1 method_pattern1 class_name2 method_pattern2 . . .

the file says want instrument methods of class class_name1 methods match method_pattern1 , on.

so long target jars in classpath can use current classloader load each class name (call this.getclass().getclassloader() classloader , call classloader.loadclass(class_name) desired class). use reflection list of class's methods. each method, if name of method matches corresponding method_pattern output @ entry rule and/or @ exit rule script file.

if want see code whcih similar @ contrib/dtest package part of byteman sources.

https://github.com/bytemanproject/byteman/tree/master/contrib/dtest

if have further questions byteman please coem , ask them on official byteman user forum provided project:

https://developer.jboss.org/en/byteman?view=discussions

regards,

andrew dinn (byteman project lead)


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

c# - two queries in same method -