-
Notifications
You must be signed in to change notification settings - Fork 227
Description
Description:
We have encountered a bug in the Microsoft MIEngine while using the cppdbg VS Code extension. The issue occurs when setting breakpoints in projects that contain multiple main.c or main.cpp files, specifically in a heterogeneous debug session where both main.c or main.cpp files are being debugged simultaneously. The problem arises because the MIEngine uses the file name (main.c/main.cpp) as a parameter to retrieve the path to the file. This retrieval process involves a search function that returns all paths to valid main.c/main.cpp files. These paths are then used to set breakpoints.
In our specific case, we have two main.c/main.cpp files in different project directories within a single multi-project workspace. The search function correctly finds two valid paths to these files. However, when setting a breakpoint, the MIEngine sets the breakpoint in both main.c/main.cpp files on the same line, which is not the intended behavior.
Steps to Reproduce:
- System Set Up:
- The following documentation can be used for system set up: https://code.visualstudio.com/docs/cpp/config-mingw
- These steps are for system setup on a windows machine but documentation for other OS's is available too.
- Project Creation:
- Using the project creation steps outline in https://code.visualstudio.com/docs/cpp/config-mingw, create a project with two main.c/main.cpp files located in different directories.
- Note: I have created the following example for convenience. While system set up is still required, the following example can be used by simply updating the appropriate paths in all
.vscodefiles and rebuilding the projects before debugging: helloworld.zip - Start a heterogeneous debug session where both main.c/main.cpp files are being debugged simultaneously. This heterogeneous debug session should be launched via Run & Debug using unique configurations for each project.
- Set a breakpoint in one of the main.c/main.cpp files. I.e. app1 main.cpp line 10.
- Use GDB commands such as -exec info b in each debug console to confirm that the breakpoint is set in both main.c/main.cpp files on the same line.
Expected Behavior:
The breakpoint should only be set in the specified main.c/main.cpp file, not in all files with the same name.
Actual Behavior:
The breakpoint is set in both main.c/main.cpp files on the same line, leading to unintended debugging behavior.
Overview of Example:
Given the following directory structure:
/project
/dir1
main.c
/dir2
main.c
Setting a breakpoint in /project/dir1/main.c on line 10 during a heterogeneous debug session results in breakpoints being set in both /project/dir1/main.c and /project/dir2/main.c on line 10.
Proposed Solution:
To resolve this issue, the MIEngine could use the full path to the main.c/main.cpp file rather than using a search and find function that only uses the file name. This approach is used by Cortex Debug and ensures that breakpoints are set in the correct file. By passing the full path to the main.c file, the MIEngine can accurately identify and set breakpoints in the intended file without affecting other files with the same name.
Additional Information:
This issue can cause significant confusion and debugging difficulties, especially in larger projects with multiple files having the same name. An example of this would be building, flashing, and debugging multiple projects on a multicore MCU. A more precise method of identifying and setting breakpoints in the correct file is needed.
References:
https://code.visualstudio.com/docs/cpp/config-mingw