Add processFilter for remote attach process selection - #14684
Open
afreof wants to merge 3 commits into
Open
Conversation
added 3 commits
August 14, 2026 22:45
When attaching to a process on a remote target, the process always has to be selected by hand, even though the launch configuration already knows which executable it belongs to. A generated configuration cannot hard-code processId either, because the pid changes on every boot and on every restart of the service, so the picker is the only option. Add an optional processFilter regular expression to the cppdbg attach configuration. When set, it is matched against the label, description and detail of the remote process list: exactly one match attach to that process directly more than one show the picker with only the matching entries no match show the full picker, as before All three fields are considered because the item format depends on the transport: useExtendedRemote reports the user and the full command line in the label, while pipeTransport reports the process name in the label and the command line in the detail. An invalid regular expression is reported instead of being silently ignored. This affects remote attach only (pipeTransport and useExtendedRemote); local attach continues to use program-based matching. Closes microsoft#14682
Move the matching logic out of RemoteAttachPicker into a standalone function so that it can be unit tested without a VS Code quick pick or a live connection to a remote target. No functional change.
Cover empty and non-string filter values, matching against label, description and detail, multiple matches, and an invalid regular expression.
Author
|
@microsoft-github-policy-service agree company="Siemens AG"
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When attaching to a process on a remote target (
useExtendedRemoteorpipeTransport), the process to attach to always has to be picked manually from the full process list on every debug session, even though a generatedlaunch.jsonalready knows which executable it targets. The PID can't be hard-coded because it changes on every restart/boot, and picking the wrong entry silently produces a session with mismatched symbols and source mappings.This mirrors the existing
program-based auto-selection already used for local attach (findProcessByProgramName), which does not apply to remote attach because the remote process list comes from a different source (RemoteAttachPicker) and itslabel/detailshapes differ per transport.Solution
Adds an optional
processFilter(regular expression) to thecppdbgattach configuration:label,description, anddetailof each remote process entry (the exact fields differ by transport:useExtendedRemoteputs the user + full command line inlabel;pipeTransportputs the process name inlabeland the command line indetail).Scope: this only affects remote attach (
pipeTransport/useExtendedRemote). Local attach is unaffected by this PR.Example
launch.json:{ "name": "attach my-daemon", "type": "cppdbg", "request": "attach", "program": "/path/on/build/host/to/unstripped/my-daemon", "MIMode": "gdb", "miDebuggerPath": "/path/to/aarch64-poky-linux-gdb", "miDebuggerServerAddress": "192.168.7.2:1234", "useExtendedRemote": true, "processFilter": "/usr/bin/my-daemon" }Closes #14682.
Open question for maintainers
Should
processFilteralso apply to local attach, in addition to (or instead of) the existingprogram-based basename matching? Sinceprogramis a required field forcppdbgattach, both would typically be present locally at the same time, so the semantics need a decision — I'd lean towards intersecting with theprogrammatch (never lettingprocessFilteralone select a process unrelated toprogram) rather than giving it precedence, but wanted to keep this PR scoped to the originally requested remote-only case and get feedback before extending it.Testing
Extension/test/unit/processFilter.test.ts.gdbserver --multitarget withuseExtendedRemote: true:processFiltermatch attaches directly without showing the picker