rbbcc 0.11.6 → 0.11.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/lib/rbbcc/table.rb +8 -7
  4. data/lib/rbbcc/version.rb +1 -1
  5. data/rbbcc.gemspec +5 -2
  6. metadata +2 -62
  7. data/docs/README.md +0 -7
  8. data/docs/answers/01-hello-world.rb +0 -16
  9. data/docs/answers/02-sys_sync.rb +0 -18
  10. data/docs/answers/03-hello_fields.rb +0 -33
  11. data/docs/answers/04-sync_timing.rb +0 -46
  12. data/docs/answers/05-sync_count.rb +0 -54
  13. data/docs/answers/06-disksnoop.rb +0 -71
  14. data/docs/answers/07-hello_perf_output.rb +0 -59
  15. data/docs/answers/08-sync_perf_output.rb +0 -60
  16. data/docs/answers/09-bitehist.rb +0 -32
  17. data/docs/answers/10-disklatency.rb +0 -51
  18. data/docs/answers/11-vfsreadlat.c +0 -46
  19. data/docs/answers/11-vfsreadlat.rb +0 -66
  20. data/docs/answers/12-urandomread.rb +0 -38
  21. data/docs/answers/13-disksnoop_fixed.rb +0 -108
  22. data/docs/answers/14-strlen_count.rb +0 -46
  23. data/docs/answers/15-nodejs_http_server.rb +0 -44
  24. data/docs/answers/16-task_switch.c +0 -23
  25. data/docs/answers/16-task_switch.rb +0 -17
  26. data/docs/answers/node-server.js +0 -11
  27. data/docs/getting_started.md +0 -154
  28. data/docs/projects_using_rbbcc.md +0 -43
  29. data/docs/tutorial_bcc_ruby_developer.md +0 -774
  30. data/docs/tutorial_bcc_ruby_developer_japanese.md +0 -770
  31. data/examples/bitehist.rb +0 -46
  32. data/examples/charty/Gemfile +0 -11
  33. data/examples/charty/Gemfile.lock +0 -48
  34. data/examples/charty/bitehist-unicode.rb +0 -87
  35. data/examples/collectsyscall.rb +0 -182
  36. data/examples/dddos.rb +0 -112
  37. data/examples/disksnoop.rb +0 -73
  38. data/examples/dns_blocker.rb +0 -134
  39. data/examples/example.gif +0 -0
  40. data/examples/extract_arg.rb +0 -26
  41. data/examples/hello_fields.rb +0 -32
  42. data/examples/hello_perf_output.rb +0 -64
  43. data/examples/hello_ring_buffer.rb +0 -64
  44. data/examples/hello_world.rb +0 -6
  45. data/examples/kvm_hypercall.rb +0 -69
  46. data/examples/lsm_sockblock.rb +0 -141
  47. data/examples/mallocstack.rb +0 -63
  48. data/examples/networking/http_filter/http-parse-simple.c +0 -114
  49. data/examples/networking/http_filter/http-parse-simple.rb +0 -85
  50. data/examples/pin_maps_a.rb +0 -88
  51. data/examples/pin_maps_b.rb +0 -71
  52. data/examples/py-orig/sockblock.py +0 -119
  53. data/examples/ringbuf_pin_a.rb +0 -51
  54. data/examples/ringbuf_pin_b.rb +0 -29
  55. data/examples/ruby_usdt.rb +0 -105
  56. data/examples/sbrk_trace.rb +0 -204
  57. data/examples/ssl_http_trace.rb +0 -274
  58. data/examples/syscalluname.rb +0 -39
  59. data/examples/table.rb +0 -15
  60. data/examples/tools/bashreadline.rb +0 -83
  61. data/examples/tools/execsnoop.rb +0 -229
  62. data/examples/tools/runqlat.rb +0 -148
  63. data/examples/urandomread-explicit.rb +0 -58
  64. data/examples/urandomread.rb +0 -39
  65. data/examples/usdt-test.rb +0 -6
  66. data/examples/usdt.rb +0 -26
