Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- BINNAME="$1"
- SRCPATH="${2:-./src}"
- YW="\e[33m"
- RD="\e[31m"
- NC="\e[0m"
- if [ -z "$BINNAME" ]; then
- echo -e "${YW}This little script will print out all the functions that you defined in your code, but you're not using in the final binary (yes the static ones too)."
- echo -e "If you have done the bonuses and compiled the mandatory binary, this will probably flag functions that you do use in the bonus part. Watch out for false-positives.${NC}\n"
- echo -e "${RD}Usage: $0 <binary-name> [source-path]${NC}" >&2
- exit 1
- fi
- if [ ! -d "$SRCPATH" ]; then
- echo -e "${RD}Source path \`${SRCPATH}\` not found. Run without arguments for usage.${NC}"
- exit 1
- fi
- comm -23 \
- <(ctags -R --languages=C --c-kinds=f --fields=+n --output-format=json "$SRCPATH" |
- jq -r 'select(._type == "tag" and .kind == "function") | .name' |
- sort -u) \
- <(nm -g "$BINNAME" 2>/dev/null |
- awk '{ print $3 }' |
- sort -u)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement