Xinfeng Liu
2007-May-29 12:44 UTC
[dtrace-discuss] How to interpret UTF-8 strings in dtrace java
Hi, I met a problem when dtracing java programs. For example: tracing method-entry and using copyinstr(args) got the below output: java/util/HashMap: addEntry: java/lang/NoClassDefFoundError\330@?\331*&\330: <init>\330\205\236#\331*&\330: java/lang/LinkageError\330@\324^[\331*1\310: <init>\330\205\236#\331*&\330: java/lang/Error: <init>\330\205\236#\331*&\330: java/lang/Throwable: <init>\330\205\236#\331*&\330: java/lang/Object: <init>\330\205\236#\331*&\330: java/lang/Throwable: fillInStackTrace: What I need is to get the meanings of those UTF-8 strings like \330 \205... I used mozilla browser to open above output and set encoding to UTF-8, but got the wrong characters. Is there any solution for my problem? Thanks in advance, Xinfeng Liu (lxf) -- This message posted from opensolaris.org
Keith McGuigan
2007-May-29 13:09 UTC
[dtrace-discuss] How to interpret UTF-8 strings in dtrace java
Hi Xinfeng, There is no meaning to those extra characters; they''re not UTF-8, they''re just garbage after the UTF-8 string. The strings returned from the probes in the JVM are not NUL-terminated, so you have to use the associated length argument when reading the strings using copyinstr. For example: "copyinstr(args[3], args[4])" to get the method name. Refer to: http://java.sun.com/javase/6/docs/technotes/guides/vm/dtrace.html -- - Keith Xinfeng Liu wrote:> Hi, > I met a problem when dtracing java programs. > For example: tracing method-entry and using copyinstr(args) got the below output: > java/util/HashMap: addEntry: > java/lang/NoClassDefFoundError\330@?\331*&\330: <init>\330\205\236#\331*&\330: > java/lang/LinkageError\330@\324^[\331*1\310: <init>\330\205\236#\331*&\330: > java/lang/Error: <init>\330\205\236#\331*&\330: > java/lang/Throwable: <init>\330\205\236#\331*&\330: > java/lang/Object: <init>\330\205\236#\331*&\330: > java/lang/Throwable: fillInStackTrace: > > What I need is to get the meanings of those UTF-8 strings like \330 \205... > I used mozilla browser to open above output and set encoding to UTF-8, but got the wrong characters. > Is there any solution for my problem? > > Thanks in advance, > Xinfeng Liu (lxf) > -- > This message posted from opensolaris.org > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org
Xinfeng Liu
2007-May-30 04:08 UTC
[dtrace-discuss] Re: How to interpret UTF-8 strings in dtrace java
Hi, keith, Thanks a lot! Your explanation is correct! By the way, copyinstr(args3, args4) should be used instead of arg[3], args[4]. It might be the typo of the guide. In addition, it will be better if method-entry probe can output method parameter values. Currently, the args5 and args6 for method-entry probe output method signatures(i.e. parameter types). Thanks again and Have a nice day, Xinfeng -- This message posted from opensolaris.org
Ekaterina Pavlova
2007-May-30 06:19 UTC
[dtrace-discuss] Re: How to interpret UTF-8 strings in dtrace java
Xinfeng Liu wrote:> Hi, keith, > > Thanks a lot! Your explanation is correct! > By the way, copyinstr(args3, args4) should be used instead of arg[3], args[4]. It might be the typo of the guide.Did you mean args[N]? args[N] actually will not work in case you will run dtrace using ''-c'': dscript.d -c "java ..." This is because HotSpot probes definitions are located in libjvm.so which is loaded after some time and as result probes definitions are not available at the time dtrace command starts. As result there are no probes matching the probe specifier so there''s no way to infer the typed arguments. But args[N] will work if you will attach DTrace to already running Java application: dscript.d -p JAVA_PID -katya> In addition, it will be better if method-entry probe can output method parameter values. Currently, the args5 and args6 for method-entry probe output method signatures(i.e. parameter types). > > Thanks again and Have a nice day, > Xinfeng > -- > This message posted from opensolaris.org > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org--
Xinfeng Liu
2007-May-30 06:41 UTC
[dtrace-discuss] Re: Re: How to interpret UTF-8 strings in dtrace java
Hi, katya, Thanks for your comments. In fact, I used -p to attach java process. If I change args3 to args[3], then #./dtrace-java-method.d -p `pgrep -n java` dtrace: failed to compile script ./dtrace-java-method.d: line 7: arg has not yet been declared or assigned My scripts: -------------------------------------- #!/usr/sbin/dtrace -s #pragma D option quiet hotspot$target:::method-entry /copyinstr(arg1) == "com/sun/identity/sm/SMSEntry"/ { printf("%s: %s: \n", copyinstr(arg1,arg2), copyinstr(arg[3],arg[4])); trace_flag=1; } hotspot$target:::method-entry /trace_flag/ { printf("%s: %s: \n", copyinstr(arg1,arg2), copyinstr(arg3, arg4)); } hotspot$target:::method-return /copyinstr(arg1) == "com/sun/identity/sm/SMSEntry"/ { printf("RETURN: %s: %s: \n", copyinstr(arg1,arg2), copyinstr(arg3,arg4)); trace_flag=0; } ----------------------------------------- Thanks, Xinfeng -- This message posted from opensolaris.org
Ekaterina Pavlova
2007-May-30 06:46 UTC
[dtrace-discuss] Re: Re: How to interpret UTF-8 strings in dtrace java
Xinfeng Liu wrote:> Hi, katya, > > Thanks for your comments. > In fact, I used -p to attach java process. > > If I change args3 to args[3], then > > #./dtrace-java-method.d -p `pgrep -n java` > > dtrace: failed to compile script ./dtrace-java-method.d: line 7: arg has not yet been declared or assigned > > My scripts: > > -------------------------------------- > #!/usr/sbin/dtrace -s > #pragma D option quiet > > hotspot$target:::method-entry > /copyinstr(arg1) == "com/sun/identity/sm/SMSEntry"/ > { > printf("%s: %s: \n", copyinstr(arg1,arg2), copyinstr(arg[3],arg[4]));it should be: printf("%s: %s: \n", copyinstr(arg1,arg2), copyinstr(args[3],args[4]));> trace_flag=1; > } > > hotspot$target:::method-entry > /trace_flag/ > { > printf("%s: %s: \n", copyinstr(arg1,arg2), copyinstr(arg3, arg4)); > } > > hotspot$target:::method-return > /copyinstr(arg1) == "com/sun/identity/sm/SMSEntry"/ > { > printf("RETURN: %s: %s: \n", copyinstr(arg1,arg2), copyinstr(arg3,arg4)); > trace_flag=0; > } > ----------------------------------------- > > Thanks, > Xinfeng > -- > This message posted from opensolaris.org > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org