@@ -1,148 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # @lint-avoid-python-3-compatibility-imports
3
- #
4
- # runqlat Run queue (scheduler) latency as a histogram.
5
- # For Linux, uses BCC, eBPF.
6
- #
7
- # USAGE: runqlat [-h] [-T] [-m] [-P] [-L] [-p PID] [interval] [count]
8
- #
9
- # This measures the time a task spends waiting on a run queue for a turn
10
- # on-CPU, and shows this time as a histogram. This time should be small, but a
11
- # task may need to wait its turn due to CPU load.
12
- #
13
- # This measures two types of run queue latency:
14
- # 1. The time from a task being enqueued on a run queue to its context switch
15
- # and execution. This traces ttwu_do_wakeup(), wake_up_new_task() ->
16
- # finish_task_switch() with either raw tracepoints (if supported) or kprobes
17
- # and instruments the run queue latency after a voluntary context switch.
18
- # 2. The time from when a task was involuntary context switched and still
19
- # in the runnable state, to when it next executed. This is instrumented
20
- # from finish_task_switch() alone.
21
- #
22
- # Copyright 2016 Netflix, Inc.
23
- # Licensed under the Apache License, Version 2.0 (the "License")
24
- #
25
- # 07-Feb-2016 Brendan Gregg Created this.
26
-
27
- require 'rbbcc'
28
- include RbBCC
29
-
30
- bpf_text = <<TXT
31
- #include <uapi/linux/ptrace.h>
32
- #include <linux/sched.h>
33
- #include <linux/nsproxy.h>
34
- #include <linux/pid_namespace.h>
35
-
36
- typedef struct pid_key {
37
- u64 id; // work around
38
- u64 slot;
39
- } pid_key_t;
40
-
41
- typedef struct pidns_key {
42
- u64 id; // work around
43
- u64 slot;
44
- } pidns_key_t;
45
-
46
- BPF_HASH(start, u32);
47
- STORAGE
48
-
49
- struct rq;
50
-
51
- // record enqueue timestamp
52
- static int trace_enqueue(u32 tgid, u32 pid)
53
- {
54
- if (FILTER || pid == 0)
55
- return 0;
56
- u64 ts = bpf_ktime_get_ns();
57
- start.update(&pid, &ts);
58
- return 0;
59
- }
60
- TXT
61
-
62
- bpf_text_raw_tp = <<TXT
63
- RAW_TRACEPOINT_PROBE(sched_wakeup)
64
- {
65
- // TP_PROTO(struct task_struct *p)
66
- struct task_struct *p = (struct task_struct *)ctx->args[0];
67
- return trace_enqueue(p->tgid, p->pid);
68
- }
69
-
70
- RAW_TRACEPOINT_PROBE(sched_wakeup_new)
71
- {
72
- // TP_PROTO(struct task_struct *p)
73
- struct task_struct *p = (struct task_struct *)ctx->args[0];
74
- return trace_enqueue(p->tgid, p->pid);
75
- }
76
-
77
- RAW_TRACEPOINT_PROBE(sched_switch)
78
- {
79
- // TP_PROTO(bool preempt, struct task_struct *prev, struct task_struct *next)
80
- struct task_struct *prev = (struct task_struct *)ctx->args[1];
81
- struct task_struct *next = (struct task_struct *)ctx->args[2];
82
- u32 pid, tgid;
83
-
84
- // ivcsw: treat like an enqueue event and store timestamp
85
- if (prev->state == TASK_RUNNING) {
86
- tgid = prev->tgid;
87
- pid = prev->pid;
88
- if (!(FILTER || pid == 0)) {
89
- u64 ts = bpf_ktime_get_ns();
90
- start.update(&pid, &ts);
91
- }
92
- }
93
-
94
- tgid = next->tgid;
95
- pid = next->pid;
96
- if (FILTER || pid == 0)
97
- return 0;
98
- u64 *tsp, delta;
99
-
100
- // fetch timestamp and calculate delta
101
- tsp = start.lookup(&pid);
102
- if (tsp == 0) {
103
- return 0; // missed enqueue
104
- }
105
- delta = bpf_ktime_get_ns() - *tsp;
106
- FACTOR
107
-
108
- // store as histogram
109
- STORE
110
-
111
- start.delete(&pid);
112
- return 0;
113
- }
114
- TXT
115
-
116
- is_support_raw_tp = BCC.support_raw_tracepoint
117
- if is_support_raw_tp
118
- bpf_text += bpf_text_raw_tp
119
- else
120
- raise "BCC.support_raw_tracepoint is false; Unsupported kernel version: ${`uname -a`.chomp}"
121
- end
122
-
123
- bpf_text.gsub!('FILTER', '0')
124
- bpf_text.gsub!('FACTOR', 'delta /= 1000;')
125
- label = "usecs"
126
- bpf_text.gsub!('STORAGE', 'BPF_HISTOGRAM(dist);')
127
- bpf_text.gsub!('STORE',
128
- 'dist.increment(bpf_log2l(delta));')
129
- section = ""
130
-
131
- b = BCC.new(text: bpf_text)
132
-
133
- puts("Tracing run queue latency... Hit Ctrl-C to end.")
134
-
135
- # TODO: interval
136
- loop do
137
- begin
138
- sleep 1
139
- rescue Interrupt
140
- puts
141
- break
142
- end
143
- end
144
-
145
- dist = b.get_table("dist")
146
- dist.print_log2_hist(label, section_header: section, section_print_fn: :to_i)
147
- # dist.clear()
148
- exit
@@ -1,58 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # urandomread-explicit.rb Example of instrumenting a kernel tracepoint.
4
- # For Linux, uses BCC, BPF. Embedded C.
5
- # Originally urandomread-explicit.py in BCC
6
- #
7
- # This is an older example of instrumenting a tracepoint, which defines
8
- # the argument struct and makes an explicit call to attach_tracepoint().
9
- # See urandomread for a newer version that uses TRACEPOINT_PROBE().
10
- #
11
- # REQUIRES: Linux 4.7+ (BPF_PROG_TYPE_TRACEPOINT support).
12
- #
13
- # Test by running this, then in another shell, run:
14
- # dd if=/dev/urandom of=/dev/null bs=1k count=5
15
- #
16
- # Copyright 2016 Netflix, Inc.
17
- # Licensed under the Apache License, Version 2.0 (the "License")
18
-
19
- # FIXME: random/urandom_read is removed from newer kernel!!
20
-
21
- require 'rbbcc'
22
- include RbBCC
23
-
24
- # define BPF program
25
- bpf_text = <<CLANG
26
- #include <uapi/linux/ptrace.h>
27
-
28
- struct urandom_read_args {
29
- // from /sys/kernel/debug/tracing/events/random/urandom_read/format
30
- u64 __unused__;
31
- u32 got_bits;
32
- u32 pool_left;
33
- u32 input_left;
34
- };
35
-
36
- int printarg(struct urandom_read_args *args) {
37
- bpf_trace_printk("%d\\n", args->got_bits);
38
- return 0;
39
- }
40
- CLANG
41
-
42
- # load BPF program
43
- b = BCC.new(text: bpf_text)
44
- b.attach_tracepoint(tp: "random:urandom_read", fn_name: "printarg")
45
-
46
- # header
47
- printf("%-18s %-16s %-6s %s\n", "TIME(s)", "COMM", "PID", "GOTBITS")
48
-
49
- # format output
50
- loop do
51
- begin
52
- b.trace_fields do |task, pid, cpu, flags, ts, msg|
53
- puts("%-18.9f %-16s %-6d %s" % [ts, task, pid, msg])
54
- end
55
- rescue Interrupt
56
- exit
57
- end
58
- end
@@ -1,39 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # urandomread.rb Example of instrumenting a kernel tracepoint.
4
- # For Linux, uses BCC, BPF. Embedded C.
5
- #
6
- # REQUIRES: Linux 4.7+ (BPF_PROG_TYPE_TRACEPOINT support).
7
- #
8
- # Test by running this, then in another shell, run:
9
- # dd if=/dev/urandom of=/dev/null bs=1k count=5
10
- #
11
- # Copyright 2016 Netflix, Inc.
12
- # Licensed under the Apache License, Version 2.0 (the "License")
13
-
14
- # FIXME: random/urandom_read is removed from newer kernel!!
15
-
16
- require 'rbbcc'
17
- include RbBCC
18
-
19
- b = BCC.new(text: %|
20
- TRACEPOINT_PROBE(random, urandom_read) {
21
- // args is from /sys/kernel/debug/tracing/events/random/urandom_read/format
22
- bpf_trace_printk("%d\\n", args->got_bits);
23
- return 0;
24
- }
25
- |)
26
-
27
- # header
28
- printf("%-18s %-16s %-6s %s\n", "TIME(s)", "COMM", "PID", "GOTBITS")
29
-
30
- # format output
31
- loop do
32
- begin
33
- b.trace_fields do |task, pid, cpu, flags, ts, msg|
34
- puts("%-18.9f %-16s %-6d %s" % [ts, task, pid, msg])
35
- end
36
- rescue Interrupt
37
- exit
38
- end
39
- end
@@ -1,6 +0,0 @@
1
- require 'rbbcc/usdt'
2
- include RbBCC
3
- usdt = USDT.new(pid: 13909)
4
- usdt.enable_probe(probe: 'mruby', fn_name: 'test')
5
- Clib.bcc_usdt_foreach_uprobe(usdt.context, Clib::UsdtUprobeAttachCallback)
6
-
data/examples/usdt.rb DELETED
@@ -1,26 +0,0 @@
1
- require 'rbbcc'
2
- include RbBCC
3
-
4
- pid = ARGV[0]
5
-
6
- bpf_text = <<CLANG
7
- #include <uapi/linux/ptrace.h>
8
- int do_trace(struct pt_regs *ctx) {
9
- long buf, tgt;
10
- bpf_usdt_readarg(1, ctx, &buf);
11
- bpf_probe_read(&tgt, sizeof(tgt), (void *)&buf);
12
- bpf_trace_printk("%ld\\n", tgt);
13
- return 0;
14
- };
15
- CLANG
16
-
17
- u = USDT.new(pid: pid.to_i)
18
- u.enable_probe(probe: "ruby", fn_name: "do_trace")
19
-
20
- b = BCC.new(text: bpf_text, usdt_contexts: [u])
21
-
22
- printf("%-18s %-16s %-6s %s\n", "TIME(s)", "COMM", "PID", "value")
23
-
24
- b.trace_fields do |task, pid, cpu, flags, ts, msg|
25
- printf("%-18.9f %-16s %-6d %s", ts, task, pid, msg)
26
- end