mesa/src/intel/tools
Antonio Ospite ddf2aa3a4d build: avoid redefining unreachable() which is standard in C23
In the C23 standard unreachable() is now a predefined function-like
macro in <stddef.h>

See https://android.googlesource.com/platform/bionic/+/HEAD/docs/c23.md#is-now-a-predefined-function_like-macro-in

And this causes build errors when building for C23:

-----------------------------------------------------------------------
In file included from ../src/util/log.h:30,
                 from ../src/util/log.c:30:
../src/util/macros.h:123:9: warning: "unreachable" redefined
  123 | #define unreachable(str)    \
      |         ^~~~~~~~~~~
In file included from ../src/util/macros.h:31:
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:456:9: note: this is the location of the previous definition
  456 | #define unreachable() (__builtin_unreachable ())
      |         ^~~~~~~~~~~
-----------------------------------------------------------------------

So don't redefine it with the same name, but use the name UNREACHABLE()
to also signify it's a macro.

Using a different name also makes sense because the behavior of the
macro was extending the one of __builtin_unreachable() anyway, and it
also had a different signature, accepting one argument, compared to the
standard unreachable() with no arguments.

This change improves the chances of building mesa with the C23 standard,
which for instance is the default in recent AOSP versions.

All the instances of the macro, including the definition, were updated
with the following command line:

  git grep -l '[^_]unreachable(' -- "src/**" | sort | uniq | \
  while read file; \
  do \
    sed -e 's/\([^_]\)unreachable(/\1UNREACHABLE(/g' -i "$file"; \
  done && \
  sed -e 's/#undef unreachable/#undef UNREACHABLE/g' -i src/intel/isl/isl_aux_info.c

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36437>
2025-07-31 17:49:42 +00:00
..
imgui
aub_mem.c
aub_mem.h
aub_read.c
aub_read.h
aub_write.c build: avoid redefining unreachable() which is standard in C23 2025-07-31 17:49:42 +00:00
aub_write.h
aubinator.c intel/tools: Fix batch buffer decoder 2025-05-01 13:27:44 +00:00
aubinator_error_decode.c intel/tools: Fix batch buffer decoder 2025-05-01 13:27:44 +00:00
aubinator_error_decode_lib.c
aubinator_error_decode_lib.h
aubinator_error_decode_xe.c intel/tools: Skip dump of binaries in unknown sections 2025-05-28 20:26:55 +00:00
aubinator_error_decode_xe.h
aubinator_viewer.cpp intel/tools: Add helpers for decoder_init/disasm 2025-01-30 00:45:59 +00:00
aubinator_viewer.h
aubinator_viewer_decoder.cpp
aubinator_viewer_urb.h
error2aub.c intel/tools: move ascii85_decode to common code 2025-04-02 19:26:55 +00:00
error2hangdump.c intel/tools: move ascii85_decode to common code 2025-04-02 19:26:55 +00:00
error2hangdump_lib.c
error2hangdump_lib.h
error2hangdump_xe.c intel/tools: Rename and better detect topic changes 2025-05-28 20:26:55 +00:00
error2hangdump_xe.h
error_decode_lib.c intel/tools: move ascii85_decode to common code 2025-04-02 19:26:55 +00:00
error_decode_lib.h intel/tools: move ascii85_decode to common code 2025-04-02 19:26:55 +00:00
error_decode_xe_lib.c intel/tools: Rename and better detect topic changes 2025-05-28 20:26:55 +00:00
error_decode_xe_lib.h intel/tools: Rename and better detect topic changes 2025-05-28 20:26:55 +00:00
gfx8_context.h
gfx10_context.h
intel_aub.h
intel_context.h
intel_dev_info.c intel/tools: Reflect SIMD lane count for EUs in device info output 2025-06-10 06:55:27 +00:00
intel_dump_gpu.c
intel_dump_gpu.in
intel_hang_replay.c build: avoid redefining unreachable() which is standard in C23 2025-07-31 17:49:42 +00:00
intel_hang_viewer.cpp build: avoid redefining unreachable() which is standard in C23 2025-07-31 17:49:42 +00:00
intel_measure.py intel/tools: add intel_measure.py 2025-05-19 17:27:30 +00:00
intel_monitor.c intel/perf: intel_monitor documentation tweak 2025-05-23 19:57:02 +00:00
intel_monitor_eustall.c intel/tools: fix 32b build for EU stall tool 2025-04-09 21:40:46 +00:00
intel_monitor_eustall.h intel/tools: create intel_monitor for sampling eu stalls 2025-04-08 19:39:53 +00:00
intel_noop_drm_shim.c intel/shim: Report I915_PARAM_HAS_GEN7_SOL_RESET. 2025-06-18 23:11:37 +00:00
intel_sanitize_gpu.c
intel_sanitize_gpu.in
intel_stub_gpu.in
intel_tools.c intel/tools: Fix batch buffer decoder 2025-05-01 13:27:44 +00:00
intel_tools.h intel/tools: Fix batch buffer decoder 2025-05-01 13:27:44 +00:00
meson.build intel: fix monitor build dependencies 2025-06-22 10:55:21 +00:00
README.md

aubinator_error_decode

This tool allows decode an error state dump generated by the kernel driver.

Make a copy of the error state file (i915) :

$ sudo cp /sys/devices/pci0000:00/0000:00:02.0/drm/card0/error /tmp/error
$ sudo chmod go+rw /tmp/error

Make a copy of the error state file (Xe) :

$ sudo cp /sys/class/drm/card0/device/devcoredump/data /tmp/error
$ sudo chmod go+rw /tmp/error

Then visualize the error state (from the mesa build directory) :

$ ./src/intel/tools/aubinator_error_decode /tmp/error

intel_stub_gpu

This tool allows faking a particular device at the ioctl level. This is useful to test compiler changes (using shader-db/fossils-db replays) across a number of device you don't necessarily have access too.

Faking a DG2 device :

$ intel_stub_gpu -p dg2 fossilize-replay /path/to/fossilize.foz --enable-pipeline-stats /tmp/dg2.csv

Faking a ICL device :

$ intel_stub_gpu -p icl fossilize-replay /path/to/fossilize.foz --enable-pipeline-stats /tmp/icl.csv

intel_error2hangdump

This tool converts an error state dump into an uncompressed/easy-to-modify binary file (format described in src/intel/common/intel_hang_dump.h).

Capture the error state (i915) :

$ sudo cp /sys/devices/pci0000:00/0000:00:02.0/drm/card0/error /tmp/error
$ sudo chmod go+rw /tmp/error

Capture the error state (Xe) :

$ sudo cp /sys/class/drm/card0/device/devcoredump/data /tmp/error
$ sudo chmod go+rw /tmp/error

Convert an error state (from the mesa build directory) :

$ ./src/intel/tools/intel_error2hang /tmp/error

A resulting error.dmp file will be created

intel_hang_replay

This tool replays a binary file generated by intel_error2hangdump.

From the mesa build directory :

$ ./src/intel/tools/intel_hang_replay -d /tmp/error.dmp

intel_hang_viewer

This tool is a editor/visualizer for the file generated by intel_error2hangdump. When replaying on simulation a few tweaks might be needed in order for the simulator to accept the input commands (this is due to divergences between the simulation & HW implementations).

To visualize a file generated from a DG2 error state (from the mesa build directory) :

./src/intel/tools/intel_hang_viewer -p dg2 /tmp/error.dmp

To visualize and edit a file generated from a DG2 error state (from the mesa build directory) :

./src/intel/tools/intel_hang_viewer -e -p dg2 /tmp/error.dmp