Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Lua Development Tools » Can LDT debug Lua in a C app?
Can LDT debug Lua in a C app? [message #1048571] Wed, 24 April 2013 17:05 Go to next message
tom adams is currently offline tom adamsFriend
Messages: 6
Registered: April 2013
Junior Member
Hi,
My project is a Windows console app written in c with Lua 5.2 embedded. I need a way to debug the Lua code. I have tried to Debug my project in LDT Eclipse, but it only works for a Lua Project, mine is c/c++ project.

Does LDT support a way to debug my Lua code?
Re: Can LDT debug Lua in a C app? [message #1049179 is a reply to message #1048571] Thu, 25 April 2013 13:26 Go to previous messageGo to next message
Simon Bernard is currently offline Simon BernardFriend
Messages: 345
Registered: July 2009
Senior Member
Hi,
I propose 2 not perfect solutions :

  1. create another Lua Project in the workspace and create a linked source folder.
    (right click on project "BuildPath/link source ..." and refer the folder which contains your lua source)

  2. (only for advanced eclipse user) you could add the LDT nature to your project and the script builder (see .project file) then configure your buildpath.

I recommend the first one.

To set your debug session you could have a look on the User guide.

If your interpreter(application) don't manage the -e option, (used by LDT to bootstrap the debugger) you could :
- use the attach debug.
- test the milestone version 1.0.0M1 which proposes a more integrated solution for this use case.

You will probably need a compatible 5.2 version of lua socket.
Re: Can LDT debug Lua in a C app? [message #1049473 is a reply to message #1049179] Thu, 25 April 2013 22:48 Go to previous messageGo to next message
tom adams is currently offline tom adamsFriend
Messages: 6
Registered: April 2013
Junior Member
ok, I used the first method, it seems cleaner. So, I added the nature and now I can see the Lua settings for the Project as well as C/C++.
But when I try to debug some lua code within my c app (by setting a breakpoint) the debugger skips over the code.

What is the next step to tell the debugger I want to debug the Lua code, not the C code when I run the Console app?

Thanks.
Re: Can LDT debug Lua in a C app? [message #1049766 is a reply to message #1049473] Fri, 26 April 2013 08:50 Go to previous messageGo to next message
Simon Bernard is currently offline Simon BernardFriend
Messages: 345
Registered: July 2009
Senior Member
As I said :

To set your debug session you could have a look on the User guide.

If your interpreter(application) don't manage the -e option, (used by LDT to bootstrap the debugger) you could :
- use the attach debug.
or
- test the milestone version 1.0.0M1 which proposes a more integrated solution for this use case.

You will probably need a compatible 5.2 version of lua socket.

If there something not clear, in the documentation. Please tell us and we will try to make it clearer.

[Updated on: Mon, 29 April 2013 11:42]

Report message to a moderator

Re: Can LDT debug Lua in a C app? [message #1050168 is a reply to message #1049766] Fri, 26 April 2013 20:12 Go to previous messageGo to next message
tom adams is currently offline tom adamsFriend
Messages: 6
Registered: April 2013
Junior Member
I have tried to add my Alternate lua interpreter, in Run Configuration, but it asks for a Launch script: which I don't have because my app, call it myapp.exe, has Lua libraries embedded, so I don't have an external script.

The docs are confusing and don't describe how I can Debug Lua code "inside" my app when I don't have any external lua scripts.

Thanks.
Re: Can LDT debug Lua in a C app? [message #1051928 is a reply to message #1050168] Mon, 29 April 2013 11:41 Go to previous message
Simon Bernard is currently offline Simon BernardFriend
Messages: 345
Registered: July 2009
Senior Member
You talk about 'interpreter' and 'Launch script'? Your comment is confusing but I suppose you tried the second solution (so you downloaded the 1.0.0M1 version).
Did you test the first one ?

If you want to use the second solution, I will try to make it clearer :
When you use a "standard" Lua Interpreter (Lua 5.1, wxLua, LuaJIT ...), you could pass the file you want to be interpreted by the VM.
If I understand in your case, your C application (which will be considered by LDT as an interpreter) can not take a Script file in parameters. So in this case, you must fake the UI and Select any file.
(I agree this is not really userfriendly)

When you registered your interpreter, you need to check/uncheck options in function of your interpreter capabilities. (as explain here)


You say you have no external script, but I suppose your C application load some lua files. Files which are present in your project. Files on which you will set breakpoints. If not, please can you explain me where is your Lua code ?

Now to debug your application, the lua debugger client should be launched. Generally this is done automatically by LDT thx to the -e option but if your application don't support this convention you must launch the debugger on your own.
So choose the lua file which is loading in first and add this line of code at begin : (cal_session]as explain here)
if os.getenv('DEBUG_MODE') then require "debugger"() end[/code]

Do not forget your need luasocket to allow the debugger client to connect to the debugger Server integrated in LDT.
Previous Topic:LDT with luabind
Next Topic:Run external program on save
Goto Forum:
  


Current Time: Fri Mar 29 11:03:29 GMT 2024

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

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

Back to the top