Community
Participate
Working Groups
When we send the -gdb-set env command we need to avoid putting "" around the variable. -gdb-set env "MYVAR=MY VAR" will not set MYVAR to MY VAR, but instead will create an empty variable with name "MYVAR=MY VAR". What we really want to send is: -gdb-set env MYVAR=MY VAR Quotes are automatically being added by MICommand when there is a space in the parameter. To fix that, we can treat each entry in the variable value as a separate parameter. Note that GDB does not accept env variable with a space in the name, so we don't need to worry about that.
Created attachment 188081 [details] Fix Fix
Committed to HEAD and 7_0 John, can you review (one-file patch)?
*** cdt cvs genie on behalf of mkhouzam *** Bug 336013: [launch] Environment variables that contain a space are not properly set at launch time [*] MIGDBSetEnv.java 1.2 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIGDBSetEnv.java?root=Tools_Project&r1=1.1&r2=1.2 [*] MIGDBSetEnv.java 1.1.2.1 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIGDBSetEnv.java?root=Tools_Project&r1=1.1&r2=1.1.2.1
The fix looks good but I think the explanation in the code is a bit confusing. Here's how I would phrase it: MICommand wraps a parameter with double quotes if it contains a space. If the value of the environment variable has a space, and we bundle the var name, the '=' and the value as a single parameter, then we'll end up with something like -gdb-set env "MYVAR=MY VAR" which defines an environment variable named "MYVAR=MY VAR", with an empty string for a value. To avoid this, we send each element as a separate parameter -gdb-set env MYVAR = MY VAR
(In reply to comment #4) > The fix looks good but I think the explanation in the code is a bit confusing. > Here's how I would phrase it: > > MICommand wraps a parameter with double quotes if it contains a space. If the > value of the environment variable has a space, and we bundle the var name, the > '=' and the value as a single parameter, then we'll end up with something like > > -gdb-set env "MYVAR=MY VAR" > > which defines an environment variable named "MYVAR=MY VAR", with an empty > string for a value. To avoid this, we send each element as a separate parameter > > -gdb-set env MYVAR = MY VAR Yes, that's better. Thanks. I updated HEAD. (I didn't bother with 7_0 since that code is not going to be maintained for much longer).
*** cdt cvs genie on behalf of mkhouzam *** Bug 336013: [launch] Environment variables that contain a space are not properly set at launch time [*] MIGDBSetEnv.java 1.3 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIGDBSetEnv.java?root=Tools_Project&r1=1.2&r2=1.3