When running gdb, make sure to pass the LD_PRELOAD variable only to
the executed program, not the debugger. Otherwise the debugger will
run the preloaded constructor/destructor too and bad things will
happen.
Suggested-by: Rafael Antognolli <rafael.antognolli@intel.com>
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Rafael Antognolli <rafael.antognolli@intel.com>
exit 0
}
+ld_preload="@install_libexecdir@/libintel_dump_gpu.so${LD_PPRELOAD:+:$LD_PRELOAD}"
args=""
file=""
+gdb=""
function add_arg() {
arg=$1
add_arg "device=${1##--device=}"
shift
;;
+ --gdb)
+ gdb=1
+ shift
+ ;;
+ -g)
+ gdb=1
+ shift
+ ;;
--help)
show_help
;;
tmp_file=`mktemp`
echo -e $args > $tmp_file
-LD_PRELOAD="@install_libexecdir@/libintel_dump_gpu.so${LD_PPRELOAD:+:$LD_PRELOAD}" \
- INTEL_DUMP_GPU_CONFIG=$tmp_file \
- $@
+if [ -z $gdb ]; then
+ LD_PRELOAD="$ld_preload" INTEL_DUMP_GPU_CONFIG=$tmp_file $@
+else
+ gdb -iex "set exec-wrapper env LD_PRELOAD=$ld_preload INTEL_DUMP_GPU_CONFIG=$tmp_file" --args $@
+fi
+
ret=$?
rm $tmp_file
exit $ret