]>
Commit | Line | Data |
---|---|---|
94ff46dc A |
1 | #!/usr/local/bin/recon |
2 | ||
3 | local ktrace = require 'ktrace' | |
4 | ||
5 | if not arg[1] or arg[1] == '-h' then | |
6 | print[[ | |
7 | usage: ktruss <syscall-name> [<more-names> ...] | |
8 | ||
9 | Use Kernel TRace to print User Space Syscalls (ktruss).]] | |
10 | os.exit(arg[1] == nil) | |
11 | end | |
12 | ||
13 | local sess = ktrace.Session.new() | |
14 | ||
15 | for i = 1, #arg do | |
16 | sess:add_callback_pair('BSC_' .. arg[i], function (start, finish) | |
17 | print(('%s[%d]: %s(0x%x, 0x%x, 0x%x, 0x%x) -> %d'):format( | |
18 | sess:procname_for_threadid(start.threadid), | |
19 | sess:pid_for_threadid(start.threadid), arg[1], start[1], start[2], | |
20 | start[3], start[4], finish[2])) | |
21 | end) | |
22 | end | |
23 | ||
24 | local ok, err = sess:start() | |
25 | if not ok then | |
26 | io.stderr:write('tracing failed: ', err, '\n') | |
27 | os.exit(1) | |
28 | end |