1*387f9dfdSAndroid Build Coastguard WorkerDemonstrations of uthreads. 2*387f9dfdSAndroid Build Coastguard Worker 3*387f9dfdSAndroid Build Coastguard Worker 4*387f9dfdSAndroid Build Coastguard Workeruthreads traces thread creation events in Java or raw (C) pthreads, and prints 5*387f9dfdSAndroid Build Coastguard Workerdetails about the newly created thread. For Java threads, the thread name is 6*387f9dfdSAndroid Build Coastguard Workerprinted; for pthreads, the thread's start function is printed, if there is 7*387f9dfdSAndroid Build Coastguard Workersymbol information to resolve it. 8*387f9dfdSAndroid Build Coastguard Worker 9*387f9dfdSAndroid Build Coastguard WorkerFor example, trace all Java thread creation events: 10*387f9dfdSAndroid Build Coastguard Worker 11*387f9dfdSAndroid Build Coastguard Worker# ./uthreads -l java 27420 12*387f9dfdSAndroid Build Coastguard WorkerTracing thread events in process 27420 (language: java)... Ctrl-C to quit. 13*387f9dfdSAndroid Build Coastguard WorkerTIME ID TYPE DESCRIPTION 14*387f9dfdSAndroid Build Coastguard Worker18.596 R=9/N=0 start SIGINT handler 15*387f9dfdSAndroid Build Coastguard Worker18.596 R=4/N=0 stop Signal Dispatcher 16*387f9dfdSAndroid Build Coastguard Worker^C 17*387f9dfdSAndroid Build Coastguard Worker 18*387f9dfdSAndroid Build Coastguard WorkerThe ID column in the preceding output shows the thread's runtime ID and native 19*387f9dfdSAndroid Build Coastguard WorkerID, when available. The accuracy of this information depends on the Java 20*387f9dfdSAndroid Build Coastguard Workerruntime. 21*387f9dfdSAndroid Build Coastguard Worker 22*387f9dfdSAndroid Build Coastguard Worker 23*387f9dfdSAndroid Build Coastguard WorkerNext, trace only pthread creation events in some native application: 24*387f9dfdSAndroid Build Coastguard Worker 25*387f9dfdSAndroid Build Coastguard Worker# ./uthreads 27450 26*387f9dfdSAndroid Build Coastguard WorkerTracing thread events in process 27450 (language: c)... Ctrl-C to quit. 27*387f9dfdSAndroid Build Coastguard WorkerTIME ID TYPE DESCRIPTION 28*387f9dfdSAndroid Build Coastguard Worker0.924 27462 pthread primes_thread [primes] 29*387f9dfdSAndroid Build Coastguard Worker0.927 27463 pthread primes_thread [primes] 30*387f9dfdSAndroid Build Coastguard Worker0.928 27464 pthread primes_thread [primes] 31*387f9dfdSAndroid Build Coastguard Worker0.928 27465 pthread primes_thread [primes] 32*387f9dfdSAndroid Build Coastguard Worker^C 33*387f9dfdSAndroid Build Coastguard Worker 34*387f9dfdSAndroid Build Coastguard WorkerThe thread name ("primes_thread" in this example) is resolved from debuginfo. 35*387f9dfdSAndroid Build Coastguard WorkerIf symbol information is not present, the thread's start address is printed 36*387f9dfdSAndroid Build Coastguard Workerinstead. 37*387f9dfdSAndroid Build Coastguard Worker 38*387f9dfdSAndroid Build Coastguard Worker 39*387f9dfdSAndroid Build Coastguard WorkerUSAGE message: 40*387f9dfdSAndroid Build Coastguard Worker 41*387f9dfdSAndroid Build Coastguard Worker# ./uthreads -h 42*387f9dfdSAndroid Build Coastguard Workerusage: uthreads.py [-h] [-l {c,java,none}] [-v] pid 43*387f9dfdSAndroid Build Coastguard Worker 44*387f9dfdSAndroid Build Coastguard WorkerTrace thread creation/destruction events in high-level languages. 45*387f9dfdSAndroid Build Coastguard Worker 46*387f9dfdSAndroid Build Coastguard Workerpositional arguments: 47*387f9dfdSAndroid Build Coastguard Worker pid process id to attach to 48*387f9dfdSAndroid Build Coastguard Worker 49*387f9dfdSAndroid Build Coastguard Workeroptional arguments: 50*387f9dfdSAndroid Build Coastguard Worker -h, --help show this help message and exit 51*387f9dfdSAndroid Build Coastguard Worker -l {c,java,none}, --language {c,java,none} 52*387f9dfdSAndroid Build Coastguard Worker language to trace (none for pthreads only) 53*387f9dfdSAndroid Build Coastguard Worker -v, --verbose verbose mode: print the BPF program (for debugging 54*387f9dfdSAndroid Build Coastguard Worker purposes) 55*387f9dfdSAndroid Build Coastguard Worker 56*387f9dfdSAndroid Build Coastguard Workerexamples: 57*387f9dfdSAndroid Build Coastguard Worker ./uthreads -l java 185 # trace Java threads in process 185 58*387f9dfdSAndroid Build Coastguard Worker ./uthreads -l none 12245 # trace only pthreads in process 12245 59