Skip to content

Commit

Permalink
fix action
Browse files Browse the repository at this point in the history
Signed-off-by: LiuLingze <[email protected]>
  • Loading branch information
GorilaMond committed May 26, 2024
1 parent 7c31b61 commit 8bae27f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 49 deletions.
37 changes: 15 additions & 22 deletions .github/workflows/ebpf_stack_analyser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,38 +23,31 @@ jobs:

- name: Install native lib dependencies
run: |
git submodule update --init --recursive
git submodule update --init --recursive eBPF_Supermarket/Stack_Analyser/ MagicEyes/
sudo apt install clang libelf1 libelf-dev zlib1g-dev
- name: Run app with native lib
- name: Compile test examples
run: |
cd eBPF_Supermarket/Stack_Analyser/testdir
gcc -o ./usdt_pthread -lpthread ./usdt_pthread.c
gcc -o ./uprobe_malloc ./uprobe_malloc.c
- name: Compile and run app with native lib
run: |
cd eBPF_Supermarket/Stack_Analyser
make
make -j$(nproc)
sudo ./stack_analyzer on_cpu off_cpu memleak io readahead llc_stat probe "vfs_open" probe "t:sched:sched_switch" -d 5
gcc -o ./testdir/usdt_pthread ./testdir/usdt_pthread.c
sudo ./stack_analyzer probe "u:pthread:pthread_create" -c "./testdir/usdt_pthread" -d 5
gcc -o ./testdir/uprobe_malloc ./testdir/uprobe_malloc.c
sudo ./stack_analyzer probe "c:malloc" -c "./testdir/uprobe_malloc" -d 5
magic-eyes-build-and-test:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3

- name: Install native lib dependencies
run: |
git submodule update --init --recursive
sudo apt install clang libelf1 libelf-dev zlib1g-dev
- name: Run app with native lib
- name: Compile and run MagicEyes app with native lib
run: |
mkdir -p MagicEyes/build
cd MagicEyes/build
cmake -DBUILD_STACK_ANALYZER=ON ..
make
sudo ./src/backend/system_diagnosis/stack_analyzer/stack_analyzer on_cpu off_cpu memleak io readahead llc_stat probe vfs_open -d 5
sudo ./src/backend/system_diagnosis/stack_analyzer/stack_analyzer probe "p::vfs_open" probe "t:sched:sched_switch" -d 5
sudo ./src/backend/system_diagnosis/stack_analyzer/stack_analyzer probe "c:malloc" -c "../../eBPF_Supermarket/Stack_Analyser/testdir/uprobe_malloc" -d 5
make -j$(nproc)
sudo ./src/backend/system_diagnosis/stack_analyzer/stack_analyzer on_cpu off_cpu memleak io readahead llc_stat probe "p::vfs_open" probe "t:sched:sched_switch" -d 5
sudo ./src/backend/system_diagnosis/stack_analyzer/stack_analyzer probe "u:pthread:pthread_create" -c "../../eBPF_Supermarket/Stack_Analyser/testdir/usdt_pthread" -d 5
sudo ./src/backend/system_diagnosis/stack_analyzer/stack_analyzer probe "c:malloc" -c "../../eBPF_Supermarket/Stack_Analyser/testdir/uprobe_malloc" -d 5
40 changes: 13 additions & 27 deletions eBPF_Supermarket/Stack_Analyser/testdir/usdt_pthread.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,28 @@
#include <sys/types.h>

// 线程函数
void *thread_function(void *arg) {
while (1) {
void *thread_function(void *arg)
{
while (1)
{
// 打印当前线程的pid
printf("Thread ID: %d\n", gettid());
// 等待一秒
sleep(1);
}
pthread_exit(NULL);
}
};

// 创建线程的函数
void create_thread() {
pthread_t thread;
int rc;
int main()
{

// 创建线程
rc = pthread_create(&thread, NULL, thread_function, NULL);
if (rc) {
fprintf(stderr, "Error: pthread_create() failed with code %d\n", rc);
pthread_t thread;
if (pthread_create(&thread, NULL, thread_function, NULL))
{
fprintf(stderr, "Error: pthread_create() failed\n");
exit(EXIT_FAILURE);
}
}

int main() {
// 打印主进程的pid
printf("Main process ID: %d\n", gettid());

// 调用函数创建线程
create_thread();

// 主进程死循环打印pid
while (1) {
printf("Main process ID: %d\n", getpid());
// 等待一秒
sleep(1);
}
thread_function(NULL);

return 0;
}
};

0 comments on commit 8bae27f

Please sign in to comment.