Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-17629] Debugger does not stop at the correct breakpoint/position

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2014-09-15T18:02:43.000+0000
Affected Version/sn/a
Fix Version/sRelease 3.4.0, Release 3.5.0
ComponentsiOS
LabelsTCSupportTriage
ReporterIvo
AssigneePedro Enrique
Created2014-08-04T14:46:30.000+0000
Updated2014-11-21T20:29:49.000+0000

Description

When I debug my application, I need to place the breakpoint exactly one line below the one I want to debug at. This is very frustrating and makes debugging really unpleasant. The only exception is file app.js for which breakpoints seems to be handled corectly. The following code illustrates the problem:
if (Ti.version < 1.8) {
  alert('Sorry - this application template requires Titanium Mobile SDK 1.8 or later');
}

var myVar = 5;
var yourVar = 6;
var thirdVar = myVar + yourVar;

var my = require("MyDir/MyThing").MyThing();
my.invoke();
Putting a break point behaves correctly for above file (app.js).
exports.MyThing = function() {

    var Me = this;

    var first = 35;
    var second = false;
    
	function myFunc() {
		var a = 5 + 3;
		return a + 2 + 3;
	}
	
	this.invoke = function() {
		var b = 7;
		return myFunc();
	};
	
	return this;
};
However for the second file, if I need to stop at line 9 I will need to place the breakpoint at line 10. More over, if I need to stop at line 10 I need to put the breakpoint at line 11 which really does not make sence. Attached is a sample project.

Attachments

FileDateSize
SDK320Test.zip2014-08-04T14:46:30.000+00002457512

Comments

  1. Praveen Innamuri 2014-08-04

    I can not reproduce the reported problem. The breakpoints always suspend at the line number that I have expected in MyThing.js file. I'm not sure whether there is a caching issue with source maps that is causing the issue on your machine. Can you clean the project and re-run the debugger ?
  2. Ivo 2014-08-05

    Cleaning the project did not help. I also tried to create a new workspace and imported the project. Issue is still there. Noticed that the misplaced suspension of the debugger happens only on the source files that are required as commonJS modules. For example, if I include a file using "Titanium.include" the debugger seems to suspend on the right place. Perhaps that explains why it works correctly in app.js. Each member in the team (team of 7) working on our project has this same issue. It is strange that no one else has experienced/reported this.
  3. Carlos Luis Seva 2014-08-06

    I have the same error while debugging using 3.3.0 GA, the debugger doesn't stop at the right position, always on the next line and is very annoying. If I use the previous version (3.2.3 GA) the debugger stops in the right position where I have placed the breakpoints. I have tried to clean and also create a new project, but has not solved the problem
  4. Jason Priebe 2014-08-19

    I also have this problem; cleaning does not correct the problem. Ti Studio version 3.3.0.201407100905 OS X 10.9.4. XCode Version 5.1.1 (5B1008) My project is comprised entirely of CommonJS modules (with the exception of app.js, of course). Breakpoints work properly in app.js, but nowhere else. Please fix this; it makes my brain hurt to debug this way!
  5. Ingo Muschenetz 2014-09-05

    Chris, could you please investigate? Not sure where we need to fix the issue (but I'm guessing somewhere in source map generation)
  6. Ingo Muschenetz 2014-09-05

    [~pec1985] I believe this may actually be related to TIMOB-16004.
  7. Pedro Enrique 2014-09-05

    PR pending: https://github.com/appcelerator/titanium_mobile/pull/6021
  8. Pedro Enrique 2014-09-15

    Back port for 3.4.x https://github.com/appcelerator/titanium_mobile/pull/6081
  9. Ewan Harris 2014-09-15

    Verified fix on: Mac OSX 10.9.4 Appcelerator Studio, build: 3.4.0.201409131030 Titanium SDK build: 3.4.0.v20140915105910 Titanium CLI, build: 3.4.0-rc3 Alloy: 1.5.0-beta2 Xcode6 GM Seed iPhone Device 5 (8.0 GM Seed) Using the test case provided by Satyam I ran the code in debug mode. The breakpoints were correctly hit and the expression value for mything_thirdVar was changed to 11 in the expected place on line 11. Closing ticket.

JSON Source