Skip to content
This repository has been archived by the owner on Jan 13, 2021. It is now read-only.

Commit

Permalink
fix(remote): minor issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Morten Henriksen committed Feb 9, 2018
1 parent 6b1819e commit d4855a5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,14 +295,14 @@ export class perlDebuggerConnection {
if (!options.port) {
// If no port is configured then run this locally in a fork
this.perlDebugger = new LocalSession(filename, cwd, args, options);
this.logOutput(this.perlDebugger.title());
} else {
// If port is configured then use the remote session.
this.logOutput(`Waiting for remote debugger to connect on port "${options.port}"`);
this.perlDebugger = new RemoteSession(options.port);
}

this.commandRunning = this.perlDebugger.title();
this.logOutput(this.perlDebugger.title());

this.perlDebugger.on('error', (err) => {
if (this.debug) console.log('error:', err);
Expand Down
3 changes: 3 additions & 0 deletions src/perlDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export interface LaunchRequestArguments extends DebugProtocol.LaunchRequestArgum
trace?: boolean;
/** env variables when executing debugger */
env?: {};
/** port for debugger to listen for remote debuggers */
port?,
}

class PerlDebugSession extends LoggingDebugSession {
Expand Down Expand Up @@ -150,6 +152,7 @@ class PerlDebugSession extends LoggingDebugSession {
PERL5LIB: process.env.PERL5LIB || '',
...args.env
},
port: args.port || undefined,
})
.then((res) => {
if (args.stopOnEntry) {
Expand Down
5 changes: 3 additions & 2 deletions src/remoteSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,18 @@ export class RemoteSession implements DebugSession {

if (!client) {
client = socket;
this.stdout.push(`> Remote debugger at "${name}" connected at port ${port}.`);
this.stdout.push(`Remote debugger at "${name}" connected at port ${port}.`);
} else {
// Already have a client connected, lets close and notify user
this.stderr.push(`> Warning: Additional remote client tried to connect "${name}".`);
this.stdout.push(`Warning: Additional remote client tried to connect "${name}".`);
socket.end('Remote debugger already connected!');
}

socket.on('data', data => this.stderr.push(data));

socket.on('end', data => {
client = null;
this.stdout.push(`Connection closed by "${name}"`);
this.event.emit('close', data);
});

Expand Down

0 comments on commit d4855a5

Please sign in to comment.