This repository has been archived on 2022-05-21. You can view files and clone it, but cannot push or open issues or pull requests.
LEFTONE/tool/leak-check.sh
falsycat 84c3a02b9a [RELEASE] u22-v03
This version is submitted to U22 breau.
2020-09-14 00:00:00 +00:00

36 lines
586 B
Bash
Executable File

#!/bin/sh
# This script works only with memory-trace file generated in Linux.
file="memory-trace"
if [ ! -f $file ]; then
echo no memory trace file found
exit 1
fi
declare -A addrs
while read line; do
IFS=" " read -r type addr1 trash1 addr2 trash2 <<< $line
case "$type" in
"new")
addrs[$addr1]="allocated"
;;
"resize")
addrs[$addr1]="freed"
addrs[$addr2]="allocated"
;;
"delete")
addrs[$addr1]="freed"
;;
*) ;;
esac
done < $file
for addr in "${!addrs[@]}"; do
if [ "${addrs[$addr]}" == "allocated" ]; then
echo $addr
fi
done