#!/usr/bin/env bash
# Attach the HW-watchpoint login tracer to the running FIFA17.exe.
set -euo pipefail
DIR="$(cd "$(dirname "$0")" && pwd)"
PID="$(pgrep -x FIFA17.exe | head -1 || true)"
[ -z "${PID}" ] && { echo "FIFA17.exe not running"; exit 1; }
echo "attaching HW watchpoint to FIFA17.exe pid=${PID}"
TMP="$(mktemp /tmp/watch_login.XXXX.gdb)"
sed "s/PIDHERE/${PID}/" "${DIR}/watch_login.gdb" > "${TMP}"
gdb -batch -x "${TMP}" 2>&1 | tee /tmp/watch_login.log
rm -f "${TMP}"
