[ovs-dev] [PATCH] ovs-sandbox: Add an option to allow running ovs-vswitchd under gdb

Ben Pfaff blp at nicira.com
Thu Feb 19 04:31:06 UTC 2015


On Wed, Feb 18, 2015 at 06:08:29PM -0800, Andy Zhou wrote:
> It is some times useful to leverage the sandbox facility to experiment
> and explore the internals of ovs-vswitchd.  Since GDB requires console
> access for user inputs, this patch launch an xterm for GDB, The main
> terminal continue to run the sub-shell as before. Exiting the sub-shell
> will also kill the ovs-vswitchd under GDB (but not GDB itself currently)
> 
> Signed-off-by: Andy Zhou <azhou at nicira.com>
> ----
> I have been making similar changes in my private tree for a while.
> It may be worth while to upstream it others can benefit as well.
> 
> Instead of launching xterm, we could probably leave the main console
> for GDB, and allow user to start another sub-shell in a separate
> terminal. However, this won't scale to multiple programs, in case
> one wants to debug both ovs-vswitchd and ovsdb-server.

It's clever.

> +For debugging ovs-vswitchd, it may be necessary to launch the program
> +under gdb, so one can set break points early or catch early segfaults. This
> +can be accomplished in the following two ways:
> +1) use '-g' command line option with ovs-sandbox script.
> +2) Set a environment variable, do 'export GDB_OVS_VSWITCHD=y' before launching
> +   the ovs-sandbox script.
> +
> +No 2 option is most convenient when launching the sandbox with 'make sandbox'.

At least for make, it's probably easier to put it in the command-line,
e.g. "make sandbox GDB_OVS_VSWITCHD=y".

Do you often run ovs-sandbox without "make"?  I haven't tried it that
way.

It's probably better to check for a nonempty DISPLAY environment
variable than to look for an X process, because DISPLAY works with
remote X servers (e.g. over SSH) too.



More information about the dev mailing list