Skip to content

Commit

Permalink
limit the syscalls to track on examples/systrack.lua
Browse files Browse the repository at this point in the history
* see #96
  • Loading branch information
lneto committed Mar 11, 2024
1 parent 17f0994 commit e6e0691
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions examples/systrack.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,19 @@
-- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--

local linux = require("linux")
local probe = require("probe")
local device = require("device")
local syscall = require("syscall.table")
local linux = require("linux")
local probe = require("probe")
local device = require("device")
local systab = require("syscall.table")

local track = {}
local syscalls = {"openat", "read", "write", "readv", "writev", "close"}

local function nop() end -- do nothing

local s = linux.stat
local driver = {name = "systrack", open = nop, release = nop, mode = s.IRUGO}

local track = {}
local toggle = true
function driver:read()
local log = ""
Expand All @@ -45,9 +46,12 @@ function driver:read()
return log
end

for symbol, address in pairs(syscall) do
for _, symbol in ipairs(syscalls) do
local address = systab[symbol]
track[symbol] = 0

local function handler()
track[symbol] = (track[symbol] or 0) + 1
track[symbol] = track[symbol] + 1
end

probe.new(address, {pre = handler, post = nop})
Expand Down

0 comments on commit e6e0691

Please sign in to comment.