thanks all , when i see dtrace can not use if , i think a solution to my script
it's a time counter dtrace script for all java methods...because dtrace is not start with the jvm at the same time ,so many java method will not have a entry, so at return probe is hard to count time cost... after test , a method throw a Exception will also have a return probe, so this script will work now... #!/usr/sbin/dtrace -s #pragma D option quiet dtrace:::BEGIN { self->index = 0; tstart = timestamp; } hotspot$1:::method-entry { mname = strjoin(strjoin(copyinstr(arg1,arg2),"->"),copyinstr(arg3,arg4)); self->index++; self->mname[self->index] = mname; self->mtime[self->index] = timestamp; @count[mname] = count(); } hotspot$1:::method-return { mname = strjoin(strjoin(copyinstr(arg1,arg2),"->"),copyinstr(arg3,arg4)); mindex = (self->mname[self->index] == mname) ? -1 : 0; mtime = (mindex == -1) ? self->mtime[self->index] : tstart; /* mname = (mindex == -1) ? mname : strjoin("non-start-", mname); printf("method : %s : start : %d\n", mname, tstart); */ @time[mname] = avg(timestamp - mtime); self->index += mindex; } copyinstr sometimes will get a wrong string if havn't the length param...like this: 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef 0: 6e 6f 6e 2d 73 74 61 72 74 2d 6a 61 76 61 2f 69 non-start-java/i 10: 6f 2f 42 75 66 66 65 72 65 64 57 72 69 74 65 72 o/BufferedWriter 20: 01 c0 d7 42 30 02 e0 d8 13 2d 3e 6e 65 77 4c 69 ...B0....->newLi 30: 6e 65 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ne.............. 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ -- This message posted from opensolaris.org _______________________________________________ dtrace-discuss mailing list dtrace-discuss@opensolaris.org