summaryrefslogtreecommitdiffstats
path: root/userspace/cuda/tools/ghidra_index_merge.sh
blob: 44479e947399d6162bc852dccf2240a54799190a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/bash
# SPDX-License-Identifier: BSD-3-Clause
#
# ghidra_index_merge.sh - merge the per-chunk decompiled_index.tsv files from
# ghidra_batch_decompile.sh into one sorted index and print coverage stats.
#
# Usage: ghidra_index_merge.sh <outdir>
set -euo pipefail
OUTDIR="${1:?usage: $0 <outdir>}"

head -1 "$OUTDIR"/index/bucket_*.tsv | head -1 > "$OUTDIR/decompiled_index.tsv"
cat "$OUTDIR"/index/bucket_*.tsv | grep -v '^addr' | sort -t$'\t' -k1,1 >> "$OUTDIR/decompiled_index.tsv"

total=$(grep -c . "$OUTDIR/decompiled_index.tsv" || true)
failed=$(grep -c $'\tfailed$' "$OUTDIR/decompiled_index.tsv" || true)
skipped=$(grep -c 'skipped-huge' "$OUTDIR/decompiled_index.tsv" || true)
echo "[index] rows=$((total-1)) failed=$failed skipped-huge=$skipped"
echo "[index] $OUTDIR/decompiled_index.tsv"