Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Lua Development Tools » Debugging lualatex
Debugging lualatex [message #872475] Wed, 16 May 2012 07:38 Go to next message
uiy uiy is currently offline uiy uiyFriend
Messages: 50
Registered: May 2012
Member
Lualatex uses lua as a scripting engine(I think it is built in to the executable though). I develop all my lua code separately then add it in to lua because it is difficult to debug(have to use console printing).

By using the debugger scripts for the DBGT will/should it hook into the ldt and allow breakpoints and inspection?

[Updated on: Wed, 16 May 2012 07:39]

Report message to a moderator

Re: Debugging lualatex [message #872779 is a reply to message #872475] Wed, 16 May 2012 19:56 Go to previous messageGo to next message
Benjamin Cabé is currently offline Benjamin CabéFriend
Messages: 156
Registered: July 2009
Location: Toulouse, France
Senior Member

After a quick search on the Internet, it seems that LuaLatex somehow supports/includes Luasocket, which is needed by the DBGP client. So I guess you should be able to use it in the exact same way you would use it in a regular Lua script... Let us know the outcome!
Re: Debugging lualatex [message #872983 is a reply to message #872779] Thu, 17 May 2012 08:32 Go to previous messageGo to next message
uiy uiy is currently offline uiy uiyFriend
Messages: 50
Registered: May 2012
Member
The issue I get with the following test is:

"LuaSocket 2.0.2

test.tex:8: LuaTeX error debugger.lua:68: module 'socket' not found:
no field package.preload['socket']
[kpse lua searcher] file not found: 'socket'
[kpse C searcher] file not found: 'socket'
stack traceback:"

with the following code(DebugTest.lua):

"
socket = require("socket")
print("\n"..socket._VERSION.."\n")
require("debugger")()
"

Line 68 in debugger is

local socketcore = require"socket.core"

and I've tried changing it to

local socketcore = require"socket"

but get the same error.

I then copied core.dll and socket.lua from my main lua distro so that lualatex could find it(same dir as my lua code). This got past that error. (I don't know why the first line worked and printed version though... should be the exact same stuff?)

Next I got an error in base_path:

"156: if not base_dir then error("Unable to determine the working directory.")end"

which I just hard coded the base_dir to the source code files.

When I ran for the first time I got a timeout trying to access the debugger. When I started the DGBT and ran everything worked BUT the breakpoints were not hit. Subsequently running the tex program without DGBT running did not cause it to time out but printed debugger_loop error msg that generally happens in LDT.

So the only real issue is getting the breakpoints working. Any ideas?


Re: Debugging lualatex [message #895736 is a reply to message #872983] Sun, 15 July 2012 15:00 Go to previous messageGo to next message
uiy uiy is currently offline uiy uiyFriend
Messages: 50
Registered: May 2012
Member
I have now been able to succesfully debug lua code from a lualatex!!!!!!!!!!!!!!

Simply include the standard require debugger header in your tex(or lua code)

\directlua{require("debugger")()}

Add your breakpoints, start the debugger in the ldt, then compile the tex code, and debug like normal.

This should be a great boon for lualatex. It seems the recent updates have solved the problem(as I have done nothing different since the I posted these messages).


So far what I have noticed is that the lualatex global variables do not seem to show up in the inspector. e.g., I should see a tex variable in there somewhere but I can't find it. It is not difficult to get it in there by simply defining a local variable of it(local t = tex).







[Updated on: Sun, 15 July 2012 15:03]

Report message to a moderator

Re: Debugging lualatex [message #895744 is a reply to message #895736] Sun, 15 July 2012 16:05 Go to previous messageGo to next message
Benjamin Cabé is currently offline Benjamin CabéFriend
Messages: 156
Registered: July 2009
Location: Toulouse, France
Senior Member

w00t! That's great news!
Re: Debugging lualatex [message #895773 is a reply to message #895744] Sun, 15 July 2012 22:52 Go to previous message
uiy uiy is currently offline uiy uiyFriend
Messages: 50
Registered: May 2012
Member
One issue seems to be the that one can't load external lua files and debug them. Trying to add a breakpoint to a lua file not in the project results in a null breakpoint added. (Well, normally it is Lua: <filename> [line: <line>] but in this case filename is shown as null which suggests it has an issue dealing with files)

When trying to actually debug I get the error:

Command breakpoint_set caused: (998) debugger.lua:880: attempt to index local 'uri' (a nil value)

Using module resolution doesn't change anything.

It seems when setting a breakpoint in the ldt it doesn't get the correct filename which then causes the debugger to break.

(I've noted that the breakpoints to not seem to store the absolute path which could be the real underlying issue. If I put the file into the current project it works as expected)

[Updated on: Sun, 15 July 2012 23:21]

Report message to a moderator

Previous Topic:Keep debugger running
Next Topic:I want customize code
Goto Forum:
  


Current Time: Fri Dec 19 08:45:39 GMT 2014

Powered by FUDForum. Page generated in 0.01908 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software