Eric Schrock's Blog

Tips and tricks of a ptool hacker

July 1, 2004

During S10 development, there have been numerous enhancements to the ptools (see proc(1)). Here are two recent additions that may have slipped through the cracks with all the hype surrounding Solaris 10. They’re not quite as ground breaking as DTrace or Zones, but well-suited for some blog exposure.

pargs -l

The pargs command has a new option to display the command and all its arguments on a single line. This makes it possible to cut and paste to restart running commands with the same set of arguments.

$ pargs -l `pgrep sleep`
/usr/bin/sleep 10 here are some args
$

java support in pstack

This one won’t hit the streets until build 59, which is due out as the next Solaris Express build. Thanks to the JVM guys, we’ve added support for pstack to display java frames. If you’re using the latest java release (1.5, err… 5.0) and you run pstack on a java process, you’ll get to see all the java functions, including line numbers. Note the java frames with an asterisk in the example below.

$ cat Main.java
public class Main {
public static int go(int a) {
if (a == 0) {
for (;;)
continue;
}
return (1 + go(a - 1));
}
public static void main(String[] argv) {
System.out.println("running...");
go(10);
}
}
$ pstack `pgrep java`
144381: /usr/jdk/instances/jdk1.5.0/bin/java Main
-----------------  lwp# 1 / thread# 1  --------------------
9940dfae * Main.go(I)I+0
99402a3f * Main.go(I)I+11 (line 10)
99402a3f * Main.go(I)I+11 (line 10)
99402a3f * Main.go(I)I+11 (line 10)
99402a3f * Main.go(I)I+11 (line 10)
99402a3f * Main.go(I)I+11 (line 10)
99402a3f * Main.go(I)I+11 (line 10)
99402a3f * Main.go(I)I+11 (line 10)
99402a3f * Main.go(I)I+11 (line 10)
99402a3f * Main.go(I)I+11 (line 10)
99402a3f * Main.go(I)I+11 (line 10)
99402a3f * Main.main([Ljava/lang/String;)V+10 (line 15)
9f4dbbe4 * StubRoutines (1)
9f4dbbe4 __1cCosUos_exception_wrapper6FpFpnJJavaValue_pnMmethodHandle_pnRJavaCa
llArguments_pnGThread__v2468_v_ (8047130, 8047038, 8047068, 8074538, 804702c, 9f
4dbee8) + 14
9f4dbbe4 __1cCosUos_exception_wrapper6FpFpnJJavaValue_pnMmethodHandle_pnRJavaCa
llArguments_pnGThread__v2468_v_ (9f4dbc90, 8047130, 8047038, 8047068, 8074538) +
14
9f4dbee8 __1cJJavaCallsEcall6FpnJJavaValue_nMmethodHandle_pnRJavaCallArguments_
pnGThread__v_ (8047130, 8074ac4, 8047068, 8074538) + 28
9f6ee200 __1cRjni_invoke_static6FpnHJNIEnv__pnJJavaValue_pnI_jobject_nLJNICallT
ype_pnK_jmethodID_pnSJNI_ArgumentPusher_pnGThread__v_ (80745f4, 8047130, 0, 0, 8
072681, 804713c) + 180
9f59f7af jni_CallStaticVoidMethod (80745f4, 80750a0, 8072681, 80750b0) + 10f
080526ee main     (0, 806fbf8, 8047a04) + a4c
08051c0a ???????? (2, 8047ae0, 8047b05, 0, 8047b0a, 8047b31) + 8051c0a
-----------------  lwp# 2 / thread# 2  --------------------
9fb53e3c lwp_cond_wait (8160740, 8160728, 0, 0)
9f4b6182 __1cHMonitorEwait6Mil_i_ (81208c8, 1, 0) + 432
9f6bfcad __1cNGCTaskManagerIget_task6MI_pnGGCTask__ (81606c0, 0) + 90
[ ... ]

Recent Posts

April 21, 2013
February 28, 2013
August 14, 2012
July 28, 2012

Archives