pkulchenko / ZeroBraneStudio

Lightweight Lua-based IDE for Lua with code completion, syntax highlighting, live coding, remote debugger, and code analyzer; supports Lua 5.1, 5.2, 5.3, 5.4, LuaJIT and other Lua interpreters on Windows, macOS, and Linux
http://studio.zerobrane.com/
Other
2.62k stars 518 forks source link

Unable to hit breakpoints (Marmalade 6.3.1 with Quick 1.1.2; ZBS v0.38) #185

Closed trysenga closed 11 years ago

trysenga commented 11 years ago

I just installed marmalade quick 1.1.2 on marmalade 6.3.1. With ZeroBraneStudio I can run the examples. I can even add a require to start debugging. Any print statements after that do show up in the output window. However, none of the break points that I set are hitting. I'm running on windows 7 64bit.

pkulchenko commented 11 years ago

@trysenga, what version of ZeroBrane Studio are you using?

pkulchenko commented 11 years ago

@trysenga, I just downloaded Quick 1.1.2 and ran one of Quick examples without any issues. Here is what I did.

  1. Opened quick\data\examples\Hello World\Hello World\main.lua file and added require('mobdebug').start() on line 8.
  2. Set project folder to ...\quick\data\examples\Hello World\Hello World.
  3. Added breakpoint on line print("Hello, World!").
  4. Set interpreter to Marmalade Quick.
  5. Started debugging and the breakpoint got hit.

I'm using Marmalade 6.2.2, but don't think it would make any difference. Do the steps above work for you?

trysenga commented 11 years ago

I followed the exact steps (mine was on line 7) and it never hits the breakpoint. Perhaps they've broken it with 6.3.1? As I said oddly the output does show in the output window ( print statements after the require('mobdebug').start() ) so I know it is trying to work.

Prior to this (a few days back) I was coding in c++ for marmalade. Perhaps something I ran there has interfered? I can try re-installing marmalade and see if that changes anything.

Oh and I'm using 0.38 (first time trying your app)

trysenga commented 11 years ago

Ok no luck tonight. I've rebooted, re-installed marmalade and quick yet following those steps it still doesn't hit the break point. Here is an odd observation: when I try to run my own test project (debug) it creates an extra lua file (mobdebug.lua) in my resources folder. This does not happen when I debug the examples.

pkulchenko commented 11 years ago

@trysenga, okay, I'll try with 6.3.1 tomorrow; just need to download it.

Here is an odd observation: when I try to run my own test project (debug) it creates an extra lua file (mobdebug.lua) in my resources folder. This does not happen when I debug the examples.

That's how it should be. When you start debugging, ZBS copies the debugger to your project, but the location depends on where s3e-data-dir points to and if it's not specified it's a project folder. For sample projects it points to ../../../../data or something like that.

Ok no luck tonight. I've rebooted, re-installed marmalade and quick yet following those steps it still doesn't hit the break point.

This is a crazy question, but just in case, you set breakpoint on a line after require('mobdebug').start() call, right?

Last thing; can you add print(debug.getinfo(1,"S").source) to your script and run it under the debugger? What does it print? In my case it's examples/Hello World/Hello World/main.lua. In most cases breakpoints don't work when there is a mismatch between paths reported by the Lua engine and paths known to the IDE. In this case the path you see in Debugging session started in '...'. message combined with the path printed above should give you the path to the main.lua file. In my case it's D:\Program Files\marmalade\quick\data\ and examples/Hello World/Hello World/main.lua (ignore different path separators).

trysenga commented 11 years ago

I added the line and it printed "examples/Hello World/Hello World/main.lua".

The full path to the hello world lua file is "C:\Marmalade\6.3\quick\data\examples\Hello World\Hello World\main.lua"

Here is the full console output:

Program starting as '"C:\Marmalade\6.3\s3e\win32\s3e_simulator_debug.exe" --dll="C:\Marmalade\6.3\quick\target\win\quick_prebuilt_d.s86" --data="C:\Marmalade\6.3\quick\data" --app-icf1="C:\Marmalade\6.3\quick\data\common.icf" --app-icf2="C:\Marmalade\6.3\quick\data\examples\Hello World\Hello World\app.icf"'. Program 's3e_simulator_debug.exe' started in 'C:\Marmalade\6.3\quick\data\examples\Hello World\' (pid: 1352). Debugging session started in 'C:\Marmalade\6.3\quick\data\'. "examples/Hello World/Hello World/main.lua" "Hello, World!" "Creating default font" Debugging session completed (traced 0 instructions). Program completed in 7.70 seconds (pid: 1352).

pkulchenko commented 11 years ago

@trysenga, I'm not sure what's going on. I downloaded and installed the latest Marmalade SDK (6.3.2) and use the latest Quick (1.1.2) and can't reproduce the issue. This is what gets printed:

