Skip to content

Commit

Permalink
dubug
Browse files Browse the repository at this point in the history
  • Loading branch information
xlauko committed Sep 6, 2024
1 parent 31fc3fd commit c3dda08
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 20 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ jobs:
- name: Build ${{ matrix.build-type }} with sanitizers set ${{ matrix.sanitizers }}
run: cmake --build --preset ci --config ${{ matrix.build-type }} -j $(nproc)

- name: Build the headless docker image
run: bash ./scripts/ghidra/build-headless-docker.sh

- name: Test ${{ matrix.build-type }} with sanitizers set ${{ matrix.sanitizers }}
run: |
bash ./scripts/ghidra/build-headless-docker.sh
cmake --preset ci
ctest --preset ci --build-config ${{ matrix.build-type }}
echo ${{ github.workspace }}
lit ./builds/ci/test -v
13 changes: 13 additions & 0 deletions scripts/ghidra/decompile-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,27 @@
# the LICENSE file found in the root directory of this source tree.
#

set -x

ls /

if [ "$#" -lt 3 ]; then
echo "Usage: $0 <input_file> <function_name> <output_file>"
exit 1
fi

INPUT_PATH=$1
if [ ! -f $INPUT_PATH ]; then
echo "Input file does not exist"
exit 1
fi

FUNCTION_NAME=$2
OUTPUT_PATH=$3
if [ ! -f $OUTPUT_PATH ]; then
echo "Output file does not exist"
exit 1
fi

# Create a new Ghidra project and import the file
${GHIDRA_HEADLESS} ${GHIDRA_PROJECTS} patchestry-decompilation \
Expand Down
17 changes: 16 additions & 1 deletion scripts/ghidra/decompile-headless.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# the LICENSE file found in the root directory of this source tree.
#

set -x

show_help() {
echo "Usage: $0 [OPTIONS]"
echo
Expand All @@ -23,7 +25,7 @@ show_help() {
INPUT_PATH=""
FUNCTION_NAME=""
OUTPUT_PATH=""
VERBOSE=false
VERBOSE=true
INTERACTIVE=false

while [[ $# -gt 0 ]]; do
Expand Down Expand Up @@ -103,7 +105,20 @@ absolute_path() {
INPUT_ABS_PATH=$(absolute_path "$INPUT_PATH")
OUTPUT_ABS_PATH=$(absolute_path "$OUTPUT_PATH")

echo "$GITHUB_WORKSPACE"

if [ ! -e "$INPUT_ABS_PATH" ]; then
echo "Error: Input file does not exist: $INPUT_ABS_PATH"
exit 1
fi

if [ ! -e "$OUTPUT_ABS_PATH" ]; then
echo "Error: Output file does not exist: $OUTPUT_ABS_PATH"
exit 1
fi

RUN="docker run --rm \
-v "/var/run/docker.sock":"/var/run/docker.sock" \
-v \"$INPUT_ABS_PATH:/input.o\" \
-v \"$OUTPUT_ABS_PATH:/output.json\" \
trailofbits/patchestry-decompilation:latest"
Expand Down
16 changes: 0 additions & 16 deletions test/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,5 @@
for tool in tools:
llvm_config.add_tool_substitutions([tool])

# # Add test directory to substitutions
# config.substitutions.append(('%test_dir', os.path.join(config.test_source_root, 'ghidra')))

# Add PATH to substitutions
config.substitutions.append(('%PATH%', config.environment['PATH']))

# config.substitutions.append(
# ('%decompile-headless', config.decompiler_headless_tool
# f"'{config.python_executable}' -c '"
# f"import subprocess;"
# f"import sys;"
# f"args = sys.argv[1:4];"
# f"print(args);"
# f"args[1] = \"{config.function_prefix}\" + args[1]; "
# f"result = subprocess.run([\"{config.decompiler_headless_tool}\"] + args, capture_output=True, text=True); "
# f"print(result.stdout + result.stderr); "
# f"sys.exit(result.returncode)' ")
# )

0 comments on commit c3dda08

Please sign in to comment.