Sasha Goldshtein | c0a6352 | 2016-10-29 13:44:55 -0700 | [diff] [blame] | 1 | Demonstrations of uthreads. |
| 2 | |
| 3 | |
| 4 | uthreads traces thread creation events in Java or raw pthreads, and prints |
| 5 | details about the newly created thread. For Java threads, the thread name is |
| 6 | printed; for pthreads, the thread's start function is printed, if there is |
| 7 | symbol information to resolve it. |
| 8 | |
| 9 | For example, trace all Java thread creation events: |
| 10 | |
| 11 | # ./uthreads -l java 27420 |
| 12 | Tracing thread events in process 27420 (language: java)... Ctrl-C to quit. |
| 13 | TIME ID TYPE DESCRIPTION |
| 14 | 18.596 R=9/N=0 start SIGINT handler |
| 15 | 18.596 R=4/N=0 stop Signal Dispatcher |
| 16 | ^C |
| 17 | |
| 18 | The ID column in the preceding output shows the thread's runtime ID and native |
| 19 | ID, when available. The accuracy of this information depends on the Java |
| 20 | runtime. |
| 21 | |
| 22 | |
| 23 | Next, trace only pthread creation events in some native application: |
| 24 | |
| 25 | # ./uthreads 27450 |
| 26 | Tracing thread events in process 27450 (language: none)... Ctrl-C to quit. |
| 27 | TIME ID TYPE DESCRIPTION |
Sasha Goldshtein | b1bff01 | 2017-02-08 23:25:28 -0500 | [diff] [blame] | 28 | 0.924 27462 pthread primes_thread [primes] |
| 29 | 0.927 27463 pthread primes_thread [primes] |
| 30 | 0.928 27464 pthread primes_thread [primes] |
| 31 | 0.928 27465 pthread primes_thread [primes] |
Sasha Goldshtein | c0a6352 | 2016-10-29 13:44:55 -0700 | [diff] [blame] | 32 | ^C |
| 33 | |
| 34 | The thread name ("primes_thread" in this example) is resolved from debuginfo. |
| 35 | If symbol information is not present, the thread's start address is printed |
| 36 | instead. |
| 37 | |
| 38 | |
| 39 | USAGE message: |
| 40 | |
| 41 | # ./uthreads -h |
Paul Chaignon | 4bb6d7f | 2017-03-30 19:05:40 +0200 | [diff] [blame] | 42 | usage: uthreads.py [-h] [-l {java,none}] [-v] pid |
Sasha Goldshtein | c0a6352 | 2016-10-29 13:44:55 -0700 | [diff] [blame] | 43 | |
| 44 | Trace thread creation/destruction events in high-level languages. |
| 45 | |
| 46 | positional arguments: |
| 47 | pid process id to attach to |
| 48 | |
| 49 | optional arguments: |
| 50 | -h, --help show this help message and exit |
Paul Chaignon | 4bb6d7f | 2017-03-30 19:05:40 +0200 | [diff] [blame] | 51 | -l {java,none}, --language {java,none} |
Sasha Goldshtein | c0a6352 | 2016-10-29 13:44:55 -0700 | [diff] [blame] | 52 | language to trace (none for pthreads only) |
| 53 | -v, --verbose verbose mode: print the BPF program (for debugging |
| 54 | purposes) |
| 55 | |
| 56 | examples: |
| 57 | ./uthreads -l java 185 # trace Java threads in process 185 |
| 58 | ./uthreads 12245 # trace only pthreads in process 12245 |