File: fetch-usdts.awk

package info (click to toggle)
pcp 7.1.0-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 252,748 kB
  • sloc: ansic: 1,483,656; sh: 182,366; xml: 160,462; cpp: 83,813; python: 24,980; perl: 18,327; yacc: 6,877; lex: 2,864; makefile: 2,738; awk: 165; fortran: 60; java: 52
file content (76 lines) | stat: -rw-r--r-- 1,528 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
65
66
67
68
69
70
71
72
73
74
75
76
# SPDX-License-Identifier: BSD-2-Clause

function reset_entry()
{
	entry = "";
	grp  = "???";
	name = "???";
	base = "???";
	sema = "???";
	args = "???";
	argn = 0;
}

function print_entry()
{
	base_key = filename ":" base;
	if (base != 0 && !(base_key in basemap)) {
		basemap[base_key] = ++base_cnt;
	}

	sema_key = filename ":" sema;
	if (sema != 0 && !(sema_key in semamap)) {
		semamap[sema_key] = ++sema_cnt;
	}

	base_stub = (base == 0) ? "0" : sprintf("BASE%d", basemap[base_key]);
	sema_stub = (sema == 0) ? "0" : sprintf("SEMA%d", semamap[sema_key]);

	printf "%s:%s base=%s sema=%s argn=%d args=%s.\n",
	       grp, name, base_stub, sema_stub, argn, args;
}

BEGIN {
	reset_entry();
	filename = "";
}

#  stapsdt              0x0000003b       NT_STAPSDT (SystemTap probe descriptors)
#    Provider: test
#    Name: name4
#    Location: 0x0000000000401198, Base: 0x0000000000402043, Semaphore: 0x0000000000000000
#    Arguments: -4@$1 -4@$2 -4@$3 -4@$4

/File:/ {
	if (entry != "") {
		print_entry();
		reset_entry();
	}
	filename = $2;
}

/\sstapsdt\s/ {
	if (entry != "") {
		print_entry();
		reset_entry();
	}
	entry = $0;
	next
}

/Provider:/ { grp = $2; }
/Name:/ { name = $2; }
/Location:/ { base = strtonum($4); sema = strtonum($6); }
/Arguments:/ {
	arg_str = substr($0, index($0, "Arguments: ") + 11);
	# Count arguments by looking for patterns like "-4@" that start each argument
	argn = gsub(/-?[0-9]+@/, "&", arg_str);
	args = (argn > 0) ? arg_str : "";
}

END {
	if (entry != "")
	{
		print_entry();
	}
}