Dave Wallace | 86b8e26 | 2017-10-19 03:47:42 -0400 | [diff] [blame] | 1 | #! /bin/bash |
| 2 | |
| 3 | if [ -z "$WS_ROOT" ] ; then |
| 4 | echo "ERROR: WS_ROOT environment variable is not set!" |
| 5 | exit 1 |
| 6 | fi |
| 7 | |
| 8 | source $WS_ROOT/extras/vcl-ldpreload/env.sh |
| 9 | tmp_gdb_cmdfile="/tmp/gdb_cmdfile_curl.$$" |
| 10 | |
| 11 | trap "rm -f $tmp_gdb_cmdfile" SIGINT SIGTERM EXIT |
| 12 | |
| 13 | cat <<EOF > $tmp_gdb_cmdfile |
| 14 | set confirm off |
| 15 | source $WS_ROOT/extras/gdb/gdb_cmdfile.vpp |
| 16 | set exec-wrapper env LD_PRELOAD=$VCL_LDPRELOAD_LIB_DIR/libvcl_ldpreload.so.0.0.0 |
| 17 | start |
| 18 | EOF |
| 19 | |
| 20 | gdb_in_emacs() { |
| 21 | sudo -E emacs --eval "(gdb \"gdb -x $tmp_gdb_cmdfile -i=mi --args $*\")" --eval "(setq frame-title-format \"CURL-DEBUG (VCL-LDPRELOAD)\")" |
| 22 | } |
| 23 | |
| 24 | # Extract nginx IPv4 address from docker bridge |
| 25 | # |
| 26 | nginx_addr=$(docker network inspect bridge | grep IPv4Address | awk -e '{print $2}' | sed -e 's,/16,,' -e 's,",,g' -e 's/,//') |
| 27 | |
| 28 | if [ -z "$nginx_addr" ] ; then |
| 29 | echo "ERROR: Unable to determine docker container address!" |
| 30 | exit 1 |
| 31 | fi |
| 32 | |
| 33 | gdb_in_emacs /usr/bin/curl http://$nginx_addr |