]> git.saurik.com Git - apple/xnu.git/blame - tools/trace/ktruss.lua
xnu-6153.41.3.tar.gz
[apple/xnu.git] / tools / trace / ktruss.lua
CommitLineData
94ff46dc
A
1#!/usr/local/bin/recon
2
3local ktrace = require 'ktrace'
4
5if not arg[1] or arg[1] == '-h' then
6 print[[
7usage: ktruss <syscall-name> [<more-names> ...]
8
9Use Kernel TRace to print User Space Syscalls (ktruss).]]
10 os.exit(arg[1] == nil)
11end
12
13local sess = ktrace.Session.new()
14
15for 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)
22end
23
24local ok, err = sess:start()
25if not ok then
26 io.stderr:write('tracing failed: ', err, '\n')
27 os.exit(1)
28end