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

Remote debugging without extra launch settings locally #142

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ChristianToepfer
Copy link

Unfortunately you are not right, if you write in #77 that existing debug features can be used. A lot of variables #https://code.visualstudio.com/docs/editor/variables-reference not resolved, e.g. '${file}'. The 'pathMappings' in launch.json to set breakpoints has to be defined specifically for the extension!

From a practical point of view, with your great extenstion remote working is like local working. But to launch means to distinguish. So i have to manage a launch, for every SSH-FS configuration, that define host and root, where actually only a debugport as new information is added. The worst thing is that I have to manage a little extra locally!

I add two config properties, patch SSH-launch's to attach and define pathmapping from SSH-FS root setting. You can work with a local launch, too. But there is no need.

@dalarworld
Copy link

Having difficulty to debug files on Remote Server. VSCODE doesn't work untill I provide local files. Can someone help on this.?

@SchoofsKelvin SchoofsKelvin added the enhancement New feature or request label Mar 19, 2020
@SchoofsKelvin
Copy link
Owner

As far as I know, the node debugger allows connecting to a remote process, and pathMapping to "local" files using the ssh:// protocol. I haven't really looked into this, as the whole debugging process is very different between languages/frameworks. With the release of vscode's Remote SSH, it isn't also something I'm planning on spending a lot of time on.

@@ -112,6 +112,89 @@ export class Manager implements vscode.TreeDataProvider<string | FileSystemConfi
}
root = root.replace(/^~/, home.replace(/\/$/, ''));
}

vscode.debug.registerDebugConfigurationProvider("*", {
Copy link
Owner

Choose a reason for hiding this comment

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

I'm not sure we're supposed to use these register methods dynamically, especially without ever unsubscribing them

});


vscode.debug.registerDebugAdapterTrackerFactory('*', {
Copy link
Owner

Choose a reason for hiding this comment

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

Same remark as on line 116

if (vscode.window.activeTextEditor)
file = root + vscode.window.activeTextEditor.document.uri.path; // '${file}' can not be resolved per default
if (debugConfig['program'])
debugConfig['program'] = eval('`' + debugConfig['program'] + '`'); // resolve ${file}, ${workspaceFolder}
Copy link
Owner

Choose a reason for hiding this comment

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

This seems a bit unsafe and a bad practice. A regular (dynamic) string replacement would work here.
I'm also not sure about if vscode will replace things like ${workspaceFolder} before/after this step.

onWillStartSession: () => {
if (config && config.debugPreLaunch) {
const file = session.configuration['program'];
const command = eval('`' + config.debugPreLaunch + '`'); // resolve ${file} and config.
Copy link
Owner

Choose a reason for hiding this comment

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

Same remark as on line 142

}}
});

vscode.debug.registerDebugAdapterTrackerFactory('*', {
Copy link
Owner

Choose a reason for hiding this comment

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

Same remark as on line 116.
This should also use the Logging facility instead of directly logging to the console.
This whole registerDebugAdapterTrackerFactory could be merged with the one on line 151.


export function debugPreLaunch(config: FileSystemConfig, onChange: FSCChanged<'debugPreLaunch'>): React.ReactElement {
const callback = (value?: string) => onChange('debugPreLaunch', value);
const description = 'Task to run before debug session starts. SSH command: e.g. `/opt/vistec/python/bin/python -m ptvsd --host ${config.host} --port ${config.debugPort} --wait ${file}`';
Copy link
Owner

Choose a reason for hiding this comment

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

A bit of a long description which doesn't specify that the command will be run locally

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

Successfully merging this pull request may close these issues.

3 participants