diff options
author | Lionel Landwerlin <[email protected]> | 2018-07-20 11:20:41 +0100 |
---|---|---|
committer | Lionel Landwerlin <[email protected]> | 2018-07-20 17:36:56 +0100 |
commit | feb43ef674593ad94e962be194cb67dfc97c4e2e (patch) | |
tree | 2e61db3b66afcca94f4004f7e2668336cbeae812 | |
parent | 2a9069eb97f636b427430ffc49813dfbfa96d56f (diff) |
intel: tools: dump: protect against multiple calls on destructor
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 <[email protected]>
Signed-off-by: Lionel Landwerlin <[email protected]>
Reviewed-by: Rafael Antognolli <[email protected]>
-rwxr-xr-x | src/intel/tools/intel_dump_gpu.in | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/intel/tools/intel_dump_gpu.in b/src/intel/tools/intel_dump_gpu.in index 0454cff25da..aa187ba8614 100755 --- a/src/intel/tools/intel_dump_gpu.in +++ b/src/intel/tools/intel_dump_gpu.in @@ -23,8 +23,10 @@ EOF exit 0 } +ld_preload="@install_libexecdir@/libintel_dump_gpu.so${LD_PPRELOAD:+:$LD_PRELOAD}" args="" file="" +gdb="" function add_arg() { arg=$1 @@ -60,6 +62,14 @@ while true; do add_arg "device=${1##--device=}" shift ;; + --gdb) + gdb=1 + shift + ;; + -g) + gdb=1 + shift + ;; --help) show_help ;; @@ -85,9 +95,12 @@ done 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 |