Skip to content

Commit

Permalink
Update examples and docs to use the new USDT API
Browse files Browse the repository at this point in the history
The BPF class constructor now accepts an array of USDT
contexts instead of just one object. Update the examples
in **examples/tracing** and docs in **docs** to reflect
this change.
  • Loading branch information
goldshtn committed Oct 17, 2016
1 parent 54c1d6f commit a2370ab
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions docs/reference_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ Constructors.

### 1. BPF

Syntax: ```BPF({text=BPF_program | src_file=filename} [, usdt=USDT_object])```
Syntax: ```BPF({text=BPF_program | src_file=filename} [, usdt_contexts=[USDT_object, ...]])```

Creates a BPF object. This is the main object for defining a BPF program, and interacting with its output.

Expand All @@ -569,7 +569,7 @@ b = BPF(src_file = "vfsreadlat.c")
# include a USDT object:
u = USDT(pid=int(pid))
[...]
b = BPF(text=bpf_text, usdt=u)
b = BPF(text=bpf_text, usdt_contexts=[u])
```

Examples in situ:
Expand All @@ -593,7 +593,7 @@ Examples:
# include a USDT object:
u = USDT(pid=int(pid))
[...]
b = BPF(text=bpf_text, usdt=u)
b = BPF(text=bpf_text, usdt_contexts=[u])
```

Examples in situ:
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorial_bcc_python_developer.md
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ u = USDT(pid=int(pid))
u.enable_probe(probe="http__server__request", fn_name="do_trace")

# initialize BPF
b = BPF(text=bpf_text, usdt=u)
b = BPF(text=bpf_text, usdt_contexts=[u])
```

Things to learn:
Expand All @@ -638,7 +638,7 @@ Things to learn:
1. ```bpf_probe_read(&path, sizeof(path), (void *)addr)```: Now the string ```addr``` points to into our ```path``` variable.
1. ```u = USDT(pid=int(pid))```: Initialize USDT tracing for the given PID.
1. ```u.enable_probe(probe="http__server__request", fn_name="do_trace")```: Attach our ```do_trace()``` BPF C function to the Node.js ```http__server__request``` USDT probe.
1. ```b = BPF(text=bpf_text, usdt=u)```: Need to pass in our USDT object, ```u```, to BPF object creation.
1. ```b = BPF(text=bpf_text, usdt_contexts=[u])```: Need to pass in our USDT object, ```u```, to BPF object creation.

### Lesson 16. task_switch.c

Expand Down
2 changes: 1 addition & 1 deletion examples/tracing/mysqld_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
print(bpf_text)

# initialize BPF
b = BPF(text=bpf_text, usdt=u)
b = BPF(text=bpf_text, usdt_contexts=[u])

# header
print("%-18s %-16s %-6s %s" % ("TIME(s)", "COMM", "PID", "QUERY"))
Expand Down
2 changes: 1 addition & 1 deletion examples/tracing/nodejs_http_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
print(bpf_text)

# initialize BPF
b = BPF(text=bpf_text, usdt=u)
b = BPF(text=bpf_text, usdt_contexts=[u])

# header
print("%-18s %-16s %-6s %s" % ("TIME(s)", "COMM", "PID", "ARGS"))
Expand Down

0 comments on commit a2370ab

Please sign in to comment.