[ovs-dev] [PATCH] ovs-ctl: allow gdb as a wrapper
Aaron Conole
aconole at redhat.com
Mon Jun 12 20:39:51 UTC 2017
It has been useful to attach gdb to the running process. With this commit
we make it a little easier, as the daemon will have a gdbserver process
attached and listening on a specific port.
Signed-off-by: Aaron Conole <aconole at redhat.com>
---
utilities/ovs-ctl.in | 2 +-
utilities/ovs-lib.in | 14 ++++++++++++++
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/utilities/ovs-ctl.in b/utilities/ovs-ctl.in
index 575ffa0..a192ead 100755
--- a/utilities/ovs-ctl.in
+++ b/utilities/ovs-ctl.in
@@ -589,7 +589,7 @@ Less important options for "start", "restart" and "force-reload-kmod":
Debugging options for "start", "restart" and "force-reload-kmod":
--ovsdb-server-wrapper=WRAPPER
--ovs-vswitchd-wrapper=WRAPPER
- run specified daemon under WRAPPER (either 'valgrind' or 'strace')
+ run specified daemon under WRAPPER (either 'valgrind', 'strace', or 'gdb')
File location options:
--db-file=FILE database file name (default: $DB_FILE)
diff --git a/utilities/ovs-lib.in b/utilities/ovs-lib.in
index 93085ca..638b118 100644
--- a/utilities/ovs-lib.in
+++ b/utilities/ovs-lib.in
@@ -167,6 +167,7 @@ start_daemon () {
shift; shift
daemon=$1
strace=""
+ gdbserver=""
# drop core files in a sensible place
install_dir "$DAEMON_CWD"
@@ -208,6 +209,14 @@ start_daemon () {
glibc)
set env MALLOC_CHECK_=2 MALLOC_PERTURB_=165 "$@"
;;
+ gdb)
+ if (gdbserver --version) > /dev/null 2>&1; then
+ gdbserver="gdbserver --attach :5432"
+ else
+ log_failure_msg \
+ "gdbserver not installed, running $daemon without it"
+ fi
+ ;;
'')
;;
*)
@@ -227,6 +236,11 @@ start_daemon () {
setsid $strace -o "$logdir/$daemon.strace.log" \
-p `cat $rundir/$daemon.pid` > /dev/null 2>&1 &
fi
+
+ if test X"$gdbserver" != X; then
+ # gdbserver needs to attach after the fact.
+ setsid $gdbserver `cat $rundir/$daemon.pid` > /dev/null 2>&1 &
+ fi
}
stop_daemon () {
--
2.9.4
More information about the dev
mailing list