microsoft / microsoft/MIEngine

Bug in Breakpoint Setting with Multiple main.c/main.cpp Files in Heterogeneous Debug Session

Open
#1,480 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
859
Forks
233
Avg merge
1d 6h
Merged PRs (30d)
3

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:

  1. System Set Up:
  1. 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 .vscode files 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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the heterogeneous session from the linked cppdbg setup, using the provided two-project example and GDB's info b command to confirm the duplicate breakpoint. Trace MIEngine's breakpoint file-path lookup, then verify that a breakpoint in one main.c or main.cpp is applied only to that file while the existing debugging scenarios still work.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, cpp, vscode
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.