CB Setup Background:
1. Configure a MSYS2 debugger configuration to use the C:\msys64\mingw64\bin\gdb.exe executable
2. Configure a Cygwin debugger to use the C:\cygwin64\bin\gdb.exe executable
3. Update the existing Cygwin compiler setup to use the Cygwin configuration from step 2)
4. Copy the existing GCC GNU compiler to "MSYS2 GNN GCC Compiler" and then modify it as follows:
4a. Change the install directory to C:\msys64\mingw64
4b. Change the exe filenames to match the "standard" GNU exe. Change the names to use the !windows config options from the options_gcc.xml fie with the exception of the db,windres and make as per the following snippet:
<Program name="C" value="gcc"/>
<Program name="CPP" value="g++"/>
<Program name="LD" value="g++"/>
<Program name="LIB" value="ar"/>
The windres and make are not changed, but the db is changed to reference the db from step 1) above
Create working CB Projects:
1. Create a project for a simple hello world program configured for say Cygwin. Call the project as say "CygwinTest.cbp"
2. Start CB and load the project
3. Rename the C:\msys64 to c:\msys64.old
4. Build the project. If it fails then it is configured for msys2. Fix this and try building again
5. Run the debugger. If it fails then it is configured incorrectly or configured for MSYS2. Fix it and try again.
6. Save the project.
7. Rename the C:\msys64.old to c:\msys64
8. Save the project as as say "Msys2Test.cbp"
9. Select Project->Properties menu option.
10. Change the Title to "MSYS2 Test"
11. Select the Ok" button
12. Select Project->Build Options menu option.
13. Select default target on the left pane.
14. Change the selected compiler to MSYS2
15. Say "Yes" to the pop up dialogs
16. Save the project.
17. Rename the C:\cygwin64 to c:\cygwin64.old
18. Build the project. If it fails then it is configured for Cygwin. Fix this and try building again
19. Run the debugger. If it fails then it is configured incorrectly or configured for Cygwin. Fix it and try again.
20. Save the project.
21. Rename the C:\cygwin64.old to c:\cygwin64
Reproduce CB Debugger bug:
1. Close CB
2. Load the "CygwinTest.cbp"
3. Build and run the debuger
4. In the debugger log check that the C:\cygwin64\bin\gdb.exe debugger was used.
5. Select Project->Build Options menu option.
6. Select default target on the left pane.
7. Change the selected compiler to MSYS2
8. Say "Yes" to the pop up dialogs
9. Rebuild the project
10. Run the debuger
11. In the debugger log check that the C:\cygwin64\bin\gdb.exe debugger was still used. This should have changed to C:\msys64\mingw64\bin\gdb.exe, but it did not!!!!
Notes:
1. Be aware that the Cygwin and MSYS2 debuggers can debug both exe's produced.
Current Debugging Status:
So far I have tracked the problem to debuggergdb.cpp following line that loads the wrong GDB.exe. The code above it correctly loads the currently selected compiler, which in the "Reproduce CB Debugger bug:" is the MSYS2 compiler.
cmdexe = GetActiveConfigEx().GetDebuggerExecutable();
I have found in the \src\plugins\compilergcc\compileroptionsdlg.cpp file in the void CompilerOptionsDlg::ProjectTargetCompilerAdjust() function if I add the following block at the end of the function and set the new boolean to true only when the code calls either of the SetCompilerID(...) function calls then I can change the compiler from MSYS2 to Cygwin or vice versa as many times I want in the project build options and the correct debugger executable is then called.
if (bNotifyUpdate == true)
{
CodeBlocksEvent event2(cbEVT_SETTINGS_CHANGED);
event2.SetInt(cbSettingsType::Compiler);
Manager::Get()->ProcessEvent(event2);
}
Is this an acceptable solution? If not point me in the right direction please.
Thanks for the feedback. How about the following as a solution:
if (bNotifyUpdate == true)
{
Manager::Get()->GetDebuggerManager()->SetTargetsDefaultAsActiveDebugger();
}
Ticket 611 is different to this as ticket 611 is if I have read it correctly is that the devs have changed the compiler paths manually, but no the debugger exe and as such the debugger exe is referencing a non existent executable and then when they run the debugger the code cmdexe = GetActiveConfigEx().GetDebuggerExecutable() loads the non existent directory into the cmdexe variable, but it is not checked to see if it is valid in the cbplug.cpp between lines approx 771 and line 943 where the debugger is launched.
My issue and ticket 611 are different, but related in that the symptom may be interpreted as the same as the debugger does not work, but they are not the same.