Author: Remi Meier <[email protected]>
Branch: stmgc-c8
Changeset: r83582:075e0be3c2d2
Date: 2016-04-08 10:55 +0300
http://bitbucket.org/pypy/pypy/changeset/075e0be3c2d2/

Log:    make perf map work for "perf top"

diff --git a/rpython/jit/backend/x86/perf_map.py 
b/rpython/jit/backend/x86/perf_map.py
--- a/rpython/jit/backend/x86/perf_map.py
+++ b/rpython/jit/backend/x86/perf_map.py
@@ -24,6 +24,7 @@
 
     fprintf(pypy_perf_map_file, "%lx %lx %s\n", start_addr,
             end_addr - start_addr, name);
+    fflush(pypy_perf_map_file);
 }
 """])
 
diff --git a/rpython/tool/perf-disassemble.sh b/rpython/tool/perf-disassemble.sh
new file mode 100755
--- /dev/null
+++ b/rpython/tool/perf-disassemble.sh
@@ -0,0 +1,50 @@
+#!/bin/bash
+#
+# Using this script instead of objdump enables perf to disassemble
+# and annotate any JIT code (given a symbol file).
+#
+# To run perf without root:
+#   kernel.perf_event_paranoid = -1
+# To trace a process without root:
+#   kernel.yama.ptrace_scope = 0
+#
+# Example usage:
+# $ dolphin-emu -P /tmp -b -e $game
+# $ perf top -p $(pidof dolphin-emu) --objdump ./Tools/perf-disassemble.sh
+
+flavor=att
+raw=r
+src=
+
+
+[[ "${@: -1}" != /tmp/perf-*.map ]] && { objdump "$@"; exit; }
+
+pid=0
+start=0
+stop=0
+
+for a in "$@"; do
+    case "$a" in
+        /tmp/perf-*.map)
+          pid="${a#/tmp/perf-}"
+          pid="${pid%.map}"
+          shift
+          ;;
+        -M | --no-show-raw | -S | -C | -l | -d)
+          shift
+            ;;
+        --start-address=*)
+            start="${a##--start-address=}"
+            shift
+            ;;
+        --stop-address=*)
+            stop="${a##--stop-address=}"
+            shift
+            ;;
+        -*)
+            echo "Unknown parameter '$1'" >&2
+            exit 1
+            ;;
+    esac
+done
+gdb -q -p $pid -ex "set disassembly $flavor" -ex "disas /$raw$src 
$start,$stop" -ex q -batch
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to