Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "LDT/User Area/User Guides/User Guide 0.9"

Line 44: Line 44:
 
==Debug a Lua script==
 
==Debug a Lua script==
  
Simply define a ''breakpoint'' and you are all set for debugging.
+
Simply define a ''breakpoint'' by right clicking (or double clicking) in the first column at the beginning of the line.
 
Select your project in favorite debug sessions and your breakpoint should be hit.
 
Select your project in favorite debug sessions and your breakpoint should be hit.
  
Line 162: Line 162:
 
==Configuring Build paths==
 
==Configuring Build paths==
  
Project path is the one set using the right clic ''Build Path > Configure Build Path ...'' UI. From there you can
+
Project path is the one set using the right click ''Build Path > Configure Build Path ...'' UI. From there you can
 
specify dependency to other project from current workspace. As a result,
 
specify dependency to other project from current workspace. As a result,
 
will enjoy completion and navigation between your project and the ones configured in Build Path.
 
will enjoy completion and navigation between your project and the ones configured in Build Path.
 +
 
[[Image:BuildPath.png|center]]
 
[[Image:BuildPath.png|center]]
  
Line 172: Line 173:
 
''Window > Preferences > Lua > Execution Environments'' and you will have following interface.
 
''Window > Preferences > Lua > Execution Environments'' and you will have following interface.
  
[[Image:EePref.png|center]]
+
[[Image:EePref_09.png|center]]
  
As you can see in previous screenshot, LDT is deliver with a Lua 5.1 Execution Environement. Embedded Execution Environment are suffied ''(embedded)''.
+
As you can see in previous screenshot, LDT is deliver with a Lua 5.1 Execution Environment. Embedded Execution Environment are suffixed by ''(embedded)''.
 
To override an installed embedded Execution Environment, create a new Execution Environment with the same name.  
 
To override an installed embedded Execution Environment, create a new Execution Environment with the same name.  
 
All the projects using the embedded Execution Environment will automatically use the new one.
 
All the projects using the embedded Execution Environment will automatically use the new one.
Line 216: Line 217:
  
 
An embedded interpreter is an interpreter delivered with LDT. You can recognize the interpreter preference page, the location is ''(embedded)''.
 
An embedded interpreter is an interpreter delivered with LDT. You can recognize the interpreter preference page, the location is ''(embedded)''.
Currently, LDT is delivered with the JNLua embedded interpreter, JNLua is Java implementation of Lua interpreter and APIs.
+
Currently, LDT is delivered with the JNLua embedded interpreter, JNLua is Java binding of Lua interpreter and APIs.
  
 
=== Local Interpreters ===
 
=== Local Interpreters ===
  
To run Lua scripts in LDT using the Lua Local Application launch configuration with an locally installed Lua interpreter, you have to configure a local interpreter.
+
To run Lua scripts in LDT using the Lua Local Application launch configuration with an locally installed Lua interpreter, you have to configure a local interpreter. To support debug, the interpreter have to support ''-e'' option and have ''luasocket'' in the path.
 +
 
 
To configure an interpreter you just need the path of the interpreter executable, then you can set interpreter
 
To configure an interpreter you just need the path of the interpreter executable, then you can set interpreter
 
arguments and set some environment variables.
 
arguments and set some environment variables.
Line 228: Line 230:
 
To open the Interpreters preference page go to
 
To open the Interpreters preference page go to
 
''Window > Preferences > Lua > Interpreters'':
 
''Window > Preferences > Lua > Interpreters'':
[[Image:InterpreterPreferencePage.png|center]]
+
[[Image:InterpreterPreferencePage_0.9.png|center]]
  
 
Then, press the ''Add...'' button to configure a new interpreter and fill in the fields as described here:
 
Then, press the ''Add...'' button to configure a new interpreter and fill in the fields as described here:
* Leave the ''Interpreter type'' as ''Generic Lua''. Currently it is the only type available,
+
* Leave the ''Interpreter type'' as ''Generic Lua''.
 
