Skip to content

Commit f7507bc

Browse files
committed
[pcode] refactor lifting scripts that use the Ghidra API for testability and maintainability, add tests and test environment, and add them into CI
1 parent 295132b commit f7507bc

43 files changed

Lines changed: 5649 additions & 2953 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 61 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,54 +5,62 @@
55
# the LICENSE file found in the root directory of this source tree.
66
#
77

8-
name: Build
9-
8+
name: CI
109
on:
1110
push:
1211
branches:
1312
- 'main'
14-
1513
tags:
1614
- '*'
17-
1815
pull_request:
1916
branches:
2017
- '*'
2118

2219
jobs:
23-
build:
20+
ghidra-script-gradle-tests:
21+
strategy:
22+
matrix:
23+
image-version: [22.04]
24+
runs-on: ubuntu-${{ matrix.image-version }}
25+
timeout-minutes: 20
26+
env:
27+
CI: true
28+
steps:
29+
- name: Clean Docker to prevent space issues
30+
run: |
31+
docker system prune -af --volumes || true
32+
- name: Clone the Patchestry repository
33+
uses: actions/checkout@v4
34+
with:
35+
submodules: true
36+
fetch-depth: 1
37+
- name: Build the Ghidra testing environment and run tests in it via Gradle
38+
run: |
39+
DOCKER_BUILDKIT=1 docker build -t trailofbits/decompile-test:latest -f test/decompile-test.dockerfile .
40+
docker run -it trailofbits/decompile-test
41+
42+
llvm-build-and-test:
2443
strategy:
2544
matrix:
2645
llvm-version: [20]
2746
image-version: [22.04]
2847
build-type: [Release, Debug]
2948
sanitizers: [OFF]
30-
3149
runs-on: ubuntu-${{ matrix.image-version }}
32-
timeout-minutes: 90
50+
timeout-minutes: 20
3351
container:
3452
image:
3553
ghcr.io/lifting-bits/patchestry-ubuntu-${{ matrix.image-version }}-llvm-${{ matrix.llvm-version }}-dev:latest
36-
37-
services:
38-
docker:
39-
image: docker:20.10-dind
40-
options: --privileged
41-
ports:
42-
- 2375:2375
43-
4454
env:
4555
CMAKE_PREFIX_PATH: "/usr/lib/llvm-${{ matrix.llvm-version }}/lib/cmake/mlir/;/usr/lib/llvm-${{ matrix.llvm-version }}/lib/cmake/clang/"
4656
LLVM_EXTERNAL_LIT: "/usr/local/bin/lit"
4757
ENABLE_SANITIZER_UNDEFINED_BEHAVIOR: ${{ matrix.sanitizers }}
4858
ENABLE_SANITIZER_ADDRESS: ${{ matrix.sanitizers }}
4959
CI: true
50-
5160
steps:
5261
- name: Clean Docker to prevent space issues
5362
run: |
5463
docker system prune -af --volumes || true
55-
5664
- name: Clone the Patchestry repository
5765
uses: actions/checkout@v4
5866
with:
@@ -63,14 +71,43 @@ jobs:
6371
run: cmake --preset ci -DPE_USE_VENDORED_Z3=OFF -DLLVM_EXTERNAL_LIT=$(which lit) -DLLVM_Z3_INSTALL_DIR=/usr/local
6472

6573
- name: Build ${{ matrix.build-type }} with sanitizers set ${{ matrix.sanitizers }}
66-
run: cmake --build --preset ci --config ${{ matrix.build-type }} -j $(nproc)
74+
run: cmake --build --preset ci --config ${{ matrix.build-type }} -j$(nproc)
75+
- name: Test ${{ matrix.build-type }} with sanitizers set ${{ matrix.sanitizers }}
76+
run: |
77+
lit ./builds/ci/test -D BUILD_TYPE=${{ matrix.build-type }} -v -DCI_OUTPUT_FOLDER=${{ github.workspace }}/builds/ci/test/ghidra/Output
6778
68-
- name: Build the headless docker image
79+
headless-image-build:
80+
needs: llvm-build-and-test
81+
strategy:
82+
matrix:
83+
llvm-version: [20]
84+
image-version: [22.04]
85+
runs-on: ubuntu-${{ matrix.image-version }}
86+
timeout-minutes: 20
87+
container:
88+
image:
89+
ghcr.io/lifting-bits/patchestry-ubuntu-${{ matrix.image-version }}-llvm-${{ matrix.llvm-version }}-dev:latest
90+
services:
91+
docker:
92+
image: docker:20.10-dind
93+
options: --privileged
94+
ports:
95+
- 2375:2375
96+
env:
97+
CMAKE_PREFIX_PATH: "/usr/lib/llvm-${{ matrix.llvm-version }}/lib/cmake/mlir/;/usr/lib/llvm-${{ matrix.llvm-version }}/lib/cmake/clang/"
98+
LLVM_EXTERNAL_LIT: "/usr/local/bin/lit"
99+
ENABLE_SANITIZER_UNDEFINED_BEHAVIOR: ${{ matrix.sanitizers }}
100+
ENABLE_SANITIZER_ADDRESS: ${{ matrix.sanitizers }}
101+
CI: true
102+
steps:
103+
- name: Clean Docker to prevent space issues
69104
run: |
70-
# Free more space before building Docker image
71105
docker system prune -af --volumes || true
72-
bash ./scripts/ghidra/build-headless-docker.sh
73-
74-
- name: Test ${{ matrix.build-type }} with sanitizers set ${{ matrix.sanitizers }}
106+
- name: Clone the Patchestry repository
107+
uses: actions/checkout@v4
108+
with:
109+
submodules: true
110+
fetch-depth: 1
111+
- name: Build the headless docker image
75112
run: |
76-
lit ./builds/ci/test -D BUILD_TYPE=${{ matrix.build-type }} -v -DCI_OUTPUT_FOLDER=${{ github.workspace }}/builds/ci/test/ghidra/Output
113+
bash ./scripts/ghidra/build-headless-docker.sh

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.z3*
12
**/.DS_Store
23
.idea/
34
.vs/

0 commit comments

Comments
 (0)