intel: tools: dump: make dump tool reliable under gdb
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Fri, 20 Jul 2018 10:18:18 +0000 (11:18 +0100)
committerLionel Landwerlin <lionel.g.landwerlin@intel.com>
Fri, 20 Jul 2018 16:36:37 +0000 (17:36 +0100)
The problem with passing the configuration of the dump lib through a
file descriptor is that it can be read only once. But under gdb you
might want to rerun your program multiple times.

This change hands the configuration through a temporary file that is
deleted once the command line passes to intel_dump_gpu has exited.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Rafael Antognolli <rafael.antognolli@intel.com>
src/intel/tools/intel_dump_gpu.c
src/intel/tools/intel_dump_gpu.in

index 6ce7d45..1abe541 100644 (file)
@@ -349,7 +349,7 @@ maybe_init(void)
 
    initialized = true;
 
-   config = fdopen(3, "r");
+   config = fopen(getenv("INTEL_DUMP_GPU_CONFIG"), "r");
    while (fscanf(config, "%m[^=]=%m[^\n]\n", &key, &value) != EOF) {
       if (!strcmp(key, "verbose")) {
          if (!strcmp(value, "1")) {
index 9eea371..0454cff 100755 (executable)
@@ -82,7 +82,12 @@ done
 
 [ -z $file ] && add_arg "file=intel.aub"
 
+tmp_file=`mktemp`
+echo -e $args > $tmp_file
+
 LD_PRELOAD="@install_libexecdir@/libintel_dump_gpu.so${LD_PPRELOAD:+:$LD_PRELOAD}" \
-          exec -- "$@" 3<<EOF
-`echo -e $args`
-EOF
+          INTEL_DUMP_GPU_CONFIG=$tmp_file \
+          $@
+ret=$?
+rm $tmp_file
+exit $ret