* You can browse your file system and locate your interpreter executable, or if the executable is in your PATH environment variable, just type its name here (e.g. <code>lua</code>),
 
* You can browse your file system and locate your interpreter executable, or if the executable is in your PATH environment variable, just type its name here (e.g. <code>lua</code>),
 
* Give a name to the interpreter (this is mandatory),
 
* Give a name to the interpreter (this is mandatory),
Line 244: Line 246:
 
== Configuring debug sessions ==
 
== Configuring debug sessions ==
  
== Local session ==
+
=== Local session ===
  
 
Create a Lua Application launch configuration in the ''Debug Configuration'' menu.
 
Create a Lua Application launch configuration in the ''Debug Configuration'' menu.
Line 253: Line 255:
  
 
In the ''Arguments'' tab, you can specify interpreter arguments and script arguments.
 
In the ''Arguments'' tab, you can specify interpreter arguments and script arguments.
The interperter arguments will be merged to the ones specified at the interpreter level (in the interpreter preference page) at runtime.
+
The interpreter arguments will be merged to the ones specified at the interpreter level (in the interpreter preference page) at runtime.
 
[[Image:ArgumentsLocalLaunchConfig.png|center]]
 
[[Image:ArgumentsLocalLaunchConfig.png|center]]
  
Line 261: Line 263:
  
 
In the ''Common'' tab, you can set some settings related to launch configurations:
 
In the ''Common'' tab, you can set some settings related to launch configurations:
**Save current launch configuration in a specified file.
+
*Save current launch configuration in a specified file.
**See in favorite menu the launch conf is displayed.
+
*See in favorite menu the launch configuration is displayed.
**Change the encoding of the launch configuration file.
+
*Change the encoding of the launch configuration file.
**Allocate  sandard input/output in a console and/or redirect standard output in a file.
+
*Allocate  standard input/output in a console and/or redirect standard output in a file.
  
== Attach session ==
+
=== Attach session ===
  
 
The Debugger of Lua Development Tools is based on the DBGp protocol, and the IDE implements a DBGp server.<br> To connect to this server, and begin remote/attach debugging, you need to use a DBGp Lua client.
 
The Debugger of Lua Development Tools is based on the DBGp protocol, and the IDE implements a DBGp server.<br> To connect to this server, and begin remote/attach debugging, you need to use a DBGp Lua client.
  
=== Launching DBGp Client  ===
+
==== Launching DBGp Client  ====
  
 
The DBGp Lua client is a Lua file and can be downloaded through the lua Attach To Application launch configuration UI.<br>
 
The DBGp Lua client is a Lua file and can be downloaded through the lua Attach To Application launch configuration UI.<br>
Line 329: Line 331:
 
}}
 
}}
  
=== Setup DBGp Server  ===
+
==== Setup DBGp Server  ====
  
 
The DBGp Server is integrated in LDT.<br> In order to accept incoming debug sessions, you must create a new '''Lua Attach to Application''' launch configuration, then launch it.  
 
The DBGp Server is integrated in LDT.<br> In order to accept incoming debug sessions, you must create a new '''Lua Attach to Application''' launch configuration, then launch it.  
Line 349: Line 351:
 
[[Image:DebugUI.png|center]]
 
[[Image:DebugUI.png|center]]
  
== Remote session ==
+
=== Remote session ===
 +
 
 +
As the remote debugging is an advanced feature not require to most of the Lua developments, the remote debbugging not delivred with
 +
LDT and have to be downloaded and installed on top of LDT.
 +
To install the LDT remote feature, first select the top menu ''Help/Install New Software...''
  
To perform remote debugging, you have to install the LDT remote feature.
 
Select the top menu ''Help/Install New Software...''
 
 
[[Image:InstallSoftware.png|center]]
 
[[Image:InstallSoftware.png|center]]
  
