Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tries to set breakpoint at main, although setting stopAtEntry is False #1453

Open
fr43nk opened this issue May 16, 2024 · 2 comments
Open

Tries to set breakpoint at main, although setting stopAtEntry is False #1453

fr43nk opened this issue May 16, 2024 · 2 comments

Comments

@fr43nk
Copy link

fr43nk commented May 16, 2024

Hi,

I use the c_cpp extension in VScode with a large c++ project.
One issue is, that starting the debugger session takes more than one minute.
I activated the logging to see what is happening. It came out, that there is a log entry saying:

1: (7051) <-1009-break-insert -f main

Then the log prints all methods within my project with the name main.
Finally the log contains the time it took to search all those methods:

--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (47494) 1009: elapsed time 40443\n"},"seq":112}

The thing about this: I disabled the stopAtEntry in the launch settings of my project

{
"name": "(GDB) mybinary (logging)",
"type": "cppdbg",
"program": "/path/to/mybinary.exe",
"request": "launch",
"cwd": "/path/to",
"stopAtEntry": false,
"linux": {},
"MIMode": "gdb",
"miDebuggerPath": "/u1/debugger/gdb-13.2.0/bin/gdb",
"logging": {
  "engineLogging": true,
  "moduleLoad": true,
  "trace": true,
  "traceResponse": true,
}

I think that this is an error not using the setting.

Looking at the source code, there might be a something wrong in:

MIEngine\src\MIDebugEngine\Engine.Impl\DebuggedProcess.cs:821

Best regards,
Frank

@fr43nk
Copy link
Author

fr43nk commented Jul 23, 2024

Is there anyone who can acknowledge this issue?

@oold
Copy link

oold commented Feb 3, 2025

We customize the Debug Engine since it tries to run too many expensive commands on the debugger, which causes e.g. one minute or more of time between entering break mode and actually being able to do anything in the IDE for our platform, so I've seen a lot of the code.

The main breakpoint is set because the Debug Engine needs to emit an "entrypoint hit" event. IDK why exactly it needs to emit the event, but I remember things not working quite right if the event is removed. In VS, there is a thread-safe wrapper around the engine callback, but that doesn't really matter here. The engine callback gets hit for VS and VS Code.

Entrypoint event:

public void OnEntryPoint(DebuggedThread thread)

Event callback for VS:
int IDebugEventCallback2.Event(IDebugEngine2 engine, IDebugProcess2 process, IDebugProgram2 program, IDebugThread2 thread, IDebugEvent2 @event, ref Guid riidEvent, uint attribs)

Event handler for the debug session:
public void HandleIDebugEntryPointEvent2(IDebugEngine2 pEngine, IDebugProcess2 pProcess, IDebugProgram2 pProgram, IDebugThread2 pThread, IDebugEvent2 pEvent)

I'd also like to see a comment from the maintainers on why exactly this is done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants