[ovs-dev] [PATCH] ovs-sandbox: Tell gdb to start the daemon.

Russell Bryant rbryant at redhat.com
Fri Apr 10 22:51:09 UTC 2015


On 04/10/2015 05:10 PM, Andy Zhou wrote:
> Hi, Russell,
> 
> Thanks for pointing out the issue.
> 
> I am afraid this patch does not solve the problem entirely.  On my
> system, the delay in launching an xterm
> and the ovsdb-server under gdb is large enough that the same error
> message is still produced.

Ah, good point.  I hadn't notice that.

> The only real use case for the gdb option is to allow setting break
> points before the program starts.
> Once the program is launched, one can always attach gdb to a running process.

My use case for trying it was actually different.  I had written code
that was crashing, and I found this a bit more convenient than getting a
bt from a core dump.

Indeed, I could have just attached to it after it started running.

> How about the following patch, that 1) remove the '-ex run' option,
> because you are better off attach gdb to a running
> process, 2) delay executing ovs-vsctl command until ovsdb-server is
> launched.  If this looks reasonable, I can
> submit an official patch.

Sure, that's fine.  I can always keep just typing "run" if I want to use
this approach instead of attaching.

It's really a question of which use case has to do an extra step.  If
you wanted to set a breakpoint before it starts, you could kill it
quickly with Ctrl-C, set your breakpoints, and 'run' again.  That seems
less clean though, I suppose.

> --andy
> 
> diff --git a/tutorial/ovs-sandbox b/tutorial/ovs-sandbox
> index 251f021..ac1c90e 100755
> --- a/tutorial/ovs-sandbox
> +++ b/tutorial/ovs-sandbox
> @@ -36,7 +36,7 @@ rungdb() {
>      if $under_gdb && [ "$DISPLAY" ]; then
>          args=`echo $@ |sed s/--detach//g | sed s/--vconsole:off//g`
>          xterm_title=$1
> -        run_xterm $xterm_title gdb -ex run --args $args
> +        run_xterm $xterm_title gdb --args $args
>      else
>          run $@
>      fi
> @@ -235,6 +235,14 @@ run ovsdb-tool create conf.db "$schema"
>  rungdb $gdb_ovsdb ovsdb-server --detach --no-chdir --pidfile
> -vconsole:off --log-file \
>      --remote=punix:"$sandbox"/db.sock
> 
> +if test ! -e "$sandbox"/db.sock; then
> +    echo -n "Waiting for ovsdb-server to start..."
> +    while test ! -e "$sandbox"/db.sock; do
> +        sleep 0;
> +    done
> +    echo "  Done"
> +fi
> +
>  # Initialize database.
>  run ovs-vsctl --no-wait -- init

Looks good.

-- 
Russell Bryant



More information about the dev mailing list