Enter the LDT update site url, it should be ''http://download.eclipse.org/koneki/releases/stable'' for the stable release, but nighly or millestone update site url can be used.
+
On the LDT update site select the remote feature in the list and install it. (see [[http://wiki.eclipse.org/Koneki/updatesites|Eclipse documentation about update site]])
Select the remote feature in the list and install it.
+
 
 
[[Image:remoteFeature.png|center]]
 
[[Image:remoteFeature.png|center]]
  
 
In the Remote System Explorer perspective, in the new wizard, create a new ''Connection'' and select the ''Lua Ssh System'' kind of system.
 
In the Remote System Explorer perspective, in the new wizard, create a new ''Connection'' and select the ''Lua Ssh System'' kind of system.
 +
 
[[Image:createConnexion.png|center]]
 
[[Image:createConnexion.png|center]]
  
 
On the next page, enter the network name of your remote system, or directly the IP address.
 
On the next page, enter the network name of your remote system, or directly the IP address.
 +
 
[[Image:createConnexionEnterIP.png|center]]
 
[[Image:createConnexionEnterIP.png|center]]
  
If needed, configure runtime paths in ssh-lua sub-system advanced properties, if paths are not configured, the remote environment variables will be used. To change the properties, select the ssh lua node of you connection, then in the property view bellow push the ''show advanced properties'' button. You can edit properties values by selecting the appropriate cell. If you let some properties empty, the remote system lua default will be used.  
+
If needed, configure runtime paths in ssh-lua sub-system advanced properties, if paths are not configured, the remote sytems's environment variables will be used. To change the properties, select the ssh lua node of your connection, then in the property view bellow push the ''show advanced properties'' button. You can edit properties values by selecting the appropriate cell. If you let some properties empty, the remote system lua default will be used.  
Warning, LDT is not able to retrieve environement variables specfied in the user scope. For exemple, if the variable LUA_PATH is modified in the .profile or .bashrc files of the remote user, on runtime theses modifications may not be taken intp account.
+
Warning, LDT is not able to retrieve environement variables specfied in the user scope. For exemple, if the variable LUA_PATH is modified in the .profile or .bashrc files of the remote user, on runtime theses modifications may not be taken into account.
 +
 
 
[[Image:remoteConnection.png|center]]
 
[[Image:remoteConnection.png|center]]
  
 
In the top menu, select ''Run/Debug Configuration...''.
 
In the top menu, select ''Run/Debug Configuration...''.
 +
 
[[Image:DebugConfiguration.png|center]]
 
[[Image:DebugConfiguration.png|center]]
  
 
Then, create a Remote Lua Application launch configuration.
 
Then, create a Remote Lua Application launch configuration.
 
Configure the project and the script to run, select also the remote system.
 
Configure the project and the script to run, select also the remote system.
 +
 
[[Image:RemoteLaunchConf.png|center]]
 
[[Image:RemoteLaunchConf.png|center]]
  
 
Following tab are also provided to configure your launch configuration:
 
Following tab are also provided to configure your launch configuration:
*''Arguments'': you can here specify script and remote interpreter arguments, type the arguments as you would in command line. At the bottom of the tab, you can also edit the location where Lua files will be copied on the remote system, an absolute path is mandatory.
+
''Arguments'': you can here specify script and remote interpreter arguments, type the arguments as you would in command line. At the bottom of the tab, you can also edit the location where Lua files will be copied on the remote system, an absolute path is mandatory.
*''Environment'': Specify here some environement variables for runtime. If the variable already exists on the remote system, the specifed value in the launch configuration will be appended to the existing value. Warning, as explained above, LDT is not able to retrieve environement variables values specfied in the user scope.
+
''Environment'': Specify here some environement variables for runtime. Theses variables will be added to remote system's existing environement variables.
*''Common'': Some common launch configuration related settings.
+
Warning, as explained above, LDT is not able to retrieve environement variables values specfied in the user scope.
**Save current launch configuration in a specified file.
+
''Common'': Some common launch configuration related settings.
**See in favorite menu the launch conf is displayed.
+
*Save current launch configuration in a specified file.
**Change the encoding of the launch configuration file.
+
*See in favorite menu the launch conf is displayed.
**Allocates standard input/output in a console and/or redirects standard output in a file.
+
*Change the encoding of the launch configuration file.
 +
*Allocates standard input/output in a console and/or redirects standard output in a file.
  
 
Launch the debug session, see how [Debugging a Lua program] to continue.
 
Launch the debug session, see how [Debugging a Lua program] to continue.
 +
  
 
== Debugging a Lua program  ==
 
== Debugging a Lua program  ==
Line 430: Line 441:
  
 
=== Source Mapping  ===
 
=== Source Mapping  ===
 +
 
The DBGp Server (IDE) and the DBGp client (running application) need to communicate about source files.
 
The DBGp Server (IDE) and the DBGp client (running application) need to communicate about source files.
  

Revision as of 05:13, 26 October 2012

Overview

The LDT project provides plug-ins that implement a Lua IDE supporting the development of Lua scripts and applications. It adds a dedicated Lua perspective to the Eclipse Workbench, which, together with features such as syntax highlighting, scope-aware code completion, code folding, etc. allows to structure Lua application better (project-based organization), and boosts the productivity of Lua developers.

Getting started

Create a project

For your code to be manipulated correctly by Lua Development Tools, it must be contained into an Eclipse project having a Lua flavour. In order to do this, you have to create a Lua Project, it will add Lua nature to your code.

In File > New > Lua Project, enter a valid name and voila!

NewLuaProject0.9.png

Edit some Lua

Now that your project is created, you are ready to start working on your Lua scripts. In every project, there is a default source folder, named src. You can edit the main.lua file in it, notice that completion is already available for Lua built in functions.

EditingFile0.9.png

Run a Lua script

To run your Lua script, the file has to be contained in a Lua project. If it is the case, you can simply right click on the file add select Run As/Lua Application.

RunAs0.9.png
Console0.9.png

The Run As menu creates a default launch configuration for the selected file and launch it.

RunShortcut0.9.png

Debug a Lua script

Simply define a breakpoint by right clicking (or double clicking) in the first column at the beginning of the line. Select your project in favorite debug sessions and your breakpoint should be hit.

ToggleBreakpoint0.9.png
DebugShortcut0.9.png
DebugPerspective0.9.png

Concepts

Before diving into the concepts of LDT, if you need more information about the concepts of Lua itself, you are highly encouraged to refer to the Lua manual (http://www.lua.org/manual/).

Buildpath

It is a set of folder paths which contains source and libraries accessible from your project. There are several kinds of them:

Some elements like source folders and project dependencies are used for tooling and runtime purposes. Some others, are used only for tooling purposes, such as [Execution_Environments|Execution Environments].

About runtime , source folders of current project and the ones of projects on which it depends will be appended to [[1]] at runtime.

About tooling, all elements from buildpath are parsed to unleash the power of tooling with features such as code completion and code navigation.

You can require files from your source folders as modules. Lets say in a src/ source path you a foo.lua file, you can write:

   require 'foo'

This logic applies to sub directories, with a bar.lua in folder src/sub, you can use:

   require 'sub.bar'

Note: Source folders are important, as they are processed for tooling information. That is to say, if you write a module outside of a source folder , it will not be accessible from another module or script; thus, its content will not be available in e.g. code completion nor documentation.

Configuring Buildpaths

Execution Environment

An Execution Environment, which may also be referred to as EE, is a file containing information about the environment where a Lua application is supposed to run. An environment is a set of libraries available to the application out of the box, as in Lua 5.1 or MOAI SDK.

The idea is to provide a file which describe elements of an environment. Provided information allows LDT to offer better code completion, code navigation and documentation layout.

An Execution Environment may contain:

  • bootstrap file: template of typical entry point for an application aiming this execution environment, so for named main.lua.
  • modules
  • version: which is handy when working on several projects.

Create an Execution Environment
Manage Execution Environments

Interpreters

In our case, an interpreter is a program which executes the instructions of your program. The most used in the Lua world might be [standalone interpreter]. It is possible to run Lua application using interpreters from Konkeki LDT. There is a JNLua base implementation available out of the box, but you can use your own.

Manage interpreters

Debug

Debug is a common way to monitor how your program behave at runtime, step by step. You might be interested to do so when your application in not even running on your computer.

Local Debug

It is the typical case, you monitor a program running on your desktop.

Configure a Local Debug session

Attach Debug

You want to monitor a an application running in a specific context, this application is not launched from Koneki LDT. There is a solution for you. Your application can connect to the IDE at startup and be monitored.

This way is called attached debug, uses DBGp and is composed of two parties.

  • DBGp Server: In our case it is Koneki LDT waiting for an application to connect.
  • DBGp Client: In our case, it is the debugged application sending information about its run to Koneki LDT.

Configure an Attach Debug session

Remote Debug

Remote Debug enables to monitor an application running on a remote system. This system must have the following installed:

  • Unix-like
  • SFTP
  • SSH

Configure a Remote Debug session

Tasks

Configuring Build paths

Project path is the one set using the right click Build Path > Configure Build Path ... UI. From there you can specify dependency to other project from current workspace. As a result, will enjoy completion and navigation between your project and the ones configured in Build Path.

BuildPath.png

Managing Execution Environments

To find preferences related to EE, go to Window > Preferences > Lua > Execution Environments and you will have following interface.

EePref 09.png

As you can see in previous screenshot, LDT is deliver with a Lua 5.1 Execution Environment. Embedded Execution Environment are suffixed by (embedded). To override an installed embedded Execution Environment, create a new Execution Environment with the same name. All the projects using the embedded Execution Environment will automatically use the new one.

From there, is it possible to add an EE to current workspace by pressing Add, then select an Execution Environment.

EePrefAdd.png

The EE is now available.

EePrefAdded.png

Link an existing project to an Execution Environment

Once you have manage to install Execution Environments in your workspace, it is time to use them in a project. Right click a project and select Build Path >> Add Libraries ....

EeContextSelection.png

You will have to choose between several libraries types, choose Lua Execution Environment.

EeAddLib.png

You can now choose among installed EEs and press OK.

EePrefAdded.png

It is now linked to selected project.

EeAddedToProject.png


Managing Interpreters

Interpreters are used by LDT to run scripts on the local computers.

Embedded Interpreters

An embedded interpreter is an interpreter delivered with LDT. You can recognize the interpreter preference page, the location is (embedded). Currently, LDT is delivered with the JNLua embedded interpreter, JNLua is Java binding of Lua interpreter and APIs.

Local Interpreters

To run Lua scripts in LDT using the Lua Local Application launch configuration with an locally installed Lua interpreter, you have to configure a local interpreter. To support debug, the interpreter have to support -e option and have luasocket in the path.

To configure an interpreter you just need the path of the interpreter executable, then you can set interpreter arguments and set some environment variables.

See below how to reference a Lua interpreter installed on your machine, and use it in LDT.

To open the Interpreters preference page go to Window > Preferences > Lua > Interpreters:

InterpreterPreferencePage 0.9.png

Then, press the Add... button to configure a new interpreter and fill in the fields as described here:

  • Leave the Interpreter type as Generic Lua.
  • You can browse your file system and locate your interpreter executable, or if the executable is in your PATH environment variable, just type its name here (e.g. lua),
  • Give a name to the interpreter (this is mandatory),
  • Add extra interpreter's arguments if needed, the same way you would on a regular command line,
  • Set environment variables for this interpreter. You can modify existing variables, or create new ones. Environment variables can be exported and imported using properties files.
AddInterpreter.png

Once you press the Ok button, the created interpreter appears in the Interpreters page. The checkbox in front of each interpreter allows to check the default interpreter used in launch configurations.

CreatedInterpreter.png

Configuring debug sessions

Local session

Create a Lua Application launch configuration in the Debug Configuration menu.

DebugConfiguration.png

In the Main tab, you can select the project, the script you want to launch and a Lua interpreter.

MainLocalLaunchConfig.png

In the Arguments tab, you can specify interpreter arguments and script arguments. The interpreter arguments will be merged to the ones specified at the interpreter level (in the interpreter preference page) at runtime.

ArgumentsLocalLaunchConfig.png

In the Environment tab, you can specify environment variables for runtime. Environment variable defined can be append

EnvironmentLocalLaunchConfig.png

In the Common tab, you can set some settings related to launch configurations:

  • Save current launch configuration in a specified file.
  • See in favorite menu the launch configuration is displayed.
  • Change the encoding of the launch configuration file.
  • Allocate standard input/output in a console and/or redirect standard output in a file.

Attach session

The Debugger of Lua Development Tools is based on the DBGp protocol, and the IDE implements a DBGp server.
To connect to this server, and begin remote/attach debugging, you need to use a DBGp Lua client.

Launching DBGp Client

The DBGp Lua client is a Lua file and can be downloaded through the lua Attach To Application launch configuration UI.

TODO add screenshot

It runs on Unix-like OS and Windows (XP and later). It is written in Lua and depends on lua-socket.
You can get Lua on http://www.lua.org/download.html and install lua-socket thanks to luarocks, or via your official OS repositories.
If for some reasons you can not use lua-socket, we did an abstraction of the communication layer so you could do your own implementation see
TODO add a link to abstract layer

To use it, you must have the debugger.lua file in your Lua path.
To begin the connection, you must execute this Lua code :

> local initconnection = require("debugger")
> initconnection(idehost, ideport, idekey,)

which can be shortened like this:

> require("debugger")(idehost, ideport, idekey)
  • idehost: the host name or the IP address of the DBGp server (thus, of your IDE).
    • if idehost is nil, the DBGP_IDEHOST environment variable is used.
    • if the environment variable is nil, the default value '127.0.0.1' is used.
  • ideport: the port of the DBGp server (must be configured in the IDE).
    • if ideport is nil, the DBGP_IDEPORT environment variable is used.
    • if the environment variable is nil, the default value '10000' is used.
  • idekey: a string which is used as session key (must be configured in the IDE).
    • if idekey is nil, the DBGP_IDEKEY environment variable is used.
    • if the environment variable is nil, the default value 'luaidekey' is used.

Advanced optional parameters :

  • transport: the module name of the transport abstraction used to do the connection with the server.
    • by default the debugger use the internal implementation based on luasocket, but if can not use it, you could implement or use another transport layer.
    • if transport is nil, the DBGP_TRANSPORT env var is used.
    • if the env var is nil, the default value 'debugger.transport.luasocket' is used : this is the default implementation based on luasocket.
  • platform: 'unix' or 'win32' string which define the kind of platform on which the program to debug is executed.
    • by default the debugger will try to guess it and surely success, if for some reasons it fails you could help it by precise the execution platform.
    • if platform is nil, the DBGP_PLATFORM env var is used.
    • if the env var is nil, the debugger will try to guess it.
  • workingdir: the working directory in which the program to debug is executed.
    • by default the debugger will try to guess it and surely success, if for some reasons it fails you could help it by precise the working directory.
    • if workingdir is nil, the DBGP_WORKINGDIR env var is used.
    • if the env var is nil, the debugger will try to guess it

So, to debug any Lua script, you can do:

lua -e "require('debugger')("idehost","ideport");" MyApp.lua

or even just go with:

lua -e "require('debugger')();" MyApp.lua

if you want to rely on default values for the debug host and port (which should be 127.0.0.1:10000 if you didn't tweak any DBGP_* environment variable).

Idea.png
console output
Some console output problems could happen because of buffer configuration. To force the stdout buffer to be flush at each call of print your should add this line io.stdout:setvbuf("line");

The full line should look like that :

lua -e "io.stdout:setvbuf('line'); require('debugger')();" MyApp.lua


Setup DBGp Server

The DBGp Server is integrated in LDT.
In order to accept incoming debug sessions, you must create a new Lua Attach to Application launch configuration, then launch it.

Go in Run/Debug Configurations....

LaunchConfiguration.png
  • Project: Set the LDT project in your workspace which includes the Lua source file(s) of the application you want to debug.
  • IdeKey: Default value is luaidekey, if you need to debug more than one application at the same time, you should change it to associate a launch configuration with only one application to debug.
  • Source Mapping: Define a common way for DBGp Server (IDE) and DBGp Client (running application) to identify source file. There are several strategy, each more or less adapted to a specific used case. To better understand it, see the advanced documentation on it.

Now you can start your debug session by clicking Debug. IDE will wait for an incoming connection from the debugger client, on the port you can see in the debug view. By default the port used is 10000, but if it is taken, another one may be used.

DebugView.png

If needed, you can change the server port, in Window > Preferences > Dynamic Languages > Debug.

DebugUI.png

Remote session

As the remote debugging is an advanced feature not require to most of the Lua developments, the remote debbugging not delivred with LDT and have to be downloaded and installed on top of LDT. To install the LDT remote feature, first select the top menu Help/Install New Software...

InstallSoftware.png

On the LDT update site select the remote feature in the list and install it. (see [documentation about update site])

RemoteFeature.png

In the Remote System Explorer perspective, in the new wizard, create a new Connection and select the Lua Ssh System kind of system.

CreateConnexion.png

On the next page, enter the network name of your remote system, or directly the IP address.

CreateConnexionEnterIP.png

If needed, configure runtime paths in ssh-lua sub-system advanced properties, if paths are not configured, the remote sytems's environment variables will be used. To change the properties, select the ssh lua node of your connection, then in the property view bellow push the show advanced properties button. You can edit properties values by selecting the appropriate cell. If you let some properties empty, the remote system lua default will be used. Warning, LDT is not able to retrieve environement variables specfied in the user scope. For exemple, if the variable LUA_PATH is modified in the .profile or .bashrc files of the remote user, on runtime theses modifications may not be taken into account.

RemoteConnection.png

In the top menu, select Run/Debug Configuration....

DebugConfiguration.png

Then, create a Remote Lua Application launch configuration. Configure the project and the script to run, select also the remote system.

RemoteLaunchConf.png

Following tab are also provided to configure your launch configuration: Arguments: you can here specify script and remote interpreter arguments, type the arguments as you would in command line. At the bottom of the tab, you can also edit the location where Lua files will be copied on the remote system, an absolute path is mandatory. Environment: Specify here some environement variables for runtime. Theses variables will be added to remote system's existing environement variables. Warning, as explained above, LDT is not able to retrieve environement variables values specfied in the user scope. Common: Some common launch configuration related settings.

  • Save current launch configuration in a specified file.
  • See in favorite menu the launch conf is displayed.
  • Change the encoding of the launch configuration file.
  • Allocates standard input/output in a console and/or redirects standard output in a file.

Launch the debug session, see how [Debugging a Lua program] to continue.


Debugging a Lua program

Breakpoints, code navigation

You can set breakpoints at a particular file/line, you can do it with the regular double-click on margin:

Dbg-setbreakpoint.png

You can optionally indicate conditions to stop execution only under specific circumstances:

Dbg-openproperties.png
Dbg-properties.png
  1. Enables or disables breakpoint globally.
  2. Condition on hit count (stop only after the 3rd hit, every 4 hits, etc.).
  3. Conditional breakpoint: you can put any expression, it will be evaluated using the local scope every time the breakpoint is hit, and stop only when the expression evaluates to true.

Once a breakpoint has been hit, and the execution has actually stopped, you can use the Step Into, Step Over and Step Return commands.

Idea.png
Coroutine handling
When the current instruction is a coroutine.yield or a coroutine.resume step over will jump over the coroutine until the next resume or yield whereas step into will go into the coroutine and re-break as soon as possible.


Environment inspection

When a breakpoint is reached, you can see any variable visible from any stack frame (local, upvalue and global variables). You can also change values to another.

Dbg-variables.png
Idea.png
New values are expressions
When you set a new value, it is evaluated as an expression, so math.sqrt will be evaluated to a function, if you want to put a literal string, use Lua syntax: "math.sqrt". In particular you can change an entire table by another table expression. This is sometimes powerful and sometimes dangerous, be careful with that.


Some special values can also be displayed such as metatables or function environments (if it is different from global environment). You can also change these values.

Interactive console and expressions

In addition to variable view, you have two other useful tools to evaluate some code snippets: expressions view and interactive console.

The expressions view allows you to re-evaluate complex expressions at each step
The interactive console allows you to type statements under the local scope
Warning2.png
Always on top level
Due to a limitation in the DBGp protocol, the interactive console and expressions are always mapped to the top stack frame


Source Mapping

The DBGp Server (IDE) and the DBGp client (running application) need to communicate about source files.

E.g. When you set a breakpoint, the IDE need to say to the running application on which file the breakpoint must be added.

E.g. When the running application stops on a breakpoint of a file, the IDE must retrieve the file and open it.

The problem is that the file executed in your Lua VM could be physically different than the source file in your IDE (in your workspace). For example, in the case where your code is executed on a different host or just if your executed code is duplicated in another folder.

To resolve this problem, LDT proposes to you different strategies, each with advantages and drawbacks :

  • Local Resolution

This way to resolve the source mapping is the more simple and the more reliable. Both client and server works with absolute path. The IDE will search only in its buildpath a file which have the given absolute path. This means that executed file should be in your workspace (in your buildpath more exactly). So you can not use it to debug code on a remote host.

  • Module Resolution

Both IDE and application have their own way to retrieve a module from its name. So we could use the module name has file ID instead of path. With this mode, you could do remote debugging without setting a list o f path mapping. The limitation is that you should use the standard LUA_PATH way to load module. Another problem is that we could not really retrieve the module name at client side, because the Lua debug API uses source pathes. The module name is retrieved from the path (from debug.getinfo) and the LUA_PATH (package.path), so with ambiguous LUA_PATH you could have insolvable conflict.
E.g: with package.path = "/foo/bar/?.lua, /foo/?.lua" and debug.getinfo="@/foo/bar/baz.lua" the possible module name is bar.baz or baz
There are no way to know the real module name, in this case the debugger will use the shorter one, but the ideal is to avoid ambiguous LUA_PATH with this mode.

  • Replace path Resolution

This mode is a fallback. If the two previous one don't fit your needs, you could try it. In this mode, client talks with absolute path and server (IDE) uses relative path (relative to the buildpath). A path must be set in launchconfiguration to move from one world to another.

e.g: You set path with "/foo/bar/".
when file path is sent from client (/foo/bar/baz/qux.lua), path will be removed (baz/qux.lua) and a file with this relative path will be searched in your buildpath.
when file path is sent from server (baz/qux.lua), path will be add (/foo/bar/baz/qux.lua) and the absolute path will be sent to the client

The problem is that you could set only one path.
The path comparison is case sensitive (even on windows).
On windows, you should prefix your path with "/" (e.g. /C:/foo/bar/)

In all case, if file is not found in the workspace, the source code is sent via the DBGp protocol

Unsupported features

The dynamic code is not supported, it means that any code that is loaded with load, loadstring will not be supported. The debugger will step over it just like a C function.

The debugger is officially supported for Lua VM 5.1. Any other implementation (Lua 5.2, LuaJIT, ...) is not guaranteed to work at this time.

Back to the top