microsoft / microsoft/vscode-cpptools

New Attach/preattach - waitFor feature

Open
#13,463 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

debugger Feature Request help wanted
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

Feature Request

Hello!

I've rumbling a bit for certain scenarios where the target PID we want to debug crashes so early at startup, the process ends quickly before we can debug the initialization or we are interested only in the beginning of the execution.

Sometimes this could be tricky:

  • We cannot modify the source code for some reason.
  • The Launch debug could be really complex to setup.
  • Others

The debuggers like GDB or LLDB has not yet fully support for this kind of stuff:

  • GDB has this in the roadmap.
  • LLDB has something similar but only works for MacOSX (as far as I know)

So I've working a few hours in a naive & simple waitFor approach (Linux only) with basic polling, I think it could work and be useful to handle this scenarios.

The current idea or approach is something like this:

  • New options for Attach mode: waitFor object with three properties
  • Enabled: specifies to use waitFor attach support.
  • Pattern: process name pattern (finds in PID detail if this pattern is included in the string process detail)
  • Timeout: time to wait for process match in Ms.

Snippet:

"waitFor": {
   "enabled": true,
   "pattern:" "myprocessnamepattern",
   "timeout": 10000 
}

Overall, something that I'm interested in -and probably others- is to "Preattach". Even if we wait for the PID and attach early, if the app is huge the debugger will take time to load symbols (in our case, even using .gdbindex could take up ~15-20seconds in large C++), so we will miss again the startup of the program!

The options here:

  1. SIGSTOP the process by default. This would require some GDB setupCommands, for example, regarding the signal handle and so on.
    1.1) If we SIGSTOP, perhaps find a way to execContinue after attaching, but I guess that this is not really doable from the Extension, right? We don't know exactly when the debugger has really completed the initialization from the Extension.

  2. Allow a new json key for waitFor like stopAtEntry idea.

  3. ?

I could do the PR with my current code in Draft if you consider this feature to be interesting and valuable for the extension.
Thanks!

Contributor guide

Open the contributing guide

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

Start by tracing existing Attach-mode configuration and the stopAtEntry option, then review Linux-only GDB setupCommands handling. Define the waitFor schema and preattach behavior, including timeout, process-pattern matching, and when execution resumes. Done should cover the requested startup timing without requiring source changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, linux, typescript
Domain
developer-experience, devtools, operating-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.