Skip to content

Commit

Permalink
Fix example
Browse files Browse the repository at this point in the history
  • Loading branch information
hp77-creator committed May 25, 2024
1 parent db1c0dd commit 551f795
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 18 deletions.
7 changes: 1 addition & 6 deletions example/libbpftime_example/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ LDFLAGS = -L$(HOME)/.bpftime
LDLIBS = -lbpftime -lboost_system -lrt -lbpf

SHM_SRC = main.cpp
SPDLOG_SRC = spdlog_exam.cpp

SHM_TARGET = shm_example
SPDLOG_TARGET = spdlog_exam

help:
@echo "Available targets:"
Expand All @@ -24,9 +22,6 @@ help:
shm_example: $(SHM_SRC) ## build shared memory example
$(CXX) -o $(SHM_TARGET) $(SHM_SRC) $(CXXFLAGS) $(LDFLAGS) $(LDLIBS)

sdplog_exam: $(SPDLOG_SRC) ## build spdlog example
$(CXX) -o $(SPDLOG_TARGET) $(SPDLOG_SRC) $(CXXFLAGS) $(LDFLAGS) $(LDLIBS)

.PHONY: clean
clean: ## clean the build
rm -f $(SHM_TARGET) $(SPDLOG_TARGET)
rm -f $(SHM_TARGET) example_shm.json
6 changes: 0 additions & 6 deletions example/libbpftime_example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,11 @@ run `make` and you will see the following output
```shell
Available targets:
shm_example build shared memory example
sdplog_exam build spdlog example
clean clean the build
```

command to execute the code:
when not using llvm-jit
```shell
g++ -o example main.cpp -I../../runtime/include -I../../vm/compat/include/ -I../../third_party/spdlog/include -I../../vm/vm-core/include -L~/.bpftime -lbpftime -lboost_system -lrt -lbpf
```

for `spdlog_exam.cpp`
```shell
g++ -o example spdlog_exam.cpp -I../../runtime/include -I../../vm/vm-core/compat/include -I../../vm/compat/include/ -I../../third_party/spdlog/include -L~/.bpftime -lbpftime -lboost_system -lrt -lbpf
```
12 changes: 12 additions & 0 deletions example/libbpftime_example/ebpf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"1": {
"type": "bpf_prog_handler",
"name": "example_prog",
"attr": {
"insns": "abcd1234ef567890",
"type": 1,
"cnt": 1,
"attach_fds": [2, 3]
}
}
}
8 changes: 7 additions & 1 deletion example/libbpftime_example/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@
int main() {
bpftime_initialize_global_shm(bpftime::shm_open_type::SHM_CREATE_OR_OPEN);
const char* jsonFileName = "example_shm.json";
const char* importJsonName = "ebpf.json";
SPDLOG_INFO("GLOBAL memory initialized ");
// load json program to shm
bpftime_import_global_shm_from_json(importJsonName);
// export it to another json file
bpftime_export_global_shm_to_json(jsonFileName);
// remove content from global shm
bpftime_remove_global_shm();
return 0;
}
}
5 changes: 0 additions & 5 deletions example/libbpftime_example/spdlog_exam.cpp

This file was deleted.

0 comments on commit 551f795

Please sign in to comment.