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

Andy Zhou azhou at nicira.com
Thu Feb 19 05:55:57 UTC 2015


On Wed, Feb 18, 2015 at 8:31 PM, Ben Pfaff <blp at nicira.com> wrote:
> 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.
>
Thanks for the quick review.

>> +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".
>
Yes, This also works, I will add it to the write up.

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

Should we remove the '-g' option?

On a slightly different note,  I may end up move ovs-sandbox out of
tutorial directory, in case
we have another use for it, such as "ovsdb micro benchmark", but it is
premature to discuss at
this time.

To directly answer your question, I don't use it directly currently.
I added the option since the
tutorial talked about run ovs-sandbox with installed OVS programs.  On
the other hand, the -g option
probably only make sense with the 'make' option.

>
> 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.

Good point,  will rework the script and send out a V2.



More information about the dev mailing list