How to get the last batch buffer before GPU hang

For all GPU-hang bugs, the most helpful thing that any bug reporter can do is to run Linux 2.6.34-rc1 or later which will detect the GPU hang and record the last batch buffer before the hang to[*]:
/sys/kernel/debug/dri/0/i915_error_state

Anything from that file other than "no error state collected" is very interesting and very helpful for bug reports.

[*] If you don't have a /sys/kernel/debug/dri directory then ensure that debugfs is mounted as following:
sudo mount -t debugfs debugfs /sys/kernel/debug