| 1 |
#!/usr/bin/stap |
| 2 |
/* |
| 3 |
* killsnoop-nd.stp Trace process signals. |
| 4 |
* For Linux, uses SystemTap (non-debuginfo). |
| 5 |
* |
| 6 |
* Copyright (C) 2015 Brendan Gregg. |
| 7 |
* |
| 8 |
* This program is free software; you can redistribute it and/or modify |
| 9 |
* it under the terms of the GNU General Public License as published by |
| 10 |
* the Free Software Foundation; either version 2 of the License, or |
| 11 |
* (at your option) any later version. |
| 12 |
* |
| 13 |
* This program is distributed in the hope that it will be useful, |
| 14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
* GNU General Public License for more details. |
| 17 |
* |
| 18 |
* 24-Jun-2014 Brendan Gregg Created this. |
| 19 |
*/ |
| 20 |
|
| 21 |
global target; |
| 22 |
global signal; |
| 23 |
|
| 24 |
probe begin |
| 25 |
{ |
| 26 |
printf("%-6s %-12s %-5s %-6s %6s\n", "FROM", "COMMAND", "SIG", "TO", |
| 27 |
"RESULT"); |
| 28 |
} |
| 29 |
|
| 30 |
probe nd_syscall.kill |
| 31 |
{ |
| 32 |
/* |
| 33 |
* I could use the @entry shortcut on the return probe instead, but |
| 34 |
* wanted a full example of using global arrays directly. |
| 35 |
*/ |
| 36 |
target[tid()] = uint_arg(1); |
| 37 |
signal[tid()] = uint_arg(2); |
| 38 |
} |
| 39 |
|
| 40 |
probe nd_syscall.kill.return |
| 41 |
{ |
| 42 |
if (target[tid()] != 0) { |
| 43 |
printf("%-6d %-12s %-5d %-6d %6d\n", pid(), execname(), |
| 44 |
signal[tid()], target[tid()], int_arg(1)); |
| 45 |
delete target[tid()]; |
| 46 |
delete signal[tid()]; |
| 47 |
} |
| 48 |
} |