File: sanitize.awk

package info (click to toggle)
ocaml 5.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 44,372 kB
  • sloc: ml: 370,196; ansic: 52,820; sh: 27,419; asm: 5,462; makefile: 3,684; python: 974; awk: 278; javascript: 273; perl: 59; fortran: 21; cs: 9
file content (61 lines) | stat: -rw-r--r-- 2,171 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
# Replace sections of LLDB and GDB output
# This primarily looks for hex addresses, process ids, filepaths and
# other specific details of the machine the test is running on.
{
    # Replace single quoted file paths
    gsub(/'(.*)'/,"'XXXX'")

    # Replace target create for executable
    gsub(/target create "(.*)"/,"target create \"XXXX\"")

    # Replace hex addresses, not offset values less than 4 digits.
    gsub(/0x[0-9a-f][0-9a-f][0-9a-f][0-9a-f]+/, "0x00000000000000")

    # Sanitise executable name in image lookup
    gsub("5 matches found in /(.*):$", "5 matches found in XXXX")

    # Replace debug process forked by lldb
    gsub("Process ([0-9]+)", "Process XXXX")

    # Replace debug process forked by gdb
    gsub("[Inferior 1 (process [0-9]+) exited normally]", "[Inferior 1 (process XXXX) exited normally]")

    # Replace architecture identifiers
    gsub("(x86_64)", "$ARCH")
    gsub("(arm64)", "$ARCH")
    gsub("(riscv64)", "$ARCH")

    # Replace offsets in disassembly output
    gsub(/\<\+[0-9]+\>/, "<+XX>")

    # Replace comments with blank comments
    gsub(/; [a-zA-Z0-9._+ ]+/, ";")

    # Replace line numbers in runtime files - one rule for lldb, one for gdb
    # (it would be better to only match on runtime/*.c, but gsub does not
    # handle ERE)
    gsub(/.c:[0-9]+:[0-9]+/, ".c:XX")
    gsub(/.c:[0-9]+/, ".c:XX")

    # Replace libpath. Different distributions have different naming
    # schemes.
    gsub(/Using host libthread_db library "\/(.*)\/libthread_db\.so\.1"\./,
         "Using host libthread_db library \"/XXXX/libthread_db.so.1\".")

    # Replace line number when setting breakpoints in GDB.
    gsub(/line [0-9]+/, "line XXX")

    # Work around inconsistent name mangling
    gsub(/c_to_ocaml_[0-9]+/, "c_to_ocaml")

    gsub("warning: This version of LLDB", "This version of LLDB")
    gsub("This version of LLDB has no plugin for the language \"assembler\". Inspection of frame variables will be limited.", "")
    # Replace printed match results
    gsub("1 match found in /(.*):$", "1 match found in \"XXXX\":")

    # Remove trailing blanks
    gsub(/[ \t]+$/, "")

    if ($0 != "")
      print $0
}