summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJerome Glisse <jglisse@redhat.com>2012-10-24 15:40:07 -0400
committerJerome Glisse <jglisse@redhat.com>2012-10-24 14:47:59 -0400
commitfb4cc9ec04c171b74d482bee54f52909d92a1a55 (patch)
treeec84d708deeb3cb8840255de3f26e9a99ce29522
parent16fc3852069a9e0faac9965adf4b4836a9a6c971 (diff)
gdb script to intercept fglrx command stream
Script will intercept and dump fglrx command stream. Only works with amd-driver-installer-12-3-x86.x86_64.run Signed-off-by: Jerome Glisse <jglisse@redhat.com>
-rwxr-xr-xfglrx-gen-breakpoint.sh19
-rw-r--r--fglrx-trace-cs.gdb19
-rwxr-xr-xrun.sh5
3 files changed, 41 insertions, 2 deletions
diff --git a/fglrx-gen-breakpoint.sh b/fglrx-gen-breakpoint.sh
new file mode 100755
index 0000000..e1f1925
--- /dev/null
+++ b/fglrx-gen-breakpoint.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+addr=`cat .tmp1 | grep fglrx_dri | sed -e 's/^\(0x[0-9a-fA-F]\+\).*/\1/'`
+# 0x1983091 was found using valgrind by intercepting write to
+# what was identified to be indirect buffer mapped into userspace
+# this offset is heavily dependant on which fglrx version you
+# are using in this case amd-driver-installer-12-3-x86.x86_64.run or
+# amd-driver-installer-12-2-x86.x86_64.run (i dont remember ;))
+addr=$(($addr + 0x1983091))
+printf "break *0x%x\n" $addr > .tmp2
+echo "commands" >> .tmp2
+echo " set \$idx = 0" >> .tmp2
+echo " while \$idx < \$ebx" >> .tmp2
+echo " set \$off = \$idx / 4" >> .tmp2
+echo ' printf "[%5d] [%5d] 0x%08x\n", $ibidx, $off, ((unsigned*)$rsi)[$off]' >> .tmp2
+echo " set \$idx = \$idx + 4" >> .tmp2
+echo " end" >> .tmp2
+echo " set \$ibidx = \$ibidx + 1" >> .tmp2
+echo " continue" >> .tmp2
+echo "end" >> .tmp2
diff --git a/fglrx-trace-cs.gdb b/fglrx-trace-cs.gdb
new file mode 100644
index 0000000..27e976d
--- /dev/null
+++ b/fglrx-trace-cs.gdb
@@ -0,0 +1,19 @@
+set logging file .tmp1
+set breakpoint pending on
+set pagination off
+set logging overwrite on
+set logging on
+set confirm off
+set $ibidx = 0
+
+break glutDisplayFunc
+commands
+ silent
+ info sharedlibrary fglrx_dri
+ set logging off
+ shell ./fglrx-gen-breakpoint.sh
+ source .tmp2
+ continue
+end
+
+run
diff --git a/run.sh b/run.sh
index 01c31e2..467e4a5 100755
--- a/run.sh
+++ b/run.sh
@@ -1,10 +1,11 @@
#!/bin/sh
+export DISPLAY=:0
output=`./amd-gpu-name`
rdb_name=`echo $output | cut --delimiter='-' -f1`
for i in `find ./ -name 'gl*' -executable` ; do
e=`basename $i`
echo $e
- $i 2> .tmp
+ sudo gdb -batch -x fglrx-trace-cs.gdb --args $i > .tmp 2>&1
~/git/rdb/rdb_annotateib .tmp ~/git/rdb/$rdb_name.rdb > $output-$e.txt
- rm .tmp
+ sudo rm .tmp*
done