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

Use pid to determine program if one is not configured for local attach #1230

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

OEP
Copy link

@OEP OEP commented Oct 16, 2021

This makes the "program" configuration optional for local attach cases. The configured program is always preferred if it is defined.

This was stemmed from a discussion over in microsoft/vscode-cpptools#5713 where another user had suggested a change like this based on feedback from one of the maintainers, but I didn't see an open pull request for it. The goal was to ultimately relax requiring the program configuration key to be set while debugging with local attach by pid on Linux. If this is merged, I think the C++ plugin's settings schema would also need to be altered to relax the program requirement.

Word of warning: I wasn't able to figure out the debug procedure for the VSCode C++ extension to verify this change, but I thought it was small enough to at least propose for discussion.

I thought I should note there is a pretty good workaround I saw in microsoft/vscode-cpptools#1272 which suggests using the procfs to infer the executable within VSCode's settings system.

This makes the "program" configuration optional for local attach cases.
The configured program is always preferred if it is defined.
src/OpenDebugAD7/AD7DebugSession.cs Outdated Show resolved Hide resolved
@@ -1135,6 +1135,10 @@ protected override void HandleAttachRequestAsync(IRequestResponder<AttachArgumen
SetCommonDebugSettings(responder.Arguments.ConfigurationProperties);

string program = responder.Arguments.ConfigurationProperties.GetValueAsString("program");
if (isLocal && program == null)
{
program = Process.GetProcessById(pid).MainModule.FileName;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Downstream in MICore they still have a hard check for program that it grabs from the ConfigurationProperties JSON object.
See string launchJson = JsonConvert.SerializeObject(responder.Arguments.ConfigurationProperties); below.

You will need to set it for it not to fail the PathExe check in MICore.

responder.Arguments.ConfigurationProperties["program"] = program;

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

Successfully merging this pull request may close these issues.

2 participants