I've looked at the patches not long ago and now I find the time to answer, sorry for the delay:
I think the first patch is really dangerous because it applies macro replacement to the whole command in the compiler and in the debugger it applies the replacements to the execution parameters separately. I think we should do this consistently otherwise will create oddly behaving system. Also the patch doesn't change the behaviour in the valgrind plugin, so this will break. Can you apply the change to the compiler in the same/separate fashion as in the debugger? As far as I can see the execution parameters are used everywhere, so you can extract them in a variable before the if/else code and apply the macro expansion there. Also I think we need some helper function that do this expansion automatically in a single place, but I'm not sure how to achieve this yet. Probably we need some execution command generator class with some methods like getFullCmd(), getExePath(), getParameters() and then every call site use either getFullCmd or a combination of getExePath and getParameters. And getFullCmd will call getExePath and getParameters, so the behaviour will be consistent and reliable.
For the second: It should be separated in two patches - one that handles the code reordering and one that introduces the improvement. Also it needs to be expanded to support the debugger and valgrind plugins. But I think we should proceed with it after the comments in the first patch have been resolved.
What do you think?