build: stop tracking generated tutorial artifacts (#215)

* build: stop tracking generated tutorial artifacts

* build: avoid duplicating the goroutine offset

---------

Co-authored-by: LinuxDev9002 <i@littlefisher.me>
This commit is contained in:
云微
2026-07-14 06:32:13 -07:00
committed by GitHub
parent 964b65b53d
commit 929aec4441
10 changed files with 66 additions and 102939 deletions

View File

@@ -6,3 +6,4 @@ package.json
package.yaml
ecli
goroutine
/go-server-http/main

View File

@@ -75,21 +75,31 @@ char LICENSE[] SEC("license") = "GPL";
## Running the Program
To run this tracing program, follow these steps:
Run the following commands from `src/31-goroutine`. The eBPF program attaches to
`./go-server-http/main`, so the target binary is generated locally rather than
stored in Git. Use Go 1.17.13 to match the checked-in `GOID_OFFSET` value; verify
the offset before tracing a binary built with another Go version.
1. **Compile the eBPF Code**: Compile the eBPF program using a compiler like `ecc` (eBPF Compiler Collection) and generate a package that can be loaded by an eBPF loader.
1. **Build and start the target program**: Keep the HTTP server running, then use a second terminal for the remaining commands.
```bash
make -C go-server-http
sudo ./go-server-http/main
```
2. **Compile the eBPF Code**: Compile the eBPF program using a compiler like `ecc` (eBPF Compiler Collection) and generate a package that can be loaded by an eBPF loader.
```bash
ecc goroutine.bpf.c goroutine.h
```
2. **Run the eBPF Program**: Use an eBPF loader to run the compiled eBPF program.
3. **Run the eBPF Program**: Use an eBPF loader to run the compiled eBPF program.
```bash
ecli-rs run package.json
```
3. **Output**: The program will output the state transitions of goroutines along with their `goid`, `pid`, and `tgid`. Here’s an example of the output:
4. **Output**: The program will output the state transitions of goroutines along with their `goid`, `pid`, and `tgid`. Here’s an example of the output:
```console
TIME STATE GOID PID TGID

View File

@@ -73,21 +73,31 @@ char LICENSE[] SEC("license") = "GPL";
## 运行程序
要运行此跟踪程序,请按照以下步骤操作:
请从 `src/31-goroutine` 目录运行以下命令。eBPF 程序会附加到
`./go-server-http/main`,因此目标二进制文件应在本地生成,不再存储在 Git
中。请使用 Go 1.17.13 以匹配当前 `GOID_OFFSET`;如果使用其他 Go 版本构建,
请先重新验证该偏移量。
1. **编译 eBPF 代码**:使用类似 `ecc`(eBPF 编译集合)这样的编译器编译 eBPF 程序,并生成一个可以由 eBPF 加载器加载的包。
1. **构建并启动目标程序**:保持 HTTP 服务运行,然后在另一个终端执行后续命令。
```bash
make -C go-server-http
sudo ./go-server-http/main
```
2. **编译 eBPF 代码**:使用类似 `ecc`(eBPF 编译集合)这样的编译器编译 eBPF 程序,并生成一个可以由 eBPF 加载器加载的包。
```bash
ecc goroutine.bpf.c goroutine.h
```
2. **运行 eBPF 程序**:使用 eBPF 加载器运行编译后的 eBPF 程序。
3. **运行 eBPF 程序**:使用 eBPF 加载器运行编译后的 eBPF 程序。
```bash
ecli-rs run package.json
```
3. **输出**:程序将输出协程的状态转换及其 `goid`、`pid` 和 `tgid`。以下是一个示例输出:
4. **输出**:程序将输出协程的状态转换及其 `goid`、`pid` 和 `tgid`。以下是一个示例输出:
```console
TIME STATE GOID PID TGID

View File

@@ -0,0 +1,16 @@
GO ?= go
BINARY := main
.PHONY: all clean
all: $(BINARY)
$(BINARY): main.go
@version="$$($(GO) version)"; \
case "$$version" in \
*" go1.17."*) ;; \
*) echo "warning: the goroutine goid offset was validated with Go 1.17; verify it for $$version" >&2 ;; \
esac
$(GO) build -o $@ $<
clean:
rm -f $(BINARY)

Binary file not shown.