Skip to content
This repository has been archived by the owner on Apr 3, 2024. It is now read-only.

Breakpoints are not hit on Windows #795

Closed
DominicKramer opened this issue Nov 26, 2019 · 2 comments
Closed

Breakpoints are not hit on Windows #795

DominicKramer opened this issue Nov 26, 2019 · 2 comments
Assignees
Labels
api: clouddebugger Issues related to the googleapis/cloud-debug-nodejs API. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. 🚨 This issue needs some love. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@DominicKramer
Copy link
Contributor

Breakpoints don't appear to be hit on Windows (Tested on Windows Server 2019 with Node 12.13.1).

The following code isolates how the debug agent uses V8's inspector API. Either we are using the API incorrectly or there is a bug in the API.

index.js

const inspector = require('inspector');

const session = new inspector.Session();
session.connect();
session.post('Debugger.enable');
session.post('Debugger.setBreakpointsActive', {active: true});
session.on('Debugger.paused', message => {
	console.log('Paused with message', message);
});

const url = `file://${__filename}`
const line = 26;
const column = 1;

const options = {
  lineNumber: line - 1,
  url,
  columnNumber: column - 1,
  condition: undefined,
};

console.log('Setting breakpoing with options=', options);

session.post('Debugger.setBreakpointByUrl', options, (error, response) => {
  console.log('Setting breakpoint, error=', error, ', response=', response);
});

function f() {
	console.log('f() called');
	const a = 42;
}

setInterval(f, 1000);

Running node index.js on Linux causes the Paused with message ... callback to correctly get called. When running the code on Windows, the callback is never invoked. I think this is why breakpoints are not being hit by the debug agent on Windows.

The following is the output on Linux

$ node index.js 
Setting breakpoing with options= {
  lineNumber: 25,
  url: 'file:///xxxxx/index.js',
  columnNumber: 0,
  condition: undefined
}
Paused with message {
  method: 'Debugger.paused',
  params: {
    callFrames: [
      [Object], [Object],
      [Object], [Object],
      [Object], [Object],
      [Object], [Object],
      [Object], [Object],
      [Object]
    ],
    reason: 'other',
    hitBreakpoints: [
      '1:25:0:file:///xxxxx/index.js'
    ]
  }
}
Setting breakpoint, error= null , response= {
  breakpointId: '1:25:0:file:///xxxxx/index.js',
  locations: [ { scriptId: '51', lineNumber: 25, columnNumber: 2 } ]
}
f() called
f() called
f() called
f() called

while on Windows the output is

> node index.js
Setting breakpoing with options= {
  lineNumber: 24,
  url: 'file://C:\\xxxxx\\index.js',
  columnNumber: 0,
  condition: undefined
}
Setting breakpoint, error= null , response= {
  breakpointId: '1:24:0:file://C:\\xxxxx\\index.js',
  locations: []
}
f() called
f() called
f() called
f() called
f() called

Notice that the Setting breakpoint response returns a list of locations with zero elements.

@DominicKramer DominicKramer added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. labels Nov 26, 2019
@yoshi-automation yoshi-automation added 🚨 This issue needs some love. and removed 🚨 This issue needs some love. labels Dec 1, 2019
@yoshi-automation yoshi-automation added 🚨 This issue needs some love. and removed 🚨 This issue needs some love. labels Dec 11, 2019
@yoshi-automation yoshi-automation added 🚨 This issue needs some love. and removed 🚨 This issue needs some love. labels Dec 21, 2019
@yoshi-automation yoshi-automation added 🚨 This issue needs some love. and removed 🚨 This issue needs some love. labels Dec 31, 2019
@DominicKramer
Copy link
Contributor Author

@hashseed I was wondering if you could help me out. Based on the repro above, is there a problem with how we are using the inspector API on Windows. Thanks.

@DominicKramer
Copy link
Contributor Author

I have a potential fix in #815. The PR still has unit test failures, but I have verified that the modification I made works to debug on Windows 10.

It seems the inspector.setBreakpointByUrl method requires the url to start with file:/// (not file://, note the difference in the number of slashes). In addition, the url has to have all of its backslashes converted to forward slashes.

@google-cloud-label-sync google-cloud-label-sync bot added the api: clouddebugger Issues related to the googleapis/cloud-debug-nodejs API. label Jan 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api: clouddebugger Issues related to the googleapis/cloud-debug-nodejs API. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. 🚨 This issue needs some love. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

2 participants