Program starting as '"D:\Program Files\marmalade\s3e\win32\s3e_simulator_debug.exe" --dll="D:\Program Files\marmalade\quick\target\win\quick_prebuilt_d.s86" --data="D:\Program Files\marmalade\quick\data" --app-icf1="D:\Program Files\marmalade\quick\data\common.icf" --app-icf2="D:\Program Files\marmalade\quick\data\examples\Hello World\Hello World\app.icf"'.
Program 's3e_simulator_debug.exe' started in 'D:\Program Files\marmalade\quick\data\examples\Hello World\' (pid: 6008).
Debugging session started in 'D:\Program Files\marmalade\quick\data\'.
"Hello, World!"
"examples/Hello World/Hello World/main.lua"

This is what I have in the Hello World script:

require('mobdebug').start()

-- Simple print to console
print("Hello, World!") --<-- set breakpoint here
print(debug.getinfo(1,"S").source)
...

Can you try setting breakpoint as described (before starting Debugging) and maybe using 6.3.2 (I couldn't get 6.3.1 installed, so I got the latest Marmalade version)?

If this still doesn't help, I'll try to find an instance of win7 64bit (I'm testing on 32bit Vista) to check there.

trysenga commented 11 years ago

Well I grabbed 6.3.2 this morning, but the same issue. I'm setting break points (before starting) on nearly every line now - nothing hits. Here is the output from console:

Debugger server started at STUDIO-PC:8172. Program starting as '"C:\Marmalade\6.3\s3e\win32\s3e_simulator_debug.exe" --dll="C:\Marmalade\6.3\quick\target\win\quick_prebuilt_d.s86" --data="C:\Marmalade\6.3\quick\data" --app-icf1="C:\Marmalade\6.3\quick\data\common.icf" --app-icf2="C:\Marmalade\6.3\quick\data\examples\Hello World\Hello World\app.icf"'. Program 's3e_simulator_debug.exe' started in 'C:\Marmalade\6.3\quick\data\examples\Hello World\' (pid: 4524). Debugging session started in 'C:\Marmalade\6.3\quick\data\'. "Hello, World!" "examples/Hello World/Hello World/main.lua" "Creating default font" Debugging session completed (traced 0 instructions). Program completed in 10.56 seconds (pid: 4524).

pkulchenko commented 11 years ago

@trysenga, okay, let's try this. Open lualibs/mobdebug/mobdebug.lua and add the following:

local function set_breakpoint(file, line)
  if file == '-' and lastfile then file = lastfile
  elseif iscasepreserving then file = string.lower(file) end
  if not breakpoints[line] then breakpoints[line] = {} end
  breakpoints[line][file] = true
iobase.print("set", file, line) --<-- add this line
end

...

local function has_breakpoint(file, line)
iobase.print("has", file, line) --<-- add this line
  return breakpoints[line]
     and breakpoints[line][iscasepreserving and string.lower(file) or file]
end

Then do everything as before and add breakpoint as we discussed earlier. After your debugging process is done, open examples\Hello World\iwtrace.txt and check set and has output there (should be close to the end). You will see something like this:

set examples/hello world/hello world/main.lua   15
Hello, World!
examples/Hello World/Hello World/main.lua
has examples/Hello World/Hello World/main.lua   15

Please send me all these has/set lines.

trysenga commented 11 years ago

I'm including more of the trace than you mentioned because I see other errors that perhaps are relevant. I had 4 breakpoints set - none hit.

QUICKCPP LOG: Marmalade Quick 1.1

QUICKCPP LOG: Loading app configuration...

ERROR: S3E_FILE_ERR_NOT_FOUND in s3eFileOpen - Path config.lua not found QUICKCPP WARNING: Failed to load config lua file

QUICKCPP LOG: Loading Quick engine...

COCOS2DX LOG: cocos2d: GL_VENDOR: Google Inc.

COCOS2DX LOG: cocos2d: GL_RENDERER: ANGLE (ATI Radeon HD 4300/4500 Series)

COCOS2DX LOG: cocos2d: GL_VERSION: OpenGL ES 2.0 (ANGLE 1.0.0.1275)

COCOS2DX LOG: cocos2d: GL_MAX_TEXTURE_SIZE: 8192

COCOS2DX LOG: cocos2d: GL_MAX_TEXTURE_UNITS: 20

COCOS2DX LOG: cocos2d: GL supports PVRTC: NO

COCOS2DX LOG: cocos2d: GL supports BGRA8888 textures: NO

COCOS2DX LOG: cocos2d: GL supports NPOT textures: YES

COCOS2DX LOG: cocos2d: GL supports discard_framebuffer: NO

COCOS2DX LOG: cocos2d: GL supports shareable VAO: NO

COCOS2DX LOG: cocos2d: compiled with Profiling Support: NO

QUICKCPP LOG: Loading app...

ERROR: S3E_FILE_ERR_NOT_FOUND in s3eFileOpen - Path proc not found 03/08/13 12:10:20.328: [0xfa0] SOCKET: s3eSocketCreate -> p=0x50455ea4 id=3000 03/08/13 12:10:20.328: [0xfa0] SOCKET: s3eInetAton: 'localhost' 03/08/13 12:10:20.328: [0xfa0] SOCKET: s3eInetLookup: 'localhost' 03/08/13 12:10:20.334: [0xfa0] SOCKET: s3eInetLookup (synchronous): done DNS: '127.0.0.1:0' 03/08/13 12:10:20.334: [0xfa0] SOCKET: s3eSocketConnect: 0x50455ea4 -> 127.0.0.1:8172 ERROR: S3E_SOCKET_ERR_INPROGRESS in s3eSocketConnect 03/08/13 12:10:20.335: [0xfa0] SOCKET: TryConnect error: 10036 03/08/13 12:10:20.335: [0xfa0] SOCKET: Connect: FAILED (1001: S3E_SOCKET_ERR_INPROGRESS in s3eSocketConnect) 03/08/13 12:10:20.335: [0xfa0] SOCKET: TryConnect error: 10056 03/08/13 12:10:20.335: [0xfa0] SOCKET: NotifyConnect: 3000 0x50455ea4 set examples/hello world/hello world/main.lua 12 set examples/hello world/hello world/main.lua 16 set examples/hello world/hello world/main.lua 23 set examples/hello world/hello world/main.lua 29 Hello, World! has "examples/Hello World/Hello World/main.lua" 12 examples/Hello World/Hello World/main.lua Creating default font COCOS2DX LOG: cocos2d: padding: 1,1,1,1

COCOS2DX LOG: cocos2d: padding: 1,1,1,1

has "examples/Hello World/Hello World/main.lua" 16 has "examples/Hello World/Hello World/main.lua" 29 COCOS2DX LOG: cocos2d: padding: 0,0,0,0

COCOS2DX LOG: cocos2d: padding: 0,0,0,0

COCOS2DX LOG: cocos2d: padding: 0,0,0,0

has "examples/Hello World/Hello World/main.lua" 23 has "examples/Hello World/Hello World/main.lua" 23 has "examples/Hello World/Hello World/main.lua" 23 has "examples/Hello World/Hello World/main.lua" 23 03/08/13 12:10:24.279: [0xfa0] IW_GL: Leaked Program with handle 2 03/08/13 12:10:24.280: [0xfa0] IW_GL: Leaked Program with handle 5 03/08/13 12:10:24.281: [0xfa0] IW_GL: Leaked Texture with handle 1 03/08/13 12:10:24.282: [0xfa0] IW_GL: Leaked Texture with handle 2 03/08/13 12:10:24.282: [0xfa0] IW_GL: Leaked Texture with handle 3 03/08/13 12:10:24.283: [0xfa0] IW_GL: Leaked VBO with handle 1 03/08/13 12:10:24.283: [0xfa0] IW_GL: Leaked VBO with handle 2 03/08/13 12:10:24.283: [0xfa0] IW_GL: Leaked VBO with handle 3 03/08/13 12:10:24.284: [0xfa0] IW_GL: Leaked VBO with handle 4 03/08/13 12:10:24.284: [0xfa0] IW_GL: Terminating EGL... 03/08/13 12:10:24.307: [0xfa0] IW_GL: Terminating EGL... Done COCOS2DX LOG: cocos2d: deallocing CCDirector 06CC2708

COCOS2DX LOG: cocos2d: cocos2d-2.1beta3-x-2.1.0

COCOS2DX LOG: cocos2d: deallocing CCDirector 06CC5A28

03/08/13 12:10:24.335: [0xfa0] SOCKET: s3eSocketClose: 0x50455ea4 open=1 -- END TRACE --

pkulchenko commented 11 years ago

@trysenga, thank you for the trace; I now know what's going on. Some SDKs report sources as filename instead of @filename and there was a change put in as part of 0.38 to allow debugging of code source fragments (9175bdd3) that was affected by this. I made a fix for it (43513c91) couple of weeks ago, so you either need to downgrade to v0.37 or try the latest code from github (master; just unzip to any folder and run zbstudio.exe; it should use your current settings). Please let me know if this resolves the issue.

trysenga commented 11 years ago

Master fixes it - thanks! I'm so glad you wrote support for Marmalade. I won't even consider a cross-platform solution unless it can be debugged. They should be paying you for your ongoing support (I'm sure I will once I sell a game).

pkulchenko commented 11 years ago

Great! Closing.