Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-debug-dev] Quoting for MI -environment-cd command

Mikhail Khodjaiants wrote:

> I am using gdb 6.3 on Windows, my workspace path contains space
> characters and it works fine with both (standard and CygWin) command
> factories.

I am using GDB 6.3.50, and it does not work correctly for me using CDT
3.0.2.  I don't see how it could with any recent version of GDB; here is
a quote from a DOS console running a MinGW GDB:

  -environment-cd c:\Program Files
  &"mi_cmd_env_cd: Usage DIRECTORY\n"
  ^error,msg="mi_cmd_env_cd: Usage DIRECTORY"

whereas:

  -environment-cd "c:\\Program Files"
  ^done

works fine.  The quotes are not optional.

GDB made an incompatible change to MI version 1 at some point; earlier
versions did not require the quotes, while newer versions do.  MI
version 2 has always required the quotes.

How about checking the MI version and using the default MICommand
parametersToString (rather than the special version in MIEnvironmentCD)
for MI versions greater than 2?  That would preserve compatibility for
GDB 5.2, using MI version 1, and do the right thing for newer versions
of GDB, using MI version 2.

> The new "commandFactory" extension point has been added lately (CDT
> 3.1). If you need to use a particular version of gdb the best way is to
> contribute your own command factory. You can simply extend the
> "CommandFactory" class and overwrite the commands you need to change.

Yes, that's a workaround.  Unfortunately, MICommand.parametersToString
is protected, andCommandFactory requires that getEnvironmentCD return
something derived from MIEnvironmentCD, so you have to jump through
hoops to actually get at the base MICommand version of
parametersToString.  But, it is doable; thanks!

-- 
Mark Mitchell
CodeSourcery
mark@xxxxxxxxxxxxxxxx
(650) 331-3385 x713



Back to the top