Commit 914ace79 authored by Brendan Gregg's avatar Brendan Gregg Committed by GitHub

Merge pull request #362 from iovisor/nits

use structs with semicolons
parents e73f69c9 85dba931
...@@ -20,9 +20,10 @@ This is a work in progress. If something is missing, check the bpftrace source t ...@@ -20,9 +20,10 @@ This is a work in progress. If something is missing, check the bpftrace source t
- [2. `/.../`: Filtering](#2--filtering) - [2. `/.../`: Filtering](#2--filtering)
- [3. `//`, `/*`: Comments](#3---comments) - [3. `//`, `/*`: Comments](#3---comments)
- [4. `->`: C Struct Navigation](#4---c-struct-navigation) - [4. `->`: C Struct Navigation](#4---c-struct-navigation)
- [5. `? :`: ternary operators](#5---ternary-operators) - [5. `struct`: Struct Declaration](#5-struct-struct-declaration)
- [6. `if () {...} else {...}`: if-else statements](#6-if---else--if-else-statements) - [6. `? :`: ternary operators](#6---ternary-operators)
- [7. `unroll () {...}`: unroll](#7-unroll---unroll) - [7. `if () {...} else {...}`: if-else statements](#7-if---else--if-else-statements)
- [8. `unroll () {...}`: unroll](#8-unroll---unroll)
- [Probes](#probes) - [Probes](#probes)
- [1. `kprobe`/`kretprobe`: Dynamic Tracing, Kernel-Level](#1-kprobekretprobe-dynamic-tracing-kernel-level) - [1. `kprobe`/`kretprobe`: Dynamic Tracing, Kernel-Level](#1-kprobekretprobe-dynamic-tracing-kernel-level)
- [2. `kprobe`/`kretprobe`: Dynamic Tracing, Kernel-Level Arguments](#2-kprobekretprobe-dynamic-tracing-kernel-level-arguments) - [2. `kprobe`/`kretprobe`: Dynamic Tracing, Kernel-Level Arguments](#2-kprobekretprobe-dynamic-tracing-kernel-level-arguments)
...@@ -441,7 +442,22 @@ open path: retrans_time_ms ...@@ -441,7 +442,22 @@ open path: retrans_time_ms
This uses dynamic tracing of the `vfs_open()` kernel function, via the short script path.bt. Some kernel headers needed to be included to understand the `path` and `dentry` structs. This uses dynamic tracing of the `vfs_open()` kernel function, via the short script path.bt. Some kernel headers needed to be included to understand the `path` and `dentry` structs.
## 5. `? :`: ternary operators ## 5. `struct`: Struct Declaration
Example:
```
// from fs/namei.c:
struct nameidata {
struct path path;
struct qstr last;
// [...]
};
```
You can define your own structs when needed. In some cases, kernel structs are not declared in the kernel headers package, and are declared manually in bpftrace tools (or partial structs are: enough to reach the member to dereference).
## 6. `? :`: ternary operators
Example: Example:
...@@ -454,7 +470,7 @@ Attaching 1 probe... ...@@ -454,7 +470,7 @@ Attaching 1 probe...
@error[0]: 78 @error[0]: 78
``` ```
## 6. `if () {...} else {...}`: if-else statements ## 7. `if () {...} else {...}`: if-else statements
Example: Example:
...@@ -467,7 +483,7 @@ Attaching 1 probe... ...@@ -467,7 +483,7 @@ Attaching 1 probe...
@reads: 80 @reads: 80
``` ```
## 7. `unroll () {...}`: Unroll ## 8. `unroll () {...}`: Unroll
Example: Example:
......
...@@ -23,7 +23,7 @@ struct nameidata { ...@@ -23,7 +23,7 @@ struct nameidata {
struct path path; struct path path;
struct qstr last; struct qstr last;
// [...] // [...]
} };
BEGIN BEGIN
{ {
......
...@@ -21,7 +21,7 @@ struct cfs_rq_partial { ...@@ -21,7 +21,7 @@ struct cfs_rq_partial {
unsigned long runnable_weight; unsigned long runnable_weight;
unsigned int nr_running; unsigned int nr_running;
unsigned int h_nr_running; unsigned int h_nr_running;
} };
BEGIN BEGIN
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment