mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 02:38:04 +02:00
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 <rafael.antognolli@intel.com> Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Reviewed-by: Rafael Antognolli <rafael.antognolli@intel.com>
This commit is contained in:
parent
2a9069eb97
commit
feb43ef674
1 changed files with 16 additions and 3 deletions
|
|
@ -23,8 +23,10 @@ EOF
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ld_preload="@install_libexecdir@/libintel_dump_gpu.so${LD_PPRELOAD:+:$LD_PRELOAD}"
|
||||||
args=""
|
args=""
|
||||||
file=""
|
file=""
|
||||||
|
gdb=""
|
||||||
|
|
||||||
function add_arg() {
|
function add_arg() {
|
||||||
arg=$1
|
arg=$1
|
||||||
|
|
@ -60,6 +62,14 @@ while true; do
|
||||||
add_arg "device=${1##--device=}"
|
add_arg "device=${1##--device=}"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
--gdb)
|
||||||
|
gdb=1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-g)
|
||||||
|
gdb=1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
--help)
|
--help)
|
||||||
show_help
|
show_help
|
||||||
;;
|
;;
|
||||||
|
|
@ -85,9 +95,12 @@ done
|
||||||
tmp_file=`mktemp`
|
tmp_file=`mktemp`
|
||||||
echo -e $args > $tmp_file
|
echo -e $args > $tmp_file
|
||||||
|
|
||||||
LD_PRELOAD="@install_libexecdir@/libintel_dump_gpu.so${LD_PPRELOAD:+:$LD_PRELOAD}" \
|
if [ -z $gdb ]; then
|
||||||
INTEL_DUMP_GPU_CONFIG=$tmp_file \
|
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=$?
|
ret=$?
|
||||||
rm $tmp_file
|
rm $tmp_file
|
||||||
exit $ret
|
exit $ret
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue