debug backend plugin

This commit is contained in:
Alexander Zobnin
2020-01-14 13:16:40 +03:00
parent 3f5719794a
commit 94cdf10989
3 changed files with 48 additions and 0 deletions

18
debug-backend.sh Executable file
View File

@@ -0,0 +1,18 @@
#!/bin/bash
if [ "$1" == "-h" ]; then
echo "Usage: ${BASH_SOURCE[0]} [plugin process name] [port]"
exit
fi
PORT="${2:-3222}"
PLUGIN_NAME="${1:-'zabbix-plugin_'}"
echo $PORT $PLUGIN_NAME
ptrace_scope=`cat /proc/sys/kernel/yama/ptrace_scope`
if [ "$ptrace_scope" != 0 ]; then
echo "WARNING: ptrace_scope set to value other than 0, this might prevent debugger from connecting, try writing \"0\" to /proc/sys/kernel/yama/ptrace_scope.
Read more at https://www.kernel.org/doc/Documentation/security/Yama.txt"
fi
dlv attach `pgrep ${PLUGIN_NAME}` --headless --listen 0.0.0.0:${PORT} --api-version 2
pkill dlv