perf-disassemble.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/bash
  2. #
  3. # Using this script instead of objdump enables perf to disassemble
  4. # and annotate any JIT code (given a symbol file).
  5. #
  6. # To run perf without root:
  7. # kernel.perf_event_paranoid = -1
  8. # To trace a process without root:
  9. # kernel.yama.ptrace_scope = 0
  10. #
  11. # Example usage:
  12. # $ dolphin-emu -C Dolphin.Core.PerfMapDir=/tmp -b -e $game
  13. # $ perf top -p $(pidof dolphin-emu) --objdump ./Tools/perf-disassemble.sh -M intel
  14. flavor=att
  15. raw=r
  16. src=
  17. [[ "${@: -1}" != /tmp/perf-*.map ]] && { objdump "$@"; exit; }
  18. while [ "$1" ]
  19. do
  20. case "$1" in
  21. -M)
  22. flavor=$2
  23. shift
  24. ;;
  25. --start-address=*)
  26. start="${1##--start-address=}"
  27. ;;
  28. --stop-address=*)
  29. stop="${1##--stop-address=}"
  30. ;;
  31. --no-show-raw-insn)
  32. raw=
  33. ;;
  34. --no-show-raw)
  35. raw=
  36. ;;
  37. -S)
  38. src=m
  39. ;;
  40. -[ldC])
  41. ;;
  42. -*)
  43. echo "Unknown parameter '$1'"
  44. ;;
  45. *)
  46. ;;
  47. esac
  48. shift
  49. done
  50. gdb -q -p $(pidof dolphin-emu) -ex "set disassembly $flavor" -ex "disas /$raw$src $start,$stop" -ex q -batch