Bug 361315 - Crossfire Remote Attach does not sync breakpoints from Eclipse to Firebug when setting a project or WS as the source.
Summary: Crossfire Remote Attach does not sync breakpoints from Eclipse to Firebug whe...
Status: RESOLVED FIXED
Alias: None
Product: JSDT
Classification: WebTools
Component: Debug (show other bugs)
Version: 3.2.5   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: 3.4 M4   Edit
Assignee: Michael Rennie CLA
QA Contact: Michael Rennie CLA
URL:
Whiteboard:
Keywords: api, noteworthy
Depends on:
Blocks: 367806
  Show dependency tree
 
Reported: 2011-10-18 18:53 EDT by Leopoldo (Polo) Miranda CLA
Modified: 2012-01-03 19:45 EST (History)
5 users (show)

See Also:


Attachments
work in progress (7.70 KB, patch)
2011-11-03 16:29 EDT, Michael Rennie CLA
no flags Details | Diff
update (30.27 KB, patch)
2011-11-17 13:44 EST, Michael Rennie CLA
no flags Details | Diff
update2 (32.94 KB, patch)
2011-11-17 15:40 EST, Michael Rennie CLA
no flags Details | Diff
update (44.08 KB, patch)
2011-11-21 17:37 EST, Michael Rennie CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Leopoldo (Polo) Miranda CLA 2011-10-18 18:53:26 EDT
Here the steps to recreate this scenario:

1. Create a simple static web project, that contains the following:
- A JS file/function that has five lines of code for example:

	console.log('Msg 1');
	console.log('Msg 2');
	console.log('Msg 3');
	console.log('Msg 4');
	console.log('Msg 5');

- An HTML that contains a button with onClick event to call the JS function above.
2. Deploy your web project in any web container.
3. Open the URL for the html page in Firefox (Firebug up and running and Crossfire   already listening)
4. In Eclipse create a new Remote JavaScript configuration as follow:
- In Connect tab, select "Crossfire - Remote Attach" and leave all defaults
- In the Source tab, delete the Default "Source Lookup Path" and add your sample project (or workspace) instead.
5. Start to "Debug"
6. Go to Firebug, and select the script tab and set a break in the first console message.
7. Click in the button so then your JS breakpoint is reached.
8. Accept the Eclipse notification to go to debug mode (if not there already)
9. You will have the JS open with something like this path: SWPsampe/WebContent/js/testJsFile.js
10. In Eclipse, try to set breakpoints in any JS line and will notice two things:
- Breakpoints are added to the breakpoints view
- Breakpoints are not reflected in firebug.
11. In Eclipse, if you click on resume you won't stop in the next breakpoints as you set previously.

This scenario works ok by leaving "Default" as the Source. However, this means to retrieve the resource again to the workspace. 

Firefox versions either 6 or 7
Firebug 1.8.3
Crossfire 0.3a8
Comment 1 Michael Rennie CLA 2011-11-03 16:29:17 EDT
Created attachment 206431 [details]
work in progress

This patch takes a swing at attempting to guess if two paths are equivalent based on how many segments match in the same ordering.
Comment 2 Hernan Pepe Petersen CLA 2011-11-08 11:04:37 EST
I was comparing this 2 paths:

1. local: /testproject2/WebContent/testscript2.js
2. remote: /testproject2/testscript2.js

Didn't work at one. I changed this in order to compare all uri path parts to some local file path segment. 

if (bppath.segment(i).equals(uri.segment(last1))) {
     matched_segments++;
     last1--;
}

Hope it helps.
Comment 3 Michael Rennie CLA 2011-11-17 13:44:42 EST
Created attachment 207169 [details]
update

This patch changes things slightly, it provides an extension point so contributors can do their own mapping and script path resolution. As well, it slightly changes the logic for the default matching, but it does not yet include your suggested changes Hernan - the reason being that adds quite a bit of fuzz-factor into the correctness of the match.

The new extension point is call scriptResolvers and is available from the jsdt.debug.core.
Comment 4 Michael Rennie CLA 2011-11-17 15:40:39 EST
Created attachment 207179 [details]
update2

This update fixes an issue found for global suspend, and provides a toggle breakpoint adapter for HTML files (not quite working yet)
Comment 5 Michael Rennie CLA 2011-11-21 17:37:06 EST
Created attachment 207338 [details]
update

This patch provides an implementation of getFile in the manager and HTML breakpoint hooks. It also changes the logic a bit to not have JSDT debug provide a script resolver, instead it uses the old logic of script resolution as a fall-back  in the event there are no resolvers defined or none of the resolvers can determine script matches.
Comment 6 Hernan Pepe Petersen CLA 2011-11-23 11:02:13 EST
I've tested this patch extending the scriptResolver and seems to be working fine. My extension is being called when resource matching is required in breakpoint setting and script loading.
Comment 7 Michael Rennie CLA 2011-11-25 12:38:12 EST
Thanks for the testing Hernan.

I have released the new API with a slight change - rather than have consumers implement the IScriptResolver interface I added an abstract class for them to extend.