[go: up one dir, main page]

File: strings.py

package info (click to toggle)
uftrace 0.18.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,356 kB
  • sloc: ansic: 49,770; python: 11,181; asm: 837; makefile: 769; sh: 637; cpp: 627; javascript: 191
file content (32 lines) | stat: -rw-r--r-- 793 bytes parent folder | download | duplicates (3)
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
#
# strings.py - print the unique strings of runtime function arguments and return values.
#
# uftrace-option: --nest-libcall --auto-args
#

strset = set()

def uftrace_entry(ctx):
    global strset
    if "args" in ctx:
        args = ctx["args"]
        for arg in args:
            if isinstance(arg, str):
                arg = arg.strip()
                if arg != "" and arg[:8] != "struct: ":
                    strset.add(arg)

def uftrace_exit(ctx):
    global strset
    if "retval" in ctx:
        ret = ctx["retval"]
        if isinstance(ret, str):
            ret = ret.strip()
            if ret != "" and ret[:8] != "struct: ":
                strset.add(ret)

def uftrace_end():
    global strset
    for strval in strset:
        print('"%s"' % strval)
        print("---")