Skip to content

Commit

Permalink
Merge pull request #28 from parca-dev/download_libc
Browse files Browse the repository at this point in the history
Add glibc offsets
  • Loading branch information
kakkoyun authored Feb 22, 2024
2 parents 838a856 + 84476ee commit b5a0597
Show file tree
Hide file tree
Showing 37 changed files with 1,647 additions and 30 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/generate-glibc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Generate glibc
on:
workflow_call:
push:
branches:
- main
- release
paths:
- ".github/workflows/generate-glibc.yml"
- "pkg/libc/glibc"
- "scripts"
- "Makefile"

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
generate-and-create-branch:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Check out the code
uses: actions/checkout@v4

- name: Install devbox
uses: jetpack-io/[email protected]
with:
enable-cache: true

- name: Setup devbox
run: devbox run -- echo "done!"

- name: Load devbox shellenv
uses: HatsuneMiku3939/direnv-action@v1
with:
direnvVersion: 2.32.3

- name: Set up Go tool cache
uses: actions/cache@v4
with:
path: ~/.devbox/go
key: devbox-go-tools.cache-${{ runner.os }}-${{ runner.arch }}

- name: Build
run: make build

- name: Set up cache for downloaded files
uses: actions/cache@v4
with:
path: workspace-glibc
key: glibc-downloaded-${{ runner.os }}-${{ matrix.arch }}
restore-keys: |
glibc-downloaded-${{ runner.os }}-${{ matrix.arch }}
- name: Generate glibc Offsets
run: |
TEMP_DIR=workspace-glibc make generate/glibc
# If there are no changes (i.e. no diff exists with the checked-out base branch),
# no pull request will be created and the action exits silently.
- name: Create a pull-request
if: github.event_name != 'pull_request'
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "chore: update glibc layouts"
title: "chore: Update glibc layouts"
branch: update-offsets-glibc-${{ github.run_number }}
add-paths: pkg/libc/glibc/layout
base: main
labels: chore
draft: false
delete-branch: true
2 changes: 1 addition & 1 deletion .github/workflows/test-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ jobs:
${{ runner.arch }}-integration-runtimes
- name: Run integration tests
run: make ARCH="amd64" generate test/integration
run: make ARCH="amd64" generate/python generate/ruby test/integration
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ tmp

/structlayout
/mergelayout
/debdownload
/debuginfofind
/main
26 changes: 22 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,18 @@ structlayout: cmd/structlayout/structlayout.go $(filter-out *_test.go,$(GO_SRC))
mergelayout: cmd/mergelayout/mergelayout.go $(filter-out *_test.go,$(GO_SRC))
go build -o $@ $<

debdownload: cmd/debdownload/debdownload.go $(filter-out *_test.go,$(GO_SRC))
go build -o $@ $<

debuginfofind: cmd/debuginfofind/debuginfofind.go $(filter-out *_test.go,$(GO_SRC))
go build -o $@ $<

.PHONY: build
build: structlayout mergelayout
build: structlayout mergelayout debdownload debuginfofind
go build ./...

.PHONY: generate
generate: build generate/python generate/ruby
generate: build generate/python generate/ruby generate/glibc

.PHONY: generate/python
generate/python:
Expand All @@ -30,6 +36,12 @@ generate/ruby:
./scripts/structlayout/ruby.sh
./scripts/mergelayout/ruby.sh

.PHONY: generate/glibc
generate/glibc:
./scripts/download/glibc.sh
./scripts/structlayout/glibc.sh
./scripts/mergelayout/glibc.sh

.PHONY: clean
clean:
rm -rf target
Expand Down Expand Up @@ -80,9 +92,15 @@ $(TMPDIR)/structlayout-help.txt: $(TMPDIR) ./cmd/structlayout/structlayout.go
go run ./cmd/structlayout/structlayout.go -h > $@ 2>&1

$(TMPDIR)/mergelayout-help.txt: $(TMPDIR) ./cmd/mergelayout/mergelayout.go
go run ./cmd/mergelayout/mergelayout.go -h >> $@ 2>&1
go run ./cmd/mergelayout/mergelayout.go -h > $@ 2>&1

$(TMPDIR)/debdownload-help.txt: $(TMPDIR) ./cmd/debdownload/debdownload.go
go run ./cmd/debdownload/debdownload.go -h > $@ 2>&1

$(TMPDIR)/debuginfofind-help.txt: $(TMPDIR) ./cmd/debuginfofind/debuginfofind.go
go run ./cmd/debuginfofind/debuginfofind.go -h > $@ 2>&1

.PHONY: README.md
README.md: $(TMPDIR)/structlayout-help.txt $(TMPDIR)/mergelayout-help.txt
README.md: $(TMPDIR)/structlayout-help.txt $(TMPDIR)/mergelayout-help.txt $(TMPDIR)/debdownload-help.txt $(TMPDIR)/debuginfofind-help.txt
go run github.com/campoy/embedmd/v2@latest -w README.md
devbox generate readme CONTRIBUTING.md
35 changes: 29 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Under the `cmd` directory, you can find the following tools:
[embedmd]:# (tmp/structlayout-help.txt)
```txt
usage: structlayout [flags] <path-to-elf>
e.g: structlayout -m python -v 3.9.5 /usr/bin/python3.9
e.g: structlayout -r python -v 3.9.5 /usr/bin/python3.9
flags:
-o string
Expand All @@ -114,19 +114,42 @@ flags:
[embedmd]:# (tmp/mergelayout-help.txt)
```txt
usage: mergelayout -o outputDir <path-to-layout-files>
e.g: mergelayout -o /tmp/merged /tmp/python/*.yaml
e.g: mergelayout -o /tmp/merged '/tmp/python/*.yaml'
flags:
-i string
path to struct layout files (shorthand)
-input string
path to struct layout files. Can be a glob pattern.
-o string
output directory to write the merged layout file (shorthand)
-output string
output directory to write the merged layout file
```

### debdownload
[embedmd]:# (tmp/debdownload-help.txt)
```txt
NAME
debdownload
FLAGS
-o, --output STRING output directory to write the downloaded deb files
-t, --temp-dir STRING temporary directory to download deb files
-u, --url STRING URL to download deb files from
-p, --package STRING package name to download
-a, --arch STRING architectures to download
-c, --constraint STRING version constraints to download
```

### debuginfofind
[embedmd]:# (tmp/debuginfofind-help.txt)
```txt
NAME
debdownload
FLAGS
-d, --debuginfo-dir STRING directory to write the downloaded debuginfo files
```

## Acknowledgments

- [rbperf](https://github.com/javierhonduco/rbperf)
Expand Down
Loading

0 comments on commit b5a0597

Please sign in to comment.