File: dump.lua

package info (click to toggle)
uftrace 0.13-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 5,212 kB
  • sloc: ansic: 53,313; python: 9,846; makefile: 838; asm: 703; cpp: 602; sh: 560; javascript: 191
file content (64 lines) | stat: -rw-r--r-- 1,988 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
-- uftrace-option: --auto-args --nest-libcall
-- UFTRACE_FUNCS = [ "foo", "bar" ]

function uftrace_begin(ctx)
    print('uftrace_begin(ctx)')
    print(string.format('  record  : %s', ctx['record']))
    print(string.format('  version : %s', ctx['version']))
    if ctx['cmds'] ~= nil then
        print(string.format('  cmds    : %s', table.concat(ctx['cmds'], ' ')))
    end
    print('')
end

function uftrace_entry(ctx)
    local _tid        = ctx['tid']
    local _depth      = ctx['depth']
    local _time       = ctx['timestamp']
    -- _duration = ctx["duration"]        -- exit only
    local _address    = ctx['address']
    local _name       = ctx['name']

    local unit = 1000000000
    print(string.format('%d.%09d %6d: [entry] %s(%x) depth: %d',
            _time / unit, _time % unit, _tid, _name, _address, _depth))

    if ctx['args'] ~= nil then
        for i, arg in ipairs(ctx['args']) do
            print(string.format('  args[%d] %s: %s', i, type(arg), arg))
        end
    end
end

function uftrace_exit(ctx)
    local _tid        = ctx['tid']
    local _depth      = ctx['depth']
    local _time       = ctx['timestamp']
    local _duration   = ctx["duration"]        -- not used here
    local _address    = ctx["address"]
    local _name       = ctx["name"]

    local unit = 1000000000
    print(string.format('%d.%09d %6d: [exit ] %s(%x) depth: %d',
            _time / unit, _time % unit, _tid, _name, _address, _depth))

    if ctx['retval'] ~= nil then
        local ret = ctx['retval']
        print(string.format('  retval  %s: %s', type(ret), ret))
    end
end

function uftrace_event(ctx)
    local _tid        = ctx['tid']
    local _time       = ctx['timestamp']
    local _address    = ctx["address"]
    local _name       = ctx["name"]

    local unit = 1000000000
    print(string.format('%d.%09d %6d: [event] %s(%x)',
            _time / unit, _time % unit, _tid, _name, _address))
end

function uftrace_end()
    print('\nuftrace_end()')
end